From 0bd735df7681e41647a69b1fad0eb5594c60a727 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 14 May 2020 17:19:53 +0900 Subject: scsi: sd: Signal drive managed SMR disks Print a message indicating that a disk is a drive-managed SMR model when such drive is found using the ZONED field of the Block Device Characteristics VPD page (IDENTIFY data on ATA side). [mkp: typo] Link: https://lore.kernel.org/r/20200514081953.1252087-1-damien.lemoal@wdc.com Reviewed-by: Johannes Thumshirn Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/scsi/sd.c') diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a793cb08d025..8929e178c6f8 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2955,6 +2955,9 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) * with partitions as regular block devices. */ q->limits.zoned = BLK_ZONED_NONE; + if (sdkp->zoned == 2 && sdkp->first_scan) + sd_printk(KERN_NOTICE, sdkp, + "Drive-managed SMR disk\n"); } } if (blk_queue_is_zoned(q) && sdkp->first_scan) -- cgit v1.2.3 From c5f8852273dd7df45d3fe12cf0e2ec68cacfad80 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Fri, 15 May 2020 14:48:56 +0900 Subject: scsi: sd: Add zoned capabilities device attribute Export through sysfs as a scsi_disk attribute the zoned capabilities of a disk ("zoned_cap" attribute file). This new attribute indicates in human readable form (i.e. a string) the zoned block capabilities implemented by the disk as found in the ZONED field of the disk block device characteristics VPD page. The possible values are: - "none": ZONED=00b (not reported), regular disk - "host-aware": ZONED=01b, host-aware ZBC disk - "drive-managed": ZONED=10b, drive-managed ZBC disk (regular disk interface) For completeness, also add the following value which is detected using the device type rather than the ZONED field: - "host-managed": device type = 0x14 (TYPE_ZBC), host-managed ZBC disk This new sysfs attribute is purely informational and complementary to the "zoned" device request queue sysfs attribute as it allows applications and user daemons (e.g. udev) to easily differentiate regular disks from drive-managed SMR disks without the need for direct access tools such as provided by sg3utils. Link: https://lore.kernel.org/r/20200515054856.1408575-1-damien.lemoal@wdc.com Reviewed-by: Johannes Thumshirn Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/scsi/sd.c') diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8929e178c6f8..1bc2a061efa9 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -528,6 +528,21 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RW(max_write_same_blocks); +static ssize_t +zoned_cap_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct scsi_disk *sdkp = to_scsi_disk(dev); + + if (sdkp->device->type == TYPE_ZBC) + return sprintf(buf, "host-managed\n"); + if (sdkp->zoned == 1) + return sprintf(buf, "host-aware\n"); + if (sdkp->zoned == 2) + return sprintf(buf, "drive-managed\n"); + return sprintf(buf, "none\n"); +} +static DEVICE_ATTR_RO(zoned_cap); + static struct attribute *sd_disk_attrs[] = { &dev_attr_cache_type.attr, &dev_attr_FUA.attr, @@ -541,6 +556,7 @@ static struct attribute *sd_disk_attrs[] = { &dev_attr_zeroing_mode.attr, &dev_attr_max_write_same_blocks.attr, &dev_attr_max_medium_access_timeouts.attr, + &dev_attr_zoned_cap.attr, NULL, }; ATTRIBUTE_GROUPS(sd_disk); -- cgit v1.2.3