[btrfs-devel][patch]fix get_bh and brelse issues when drop snapshot
Yan Zheng
yanzheng at 21cn.com
Sun Sep 23 20:00:25 PDT 2007
Hello,
When drop_progress isn't zero, the root->node's usage count is
increased in btrfs_search_slot. Therefore, the get_bh in the body of
while loop is redundant in most cases. (this change is in accordance
with btrfs_defrag_leaves).
The second change is decrease root->node's usage count when drop a snapshot.
Regards
YZ
diff -r 29b8cc7794ac extent-tree.c
--- a/extent-tree.c Thu Sep 20 14:14:42 2007 -0400
+++ b/extent-tree.c Sun Sep 23 12:35:00 2007 +0800
@@ -1483,6 +1483,7 @@ int btrfs_drop_snapshot(struct btrfs_tra
level = btrfs_header_level(btrfs_buffer_header(root->node));
orig_level = level;
if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
+ get_bh(root->node);
path->nodes[level] = root->node;
path->slots[level] = 0;
} else {
@@ -1516,7 +1517,6 @@ int btrfs_drop_snapshot(struct btrfs_tra
if (wret < 0)
ret = wret;
ret = -EAGAIN;
- get_bh(root->node);
break;
}
for (i = 0; i <= orig_level; i++) {
diff -r 29b8cc7794ac transaction.c
--- a/transaction.c Thu Sep 20 14:14:42 2007 -0400
+++ b/transaction.c Sun Sep 23 12:35:00 2007 +0800
@@ -457,6 +457,7 @@ static int drop_dirty_roots(struct btrfs
ret = btrfs_end_transaction(trans, tree_root);
BUG_ON(ret);
+ btrfs_block_release(dirty->root, dirty->root->node);
kfree(dirty->root);
kfree(dirty);
mutex_unlock(&tree_root->fs_info->fs_mutex);
More information about the Btrfs-devel
mailing list