f2fs: spread f2fs_set_inode_flags()
authorChao Yu <yuchao0@huawei.com>
Sun, 7 Oct 2018 11:06:15 +0000 (19:06 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 23 Oct 2018 00:54:47 +0000 (17:54 -0700)
This patch changes codes as below:
- use f2fs_set_inode_flags() to update i_flags atomically to avoid
potential race.
- synchronize F2FS_I(inode)->i_flags to inode->i_flags in
f2fs_new_inode().
- use f2fs_set_inode_flags() to simply codes in f2fs_quota_{on,off}.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/namei.c
fs/f2fs/super.c

index 7f9cb0bba104bc9c340cdefdadf28c9800b116c0..c25c67868b983416150a1904e39f17be8b085eef 100644 (file)
@@ -3422,7 +3422,7 @@ static inline void f2fs_set_encrypted_inode(struct inode *inode)
 {
 #ifdef CONFIG_F2FS_FS_ENCRYPTION
        file_set_encrypt(inode);
-       inode->i_flags |= S_ENCRYPTED;
+       f2fs_set_inode_flags(inode);
 #endif
 }
 
index a54577e417b156b5f33bfd01a765c4a3aacf20a7..54295b5c18229ef02a284c0314c0ba071737209c 100644 (file)
@@ -122,6 +122,8 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
        if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL)
                set_inode_flag(inode, FI_PROJ_INHERIT);
 
+       f2fs_set_inode_flags(inode);
+
        trace_f2fs_new_inode(inode, 0);
        return inode;
 
index 262a27744eb1f1debdaf38d7ff2d60544ac3fd6d..bb88ae62ae6f2de1efbe6e2dd7750638e4486033 100644 (file)
@@ -1939,8 +1939,7 @@ static int f2fs_quota_on(struct super_block *sb, int type, int format_id,
 
        inode_lock(inode);
        F2FS_I(inode)->i_flags |= F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL;
-       inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
-                                       S_NOATIME | S_IMMUTABLE);
+       f2fs_set_inode_flags(inode);
        inode_unlock(inode);
        f2fs_mark_inode_dirty_sync(inode, false);
 
@@ -1965,7 +1964,7 @@ static int f2fs_quota_off(struct super_block *sb, int type)
 
        inode_lock(inode);
        F2FS_I(inode)->i_flags &= ~(F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL);
-       inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
+       f2fs_set_inode_flags(inode);
        inode_unlock(inode);
        f2fs_mark_inode_dirty_sync(inode, false);
 out_put: