From patchwork Mon Sep 19 21:27:26 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: 9340557 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 231F3607D0 for ; Mon, 19 Sep 2016 21:28:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 136CD29906 for ; Mon, 19 Sep 2016 21:28:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07CCE29909; Mon, 19 Sep 2016 21:28:34 +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=unavailable 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 4A2AC29906 for ; Mon, 19 Sep 2016 21:28:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753042AbcISV2a (ORCPT ); Mon, 19 Sep 2016 17:28:30 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:20108 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbcISV22 (ORCPT ); Mon, 19 Sep 2016 17:28:28 -0400 X-IronPort-AV: E=Sophos;i="5.30,363,1470672000"; d="scan'208";a="15969599" Received: from mail-bn3nam01lp0180.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([216.32.180.180]) by ob1.hgst.iphmx.com with ESMTP; 20 Sep 2016 05:27:56 +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=Syw7z698EZSUeBBY8yQu3Kr642vk9KWZHJshKAOnqyw=; b=TrzgDwQq4UyST4L44PJwiz9r8TiDrO7AjS/BsTELcJ+lfV2f//dtCujbIBPpFfoechNrbWq6e2I/ivKIiVlQeK2Fsk1lWriV5bprTJdsetJgmDq8zN5BXKbai3TW0k9SpqpcsgeEL7ib+abdW3fCHgSubbJuL2sWSp5m3ioAOdg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from localhost.localdomain.localdomain (4.28.11.153) by BY2PR04MB1975.namprd04.prod.outlook.com (10.166.111.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Mon, 19 Sep 2016 21:27:53 +0000 From: Damien Le Moal To: , CC: , , , , Damien Le Moal Subject: [PATCH 1/9] block: Add 'zoned' queue limit Date: Tue, 20 Sep 2016 06:27:26 +0900 Message-ID: <1474320454-5264-2-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474320454-5264-1-git-send-email-damien.lemoal@hgst.com> References: <1474320454-5264-1-git-send-email-damien.lemoal@hgst.com> MIME-Version: 1.0 X-Originating-IP: [4.28.11.153] X-ClientProxiedBy: BY2PR12CA0038.namprd12.prod.outlook.com (10.160.121.48) To BY2PR04MB1975.namprd04.prod.outlook.com (10.166.111.15) X-MS-Office365-Filtering-Correlation-Id: 4fac330e-6e33-44a3-e42f-08d3e0d3d150 X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 2:Rus48TUYHD6budvJ2mH9X7NvmGy87LNfn3bJ3sZtuIl+VlP99j0iFg78e/mM4jUPuh6u6hYkef4mlAP5s2Wo9nasDrRLN1bP9c3lfWWwrE7lHL0vylPXSe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w1dLD2+lK0cA/GhfTjoPstv/U/OBD2obknMkKeP4EWVjcGGeFgyMyNvbyv8emDd8QfBXbmqAN0skV9jt4Klc0T1Ru6eZf5aBc1hTANhMebcXWAFzIiy7iLt1lrS3sUnCjI3JyLZbdIWfzMgUbDg1NhLtqSzSf6yhSYM/r6eMPOO+z6ku+E0IZphWb8tFGHQ0nDRviP27MqtG807Kfsvz4FvJzOILLFk1xsiqXAAVeEH7T8W8YGGgSP3T8IW161D9HzZi0UDGTkZk4/GY5n8khZARKSiG7n42CTElhniay0qncTfqUbnaoRj2z7MjsxUxBU1bQSdaQMTQ6IkAY4bH4jp/GPTsnyd6gUnGPw1smzAwnrWqPtBULDr1FVbqloNCz+dAlSz7BN4a8r/n9teqsBFB+BaX 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)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BY2PR04MB1975; BCL:0; PCL:0; RULEID:; SRVR:BY2PR04MB1975; X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 4:MSkXaz3b2UDv7w3lyW6xLZYrczGmVfjCXfn3LVl5birv4tzaR/qmjhT33FFfoQqDBmh5jLjpvqYi+sJSMkV0EdMeTTI9bnKTWnDpzStIz8eK+D8KzPNVh2u184+S7an861JKHbIeAImcSfKQGH21QJcP0MM7zVNKc9IcJai6l0dgVSp9xYVqxBz1CgxcQqj5w0MwBelYw1LY3erpaAvhC+YECSKq2zn1nckP10XADPJptzy6rgsUcB7Ci/zCvdrhpzXo9ruM5QZ73txva+tOnoQrpERxzQ8NvoqibEToB34fikEcNkG0tJnQDh5sDd8szFC5Fr8YR6TarsNXXC+5sOPAWmbw6471CMSMhXMUm0+3PUKJ2P+sfTvb4Db/zIUzo0kI9bwFqUBNenMpy5eUfSALSMHYSs7I4JIrV9uWhVDp/zR3uuSDKoudp3rYCaRwe6vG9Xr2DgEx5TskzpMCoJzzCRygZFcEMmgkhhnVTUg= X-Forefront-PRVS: 0070A8666B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(4001430100002)(305945005)(5660300001)(2950100001)(5003940100001)(86362001)(47776003)(33646002)(66066001)(97736004)(5001770100001)(50986999)(2906002)(229853001)(6116002)(4326007)(3846002)(76176999)(189998001)(101416001)(106356001)(105586002)(586003)(42186005)(77096005)(36756003)(50466002)(48376002)(19580405001)(81166006)(37156001)(92566002)(7736002)(8676002)(50226002)(68736007)(19580395003)(81156014)(7846002)(107886002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR04MB1975; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BY2PR04MB1975; 23:qkGDRadX5m8jENagPfkYFh4PV9zudck0b2zsgQ+ID?= =?us-ascii?Q?Nz8sISNP6kxL2+L5051ycGj6YoFjAc2MiDT9Z2SZi+Mj9rU1lz4J3qaQ78eP?= =?us-ascii?Q?YXSRI64pdYOpa6uanchb8VFU5Ed06NxDEGKTQ2ReJmVzYHOtWelsaaINVChZ?= =?us-ascii?Q?pATYBP6eRSwXHQBPpoFlWY9PlJ80nj8rPey7IuYSJH6UMfymYXJCv8tZ2O1T?= =?us-ascii?Q?smaNrDhFs9esxWV61wrOG/RCK1jGd8e96p7U8JThVk3g8JajvRVuOVbodfYy?= =?us-ascii?Q?WaZ0cMm23pwbPx8pvHwvoZXWAmuj3HaXj9DPRVpVZZLsNBGufM/lkjPydUFh?= =?us-ascii?Q?GMJ/NJ9NrxU3IhopfFcMRYrTRMmWOYVWtlq8o+wOx0bHCxrqOF7GNNZReFfp?= =?us-ascii?Q?R7+sOGx3GW0DpcDbyb1XSoIEF2xtMppymgeRy46R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reF1nAF3ckXM8AkQvDsq+1L X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2016 21:27:53.8798 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR04MB1975 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 drive managed model is not defined here since these block devices do not provide any command for accessing zone information. The helper functions blk_queue_zoned and bdev_zoned return the zoned limit which can in turn be used as a boolean 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 --- block/blk-settings.c | 1 + block/blk-sysfs.c | 18 ++++++++++++++++++ include/linux/blkdev.h | 25 +++++++++++++++++++++++++ 3 files changed, 44 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 f87a7e7..31ecff9 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(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 e79055c..1c74b19 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; + unsigned char zoned; }; struct request_queue { @@ -627,6 +637,11 @@ static inline unsigned int blk_queue_cluster(struct request_queue *q) return q->limits.cluster; } +static inline unsigned int blk_queue_zoned(struct request_queue *q) +{ + return q->limits.zoned; +} + /* * We regard a request as sync, if either a read or a sync write */ @@ -1354,6 +1369,16 @@ static inline unsigned int bdev_write_same(struct block_device *bdev) return 0; } +static inline unsigned int bdev_zoned(struct block_device *bdev) +{ + struct request_queue *q = bdev_get_queue(bdev); + + if (q) + return blk_queue_zoned(q); + + return 0; +} + static inline int queue_dma_alignment(struct request_queue *q) { return q ? q->dma_alignment : 511;