aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2012-09-28 11:56:28 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-09 09:15:41 -0400
commit18ec90d63f43cf785f6e73e7a7db546bff3fa380 (patch)
tree1f75eeb616202d30d331149c922525fbd25b84d8 /fs/btrfs/tree-log.c
parent6f1fed775316d58ba356b2ce62de600ad00f003a (diff)
Btrfs: be smarter about dropping things from the tree log
When we truncate existing items in the tree log we've been searching for each individual item and removing them. This is unnecessary churn and searching, just keep track of the slot we are on and how many items we need to delete and delete them all at once. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 31b46a9e94cc..179fda964601 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2901,6 +2901,7 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
2901 int ret; 2901 int ret;
2902 struct btrfs_key key; 2902 struct btrfs_key key;
2903 struct btrfs_key found_key; 2903 struct btrfs_key found_key;
2904 int start_slot;
2904 2905
2905 key.objectid = objectid; 2906 key.objectid = objectid;
2906 key.type = max_key_type; 2907 key.type = max_key_type;
@@ -2922,8 +2923,18 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
2922 if (found_key.objectid != objectid) 2923 if (found_key.objectid != objectid)
2923 break; 2924 break;
2924 2925
2925 ret = btrfs_del_item(trans, log, path); 2926 found_key.offset = 0;
2926 if (ret) 2927 found_key.type = 0;
2928 ret = btrfs_bin_search(path->nodes[0], &found_key, 0,
2929 &start_slot);
2930
2931 ret = btrfs_del_items(trans, log, path, start_slot,
2932 path->slots[0] - start_slot + 1);
2933 /*
2934 * If start slot isn't 0 then we don't need to re-search, we've
2935 * found the last guy with the objectid in this tree.
2936 */
2937 if (ret || start_slot != 0)
2927 break; 2938 break;
2928 btrfs_release_path(path); 2939 btrfs_release_path(path);
2929 } 2940 }