f2fs: read isize while holding i_mutex in fiemap
authorFan Li <fanofcode.li@samsung.com>
Mon, 4 Jan 2016 07:56:50 +0000 (15:56 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 7 Jan 2016 03:15:49 +0000 (19:15 -0800)
make sure the isize we read doesn't change during the process.

Signed-off-by: Fan li <fanofcode.li@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 89a978c57da92b31cfeefead65f7700718b8386f..ac5bea0f5f09a630a572ac06521e96e1b309b523 100644 (file)
@@ -784,7 +784,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 {
        struct buffer_head map_bh;
        sector_t start_blk, last_blk;
-       loff_t isize = i_size_read(inode);
+       loff_t isize;
        u64 logical = 0, phys = 0, size = 0;
        u32 flags = 0;
        int ret = 0;
@@ -800,6 +800,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        }
 
        mutex_lock(&inode->i_mutex);
+
+       isize = i_size_read(inode);
        if (start >= isize)
                goto out;