Changeset 402a18f in mainline
- Timestamp:
- 2009-08-27T19:57:03Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ff62c6d
- Parents:
- cd688d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libblock/libblock.c
rcd688d9 r402a18f 331 331 link_t *l; 332 332 unsigned long key = boff; 333 int rc = EOK; 333 334 334 335 devcon = devcon_search(dev_handle); … … 350 351 if (b->refcnt++ == 0) 351 352 list_remove(&b->free_link); 353 if (b->toxic) 354 rc = EIO; 352 355 fibril_mutex_unlock(&b->lock); 353 356 fibril_mutex_unlock(&cache->lock); … … 356 359 * The block was not found in the cache. 357 360 */ 358 int rc;359 360 361 if (cache_can_grow(cache)) { 361 362 /* … … 402 403 cache->block_size); 403 404 fibril_mutex_unlock(&devcon->com_area_lock); 404 assert(rc == EOK); 405 if (rc != EOK) { 406 /* 407 * We did not manage to write the block 408 * to the device. Keep it around for 409 * another try. Hopefully, we will grab 410 * another block next time. 411 */ 412 fibril_mutex_unlock(&b->lock); 413 goto retry; 414 } 405 415 b->dirty = false; 406 416 if (!fibril_mutex_trylock(&cache->lock)) { … … 446 456 fibril_mutex_lock(&devcon->com_area_lock); 447 457 rc = read_block(devcon, b->boff, cache->block_size); 448 assert(rc == EOK);449 458 memcpy(b->data, devcon->com_area, cache->block_size); 450 459 fibril_mutex_unlock(&devcon->com_area_lock); 451 } 460 if (rc != EOK) 461 b->toxic = true; 462 } else 463 rc = EOK; 452 464 453 465 fibril_mutex_unlock(&b->lock); 454 466 } 455 467 *block = b; 456 return EOK;468 return rc; 457 469 } 458 470 … … 471 483 unsigned blocks_cached; 472 484 enum cache_mode mode; 473 int rc ;485 int rc = EOK; 474 486 475 487 assert(devcon); … … 492 504 */ 493 505 fibril_mutex_lock(&block->lock); 506 if (block->toxic) 507 block->dirty = false; /* will not write back toxic block */ 494 508 if (block->dirty && (block->refcnt == 1) && 495 509 (blocks_cached > CACHE_HI_WATERMARK || mode != CACHE_MODE_WB)) { … … 497 511 memcpy(devcon->com_area, block->data, block->size); 498 512 rc = write_block(devcon, block->boff, block->size); 499 assert(rc == EOK);500 513 fibril_mutex_unlock(&devcon->com_area_lock); 501 514 block->dirty = false; … … 508 521 /* 509 522 * Last reference to the block was dropped. Either free the 510 * block or put it on the free list. 523 * block or put it on the free list. In case of an I/O error, 524 * free the block. 511 525 */ 512 if (cache->blocks_cached > CACHE_HI_WATERMARK) { 513 /* 514 * Currently there are too many cached blocks. 526 if ((cache->blocks_cached > CACHE_HI_WATERMARK) || 527 (rc != EOK)) { 528 /* 529 * Currently there are too many cached blocks or there 530 * was an I/O error when writing the block back to the 531 * device. 515 532 */ 516 533 if (block->dirty) { … … 533 550 cache->blocks_cached--; 534 551 fibril_mutex_unlock(&cache->lock); 535 return ;552 return rc; 536 553 } 537 554 /* … … 553 570 fibril_mutex_unlock(&cache->lock); 554 571 555 return EOK;572 return rc; 556 573 } 557 574
Note:
See TracChangeset
for help on using the changeset viewer.