f2fs: recover fallocated data and its i_size together
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 13 Jun 2014 04:05:55 +0000 (13:05 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 23 Jun 2014 01:05:08 +0000 (10:05 +0900)
This patch arranges the f2fs_locks to cover the fallocated data and its i_size.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index c58e330757191392656d2819fd937a1cc564cb37..f6c4bdaaae86c2500b8dbf5e3cef348f2c9585df 100644 (file)
@@ -659,13 +659,13 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
        off_start = offset & (PAGE_CACHE_SIZE - 1);
        off_end = (offset + len) & (PAGE_CACHE_SIZE - 1);
 
+       f2fs_lock_op(sbi);
+
        for (index = pg_start; index <= pg_end; index++) {
                struct dnode_of_data dn;
 
-               f2fs_lock_op(sbi);
                set_new_dnode(&dn, inode, NULL, NULL, 0);
                ret = f2fs_reserve_block(&dn, index);
-               f2fs_unlock_op(sbi);
                if (ret)
                        break;
 
@@ -683,8 +683,9 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
                i_size_read(inode) < new_size) {
                i_size_write(inode, new_size);
                mark_inode_dirty(inode);
-               f2fs_write_inode(inode, NULL);
+               update_inode_page(inode);
        }
+       f2fs_unlock_op(sbi);
 
        return ret;
 }