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: remove support for the host aware zone model

When zones were first added the SCSI and ATA specs, two different
models were supported (in addition to the drive managed one that
is invisible to the host):

- host managed where non-conventional zones there is strict requirement
to write at the write pointer, or else an error is returned
- host aware where a write point is maintained if writes always happen
at it, otherwise it is left in an under-defined state and the
sequential write preferred zones behave like conventional zones
(probably very badly performing ones, though)

Not surprisingly this lukewarm model didn't prove to be very useful and
was finally removed from the ZBC and SBC specs (NVMe never implemented
it). Due to to the easily disappearing write pointer host software
could never rely on the write pointer to actually be useful for say
recovery.

Fortunately only a few HDD prototypes shipped using this model which
never made it to mass production. Drop the support before it is too
late. Note that any such host aware prototype HDD can still be used
with Linux as we'll now treat it as a conventional HDD.

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

authored by

Christoph Hellwig and committed by
Jens Axboe
7437bb73 a971ed80

+92 -231
+9 -58
block/blk-settings.c
··· 56 56 lim->alignment_offset = 0; 57 57 lim->io_opt = 0; 58 58 lim->misaligned = 0; 59 - lim->zoned = BLK_ZONED_NONE; 59 + lim->zoned = false; 60 60 lim->zone_write_granularity = 0; 61 61 lim->dma_alignment = 511; 62 62 } ··· 880 880 } 881 881 EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging); 882 882 883 - static bool disk_has_partitions(struct gendisk *disk) 884 - { 885 - unsigned long idx; 886 - struct block_device *part; 887 - bool ret = false; 888 - 889 - rcu_read_lock(); 890 - xa_for_each(&disk->part_tbl, idx, part) { 891 - if (bdev_is_partition(part)) { 892 - ret = true; 893 - break; 894 - } 895 - } 896 - rcu_read_unlock(); 897 - 898 - return ret; 899 - } 900 - 901 883 /** 902 884 * disk_set_zoned - configure the zoned model for a disk 903 885 * @disk: the gendisk of the queue to configure 904 - * @model: the zoned model to set 886 + * @zoned: zoned or not. 905 887 * 906 - * Set the zoned model of @disk to @model. 907 - * 908 - * When @model is BLK_ZONED_HM (host managed), this should be called only 909 - * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option). 910 - * If @model specifies BLK_ZONED_HA (host aware), the effective model used 911 - * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions 912 - * on the disk. 888 + * When @zoned is %true, this should be called only if zoned block device 889 + * support is enabled (CONFIG_BLK_DEV_ZONED option). 913 890 */ 914 - void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model) 891 + void disk_set_zoned(struct gendisk *disk, bool zoned) 915 892 { 916 893 struct request_queue *q = disk->queue; 917 - unsigned int old_model = q->limits.zoned; 918 894 919 - switch (model) { 920 - case BLK_ZONED_HM: 921 - /* 922 - * Host managed devices are supported only if 923 - * CONFIG_BLK_DEV_ZONED is enabled. 924 - */ 895 + if (zoned) { 925 896 WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED)); 926 - break; 927 - case BLK_ZONED_HA: 928 - /* 929 - * Host aware devices can be treated either as regular block 930 - * devices (similar to drive managed devices) or as zoned block 931 - * devices to take advantage of the zone command set, similarly 932 - * to host managed devices. We try the latter if there are no 933 - * partitions and zoned block device support is enabled, else 934 - * we do nothing special as far as the block layer is concerned. 935 - */ 936 - if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) || 937 - disk_has_partitions(disk)) 938 - model = BLK_ZONED_NONE; 939 - break; 940 - case BLK_ZONED_NONE: 941 - default: 942 - if (WARN_ON_ONCE(model != BLK_ZONED_NONE)) 943 - model = BLK_ZONED_NONE; 944 - break; 945 - } 946 897 947 - q->limits.zoned = model; 948 - if (model != BLK_ZONED_NONE) { 949 898 /* 950 899 * Set the zone write granularity to the device logical block 951 900 * size by default. The driver can change this value if needed. 952 901 */ 902 + q->limits.zoned = true; 953 903 blk_queue_zone_write_granularity(q, 954 904 queue_logical_block_size(q)); 955 - } else if (old_model != BLK_ZONED_NONE) { 905 + } else if (q->limits.zoned) { 906 + q->limits.zoned = false; 956 907 disk_clear_zone_settings(disk); 957 908 } 958 909 }
+2 -7
block/blk-sysfs.c
··· 309 309 310 310 static ssize_t queue_zoned_show(struct request_queue *q, char *page) 311 311 { 312 - switch (blk_queue_zoned_model(q)) { 313 - case BLK_ZONED_HA: 314 - return sprintf(page, "host-aware\n"); 315 - case BLK_ZONED_HM: 312 + if (blk_queue_is_zoned(q)) 316 313 return sprintf(page, "host-managed\n"); 317 - default: 318 - return sprintf(page, "none\n"); 319 - } 314 + return sprintf(page, "none\n"); 320 315 } 321 316 322 317 static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
+2 -10
block/partitions/core.c
··· 305 305 * Partitions are not supported on zoned block devices that are used as 306 306 * such. 307 307 */ 308 - switch (disk->queue->limits.zoned) { 309 - case BLK_ZONED_HM: 308 + if (bdev_is_zoned(disk->part0)) { 310 309 pr_warn("%s: partitions not supported on host managed zoned block device\n", 311 310 disk->disk_name); 312 311 return ERR_PTR(-ENXIO); 313 - case BLK_ZONED_HA: 314 - pr_info("%s: disabling host aware zoned block device support due to partitions\n", 315 - disk->disk_name); 316 - disk_set_zoned(disk, BLK_ZONED_NONE); 317 - break; 318 - case BLK_ZONED_NONE: 319 - break; 320 312 } 321 313 322 314 if (xa_load(&disk->part_tbl, partno)) ··· 605 613 /* 606 614 * Partitions are not supported on host managed zoned block devices. 607 615 */ 608 - if (disk->queue->limits.zoned == BLK_ZONED_HM) { 616 + if (bdev_is_zoned(disk->part0)) { 609 617 pr_warn("%s: ignoring partition table on host managed zoned block device\n", 610 618 disk->disk_name); 611 619 ret = 0;
+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, BLK_ZONED_HM); 162 + disk_set_zoned(nullb->disk, true); 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, BLK_ZONED_HM); 253 + disk_set_zoned(ub->ub_disk, true); 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, BLK_ZONED_HM); 733 + disk_set_zoned(vblk->disk, true); 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/md/dm-kcopyd.c
··· 807 807 */ 808 808 if (!(job->flags & BIT(DM_KCOPYD_WRITE_SEQ))) { 809 809 for (i = 0; i < job->num_dests; i++) { 810 - if (bdev_zoned_model(dests[i].bdev) == BLK_ZONED_HM) { 810 + if (bdev_is_zoned(dests[i].bdev)) { 811 811 job->flags |= BIT(DM_KCOPYD_WRITE_SEQ); 812 812 break; 813 813 }
+20 -25
drivers/md/dm-table.c
··· 1579 1579 return true; 1580 1580 } 1581 1581 1582 - static int device_not_zoned_model(struct dm_target *ti, struct dm_dev *dev, 1583 - sector_t start, sector_t len, void *data) 1582 + static int device_not_zoned(struct dm_target *ti, struct dm_dev *dev, 1583 + sector_t start, sector_t len, void *data) 1584 1584 { 1585 - struct request_queue *q = bdev_get_queue(dev->bdev); 1586 - enum blk_zoned_model *zoned_model = data; 1585 + bool *zoned = data; 1587 1586 1588 - return blk_queue_zoned_model(q) != *zoned_model; 1587 + return bdev_is_zoned(dev->bdev) != *zoned; 1589 1588 } 1590 1589 1591 1590 static int device_is_zoned_model(struct dm_target *ti, struct dm_dev *dev, 1592 1591 sector_t start, sector_t len, void *data) 1593 1592 { 1594 - struct request_queue *q = bdev_get_queue(dev->bdev); 1595 - 1596 - return blk_queue_zoned_model(q) != BLK_ZONED_NONE; 1593 + return bdev_is_zoned(dev->bdev); 1597 1594 } 1598 1595 1599 1596 /* ··· 1600 1603 * has the DM_TARGET_MIXED_ZONED_MODEL feature set, the devices can have any 1601 1604 * zoned model with all zoned devices having the same zone size. 1602 1605 */ 1603 - static bool dm_table_supports_zoned_model(struct dm_table *t, 1604 - enum blk_zoned_model zoned_model) 1606 + static bool dm_table_supports_zoned(struct dm_table *t, bool zoned) 1605 1607 { 1606 1608 for (unsigned int i = 0; i < t->num_targets; i++) { 1607 1609 struct dm_target *ti = dm_table_get_target(t, i); ··· 1619 1623 1620 1624 if (dm_target_supports_zoned_hm(ti->type)) { 1621 1625 if (!ti->type->iterate_devices || 1622 - ti->type->iterate_devices(ti, device_not_zoned_model, 1623 - &zoned_model)) 1626 + ti->type->iterate_devices(ti, device_not_zoned, 1627 + &zoned)) 1624 1628 return false; 1625 1629 } else if (!dm_target_supports_mixed_zoned_model(ti->type)) { 1626 - if (zoned_model == BLK_ZONED_HM) 1630 + if (zoned) 1627 1631 return false; 1628 1632 } 1629 1633 } ··· 1646 1650 * zone sectors, if the destination device is a zoned block device, it shall 1647 1651 * have the specified zone_sectors. 1648 1652 */ 1649 - static int validate_hardware_zoned_model(struct dm_table *t, 1650 - enum blk_zoned_model zoned_model, 1651 - unsigned int zone_sectors) 1653 + static int validate_hardware_zoned(struct dm_table *t, bool zoned, 1654 + unsigned int zone_sectors) 1652 1655 { 1653 - if (zoned_model == BLK_ZONED_NONE) 1656 + if (!zoned) 1654 1657 return 0; 1655 1658 1656 - if (!dm_table_supports_zoned_model(t, zoned_model)) { 1659 + if (!dm_table_supports_zoned(t, zoned)) { 1657 1660 DMERR("%s: zoned model is not consistent across all devices", 1658 1661 dm_device_name(t->md)); 1659 1662 return -EINVAL; ··· 1678 1683 struct queue_limits *limits) 1679 1684 { 1680 1685 struct queue_limits ti_limits; 1681 - enum blk_zoned_model zoned_model = BLK_ZONED_NONE; 1682 1686 unsigned int zone_sectors = 0; 1687 + bool zoned = false; 1683 1688 1684 1689 blk_set_stacking_limits(limits); 1685 1690 ··· 1701 1706 ti->type->iterate_devices(ti, dm_set_device_limits, 1702 1707 &ti_limits); 1703 1708 1704 - if (zoned_model == BLK_ZONED_NONE && ti_limits.zoned != BLK_ZONED_NONE) { 1709 + if (!zoned && ti_limits.zoned) { 1705 1710 /* 1706 1711 * After stacking all limits, validate all devices 1707 1712 * in table support this zoned model and zone sectors. 1708 1713 */ 1709 - zoned_model = ti_limits.zoned; 1714 + zoned = ti_limits.zoned; 1710 1715 zone_sectors = ti_limits.chunk_sectors; 1711 1716 } 1712 1717 ··· 1739 1744 * Verify that the zoned model and zone sectors, as determined before 1740 1745 * any .io_hints override, are the same across all devices in the table. 1741 1746 * - this is especially relevant if .io_hints is emulating a disk-managed 1742 - * zoned model (aka BLK_ZONED_NONE) on host-managed zoned block devices. 1747 + * zoned model on host-managed zoned block devices. 1743 1748 * BUT... 1744 1749 */ 1745 - if (limits->zoned != BLK_ZONED_NONE) { 1750 + if (limits->zoned) { 1746 1751 /* 1747 1752 * ...IF the above limits stacking determined a zoned model 1748 1753 * validate that all of the table's devices conform to it. 1749 1754 */ 1750 - zoned_model = limits->zoned; 1755 + zoned = limits->zoned; 1751 1756 zone_sectors = limits->chunk_sectors; 1752 1757 } 1753 - if (validate_hardware_zoned_model(t, zoned_model, zone_sectors)) 1758 + if (validate_hardware_zoned(t, zoned, zone_sectors)) 1754 1759 return -EINVAL; 1755 1760 1756 1761 return validate_hardware_logical_block_alignment(t, limits);
+3 -4
drivers/md/dm-zoned-metadata.c
··· 2836 2836 { 2837 2837 struct dmz_dev *dev = &zmd->dev[num]; 2838 2838 2839 - if (bdev_zoned_model(dev->bdev) == BLK_ZONED_NONE) 2839 + if (!bdev_is_zoned(dev->bdev)) 2840 2840 dmz_dev_info(dev, "Regular block device"); 2841 2841 else 2842 - dmz_dev_info(dev, "Host-%s zoned block device", 2843 - bdev_zoned_model(dev->bdev) == BLK_ZONED_HA ? 2844 - "aware" : "managed"); 2842 + dmz_dev_info(dev, "Host-managed zoned block device"); 2843 + 2845 2844 if (zmd->sb_version > 1) { 2846 2845 sector_t sector_offset = 2847 2846 dev->zone_offset << zmd->zone_nr_sectors_shift;
+2 -2
drivers/md/dm-zoned-target.c
··· 702 702 } 703 703 704 704 bdev = ddev->bdev; 705 - if (bdev_zoned_model(bdev) == BLK_ZONED_NONE) { 705 + if (!bdev_is_zoned(bdev)) { 706 706 if (nr_devs == 1) { 707 707 ti->error = "Invalid regular device"; 708 708 goto err; ··· 1010 1010 limits->max_sectors = chunk_sectors; 1011 1011 1012 1012 /* We are exposing a drive-managed zoned block device */ 1013 - limits->zoned = BLK_ZONED_NONE; 1013 + limits->zoned = false; 1014 1014 } 1015 1015 1016 1016 /*
+1 -1
drivers/nvme/host/zns.c
··· 108 108 goto free_data; 109 109 } 110 110 111 - disk_set_zoned(ns->disk, BLK_ZONED_HM); 111 + disk_set_zoned(ns->disk, true); 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);
+13 -14
drivers/scsi/scsi_debug.c
··· 339 339 bool used; 340 340 341 341 /* For ZBC devices */ 342 - enum blk_zoned_model zmodel; 342 + bool zoned; 343 343 unsigned int zcap; 344 344 unsigned int zsize; 345 345 unsigned int zsize_shift; ··· 844 844 static bool sdebug_statistics = DEF_STATISTICS; 845 845 static bool sdebug_wp; 846 846 static bool sdebug_allow_restart; 847 - /* Following enum: 0: no zbc, def; 1: host aware; 2: host managed */ 848 - static enum blk_zoned_model sdeb_zbc_model = BLK_ZONED_NONE; 847 + static enum { 848 + BLK_ZONED_NONE = 0, 849 + BLK_ZONED_HA = 1, 850 + BLK_ZONED_HM = 2, 851 + } sdeb_zbc_model = BLK_ZONED_NONE; 849 852 static char *sdeb_zbc_model_s; 850 853 851 854 enum sam_lun_addr_method {SAM_LUN_AM_PERIPHERAL = 0x0, ··· 1818 1815 arr[1] = 1; /* non rotating medium (e.g. solid state) */ 1819 1816 arr[2] = 0; 1820 1817 arr[3] = 5; /* less than 1.8" */ 1821 - if (devip->zmodel == BLK_ZONED_HA) 1822 - arr[4] = 1 << 4; /* zoned field = 01b */ 1823 1818 1824 1819 return 0x3c; 1825 1820 } ··· 1884 1883 if (! arr) 1885 1884 return DID_REQUEUE << 16; 1886 1885 is_disk = (sdebug_ptype == TYPE_DISK); 1887 - is_zbc = (devip->zmodel != BLK_ZONED_NONE); 1886 + is_zbc = devip->zoned; 1888 1887 is_disk_zbc = (is_disk || is_zbc); 1889 1888 have_wlun = scsi_is_wlun(scp->device->lun); 1890 1889 if (have_wlun) ··· 2196 2195 * Since the scsi_debug READ CAPACITY implementation always reports the 2197 2196 * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices. 2198 2197 */ 2199 - if (devip->zmodel == BLK_ZONED_HM) 2198 + if (devip->zoned) 2200 2199 arr[12] |= 1 << 4; 2201 2200 2202 2201 arr[15] = sdebug_lowest_aligned & 0xff; ··· 2649 2648 msense_6 = (MODE_SENSE == cmd[0]); 2650 2649 llbaa = msense_6 ? false : !!(cmd[1] & 0x10); 2651 2650 is_disk = (sdebug_ptype == TYPE_DISK); 2652 - is_zbc = (devip->zmodel != BLK_ZONED_NONE); 2651 + is_zbc = devip->zoned; 2653 2652 if ((is_disk || is_zbc) && !dbd) 2654 2653 bd_len = llbaa ? 16 : 8; 2655 2654 else ··· 3195 3194 struct sdeb_zone_state *zsp_end = zbc_zone(devip, lba + num - 1); 3196 3195 3197 3196 if (!write) { 3198 - if (devip->zmodel == BLK_ZONED_HA) 3199 - return 0; 3200 3197 /* For host-managed, reads cannot cross zone types boundaries */ 3201 3198 if (zsp->z_type != zsp_end->z_type) { 3202 3199 mk_sense_buffer(scp, ILLEGAL_REQUEST, ··· 5321 5322 if (devip->zcap < devip->zsize) 5322 5323 devip->nr_zones += devip->nr_seq_zones; 5323 5324 5324 - if (devip->zmodel == BLK_ZONED_HM) { 5325 + if (devip->zoned) { 5325 5326 /* zbc_max_open_zones can be 0, meaning "not reported" */ 5326 5327 if (sdeb_zbc_max_open >= devip->nr_zones - 1) 5327 5328 devip->max_open = (devip->nr_zones - 1) / 2; ··· 5346 5347 zsp->z_size = 5347 5348 min_t(u64, devip->zsize, capacity - zstart); 5348 5349 } else if ((zstart & (devip->zsize - 1)) == 0) { 5349 - if (devip->zmodel == BLK_ZONED_HM) 5350 + if (devip->zoned) 5350 5351 zsp->z_type = ZBC_ZTYPE_SWR; 5351 5352 else 5352 5353 zsp->z_type = ZBC_ZTYPE_SWP; ··· 5389 5390 } 5390 5391 devip->sdbg_host = sdbg_host; 5391 5392 if (sdeb_zbc_in_use) { 5392 - devip->zmodel = sdeb_zbc_model; 5393 + devip->zoned = sdeb_zbc_model == BLK_ZONED_HM; 5393 5394 if (sdebug_device_create_zones(devip)) { 5394 5395 kfree(devip); 5395 5396 return NULL; 5396 5397 } 5397 5398 } else { 5398 - devip->zmodel = BLK_ZONED_NONE; 5399 + devip->zoned = false; 5399 5400 } 5400 5401 devip->create_ts = ktime_get_boottime(); 5401 5402 atomic_set(&devip->stopped, (sdeb_tur_ms_to_ready > 0 ? 2 : 0));
+20 -25
drivers/scsi/sd.c
··· 3117 3117 struct request_queue *q = sdkp->disk->queue; 3118 3118 struct scsi_vpd *vpd; 3119 3119 u16 rot; 3120 - u8 zoned; 3121 3120 3122 3121 rcu_read_lock(); 3123 3122 vpd = rcu_dereference(sdkp->device->vpd_pgb1); ··· 3127 3128 } 3128 3129 3129 3130 rot = get_unaligned_be16(&vpd->data[4]); 3130 - zoned = (vpd->data[8] >> 4) & 3; 3131 + sdkp->zoned = (vpd->data[8] >> 4) & 3; 3131 3132 rcu_read_unlock(); 3132 3133 3133 3134 if (rot == 1) { ··· 3137 3138 3138 3139 if (sdkp->device->type == TYPE_ZBC) { 3139 3140 /* 3140 - * Host-managed: Per ZBC and ZAC specifications, writes in 3141 - * sequential write required zones of host-managed devices must 3142 - * be aligned to the device physical block size. 3141 + * Host-managed. 3143 3142 */ 3144 - disk_set_zoned(sdkp->disk, BLK_ZONED_HM); 3143 + disk_set_zoned(sdkp->disk, true); 3144 + 3145 + /* 3146 + * Per ZBC and ZAC specifications, writes in sequential write 3147 + * required zones of host-managed devices must be aligned to 3148 + * the device physical block size. 3149 + */ 3145 3150 blk_queue_zone_write_granularity(q, sdkp->physical_block_size); 3146 3151 } else { 3147 - sdkp->zoned = zoned; 3148 - if (sdkp->zoned == 1) { 3149 - /* Host-aware */ 3150 - disk_set_zoned(sdkp->disk, BLK_ZONED_HA); 3151 - } else { 3152 - /* Regular disk or drive managed disk */ 3153 - disk_set_zoned(sdkp->disk, BLK_ZONED_NONE); 3154 - } 3152 + /* 3153 + * Anything else. This includes host-aware device that we treat 3154 + * as conventional. 3155 + */ 3156 + disk_set_zoned(sdkp->disk, false); 3155 3157 } 3156 3158 3157 3159 if (!sdkp->first_scan) 3158 3160 return; 3159 3161 3160 - if (blk_queue_is_zoned(q)) { 3161 - sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", 3162 - q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware"); 3163 - } else { 3164 - if (sdkp->zoned == 1) 3165 - sd_printk(KERN_NOTICE, sdkp, 3166 - "Host-aware SMR disk used as regular disk\n"); 3167 - else if (sdkp->zoned == 2) 3168 - sd_printk(KERN_NOTICE, sdkp, 3169 - "Drive-managed SMR disk\n"); 3170 - } 3162 + if (blk_queue_is_zoned(q)) 3163 + sd_printk(KERN_NOTICE, sdkp, "Host-managed zoned block device\n"); 3164 + else if (sdkp->zoned == 1) 3165 + sd_printk(KERN_NOTICE, sdkp, "Host-aware SMR disk used as regular disk\n"); 3166 + else if (sdkp->zoned == 2) 3167 + sd_printk(KERN_NOTICE, sdkp, "Drive-managed SMR disk\n"); 3171 3168 } 3172 3169 3173 3170 /**
+1 -15
drivers/scsi/sd_zbc.c
··· 836 836 837 837 /* 838 838 * For all zoned disks, initialize zone append emulation data if not 839 - * already done. This is necessary also for host-aware disks used as 840 - * regular disks due to the presence of partitions as these partitions 841 - * may be deleted and the disk zoned model changed back from 842 - * BLK_ZONED_NONE to BLK_ZONED_HA. 839 + * already done. 843 840 */ 844 841 if (sd_is_zoned(sdkp) && !sdkp->zone_wp_update_buf) { 845 842 ret = sd_zbc_init_disk(sdkp); ··· 928 931 sdkp->device->use_16_for_rw = 1; 929 932 sdkp->device->use_10_for_rw = 0; 930 933 sdkp->device->use_16_for_sync = 1; 931 - 932 - if (!blk_queue_is_zoned(q)) { 933 - /* 934 - * This can happen for a host aware disk with partitions. 935 - * The block device zone model was already cleared by 936 - * disk_set_zoned(). Only free the scsi disk zone 937 - * information and exit early. 938 - */ 939 - sd_zbc_free_zone_info(sdkp); 940 - return 0; 941 - } 942 934 943 935 /* Check zoned block device characteristics (unconstrained reads) */ 944 936 ret = sd_zbc_check_zoned_characteristics(sdkp, buf);
+3 -20
fs/btrfs/zoned.c
··· 578 578 579 579 kvfree(zones); 580 580 581 - switch (bdev_zoned_model(bdev)) { 582 - case BLK_ZONED_HM: 581 + if (bdev_is_zoned(bdev)) { 583 582 model = "host-managed zoned"; 584 583 emulated = ""; 585 - break; 586 - case BLK_ZONED_HA: 587 - model = "host-aware zoned"; 588 - emulated = ""; 589 - break; 590 - case BLK_ZONED_NONE: 584 + } else { 591 585 model = "regular"; 592 586 emulated = "emulated "; 593 - break; 594 - default: 595 - /* Just in case */ 596 - btrfs_err_in_rcu(fs_info, "zoned: unsupported model %d on %s", 597 - bdev_zoned_model(bdev), 598 - rcu_str_deref(device->name)); 599 - ret = -EOPNOTSUPP; 600 - goto out_free_zone_info; 601 587 } 602 588 603 589 btrfs_info_in_rcu(fs_info, ··· 595 609 596 610 out: 597 611 kvfree(zones); 598 - out_free_zone_info: 599 612 btrfs_destroy_dev_zone_info(device); 600 - 601 613 return ret; 602 614 } 603 615 ··· 672 688 struct btrfs_device *device; 673 689 674 690 list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) { 675 - if (device->bdev && 676 - bdev_zoned_model(device->bdev) == BLK_ZONED_HM) { 691 + if (device->bdev && bdev_is_zoned(device->bdev)) { 677 692 btrfs_err(fs_info, 678 693 "zoned: mode not enabled but zoned device found: %pg", 679 694 device->bdev);
+1 -1
fs/btrfs/zoned.h
··· 324 324 } 325 325 326 326 /* Do not allow Host Manged zoned device */ 327 - return bdev_zoned_model(bdev) != BLK_ZONED_HM; 327 + return !bdev_is_zoned(bdev); 328 328 } 329 329 330 330 static inline bool btrfs_check_super_location(struct btrfs_device *device, u64 pos)
+1 -1
fs/f2fs/data.c
··· 995 995 } 996 996 blkaddr -= FDEV(devi).start_blk; 997 997 } 998 - return bdev_zoned_model(FDEV(devi).bdev) == BLK_ZONED_HM && 998 + return bdev_is_zoned(FDEV(devi).bdev) && 999 999 f2fs_blkz_is_seq(sbi, devi, blkaddr) && 1000 1000 (blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1); 1001 1001 }
+7 -10
fs/f2fs/super.c
··· 4282 4282 sbi->aligned_blksize = false; 4283 4283 4284 4284 #ifdef CONFIG_BLK_DEV_ZONED 4285 - if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM && 4286 - !f2fs_sb_has_blkzoned(sbi)) { 4287 - f2fs_err(sbi, "Zoned block device feature not enabled"); 4288 - return -EINVAL; 4289 - } 4290 - if (bdev_zoned_model(FDEV(i).bdev) != BLK_ZONED_NONE) { 4285 + if (bdev_is_zoned(FDEV(i).bdev)) { 4286 + if (!f2fs_sb_has_blkzoned(sbi)) { 4287 + f2fs_err(sbi, "Zoned block device feature not enabled"); 4288 + return -EINVAL; 4289 + } 4291 4290 if (init_blkz_info(sbi, i)) { 4292 4291 f2fs_err(sbi, "Failed to initialize F2FS blkzone information"); 4293 4292 return -EINVAL; 4294 4293 } 4295 4294 if (max_devices == 1) 4296 4295 break; 4297 - f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)", 4296 + f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: Host-managed)", 4298 4297 i, FDEV(i).path, 4299 4298 FDEV(i).total_segments, 4300 - FDEV(i).start_blk, FDEV(i).end_blk, 4301 - bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HA ? 4302 - "Host-aware" : "Host-managed"); 4299 + FDEV(i).start_blk, FDEV(i).end_blk); 4303 4300 continue; 4304 4301 } 4305 4302 #endif
+3 -34
include/linux/blkdev.h
··· 264 264 } 265 265 266 266 /* 267 - * Zoned block device models (zoned limit). 268 - * 269 - * Note: This needs to be ordered from the least to the most severe 270 - * restrictions for the inheritance in blk_stack_limits() to work. 271 - */ 272 - enum blk_zoned_model { 273 - BLK_ZONED_NONE = 0, /* Regular block device */ 274 - BLK_ZONED_HA, /* Host-aware zoned block device */ 275 - BLK_ZONED_HM, /* Host-managed zoned block device */ 276 - }; 277 - 278 - /* 279 267 * BLK_BOUNCE_NONE: never bounce (default) 280 268 * BLK_BOUNCE_HIGH: bounce all highmem pages 281 269 */ ··· 304 316 unsigned char misaligned; 305 317 unsigned char discard_misaligned; 306 318 unsigned char raid_partial_stripes_expensive; 307 - enum blk_zoned_model zoned; 319 + bool zoned; 308 320 309 321 /* 310 322 * Drivers that set dma_alignment to less than 511 must be prepared to ··· 317 329 typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx, 318 330 void *data); 319 331 320 - void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model); 332 + void disk_set_zoned(struct gendisk *disk, bool zoned); 321 333 322 334 #define BLK_ALL_ZONES ((unsigned int)-1) 323 335 int blkdev_report_zones(struct block_device *bdev, sector_t sector, ··· 605 617 } 606 618 #endif 607 619 608 - static inline enum blk_zoned_model 609 - blk_queue_zoned_model(struct request_queue *q) 610 - { 611 - if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) 612 - return q->limits.zoned; 613 - return BLK_ZONED_NONE; 614 - } 615 - 616 620 static inline bool blk_queue_is_zoned(struct request_queue *q) 617 621 { 618 - switch (blk_queue_zoned_model(q)) { 619 - case BLK_ZONED_HA: 620 - case BLK_ZONED_HM: 621 - return true; 622 - default: 623 - return false; 624 - } 622 + return IS_ENABLED(CONFIG_BLK_DEV_ZONED) && q->limits.zoned; 625 623 } 626 624 627 625 #ifdef CONFIG_BLK_DEV_ZONED ··· 1232 1258 static inline bool bdev_nowait(struct block_device *bdev) 1233 1259 { 1234 1260 return test_bit(QUEUE_FLAG_NOWAIT, &bdev_get_queue(bdev)->queue_flags); 1235 - } 1236 - 1237 - static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) 1238 - { 1239 - return blk_queue_zoned_model(bdev_get_queue(bdev)); 1240 1261 } 1241 1262 1242 1263 static inline bool bdev_is_zoned(struct block_device *bdev)