Skip to content

Commit

Permalink
f2fs: fix to set noatime and immutable flag for quota file
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
chaseyu authored and asuka-mio committed Sep 20, 2023
1 parent 4ad7bc3 commit 9bb1960
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,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)));
Expand All @@ -2761,7 +2762,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_enable(qf_inode, type, format_id, flags);
iput(qf_inode);
return err;
Expand Down

0 comments on commit 9bb1960

Please sign in to comment.