linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
@ 2020-07-09  1:57 Daeho Jeong
  2020-07-09  3:05 ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Daeho Jeong @ 2020-07-09  1:57 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

When end_addr comes to zero, it'll trigger different behaviour.
To prevent this, we need to ignore the case of that range.len is
zero in the function.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fs/f2fs/file.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 368c80f8e2a1..98b0a8dbf669 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
 	file_start_write(filp);
 	inode_lock(inode);
 
-	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
+	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
+			range.start >= inode->i_size) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (range.start >= inode->i_size) {
-		ret = -EINVAL;
+	if (range.len == 0)
 		goto err;
-	}
 
 	if (inode->i_size - range.start < range.len) {
 		ret = -E2BIG;
-- 
2.27.0.383.g050319c2ae-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
  2020-07-09  1:57 [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero Daeho Jeong
@ 2020-07-09  3:05 ` Chao Yu
  2020-07-09  4:15   ` Daeho Jeong
  2020-07-09  5:39   ` Jaegeuk Kim
  0 siblings, 2 replies; 5+ messages in thread
From: Chao Yu @ 2020-07-09  3:05 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

On 2020/7/9 9:57, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> When end_addr comes to zero, it'll trigger different behaviour.
> To prevent this, we need to ignore the case of that range.len is
> zero in the function.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
>  fs/f2fs/file.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 368c80f8e2a1..98b0a8dbf669 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
>  	file_start_write(filp);
>  	inode_lock(inode);
>  
> -	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
> +	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
> +			range.start >= inode->i_size) {
>  		ret = -EINVAL;
>  		goto err;
>  	}
>  
> -	if (range.start >= inode->i_size) {
> -		ret = -EINVAL;
> +	if (range.len == 0)
>  		goto err;
> -	}
>  
>  	if (inode->i_size - range.start < range.len) {
>  		ret = -E2BIG;

How about the case trimming last partial written block?

i_size = 8000
range.start = 4096
range.len = 4096

Do we need to roundup(isize, PAGE_SIZE) before comparison?

Thanks,

> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
  2020-07-09  3:05 ` Chao Yu
@ 2020-07-09  4:15   ` Daeho Jeong
  2020-07-09  5:39   ` Jaegeuk Kim
  1 sibling, 0 replies; 5+ messages in thread
From: Daeho Jeong @ 2020-07-09  4:15 UTC (permalink / raw)
  To: Chao Yu; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel

I thought it's better to treat this as the error case, since the range
already passed out of the i_size range.
If we allow that, the user needs to send the range parameter being
aligned like start:0 and len: roundup(i_size, PAGE_SIZE), even if he
or she wants to erase the whole file.

2020년 7월 9일 (목) 오후 12:05, Chao Yu <yuchao0@huawei.com>님이 작성:
>
> On 2020/7/9 9:57, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> >
> > When end_addr comes to zero, it'll trigger different behaviour.
> > To prevent this, we need to ignore the case of that range.len is
> > zero in the function.
> >
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> >  fs/f2fs/file.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 368c80f8e2a1..98b0a8dbf669 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
> >       file_start_write(filp);
> >       inode_lock(inode);
> >
> > -     if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
> > +     if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
> > +                     range.start >= inode->i_size) {
> >               ret = -EINVAL;
> >               goto err;
> >       }
> >
> > -     if (range.start >= inode->i_size) {
> > -             ret = -EINVAL;
> > +     if (range.len == 0)
> >               goto err;
> > -     }
> >
> >       if (inode->i_size - range.start < range.len) {
> >               ret = -E2BIG;
>
> How about the case trimming last partial written block?
>
> i_size = 8000
> range.start = 4096
> range.len = 4096
>
> Do we need to roundup(isize, PAGE_SIZE) before comparison?
>
> Thanks,
>
> >


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
  2020-07-09  3:05 ` Chao Yu
  2020-07-09  4:15   ` Daeho Jeong
@ 2020-07-09  5:39   ` Jaegeuk Kim
  2020-07-09  6:00     ` Daeho Jeong
  1 sibling, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2020-07-09  5:39 UTC (permalink / raw)
  To: Chao Yu; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel

On 07/09, Chao Yu wrote:
> On 2020/7/9 9:57, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> > 
> > When end_addr comes to zero, it'll trigger different behaviour.
> > To prevent this, we need to ignore the case of that range.len is
> > zero in the function.
> > 
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> >  fs/f2fs/file.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 368c80f8e2a1..98b0a8dbf669 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
> >  	file_start_write(filp);
> >  	inode_lock(inode);
> >  
> > -	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
> > +	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
> > +			range.start >= inode->i_size) {
> >  		ret = -EINVAL;
> >  		goto err;
> >  	}
> >  
> > -	if (range.start >= inode->i_size) {
> > -		ret = -EINVAL;
> > +	if (range.len == 0)
> >  		goto err;
> > -	}
> >  
> >  	if (inode->i_size - range.start < range.len) {
> >  		ret = -E2BIG;
> 
> How about the case trimming last partial written block?
> 
> i_size = 8000
> range.start = 4096
> range.len = 4096
> 
> Do we need to roundup(isize, PAGE_SIZE) before comparison?

If we want to trim whole file, do we need to give the exact i_size?
Wouldn't it be better to give trim(0, -1)?

> 
> Thanks,
> 
> > 
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
  2020-07-09  5:39   ` Jaegeuk Kim
@ 2020-07-09  6:00     ` Daeho Jeong
  0 siblings, 0 replies; 5+ messages in thread
From: Daeho Jeong @ 2020-07-09  6:00 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel

I can add it~

2020년 7월 9일 (목) 오후 2:39, Jaegeuk Kim <jaegeuk@kernel.org>님이 작성:
>
> On 07/09, Chao Yu wrote:
> > On 2020/7/9 9:57, Daeho Jeong wrote:
> > > From: Daeho Jeong <daehojeong@google.com>
> > >
> > > When end_addr comes to zero, it'll trigger different behaviour.
> > > To prevent this, we need to ignore the case of that range.len is
> > > zero in the function.
> > >
> > > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > > ---
> > >  fs/f2fs/file.c | 7 +++----
> > >  1 file changed, 3 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > > index 368c80f8e2a1..98b0a8dbf669 100644
> > > --- a/fs/f2fs/file.c
> > > +++ b/fs/f2fs/file.c
> > > @@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
> > >     file_start_write(filp);
> > >     inode_lock(inode);
> > >
> > > -   if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
> > > +   if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
> > > +                   range.start >= inode->i_size) {
> > >             ret = -EINVAL;
> > >             goto err;
> > >     }
> > >
> > > -   if (range.start >= inode->i_size) {
> > > -           ret = -EINVAL;
> > > +   if (range.len == 0)
> > >             goto err;
> > > -   }
> > >
> > >     if (inode->i_size - range.start < range.len) {
> > >             ret = -E2BIG;
> >
> > How about the case trimming last partial written block?
> >
> > i_size = 8000
> > range.start = 4096
> > range.len = 4096
> >
> > Do we need to roundup(isize, PAGE_SIZE) before comparison?
>
> If we want to trim whole file, do we need to give the exact i_size?
> Wouldn't it be better to give trim(0, -1)?
>
> >
> > Thanks,
> >
> > >
> >
> >
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2020-07-09  6:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  1:57 [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero Daeho Jeong
2020-07-09  3:05 ` Chao Yu
2020-07-09  4:15   ` Daeho Jeong
2020-07-09  5:39   ` Jaegeuk Kim
2020-07-09  6:00     ` Daeho Jeong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).