Changes in uspace/lib/block/libblock.c [b72efe8:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
rb72efe8 r79ae36dd 60 60 static FIBRIL_MUTEX_INITIALIZE(dcl_lock); 61 61 /** Device connection list head. */ 62 static LIST_INITIALIZE(dcl );62 static LIST_INITIALIZE(dcl_head); 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 st_t free_list;74 link_t free_head; 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 99 101 fibril_mutex_lock(&dcl_lock); 100 102 101 list_foreach(dcl, cur) {103 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 102 104 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 103 105 if (devcon->devmap_handle == devmap_handle) { … … 114 116 size_t bsize, void *comm_area, size_t comm_size) 115 117 { 118 link_t *cur; 116 119 devcon_t *devcon; 117 120 … … 135 138 136 139 fibril_mutex_lock(&dcl_lock); 137 list_foreach(dcl, cur) {140 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 138 141 devcon_t *d = list_get_instance(cur, devcon_t, link); 139 142 if (d->devmap_handle == devmap_handle) { … … 143 146 } 144 147 } 145 list_append(&devcon->link, &dcl );148 list_append(&devcon->link, &dcl_head); 146 149 fibril_mutex_unlock(&dcl_lock); 147 150 return EOK; … … 291 294 292 295 fibril_mutex_initialize(&cache->lock); 293 list_initialize(&cache->free_ list);296 list_initialize(&cache->free_head); 294 297 cache->lblock_size = size; 295 298 cache->block_count = blocks; … … 332 335 * bother with the cache and block locks because we are single-threaded. 333 336 */ 334 while (!list_empty(&cache->free_ list)) {335 block_t *b = list_get_instance( list_first(&cache->free_list),337 while (!list_empty(&cache->free_head)) { 338 block_t *b = list_get_instance(cache->free_head.next, 336 339 block_t, free_link); 337 340 … … 364 367 if (cache->blocks_cached < CACHE_LO_WATERMARK) 365 368 return true; 366 if (!list_empty(&cache->free_ list))369 if (!list_empty(&cache->free_head)) 367 370 return false; 368 371 return true; … … 453 456 unsigned long temp_key; 454 457 recycle: 455 if (list_empty(&cache->free_ list)) {458 if (list_empty(&cache->free_head)) { 456 459 fibril_mutex_unlock(&cache->lock); 457 460 rc = ENOMEM; 458 461 goto out; 459 462 } 460 l = list_first(&cache->free_list);463 l = cache->free_head.next; 461 464 b = list_get_instance(l, block_t, free_link); 462 465 … … 473 476 */ 474 477 list_remove(&b->free_link); 475 list_append(&b->free_link, &cache->free_ list);478 list_append(&b->free_link, &cache->free_head); 476 479 fibril_mutex_unlock(&cache->lock); 477 480 fibril_mutex_lock(&devcon->comm_area_lock); … … 665 668 goto retry; 666 669 } 667 list_append(&block->free_link, &cache->free_ list);670 list_append(&block->free_link, &cache->free_head); 668 671 } 669 672 fibril_mutex_unlock(&block->lock);
Note:
See TracChangeset
for help on using the changeset viewer.