Patch "Btrfs: don't BUG() during drop snapshot" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
Btrfs: don't BUG() during drop snapshot
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-don-t-bug-during-drop-snapshot.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 <[email protected]> know about it.
Quoted 1 line
From
4867268c57ff709a7b6b86ae6f6537d846d1443aMon Sep 17 00:00:00 2001
From: Josef Bacik <[email protected]>
Date: Fri, 23 Sep 2016 13:23:28 +0200
Subject: Btrfs: don't BUG() during drop snapshot
From: Josef Bacik <[email protected]>
commit 4867268c57ff709a7b6b86ae6f6537d846d1443a upstream.
Really there's lots of things that can go wrong here, kill all the BUG_ON()'s and replace the logic ones with ASSERT()'s and return EIO instead.
--- fs/btrfs/extent-tree.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-)
fs/btrfs/extent-tree.c +27 -11
@@ -8486,15 +8486,13 @@ static noinline int do_walk_down(struct ret =btrfs_lookup_extent_info (trans, root, bytenr, level -1 ,1 , &wc->refs[level -1 ], &wc->flags[level -1 ]); -if (ret <0 ) { -btrfs_tree_unlock (next); -free_extent_buffer (next); -return ret; - } +if (ret <0 ) + goto out_unlock;if (unlikely (wc->refs[level -1 ] ==0 )) {btrfs_err (root->fs_info,"Missing references." ); -BUG (); + ret = -EIO ; + goto out_unlock; } *lookup_info =0 ;
@@ -8546,7 +8544,12 @@ static noinline int do_walk_down(struct } level--; -BUG_ON (level !=btrfs_header_level (next)); +ASSERT (level ==btrfs_header_level (next)); +if (level !=btrfs_header_level (next)) { +btrfs_err (root->fs_info,"mismatched level" ); + ret = -EIO ; + goto out_unlock; + } path->nodes[level] = next; path->slots[level] =0 ; path->locks[level] =BTRFS_WRITE_LOCK_BLOCKING ;
@@ -8561,8 +8564,15 @@ skip:if (wc->flags[level] &BTRFS_BLOCK_FLAG_FULL_BACKREF ) { parent = path->nodes[level]->start; }else { -BUG_ON (root->root_key.objectid != +ASSERT (root->root_key.objectid ==btrfs_header_owner (path->nodes[level])); +if (root->root_key.objectid != +btrfs_header_owner (path->nodes[level])) { +btrfs_err (root->fs_info, +"mismatched block owner" ); + ret = -EIO ; + goto out_unlock; + } parent =0 ; }
@@ -8579,12 +8589,18 @@ skip: } ret =btrfs_free_extent (trans, root, bytenr, blocksize, parent, root->root_key.objectid, level -1 ,0 ); -BUG_ON (ret);/* -ENOMEM */ +if (ret) + goto out_unlock; } + + *lookup_info =1 ; + ret =1 ; + +out_unlock:btrfs_tree_unlock (next);free_extent_buffer (next); - *lookup_info =1 ; -return 1 ; + +return ret; }/*
Patches currently in stable-queue which might be from [email protected] are
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-don-t-leak-reloc-root-nodes-on-error.patch