On Thu, Feb 17, 2022 at 01:50:56PM +0900, Naohiro Aota wrote: > commit 16beac87e95e2fb278b552397c8260637f8a63f7 upstream. > > 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@xxxxxxxxxxxxxx/ > Fixes: 5b316468983d ("btrfs: get zone information of zoned block devices") > CC: stable@xxxxxxxxxxxxxxx > Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx> > Signed-off-by: David Sterba <dsterba@xxxxxxxx> > --- > fs/btrfs/dev-replace.c | 2 +- > fs/btrfs/disk-io.c | 2 + > fs/btrfs/volumes.c | 2 +- > fs/btrfs/zoned.c | 85 ++++++++++++++++++++++++++++++++++++++---- > fs/btrfs/zoned.h | 8 +++- > 5 files changed, 87 insertions(+), 12 deletions(-) Now queued up, thanks. greg k-h