]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
f2fs: add a case of no need to read a page in write begin
authorYunlei He <heyunlei@huawei.com>
Tue, 20 Dec 2016 03:11:35 +0000 (11:11 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 29 Jan 2017 03:46:01 +0000 (12:46 +0900)
If the range we write cover the whole valid data in the last page,
we do not need to read it.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
[Jaegeuk Kim: nullify the remaining area (fix: xfstests/f2fs/001)]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 9ac262564fa6b5934b8ec4987425ea3205bba1cf..2c5df1dc14798948558032f0e73bc25895379015 100644 (file)
@@ -1715,6 +1715,11 @@ repeat:
        if (len == PAGE_SIZE || PageUptodate(page))
                return 0;
 
+       if (!(pos & (PAGE_SIZE - 1)) && (pos + len) >= i_size_read(inode)) {
+               zero_user_segment(page, len, PAGE_SIZE);
+               return 0;
+       }
+
        if (blkaddr == NEW_ADDR) {
                zero_user_segment(page, 0, PAGE_SIZE);
                SetPageUptodate(page);
@@ -1768,7 +1773,7 @@ static int f2fs_write_end(struct file *file,
         * let generic_perform_write() try to copy data again through copied=0.
         */
        if (!PageUptodate(page)) {
-               if (unlikely(copied != PAGE_SIZE))
+               if (unlikely(copied != len))
                        copied = 0;
                else
                        SetPageUptodate(page);