From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
David Sterba <dsterba@suse.cz>,
Naohiro Aota <Naohiro.Aota@wdc.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: zoned: use greedy gc for auto reclaim
Date: Wed, 13 Oct 2021 15:52:26 +0200 [thread overview]
Message-ID: <20211013135226.GG9286@twin.jikos.cz> (raw)
In-Reply-To: <3d5b7f4e-646b-8430-6970-e287ebbb7719@suse.com>
On Tue, Oct 12, 2021 at 04:56:01PM +0300, Nikolay Borisov wrote:
> On 12.10.21 г. 15:37, Johannes Thumshirn wrote:
> > Currently auto reclaim of unusable zones reclaims the block-groups in the
> > order they have been added to the reclaim list.
> >
> > Change this to a greedy algorithm by sorting the list so we have the
> > block-groups with the least amount of valid bytes reclaimed first.
> >
> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> >
> > ---
> > Changes since v1:
> > - Changed list_sort() comparator to 'boolean' style
> >
> > Changes since RFC:
> > - Updated the patch description
> > - Don't sort the list under the spin_lock (David)
>
> <snip>
>
>
> > @@ -1510,17 +1528,20 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
> > }
> >
> > spin_lock(&fs_info->unused_bgs_lock);
> > - while (!list_empty(&fs_info->reclaim_bgs)) {
> > + list_splice_init(&fs_info->reclaim_bgs, &reclaim_list);
> > + spin_unlock(&fs_info->unused_bgs_lock);
> > +
> > + list_sort(NULL, &reclaim_list, reclaim_bgs_cmp);
> > + while (!list_empty(&reclaim_list)) {
>
> Nit: Now that you've switched to a local reclaim_list you can convert
> the while to a list_for_each_entry_safe, since it's guaranteed that new
> entries can't be added while you are iterating the list, which is
> generally the reason why a while() is preferred to one of the iteration
> helpers.
Like the following? I'll fold it in if yes:
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1507,7 +1507,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
{
struct btrfs_fs_info *fs_info =
container_of(work, struct btrfs_fs_info, reclaim_bgs_work);
- struct btrfs_block_group *bg;
+ struct btrfs_block_group *bg, *tmp;
struct btrfs_space_info *space_info;
LIST_HEAD(again_list);
LIST_HEAD(reclaim_list);
@@ -1532,13 +1532,10 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
spin_unlock(&fs_info->unused_bgs_lock);
list_sort(NULL, &reclaim_list, reclaim_bgs_cmp);
- while (!list_empty(&reclaim_list)) {
+ list_for_each_entry_safe(bg, tmp, &reclaim_list, bg_list) {
u64 zone_unusable;
int ret = 0;
- bg = list_first_entry(&reclaim_list,
- struct btrfs_block_group,
- bg_list);
list_del_init(&bg->bg_list);
space_info = bg->space_info;
---
next prev parent reply other threads:[~2021-10-13 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 12:37 [PATCH v2] btrfs: zoned: use greedy gc for auto reclaim Johannes Thumshirn
2021-10-12 13:56 ` Nikolay Borisov
2021-10-13 13:52 ` David Sterba [this message]
2021-10-13 14:14 ` Nikolay Borisov
2021-10-13 14:18 ` Nikolay Borisov
2021-10-14 6:59 ` Johannes Thumshirn
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=20211013135226.GG9286@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=Naohiro.Aota@wdc.com \
--cc=johannes.thumshirn@wdc.com \
--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