shithub: lwext4

Download patch

ref: 3b136f8a7036606a9e6c130ee292da2a9ae39123
parent: e299c8d66002d6b9c8d77b3c6c3247e0915fd8c6
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Wed Dec 16 05:45:24 EST 2015

ext4_bcache: add new flag BC_FLUSH.

--- a/lwext4/ext4_bcache.c
+++ b/lwext4/ext4_bcache.c
@@ -233,10 +233,13 @@
 		RB_INSERT(ext4_buf_lru, &bc->lru_root, buf);
 		/* This buffer is ready to be flushed. */
 		if (ext4_bcache_test_flag(buf, BC_DIRTY)) {
-			if (bc->bdev->cache_write_back)
+			if (bc->bdev->cache_write_back &&
+			    !ext4_bcache_test_flag(buf, BC_FLUSH))
 				ext4_bcache_insert_dirty_node(bc, buf);
-			else
+			else {
 				ext4_block_flush_buf(bc->bdev, buf);
+				ext4_bcache_clear_flag(buf, BC_FLUSH);
+			}
 		}
 
 		/* The buffer is invalidated...drop it. */
--- a/lwext4/ext4_bcache.h
+++ b/lwext4/ext4_bcache.h
@@ -142,9 +142,17 @@
 	SLIST_HEAD(ext4_buf_dirty, ext4_buf) dirty_list;
 };
 
+/**@brief buffer state bits
+ *
+ *  - BC♡UPTODATE: Buffer contains valid data.
+ *  - BC_DIRTY: Buffer is dirty.
+ *  - BC_FLUSH: Buffer will be immediately flushed,
+ *              when no one references it.
+ */
 enum bcache_state_bits {
 	BC_UPTODATE,
-	BC_DIRTY
+	BC_DIRTY,
+	BC_FLUSH
 };
 
 #define ext4_bcache_set_flag(buf, b)    \