Skip to contentSkip to conversation

f2fs: fix to set noatime and immutable flag for quota file

PATCH Applied Chao Yu 2 participants 2 messages May 27, 2023 – May 30, 2023 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH v3 1/1 f2fs: fix to set noatime and immutable flag for quota file

We should set noatime bit for quota files, since no one cares about atime of quota file, and we should set immutalbe bit as well, due to nobody should write to the file through exported interfaces.

Meanwhile this patch use inode_lock to avoid race condition during inode->i_flags, f2fs_inode->i_flags update.

---
v3:
- simply check condition suggested by Jaegeuk.

 fs/f2fs/super.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/f2fs/super.c +9 -0
index 51812f459581..8eb17cc73941 100644
@@ -2748,6 +2748,7 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id,
 {
 	struct inode *qf_inode;
 	unsigned long qf_inum;
+	unsigned long qf_flag = F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL;
 	int err;
 
 	BUG_ON(!f2fs_sb_has_quota_ino(F2FS_SB(sb)));
@@ -2763,7 +2764,15 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id,
 	}
 
 	/* Don't account quota for quota files to avoid recursion */
+	inode_lock(qf_inode);
 	qf_inode->i_flags |= S_NOQUOTA;
+
+	if ((F2FS_I(qf_inode)->i_flags & qf_flag) != qf_flag) {
+		F2FS_I(qf_inode)->i_flags |= qf_flag;
+		f2fs_set_inode_flags(qf_inode);
+	}
+	inode_unlock(qf_inode);
+
 	err = dquot_load_quota_inode(qf_inode, type, format_id, flags);
 	iput(qf_inode);
 	return err;
Signature · 1 line
2.40.1
#1 lore raw
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 8 lines · On Sat, 27 May 2023 08:15:39 +0800 you wrote:

We should set noatime bit for quota files, since no one cares about atime of quota file, and we should set immutalbe bit as well, due to nobody should write to the file through exported interfaces.

Meanwhile this patch use inode_lock to avoid race condition during inode->i_flags, f2fs_inode->i_flags update.

[...]

Here is the summary with links:
- [f2fs-dev,v3] f2fs: fix to set noatime and immutable flag for quota file

    https://git.kernel.org/jaegeuk/f2fs/c/cd2a3af38096

You are awesome, thank you!

Signature · 10 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




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