From patchwork Mon Sep 19 21:27:34 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: 9340583 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 154B2607D0 for ; Mon, 19 Sep 2016 21:29:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 049D429921 for ; Mon, 19 Sep 2016 21:29:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E729F2990B; Mon, 19 Sep 2016 21:29:14 +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 D38572990B for ; Mon, 19 Sep 2016 21:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932641AbcISV3N (ORCPT ); Mon, 19 Sep 2016 17:29:13 -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 S932649AbcISV3L (ORCPT ); Mon, 19 Sep 2016 17:29:11 -0400 X-IronPort-AV: E=Sophos;i="5.30,363,1470672000"; d="scan'";a="15969695" Received: from mail-cys01nam02lp0055.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.55]) by ob1.hgst.iphmx.com with ESMTP; 20 Sep 2016 05:28:14 +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=yYSvOyqk7j+o8Aq+3F/c8w/2yyx7lwH7tnpw7vsY184=; b=lckzU6av6Akeb+PFTSdkNMn/XjJP+8KI5dgM6f6PzxFttRirfs7ZPkda1cUGSRWcRY7NBdmXw8FY8jUjO5512Ml3EHLp+DtB82SldP7sRJoElY0vcucPdA4VdI364V/Xigz60SxvAGxoy2uP4TVcYOq3QJtj7HfKYXEMBaDVNyA= 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:28:11 +0000 From: Damien Le Moal To: , CC: , , , , Damien Le Moal Subject: [PATCH 9/9] blk-zoned: Add ioctl interface for zone operations Date: Tue, 20 Sep 2016 06:27:34 +0900 Message-ID: <1474320454-5264-10-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: 9bc15cc6-66a4-44fa-c16a-08d3e0d3dbf1 X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 2:hXM3U742iP9efPqBH6OwTpJwTZOIQts+XRrsfojK6nD495jP3Ud8MYG+hcpWTDz+MK7pxcIEzg/p6lyMzxzfJIMDpSJWLRs/fQRCPA8OR7NBwxiCdpNfAdggTPNfyW3mDSnLQ+tup6+qz0HPwRFcG5ZCe3DBIzq4I+WJQOgaCDCuZxJdwMA/M0MU0iEwkoE/; 3:runuONl6Qv35skkoHiMPuhcIxdelPdMZk8shInvQUCPbQlxHY9Tukvxs6a7xWBCRTw+S20aisCFL0kQ35uPPqV+gaB5K+WwtCwdC1xXdL7ebPOCjFhQaisXd3r9eM9Mo X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR04MB1975; X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 25:EUL8zjtqlIOmuwZG9tqmlAtbx3D8Mhite0RwsHyuJPr5FqurjXHk8oL3wCRyev/Zuy/E036CM/QbfUrYRhU14htAYrNBo3B8fL+GTGa7v5l039G2glU96Ziiwlv2ofcyML/cmhXl00OXFSkES/okrn2hhjeOOk2nQD94dfQ1c0VY5RB6beGs5iQADEt6hosC70EO+Z7mu8gzmUJ9hhRonbAuywWsQR/eUspymqz6MJC7BqP/w4/OmD2cnrxJJ6qEI9oTbDSnvX2zOyMSDUKGjTUP3UwVtdtguNwYTAB8A5V2v64wJg50h4puWFHWXegLZXAlzQWHLEaaWtA1tb1C51iNQzYWyvblqSbz7FXGfXC3oQzSc9lSctJo5N41yv+qOanuu+4PtDihS7MRebHjdCHZJCpQIBq8l5oDYJVuP7EiPIJWhbNqMSh5I+MxJ06zI+mMjykFQxD/vATyeLk/BdFwTmqjTtt6RiOucauPazJX9PPrFy0LnBcwY+0jmjJTihK6BWhs16/Xv/cs1KugMbrLqWxG6p1r23kgX8hlUNCIRbXgCMSMU+qA0Zrka2nPMJz/aBee495fX46MND5x72Dnb3O9CreXJBCH0o/hmIDuiwPu7lNpFf4hSCn01WjG/ggWxjFyU1xQIe5POt3uEqz+awUSJHiTFA7npsbnTOMGw0xxWsyKioHBrGghBYS1wXmXg5rSXg+/C7Mud+xbifcHMiCelwBdbCblukHwmO+VZLTkuaVPcFVYJ7692VR3nnALapx5t0Z4hTTPlsiFfA== X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 31:YrwsiB1CfYd/7Yh7i0M9tSO/ZQHQQRIkL1N2EVHpZZvaGRMwW4Uq3WZZ2TQN/5iK8uz3aF7FpY3RuArknhLAC+dHmDP41Du+YHk73gzI9F+lhtdNeJH51VaybQrav3dWppnTFANd7jeBfRcSLcU1EcoHuDpq6BHc6dTXjgdb06WURvKq9tDzMl1zp++VIYzi4DNu8vXZmUxD5CnN7tv0AbeAUCPfMfvp159sQYKTDK4=; 20:wG5Wvje8lEvn6jj3HVCJB2tpcuUROV3ADJki6Uj5V9lcli4N9kf2Ox2loUwQN3ysFbfLIuAeUJaTJG04bCkHdwKcFugVZiKkAwKLxRZRkns9bFx8YPlawBPaLSyaqNJ33AZCU8gMo8v6KiQi39XhXnamKKhAZYo+5tgBN9cDkpNBX/qMzEntH/ozdCE/Sdr0cDtP9GZKKfFYZCb57uRVIAT+GCI7f7HVYgt/hQeOiCr1FOz+n9q4Qd1BIJI1Z1MQUeN+tMhEbipfWtDlJJlBiBJJgiu8RsFmjyQwkSaHzLAFcHz95HlT4M9R0pJdpcOu8szGh6pGuAf4Dzkk4ApNP+80QiR/JrZPbuYdru4dP5lOHN9U+UlaQzzT+78GPK6AF6KcGasGKzkxd2VbAIESz/hQsoH8c/Q6xyCGPDn2LXNJq9IqaQKhfgblanLc3BFXN2ml/czTFcM49Pr1+CT6bDF5nLNJJm0wMY9Babx/MASHbsRFubb0vVU9VelidruL X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); 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:9MgPytWbVfY2MpTwJWROdtmIkYwKzH1R6KoLORQcdP3F4POSaCyYoaZy6lbtJUvCwtvqgmZeeDqAwS4WJXGtlr0qqfVi2vtCT+WNPH9td+64nvkB3ObStfnuzRhXMkyYVjFafj+VlcEIRye20KqMYGh2uPC6XeMcGAJtycJeGEqv7/tiU4ee5RhEjZLdXCEeVqDfFmiPmO9m6aqw4ZpovHynRJPMMGjaML1PJpO5FDW8tVGIrbTSb25xMsxxKHIlIJeO6i5Za0rztQp09RrezodMw/JjHBTeWqJx5fYm13iK+F1KYhJT4TG3SKTkfsR5ZchoqC2WzPicdfgttw6FHfaZ2NZ2BEce9OXhkcGpbuCJsYOY3RfnAF5v1L/O2+08SYxcpa2sKYB5M5chONiYF6c437antaeJWfpz0NI8cqP277OLOcGGqWDWbbS9gDOA7qTqtMJgmNEWDahh6mO93Q== X-Forefront-PRVS: 0070A8666B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(54534003)(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:CxYLm3oZBp8OHh2ELllK5qNdjoWDZ6GHObYtwNowl?= =?us-ascii?Q?hjKlwZXYbHv6FesaktV3NfDZmFXn4/AMbhOs6YawVJ13+Ezg1i7+xOvpxKT4?= =?us-ascii?Q?raBQ2+mkv0JJ07DG18sA2pl6FZUdJDDCGx4+m4cStrLh3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8V7iuT6hlzWGR8mrIVggrEMz2VWy6ag6lbj8ushldaMTTqOdB4akKW4EkpM0klSZDOSNJHG1yI+sCwf6ql6DChB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 20:PkCToVBQhCKZyXTysJi8CSUSRyGasO+kyjw4jimXHa56gvkdT6Gddp4SkwmkwxIBF/5Rict9HhjSHrBttDAbGxHsE0gcOcqkbRnFh6R6RQR5pD4hAdoGk8c+RWtq1SUF3lhh0M9NM7iJDf4D6lxN7JkRw//qV6IFCi0yygWoo+CMsXLUGJcOyq15BOo1gV8raBcMRcPa80jKdEYqWd3K7El38MX3blGBRIjhbNnczT+pYTwmF2iWYhiOsW3Q/dkI X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2016 21:28:11.6992 (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 From: Shaun Tancheff Adds the new BLKUPDATEZONES, BLKREPORTZONE, BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctls. BLKREPORTZONE implementation uses the device queue zone RB-tree by default and no actual command is issued to the device. If the application needs access to the untracked zone attributes (non-seq flag or reset recommended flag, offline or read-only zone condition, etc), BLKUPDATEZONES must be issued first to force an update of the cached zone information. Changelog (Damien): * Simplified blkzone descriptor (removed bit-fields and use CPU endianness) * Changed report ioctl to operate on single zone instead of an array of blkzone structures. Signed-off-by: Shaun Tancheff Signed-off-by: Damien Le Moal --- block/blk-zoned.c | 115 ++++++++++++++++++++++++++++++++++++++++++ block/ioctl.c | 8 +++ include/linux/blkdev.h | 7 +++ include/uapi/linux/Kbuild | 1 + include/uapi/linux/blkzoned.h | 91 +++++++++++++++++++++++++++++++++ include/uapi/linux/fs.h | 1 + 6 files changed, 223 insertions(+) create mode 100644 include/uapi/linux/blkzoned.h diff --git a/block/blk-zoned.c b/block/blk-zoned.c index a107940..71205c8 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -12,6 +12,7 @@ #include #include #include +#include void blk_init_zones(struct request_queue *q) { @@ -336,3 +337,117 @@ int blkdev_finish_zone(struct block_device *bdev, return blkdev_issue_zone_action(bdev, sector, REQ_OP_ZONE_FINISH, gfp_mask); } + +static int blkdev_report_zone_ioctl(struct block_device *bdev, + void __user *argp) +{ + struct blk_zone *zone; + struct blkzone z; + + if (copy_from_user(&z, argp, sizeof(struct blkzone))) + return -EFAULT; + + zone = blk_lookup_zone(bdev_get_queue(bdev), z.start); + if (!zone) + return -EINVAL; + + memset(&z, 0, sizeof(struct blkzone)); + + blk_lock_zone(zone); + + blk_wait_for_zone_update(zone); + + z.len = zone->len; + z.start = zone->start; + z.wp = zone->wp; + z.type = zone->type; + z.cond = zone->cond; + z.non_seq = zone->non_seq; + z.reset = zone->reset; + + blk_unlock_zone(zone); + + if (copy_to_user(argp, &z, sizeof(struct blkzone))) + return -EFAULT; + + return 0; +} + +static int blkdev_zone_action_ioctl(struct block_device *bdev, + unsigned cmd, void __user *argp) +{ + unsigned int op; + u64 sector; + + if (get_user(sector, (u64 __user *)argp)) + return -EFAULT; + + switch (cmd) { + case BLKRESETZONE: + op = REQ_OP_ZONE_RESET; + break; + case BLKOPENZONE: + op = REQ_OP_ZONE_OPEN; + break; + case BLKCLOSEZONE: + op = REQ_OP_ZONE_CLOSE; + break; + case BLKFINISHZONE: + op = REQ_OP_ZONE_FINISH; + break; + } + + return blkdev_issue_zone_action(bdev, sector, op, GFP_KERNEL); +} + +/** + * Called from blkdev_ioctl. + */ +int blkdev_zone_ioctl(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) +{ + void __user *argp = (void __user *)arg; + struct request_queue *q; + int ret; + + if (!argp) + return -EINVAL; + + q = bdev_get_queue(bdev); + if (!q) + return -ENXIO; + + if (!blk_queue_zoned(q)) + return -ENOTTY; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + + switch (cmd) { + case BLKREPORTZONE: + ret = blkdev_report_zone_ioctl(bdev, argp); + break; + case BLKUPDATEZONES: + if (!(mode & FMODE_WRITE)) { + ret = -EBADF; + break; + } + ret = blkdev_update_zones(bdev, GFP_KERNEL); + break; + case BLKRESETZONE: + case BLKOPENZONE: + case BLKCLOSEZONE: + case BLKFINISHZONE: + if (!(mode & FMODE_WRITE)) { + ret = -EBADF; + break; + } + ret = blkdev_zone_action_ioctl(bdev, cmd, argp); + break; + default: + ret = -ENOTTY; + break; + } + + return ret; +} diff --git a/block/ioctl.c b/block/ioctl.c index ed2397f..f09679a 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -513,6 +514,13 @@ 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 BLKUPDATEZONES: + case BLKREPORTZONE: + case BLKRESETZONE: + case BLKOPENZONE: + case BLKCLOSEZONE: + case BLKFINISHZONE: + return blkdev_zone_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 a85f95b..0299d41 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -405,9 +405,16 @@ extern int blkdev_reset_zone(struct block_device *, sector_t, gfp_t); extern int blkdev_open_zone(struct block_device *, sector_t, gfp_t); extern int blkdev_close_zone(struct block_device *, sector_t, gfp_t); extern int blkdev_finish_zone(struct block_device *, sector_t, gfp_t); +extern int blkdev_zone_ioctl(struct block_device *, fmode_t, unsigned int, + unsigned long); #else /* CONFIG_BLK_DEV_ZONED */ static inline void blk_init_zones(struct request_queue *q) { }; static inline void blk_drop_zones(struct request_queue *q) { }; +static inline int blkdev_zone_ioctl(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) +{ + return -ENOTTY; +} #endif /* CONFIG_BLK_DEV_ZONED */ struct request_queue { diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index 185f8ea..a2a7522 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -70,6 +70,7 @@ header-y += bfs_fs.h header-y += binfmts.h header-y += blkpg.h header-y += blktrace_api.h +header-y += blkzoned.h header-y += bpf_common.h header-y += bpf.h header-y += bpqether.h diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h new file mode 100644 index 0000000..23a2702 --- /dev/null +++ b/include/uapi/linux/blkzoned.h @@ -0,0 +1,91 @@ +/* + * Zoned block devices handling. + * + * Copyright (C) 2015 Seagate Technology PLC + * + * Written by: Shaun Tancheff + * + * Modified by: Damien Le Moal + * Copyright (C) 2016 Western Digital + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ +#ifndef _UAPI_BLKZONED_H +#define _UAPI_BLKZONED_H + +#include +#include + +/* + * Zone type. + */ +enum blkzone_type { + BLKZONE_TYPE_UNKNOWN, + BLKZONE_TYPE_CONVENTIONAL, + BLKZONE_TYPE_SEQWRITE_REQ, + BLKZONE_TYPE_SEQWRITE_PREF, +}; + +/* + * Zone condition. + */ +enum blkzone_cond { + BLKZONE_COND_NO_WP, + BLKZONE_COND_EMPTY, + BLKZONE_COND_IMP_OPEN, + BLKZONE_COND_EXP_OPEN, + BLKZONE_COND_CLOSED, + BLKZONE_COND_READONLY = 0xd, + BLKZONE_COND_FULL, + BLKZONE_COND_OFFLINE, +}; + +/* + * Zone descriptor for BLKREPORTZONE. + * start, len and wp use the regulare 512 B sector unit, + * regardless of the device logical block size. The overall + * structure size is 64 B to match the ZBC/ZAC defined zone descriptor + * and allow support for future additional zone information. + */ +struct blkzone { + __u64 start; /* Zone start sector */ + __u64 len; /* Zone length in number of sectors */ + __u64 wp; /* Zone write pointer position */ + __u8 type; /* Zone type */ + __u8 cond; /* Zone condition */ + __u8 non_seq; /* Non-sequential write resources active */ + __u8 reset; /* Reset write pointer recommended */ + __u8 reserved[36]; +}; + +/* + * Zone ioctl's: + * + * BLKUPDATEZONES : Force update of all zones information + * BLKREPORTZONE : Get a zone descriptor. Takes a zone descriptor as + * argument. The zone to report is the one + * containing the sector initially specified in the + * descriptor start field. + * BLKRESETZONE : Reset the write pointer of the zone containing the + * specified sector, or of all written zones if the + * sector is ~0ull. + * BLKOPENZONE : Explicitely open the zone containing the + * specified sector, or all possible zones if the + * sector is ~0ull (the drive determines which zone + * to open in this case). + * BLKCLOSEZONE : Close the zone containing the specified sector, or + * all open zones if the sector is ~0ull. + * BLKFINISHZONE : Finish the zone (make it full) containing the + * specified sector, or all open and closed zones if + * the sector is ~0ull. + */ +#define BLKUPDATEZONES _IO(0x12,130) +#define BLKREPORTZONE _IOWR(0x12,131,struct blkzone) +#define BLKRESETZONE _IOW(0x12,132,unsigned long long) +#define BLKOPENZONE _IOW(0x12,133,unsigned long long) +#define BLKCLOSEZONE _IOW(0x12,134,unsigned long long) +#define BLKFINISHZONE _IOW(0x12,135,unsigned long long) + +#endif /* _UAPI_BLKZONED_H */ diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 3b00f7c..1db6d66 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -222,6 +222,7 @@ struct fsxattr { #define BLKSECDISCARD _IO(0x12,125) #define BLKROTATIONAL _IO(0x12,126) #define BLKZEROOUT _IO(0x12,127) +/* A jump here: 130-135 are used for zoned block devices (see uapi/linux/blkzoned.h) */ #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1) /* bmap access */