提交 746e2403 编写于 作者: Y Yunlei He 提交者: Jaegeuk Kim

f2fs: add a case of no need to read a page in write begin

If the range we write cover the whole valid data in the last page,
we do not need to read it.
Signed-off-by: NYunlei He <heyunlei@huawei.com>
[Jaegeuk Kim: nullify the remaining area (fix: xfstests/f2fs/001)]
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 7855eba4
......@@ -1715,6 +1715,11 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册