diff mbox series

fs: ext4: skip journal state if fs has metadata_csum

Message ID 20200422104344.87714-1-arnaud.ferraris@collabora.com
State Accepted
Commit 7683b11098ded5087138d84e2e85078335a0cb72
Headers show
Series fs: ext4: skip journal state if fs has metadata_csum | expand

Commit Message

Arnaud Ferraris April 22, 2020, 10:43 a.m. UTC
As u-boot doesn't support the metadata_csum feature, writing to a
filesystem with this feature enabled will fail, as expected. However,
during the process, a journal state check is performed, which could
result in:
  - a fs recovery if the fs wasn't umounted properly
  - the fs being marked dirty

Both these cases result in a superblock change, leading to a mismatch
between the superblock checksum and its contents. Therefore, Linux will
consider the filesystem heavily corrupted and will require e2fsck to be
run manually to boot.

By bypassing the journal state check, this patch ensures the superblock
won't be corrupted if the filesystem has metadata_csum feature enabled.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris at collabora.com>
---

 fs/ext4/ext4_journal.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tom Rini April 28, 2020, 1:54 p.m. UTC | #1
On Wed, Apr 22, 2020 at 12:43:44PM +0200, Arnaud Ferraris wrote:

> As u-boot doesn't support the metadata_csum feature, writing to a
> filesystem with this feature enabled will fail, as expected. However,
> during the process, a journal state check is performed, which could
> result in:
>   - a fs recovery if the fs wasn't umounted properly
>   - the fs being marked dirty
> 
> Both these cases result in a superblock change, leading to a mismatch
> between the superblock checksum and its contents. Therefore, Linux will
> consider the filesystem heavily corrupted and will require e2fsck to be
> run manually to boot.
> 
> By bypassing the journal state check, this patch ensures the superblock
> won't be corrupted if the filesystem has metadata_csum feature enabled.
> 
> Signed-off-by: Arnaud Ferraris <arnaud.ferraris at collabora.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c
index 3559daf11d..f8524e5a99 100644
--- a/fs/ext4/ext4_journal.c
+++ b/fs/ext4/ext4_journal.c
@@ -409,6 +409,9 @@  int ext4fs_check_journal_state(int recovery_flag)
 	char *temp_buff1 = NULL;
 	struct ext_filesystem *fs = get_fs();
 
+	if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
+		return 0;
+
 	temp_buff = zalloc(fs->blksz);
 	if (!temp_buff)
 		return -ENOMEM;