From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>
Subject: [PATCH] Btrfs: don't BUG() during drop snapshot
Date: Thu, 22 Sep 2016 17:08:24 +0200 [thread overview]
Message-ID: <1474556904-22495-1-git-send-email-dsterba@suse.com> (raw)
From: Josef Bacik <jbacik@fb.com>
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.
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/extent-tree.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c95f85c292a4..37aba7d00c8f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8884,12 +8884,15 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
&wc->flags[level - 1]);
if (ret < 0) {
btrfs_tree_unlock(next);
+ free_extent_buffer(next);
return ret;
}
if (unlikely(wc->refs[level - 1] == 0)) {
btrfs_err(root->fs_info, "Missing references.");
- BUG();
+ btrfs_tree_unlock(next);
+ free_extent_buffer(next);
+ return -EIO;
}
*lookup_info = 0;
@@ -8941,7 +8944,13 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
}
level--;
- BUG_ON(level != btrfs_header_level(next));
+ ASSERT(level == btrfs_header_level(next));
+ if (level != btrfs_header_level(next)) {
+ btrfs_err("mismatched level");
+ btrfs_tree_unlock(next);
+ free_extent_buffer(next);
+ return -EIO;
+ }
path->nodes[level] = next;
path->slots[level] = 0;
path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
@@ -8956,8 +8965,14 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
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("mismatched block owner");
+ btrfs_tree_unlock(next);
+ free_extent_buffer(next);
+ }
parent = 0;
}
@@ -8972,7 +8987,11 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
}
ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent,
root->root_key.objectid, level - 1, 0);
- BUG_ON(ret); /* -ENOMEM */
+ if (ret) {
+ btrfs_tree_unlock(next);
+ free_extent_buffer(next);
+ return ret;
+ }
}
btrfs_tree_unlock(next);
free_extent_buffer(next);
--
2.7.1
next reply other threads:[~2016-09-22 15:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 15:08 David Sterba [this message]
2016-09-22 18:03 ` [PATCH] Btrfs: don't BUG() during drop snapshot Liu Bo
2016-09-23 11:23 ` [PATCH v2] " David Sterba
2016-09-23 18:01 ` Liu Bo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474556904-22495-1-git-send-email-dsterba@suse.com \
--to=dsterba@suse.com \
--cc=jbacik@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).