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;
check_leaf(&path, 0);
out:
release_path(root, &path);
- wret = commit_transaction(root);
- if (wret)
- ret = wret;
return ret;
}
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;
}
}
}
- wret = commit_transaction(root);
- if (wret)
- ret = wret;
return ret;
}
}
int close_ctree(struct ctree_root *root)
{
+ commit_transaction(root);
drop_cache(root->extent_root);
drop_cache(root);
BUG_ON(!list_empty(&root->trans));
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);
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);
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;
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)
{
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;