Changeset 1fbe064b in mainline
- Timestamp:
- 2009-06-26T21:34:47Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00fe6bb
- Parents:
- af65b72
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/bdd/bdd.c
raf65b72 r1fbe064b 103 103 } 104 104 105 rc = block_cache_init(handle, BLOCK_SIZE, 2 );105 rc = block_cache_init(handle, BLOCK_SIZE, 2, CACHE_MODE_WB); 106 106 if (rc != EOK) { 107 107 printf("Error: could not init block cache.\n"); -
uspace/lib/libblock/libblock.c
raf65b72 r1fbe064b 66 66 hash_table_t block_hash; 67 67 link_t free_head; 68 enum cache_mode mode; 68 69 } cache_t; 69 70 … … 80 81 } devcon_t; 81 82 83 static int write_block(devcon_t *devcon, bn_t boff, size_t block_size, 84 const void *src); 85 82 86 static devcon_t *devcon_search(dev_handle_t dev_handle) 83 87 { … … 251 255 }; 252 256 253 int block_cache_init(dev_handle_t dev_handle, size_t size, unsigned blocks) 257 int block_cache_init(dev_handle_t dev_handle, size_t size, unsigned blocks, 258 enum cache_mode mode) 254 259 { 255 260 devcon_t *devcon = devcon_search(dev_handle); … … 267 272 cache->block_size = size; 268 273 cache->block_count = blocks; 274 cache->mode = mode; 269 275 270 276 if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1, … … 414 420 devcon_t *devcon = devcon_search(block->dev_handle); 415 421 cache_t *cache; 422 int rc; 416 423 417 424 assert(devcon); … … 427 434 */ 428 435 list_append(&block->free_link, &cache->free_head); 436 if (cache->mode != CACHE_MODE_WB && block->dirty) { 437 rc = write_block(devcon, block->boff, block->size, 438 block->data); 439 assert(rc == EOK); 440 441 block->dirty = false; 442 } 429 443 } 430 444 fibril_mutex_unlock(&block->lock); … … 491 505 } 492 506 507 /** Write block to block device. 508 * 509 * @param devcon Device connection. 510 * @param boff Block index. 511 * @param block_size Block size. 512 * @param src Buffer containing the data to write. 513 * 514 * @return EOK on success or negative error code on failure. 515 */ 516 static int write_block(devcon_t *devcon, bn_t boff, size_t block_size, 517 const void *src) 518 { 519 ipcarg_t retval; 520 int rc; 521 522 assert(devcon); 523 memcpy(devcon->com_area, src, block_size); 524 525 rc = async_req_2_1(devcon->dev_phone, BD_WRITE_BLOCK, 526 boff, block_size, &retval); 527 if ((rc != EOK) || (retval != EOK)) 528 return (rc != EOK ? rc : (int) retval); 529 530 return EOK; 531 } 532 493 533 /** @} 494 534 */ -
uspace/lib/libblock/libblock.h
raf65b72 r1fbe064b 85 85 } block_t; 86 86 87 /** Caching mode */ 88 enum cache_mode { 89 /** Write-Through */ 90 CACHE_MODE_WT, 91 /** Write-Back */ 92 CACHE_MODE_WB 93 }; 94 87 95 extern int block_init(dev_handle_t, size_t); 88 96 extern void block_fini(dev_handle_t); … … 91 99 extern void *block_bb_get(dev_handle_t); 92 100 93 extern int block_cache_init(dev_handle_t, size_t, unsigned );101 extern int block_cache_init(dev_handle_t, size_t, unsigned, enum cache_mode); 94 102 95 103 extern block_t *block_get(dev_handle_t, bn_t, int flags); -
uspace/srv/fs/fat/fat_ops.c
raf65b72 r1fbe064b 771 771 { 772 772 dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); 773 enum cache_mode cmode; 773 774 fat_bs_t *bs; 774 775 uint16_t bps; … … 798 799 opts[size] = '\0'; 799 800 801 /* Check for option enabling write through. */ 802 if (str_cmp(opts, "wtcache") == 0) 803 cmode = CACHE_MODE_WT; 804 else 805 cmode = CACHE_MODE_WB; 806 800 807 /* initialize libblock */ 801 808 rc = block_init(dev_handle, BS_SIZE); … … 827 834 828 835 /* Initialize the block cache */ 829 rc = block_cache_init(dev_handle, bps, 0 /* XXX */ );836 rc = block_cache_init(dev_handle, bps, 0 /* XXX */, cmode); 830 837 if (rc != EOK) { 831 838 block_fini(dev_handle);
Note:
See TracChangeset
for help on using the changeset viewer.