Skip to content

Commit

Permalink
f2fs: relocate inode_{,un}lock in F2FS_IOC_SETFLAGS
Browse files Browse the repository at this point in the history
This patch expands cover region of inode->i_rwsem to keep setting flag
atomically.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed May 3, 2017
1 parent 3adc5fc commit a72d4b9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,10 +1473,10 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg)
if (ret)
return ret;

flags = f2fs_mask_flags(inode->i_mode, flags);

inode_lock(inode);

flags = f2fs_mask_flags(inode->i_mode, flags);

oldflags = fi->i_flags;

if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
Expand All @@ -1490,10 +1490,11 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg)
flags = flags & FS_FL_USER_MODIFIABLE;
flags |= oldflags & ~FS_FL_USER_MODIFIABLE;
fi->i_flags = flags;
inode_unlock(inode);

inode->i_ctime = current_time(inode);
f2fs_set_inode_flags(inode);

inode_unlock(inode);
out:
mnt_drop_write_file(filp);
return ret;
Expand Down

0 comments on commit a72d4b9

Please sign in to comment.