From: Chao Yu Subject: Re: [PATCH] f2fs: move mnt_want_write_file after range check Date: Mon, 23 Apr 2018 16:32:21 +0800 Message-ID: References: <1524451043-22501-1-git-send-email-heyunlei@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fAWu5-0004hs-1x for linux-f2fs-devel@lists.sourceforge.net; Mon, 23 Apr 2018 08:32:53 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191] helo=huawei.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fAWu2-003QeY-EX for linux-f2fs-devel@lists.sourceforge.net; Mon, 23 Apr 2018 08:32:53 +0000 In-Reply-To: <1524451043-22501-1-git-send-email-heyunlei@huawei.com> Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Yunlei He , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: zhangdianfang@huawei.com On 2018/4/23 10:37, Yunlei He wrote: > This patch move mnt_want_write_file after range check, > it's needless to check arguments with it. > > Signed-off-by: Yunlei He > --- > fs/f2fs/file.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 16dad2b..165a60f 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -2061,15 +2061,18 @@ 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)) { > + f2fs_msg(sbi->sb, KERN_WARNING, > + "range should be located in (%u, %u]", > + MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi)); We don't need add kmsg in this condition as handling parameter check in most other interfaces. Thanks, > + 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)) { > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot