All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: move mnt_want_write_file after range check
@ 2018-04-23  2:37 Yunlei He
  2018-04-23  8:32 ` Chao Yu
  2018-04-23  9:11 ` heyunlei
  0 siblings, 2 replies; 4+ messages in thread
From: Yunlei He @ 2018-04-23  2:37 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel; +Cc: zhangdianfang

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>
---
 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));
+		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)) {
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs: move mnt_want_write_file after range check
  2018-04-23  2:37 [PATCH] f2fs: move mnt_want_write_file after range check Yunlei He
@ 2018-04-23  8:32 ` Chao Yu
  2018-04-23  9:11 ` heyunlei
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2018-04-23  8:32 UTC (permalink / raw)
  To: Yunlei He, jaegeuk, linux-f2fs-devel; +Cc: zhangdianfang

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 <heyunlei@huawei.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs: move mnt_want_write_file after range check
  2018-04-23  2:37 [PATCH] f2fs: move mnt_want_write_file after range check Yunlei He
  2018-04-23  8:32 ` Chao Yu
@ 2018-04-23  9:11 ` heyunlei
  2018-04-23 10:52   ` Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: heyunlei @ 2018-04-23  9:11 UTC (permalink / raw)
  To: heyunlei, jaegeuk, Yuchao (T), linux-f2fs-devel; +Cc: Zhangdianfang (Euler)



>-----Original Message-----
>From: heyunlei
>Sent: Monday, April 23, 2018 10:37 AM
>To: jaegeuk@kernel.org; Yuchao (T); linux-f2fs-devel@lists.sourceforge.net
>Cc: Wangbintian; heyunlei; Zhangdianfang (Euler)
>Subject: [f2fs-dev][PATCH] f2fs: move mnt_want_write_file after range check
>
>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>
>---
> 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));
>+		return -EINVAL;
>+	}

Okay, btw, should we combine f2fs_ioc_gc and f2fs_ioc_gc_range? 
we can add a value in input arguments to indicate whether it's range gc or not.

Thanks. 
>+
> 	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)) {
>--
>1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] f2fs: move mnt_want_write_file after range check
  2018-04-23  9:11 ` heyunlei
@ 2018-04-23 10:52   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2018-04-23 10:52 UTC (permalink / raw)
  To: heyunlei, jaegeuk, linux-f2fs-devel; +Cc: Zhangdianfang (Euler)

On 2018/4/23 17:11, heyunlei wrote:
> 
> 
>> -----Original Message-----
>> From: heyunlei
>> Sent: Monday, April 23, 2018 10:37 AM
>> To: jaegeuk@kernel.org; Yuchao (T); linux-f2fs-devel@lists.sourceforge.net
>> Cc: Wangbintian; heyunlei; Zhangdianfang (Euler)
>> Subject: [f2fs-dev][PATCH] f2fs: move mnt_want_write_file after range check
>>
>> 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>
>> ---
>> 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));
>> +		return -EINVAL;
>> +	}
> 
> Okay, btw, should we combine f2fs_ioc_gc and f2fs_ioc_gc_range? 
> we can add a value in input arguments to indicate whether it's range gc or not.

That's not a big problem since it's just cleanup, if you want to, please go
ahead. :)

Thanks,

> 
> Thanks. 
>> +
>> 	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)) {
>> --
>> 1.9.1
> 
> 
> .
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-23 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23  2:37 [PATCH] f2fs: move mnt_want_write_file after range check Yunlei He
2018-04-23  8:32 ` Chao Yu
2018-04-23  9:11 ` heyunlei
2018-04-23 10:52   ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.