From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
Pankaj Raghav <p.raghav@samsung.com>,
David Sterba <dsterba@suse.com>,
Naohiro Aota <Naohiro.Aota@wdc.com>
Cc: Josef Bacik <josef@toxicpanda.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Javier Gonzalez <javier.gonz@samsung.com>
Subject: Re: [PATCH 5/5] btrfs: zoned: make auto-reclaim less aggressive
Date: Thu, 24 Mar 2022 09:06:48 +0900 [thread overview]
Message-ID: <8d09bc99-0a7f-dcac-0d63-1979ba7dadba@opensource.wdc.com> (raw)
In-Reply-To: <PH0PR04MB7416D06ED74EE14B13C1DB3E9B189@PH0PR04MB7416.namprd04.prod.outlook.com>
On 3/23/22 20:52, Johannes Thumshirn wrote:
> On 23/03/2022 12:24, Pankaj Raghav wrote:
>>
>>
>> On 2022-03-23 11:39, Johannes Thumshirn wrote:
>>>
>>> It looks like we can't use btrfs_calc_available_free_space(), can
>>> you try this one on top:
>>>
>>> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
>>> index f2a412427921..4a6c1f1a7223 100644
>>> --- a/fs/btrfs/zoned.c
>>> +++ b/fs/btrfs/zoned.c
>>> @@ -2082,23 +2082,27 @@ void btrfs_free_zone_cache(struct btrfs_fs_info *fs_info)
>>>
>>> bool btrfs_zoned_should_reclaim(struct btrfs_fs_info *fs_info)
>>> {
>>> - struct btrfs_space_info *sinfo;
>>> + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
>>> + struct btrfs_device *device;
>>> u64 used = 0;
>>> u64 total = 0;
>>> u64 factor;
>>>
>>> - if (!btrfs_is_zoned(fs_info))
>>> - return false;
>>> -
>>> if (!fs_info->bg_reclaim_threshold)
>>> return false;
>>>
>>> - list_for_each_entry(sinfo, &fs_info->space_info, list) {
>>> - total += sinfo->total_bytes;
>>> - used += btrfs_calc_available_free_space(fs_info, sinfo,
>>> - BTRFS_RESERVE_NO_FLUSH);
>>> +
>>> + mutex_lock(&fs_devices->device_list_mutex);
>>> + list_for_each_entry(device, &fs_devices->devices, dev_list) {
>>> + if (!device->bdev)
>>> + continue;
>>> +
>>> + total += device->disk_total_bytes;
>>> + used += device->bytes_used;
Does bytes_used include all the unusable blocks between zone cap and zone
size for all zones ? If yes, then the calculation will be OK. If not, then
you will get an artificially low factor not reflecting the need for defrag.
>>> +
>>> }
>>> + mutex_unlock(&fs_devices->device_list_mutex);
>>>
>>> - factor = div_u64(used * 100, total);
>>> + factor = div64_u64(used * 100, total);
>>> return factor >= fs_info->bg_reclaim_threshold;
Not sure if the factor variable is really necessary here.
>>> }
>>>
>> size 1280M:
>> [ 47.511871] btrfs: factor: 30 used: 402653184, total: 1342177280
>> [ 48.542981] btrfs: factor: 30 used: 402653184, total: 1342177280
>> [ 49.576005] btrfs: factor: 30 used: 402653184, total: 1342177280
>> size: 12800M:
>> [ 33.971009] btrfs: factor: 3 used: 402653184, total: 13421772800
>> [ 34.978602] btrfs: factor: 3 used: 402653184, total: 13421772800
>> [ 35.991784] btrfs: factor: 3 used: 402653184, total: 13421772800
>> size: 12800M, zcap=96M zsze=128M:
>> [ 64.639103] btrfs: factor: 3 used: 402653184, total: 13421772800
>> [ 65.643778] btrfs: factor: 3 used: 402653184, total: 13421772800
>> [ 66.661920] btrfs: factor: 3 used: 402653184, total: 13421772800
>>
>> This looks good. And the test btrfs/237 is failing, as it should be
>> because of the change in reclaim condition. Are you planning to update
>> this test in fstests later?
>
> Yes, once I have an idea how to do. Probably just fill the FS until
> ~75% of the drive is filled and then use the original logic.
>
>> I still have one more question: shouldn't we use the usable disk bytes
>> (zcap * nr_zones) instead of disk_total_bytes (zsze * nr_zones) to
>> calculate the `total` variable? The `used` value is a part of the usable
>> disk space so I feel it makes more sense to calculate the `factor` with
>> the usable disk bytes instead of the disk_total_bytes.
>>
>
> disk_total_bytes comes from the value the underlying device driver set
> for the gendisk's capacity via set_capacity().
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2022-03-24 0:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 16:14 [PATCH 0/5] btrfs: rework background block group relocation Johannes Thumshirn
2022-03-21 16:14 ` [PATCH 1/5] btrfs: make the bg_reclaim_threshold per-space info Johannes Thumshirn
2022-03-22 17:32 ` Josef Bacik
2022-03-22 17:34 ` Johannes Thumshirn
2022-03-21 16:14 ` [PATCH 2/5] btrfs: allow block group background reclaim for !zoned fs'es Johannes Thumshirn
2022-03-22 17:38 ` Josef Bacik
2022-03-22 17:40 ` Johannes Thumshirn
2022-03-21 16:14 ` [PATCH 3/5] btrfs: change the bg_reclaim_threshold valid region from 0 to 100 Johannes Thumshirn
2022-03-21 16:14 ` [PATCH 4/5] btrfs: make calc_available_free_space available outside of space-info Johannes Thumshirn
2022-03-22 17:34 ` Josef Bacik
2022-03-21 16:14 ` [PATCH 5/5] btrfs: zoned: make auto-reclaim less aggressive Johannes Thumshirn
2022-03-23 9:08 ` Pankaj Raghav
2022-03-23 9:11 ` Johannes Thumshirn
2022-03-23 9:14 ` Pankaj Raghav
2022-03-23 10:39 ` Johannes Thumshirn
2022-03-23 11:24 ` Pankaj Raghav
2022-03-23 11:52 ` Johannes Thumshirn
2022-03-23 19:37 ` Pankaj Raghav
2022-03-24 0:06 ` Damien Le Moal [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=8d09bc99-0a7f-dcac-0d63-1979ba7dadba@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Johannes.Thumshirn@wdc.com \
--cc=Naohiro.Aota@wdc.com \
--cc=dsterba@suse.com \
--cc=javier.gonz@samsung.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.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