f2fs: move mnt_want_write_file after range check
PATCH 1/1 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.
--- fs/f2fs/file.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/f2fs/file.c +8 -5
@@ -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)) {
Signature · 6 lines
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
Quoted 13 lines · Yunlei He
This patch move
mnt_want_write_fileafter range check, it's needless to check arguments with it.Signed-off-by Yunlei He <[email protected]>--- fs/f2fs/file.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg) · line 2068
Quoted 8 lines
fs/f2fs/file.c +5
-0@@ -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,
Quoted 6 lines
fs/f2fs/file.c +3
-0+return -EINVAL ; + } + ret =mnt_want_write_file (filp);if (ret)
fs/f2fs/file.c static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg) · line 2078
Quoted 10 lines
fs/f2fs/file.c +0
-5return 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
Quoted 22 lines
-----Original Message-----
From: heyunlei
Sent: Monday, April 23, 2018 10:37 AM
To: [email protected]; Yuchao (T); [email protected]
Cc: Wangbintian; heyunlei; Zhangdianfang (Euler)
Subject: [f2fs-dev][PATCH] f2fs: movemnt_want_write_fileafter range checkThis patch move
mnt_want_write_fileafter range check, it's needless to check arguments with it.Signed-off-by Yunlei He <[email protected]>---
fs/f2fs/file.c| 13 ++++++++-----1 file changed, 8 insertions(+), 5 deletions(-)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg) · line 2070
Quoted 10 lines
fs/f2fs/file.c +7
-0@@ -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.
Quoted 11 lines
fs/f2fs/file.c +1
-5+ 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:
Quoted 4 lines
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
Quoted 25 lines · heyunlei
Quoted 25 lines
-----Original Message-----
From: heyunlei
Sent: Monday, April 23, 2018 10:37 AM
To: [email protected]; Yuchao (T); [email protected]
Cc: Wangbintian; heyunlei; Zhangdianfang (Euler)
Subject: [f2fs-dev][PATCH] f2fs: movemnt_want_write_fileafter range checkThis patch move
mnt_want_write_fileafter range check, it's needless to check arguments with it.Signed-off-by Yunlei He <[email protected]>---
fs/f2fs/file.c| 13 ++++++++-----1 file changed, 8 insertions(+), 5 deletions(-)fs/f2fs/file.c +0
-0@@ -2061,15 +2061,18 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)if (f2fs_readonly (sbi->sb))return -EROFS ;
Quoted 10 lines
fs/f2fs/file.c static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg) · line 2070
Quoted 7 lines
fs/f2fs/file.c +7
-0+ 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_gcandf2fs_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,
Quoted 7 lines
Thanks.
Quoted 5 lines
fs/f2fs/file.c +1
-0+ ret =mnt_want_write_file (filp);if (ret)return ret;
Quoted 14 lines
Quoted 10 lines
fs/f2fs/file.c +0
-5- 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