From patchwork Mon Sep 26 11:14:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9350485 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 45FD56086A for ; Mon, 26 Sep 2016 11:15:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37AD728AD9 for ; Mon, 26 Sep 2016 11:15:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B36A28AE2; Mon, 26 Sep 2016 11:15:29 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 0657928ADB for ; Mon, 26 Sep 2016 11:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935933AbcIZLPV (ORCPT ); Mon, 26 Sep 2016 07:15:21 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:5114 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966403AbcIZLPK (ORCPT ); Mon, 26 Sep 2016 07:15:10 -0400 X-IronPort-AV: E=Sophos;i="5.30,399,1470672000"; d="scan'208";a="18123002" Received: from mail-by2nam03lp0056.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.56]) by ob1.hgst.iphmx.com with ESMTP; 26 Sep 2016 19:15:10 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-hgst-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FmCMHMCflA4Q3kyjXmD9DViRP7OwM6bCqNAlIUR7V+4=; b=dB6QS62Kyh3tkOoK8EHWbF6bkkGtto/YYUg5r7bBSsjbig70t08TKI/Cd86DoIFkFndRgBvBgjXoIOuuIw369ymlvQbnZter7rrrNQG1f77LuI7P065Dyxtns1fbEDozlio+Hc2MTjeem7Bu3cZtFqQFijcmPmFZuZ+6tsIuMQI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from washi.fujisawa.hgst.com (199.255.47.8) by BY2PR04MB1976.namprd04.prod.outlook.com (10.166.111.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Mon, 26 Sep 2016 11:15:08 +0000 From: Damien Le Moal To: Jens Axboe CC: , , Christoph Hellwig , "Martin K . Petersen" , Damien Le Moal Subject: [PATCH v2 1/7] block: Add 'zoned' queue limit Date: Mon, 26 Sep 2016 20:14:37 +0900 Message-ID: <1474888483-29762-2-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474888483-29762-1-git-send-email-damien.lemoal@hgst.com> References: <1474888483-29762-1-git-send-email-damien.lemoal@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: BY1PR0201CA0007.namprd02.prod.outlook.com (10.160.191.145) To BY2PR04MB1976.namprd04.prod.outlook.com (10.166.111.16) X-MS-Office365-Filtering-Correlation-Id: bf6b8dc9-feca-4f74-ac96-08d3e5fe6068 X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1976; 2:VsAIrQV9xCr/LsYslRzEpefYOv4AiGvJbkiE3tZr7N6WqoSUqoqaMI/GlHlGcgLPODsGwNL36kq4dKsihYHExBskH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0Eu++PPftR+KH56PfL4Mg7uLNpYJXtW5MJYKJiavlpztK3cG8eww52XyVCILiWOf2BRtvJJVxFoOvniBDeVto8Evjb459cHW7rq9jy087o8xBmvPlbu3NmtdhTpBOmNEmXL4B+9sFYq10a7wKp3BkRWEZwOoH+i1Wp0M6zuHPCk0EnOZq/o9Tpud1BhEW7NSYROa7anjG3ziIY8ta68oPtr8SfIGL0j2tVZyXhburVCHv8SbkNH8TxWF9gDaoyQMwVagQ10wGf2IWjAGGK9D6apfJSeoUAEj49YlDSBKdD67b3zvCvlHFP89ViqD3Kc3dDmKVI+xYF9Xk8gYKz3TMPIpwn+KM3ivvrSv0HrfkY8uQM72YI87F/PMrO8/CZAdouE8E2tH/mGcUnqRvuIswWlOqpxEQ12NpDBbVRyKVNDBU98EbapSy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625)(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR04MB1976; BCL:0; PCL:0; RULEID:; SRVR:BY2PR04MB1976; X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1976; 4:/ld6mP4TCkWlHqBoknvm6089h+zNSWhtNYOc5DSXM1rOTG9QA4Yj6lg/+2U7D34oYRCsZMyXw5bhuF93IhVQ+yqz+ovb61i2pC6NDUAb9VaBz8iBJkrhYNQGFaE3+q2JS6Mtxv7EMdu3HuBEoZG3by1U0mvfqludSgVPt+hbLBfufK8InHhmF8mzxtpa6KPGpJv/6myqyOKKHatdhuX3f5Aor0LTW2G9j3E2a3HPUtTmmSIz5QWcK+5w/6of2/y2MnOwv1Kbi/3X83TkYok+UPL1EgDkOqP5IXVkfV57MmJVv6ws+tGHcpkf3pOXMYDEwDKeB612KpwtZc+5KNPEzmWzcY/aM3J/nO1ZrqRS5Mz4Gq0ZY2cNl0Viut1dbvTXSc80I+1vc1rQHey8lYSHljjXu0d7Y0n2bs89TgO5Va4d90EWHKYp2Z70swa4Jjd3FEX3+HiMFTxRcZfj8sdKMSK71A/f6bTL09FjPtSdEm0= X-Forefront-PRVS: 00770C4423 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(2950100002)(77096005)(6916009)(36756003)(86362001)(50466002)(101416001)(107886002)(4001430100002)(97736004)(2906002)(50226002)(189998001)(68736007)(4326007)(19580405001)(50986999)(229853001)(66066001)(586003)(47776003)(7846002)(81166006)(81156014)(7736002)(106356001)(92566002)(305945005)(110136003)(5003940100001)(3846002)(48376002)(8676002)(105586002)(76176999)(5660300001)(33646002)(19580395003)(6116002)(42186005)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR04MB1976; H:washi.fujisawa.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: hgst.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR04MB1976; 23:yPt9c4i3DhXsONp07oeKBvXvKipUfRrAIcHl9v+Em?= =?us-ascii?Q?UfAExN/bA4ef2H8pQpu+RjCNlGV6GfpBjJ4jnpEjvtq9K3l7Dfr23lpb5Cvd?= =?us-ascii?Q?ZmWc9MP+BRkc6rpCmVYM+PuSdDL+QVEau3mCEe/qvkHR2lsXkSlkV8bNgvVA?= =?us-ascii?Q?GTaEjWJX80TON4YoeivbO2QJce4G2+U+tT/BLmTJzCivmXOz/pvxPVX6Lg42?= =?us-ascii?Q?Z1s1vxN+1cQyikXkfpq/dgTDaFFaFits9wXXAgsTPnPHu9ETfjJTsns3QTNj?= =?us-ascii?Q?MxRnBFmri1zxPJwgTuhtLU0Cd6pwz57KuKa6TZVhlJ0Fo4GAayxM/0VvQwL/?= =?us-ascii?Q?BpwRXtp7uewvT5S5L/BQNCXe4OrgChHnW9mz0kR+UxnjySfpb2BfBlBEE6wN?= =?us-ascii?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bVTKtjqiQcNfPv+PVOFGQLusrabl15jNrc0MkIz2Sq8ta4PTgupH X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2016 11:15:08.1690 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR04MB1976 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Shaun Tancheff Tested-by: Shaun Tancheff --- block/blk-settings.c | 1 + block/blk-sysfs.c | 18 ++++++++++++++++++ include/linux/blkdev.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) 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;