Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: simplify disk_set_zoned

Only use disk_set_zoned to actually enable zoned device support.
For clearing it, call disk_clear_zoned, which is renamed from
disk_clear_zone_settings and now directly clears the zoned flag as
well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20231217165359.604246-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
d73e93b4 7437bb73

+23 -30
+10 -20
block/blk-settings.c
··· 881 881 EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging); 882 882 883 883 /** 884 - * disk_set_zoned - configure the zoned model for a disk 885 - * @disk: the gendisk of the queue to configure 886 - * @zoned: zoned or not. 887 - * 888 - * When @zoned is %true, this should be called only if zoned block device 889 - * support is enabled (CONFIG_BLK_DEV_ZONED option). 884 + * disk_set_zoned - inidicate a zoned device 885 + * @disk: gendisk to configure 890 886 */ 891 - void disk_set_zoned(struct gendisk *disk, bool zoned) 887 + void disk_set_zoned(struct gendisk *disk) 892 888 { 893 889 struct request_queue *q = disk->queue; 894 890 895 - if (zoned) { 896 - WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED)); 891 + WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED)); 897 892 898 - /* 899 - * Set the zone write granularity to the device logical block 900 - * size by default. The driver can change this value if needed. 901 - */ 902 - q->limits.zoned = true; 903 - blk_queue_zone_write_granularity(q, 904 - queue_logical_block_size(q)); 905 - } else if (q->limits.zoned) { 906 - q->limits.zoned = false; 907 - disk_clear_zone_settings(disk); 908 - } 893 + /* 894 + * Set the zone write granularity to the device logical block 895 + * size by default. The driver can change this value if needed. 896 + */ 897 + q->limits.zoned = true; 898 + blk_queue_zone_write_granularity(q, queue_logical_block_size(q)); 909 899 } 910 900 EXPORT_SYMBOL_GPL(disk_set_zoned); 911 901
+2 -1
block/blk-zoned.c
··· 616 616 } 617 617 EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones); 618 618 619 - void disk_clear_zone_settings(struct gendisk *disk) 619 + void disk_clear_zoned(struct gendisk *disk) 620 620 { 621 621 struct request_queue *q = disk->queue; 622 622 623 623 blk_mq_freeze_queue(q); 624 624 625 + q->limits.zoned = false; 625 626 disk_free_zone_bitmaps(disk); 626 627 blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q); 627 628 q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
-2
block/blk.h
··· 395 395 396 396 #ifdef CONFIG_BLK_DEV_ZONED 397 397 void disk_free_zone_bitmaps(struct gendisk *disk); 398 - void disk_clear_zone_settings(struct gendisk *disk); 399 398 int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, 400 399 unsigned long arg); 401 400 int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, 402 401 unsigned int cmd, unsigned long arg); 403 402 #else /* CONFIG_BLK_DEV_ZONED */ 404 403 static inline void disk_free_zone_bitmaps(struct gendisk *disk) {} 405 - static inline void disk_clear_zone_settings(struct gendisk *disk) {} 406 404 static inline int blkdev_report_zones_ioctl(struct block_device *bdev, 407 405 unsigned int cmd, unsigned long arg) 408 406 {
+1 -1
drivers/block/null_blk/zoned.c
··· 159 159 struct nullb_device *dev = nullb->dev; 160 160 struct request_queue *q = nullb->q; 161 161 162 - disk_set_zoned(nullb->disk, true); 162 + disk_set_zoned(nullb->disk); 163 163 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); 164 164 blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE); 165 165 blk_queue_chunk_sectors(q, dev->zone_size_sects);
+1 -1
drivers/block/ublk_drv.c
··· 250 250 { 251 251 const struct ublk_param_zoned *p = &ub->params.zoned; 252 252 253 - disk_set_zoned(ub->ub_disk, true); 253 + disk_set_zoned(ub->ub_disk); 254 254 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ub->ub_disk->queue); 255 255 blk_queue_required_elevator_features(ub->ub_disk->queue, 256 256 ELEVATOR_F_ZBD_SEQ_WRITE);
+1 -1
drivers/block/virtio_blk.c
··· 730 730 731 731 dev_dbg(&vdev->dev, "probing host-managed zoned device\n"); 732 732 733 - disk_set_zoned(vblk->disk, true); 733 + disk_set_zoned(vblk->disk); 734 734 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); 735 735 736 736 virtio_cread(vdev, struct virtio_blk_config,
+1 -1
drivers/nvme/host/zns.c
··· 108 108 goto free_data; 109 109 } 110 110 111 - disk_set_zoned(ns->disk, true); 111 + disk_set_zoned(ns->disk); 112 112 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); 113 113 disk_set_max_open_zones(ns->disk, le32_to_cpu(id->mor) + 1); 114 114 disk_set_max_active_zones(ns->disk, le32_to_cpu(id->mar) + 1);
+5 -2
drivers/scsi/sd.c
··· 3135 3135 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); 3136 3136 } 3137 3137 3138 + 3139 + #ifdef CONFIG_BLK_DEV_ZONED /* sd_probe rejects ZBD devices early otherwise */ 3138 3140 if (sdkp->device->type == TYPE_ZBC) { 3139 3141 /* 3140 3142 * Host-managed. 3141 3143 */ 3142 - disk_set_zoned(sdkp->disk, true); 3144 + disk_set_zoned(sdkp->disk); 3143 3145 3144 3146 /* 3145 3147 * Per ZBC and ZAC specifications, writes in sequential write ··· 3154 3152 * Anything else. This includes host-aware device that we treat 3155 3153 * as conventional. 3156 3154 */ 3157 - disk_set_zoned(sdkp->disk, false); 3155 + disk_clear_zoned(sdkp->disk); 3158 3156 } 3157 + #endif /* CONFIG_BLK_DEV_ZONED */ 3159 3158 3160 3159 if (!sdkp->first_scan) 3161 3160 return;
+2 -1
include/linux/blkdev.h
··· 317 317 typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx, 318 318 void *data); 319 319 320 - void disk_set_zoned(struct gendisk *disk, bool zoned); 320 + void disk_set_zoned(struct gendisk *disk); 321 + void disk_clear_zoned(struct gendisk *disk); 321 322 322 323 #define BLK_ALL_ZONES ((unsigned int)-1) 323 324 int blkdev_report_zones(struct block_device *bdev, sector_t sector,