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.

virtio_blk: cleanup zoned device probing

Move reading and checking the zoned model from virtblk_probe_zoned_device
into the caller, leaving only the code to perform the actual setup for
host managed zoned devices in virtblk_probe_zoned_device.

This allows to share the model reading and sharing between builds with
and without CONFIG_BLK_DEV_ZONED, and improve it for the
!CONFIG_BLK_DEV_ZONED case.

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

authored by

Christoph Hellwig and committed by
Jens Axboe
77360cad 0bd7c5d8

+22 -28
+22 -28
drivers/block/virtio_blk.c
··· 748 748 struct request_queue *q) 749 749 { 750 750 u32 v, wg; 751 - u8 model; 752 - 753 - virtio_cread(vdev, struct virtio_blk_config, 754 - zoned.model, &model); 755 - 756 - switch (model) { 757 - case VIRTIO_BLK_Z_NONE: 758 - case VIRTIO_BLK_Z_HA: 759 - /* Present the host-aware device as non-zoned */ 760 - return 0; 761 - case VIRTIO_BLK_Z_HM: 762 - break; 763 - default: 764 - dev_err(&vdev->dev, "unsupported zone model %d\n", model); 765 - return -EINVAL; 766 - } 767 751 768 752 dev_dbg(&vdev->dev, "probing host-managed zoned device\n"); 769 753 ··· 830 846 static inline int virtblk_probe_zoned_device(struct virtio_device *vdev, 831 847 struct virtio_blk *vblk, struct request_queue *q) 832 848 { 833 - u8 model; 834 - 835 - virtio_cread(vdev, struct virtio_blk_config, zoned.model, &model); 836 - if (model == VIRTIO_BLK_Z_HM) { 837 - dev_err(&vdev->dev, 838 - "virtio_blk: zoned devices are not supported"); 839 - return -EOPNOTSUPP; 840 - } 841 - 842 - return 0; 849 + dev_err(&vdev->dev, 850 + "virtio_blk: zoned devices are not supported"); 851 + return -EOPNOTSUPP; 843 852 } 844 853 #endif /* CONFIG_BLK_DEV_ZONED */ 845 854 ··· 1547 1570 * placed after the virtio_device_ready() call above. 1548 1571 */ 1549 1572 if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) { 1550 - err = virtblk_probe_zoned_device(vdev, vblk, q); 1551 - if (err) 1573 + u8 model; 1574 + 1575 + virtio_cread(vdev, struct virtio_blk_config, zoned.model, 1576 + &model); 1577 + switch (model) { 1578 + case VIRTIO_BLK_Z_NONE: 1579 + case VIRTIO_BLK_Z_HA: 1580 + /* Present the host-aware device as non-zoned */ 1581 + break; 1582 + case VIRTIO_BLK_Z_HM: 1583 + err = virtblk_probe_zoned_device(vdev, vblk, q); 1584 + if (err) 1585 + goto out_cleanup_disk; 1586 + break; 1587 + default: 1588 + dev_err(&vdev->dev, "unsupported zone model %d\n", 1589 + model); 1590 + err = -EINVAL; 1552 1591 goto out_cleanup_disk; 1592 + } 1553 1593 } 1554 1594 1555 1595 err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);