From: Filipe Manana <fdmanana@kernel.org>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 07/12] btrfs: improve batch deletion of delayed dir index items
Date: Thu, 2 Jun 2022 09:55:02 +0100 [thread overview]
Message-ID: <20220602085502.GA3331364@falcondesktop> (raw)
In-Reply-To: <2cc71b46-7e53-d1a1-327f-39b28b18687e@suse.com>
On Thu, Jun 02, 2022 at 11:24:53AM +0300, Nikolay Borisov wrote:
>
>
> On 31.05.22 г. 18:06 ч., fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
>
> <snip>
>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> One small idea, see further down below though.
That's a rather different thing from what the patch intends, which
is just to improve the deletion of items in the btree.
Send that as a separate patch with a proper changelog.
Thanks.
>
> >
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> > ---
> > fs/btrfs/delayed-inode.c | 60 +++++++++++++++++-----------------------
> > 1 file changed, 25 insertions(+), 35 deletions(-)
> >
> > diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> > index 0125586fd565..74c806d3ab2a 100644
> > --- a/fs/btrfs/delayed-inode.c
> > +++ b/fs/btrfs/delayed-inode.c
> > @@ -791,68 +791,58 @@ static int btrfs_batch_delete_items(struct btrfs_trans_handle *trans,
> > {
>
> <snip>
>
> > + while (slot < last_slot) {
> > + struct btrfs_key key;
> > - curr = next;
> > next = __btrfs_next_delayed_item(curr);
> > if (!next)
> > break;
> > - if (!btrfs_is_continuous_delayed_item(curr, next))
> > + slot++;
> > + btrfs_item_key_to_cpu(leaf, &key, slot);
> > + if (btrfs_comp_cpu_keys(&next->key, &key) != 0)
> > break;
> > -
> > - i++;
> > - if (i > last_item)
> > - break;
> > - btrfs_item_key_to_cpu(leaf, &key, i);
> > + nitems++;
> > + curr = next;
> > + list_add_tail(&curr->tree_list, &batch_list);
> > }
> > - /*
> > - * Our caller always gives us a path pointing to an existing item, so
> > - * this can not happen.
> > - */
> > - ASSERT(nitems >= 1);
> > - if (nitems < 1)
> > - return -ENOENT;
> > -
> > ret = btrfs_del_items(trans, root, path, path->slots[0], nitems);
> > if (ret)
> > - goto out;
> > + return ret;
> > - list_for_each_entry_safe(curr, next, &head, tree_list) {
> > + list_for_each_entry_safe(curr, next, &batch_list, tree_list) {
> > btrfs_delayed_item_release_metadata(root, curr);
> > list_del(&curr->tree_list);
> > btrfs_release_delayed_item(curr);
> > }
>
> nit: This function could be further optimized
> with the following snippet.
>
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index fedbc45b71a2..950f5a2a9950 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -805,6 +805,7 @@ static int btrfs_batch_delete_items(struct btrfs_trans_handle *trans,
> LIST_HEAD(batch_list);
> int nitems, slot, last_slot;
> int ret;
> + u64 bytes_reserved = item->bytes_reserved;
> ASSERT(leaf != NULL);
> @@ -840,6 +841,7 @@ static int btrfs_batch_delete_items(struct btrfs_trans_handle *trans,
> break;
> nitems++;
> curr = next;
> + bytes_reserved += curr->bytes_reserved;
> list_add_tail(&curr->tree_list, &batch_list);
> }
> @@ -847,8 +849,11 @@ static int btrfs_batch_delete_items(struct btrfs_trans_handle *trans,
> if (ret)
> return ret;
> + btrfs_block_rsv_release(root->fs_info, &root->fs_info->delayed_block_rsv,
> + bytes_reserved, NULL);
> +
> list_for_each_entry_safe(curr, next, &batch_list, tree_list) {
> - btrfs_delayed_item_release_metadata(root, curr);
> + //btrfs_delayed_item_release_metadata(root, curr);
> list_del(&curr->tree_list);
> btrfs_release_delayed_item(curr);
> }
>
>
> Running your series VS this diff on top produces:
>
> Before this change:
> @block_rsv_release: 1004
> @btrfs_delete_delayed_items_total_time: 14602
> @delete_batches: 505
>
> After:
> @block_rsv_release: 510
> @btrfs_delete_delayed_items_total_time: 13643
> @delete_batches: 507
>
>
> > -out:
> > - return ret;
> > + return 0;
> > }
> > static int btrfs_delete_delayed_items(struct btrfs_trans_handle *trans,
next prev parent reply other threads:[~2022-06-02 8:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 15:06 [PATCH 00/12] btrfs: some improvements and cleanups around delayed items fdmanana
2022-05-31 15:06 ` [PATCH 01/12] btrfs: balance btree dirty pages and delayed items after a rename fdmanana
2022-05-31 15:16 ` Nikolay Borisov
2022-05-31 23:13 ` Anand Jain
2022-05-31 15:06 ` [PATCH 02/12] btrfs: free the path earlier when creating a new inode fdmanana
2022-05-31 15:21 ` Nikolay Borisov
2022-05-31 23:22 ` Anand Jain
2022-06-01 9:34 ` Filipe Manana
2022-06-01 11:11 ` Anand Jain
2022-06-01 11:51 ` David Sterba
2022-05-31 15:06 ` [PATCH 03/12] btrfs: balance btree dirty pages and delayed items after clone and dedupe fdmanana
2022-06-01 0:54 ` Anand Jain
2022-05-31 15:06 ` [PATCH 04/12] btrfs: add assertions when deleting batches of delayed items fdmanana
2022-06-01 1:34 ` Anand Jain
2022-05-31 15:06 ` [PATCH 05/12] btrfs: deal with deletion errors when deleting " fdmanana
2022-06-01 1:44 ` Anand Jain
2022-05-31 15:06 ` [PATCH 06/12] btrfs: refactor the delayed item deletion entry point fdmanana
2022-05-31 15:06 ` [PATCH 07/12] btrfs: improve batch deletion of delayed dir index items fdmanana
2022-06-02 8:24 ` Nikolay Borisov
2022-06-02 8:55 ` Filipe Manana [this message]
2022-05-31 15:06 ` [PATCH 08/12] btrfs: assert that delayed item is a dir index item when adding it fdmanana
2022-05-31 15:06 ` [PATCH 09/12] btrfs: improve batch insertion of delayed dir index items fdmanana
2022-05-31 15:06 ` [PATCH 10/12] btrfs: do not BUG_ON() on failure to reserve metadata for delayed item fdmanana
2022-05-31 15:06 ` [PATCH 11/12] btrfs: set delayed item type when initializing it fdmanana
2022-05-31 15:06 ` [PATCH 12/12] btrfs: reduce amount of reserved metadata for delayed item insertion fdmanana
2022-06-08 15:23 ` [btrfs] 62bd8124e2: WARNING:at_fs/btrfs/block-rsv.c:#btrfs_release_global_block_rsv[btrfs] kernel test robot
2022-06-09 9:46 ` Filipe Manana
2022-06-10 1:26 ` Oliver Sang
2022-06-12 14:36 ` Oliver Sang
2022-06-13 10:50 ` Filipe Manana
2022-06-16 2:42 ` Oliver Sang
2022-06-17 10:32 ` Filipe Manana
2022-06-01 18:35 ` [PATCH 00/12] btrfs: some improvements and cleanups around delayed items David Sterba
2022-06-02 9:34 ` Nikolay Borisov
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=20220602085502.GA3331364@falcondesktop \
--to=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/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