From patchwork Fri Sep 30 19:12:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaun Tancheff X-Patchwork-Id: 9358769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D4BB600C8 for ; Fri, 30 Sep 2016 19:14:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED9102A154 for ; Fri, 30 Sep 2016 19:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0F532A16E; Fri, 30 Sep 2016 19:14:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DD3F2A154 for ; Fri, 30 Sep 2016 19:14:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933956AbcI3TNy (ORCPT ); Fri, 30 Sep 2016 15:13:54 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:34576 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932348AbcI3TNw (ORCPT ); Fri, 30 Sep 2016 15:13:52 -0400 Received: by mail-it0-f66.google.com with SMTP id j69so3475858itb.1; Fri, 30 Sep 2016 12:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=JMjCKOfcUxFq9frza8Hd2+sZ/FLOPYWzKw6LFFaj5ns=; b=DZAhwJIzK/GlEXSu6uBAscLEBRfNwkOJ96F496B1rL85VBnLs10O80Hr68uRByQdmK tCK1bxR/rhqZVxzWqT1aWFLMizG7kpRlZmsr4x3NKRfI+lXnmyKhHPiVoJhfNH7rDilJ Y+qv12RF/mkJPsATv4e+jzEtGlKlirpB6MQeBgy+jRPFx2odWF3ALt+51rd3McIR/bx0 Prm+wY6l9jfkmRZSOb1qegabf2rMZyBY5zYCeaNm21iI8nH6Numd6zJT41vwKi6wAGnB U7YQJTNUFT851zdOZTbFbtx2yKftU1DIcXIKV0XPWBBuMTLGWdRalT0BRJuecoFqR9WU KZlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=JMjCKOfcUxFq9frza8Hd2+sZ/FLOPYWzKw6LFFaj5ns=; b=a6CIOW0vWRt5ZqVDrxVJsikEcULwehkGfa16nIliq40omZHg08cRUJhzGOtGGwsxev 5jwO8cQ5BZ2UK64zzklANyjlplQoaXE+iJx19ERORPS1CpPxTcTpTX18dxpIrZve7f5B DYI/IhEhX7GovGLbmOQqEworSW56mPkBy7TgpsOtLnI6/aHMaKnZN4VxSo8l6R/0+KJg HR7grl0kVU2/dBf0f9i5O33XPAQ+0VjnZT13NsMQ0Cg4PIhk4m6e6BA//yHMIj1IyKoZ VF9Q6MjOnohovOI5YOKKqXiZa7LcmNsVhUw+eavJgVnIU3CJU5LQdUyL15Il7qpf0+Uj GyKw== X-Gm-Message-State: AA6/9Rm9BzkDepk4wk1wr9RPlE1p40LQNFEJWDLVZEXf5PBP7KLg+JFGAJMFHpjj361CXA== X-Received: by 10.107.134.78 with SMTP id i75mr6505318iod.151.1475262830133; Fri, 30 Sep 2016 12:13:50 -0700 (PDT) Received: from helios.aeonazure.com (173-16-223-93.client.mchsi.com. [173.16.223.93]) by smtp.gmail.com with ESMTPSA id n69sm2599900ita.0.2016.09.30.12.13.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 12:13:49 -0700 (PDT) From: Shaun Tancheff To: Jens Axboe Cc: Damien Le Moal , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , "Martin K . Petersen" , "James E . J . Bottomley" , Hannes Reinecke , Michael T Lombardi Subject: [PATCH v6 1/7] block: Add 'zoned' queue limit Date: Fri, 30 Sep 2016 14:12:30 -0500 Message-Id: <20160930191237.13695-2-shaun@tancheff.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160930191237.13695-1-shaun@tancheff.com> References: <20160930191237.13695-1-shaun@tancheff.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Le Moal 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 Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Shaun Tancheff Tested-by: Shaun Tancheff --- Documentation/ABI/testing/sysfs-block | 16 ++++++++++++ block/blk-settings.c | 1 + block/blk-sysfs.c | 18 ++++++++++++++ include/linux/blkdev.h | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block index 71d184d..75a5055 100644 --- a/Documentation/ABI/testing/sysfs-block +++ b/Documentation/ABI/testing/sysfs-block @@ -235,3 +235,19 @@ Description: write_same_max_bytes is 0, write same is not supported by the device. +What: /sys/block//queue/zoned +Date: September 2016 +Contact: Damien Le Moal +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". diff --git a/block/blk-settings.c b/block/blk-settings.c index f679ae1..b1d5b7f 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -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); diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 9cc8d7c..ff9cd9c 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -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, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index c47c358..f19e16b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -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;