浏览代码

Btrfs: only do the tree_mod_log_free_eb if this is our last ref

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,

Cc: stable@vger.kernel.org
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Josef Bacik 12 年之前
父节点
当前提交
7fb7d76f96
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      fs/btrfs/ctree.c

+ 2 - 1
fs/btrfs/ctree.c

@@ -1089,7 +1089,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
 		btrfs_set_node_ptr_generation(parent, parent_slot,
 		btrfs_set_node_ptr_generation(parent, parent_slot,
 					      trans->transid);
 					      trans->transid);
 		btrfs_mark_buffer_dirty(parent);
 		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,
 		btrfs_free_tree_block(trans, root, buf, parent_start,
 				      last_ref);
 				      last_ref);
 	}
 	}