aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
commitf0930a37f1c096c3a8f6a17b1e251c7fdf4d4457 (patch)
tree51b569606b25cd5ef903f9ef97734a1f6ec291d2 /fs
parented2ff2cba766dfe7976a0113f667c9a0a50dff02 (diff)
Btrfs: 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 Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.c15
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/extent-tree.c4
-rw-r--r--fs/btrfs/random-test.c10
4 files changed, 14 insertions, 16 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 57fa505fb9f6..3c5f4c2dd525 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1065,11 +1065,7 @@ int insert_item(struct ctree_root *root, struct key *key,
1065 ret = search_slot(root, key, &path, data_size); 1065 ret = search_slot(root, key, &path, data_size);
1066 if (ret == 0) { 1066 if (ret == 0) {
1067 release_path(root, &path); 1067 release_path(root, &path);
1068 ret = -EEXIST; 1068 return -EEXIST;
1069 wret = commit_transaction(root);
1070 if (wret)
1071 ret = wret;
1072 return ret;
1073 } 1069 }
1074 if (ret < 0) 1070 if (ret < 0)
1075 goto out; 1071 goto out;
@@ -1127,9 +1123,6 @@ int insert_item(struct ctree_root *root, struct key *key,
1127 check_leaf(&path, 0); 1123 check_leaf(&path, 0);
1128out: 1124out:
1129 release_path(root, &path); 1125 release_path(root, &path);
1130 wret = commit_transaction(root);
1131 if (wret)
1132 ret = wret;
1133 return ret; 1126 return ret;
1134} 1127}
1135 1128
@@ -1245,7 +1238,8 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
1245 wret = push_leaf_left(root, path, 1); 1238 wret = push_leaf_left(root, path, 1);
1246 if (wret < 0) 1239 if (wret < 0)
1247 ret = wret; 1240 ret = wret;
1248 if (leaf->header.nritems) { 1241 if (path->nodes[0] == leaf_buf &&
1242 leaf->header.nritems) {
1249 wret = push_leaf_right(root, path, 1); 1243 wret = push_leaf_right(root, path, 1);
1250 if (wret < 0) 1244 if (wret < 0)
1251 ret = wret; 1245 ret = wret;
@@ -1265,9 +1259,6 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
1265 } 1259 }
1266 } 1260 }
1267 } 1261 }
1268 wret = commit_transaction(root);
1269 if (wret)
1270 ret = wret;
1271 return ret; 1262 return ret;
1272} 1263}
1273 1264
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 656ace6147a8..f7ca5362291e 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -239,6 +239,7 @@ static int drop_cache(struct ctree_root *root)
239} 239}
240int close_ctree(struct ctree_root *root) 240int close_ctree(struct ctree_root *root)
241{ 241{
242 commit_transaction(root);
242 drop_cache(root->extent_root); 243 drop_cache(root->extent_root);
243 drop_cache(root); 244 drop_cache(root);
244 BUG_ON(!list_empty(&root->trans)); 245 BUG_ON(!list_empty(&root->trans));
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 074f4b182f16..fb2144496215 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -39,7 +39,7 @@ static int del_pending_extents(struct ctree_root *extent_root)
39 key.flags = 0; 39 key.flags = 0;
40 key.offset = 1; 40 key.offset = 1;
41 init_path(&path); 41 init_path(&path);
42 ret = search_slot(extent_root, &key, &path, 0); 42 ret = search_slot(extent_root, &key, &path, -1);
43 if (ret) { 43 if (ret) {
44 print_tree(extent_root, extent_root->node); 44 print_tree(extent_root, extent_root->node);
45 printf("unable to find %Lu\n", key.objectid); 45 printf("unable to find %Lu\n", key.objectid);
@@ -83,7 +83,7 @@ int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
83 return 0; 83 return 0;
84 } 84 }
85 init_path(&path); 85 init_path(&path);
86 ret = search_slot(extent_root, &key, &path, 0); 86 ret = search_slot(extent_root, &key, &path, -1);
87 if (ret) { 87 if (ret) {
88 print_tree(extent_root, extent_root->node); 88 print_tree(extent_root, extent_root->node);
89 printf("failed to find %Lu\n", key.objectid); 89 printf("failed to find %Lu\n", key.objectid);
diff --git a/fs/btrfs/random-test.c b/fs/btrfs/random-test.c
index bbd554e88db2..22955753c3a7 100644
--- a/fs/btrfs/random-test.c
+++ b/fs/btrfs/random-test.c
@@ -59,6 +59,11 @@ error:
59 return -1; 59 return -1;
60} 60}
61 61
62static int run_commit(struct ctree_root *root, struct radix_tree_root *radix)
63{
64 return commit_transaction(root);
65}
66
62static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix) 67static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix)
63{ 68{
64 struct ctree_path path; 69 struct ctree_path path;
@@ -233,7 +238,8 @@ static int bulk_op(struct ctree_root *root, struct radix_tree_root *radix)
233 238
234 239
235int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) = 240int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) =
236{ ins_one, insert_dup, del_one, lookup_item, lookup_enoent, bulk_op }; 241 { ins_one, insert_dup, del_one, lookup_item,
242 lookup_enoent, bulk_op, run_commit };
237 243
238static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix) 244static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix)
239{ 245{
@@ -366,7 +372,7 @@ int main(int ac, char **av)
366 err = ret; 372 err = ret;
367 goto out; 373 goto out;
368 } 374 }
369 if (ops[op] == bulk_op) 375 if (ops[op] == bulk_op || ops[op] == run_commit)
370 break; 376 break;
371 if (keep_running == 0) { 377 if (keep_running == 0) {
372 err = 0; 378 err = 0;