From patchwork Fri Sep 30 04:11:39 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: 9357647 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 ED062600C8 for ; Fri, 30 Sep 2016 04:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2D5F29D9D for ; Fri, 30 Sep 2016 04:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E771D29DBC; Fri, 30 Sep 2016 04:12:16 +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 E703129D9D for ; Fri, 30 Sep 2016 04:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753148AbcI3EMO (ORCPT ); Fri, 30 Sep 2016 00:12:14 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:32069 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbcI3EMM (ORCPT ); Fri, 30 Sep 2016 00:12:12 -0400 X-IronPort-AV: E=Sophos;i="5.31,418,1473091200"; d="scan'208";a="22622671" Received: from mail-co1nam03lp0018.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) ([216.32.181.18]) by ob1.hgst.iphmx.com with ESMTP; 30 Sep 2016 12:12:08 +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=WdQN1TJ42ixqvkkdT8gPPT2BGq9FvVzGlMdaU1HZbxM=; b=Poc2M2cMr79T4SaVQlMI5ohYaIRnkBQ+nRJ86foauJ/sQ0gDkOptqa+7Jb6W16smtZhfMly0GSUaZB2ts05nvAnKDqspsNV1QsRRpVdqaO5ZL3QenLOblecCvokflLRlHcERI0I7Gvq9KlcYtNumi+6deFGNmEbMdakSPLcje3M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from washi.fujisawa.hgst.com (199.255.47.8) by CY1PR04MB1979.namprd04.prod.outlook.com (10.166.191.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Fri, 30 Sep 2016 04:12:04 +0000 From: Damien Le Moal To: Jens Axboe CC: , , Christoph Hellwig , "Martin K . Petersen" , Hannes Reinecke , Shaun Tancheff , Damien Le Moal , Shaun Tancheff Subject: [PATCH v5 7/7] blk-zoned: implement ioctls Date: Fri, 30 Sep 2016 13:11:39 +0900 Message-ID: <1475208699-27310-8-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475208699-27310-1-git-send-email-damien.lemoal@hgst.com> References: <1475208699-27310-1-git-send-email-damien.lemoal@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: BY2PR12CA0020.namprd12.prod.outlook.com (10.160.121.30) To CY1PR04MB1979.namprd04.prod.outlook.com (10.166.191.15) X-MS-Office365-Filtering-Correlation-Id: f0f539f2-22e5-4ce5-24c7-08d3e8e7f0b1 X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1979; 2:ta5WGAE44nFpKh+G9IxEaqOaAu5qjqPu7MXhVuykkLI/qCNITx4urgYE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YljGlYKKSb9UkCAjNEM= X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1979; 31:lBL64QBDcqKrmBnBcBKdA9xTcxJ3I0Sgw2mgDwdi2TRlwdBxxhgu550+IO2stvQlShIen/U2iJdebaHV4yuuofhWJxcHls/TyPjK4SyW7cEhHcsOuOnp/Yvz5+UP8T4oy7oEhisFf1bYib5CHfC+4aoxTJbDllSzsP8QS64GvRO/9I0PcNew98MsJFzfLfb2y7TvbRdGBIB6SBSRjgPG9180FJqHHcmULEOLd4CjkCuBqKuxixqdymUQmhVGShR3; 20:cldHwXwPWDKs+/T1DfFNV/ZpvKiAq6wy52iW/4ajOxELHi7bnLEcq92cp1YJwdm6fNHZ0ceQA2Wo/KIqKs5pI8Q23xcudZ9bcQoYc27AanWynmwlmkbwi0/P0nNFEb9RFXgh2xaJc2ljouoY9Le1+wHQWckHYhAbiXWTLFHnLJ988cxByndYqjuNwrzlBwg8JaqEFHWVIy5Gkavt1fTauNR5hmy/c1WJf6GGymVIKdi5Hke8dLnw8TEHjwuWBHjfNNuSJtCAaWsNHrF2/3jy7T/95LQH8OlR3h22TkOlMO+GaeQdTpXqECkz3RcR29674xZ1TANBlMPJ3JZ8AK6PBFM7mCi0xOLhw5Vc+2KSBN50Kyu0Ckf9FPTeFad6Sx+YBy+Emh3K+wUcwA5tZszRBfhKWM79AKN0NwRZhZgv/obRdgw7MYw2hV2b9gd7YN7Bbwmws7Kwxp2CR4wsp0BXI2Ox2WM8A7WLfLONl0GXfQ5Nj7tdOvZ0mjp/pUWlnj83 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR04MB1979; BCL:0; PCL:0; RULEID:; SRVR:CY1PR04MB1979; X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1979; 4:z4Gud19XVRrOhZpGATfqFDqgCDpEQMPDTYT0rUNsfDNGZOk5T0RPf48ohhJjE0xVSzVtZ5U2kn7yw8hBRRQZ0QHx612tdpI/MW3qoVCTlPFRKnj4CLyC5OYboA0cW0D7pq+RIoNPCeeb8lirxdTqtDmTunbgHQozumB6u3LxEKQVUAqXwan5uO8LgxHuj2B3vRnwmN5QsRDHaUD0+XCmkvTHu2+jb69TLGf3q/x8LUnk0AU0xRNQ/3f2pt05h2MK0mAf3uFFc84bQkb+9MWd8q3sECU8t3U2MZ0QaKJHDHp0R8PzheMSqTSjJbUmFdi5uWIkQSzXZbVHIjDLdyQAhInicqWvrNldeFew/G/OunQf9dLulpN0kR72dCuVbgiQO8PrjXDkj3oDy2GiPdWdVvS9BfnHUbsTrTibGxEehUyAM96a8VvBltfB2xaU6knK+iQDR6XHnvEoGEizKyrhLMeQdTF3YjMxdsztCRby+rc= X-Forefront-PRVS: 008184426E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(8676002)(42186005)(2950100002)(81156014)(6916009)(6666003)(81166006)(5003940100001)(47776003)(66066001)(229853001)(106356001)(7846002)(105586002)(305945005)(2906002)(36756003)(189998001)(7736002)(5660300001)(76176999)(50986999)(97736004)(586003)(4326007)(3846002)(50226002)(33646002)(575784001)(50466002)(86362001)(68736007)(77096005)(110136003)(101416001)(19580395003)(92566002)(19580405001)(48376002)(6116002)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR04MB1979; 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; CY1PR04MB1979; 23:J1pqXbukXf3yhtQH1uLNNM4j+F2tvCEcYjDkg7DCj?= =?us-ascii?Q?SQxtW0TD+Qn6cHqioCHOxjZKfGuJ/52yJDWRFT+a6AAFEhLUVW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0enw/4PUrSiTU8yGxK4jcLdE2/8Y2uRpUivaaTKeUcPxstq4kp39biJL+ksLC380g9493w8mBaq5iqnsdbbZZ4cy+QF2TfPDRUANTcf2LNohD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1979; 20:GuH+Kru0ZDKTsAVY/RryTceDkflJpfyehBIy3bKdeYE+I/R+vIcWObrHb1EkgPt3T0uUzfCdhm/yu9+TOn26MAXKOq4NhMRRUBNaM15wv9NLZvZNjNf6O4dJ9/ogpCb2l+41hY8WyFkiXxZWKcBTcGuPgN4TxyUkDj2nGPyE+yKL8+woMmqQwfEhSdNaXmmhAgzn06Xz92jPRTFaoK3iZFrHi6ogBl+IZnrmnWZde6I6A6MVCUs8Q6yNnZMtjhGZ X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2016 04:12:04.6249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR04MB1979 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 From: Shaun Tancheff Adds the new BLKREPORTZONE and BLKRESETZONE ioctls for respectively obtaining the zone configuration of a zoned block device and resetting the write pointer of sequential zones of a zoned block device. The BLKREPORTZONE ioctl maps directly to a single call of the function blkdev_report_zones. The zone information result is passed as an array of struct blk_zone identical to the structure used internally for processing the REQ_OP_ZONE_REPORT operation. The BLKRESETZONE ioctl maps to a single call of the blkdev_reset_zones function. Signed-off-by: Shaun Tancheff Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Reviewed-by: Hannes Reinecke --- block/blk-zoned.c | 93 +++++++++++++++++++++++++++++++++++++++++++ block/ioctl.c | 4 ++ include/linux/blkdev.h | 21 ++++++++++ include/uapi/linux/blkzoned.h | 40 +++++++++++++++++++ include/uapi/linux/fs.h | 4 ++ 5 files changed, 162 insertions(+) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 1603573..667f95d 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -255,3 +255,96 @@ int blkdev_reset_zones(struct block_device *bdev, return 0; } EXPORT_SYMBOL_GPL(blkdev_reset_zones); + +/** + * BLKREPORTZONE ioctl processing. + * Called from blkdev_ioctl. + */ +int blkdev_report_zones_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_report rep; + struct blk_zone *zones; + 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 (copy_from_user(&rep, argp, sizeof(struct blk_zone_report))) + return -EFAULT; + + if (!rep.nr_zones) + return -EINVAL; + + zones = kcalloc(rep.nr_zones, sizeof(struct blk_zone), GFP_KERNEL); + if (!zones) + return -ENOMEM; + + ret = blkdev_report_zones(bdev, rep.sector, + zones, &rep.nr_zones, + GFP_KERNEL); + if (ret) + goto out; + + if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report))) { + ret = -EFAULT; + goto out; + } + + if (rep.nr_zones) { + if (copy_to_user(argp + sizeof(struct blk_zone_report), zones, + sizeof(struct blk_zone) * rep.nr_zones)) + ret = -EFAULT; + } + + out: + kfree(zones); + + return ret; +} + +/** + * BLKRESETZONE ioctl processing. + * Called from blkdev_ioctl. + */ +int blkdev_reset_zones_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_range zrange; + + 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 (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range))) + return -EFAULT; + + return blkdev_reset_zones(bdev, zrange.sector, zrange.nr_sectors, + GFP_KERNEL); +} diff --git a/block/ioctl.c b/block/ioctl.c index ed2397f..448f78a 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -513,6 +513,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, BLKDEV_DISCARD_SECURE); case BLKZEROOUT: return blk_ioctl_zeroout(bdev, mode, arg); + case BLKREPORTZONE: + return blkdev_report_zones_ioctl(bdev, mode, cmd, arg); + case BLKRESETZONE: + return blkdev_reset_zones_ioctl(bdev, mode, cmd, arg); case HDIO_GETGEO: return blkdev_getgeo(bdev, argp); case BLKRAGET: diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 252043f..90097dd 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -316,6 +316,27 @@ extern int blkdev_report_zones(struct block_device *bdev, extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors, sector_t nr_sectors, gfp_t gfp_mask); +extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg); +extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg); + +#else /* CONFIG_BLK_DEV_ZONED */ + +static inline int blkdev_report_zones_ioctl(struct block_device *bdev, + fmode_t mode, unsigned int cmd, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline int blkdev_reset_zones_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 a381721..40d1d7b 100644 --- a/include/uapi/linux/blkzoned.h +++ b/include/uapi/linux/blkzoned.h @@ -16,6 +16,7 @@ #define _UAPI_BLKZONED_H #include +#include /** * enum blk_zone_type - Types of zones allowed in a zoned device. @@ -100,4 +101,43 @@ struct blk_zone { __u8 reserved[36]; }; +/** + * struct blk_zone_report - BLKREPORTZONE ioctl request/reply + * + * @sector: starting sector of report + * @nr_zones: IN maximum / OUT actual + * @reserved: padding to 16 byte alignment + * @zones: Space to hold @nr_zones @zones entries on reply. + * + * The array of at most @nr_zones must follow this structure in memory. + */ +struct blk_zone_report { + __u64 sector; + __u32 nr_zones; + __u8 reserved[4]; + struct blk_zone zones[0]; +} __packed; + +/** + * struct blk_zone_range - BLKRESETZONE ioctl request + * @sector: starting sector of the first zone to issue reset write pointer + * @nr_sectors: Total number of sectors of 1 or more zones to reset + */ +struct blk_zone_range { + __u64 sector; + __u64 nr_sectors; +}; + +/** + * Zoned block device ioctl's: + * + * @BLKREPORTZONE: Get zone information. Takes a zone report as argument. + * The zone report will start from the zone containing the + * sector specified in the report request structure. + * @BLKRESETZONE: Reset the write pointer of the zones in the specified + * sector range. The sector range must be zone aligned. + */ +#define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) +#define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range) + #endif /* _UAPI_BLKZONED_H */ diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 3b00f7c..e0fc7f0 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -222,6 +222,10 @@ struct fsxattr { #define BLKSECDISCARD _IO(0x12,125) #define BLKROTATIONAL _IO(0x12,126) #define BLKZEROOUT _IO(0x12,127) +/* + * A jump here: 130-131 are reserved for zoned block devices + * (see uapi/linux/blkzoned.h) + */ #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1) /* bmap access */