From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: Naohiro Aota <Naohiro.Aota@wdc.com>
Cc: Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Damien Le Moal <dlemoal@kernel.org>
Subject: Re: [PATCH 2/2] btrfs: zoned: wake up cleaner sooner if needed
Date: Mon, 22 Jan 2024 14:43:03 +0000 [thread overview]
Message-ID: <2fa9112d-a72a-440f-a32a-199b5350b59d@wdc.com> (raw)
In-Reply-To: <k7fiky6xm4hshkr5q2xukfjndcseiesfanlpc4oozztvuyclbw@ftrhgjeicsfs>
On 22.01.24 15:39, Naohiro Aota wrote:
>>>
>>> Also, looking into btrfs_zoned_should_reclaim(), it sums device->bytes_used
>>> for each fs_devices->devices. And, device->bytes_used is set at
>>> create_chunk() or at btrfs_remove_chunk(). Isn't it feasible to do the
>>> calculation only there?
>>
>> Oh sh*t! Right we should check bytes_used from all space_infos in
>> btrfs_zoned_should_reclaim() and compare that to the disk total bytes.
>
> You mean device->bytes_used? space_info->bytes_used does not count free
> space and zone_unusable in BGs, so using that changes the behavior. Even,
> it won't kick the thread if there are many zone_unusable but small used
> space.
>
I did mean btrfs_space_info_used():
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index b7e7b5a5a6fa..d5242c96c97c 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2414,6 +2414,7 @@ bool btrfs_zoned_should_reclaim(struct
btrfs_fs_info *fs_info)
{
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
struct btrfs_device *device;
+ struct btrfs_space_info *space_info;
u64 used = 0;
u64 total = 0;
u64 factor;
@@ -2429,10 +2430,15 @@ bool btrfs_zoned_should_reclaim(struct
btrfs_fs_info *fs_info)
continue;
total += device->disk_total_bytes;
- used += device->bytes_used;
}
rcu_read_unlock();
+ list_for_each_entry(space_info, &fs_info->space_info, list) {
+ spin_lock(&space_info->lock);
+ used += btrfs_space_info_used(space_info, true);
+ spin_unlock(&space_info->lock);
+ }
+
factor = div64_u64(used * 100, total);
return factor >= fs_info->bg_reclaim_threshold;
}
next prev parent reply other threads:[~2024-01-22 14:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 10:51 [PATCH 0/2] btrfs: zoned: kick reclaim earlier on fast zoned devices Johannes Thumshirn
2024-01-22 10:51 ` [PATCH 1/2] btrfs: zoned: use rcu list for iterating devices to collect stats Johannes Thumshirn
2024-01-22 12:12 ` Naohiro Aota
2024-01-22 21:34 ` David Sterba
2024-01-23 7:49 ` Johannes Thumshirn
2024-01-23 18:35 ` David Sterba
2024-01-22 10:51 ` [PATCH 2/2] btrfs: zoned: wake up cleaner sooner if needed Johannes Thumshirn
2024-01-22 12:22 ` Naohiro Aota
2024-01-22 12:30 ` Johannes Thumshirn
2024-01-22 14:39 ` Naohiro Aota
2024-01-22 14:43 ` Johannes Thumshirn [this message]
2024-01-22 15:26 ` Naohiro Aota
2024-01-22 23:51 ` Boris Burkov
2024-01-22 16:04 ` [PATCH 0/2] btrfs: zoned: kick reclaim earlier on fast zoned devices 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=2fa9112d-a72a-440f-a32a-199b5350b59d@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=Naohiro.Aota@wdc.com \
--cc=dlemoal@kernel.org \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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