]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
block: Add 'zoned' queue limit
authorDamien Le Moal <damien.lemoal@hgst.com>
Tue, 18 Oct 2016 06:40:29 +0000 (15:40 +0900)
committerJens Axboe <axboe@fb.com>
Tue, 18 Oct 2016 16:02:00 +0000 (10:02 -0600)
Add the zoned queue limit to indicate the zoning model of a block device.
Defined values are 0 (BLK_ZONED_NONE) for regular block devices,
1 (BLK_ZONED_HA) for host-aware zone block devices and 2 (BLK_ZONED_HM)
for host-managed zone block devices. The standards defined drive managed
model is not defined here since these block devices do not provide any
command for accessing zone information. Drive managed model devices will
be reported as BLK_ZONED_NONE.

The helper functions blk_queue_zoned_model and bdev_zoned_model return
the zoned limit and the functions blk_queue_is_zoned and bdev_is_zoned
return a boolean for callers to test if a block device is zoned.

The zoned attribute is also exported as a string to applications via
sysfs. BLK_ZONED_NONE shows as "none", BLK_ZONED_HA as "host-aware" and
BLK_ZONED_HM as "host-managed".

Signed-off-by: Damien Le Moal <damien.lemoal@hgst.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Documentation/ABI/testing/sysfs-block
block/blk-settings.c
block/blk-sysfs.c
include/linux/blkdev.h

index 71d184dbb70d29daabf9ad1461d12615c7d34fbf..75a5055a722b7214ae1fe82ed63d497799355bd7 100644 (file)
@@ -235,3 +235,19 @@ Description:
                write_same_max_bytes is 0, write same is not supported
                by the device.
 
+What:          /sys/block/<disk>/queue/zoned
+Date:          September 2016
+Contact:       Damien Le Moal <damien.lemoal@hgst.com>
+Description:
+               zoned indicates if the device is a zoned block device
+               and the zone model of the device if it is indeed zoned.
+               The possible values indicated by zoned are "none" for
+               regular block devices and "host-aware" or "host-managed"
+               for zoned block devices. The characteristics of
+               host-aware and host-managed zoned block devices are
+               described in the ZBC (Zoned Block Commands) and ZAC
+               (Zoned Device ATA Command Set) standards. These standards
+               also define the "drive-managed" zone model. However,
+               since drive-managed zoned block devices do not support
+               zone commands, they will be treated as regular block
+               devices and zoned will report "none".
index f679ae12284351fdb53f8cfc80a2a662269c164f..b1d5b7fa4d0766d4e43e92c81f82867fc3b5c661 100644 (file)
@@ -107,6 +107,7 @@ void blk_set_default_limits(struct queue_limits *lim)
        lim->io_opt = 0;
        lim->misaligned = 0;
        lim->cluster = 1;
+       lim->zoned = BLK_ZONED_NONE;
 }
 EXPORT_SYMBOL(blk_set_default_limits);
 
index 9cc8d7c5439a98422eb5a99a66ea79314ff7baa7..ff9cd9cd35a35143d43e0ed95ea8c5b5bead19ba 100644 (file)
@@ -257,6 +257,18 @@ QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0);
 QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0);
 #undef QUEUE_SYSFS_BIT_FNS
 
+static ssize_t queue_zoned_show(struct request_queue *q, char *page)
+{
+       switch (blk_queue_zoned_model(q)) {
+       case BLK_ZONED_HA:
+               return sprintf(page, "host-aware\n");
+       case BLK_ZONED_HM:
+               return sprintf(page, "host-managed\n");
+       default:
+               return sprintf(page, "none\n");
+       }
+}
+
 static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
 {
        return queue_var_show((blk_queue_nomerges(q) << 1) |
@@ -485,6 +497,11 @@ static struct queue_sysfs_entry queue_nonrot_entry = {
        .store = queue_store_nonrot,
 };
 
+static struct queue_sysfs_entry queue_zoned_entry = {
+       .attr = {.name = "zoned", .mode = S_IRUGO },
+       .show = queue_zoned_show,
+};
+
 static struct queue_sysfs_entry queue_nomerges_entry = {
        .attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR },
        .show = queue_nomerges_show,
@@ -546,6 +563,7 @@ static struct attribute *default_attrs[] = {
        &queue_discard_zeroes_data_entry.attr,
        &queue_write_same_max_entry.attr,
        &queue_nonrot_entry.attr,
+       &queue_zoned_entry.attr,
        &queue_nomerges_entry.attr,
        &queue_rq_affinity_entry.attr,
        &queue_iostats_entry.attr,
index c47c358ba0529c7184e3fe22d70ec8fee8ecb1e6..f19e16bb43d1cd3ac5891427e8a03248fb8f2c12 100644 (file)
@@ -261,6 +261,15 @@ struct blk_queue_tag {
 #define BLK_SCSI_MAX_CMDS      (256)
 #define BLK_SCSI_CMD_PER_LONG  (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
 
+/*
+ * Zoned block device models (zoned limit).
+ */
+enum blk_zoned_model {
+       BLK_ZONED_NONE, /* Regular block device */
+       BLK_ZONED_HA,   /* Host-aware zoned block device */
+       BLK_ZONED_HM,   /* Host-managed zoned block device */
+};
+
 struct queue_limits {
        unsigned long           bounce_pfn;
        unsigned long           seg_boundary_mask;
@@ -290,6 +299,7 @@ struct queue_limits {
        unsigned char           cluster;
        unsigned char           discard_zeroes_data;
        unsigned char           raid_partial_stripes_expensive;
+       enum blk_zoned_model    zoned;
 };
 
 struct request_queue {
@@ -627,6 +637,23 @@ static inline unsigned int blk_queue_cluster(struct request_queue *q)
        return q->limits.cluster;
 }
 
+static inline enum blk_zoned_model
+blk_queue_zoned_model(struct request_queue *q)
+{
+       return q->limits.zoned;
+}
+
+static inline bool blk_queue_is_zoned(struct request_queue *q)
+{
+       switch (blk_queue_zoned_model(q)) {
+       case BLK_ZONED_HA:
+       case BLK_ZONED_HM:
+               return true;
+       default:
+               return false;
+       }
+}
+
 /*
  * We regard a request as sync, if either a read or a sync write
  */
@@ -1354,6 +1381,26 @@ static inline unsigned int bdev_write_same(struct block_device *bdev)
        return 0;
 }
 
+static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
+{
+       struct request_queue *q = bdev_get_queue(bdev);
+
+       if (q)
+               return blk_queue_zoned_model(q);
+
+       return BLK_ZONED_NONE;
+}
+
+static inline bool bdev_is_zoned(struct block_device *bdev)
+{
+       struct request_queue *q = bdev_get_queue(bdev);
+
+       if (q)
+               return blk_queue_is_zoned(q);
+
+       return false;
+}
+
 static inline int queue_dma_alignment(struct request_queue *q)
 {
        return q ? q->dma_alignment : 511;