f2fs: flush dirty data for bmap
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 19 Oct 2015 17:29:51 +0000 (10:29 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 20 Oct 2015 18:33:11 +0000 (11:33 -0700)
Users expect bmap will give allocated block addresses.
Let's play likewise ext4.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 77dfc9eee380b6a2e3ba1888b7219d08b64e08c9..b052e7c262ac947fd465275a414a97bda9056224 100644 (file)
@@ -1667,12 +1667,13 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 {
        struct inode *inode = mapping->host;
 
-       /* we don't need to use inline_data strictly */
-       if (f2fs_has_inline_data(inode)) {
-               int err = f2fs_convert_inline_inode(inode);
-               if (err)
-                       return err;
-       }
+       if (f2fs_has_inline_data(inode))
+               return 0;
+
+       /* make sure allocating whole blocks */
+       if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
+               filemap_write_and_wait(mapping);
+
        return generic_block_bmap(mapping, block, get_data_block_bmap);
 }