summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2017-03-10 17:55:07 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2017-03-21 22:34:30 -0400
commitd7563861722a471cf0ca348b00fa7a1c34507dea (patch)
tree928a593a933878aa755d8793053fd259e80c059c
parent46e82fb1b5349e75d8e64df40760f5f5a46bd80f (diff)
f2fs: move mnt_want_write_file after arguments checking
It's needless of mnt_want_write_file for arguments checking. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/file.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index bc853dd9b7a3..22c73b205cd7 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2037,45 +2037,37 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg)
if (!S_ISREG(inode->i_mode))
return -EINVAL;
- err = mnt_want_write_file(filp);
- if (err)
- return err;
-
- if (f2fs_readonly(sbi->sb)) {
- err = -EROFS;
- goto out;
- }
+ if (f2fs_readonly(sbi->sb))
+ return -EROFS;
if (copy_from_user(&range, (struct f2fs_defragment __user *)arg,
- sizeof(range))) {
- err = -EFAULT;
- goto out;
- }
+ sizeof(range)))
+ return -EFAULT;
/* verify alignment of offset & size */
- if (range.start & (F2FS_BLKSIZE - 1) ||
- range.len & (F2FS_BLKSIZE - 1)) {
- err = -EINVAL;
- goto out;
- }
+ if (range.start & (F2FS_BLKSIZE - 1) || range.len & (F2FS_BLKSIZE - 1))
+ return -EINVAL;
if (unlikely((range.start + range.len) >> PAGE_SHIFT >
- sbi->max_file_blocks)) {
- err = -EINVAL;
- goto out;
- }
+ sbi->max_file_blocks))
+ return -EINVAL;
+
+ err = mnt_want_write_file(filp);
+ if (err)
+ return err;
err = f2fs_defragment_range(sbi, filp, &range);
+ mnt_drop_write_file(filp);
+
f2fs_update_time(sbi, REQ_TIME);
if (err < 0)
- goto out;
+ return err;
if (copy_to_user((struct f2fs_defragment __user *)arg, &range,
sizeof(range)))
- err = -EFAULT;
-out:
- mnt_drop_write_file(filp);
- return err;
+ return -EFAULT;
+
+ return 0;
}
static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,