From: Jeff Mahoney <jeffm@suse.com>
To: Btrfs Development List <linux-btrfs@vger.kernel.org>
Subject: [patch v2 8/9] btrfs: Push up btrfs_pin_extent failures
Date: Mon, 15 Aug 2011 15:50:50 -0400 [thread overview]
Message-ID: <20110815195233.066845613@suse.com> (raw)
In-Reply-To: 20110815195042.559654068@suse.com
btrfs_pin_extent looks up a block group and then calls pin_down_extent
with it. If the lookup fails, it should return -ENOENT to allow callers
to handle the error condition. For the three existing callers, it is
a logic error if the lookup fails and a panic will occur.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/btrfs/extent-tree.c | 20 +++++++++++++++-----
fs/btrfs/tree-log.c | 10 +++++++---
2 files changed, 22 insertions(+), 8 deletions(-)
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2075,8 +2075,14 @@ static int run_one_delayed_ref(struct bt
BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node);
if (insert_reserved) {
- btrfs_pin_extent(root, node->bytenr,
- node->num_bytes, 1);
+ ret = btrfs_pin_extent(root, node->bytenr,
+ node->num_bytes, 1);
+ if (ret)
+ btrfs_panic(root->fs_info, ret,
+ "Cannot pin extent in range "
+ "%llu(%llu)\n",
+ node->bytenr, node->num_bytes);
+
if (head->is_data) {
ret = btrfs_del_csums(trans, root,
node->bytenr,
@@ -4205,7 +4211,8 @@ int btrfs_pin_extent(struct btrfs_root *
struct btrfs_block_group_cache *cache;
cache = btrfs_lookup_block_group(root->fs_info, bytenr);
- BUG_ON(!cache);
+ if (cache == NULL)
+ return -ENOENT;
pin_down_extent(root, cache, bytenr, num_bytes, reserved);
@@ -4765,8 +4772,11 @@ int btrfs_free_extent(struct btrfs_trans
if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);
/* unlocks the pinned mutex */
- btrfs_pin_extent(root, bytenr, num_bytes, 1);
- ret = 0;
+ ret = btrfs_pin_extent(root, bytenr, num_bytes, 1);
+ if (ret)
+ btrfs_panic(root->fs_info, ret, "Cannot pin "
+ "extent in range %llu(%llu)\n",
+ bytenr, num_bytes);
} else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
ret = btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes,
parent, root_objectid, (int)owner,
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -275,9 +275,13 @@ static int process_one_buffer(struct btr
struct extent_buffer *eb,
struct walk_control *wc, u64 gen)
{
- if (wc->pin)
- btrfs_pin_extent(log->fs_info->extent_root,
- eb->start, eb->len, 0);
+ if (wc->pin) {
+ int ret = btrfs_pin_extent(log->fs_info->extent_root,
+ eb->start, eb->len, 0);
+ if (ret)
+ btrfs_panic(log->fs_info, ret, "Cannot pin extent in "
+ "range %llu(%llu)\n", eb->start, eb->len);
+ }
if (btrfs_buffer_uptodate(eb, gen)) {
if (wc->write)
next prev parent reply other threads:[~2011-08-15 19:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 19:50 [patch v2 0/9] btrfs: More error handling patches Jeff Mahoney
2011-08-15 19:50 ` [patch v2 1/9] btrfs: Add btrfs_panic() Jeff Mahoney
2011-08-15 19:50 ` [patch v2 2/9] btrfs: Catch locking failures in {set,clear}_extent_bit Jeff Mahoney
2011-08-15 19:50 ` [patch v2 3/9] btrfs: Push up set_extent_bit errors to callers Jeff Mahoney
2011-08-15 19:50 ` [patch v2 4/9] btrfs: Push up lock_extent " Jeff Mahoney
2011-08-15 19:50 ` [patch v2 5/9] btrfs: Push up clear_extent_bit " Jeff Mahoney
2011-08-15 19:50 ` [patch v2 6/9] btrfs: Push up unlock_extent " Jeff Mahoney
2011-08-15 19:50 ` [patch v2 7/9] btrfs: Make pin_down_extent return void Jeff Mahoney
2011-08-15 19:50 ` Jeff Mahoney [this message]
2011-08-15 19:50 ` [patch v2 9/9] btrfs: Push up non-looped btrfs_start_transaction failures Jeff Mahoney
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=20110815195233.066845613@suse.com \
--to=jeffm@suse.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).