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 <yuch...@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

Reply via email to