Skip to contentSkip to conversation

f2fs: avoid attaching SB_ACTIVE flag during mount

PATCH In review Chao Yu 2 participants 4 messages Sep 1, 2021 – Sep 10, 2021 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH v2 1/1 f2fs: avoid attaching SB_ACTIVE flag during mount

Quoted from [1]

"I do remember that I've added this code back then because otherwise orphan cleanup was losing updates to quota files. But you're right that now I don't see how that could be happening and it would be nice if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/[email protected]/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

---
v2:
- don't bother checkpoint disabling path

 fs/f2fs/checkpoint.c | 3 ---
 fs/f2fs/recovery.c   | 8 ++------
 2 files changed, 2 insertions(+), 9 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 83e9bc0f91ff..7d8803a4cbc2 100644
@@ -705,9 +705,6 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
 	}
 
 #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
-
 	/*
 	 * Turn on quotas which were not enabled for read-only mounts if
 	 * filesystem has quota feature, so that they are updated correctly.
fs/f2fs/recovery.c +2 -6
index 04655511d7f5..706ddb3c95c0 100644
@@ -787,8 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	}
 
 #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
 	/* Turn on quotas so that they are updated correctly */
 	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
 #endif
@@ -816,10 +814,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
 	if (!err)
 		f2fs_bug_on(sbi, !list_empty(&inode_list));
-	else {
-		/* restore s_flags to let iput() trash data */
-		sbi->sb->s_flags = s_flags;
-	}
+	else
+		f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
 skip:
 	fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
 
Signature · 8 lines
2.32.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw

I remember this gave a regression before?

Quoted 71 lines · Chao Yu

Quoted from [1]

"I do remember that I've added this code back then because otherwise orphan cleanup was losing updates to quota files. But you're right that now I don't see how that could be happening and it would be nice if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/[email protected]/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

---
v2:
- don't bother checkpoint disabling path

 fs/f2fs/checkpoint.c | 3 ---
 fs/f2fs/recovery.c   | 8 ++------
 2 files changed, 2 insertions(+), 9 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 83e9bc0f91ff..7d8803a4cbc2 100644
@@ -705,9 +705,6 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
 	}
 
 #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
-
 	/*
 	 * Turn on quotas which were not enabled for read-only mounts if
 	 * filesystem has quota feature, so that they are updated correctly.
fs/f2fs/recovery.c +2 -6
index 04655511d7f5..706ddb3c95c0 100644
@@ -787,8 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	}
 
 #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
 	/* Turn on quotas so that they are updated correctly */
 	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
 #endif
@@ -816,10 +814,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 	err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
 	if (!err)
 		f2fs_bug_on(sbi, !list_empty(&inode_list));
-	else {
-		/* restore s_flags to let iput() trash data */
-		sbi->sb->s_flags = s_flags;
-	}
+	else
+		f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
 skip:
 	fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
 
Signature · 1 line
2.32.0
author maintainer
#2 lore raw
Quoted 1 line · Jaegeuk Kim

I remember this gave a regression before?

I have removed changes which bothers checkpoint disabling path, how about testing this in dev-test branch for a while?

BTW, any plan to porting checkpoint disabling testcases from android into xfstest suit?

Thanks,

Quoted 73 lines · Chao Yu
Quoted 71 lines

Quoted from [1]

"I do remember that I've added this code back then because otherwise orphan cleanup was losing updates to quota files. But you're right that now I don't see how that could be happening and it would be nice if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/[email protected]/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

---
v2:
- don't bother checkpoint disabling path

  fs/f2fs/checkpoint.c | 3 ---
  fs/f2fs/recovery.c   | 8 ++------
  2 files changed, 2 insertions(+), 9 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 83e9bc0f91ff..7d8803a4cbc2 100644
@@ -705,9 +705,6 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
  	}
 
  #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
-
  	/*
  	 * Turn on quotas which were not enabled for read-only mounts if
  	 * filesystem has quota feature, so that they are updated correctly.
fs/f2fs/recovery.c +2 -6
index 04655511d7f5..706ddb3c95c0 100644
@@ -787,8 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	}
 
  #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
  	/* Turn on quotas so that they are updated correctly */
  	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
  #endif
@@ -816,10 +814,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
  	if (!err)
  		f2fs_bug_on(sbi, !list_empty(&inode_list));
-	else {
-		/* restore s_flags to let iput() trash data */
-		sbi->sb->s_flags = s_flags;
-	}
+	else
+		f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
  skip:
  	fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
 
Signature · 1 line
2.32.0
maintainer
#3 lore raw
Quoted 5 lines · Chao Yu
Quoted 1 line · Jaegeuk Kim

I remember this gave a regression before?

I have removed changes which bothers checkpoint disabling path, how about testing this in dev-test branch for a while?

Let me give it a try.

Quoted 3 lines

BTW, any plan to porting checkpoint disabling testcases from android into xfstest suit?

No.

Quoted 73 lines

Thanks,

Quoted 70 lines · Chao Yu
Quoted 68 lines

Quoted from [1]

"I do remember that I've added this code back then because otherwise orphan cleanup was losing updates to quota files. But you're right that now I don't see how that could be happening and it would be nice if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/[email protected]/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

---
v2:
- don't bother checkpoint disabling path

  fs/f2fs/checkpoint.c | 3 ---
  fs/f2fs/recovery.c   | 8 ++------
  2 files changed, 2 insertions(+), 9 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 83e9bc0f91ff..7d8803a4cbc2 100644
@@ -705,9 +705,6 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
  	}
  #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
-
  	/*
  	 * Turn on quotas which were not enabled for read-only mounts if
  	 * filesystem has quota feature, so that they are updated correctly.
fs/f2fs/recovery.c +2 -6
index 04655511d7f5..706ddb3c95c0 100644
@@ -787,8 +787,6 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	}
  #ifdef CONFIG_QUOTA
-	/* Needed for iput() to work correctly and not trash data */
-	sbi->sb->s_flags |= SB_ACTIVE;
  	/* Turn on quotas so that they are updated correctly */
  	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
  #endif
@@ -816,10 +814,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
  	err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
  	if (!err)
  		f2fs_bug_on(sbi, !list_empty(&inode_list));
-	else {
-		/* restore s_flags to let iput() trash data */
-		sbi->sb->s_flags = s_flags;
-	}
+	else
+		f2fs_bug_on(sbi, sbi->sb->s_flags & SB_ACTIVE);
  skip:
  	fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
Signature · 1 line
2.32.0