f2fs: fix to set PageUptodate in f2fs_write_end correctly
authorJaegeuk Kim <jaegeuk@kernel.org>
Tue, 6 Sep 2016 18:02:03 +0000 (11:02 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 13 Sep 2016 20:02:34 +0000 (13:02 -0700)
commit649d7df29ca83b2c9e81a4a305a8de8ab02b5e9d
tree5cd2b805dff2b6659ab15fd2142383ddba8f8aea
parent61e4da1172d18f5277be847a40559eacd3169ce7
f2fs: fix to set PageUptodate in f2fs_write_end correctly

Previously, f2fs_write_begin sets PageUptodate all the time. But, when user
tries to update the entire page (i.e., len == PAGE_SIZE), we need to consider
that the page is able to be copied partially afterwards. In such the case,
we will lose the remaing region in the page.

This patch fixes this by setting PageUptodate in f2fs_write_end as given copied
result. In the short copy case, it returns zero to let generic_perform_write
retry copying user data again.

As a result, f2fs_write_end() works:
   PageUptodate      len      copied    return   retry
1. no                4096     4096      4096     false  -> return 4096
2. no                4096     1024      0        true   -> goto #1 case
3. yes               2048     2048      2048     false  -> return 2048
4. yes               2048     1024      1024     false  -> return 1024

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c