diff options
| author | Yunlei He <heyunlei@huawei.com> | 2016-12-20 11:11:35 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@google.com> | 2017-10-03 13:39:12 +0000 |
| commit | ff9199293b056f202f447e07bb4160581ae48cac (patch) | |
| tree | de77782bbffcd1d0738092263dfcacbd8f7be7db | |
| parent | 75487d02a75b16fc40c9640459f09604185cd77b (diff) | |
f2fs: add a case of no need to read a page in write begin
commit 746e2403927efbd7c7f2e796314e3cfb3cfabaa4 upstream.
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>
| -rw-r--r-- | fs/f2fs/data.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2eddf1daf995..d7c20880e53e 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1723,6 +1723,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); @@ -1777,7 +1782,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); |
