shithub: lwext4

Download patch

ref: c6ffd2afb2caae418021acfeb7b2737822a76897
parent: a4db81436916151e5a820b5848e420b5ac6f1295
author: ngkaho1234 <[email protected]>
date: Sun Nov 8 05:18:23 EST 2015

Add comments on the introduction of up-to-date flag

--- a/lwext4/ext4_bcache.c
+++ b/lwext4/ext4_bcache.c
@@ -115,6 +115,8 @@
 			/*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 @@
 		/*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;
 
--- a/lwext4/ext4_blockdev.c
+++ b/lwext4/ext4_blockdev.c
@@ -163,7 +163,8 @@
 		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 @@
 		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 @@
 		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*/