This is a note to let you know that I've just added the patch titled Btrfs: bail out if block group has different mixed flag to the 4.4-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-bail-out-if-block-group-has-different-mixed-flag.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 49303381f19ab16a371a061b67e783d3f570d56e Mon Sep 17 00:00:00 2001 From: Liu Bo <bo.li.liu@xxxxxxxxxx> Date: Thu, 25 Aug 2016 18:08:27 -0700 Subject: Btrfs: bail out if block group has different mixed flag From: Liu Bo <bo.li.liu@xxxxxxxxxx> commit 49303381f19ab16a371a061b67e783d3f570d56e upstream. Currently we allow inconsistence about mixed flag (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA). We'd get ENOSPC if block group has mixed flag and btrfs doesn't. If that happens, we have one space_info with mixed flag and another space_info only with BTRFS_BLOCK_GROUP_METADATA, and global_block_rsv.space_info points to the latter one, but all bytes from block_group contributes to the mixed space_info, thus all the allocation will fail with ENOSPC. This adds a check for the above case. Reported-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx> Signed-off-by: Liu Bo <bo.li.liu@xxxxxxxxxx> [ updated message ] Reviewed-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/extent-tree.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -9686,6 +9686,11 @@ int btrfs_read_block_groups(struct btrfs struct extent_buffer *leaf; int need_clear = 0; u64 cache_gen; + u64 feature; + int mixed; + + feature = btrfs_super_incompat_flags(info->super_copy); + mixed = !!(feature & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS); root = info->extent_root; key.objectid = 0; @@ -9739,6 +9744,15 @@ int btrfs_read_block_groups(struct btrfs btrfs_item_ptr_offset(leaf, path->slots[0]), sizeof(cache->item)); cache->flags = btrfs_block_group_flags(&cache->item); + if (!mixed && + ((cache->flags & BTRFS_BLOCK_GROUP_METADATA) && + (cache->flags & BTRFS_BLOCK_GROUP_DATA))) { + btrfs_err(info, +"bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups", + cache->key.objectid); + ret = -EINVAL; + goto error; + } key.objectid = found_key.objectid + found_key.offset; btrfs_release_path(path); Patches currently in stable-queue which might be from bo.li.liu@xxxxxxxxxx are queue-4.4/btrfs-fix-memory-leak-in-reading-btree-blocks.patch queue-4.4/btrfs-bail-out-if-block-group-has-different-mixed-flag.patch queue-4.4/btrfs-return-gracefully-from-balance-if-fs-tree-is-corrupted.patch queue-4.4/btrfs-don-t-bug-during-drop-snapshot.patch queue-4.4/btrfs-fix-memory-leak-in-do_walk_down.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