This is a note to let you know that I've just added the patch titled Btrfs: read inode size after acquiring the mutex when punching a hole to the 3.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-read-inode-size-after-acquiring-the-mutex-when-punching-a-hole.patch and it can be found in the queue-3.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a1a50f60a6bf4f861eb94793420274bc1ccd409a Mon Sep 17 00:00:00 2001 From: Filipe Manana <fdmanana@xxxxxxxxx> Date: Sat, 26 Apr 2014 01:35:31 +0100 Subject: Btrfs: read inode size after acquiring the mutex when punching a hole From: Filipe Manana <fdmanana@xxxxxxxxx> commit a1a50f60a6bf4f861eb94793420274bc1ccd409a upstream. In a previous change, commit 12870f1c9b2de7d475d22e73fd7db1b418599725, I accidentally moved the roundup of inode->i_size to outside of the critical section delimited by the inode mutex, which is not atomic and not correct since the size can be changed by other task before we acquire the mutex. Therefore fix it. Signed-off-by: Filipe David Borba Manana <fdmanana@xxxxxxxxx> Signed-off-by: Chris Mason <clm@xxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2200,13 +2200,14 @@ static int btrfs_punch_hole(struct inode 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. Patches currently in stable-queue which might be from fdmanana@xxxxxxxxx are queue-3.15/btrfs-send-use-the-right-limits-for-xattr-names-and-values.patch queue-3.15/btrfs-read-inode-size-after-acquiring-the-mutex-when-punching-a-hole.patch queue-3.15/btrfs-send-account-for-orphan-directories-when-building-path-strings.patch queue-3.15/btrfs-fix-leaf-corruption-caused-by-enospc-while-hole-punching.patch queue-3.15/btrfs-send-don-t-error-in-the-presence-of-subvols-snapshots.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html