Commit d7563861 authored by Kinglong Mee's avatar Kinglong Mee Committed by Jaegeuk Kim

f2fs: move mnt_want_write_file after arguments checking

It's needless of mnt_want_write_file for arguments checking.
Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 46e82fb1
...@@ -2037,45 +2037,37 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg) ...@@ -2037,45 +2037,37 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg)
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return -EINVAL; return -EINVAL;
err = mnt_want_write_file(filp); if (f2fs_readonly(sbi->sb))
if (err) return -EROFS;
return err;
if (f2fs_readonly(sbi->sb)) {
err = -EROFS;
goto out;
}
if (copy_from_user(&range, (struct f2fs_defragment __user *)arg, if (copy_from_user(&range, (struct f2fs_defragment __user *)arg,
sizeof(range))) { sizeof(range)))
err = -EFAULT; return -EFAULT;
goto out;
}
/* verify alignment of offset & size */ /* verify alignment of offset & size */
if (range.start & (F2FS_BLKSIZE - 1) || if (range.start & (F2FS_BLKSIZE - 1) || range.len & (F2FS_BLKSIZE - 1))
range.len & (F2FS_BLKSIZE - 1)) { return -EINVAL;
err = -EINVAL;
goto out;
}
if (unlikely((range.start + range.len) >> PAGE_SHIFT > if (unlikely((range.start + range.len) >> PAGE_SHIFT >
sbi->max_file_blocks)) { sbi->max_file_blocks))
err = -EINVAL; return -EINVAL;
goto out;
} err = mnt_want_write_file(filp);
if (err)
return err;
err = f2fs_defragment_range(sbi, filp, &range); err = f2fs_defragment_range(sbi, filp, &range);
mnt_drop_write_file(filp);
f2fs_update_time(sbi, REQ_TIME); f2fs_update_time(sbi, REQ_TIME);
if (err < 0) if (err < 0)
goto out; return err;
if (copy_to_user((struct f2fs_defragment __user *)arg, &range, if (copy_to_user((struct f2fs_defragment __user *)arg, &range,
sizeof(range))) sizeof(range)))
err = -EFAULT; return -EFAULT;
out:
mnt_drop_write_file(filp); return 0;
return err;
} }
static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment