Changes in uspace/lib/libblock/libblock.c [64bc4b6:08232ee] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
r64bc4b6 r08232ee 198 198 assert(devcon); 199 199 200 if (devcon->cache)201 (void) block_cache_fini(dev_handle);202 203 200 devcon_remove(devcon); 204 201 205 202 if (devcon->bb_buf) 206 203 free(devcon->bb_buf); 204 205 if (devcon->cache) { 206 hash_table_destroy(&devcon->cache->block_hash); 207 free(devcon->cache); 208 } 207 209 208 210 munmap(devcon->comm_area, devcon->comm_size); … … 300 302 301 303 devcon->cache = cache; 302 return EOK;303 }304 305 int block_cache_fini(dev_handle_t dev_handle)306 {307 devcon_t *devcon = devcon_search(dev_handle);308 cache_t *cache;309 int rc;310 311 if (!devcon)312 return ENOENT;313 if (!devcon->cache)314 return EOK;315 cache = devcon->cache;316 317 /*318 * We are expecting to find all blocks for this device handle on the319 * free list, i.e. the block reference count should be zero. Do not320 * bother with the cache and block locks because we are single-threaded.321 */322 while (!list_empty(&cache->free_head)) {323 block_t *b = list_get_instance(cache->free_head.next,324 block_t, free_link);325 326 list_remove(&b->free_link);327 if (b->dirty) {328 memcpy(devcon->comm_area, b->data, b->size);329 rc = write_blocks(devcon, b->boff, 1);330 if (rc != EOK)331 return rc;332 }333 334 long key = b->boff;335 hash_table_remove(&cache->block_hash, &key, 1);336 337 free(b->data);338 free(b);339 }340 341 hash_table_destroy(&cache->block_hash);342 devcon->cache = NULL;343 free(cache);344 345 304 return EOK; 346 305 }
Note:
See TracChangeset
for help on using the changeset viewer.