From patchwork Sun Jun 28 23:01:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 11630377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27C98174A for ; Sun, 28 Jun 2020 23:02:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A97920772 for ; Sun, 28 Jun 2020 23:02:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="i1znPR9b"; dkim=pass (1024-bit key) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="XMUtjM7O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726612AbgF1XCB (ORCPT ); Sun, 28 Jun 2020 19:02:01 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:1999 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgF1XB7 (ORCPT ); Sun, 28 Jun 2020 19:01:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1593385319; x=1624921319; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=6R5hRxO5pHES573y78eR2zYl2qx0XNUrhAS2zORDx8o=; b=i1znPR9bJjszibxs0VJTHxLXGucoBIguKqyxCt1mYjwcMCK2gdPN2J8p 4rB7lKybWtA5e14RJWlBwqCsMb9GzxG3LNlrF3OjJiDJrpXMhAyCnS9Z4 v156m7aLw1rojxCmD5KPtKOykT6acFIk/lEWO4xfgfNPEvi7pKkBQzzPD n7+UH8ywMYt7cU4pND66lYaCKDPG0j62AHlHGfccb3qzRj98aPKNz3UFq F51z8rLw4JZOUp6W1e5i4tGvN/s63gRFB3myy08xzZ4spvm8XEcTbOcmW FOy7AcIyQjzG+I3gveYOXLMh9BLBA/Iv2KZw7LzuX9iaQlMtvkvt70fvF A==; IronPort-SDR: n3BgWbi+MfLUbXDsk7UJZxHPzc4T6hBtmEgPiMQDmiEMdQefie9cYV4jNz2KIM8JYGdw/LliqR RsDGoCOIrhDkwb7dmZ73CB6Vrww+DkFbw4yskECAJP05Zdfrd8gvyUJ3nQC38mDIzT/2ZhCAII Pzu1yJDOWSdDkAbGI733KUEWZcc+jUPXhIKpKkidIB9GKGLNaEhC5b90xHp0/Wgmtf2CkhmZhj 0NXmgmzhmq3A+jO2tw0kKRJ/leYwKfHmcmjDNKvdQE5H2QD04ETe7cvRUXpBKXpePR29nCrpyw njM= X-IronPort-AV: E=Sophos;i="5.75,293,1589212800"; d="scan'208";a="145457404" Received: from mail-mw2nam12lp2049.outbound.protection.outlook.com (HELO NAM12-MW2-obe.outbound.protection.outlook.com) ([104.47.66.49]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2020 07:01:57 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RvDWMqcG1qBMHEhLRzXZgdDSPEjIzkTEAHwSxXBGz8bUAmoDoN7L2DN6/xQVylejw3Lv3GhNRfmvoq5iolCA0bSqkne2WsM9bz3tbtkqVihChCIaE/2ARDvty+Zu1oHPOKv0hleZD6nRxMyL+1Y5Eh5T/IgM4PWiDKAh5JNhabyAIid86Tr+NnIjt2JAvpoA8iMSdNSv7I109+ktgwCUymGWdf7HBlo3eB4sEWgYQ71OuU63o8oqJaQUugraq4oPGqmBf/hs7b5NAaar4zbuw0BQAhXHjTBcMGVdPPQM622LnW2/F5kwhhncB/5UgqglWiFCeW6jCmRZbrh4RHC02g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t7+JJRNW97go7vUzT8jmHwdxEl3RqQU3vUt2BlPb8sk=; b=Ot9tkSa6cbex4DBafwebF6F+3l/3pebqgwL5xa1C1FzvWS8kMSD4U1WebJ1/9x5Ke75YRKfve3BWkB+loDUeM8Nhk+fLsilSxZf8sukrkaeWAV3JoGycw01Oy/pGQw9xwZNU8QOPWIzShg8PEK7tP2dbRGsrtf8vtB6c66/l+Fo72h3hMquhe5rKE7eHQgJelspyabATTdxqXM2Zy5mv8+jeI75faGposM2SHb1xWop3WQfNxg45n/2ub8Fxar46sR7dUR/GFPq7wLvSqs3qgVrSLwdeGmQ+znl91k5zy0PEDqDK/ZAGV1QUcU9mL70yDg3ZN1AlpEVVdtsq58VraQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t7+JJRNW97go7vUzT8jmHwdxEl3RqQU3vUt2BlPb8sk=; b=XMUtjM7OdVyggSF+PMyY9Km5BASJFNReSGlavsiKhFRu2oEq1gjfEiE7pHKmIxY4cTqH2d1d+v7DJQzMaUAIREi1B1uYq989j65sZIRpQRK7gU/x9tX8F0zJcHdibZCIaZ7qYN0nXTj6VnjWutkptwuCIuI/G93MxO05Byh+rqU= Authentication-Results: kernel.dk; dkim=none (message not signed) header.d=none;kernel.dk; dmarc=none action=none header.from=wdc.com; Received: from MN2PR04MB6223.namprd04.prod.outlook.com (2603:10b6:208:db::14) by MN2PR04MB5965.namprd04.prod.outlook.com (2603:10b6:208:d9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Sun, 28 Jun 2020 23:01:55 +0000 Received: from MN2PR04MB6223.namprd04.prod.outlook.com ([fe80::899f:1d14:ad80:400e]) by MN2PR04MB6223.namprd04.prod.outlook.com ([fe80::899f:1d14:ad80:400e%4]) with mapi id 15.20.3131.026; Sun, 28 Jun 2020 23:01:55 +0000 From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, damien.lemoal@wdc.com, niklas.cassel@wdc.com, hans.holmberg@wdc.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, =?utf-8?q?Mati?= =?utf-8?q?as_Bj=C3=B8rling?= Subject: [PATCH 1/2] block: add zone_desc_ext_bytes to sysfs Date: Sun, 28 Jun 2020 23:01:01 +0000 Message-Id: <20200628230102.26990-2-matias.bjorling@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628230102.26990-1-matias.bjorling@wdc.com> References: <20200628230102.26990-1-matias.bjorling@wdc.com> X-ClientProxiedBy: AM5PR0202CA0018.eurprd02.prod.outlook.com (2603:10a6:203:69::28) To MN2PR04MB6223.namprd04.prod.outlook.com (2603:10b6:208:db::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ninja.localdomain (87.116.37.42) by AM5PR0202CA0018.eurprd02.prod.outlook.com (2603:10a6:203:69::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Sun, 28 Jun 2020 23:01:53 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [87.116.37.42] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7f585e8f-cffd-45e5-c3e0-08d81bb74050 X-MS-TrafficTypeDiagnostic: MN2PR04MB5965: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0448A97BF2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xKR43QHdEXIfKFk0m9qyfVh4SIOxveSCSc4IvOkBJ8hDuSmFKHxJ5zs+v7RTYAU1JzyZheuuP7i3Pi3YHfB8zb0wR4Cu7GIkQplIlZZqfvll4OLoTBQwg/v6QC8ox2AAx9CdeuD0Ti5kHS+05G/MWB0Ooysb0mgZzVjtnPzT8rKkZ72m4pDgmO9oa76BuNXILlC2sTuprv2z7YwC6lxw8ybEhIsGLXBHKudEaigLQEVLSmuizO7aMiRICmzWUdYzvA+pEY/8ZJ0kXPCVC1ZJdnyB6HiyLK1+zjnwpEyEgVYIFoBDIcMDg/iqOy/cHthTe2QJK8FNwn6d5ONWjY0htg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR04MB6223.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(366004)(396003)(39850400004)(376002)(6486002)(4326008)(2616005)(956004)(1076003)(86362001)(6636002)(66946007)(316002)(66556008)(66476007)(186003)(6512007)(26005)(6666004)(66574015)(6506007)(8936002)(2906002)(83380400001)(36756003)(5660300002)(52116002)(16526019)(478600001)(8676002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JZ8omU0OPk9LQ2SfWDhc0EKtpJ+iY+8yohEIv98iq9WMWU2I9JNzTidvOtvcQb7tWVqDXf6nrihheZhUBSDt9DAGWFnD5tUh/v9ioJTP2s2NBGsCBn58YGiD/9H4Kqt5sh/ezo/HNckCkO/PXFSXnL4rBnQ6+LdQLG4J8Sbgj+xe0Sy+KZDZqoFi/nAIZNu4+KpT7M8bJCvrvrXgDyW9FkJFhGHjw939Ue4hnSo6nz64geKj7N7eVJ0yTYMBBeCTZFWMF/RYlausYV2RLxN8b6sINnz/f04dE2YrdIpohBM3yAeLaD33Qz6wsjJL+8IFE/HkvWRQu45VBzJqjrmqANaFpT5vgT/wxKYT+VkUr7oBMZcv3cfAaRnAATmDdQZjJXWdERNs8qA5px5Xl4qZ4h+n0+/fXQCJqYQ2HOSNcVyzfxx1QYWQDKsuQKdfBl/1KA44ntTsunfzctlAmUuMsjyYXw3hx6G34qISFJ65P54= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f585e8f-cffd-45e5-c3e0-08d81bb74050 X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6223.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2020 23:01:55.0382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4d1o6t8W+53hbqD+qznTL+L53KPlmx9pyQJomi2rZRUKGR/l8flWaJiZaSpSoqC/pdlvAuSxAI1tdBjLzUuKrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5965 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The NVMe Zoned Namespace Command Set adds support for associating data to a zone through the Zone Descriptor Extension feature. The Zone Descriptor Extension size is fixed to a multiple of 64 bytes. A value of zero communicates the feature is not available. A value larger than zero communites the feature is available, and the specified Zone Descriptor Extension size in bytes. The Zone Descriptor Extension feature is only available in the NVMe Zoned Namespaces Command Set. Devices that supports ZAC/ZBC therefore reports this value as zero, where as the NVMe device driver reports the Zone Descriptor Extension size from the specific device. Signed-off-by: Matias Bjørling --- Documentation/block/queue-sysfs.rst | 6 ++++++ block/blk-sysfs.c | 15 ++++++++++++++- drivers/nvme/host/zns.c | 1 + drivers/scsi/sd_zbc.c | 1 + include/linux/blkdev.h | 22 ++++++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Documentation/block/queue-sysfs.rst b/Documentation/block/queue-sysfs.rst index f261a5c84170..c4fa195c87b4 100644 --- a/Documentation/block/queue-sysfs.rst +++ b/Documentation/block/queue-sysfs.rst @@ -265,4 +265,10 @@ devices are described in the ZBC (Zoned Block Commands) and ZAC do not support zone commands, they will be treated as regular block devices and zoned will report "none". +zone_desc_ext_bytes (RO) +------------------------- +This indicates the zone description extension (ZDE) size, in bytes, of a zoned +block device. A value of '0' means that zone description extension is not +supported. + Jens Axboe , February 2009 diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 624bb4d85fc7..0c99454823b7 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -315,6 +315,12 @@ static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page) return queue_var_show(queue_max_active_zones(q), page); } +static ssize_t queue_zone_desc_ext_bytes_show(struct request_queue *q, + char *page) +{ + return queue_var_show(queue_zone_desc_ext_bytes(q), page); +} + static ssize_t queue_nomerges_show(struct request_queue *q, char *page) { return queue_var_show((blk_queue_nomerges(q) << 1) | @@ -687,6 +693,11 @@ static struct queue_sysfs_entry queue_max_active_zones_entry = { .show = queue_max_active_zones_show, }; +static struct queue_sysfs_entry queue_zone_desc_ext_bytes_entry = { + .attr = {.name = "zone_desc_ext_bytes", .mode = 0444 }, + .show = queue_zone_desc_ext_bytes_show, +}; + static struct queue_sysfs_entry queue_nomerges_entry = { .attr = {.name = "nomerges", .mode = 0644 }, .show = queue_nomerges_show, @@ -787,6 +798,7 @@ static struct attribute *queue_attrs[] = { &queue_nr_zones_entry.attr, &queue_max_open_zones_entry.attr, &queue_max_active_zones_entry.attr, + &queue_zone_desc_ext_bytes_entry.attr, &queue_nomerges_entry.attr, &queue_rq_affinity_entry.attr, &queue_iostats_entry.attr, @@ -815,7 +827,8 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr, return 0; if ((attr == &queue_max_open_zones_entry.attr || - attr == &queue_max_active_zones_entry.attr) && + attr == &queue_max_active_zones_entry.attr || + attr == &queue_zone_desc_ext_bytes_entry.attr) && !blk_queue_is_zoned(q)) return 0; diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 502070763266..5792d953a8f3 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -84,6 +84,7 @@ int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns, blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1); blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1); + blk_queue_zone_desc_ext_bytes(q, id->lbafe[lbaf].zdes << 6); free_data: kfree(id); return status; diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index d8b2c49d645b..a4b6d6cf5457 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -722,6 +722,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) else blk_queue_max_open_zones(q, sdkp->zones_max_open); blk_queue_max_active_zones(q, 0); + blk_queue_zone_desc_ext_bytes(q, 0); nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks); /* READ16/WRITE16 is mandatory for ZBC disks */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3776140f8f20..2ed55055f68d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -522,6 +522,7 @@ struct request_queue { unsigned long *seq_zones_wlock; unsigned int max_open_zones; unsigned int max_active_zones; + unsigned int zone_desc_ext_bytes; #endif /* CONFIG_BLK_DEV_ZONED */ /* @@ -753,6 +754,18 @@ static inline unsigned int queue_max_active_zones(const struct request_queue *q) { return q->max_active_zones; } + +static inline void blk_queue_zone_desc_ext_bytes(struct request_queue *q, + unsigned int zone_desc_ext_bytes) +{ + q->zone_desc_ext_bytes = zone_desc_ext_bytes; +} + +static inline unsigned int queue_zone_desc_ext_bytes( + const struct request_queue *q) +{ + return q->zone_desc_ext_bytes; +} #else /* CONFIG_BLK_DEV_ZONED */ static inline unsigned int blk_queue_nr_zones(struct request_queue *q) { @@ -784,6 +797,15 @@ static inline unsigned int queue_max_active_zones(const struct request_queue *q) { return 0; } +static inline void blk_queue_zone_desc_ext_bytes(struct request_queue *q, + unsigned int zone_desc_ext_bytes) +{ +} +static inline unsigned int queue_zone_desc_ext_bytes( + const struct request_queue *q) +{ + return 0; +} #endif /* CONFIG_BLK_DEV_ZONED */ static inline bool rq_is_sync(struct request *rq) From patchwork Sun Jun 28 23:01:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 11630379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 837351392 for ; Sun, 28 Jun 2020 23:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 505332076E for ; Sun, 28 Jun 2020 23:02:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="d1TgNHyT"; dkim=pass (1024-bit key) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="hzbcsgQ9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbgF1XCH (ORCPT ); Sun, 28 Jun 2020 19:02:07 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:2007 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbgF1XCA (ORCPT ); Sun, 28 Jun 2020 19:02:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1593385320; x=1624921320; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=VQdZjUpGpzPxTBS+Y1rg+pb4zhbVAOjXX96uDCZCMzU=; b=d1TgNHyTVo8Wdyc4BRMCsrkeMxL6Wu0lQgPNAI/W7ks0nTvr/iK+hb/V 5rNEU3aURI7biLR5chXCVRFVAJUwMMLHjDelcznc+i0GWeZC13X8bfwie Cxw6jt+MlvD36WnzvnvswLStZdvXri60F2xC3VLSLY17WXL3X5tE9O98x JFjgF15plHGqCn+bswMxG7NJwtJSxr21/tYUzo7/SQuW3K15YqkazvkbC Y4FN0TGx42RgXx5bqlHHwrludUVC2saviqOvKbcxpNyoE/QQdlXaZ3nE2 4TLV3GzL6i9FTuGdu+Cl0wIACeSGzmWZdzmuccVrYqqBhGySFVNRObl+o w==; IronPort-SDR: Nxi5Y0bAdsNKzewJ0Qqv+QrTWj4Jt4IvNvOb7EumPX5j6YJrhNFWcU90Gy/vopFoSJnx2aTMdC myOrmfyCrqmLnroHUqvdbr+lh/hrmFkH1v57pYibXEM0kSamm7mGWwFC+9TuL8AAVKVCZWXcVK pPUYUHw70qa9my4wO54tS8A5ozUklDXs6VYEHo6+8TtkjxzXnS7VzfAdAhVxpL80NFSj8Zxhvz 8hDJAVOmd+2R/llOzyXvul51ZXTMn3QRYrAezvB3GSyRQ96cJ4BbBxsEP8Njv06neQN+x5cq7b wZY= X-IronPort-AV: E=Sophos;i="5.75,293,1589212800"; d="scan'208";a="145457407" Received: from mail-mw2nam12lp2046.outbound.protection.outlook.com (HELO NAM12-MW2-obe.outbound.protection.outlook.com) ([104.47.66.46]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2020 07:01:59 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ee1pr3cN1X7COfXGZq3OCstTjC6leRU5WaZkH+HvNu6ou0H2kVRkQVfNcqa8O9XhNO2leFqypuhm+oEXqKrXa0y25TPLGjavV/VaUATn+0h5Sfv3NWsRQ/2wlFenanZS8RdfHUi/D4H0yRjEyGKRw38azSX4FqKJx3x5GYYhiPXIbC1vl0+3F9DPclUFxOdrhmvyNYLTx3bSZkXx/5OocN51xW3gjCBZSoXAu6PWmrbNCQPQCFWlvTHOGAUMI+1d2APj/t69m2nSZqVjyPVwBNkIu2YPPgqpJl1GGGmAOd4PtJC2zsMoVpx2VXdxH9Wulq9Xm/HptdDgb345GcwCPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e3IMlmPpP8bNkwD8bNTWv/UTt3aY69ikCOLCRsL+ux4=; b=i2d7ZAG1wKS9S1h5XQDZX3roG7XHiR4jYzqI/jUpCwQwZldnrq/wHd7sO7rj2449oBLlao82BwGYsRgNy7bivoiDuvWGdbwiViUu8Tls/WoR98BeKGyobJ53Uy+Sm8Qk21G9Bq14axJHVT6JkGcxVCAseY5QXqIU5BsyoWTyIYkUnaNF3oArU9xmxvZ8mBl1z/75yARE15AqiCvZSeHUipRrdguwBdGzEg3aFccATA87CQUYgyvcy5WSvHfbFnQ83Lb6XUE6AdpsfUDWab/LNX92qHxXIZgC6dQrLnE+U+mj4f/kNvtqPordMu5KozXcXhOxO6SmEg2uXU/egvhLCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e3IMlmPpP8bNkwD8bNTWv/UTt3aY69ikCOLCRsL+ux4=; b=hzbcsgQ9Q8rWCY5DFWUY8AXb7bPfmVn8zVeMK5FvbMKKtAzuVa3xaFEn9FrxTKM9Mh7+5q22MKswOIzq6MB4DWCPSgCXzPFw8ErnqfJdqPfWI9pRWx0J9MfeTlv+HHUYQYIH+lL/OVJTp/17IC5XD6qWApRSEcFTMmmRt8wd6/c= Authentication-Results: kernel.dk; dkim=none (message not signed) header.d=none;kernel.dk; dmarc=none action=none header.from=wdc.com; Received: from MN2PR04MB6223.namprd04.prod.outlook.com (2603:10b6:208:db::14) by MN2PR04MB5965.namprd04.prod.outlook.com (2603:10b6:208:d9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20; Sun, 28 Jun 2020 23:01:57 +0000 Received: from MN2PR04MB6223.namprd04.prod.outlook.com ([fe80::899f:1d14:ad80:400e]) by MN2PR04MB6223.namprd04.prod.outlook.com ([fe80::899f:1d14:ad80:400e%4]) with mapi id 15.20.3131.026; Sun, 28 Jun 2020 23:01:57 +0000 From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, damien.lemoal@wdc.com, niklas.cassel@wdc.com, hans.holmberg@wdc.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, =?utf-8?q?Mati?= =?utf-8?q?as_Bj=C3=B8rling?= Subject: [PATCH 2/2] block: add BLKSETDESCZONE ioctl for Zoned Block Devices Date: Sun, 28 Jun 2020 23:01:02 +0000 Message-Id: <20200628230102.26990-3-matias.bjorling@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628230102.26990-1-matias.bjorling@wdc.com> References: <20200628230102.26990-1-matias.bjorling@wdc.com> X-ClientProxiedBy: AM5PR0202CA0018.eurprd02.prod.outlook.com (2603:10a6:203:69::28) To MN2PR04MB6223.namprd04.prod.outlook.com (2603:10b6:208:db::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ninja.localdomain (87.116.37.42) by AM5PR0202CA0018.eurprd02.prod.outlook.com (2603:10a6:203:69::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Sun, 28 Jun 2020 23:01:55 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [87.116.37.42] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3ea5eda5-a4b0-48e8-ce3f-08d81bb741b1 X-MS-TrafficTypeDiagnostic: MN2PR04MB5965: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 0448A97BF2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ctj47+tfFFkkjPAB2ypCVK8ZsBJ0UR1L0KYsLrhs8Amfzf+dB11qRbJ8T4j0MdFbNVlXtkak16S8UlaSgloVfYfGWDrb7RLf4Ue8VS+QydQngV03piLaoEpUYw/925Q/XeOGFcUIvuVnYeCgBDJdJbsKeCczXtYUbx+c/Y0YY1QdZpO3O8tN98d65F9PnOPV6BMd45sPJBnQf0z2+SqtD/EWwq4wDwNFBmRjA/ZgpplglqBIUnY9kqzhGDqqZvy9Q5jouvGX31gFkj6HtykGeqSLw2pGzpCefJ+01wTOlCXUnIMIozXh5BhJ5HFeyN9PLk/PM5dI055XDqyDF8IM6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR04MB6223.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(366004)(396003)(39850400004)(376002)(6486002)(4326008)(2616005)(956004)(1076003)(86362001)(6636002)(66946007)(316002)(66556008)(66476007)(30864003)(186003)(6512007)(26005)(6666004)(66574015)(6506007)(8936002)(2906002)(83380400001)(36756003)(5660300002)(52116002)(16526019)(478600001)(8676002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: h7teW06JigNX+KSm4554LpriddLUKTHB/qFxKbmkf9DC/ChMO5oNXo5efLhmgnbya/xgcJ1b8LbJI6nXXeNcPr6gPxur9K5/0YrGRDYbHhLWBXWNjRlqEVzqZmyboQM7BBk3paByHoqIVefG074gVuMhRP54Ke0q0KbDGSmm8PtP+uNIy6Opc9UuC5Hy5qxOMlLpXxdQ21o1s/hzKaMYmNyFWKF60jpo6QTMnGrTQlWMo2YmvcJxORjVIXHG3l1S5W81MT4WpUHgXsQqiHqBGh8ETK7oKJtJt8yfqPh9xnQR97d5YzfkS97MXfQhVSNqGHS7iz3FO06f6OB4p/NZ39KiBFHlKW32FpoEBb8xx8A5HY6OpkE0nogizbguKDWXEMvFAErHFfUWUr5R5ezVI0p488vh/m1tLKYFBROFaLURoQT2Pq5S9vIxCptmETWdpyhG3fIlgVih7sSfUcf28Kbju1tyyaCQeLgwjI4BAaY= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ea5eda5-a4b0-48e8-ce3f-08d81bb741b1 X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6223.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2020 23:01:57.2049 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TTjvcw8LB3fy39jTPL5hHZyj0SDWk+hQ94TvLGm20BtChx+G0F50nC4T16H11RRfY1OUENEjuFPPYmO+fD2+KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5965 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The NVMe Zoned Namespace Command Set adds support for associating data to a zone through the Zone Descriptor Extension feature. To allow user-space to associate data to a zone, add support through the BLKSETDESCZONE ioctl. The ioctl requires that it is issued to a zoned block device, and that it supports the Zone Descriptor Extension feature. Support is detected through the the zone_desc_ext_bytes sysfs queue entry for the specific block device. A value larger than zero communicates that the device supports the feature. The ioctl associates data to a zone by issuing a Zone Management Send command with the Zone Send Action set as the Set Zone Descriptor Extension. For the command to complete successfully, the specified zone must be in the Empty state, and active resources must be available. On success, the specified zone is transioned to Closed state by the device. If less data is supplied by user-space then reported by the the Zone Descriptor Extension size, the rest is zero-filled. If more data or no data is supplied by user-space, the ioctl fails. To issue the ioctl, a new blk_zone_set_desc data structure is defined. It has following parameters: * the sector of the specific zone. * the length of the data to be associated to the zone. * any flags be used by the ioctl. None is defined. * data associated to the zone. The data is laid out after the flags parameter, and it is the caller's responsibility to allocate memory for the data that is specified in the length parameter. Signed-off-by: Matias Bjørling --- block/blk-zoned.c | 108 ++++++++++++++++++++++++++++++++++ block/ioctl.c | 2 + drivers/nvme/host/core.c | 3 + drivers/nvme/host/nvme.h | 9 +++ drivers/nvme/host/zns.c | 11 ++++ include/linux/blk_types.h | 2 + include/linux/blkdev.h | 9 ++- include/uapi/linux/blkzoned.h | 20 ++++++- 8 files changed, 162 insertions(+), 2 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 81152a260354..4dc40ec006a2 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -259,6 +259,50 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, } EXPORT_SYMBOL_GPL(blkdev_zone_mgmt); +/** + * blkdev_zone_set_desc - Execute a zone management set zone descriptor + * extension operation on a zone + * @bdev: Target block device + * @sector: Start sector of the zone to operate on + * @data: Pointer to the data that is to be associated to the zone + * @gfp_mask: Memory allocation flags (for bio_alloc) + * + * Description: + * Associate zone descriptor extension data to a specified zone. + * The block device must support zone descriptor extensions. + * i.e., by exposing a positive zone descriptor extension size. + */ +int blkdev_zone_set_desc(struct block_device *bdev, sector_t sector, + struct page *data, gfp_t gfp_mask) +{ + struct request_queue *q = bdev_get_queue(bdev); + sector_t zone_sectors = blk_queue_zone_sectors(q); + struct bio_vec bio_vec; + struct bio bio; + + if (!blk_queue_is_zoned(q)) + return -EOPNOTSUPP; + + if (bdev_read_only(bdev)) + return -EPERM; + + /* Check alignment (handle eventual smaller last zone) */ + if (sector & (zone_sectors - 1)) + return -EINVAL; + + bio_init(&bio, &bio_vec, 1); + bio.bi_opf = REQ_OP_ZONE_SET_DESC | REQ_SYNC; + bio.bi_iter.bi_sector = sector; + bio_set_dev(&bio, bdev); + bio_add_page(&bio, data, queue_zone_desc_ext_bytes(q), 0); + + /* This may take a while, so be nice to others */ + cond_resched(); + + return submit_bio_wait(&bio); +} +EXPORT_SYMBOL_GPL(blkdev_zone_set_desc); + struct zone_report_args { struct blk_zone __user *zones; }; @@ -370,6 +414,70 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode, GFP_KERNEL); } +/* + * BLKSETDESCZONE ioctl processing. + * Called from blkdev_ioctl. + */ +int blkdev_zone_set_desc_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + struct request_queue *q; + struct blk_zone_set_desc zsd; + void *zsd_data; + int ret; + + if (!argp) + return -EINVAL; + + q = bdev_get_queue(bdev); + if (!q) + return -ENXIO; + + if (!blk_queue_is_zoned(q)) + return -ENOTTY; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + + if (!(mode & FMODE_WRITE)) + return -EBADF; + + if (!queue_zone_desc_ext_bytes(q)) + return -EOPNOTSUPP; + + if (copy_from_user(&zsd, argp, sizeof(struct blk_zone_set_desc))) + return -EFAULT; + + /* no flags is currently supported */ + if (zsd.flags) + return -ENOTTY; + + if (!zsd.len || zsd.len > queue_zone_desc_ext_bytes(q)) + return -ENOTTY; + + /* allocate the size of the zone descriptor extension and fill + * with the data in the user data buffer. If the data size is less + * than the zone descriptor extension size, then the rest of the + * zone description extension data buffer is zero-filled. + */ + zsd_data = (void *) get_zeroed_page(GFP_KERNEL); + if (!zsd_data) + return -ENOMEM; + + if (copy_from_user(zsd_data, argp + sizeof(struct blk_zone_set_desc), + zsd.len)) { + ret = -EFAULT; + goto free; + } + + ret = blkdev_zone_set_desc(bdev, zsd.sector, virt_to_page(zsd_data), + GFP_KERNEL); +free: + free_page((unsigned long) zsd_data); + return ret; +} + static inline unsigned long *blk_alloc_zone_bitmap(int node, unsigned int nr_zones) { diff --git a/block/ioctl.c b/block/ioctl.c index bdb3bbb253d9..b9744705835b 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -515,6 +515,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, case BLKCLOSEZONE: case BLKFINISHZONE: return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg); + case BLKSETDESCZONE: + return blkdev_zone_set_desc_ioctl(bdev, mode, cmd, arg); case BLKGETZONESZ: return put_uint(argp, bdev_zone_sectors(bdev)); case BLKGETNRZONES: diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e961910da4ac..b8f25b0d00ad 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -776,6 +776,9 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, case REQ_OP_ZONE_FINISH: ret = nvme_setup_zone_mgmt_send(ns, req, cmd, NVME_ZONE_FINISH); break; + case REQ_OP_ZONE_SET_DESC: + ret = nvme_setup_zone_set_desc(ns, req, cmd); + break; case REQ_OP_WRITE_ZEROES: ret = nvme_setup_write_zeroes(ns, req, cmd); break; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 662f95fbd909..5bd5a437b038 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -708,6 +708,9 @@ int nvme_report_zones(struct gendisk *disk, sector_t sector, blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req, struct nvme_command *cmnd, enum nvme_zone_mgmt_action action); + +blk_status_t nvme_setup_zone_set_desc(struct nvme_ns *ns, struct request *req, + struct nvme_command *cmnd); #else #define nvme_report_zones NULL @@ -718,6 +721,12 @@ static inline blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, return BLK_STS_NOTSUPP; } +static inline blk_status_t nvme_setup_zone_set_desc(struct nvme_ns *ns, + struct request *req, struct nvme_command *cmnd) +{ + return BLK_STS_NOTSUPP; +} + static inline int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns, unsigned lbaf) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 5792d953a8f3..bfa64cc685d3 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -239,3 +239,14 @@ blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req, return BLK_STS_OK; } + +blk_status_t nvme_setup_zone_set_desc(struct nvme_ns *ns, struct request *req, + struct nvme_command *c) +{ + c->zms.opcode = nvme_cmd_zone_mgmt_send; + c->zms.nsid = cpu_to_le32(ns->head->ns_id); + c->zms.slba = cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req))); + c->zms.action = NVME_ZONE_SET_DESC_EXT; + + return BLK_STS_OK; +} diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index ccb895f911b1..53b7b05b0004 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -316,6 +316,8 @@ enum req_opf { REQ_OP_ZONE_FINISH = 12, /* write data at the current zone write pointer */ REQ_OP_ZONE_APPEND = 13, + /* associate zone desc extension data to a zone */ + REQ_OP_ZONE_SET_DESC = 14, /* SCSI passthrough using struct scsi_request */ REQ_OP_SCSI_IN = 32, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2ed55055f68d..c5f092dd5aa3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -370,7 +370,8 @@ extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); - +extern int blkdev_zone_set_desc_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg); #else /* CONFIG_BLK_DEV_ZONED */ static inline unsigned int blkdev_nr_zones(struct gendisk *disk) @@ -392,6 +393,12 @@ static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev, return -ENOTTY; } +static inline int blkdev_zone_set_desc_ioctl(struct block_device *bdev, + fmode_t mode, unsigned int cmd, + unsigned long arg) +{ + return -ENOTTY; +} #endif /* CONFIG_BLK_DEV_ZONED */ struct request_queue { diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h index 42c3366cc25f..68abda9abf33 100644 --- a/include/uapi/linux/blkzoned.h +++ b/include/uapi/linux/blkzoned.h @@ -142,6 +142,20 @@ struct blk_zone_range { __u64 nr_sectors; }; +/** + * struct blk_zone_set_desc - BLKSETDESCZONE ioctl requests + * @sector: Starting sector of the zone to operate on. + * @flags: Feature flags. + * @len: size, in bytes, of the data to be associated to the zone. + * @data: data to be associated. + */ +struct blk_zone_set_desc { + __u64 sector; + __u32 flags; + __u32 len; + __u8 data[0]; +}; + /** * Zoned block device ioctl's: * @@ -158,6 +172,10 @@ struct blk_zone_range { * The 512 B sector range must be zone aligned. * @BLKFINISHZONE: Mark the zones as full in the specified sector range. * The 512 B sector range must be zone aligned. + * @BLKSETDESCZONE: Set zone description extension data for the zone + * in the specified sector. On success, the zone + * will transition to the closed zone state. + * The 512B sector must be zone aligned. */ #define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) #define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range) @@ -166,5 +184,5 @@ struct blk_zone_range { #define BLKOPENZONE _IOW(0x12, 134, struct blk_zone_range) #define BLKCLOSEZONE _IOW(0x12, 135, struct blk_zone_range) #define BLKFINISHZONE _IOW(0x12, 136, struct blk_zone_range) - +#define BLKSETDESCZONE _IOW(0x12, 137, struct blk_zone_set_desc) #endif /* _UAPI_BLKZONED_H */