shithub: lwext4

Download patch

ref: 2a5abdbf8c1375f83edde31831cd8b0bb36bc6d8
parent: d480c36c2b0ca911db32f94d83e6ec56fb03331b
author: ngkaho1234 <[email protected]>
date: Thu Apr 28 13:31:33 EDT 2016

ext4_journal: fix not wrapping blocks when recovering.

--- a/src/ext4_journal.c
+++ b/src/ext4_journal.c
@@ -96,6 +96,14 @@
 	uint32_t this_trans_id;
 };
 
+/* Make sure we wrap around the log correctly! */
+#define wrap(sb, var)						\
+do {									\
+	if (var >= jbd_get32((sb), maxlen))					\
+		var -= (jbd_get32((sb), maxlen) - jbd_get32((sb), first));	\
+} while (0)
+
+
 static int
 jbd_revoke_entry_cmp(struct revoke_entry *a, struct revoke_entry *b)
 {
@@ -816,6 +824,7 @@
 	uint32_t *iblock = arg;
 	ext4_dbg(DEBUG_JBD, "Block in block_tag: %" PRIu64 "\n", block);
 	(*iblock)++;
+	wrap(&jbd_fs->sb, *iblock);
 	(void)jbd_fs;
 	(void)uuid;
 	return;
@@ -848,6 +857,7 @@
 	struct ext4_fs *fs = jbd_fs->inode_ref.fs;
 
 	(*this_block)++;
+	wrap(&jbd_fs->sb, *this_block);
 
 	/* We replay this block only if the current transaction id
 	 * is equal or greater than that in revoke entry.*/
@@ -940,12 +950,6 @@
 	}
 }
 
-/* Make sure we wrap around the log correctly! */
-#define wrap(sb, var)						\
-do {									\
-	if (var >= jbd_get32((sb), maxlen))					\
-		var -= (jbd_get32((sb), maxlen) - jbd_get32((sb), first));	\
-} while (0)
 
 #define ACTION_SCAN 0
 #define ACTION_REVOKE 1