linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/3] f2fs: clean up check condition for writting beyond EOF
@ 2019-11-01  9:53 Chao Yu
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Chao Yu @ 2019-11-01  9:53 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

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

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

end of thread, other threads:[~2019-11-05  3:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01  9:53 [f2fs-dev] [PATCH 1/3] f2fs: clean up check condition for writting beyond EOF Chao Yu
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

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).