Skip to content

Commit 7174466

Browse files
Yunlei Hepundiramit
authored andcommitted
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>
1 parent b1e97c8 commit 7174466

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/f2fs/data.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,11 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
17231723
if (len == PAGE_SIZE || PageUptodate(page))
17241724
return 0;
17251725

1726+
if (!(pos & (PAGE_SIZE - 1)) && (pos + len) >= i_size_read(inode)) {
1727+
zero_user_segment(page, len, PAGE_SIZE);
1728+
return 0;
1729+
}
1730+
17261731
if (blkaddr == NEW_ADDR) {
17271732
zero_user_segment(page, 0, PAGE_SIZE);
17281733
SetPageUptodate(page);
@@ -1777,7 +1782,7 @@ static int f2fs_write_end(struct file *file,
17771782
* let generic_perform_write() try to copy data again through copied=0.
17781783
*/
17791784
if (!PageUptodate(page)) {
1780-
if (unlikely(copied != PAGE_SIZE))
1785+
if (unlikely(copied != len))
17811786
copied = 0;
17821787
else
17831788
SetPageUptodate(page);

0 commit comments

Comments
 (0)