f2fs: move mnt_want_write_file after range check
authorYunlei He <heyunlei@huawei.com>
Tue, 24 Apr 2018 03:40:30 +0000 (11:40 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 28 Jun 2018 22:49:24 +0000 (15:49 -0700)
This patch move mnt_want_write_file after range check,
it's needless to check arguments with it.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index f1d5908241070341228ef0f1f785326a4e81a46e..f9c9a2074d190793a731cb16de45c1ac06527fcd 100644 (file)
@@ -2060,15 +2060,15 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
        if (f2fs_readonly(sbi->sb))
                return -EROFS;
 
+       end = range.start + range.len;
+       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
+               return -EINVAL;
+       }
+
        ret = mnt_want_write_file(filp);
        if (ret)
                return ret;
 
-       end = range.start + range.len;
-       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
-               ret = -EINVAL;
-               goto out;
-       }
 do_more:
        if (!range.sync) {
                if (!mutex_trylock(&sbi->gc_mutex)) {