From: Josef Bacik <jbacik@fusionio.com>
To: Zach Brown <zab@zabbo.net>
Cc: Josef Bacik <JBacik@fusionio.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: be smarter about dropping things from the tree log
Date: Mon, 1 Oct 2012 12:47:20 -0400 [thread overview]
Message-ID: <20121001164720.GB2370@localhost.localdomain> (raw)
In-Reply-To: <20120928174521.GA9424@lenny.home.zabbo.net>
On Fri, Sep 28, 2012 at 11:45:21AM -0600, Zach Brown wrote:
> > 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,
>
> (speaking of unnecessary churn :))
>
> > +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;
>
> A linear backwards scan? Of potentially 64k leaves?
>
> Can you use bin_search() to look for the first key >= [objectid,0,0] in
> the leaf? And probably a single comparison of slot 0 to fast path the
> case where the whole leaf contains the object id?
>
Yeah I can do that.
> > + 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);
>
> You shouldn't have to duplicate deletion and releasing the path if you
> wrap the calculation of start_slot and nr in a helper. Something like:
>
> nr = find_nr_and_slot_doo_de_doo(, &start_slot);
> if (nr > 0)
> btrfs_del_items(, start_slot, nr);
K, I'll fix that up, thanks.
Josef
prev parent reply other threads:[~2012-10-01 16:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 15:58 [PATCH] Btrfs: be smarter about dropping things from the tree log Josef Bacik
2012-09-28 17:45 ` Zach Brown
2012-10-01 16:47 ` Josef Bacik [this message]
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=20121001164720.GB2370@localhost.localdomain \
--to=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=zab@zabbo.net \
/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).