Btrfs: read inode size after acquiring the mutex when punching a hole
[deliverable/linux.git] / fs / btrfs / file.c
index ae6af072b635e195e26f3199c3aabd427964881f..e4ff2d52ea2307aabc77817e7720cbd20c7b0fda 100644 (file)
@@ -2187,13 +2187,14 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
        bool same_page = ((offset >> PAGE_CACHE_SHIFT) ==
                          ((offset + len - 1) >> PAGE_CACHE_SHIFT));
        bool no_holes = btrfs_fs_incompat(root->fs_info, NO_HOLES);
-       u64 ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE);
+       u64 ino_size;
 
        ret = btrfs_wait_ordered_range(inode, offset, len);
        if (ret)
                return ret;
 
        mutex_lock(&inode->i_mutex);
+       ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE);
        /*
         * We needn't truncate any page which is beyond the end of the file
         * because we are sure there is no data there.
This page took 0.02508 seconds and 5 git commands to generate.