diff mbox

[5/6] Btrfs: fix extent buffer reference for tree mod log roots

Message ID 1351000527-24952-6-git-send-email-list.btrfs@jan-o-sch.net (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Schmidt Oct. 23, 2012, 1:55 p.m. UTC
In get_old_root we grab a lock on the extent buffer before we obtain a
reference on that buffer. That order is changed now.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
---
 fs/btrfs/ctree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Liu Bo Oct. 23, 2012, 3:32 p.m. UTC | #1
On 10/23/2012 09:55 PM, Jan Schmidt wrote:
> In get_old_root we grab a lock on the extent buffer before we obtain a
> reference on that buffer. That order is changed now.
> 


Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

thanks,
liubo

> Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
> ---
>  fs/btrfs/ctree.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 7093ff5..bed06e8 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -1274,6 +1274,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
>  	free_extent_buffer(root->node);
>  	if (!eb)
>  		return NULL;
> +	extent_buffer_get(eb);
>  	btrfs_tree_read_lock(eb);
>  	if (old_root) {
>  		btrfs_set_header_bytenr(eb, eb->start);
> @@ -1286,7 +1287,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
>  		__tree_mod_log_rewind(eb, time_seq, tm);
>  	else
>  		WARN_ON(btrfs_header_level(eb) != 0);
> -	extent_buffer_get(eb);
>  	WARN_ON(btrfs_header_nritems(eb) > BTRFS_NODEPTRS_PER_BLOCK(root));
>  
>  	return eb;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 7093ff5..bed06e8 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1274,6 +1274,7 @@  get_old_root(struct btrfs_root *root, u64 time_seq)
 	free_extent_buffer(root->node);
 	if (!eb)
 		return NULL;
+	extent_buffer_get(eb);
 	btrfs_tree_read_lock(eb);
 	if (old_root) {
 		btrfs_set_header_bytenr(eb, eb->start);
@@ -1286,7 +1287,6 @@  get_old_root(struct btrfs_root *root, u64 time_seq)
 		__tree_mod_log_rewind(eb, time_seq, tm);
 	else
 		WARN_ON(btrfs_header_level(eb) != 0);
-	extent_buffer_get(eb);
 	WARN_ON(btrfs_header_nritems(eb) > BTRFS_NODEPTRS_PER_BLOCK(root));
 
 	return eb;