From: Chao Yu <yuchao0@huawei.com>
To: <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 1/3] f2fs: clean up check condition for writting beyond EOF
Date: Fri, 1 Nov 2019 17:53:22 +0800 [thread overview]
Message-ID: <20191101095324.9902-1-yuchao0@huawei.com> (raw)
Clean up with below codes suggested by Eric:
__write_data_page()
unsigned nr_pages = DIV_ROUND_UP(i_size, PAGE_SIZE);
/*
* If the offset is out-of-range of file size,
* this page does not have to be written to disk.
*/
if (page->index >= nr_pages)
goto out;
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index ba3bcf4c7889..ca7161e38d1f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2204,6 +2204,7 @@ static int __write_data_page(struct page *page, bool *submitted,
const pgoff_t end_index = ((unsigned long long) i_size)
>> PAGE_SHIFT;
loff_t psize = (page->index + 1) << PAGE_SHIFT;
+ unsigned nr_pages = DIV_ROUND_UP(i_size, PAGE_SIZE);
unsigned offset = 0;
bool need_balance_fs = false;
int err = 0;
@@ -2248,8 +2249,7 @@ static int __write_data_page(struct page *page, bool *submitted,
* If the offset is out-of-range of file size,
* this page does not have to be written to disk.
*/
- offset = i_size & (PAGE_SIZE - 1);
- if ((page->index >= end_index + 1) || !offset)
+ if (page->index >= nr_pages)
goto out;
zero_user_segment(page, offset, PAGE_SIZE);
--
2.18.0.rc1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next reply other threads:[~2019-11-01 9:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 9:53 Chao Yu [this message]
2019-11-01 9:53 ` [f2fs-dev] [PATCH 2/3] f2fs: show f2fs instance in printk_ratelimited Chao Yu
2019-11-01 9:53 ` [f2fs-dev] [PATCH 3/3] Revert "f2fs: use kvmalloc, if kmalloc is failed" Chao Yu
[not found] ` <201911022233.zTMqGPBr%lkp@intel.com>
2019-11-04 8:03 ` Chao Yu
2019-11-05 0:02 ` Jaegeuk Kim
2019-11-05 2:17 ` Chao Yu
2019-11-05 2:38 ` Eric Biggers
2019-11-05 2:49 ` Chao Yu
2019-11-05 3:04 ` Jaegeuk Kim
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=20191101095324.9902-1-yuchao0@huawei.com \
--to=yuchao0@huawei.com \
--cc=jaegeuk@kernel.org \
--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).