All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref
@ 2013-07-01 20:12 Josef Bacik
  2013-07-02  7:36 ` Jan Schmidt
  2013-07-03  3:26 ` Liu Bo
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2013-07-01 20:12 UTC (permalink / raw)
  To: linux-btrfs

There is another bug in the tree mod log stuff in that we're calling
tree_mod_log_free_eb every single time a block is cow'ed.  The problem with this
is that if this block is shared by multiple snapshots we will call this multiple
times per block, so if we go to rewind the mod log for this block we'll BUG_ON()
in __tree_mod_log_rewind because we try to rewind a free twice.  We only want to
call tree_mod_log_free_eb if we are actually freeing the block.  With this patch
I no longer hit the panic in __tree_mod_log_rewind.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
 fs/btrfs/ctree.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 32e30ad..127e1fd 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1093,7 +1093,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
 		btrfs_set_node_ptr_generation(parent, parent_slot,
 					      trans->transid);
 		btrfs_mark_buffer_dirty(parent);
-		tree_mod_log_free_eb(root->fs_info, buf);
+		if (last_ref)
+			tree_mod_log_free_eb(root->fs_info, buf);
 		btrfs_free_tree_block(trans, root, buf, parent_start,
 				      last_ref);
 	}
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref
  2013-07-01 20:12 [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref Josef Bacik
@ 2013-07-02  7:36 ` Jan Schmidt
  2013-07-03  3:26 ` Liu Bo
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Schmidt @ 2013-07-02  7:36 UTC (permalink / raw)
  To: linux-btrfs

(resent to list)

On Mon, July 01, 2013 at 22:12 (+0200), Josef Bacik wrote:
> There is another bug in the tree mod log stuff in that we're calling
> tree_mod_log_free_eb every single time a block is cow'ed.  The problem with this
> is that if this block is shared by multiple snapshots we will call this multiple
> times per block, so if we go to rewind the mod log for this block we'll BUG_ON()
> in __tree_mod_log_rewind because we try to rewind a free twice.  We only want to
> call tree_mod_log_free_eb if we are actually freeing the block.  With this patch
> I no longer hit the panic in __tree_mod_log_rewind.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>

Strange that never really popped up largely so far, should be quite easy to hit.
Anyway,

Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>

> ---
>  fs/btrfs/ctree.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 32e30ad..127e1fd 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -1093,7 +1093,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
>  		btrfs_set_node_ptr_generation(parent, parent_slot,
>  					      trans->transid);
>  		btrfs_mark_buffer_dirty(parent);
> -		tree_mod_log_free_eb(root->fs_info, buf);
> +		if (last_ref)
> +			tree_mod_log_free_eb(root->fs_info, buf);
>  		btrfs_free_tree_block(trans, root, buf, parent_start,
>  				      last_ref);
>  	}
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref
  2013-07-01 20:12 [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref Josef Bacik
  2013-07-02  7:36 ` Jan Schmidt
@ 2013-07-03  3:26 ` Liu Bo
  1 sibling, 0 replies; 3+ messages in thread
From: Liu Bo @ 2013-07-03  3:26 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs

On Mon, Jul 01, 2013 at 04:12:27PM -0400, Josef Bacik wrote:
> There is another bug in the tree mod log stuff in that we're calling
> tree_mod_log_free_eb every single time a block is cow'ed.  The problem with this
> is that if this block is shared by multiple snapshots we will call this multiple
> times per block, so if we go to rewind the mod log for this block we'll BUG_ON()
> in __tree_mod_log_rewind because we try to rewind a free twice.  We only want to
> call tree_mod_log_free_eb if we are actually freeing the block.  With this patch
> I no longer hit the panic in __tree_mod_log_rewind.  Thanks,

This fixes my reproducer for __tree_mod_log_rewind() BUG_ON in line 1183.

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

> 
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> ---
>  fs/btrfs/ctree.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 32e30ad..127e1fd 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -1093,7 +1093,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
>  		btrfs_set_node_ptr_generation(parent, parent_slot,
>  					      trans->transid);
>  		btrfs_mark_buffer_dirty(parent);
> -		tree_mod_log_free_eb(root->fs_info, buf);
> +		if (last_ref)
> +			tree_mod_log_free_eb(root->fs_info, buf);
>  		btrfs_free_tree_block(trans, root, buf, parent_start,
>  				      last_ref);
>  	}
> -- 
> 1.7.7.6
> 
> --
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-03  3:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-01 20:12 [PATCH] Btrfs: only do the tree_mod_log_free_eb if this is our last ref Josef Bacik
2013-07-02  7:36 ` Jan Schmidt
2013-07-03  3:26 ` Liu Bo

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.