From patchwork Wed Sep 28 01:22:31 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: 9353013 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 99B796077A for ; Wed, 28 Sep 2016 01:22:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884B828592 for ; Wed, 28 Sep 2016 01:22:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CFB028FDB; Wed, 28 Sep 2016 01:22:59 +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 0C15028592 for ; Wed, 28 Sep 2016 01:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934502AbcI1BW6 (ORCPT ); Tue, 27 Sep 2016 21:22:58 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:31916 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932967AbcI1BWz (ORCPT ); Tue, 27 Sep 2016 21:22:55 -0400 X-IronPort-AV: E=Sophos;i="5.30,407,1470672000"; d="scan'208";a="18715465" Received: from mail-co1nam03lp0017.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) ([216.32.181.17]) by ob1.hgst.iphmx.com with ESMTP; 28 Sep 2016 09:22:54 +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=qOdO1y1aIK0hUE8onqbk1IadkhOe6LCy8c5MRaHTlwr7sWHoTrJcS9i2rTKnUM8yQB1d3qQ4STeA0D2JMqXFySNiOEtdRZlbsz1wWysOr6hXVVyWbLKB0NUiPadZ97AIbbL5XtyiuwtMMyGskt/jYV/2lHGLNBRgrPj+X3N8izk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from washi.fujisawa.hgst.com (199.255.47.8) by BL2PR04MB1972.namprd04.prod.outlook.com (10.167.97.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Wed, 28 Sep 2016 01:22:51 +0000 From: Damien Le Moal To: Jens Axboe CC: , , Christoph Hellwig , "Martin K . Petersen" , Hannes Reinecke , Shaun Tancheff , Damien Le Moal Subject: [PATCH v3 1/7] block: Add 'zoned' queue limit Date: Wed, 28 Sep 2016 10:22:31 +0900 Message-ID: <1475025757-6340-2-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475025757-6340-1-git-send-email-damien.lemoal@hgst.com> References: <1475025757-6340-1-git-send-email-damien.lemoal@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: CY1PR13CA0119.namprd13.prod.outlook.com (10.164.65.45) To BL2PR04MB1972.namprd04.prod.outlook.com (10.167.97.144) X-MS-Office365-Filtering-Correlation-Id: 4694d206-85a6-4db1-86b6-08d3e73df7f4 X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1972; 2:x3OXF5isuiwuCqisRgaeDZtpnVTMMF3sw3ySxh9n4OasVLlQ5Cct2pMGWJUwwQ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8GbTsxNYtIADIC0fVTZVqASa/XU= X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1972; 31:R8qSHXbS84/qYiiZKeiKd9uXC/6slxOzQ+s/YurVnGU6iwe0QZngYcE0LmJI4mKP14hfE1rjE912HFkZz01AAKIc91ktai04fIp93iSO/49Jr2s0Xjpu6LigyeTq1vh6dilOwiAo8UxNT3G3qRWRSZwUxGuyMnh2I7RNakQMS0fY5tbx0NI6ly4XoyQ8hQA2ZHW95vAt+8TZKGuSBIa9ccaFplywt06QMBDMf9zd8W4=; 20:T5X5bBMGNtBZhfCf0HNoCO+ej3cH2M664PRQ20qxoAWfcfLS3qAsvFgb3WOfHsOMwfHkrCaNyu4TYX95ehoYYE2SCqn0h1SRtfZh4GURfGuAnI4YWSL80LylvDQPVdJg2OaDnZM/abUx0AbfS8pAymc/fS3VEuzFO6T6AYAr44yLc6q/V8WfiNU9gZZI9Q89k+LrEZ+RRryr6BTsZEQK5UBybRs3ajZw860FC7rxJP9mDs2oETklR7sQq+aieW+GJhxr3MFVhgurTD6EOpVPKQ1Gh2oSkiuJ87aj4hHV6CjA+LjbRMVgev6slcBsTS2amR8Vw2kpV4FUCvewyofvXbkR0evawCpUgE15EoiqVf8IWw1ES+vsrKPU9bqEXCcAceBLnE/lPmUq7IAP+u3EQrANvixtxMvGZa+42BP0IdLbh7ZqmycT1SvsiQsG07lXLCCvQuPyPb03GrbX0UUKORv8ACFnEzYEaMpUMaIPzcph6QPoygQk/ilAaOuSQTCW 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)(10201501046)(3002001)(6055026); SRVR:BL2PR04MB1972; BCL:0; PCL:0; RULEID:; SRVR:BL2PR04MB1972; X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1972; 4:OPN9N7M8LtzK6N2zg2ZvUEtTsXPOekht5FFwT5f39ulPQXA+3S/XTHir595Ek96Y0M/Jil0EkYLSw3Vzn28PGlsR1WAoEv+tME80jfBoO6PjWdSI8YhNk1stHUzpFI9lbR46HffM0KkEAuSafZX2E/eVoAnKjaq3sPLjl+G6PlOAXDzO06U8BvL0xH44wjKM70CFqAl46UHxhripTqZSrjtf3QSJ7rIQfKSrKhkB99T/Yv4WjncnIRo9k+/32f7SLg1A+lYZJpUw3WwM+nzS4grdR0hbRi8t5N9Xwcf6WRZlqDhi6nKSStTBZvKhWqn3bIu1M+XJ4+P69m3Gx8scfXU0YkuKaOUTsPN0lvGWf8hr7v6IN3FIpaa+ApWECKbSoi7YZ5vfg9SmO6fnh/BHABqpClz+JavYxkFd70swFcFS3jvaIs6XvE8Gt3Wl22OOJ0/UpJYcAUn79LfazzlZ5kgDQEF/i7R3y/UALQWiLwE= X-Forefront-PRVS: 0079056367 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(6009001)(7916002)(189002)(199003)(33646002)(77096005)(229853001)(3846002)(6116002)(586003)(105586002)(106356001)(107886002)(97736004)(4001430100002)(101416001)(189998001)(6916009)(2950100002)(42186005)(50986999)(76176999)(50226002)(86362001)(8676002)(19580395003)(19580405001)(4326007)(66066001)(36756003)(81156014)(81166006)(50466002)(7846002)(48376002)(305945005)(7736002)(68736007)(110136003)(5660300001)(2906002)(92566002)(5003940100001)(47776003)(7099028)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR04MB1972; 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; BL2PR04MB1972; 23:PNO64MzUscelKw03otQlrLXy1LgMFOGvUap5cI2lh?= =?us-ascii?Q?nQJHwjnA4fBI/5EJH9GhWM8CqnZC9dDv/7HXkuGPo0UA4Fg5K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QnyvMCb5fzqw046FRlsqFiBWm56gUi9/9bYvpcq86syRGztBDIDcjoH/MRXzjAgAHgnjgtO1JBqB+05x62+RCtZ9qnf+rr/c/ajXllOAbu6InB7QpqXbWZ3FihjPCpFgcVMrWdZZuwWqWOG/HJ5toDrWK7wfCdYE1i3uch88OFTnjrBSMuDorDzTei2er1ikHXJf1CFOPhXZpBxJLPEYyPWFmrrPz8AI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1972; 20:6UPPiVogH8bpPu1hRzSweRSg73R/UgKMU7i7yl6wNJjZEidDxrKCTuu06MKXBI7myeNfNF0HDra+u1Qp2SQUfcgYZnf++E3/OJaaaEOwyNN6b0+4nL3nYfodV5fHtYaLTKlIXWqAlQNIq+R3FVnxNpdmy9y6+sF+klvH0DhQUz2jEuAeEVHpMHo4uJ6ZSmWi0o8WOJY/Td4Dqt/Y+81DrTw9e4JaHgZdp5sovOcIrMGyvM7I5VXFEb+8+KKSaUH+ X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2016 01:22:51.0085 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR04MB1972 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: Martin K. Petersen --- 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;