From: Chao Yu <yuchao0@huawei.com>
To: Daeho Jeong <daeho43@gmail.com>, <linux-kernel@vger.kernel.org>,
<linux-f2fs-devel@lists.sourceforge.net>,
<kernel-team@android.com>
Cc: Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
Date: Thu, 9 Jul 2020 11:05:15 +0800 [thread overview]
Message-ID: <619af72b-2f8a-4a84-f73e-ac49989ba79f@huawei.com> (raw)
In-Reply-To: <20200709015739.1653668-1-daeho43@gmail.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
next prev parent reply other threads:[~2020-07-09 3:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-07-09 4:15 ` Daeho Jeong
2020-07-09 5:39 ` Jaegeuk Kim
2020-07-09 6:00 ` Daeho Jeong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=619af72b-2f8a-4a84-f73e-ac49989ba79f@huawei.com \
--to=yuchao0@huawei.com \
--cc=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).