Changeset cac458f in mainline for uspace/lib/block/libblock.c
- Timestamp:
- 2011-06-22T01:59:39Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41e2118
- Parents:
- 79506d6 (diff), f1fae414 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r79506d6 rcac458f 60 60 static FIBRIL_MUTEX_INITIALIZE(dcl_lock); 61 61 /** Device connection list head. */ 62 static LIST_INITIALIZE(dcl _head);62 static LIST_INITIALIZE(dcl); 63 63 64 64 #define CACHE_BUCKETS_LOG2 10 … … 72 72 unsigned blocks_cached; /**< Number of cached blocks. */ 73 73 hash_table_t block_hash; 74 li nk_t free_head;74 list_t free_list; 75 75 enum cache_mode mode; 76 76 } cache_t; … … 97 97 static devcon_t *devcon_search(devmap_handle_t devmap_handle) 98 98 { 99 link_t *cur;100 101 99 fibril_mutex_lock(&dcl_lock); 102 100 103 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {101 list_foreach(dcl, cur) { 104 102 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 105 103 if (devcon->devmap_handle == devmap_handle) { … … 116 114 size_t bsize, void *comm_area, size_t comm_size) 117 115 { 118 link_t *cur;119 116 devcon_t *devcon; 120 117 … … 138 135 139 136 fibril_mutex_lock(&dcl_lock); 140 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {137 list_foreach(dcl, cur) { 141 138 devcon_t *d = list_get_instance(cur, devcon_t, link); 142 139 if (d->devmap_handle == devmap_handle) { … … 146 143 } 147 144 } 148 list_append(&devcon->link, &dcl _head);145 list_append(&devcon->link, &dcl); 149 146 fibril_mutex_unlock(&dcl_lock); 150 147 return EOK; … … 294 291 295 292 fibril_mutex_initialize(&cache->lock); 296 list_initialize(&cache->free_ head);293 list_initialize(&cache->free_list); 297 294 cache->lblock_size = size; 298 295 cache->block_count = blocks; … … 335 332 * bother with the cache and block locks because we are single-threaded. 336 333 */ 337 while (!list_empty(&cache->free_ head)) {338 block_t *b = list_get_instance( cache->free_head.next,334 while (!list_empty(&cache->free_list)) { 335 block_t *b = list_get_instance(list_first(&cache->free_list), 339 336 block_t, free_link); 340 337 … … 367 364 if (cache->blocks_cached < CACHE_LO_WATERMARK) 368 365 return true; 369 if (!list_empty(&cache->free_ head))366 if (!list_empty(&cache->free_list)) 370 367 return false; 371 368 return true; … … 456 453 unsigned long temp_key; 457 454 recycle: 458 if (list_empty(&cache->free_ head)) {455 if (list_empty(&cache->free_list)) { 459 456 fibril_mutex_unlock(&cache->lock); 460 457 rc = ENOMEM; 461 458 goto out; 462 459 } 463 l = cache->free_head.next;460 l = list_first(&cache->free_list); 464 461 b = list_get_instance(l, block_t, free_link); 465 462 … … 476 473 */ 477 474 list_remove(&b->free_link); 478 list_append(&b->free_link, &cache->free_ head);475 list_append(&b->free_link, &cache->free_list); 479 476 fibril_mutex_unlock(&cache->lock); 480 477 fibril_mutex_lock(&devcon->comm_area_lock); … … 668 665 goto retry; 669 666 } 670 list_append(&block->free_link, &cache->free_ head);667 list_append(&block->free_link, &cache->free_list); 671 668 } 672 669 fibril_mutex_unlock(&block->lock);
Note:
See TracChangeset
for help on using the changeset viewer.