From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <jbacik@fusionio.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix all callers of read_tree_block
Date: Wed, 24 Apr 2013 17:50:11 +0200 [thread overview]
Message-ID: <20130424155011.GG16427@twin.jikos.cz> (raw)
In-Reply-To: <1366741222-1825-1-git-send-email-jbacik@fusionio.com>
On Tue, Apr 23, 2013 at 02:20:22PM -0400, Josef Bacik wrote:
> We kept leaking extent buffers when mounting a broken file system and it turns
> out it's because not everybody uses read_tree_block properly. You need to check
> and make sure the extent_buffer is uptodate before you use it. This patch fixes
> everybody who calls read_tree_block directly to make sure they check that it is
> uptodate and free it and return an error if it is not. With this we no longer
> leak EB's when things go horribly wrong. Thanks,
>
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
> @@ -2762,7 +2771,10 @@ static int get_tree_block_key(struct reloc_control *rc,
> BUG_ON(block->key_ready);
> eb = read_tree_block(rc->extent_root, block->bytenr,
> block->key.objectid, block->key.offset);
> - BUG_ON(!eb);
> + if (!eb || !extent_buffer_uptodate(eb)) {
> + free_extent_buffer(eb);
> + return -EIO;
The error code is not checked when called from relocate_tree_blocks:
2878 rb_node = rb_first(blocks);
2879 while (rb_node) {
2880 block = rb_entry(rb_node, struct tree_block, rb_node);
2881 if (!block->key_ready)
2882 get_tree_block_key(rc, block);
2883 rb_node = rb_next(rb_node);
2884 }
but the function is ready to return errors, I'll send this as a followup:
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2878,8 +2878,11 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
rb_node = rb_first(blocks);
while (rb_node) {
block = rb_entry(rb_node, struct tree_block, rb_node);
- if (!block->key_ready)
- get_tree_block_key(rc, block);
+ if (!block->key_ready) {
+ ret = get_tree_block_key(rc, block);
+ if (ret)
+ goto out_free_path;
+ }
rb_node = rb_next(rb_node);
}
@@ -2906,6 +2909,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
out:
err = finish_pending_nodes(trans, rc, path, err);
+out_free_path:
btrfs_free_path(path);
out_path:
free_block_list(blocks);
next prev parent reply other threads:[~2013-04-24 15:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 18:20 [PATCH] Btrfs: fix all callers of read_tree_block Josef Bacik
2013-04-24 8:17 ` Liu Bo
2013-04-24 13:07 ` Josef Bacik
2013-04-24 15:50 ` David Sterba [this message]
2013-07-30 15:11 ` Alex Lyakas
2013-07-30 15:40 ` Josef Bacik
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=20130424155011.GG16427@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=jbacik@fusionio.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.