Commit ad3c1188 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe
Browse files

btrfs: use blkdev_report_zones_cached()



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: default avatarDamien Le Moal <dlemoal@kernel.org>
Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1efbbc64
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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))