Modify btrfs_get_dev_zones() and btrfs_sb_log_location_bdev() to replace
the call to blkdev_report_zones() with blkdev_report_zones_cached() to
speed-up mount operations. btrfs_get_dev_zone_info() is also modified to
take into account the BLK_ZONE_COND_ACTIVE condition, which is
equivalent to either BLK_ZONE_COND_IMP_OPEN, BLK_ZONE_COND_EXP_OPEN or
BLK_ZONE_COND_CLOSED.

With this change, mounting a freshly formatted large capacity (30 TB)
SMR HDD completes under 100ms compared to over 1.8s before.

Signed-off-by: Damien Le Moal <[email protected]>
Acked-by: David Sterba <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
---
 fs/btrfs/zoned.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 0ea0df18a8e4..a16b1a896c78 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -264,8 +264,8 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, 
u64 pos,
                }
        }
 
-       ret = blkdev_report_zones(device->bdev, pos >> SECTOR_SHIFT, *nr_zones,
-                                 copy_zone_info_cb, zones);
+       ret = blkdev_report_zones_cached(device->bdev, pos >> SECTOR_SHIFT,
+                                        *nr_zones, copy_zone_info_cb, zones);
        if (ret < 0) {
                btrfs_err(device->fs_info,
                                 "zoned: failed to read zone %llu on %s (devid 
%llu)",
@@ -494,6 +494,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, 
bool populate_cache)
                        case BLK_ZONE_COND_IMP_OPEN:
                        case BLK_ZONE_COND_EXP_OPEN:
                        case BLK_ZONE_COND_CLOSED:
+                       case BLK_ZONE_COND_ACTIVE:
                                __set_bit(nreported, zone_info->active_zones);
                                nactive++;
                                break;
@@ -896,9 +897,9 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, 
int mirror, int rw,
        if (sb_zone + 1 >= nr_zones)
                return -ENOENT;
 
-       ret = blkdev_report_zones(bdev, zone_start_sector(sb_zone, bdev),
-                                 BTRFS_NR_SB_LOG_ZONES, copy_zone_info_cb,
-                                 zones);
+       ret = blkdev_report_zones_cached(bdev, zone_start_sector(sb_zone, bdev),
+                                        BTRFS_NR_SB_LOG_ZONES,
+                                        copy_zone_info_cb, zones);
        if (ret < 0)
                return ret;
        if (unlikely(ret != BTRFS_NR_SB_LOG_ZONES))
-- 
2.51.0


Reply via email to