[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191101095324.9902-1-yuchao0@huawei.com>
Date: Fri, 1 Nov 2019 17:53:22 +0800
From: Chao Yu <yuchao0@...wei.com>
To: <jaegeuk@...nel.org>
CC: <linux-f2fs-devel@...ts.sourceforge.net>,
<linux-kernel@...r.kernel.org>, <chao@...nel.org>,
Chao Yu <yuchao0@...wei.com>
Subject: [PATCH 1/3] f2fs: clean up check condition for writting beyond EOF
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@...wei.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
Powered by blists - more mailing lists