aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-02 09:47:58 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-02 09:47:58 -0500
commit11bc1cd2a565ab90f16dba2da40cba5e30128783 (patch)
tree4aff9b22200638211981451bbae62fd138a19581
parenta71a25da6968d3b681a04f5f9289a2ea4e192a79 (diff)
downloadbtrfs-progs-11bc1cd2a565ab90f16dba2da40cba5e30128783.tar.gz
btrfs-progs-11bc1cd2a565ab90f16dba2da40cba5e30128783.tar.xz
btrfs-progs-11bc1cd2a565ab90f16dba2da40cba5e30128783.zip
Fix extent code to use merge during delete
Remove implicit commit in del_item and insert_item Add implicit commit to close() Add commit op in random-test
-rw-r--r--ctree.c15
-rw-r--r--disk-io.c1
-rw-r--r--extent-tree.c4
-rw-r--r--random-test.c10
4 files changed, 14 insertions, 16 deletions
diff --git a/ctree.c b/ctree.c
index 57fa505..3c5f4c2 100644
--- a/ctree.c
+++ b/ctree.c
@@ -1065,11 +1065,7 @@ int insert_item(struct ctree_root *root, struct key *key,
ret = search_slot(root, key, &path, data_size);
if (ret == 0) {
release_path(root, &path);
- ret = -EEXIST;
- wret = commit_transaction(root);
- if (wret)
- ret = wret;
- return ret;
+ return -EEXIST;
}
if (ret < 0)
goto out;
@@ -1127,9 +1123,6 @@ int insert_item(struct ctree_root *root, struct key *key,
check_leaf(&path, 0);
out:
release_path(root, &path);
- wret = commit_transaction(root);
- if (wret)
- ret = wret;
return ret;
}
@@ -1245,7 +1238,8 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
wret = push_leaf_left(root, path, 1);
if (wret < 0)
ret = wret;
- if (leaf->header.nritems) {
+ if (path->nodes[0] == leaf_buf &&
+ leaf->header.nritems) {
wret = push_leaf_right(root, path, 1);
if (wret < 0)
ret = wret;
@@ -1265,9 +1259,6 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
}
}
}
- wret = commit_transaction(root);
- if (wret)
- ret = wret;
return ret;
}
diff --git a/disk-io.c b/disk-io.c
index 656ace6..f7ca536 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -239,6 +239,7 @@ static int drop_cache(struct ctree_root *root)
}
int close_ctree(struct ctree_root *root)
{
+ commit_transaction(root);
drop_cache(root->extent_root);
drop_cache(root);
BUG_ON(!list_empty(&root->trans));
diff --git a/extent-tree.c b/extent-tree.c
index 074f4b1..fb21444 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -39,7 +39,7 @@ static int del_pending_extents(struct ctree_root *extent_root)
key.flags = 0;
key.offset = 1;
init_path(&path);
- ret = search_slot(extent_root, &key, &path, 0);
+ ret = search_slot(extent_root, &key, &path, -1);
if (ret) {
print_tree(extent_root, extent_root->node);
printf("unable to find %Lu\n", key.objectid);
@@ -83,7 +83,7 @@ int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
return 0;
}
init_path(&path);
- ret = search_slot(extent_root, &key, &path, 0);
+ ret = search_slot(extent_root, &key, &path, -1);
if (ret) {
print_tree(extent_root, extent_root->node);
printf("failed to find %Lu\n", key.objectid);
diff --git a/random-test.c b/random-test.c
index bbd554e..2295575 100644
--- a/random-test.c
+++ b/random-test.c
@@ -59,6 +59,11 @@ error:
return -1;
}
+static int run_commit(struct ctree_root *root, struct radix_tree_root *radix)
+{
+ return commit_transaction(root);
+}
+
static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix)
{
struct ctree_path path;
@@ -233,7 +238,8 @@ static int bulk_op(struct ctree_root *root, struct radix_tree_root *radix)
int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) =
-{ ins_one, insert_dup, del_one, lookup_item, lookup_enoent, bulk_op };
+ { ins_one, insert_dup, del_one, lookup_item,
+ lookup_enoent, bulk_op, run_commit };
static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix)
{
@@ -366,7 +372,7 @@ int main(int ac, char **av)
err = ret;
goto out;
}
- if (ops[op] == bulk_op)
+ if (ops[op] == bulk_op || ops[op] == run_commit)
break;
if (keep_running == 0) {
err = 0;