f2fs: fix to update last_disk_size correctly
authorChao Yu <yuchao0@huawei.com>
Wed, 17 Jan 2018 08:31:37 +0000 (16:31 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 27 Jan 2018 21:30:28 +0000 (13:30 -0800)
This patch fixes to update last_disk_size only when writing out page
successfully.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index b0e75d74fd57f8cc6c2a327022f2c540679e5007..28c03ea27954b68c84bd227fb045b6a33ab32697 100644 (file)
@@ -1716,10 +1716,14 @@ write:
                }
        }
 
-       down_write(&F2FS_I(inode)->i_sem);
-       if (F2FS_I(inode)->last_disk_size < psize)
-               F2FS_I(inode)->last_disk_size = psize;
-       up_write(&F2FS_I(inode)->i_sem);
+       if (err) {
+               file_set_keep_isize(inode);
+       } else {
+               down_write(&F2FS_I(inode)->i_sem);
+               if (F2FS_I(inode)->last_disk_size < psize)
+                       F2FS_I(inode)->last_disk_size = psize;
+               up_write(&F2FS_I(inode)->i_sem);
+       }
 
 done:
        if (err && err != -ENOENT)