diff options
| -rw-r--r-- | lwext4/ext4_bcache.c | 4 | ||||
| -rw-r--r-- | lwext4/ext4_blockdev.c | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lwext4/ext4_bcache.c b/lwext4/ext4_bcache.c index 165cd8a..07c60e2 100644 --- a/lwext4/ext4_bcache.c +++ b/lwext4/ext4_bcache.c @@ -115,6 +115,8 @@ int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, /*Set valid cache data and id*/ b->data = bc->data + i * bc->itemsize; b->cache_id = i; + + /* If data in the caxhe is up-to-date */ b->uptodate = ext4_bcache_test_flag(bc, i, BC_UPTODATE); return EOK; @@ -155,6 +157,8 @@ int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, /*Set valid cache data and id*/ b->data = bc->data + cache_id * bc->itemsize; b->cache_id = cache_id; + + /* Data in the cache is not up-to-date anymore. */ ext4_bcache_clear_flag(bc, cache_id, BC_UPTODATE); b->uptodate = false; diff --git a/lwext4/ext4_blockdev.c b/lwext4/ext4_blockdev.c index f266618..5c55975 100644 --- a/lwext4/ext4_blockdev.c +++ b/lwext4/ext4_blockdev.c @@ -163,7 +163,8 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, return r; if (b->uptodate) { - /*Block is in cache. Read from physical device is not required*/ + /* Data in the cache is up-to-date. + * Reading from physical device is not required */ return EOK; } @@ -178,6 +179,8 @@ int ext4_block_get(struct ext4_blockdev *bdev, struct ext4_block *b, return r; } + /* Mark buffer up-to-date, since + * fresh data is read from physical device just now. */ ext4_bcache_set_flag(bdev->bc, b->cache_id, BC_UPTODATE); b->uptodate = true; bdev->bread_ctr++; @@ -205,6 +208,7 @@ int ext4_block_set(struct ext4_blockdev *bdev, struct ext4_block *b) ext4_bcache_free(bdev->bc, b, 0); return EOK; } + /* Data is valid, so mark buffer up-to-date. */ ext4_bcache_set_flag(bdev->bc, b->cache_id, BC_UPTODATE); /*Free cache delay mode*/ |
