summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngkaho1234 <ngkaho1234@gmail.com>2015-11-08 10:18:23 +0000
committergkostka <kostka.grzegorz@gmail.com>2015-11-08 14:51:53 +0100
commitc6ffd2afb2caae418021acfeb7b2737822a76897 (patch)
tree2ae2bfbc111239fe87345eab7892a262b446b0c7
parenta4db81436916151e5a820b5848e420b5ac6f1295 (diff)
Add comments on the introduction of up-to-date flag
-rw-r--r--lwext4/ext4_bcache.c4
-rw-r--r--lwext4/ext4_blockdev.c6
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*/