From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: Damien Le Moal <dlemoal@kernel.org>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: Naohiro Aota <Naohiro.Aota@wdc.com>, Boris Burkov <boris@bur.io>
Subject: Re: [PATCH 3/3] btrfs: zoned: limit number of zones reclaimed in flush_space
Date: Tue, 3 Mar 2026 09:07:51 +0000 [thread overview]
Message-ID: <6739b7b6-ec15-4276-9e37-a0d1701240aa@wdc.com> (raw)
In-Reply-To: <75b7fcfe-f8d5-47ae-abbb-871e418cbda0@kernel.org>
On 3/3/26 8:41 AM, Damien Le Moal wrote:
> On 3/2/26 23:39, Johannes Thumshirn wrote:
>> Limit the number of zones reclaimed in flush_space()'s RECLAIM_ZONES
>> state.
>>
>> This prevents possibly long running reclaim sweeps to block other tasks in
>> the system, while the system is under preassure anyways, causing the
> s/preassure/pressure
Oops. M-x flyspell would've helped :(
>
>> tasks to hang.
>>
> [...]
>> To prevent these long running reclaims from blocking the system, only
>> reclaim 5 block_groups in the RECLAIM_ZONES state of flush_space(). Also
> 5 seems very arbitrary. For a device with very large zones, this could still
> take some time and cause the problem again. Why not iterate the block groups one
> by one ? Is there any benefit to batching like this ?
I thought about limiting to the reclaim to a single block-group as well,
but this potentially leads us to a situation where we try to allocate,
run out of space, reclaim a block-group, try to allocate, run out of
space, reclaim a block-group, yada yada totally tanking performance.
So if we batch a few block-groups, we need to reclaim a few block-groups
(limiting to max 5) and then we at least have a bit of room to allocate
again. Potentially having time for a transaction commit coming in and
triggering the real (non emergency) garbage collection.
>> as these reclaims are now constrained, it opens up the use for a
>> synchronous call to brtfs_reclaim_block_groups(), eliminating the need
>> to place the reclaim task on a workqueue and then flushing the workqueue
>> again.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
>> -static int btrfs_reclaim_block_group(struct btrfs_block_group *bg)
>> +static int btrfs_reclaim_block_group(struct btrfs_block_group *bg, int *reclaimed)
>> {
>> struct btrfs_fs_info *fs_info = bg->fs_info;
>> struct btrfs_space_info *space_info = bg->space_info;
>> @@ -2036,15 +2036,17 @@ static int btrfs_reclaim_block_group(struct btrfs_block_group *bg)
>> if (space_info->total_bytes < old_total)
>> btrfs_set_periodic_reclaim_ready(space_info, true);
>> spin_unlock(&space_info->lock);
>> + (*reclaimed)++;
> If ret != 0, it means that btrfs_relocate_chunk() failed. So in that case,
> shouldn't you skip incrementing the reclaimed counter ?
True. We also increment the statistics if reclaim failed. Boris?
>>
>> return ret;
>> }
>
>
prev parent reply other threads:[~2026-03-03 9:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 14:39 [PATCH 0/3] btrfs: zoned: fix hang with generic/551 Johannes Thumshirn
2026-03-02 14:39 ` [PATCH 1/3] btrfs: move reclaiming of a single block group into its own function Johannes Thumshirn
2026-03-03 7:34 ` Damien Le Moal
2026-03-02 14:39 ` [PATCH 2/3] btrfs: create btrfs_reclaim_block_groups() Johannes Thumshirn
2026-03-03 7:34 ` Damien Le Moal
2026-03-02 14:39 ` [PATCH 3/3] btrfs: zoned: limit number of zones reclaimed in flush_space Johannes Thumshirn
2026-03-03 7:41 ` Damien Le Moal
2026-03-03 9:07 ` Johannes Thumshirn [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=6739b7b6-ec15-4276-9e37-a0d1701240aa@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=Naohiro.Aota@wdc.com \
--cc=boris@bur.io \
--cc=dlemoal@kernel.org \
--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