shithub: lwext4

Download patch

ref: 45d2d1fe5e93955080c8c24cab765d368402f6a2
parent: 4f5c65dc000b46989df352adbafcd8d264f16a3c
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Mon Dec 14 18:26:32 EST 2015

ext4_journal: handle EXT4_FINCOM_RECOVER flag properly.

--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -761,6 +761,8 @@
 			   features_incompatible,
 			   features_incompatible);
 		jbd_fs->dirty = true;
+		r = ext4_sb_write(jbd_fs->inode_ref.fs->bdev,
+				  &jbd_fs->inode_ref.fs->sb);
 	}
 	jbd_destroy_revoke_tree(&info);
 	return r;
@@ -777,6 +779,19 @@
 int jbd_journal_start(struct jbd_fs *jbd_fs,
 		      struct jbd_journal *journal)
 {
+	int r;
+	uint32_t features_incompatible =
+			ext4_get32(&jbd_fs->inode_ref.fs->sb,
+				   features_incompatible);
+	features_incompatible |= EXT4_FINCOM_RECOVER;
+	ext4_set32(&jbd_fs->inode_ref.fs->sb,
+			features_incompatible,
+			features_incompatible);
+	r = ext4_sb_write(jbd_fs->inode_ref.fs->bdev,
+			&jbd_fs->inode_ref.fs->sb);
+	if (r != EOK)
+		return r;
+
 	journal->first = jbd_get32(&jbd_fs->sb, first);
 	journal->start = journal->first;
 	journal->last = journal->first;
@@ -794,6 +809,20 @@
 
 int jbd_journal_stop(struct jbd_journal *journal)
 {
+	int r;
+	struct jbd_fs *jbd_fs = journal->jbd_fs;
+	uint32_t features_incompatible =
+			ext4_get32(&jbd_fs->inode_ref.fs->sb,
+				   features_incompatible);
+	features_incompatible &= ~EXT4_FINCOM_RECOVER;
+	ext4_set32(&jbd_fs->inode_ref.fs->sb,
+			features_incompatible,
+			features_incompatible);
+	r = ext4_sb_write(jbd_fs->inode_ref.fs->bdev,
+			&jbd_fs->inode_ref.fs->sb);
+	if (r != EOK)
+		return r;
+
 	journal->start = 0;
 	journal->trans_id = 0;
 	jbd_journal_write_sb(journal);