]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: zoned: cache reported zone during mount
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 11 Nov 2021 05:14:38 +0000 (14:14 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jan 2022 14:09:44 +0000 (15:09 +0100)
commit956eb010f46f4a367404773a03d4f53332b6e9ff
treee910dca597ba55b01665ef97b6fc812f9245984a
parent08744daef2502e0b65a2f6327e2c7635d9cd9401
btrfs: zoned: cache reported zone during mount

When mounting a device, we are reporting the zones twice: once for
checking the zone attributes in btrfs_get_dev_zone_info and once for
loading block groups' zone info in
btrfs_load_block_group_zone_info(). With a lot of block groups, that
leads to a lot of REPORT ZONE commands and slows down the mount
process.

This patch introduces a zone info cache in struct
btrfs_zoned_device_info. The cache is populated while in
btrfs_get_dev_zone_info() and used for
btrfs_load_block_group_zone_info() to reduce the number of REPORT ZONE
commands. The zone cache is then released after loading the block
groups, as it will not be much effective during the run time.

Benchmark: Mount an HDD with 57,007 block groups
Before patch: 171.368 seconds
After patch: 64.064 seconds

While it still takes a minute due to the slowness of loading all the
block groups, the patch reduces the mount time by 1/3.

Link: https://lore.kernel.org/linux-btrfs/CAHQ7scUiLtcTqZOMMY5kbWUBOhGRwKo6J6wYPT5WY+C=cD49nQ@mail.gmail.com/
Fixes: d89afd871112 ("btrfs: get zone information of zoned block devices")
CC: stable@vger.kernel.org
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dev-replace.c
fs/btrfs/disk-io.c
fs/btrfs/volumes.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h