Skip to contentSkip to conversation

btrfs: make sure SB_I_VERSION doesn't get unset by remount

PATCH In review Josef Bacik 2 participants 2 messages Jul 30, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: make sure SB_I_VERSION doesn't get unset by remount

There's some inconsistency around SB_I_VERSION handling with mount and remount. Since we don't really want it to be off ever just work around this by making sure we don't get the flag cleared on remount.

---
 fs/btrfs/super.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/btrfs/super.c +6 -0
index 5bcdad3ee258..0a9d8b7664f7 100644
@@ -1960,6 +1960,12 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 		set_bit(BTRFS_FS_OPEN, &fs_info->flags);
 	}
 out:
+	/*
+	 * We need to set S_I_VERSION here otherwise it'll get cleared by VFS,
+	 * since the absence of the flag means it can be toggled off by remount.
+	 */
+	*flags |= SB_I_VERSION;
+
 	wake_up_process(fs_info->transaction_kthread);
 	btrfs_remount_cleanup(fs_info, old_opts);
 	clear_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
Signature · 1 line
2.24.1
#1 lore raw
Quoted 3 lines · Josef Bacik

There's some inconsistency around SB_I_VERSION handling with mount and remount. Since we don't really want it to be off ever just work around this by making sure we don't get the flag cleared on remount.

Agreed. There's a tiny cpu cost of setting the bit, otherwise all changes to i_version also change some of the times (ctime/mtime) so the inode needs to be synced. We wouldn't save anything by disabling it.