]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: use blkdev_report_zones_cached()
authorDamien Le Moal <dlemoal@kernel.org>
Tue, 4 Nov 2025 21:22:48 +0000 (06:22 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 5 Nov 2025 15:07:21 +0000 (08:07 -0700)
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 <dlemoal@kernel.org>
Acked-by: David Sterba <dsterba@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/btrfs/zoned.c

index 0ea0df18a8e43ba194a52521becb46d169b51bcb..a16b1a896c7898101ad6d45e7108290fe14361f8 100644 (file)
@@ -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))