linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs: be smarter about dropping things from the tree log
Date: Fri, 28 Sep 2012 11:58:34 -0400	[thread overview]
Message-ID: <1348847914-2192-1-git-send-email-jbacik@fusionio.com> (raw)

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>
---
 fs/btrfs/tree-log.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 4e468a0..90e1c28 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2872,12 +2872,15 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
 	int ret;
 	struct btrfs_key key;
 	struct btrfs_key found_key;
+	int start_slot;
+	int del_nr = 0;
 
 	key.objectid = objectid;
 	key.type = max_key_type;
 	key.offset = (u64)-1;
 
 	while (1) {
+		del_nr = 0;
 		ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
 		BUG_ON(ret == 0);
 		if (ret < 0)
@@ -2885,20 +2888,29 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
 
 		if (path->slots[0] == 0)
 			break;
-
+next_slot:
 		path->slots[0]--;
+
 		btrfs_item_key_to_cpu(path->nodes[0], &found_key,
 				      path->slots[0]);
 
 		if (found_key.objectid != objectid)
 			break;
 
-		ret = btrfs_del_item(trans, log, path);
+		start_slot = path->slots[0];
+		del_nr++;
+		if (start_slot)
+			goto next_slot;
+
+		ret = btrfs_del_items(trans, log, path, start_slot, del_nr);
 		if (ret)
 			break;
 		btrfs_release_path(path);
 	}
+	if (!ret && del_nr)
+		ret = btrfs_del_items(trans, log, path, start_slot, del_nr);
 	btrfs_release_path(path);
+
 	if (ret > 0)
 		ret = 0;
 	return ret;
-- 
1.7.7.6


             reply	other threads:[~2012-09-28 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28 15:58 Josef Bacik [this message]
2012-09-28 17:45 ` [PATCH] Btrfs: be smarter about dropping things from the tree log Zach Brown
2012-10-01 16:47   ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348847914-2192-1-git-send-email-jbacik@fusionio.com \
    --to=jbacik@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).