From patchwork Fri Apr 21 03:55:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9691735 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 9FD726037F for ; Fri, 21 Apr 2017 03:56:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93A8428334 for ; Fri, 21 Apr 2017 03:56:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8893C285E4; Fri, 21 Apr 2017 03:56: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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 1C7BF28334 for ; Fri, 21 Apr 2017 03:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035016AbdDUD41 (ORCPT ); Thu, 20 Apr 2017 23:56:27 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:47185 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034983AbdDUD4V (ORCPT ); Thu, 20 Apr 2017 23:56:21 -0400 X-IronPort-AV: E=Sophos;i="5.37,228,1488816000"; d="scan'208";a="12700127" Received: from mail-bl2nam02lp0088.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.88]) by ob1.hgst.iphmx.com with ESMTP; 21 Apr 2017 11:56:19 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=mC9iAfRnaaqFh86yttrEmkw2cnFGrm2wHTBJsDV+gtY=; b=D9Uem7n+CbK4XpchAftsDXUZLQDnlBcbQ9yW7uf1Xy06wZgCTwS9EreIEvMsZOrwqUjPfWjckYVmSCPaNviYsZKJrAoPDxB6xGnQKIyEQJd+zknG0I3BJKSg9Ci5TmkDyUbB4LGwfk6GI3f58Vzuc9lqIT9d/OMqZUdnJblZMOs= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=wdc.com; Received: from washi.fujisawa.hgst.com (199.255.44.173) by SN1PR04MB1983.namprd04.prod.outlook.com (10.166.69.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Fri, 21 Apr 2017 03:56:15 +0000 From: damien.lemoal@wdc.com To: dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon Cc: Hannes Reinecke , Christoph Hellwig , Bart Van Assche , linux-block@vger.kernel.org, Damien Le Moal Subject: [PATCH 01/10] dm-table: Introduce DM_TARGET_ZONED_HM feature Date: Fri, 21 Apr 2017 12:55:49 +0900 Message-Id: <20170421035558.2657-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421035558.2657-1-damien.lemoal@wdc.com> References: <20170421035558.2657-1-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: MWHPR10CA0052.namprd10.prod.outlook.com (10.169.238.14) To SN1PR04MB1983.namprd04.prod.outlook.com (10.166.69.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f574eda8-6809-45fd-ee19-08d4886a5cf5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SN1PR04MB1983; X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 3:8Z9+yxhZc9Gvu8ch+1a9WtoY0j4tAQrdygoAHdAbHyQq7m7750aFd1nj4YmW3ZZCu6UlF/BVDH5WngRPp9bOevep0TNeJZ/bwlVuhTgmqBIES2Diip221cYD0nv89fu3YtIe5ZnNQb7nYX3bkvWPM5C4L9qAyuNlR/CxNQ4zhEHF0ENfRXYCQxXGIJA9/sMuiBZZNpXUgRAkNrMj8mDWSPBU5tYtrobHbAJ8qMD8EMrkWpgs8M15Wm1I6RCJNDAl4qefYi/R4DbGFkQ7Iep0x/+8+nDbVXq1e2gT7dnef5YLPygv9KWz2fUtVe2yH91GnS5tBAzE8CtOnmZpLLBoivf7uO42vPfTiuCRakyNBnA=; 25:39lK871RbXJovr63MPEB+V6SpV3iGjHNOEqRfGMEJfFAgHJzX6H8npeP5cdR8R0hbU2Ufw4yUxVO2724aPDXsqiYKbz7qc0P5QOSweepLk/SzpmRdADRCYh4MUQDK16HCwO+pJ64l2HjRINkLrBoyBtM0qEuwoPb9mf2qb6Y/uZgnA6+PvCfczOVS3Si4AEV8PoTkmSk82MoqkLrIS7juV/KGMYG7c3VYEDBqSjMRJHNDR50yLFtFb3dDcBbpiOhQN1RHO+viA5BGUgVoy3ShBtnPSSF5s7ZKpHgGh3yr/FYrhlmATI03BvMp3CTL0Zfh81bNo7PkN5dCvjck9z+SWmEoS2BDPW6eHllp15VI/YICTAvzN3zkDfp2w2hGAs79KHiaLnOBfUFH3qtDUgWOHsj2eiiporgagNhNMvdvG1OInX36u4UaCYV1a38D1/cK8mdHtT1ZwTcdqQWFJoRKA== X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 31:TjGnKRP3ySuPMFtRHxdAOWRn+O8uCmkO14rw7NOCALHUD/JOFvX5NF2M5WK5YSBwzkbmAjeh+xfST6Ys5bazvzoYnsiUUH9SeNxANyi2tjNG1z0gkIe0cKhMzPOtXGk6he2CkORHxoFGcztN9rfClPCl91f1Z8DHsi4VIfn1FE6HV3GNcsURlcNniTa7rriZ3xhMCu69/4MyB4Bo0rBGREqhaMQeuaIlOLgQJvsoMxE=; 20:1w01+ep5YyODnEGbt2BYCcQG5L4hCsGtnYSCThy9k5UhSSCu4Hz0W/I9wYUvgUZojXDMV2ZTKeQGVvpS5p2pXfGgbCP+BUN1fp9TlgePjdTM3MeJ66F6Y2kNEMq2qhSCojDARWtNrnvvAcVrpAbgxjHSQcwqVoSGV6FaKCW28QO2V9y+LAWtgo8J40uvkZz006B5tmtTPCXAs9iAzQ0U3FGeQ00S5yvwdv2F4sLuPf8Bf42pe+Tcc6CJvgC17Oc1eFmyveNQDHJXypCKuP5UEPielTzLNy5rUg35GzUS79y/Z6aLjpi2qQIPEkcENUfePDlAD2tFuyUFIkt80uPEKlbLHmzLytKyuEiy0u/2d0TSJT+1ZIcCl7S09WuJWHpAoZq8uwOk9iCCGEhMwWDSzmAO0/rpHkhB79zanouTxf6QfbUkbUnCqdelvLG3y2tQLWqZyMfpzFeWZkT/86Wi6x2K+23ese2GSahKT3KFTxPGaYuhfkVXrb2wgetXN61O WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(6072148); SRVR:SN1PR04MB1983; BCL:0; PCL:0; RULEID:; SRVR:SN1PR04MB1983; X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 4:kbP8j9l6F5GZ+jNkLtAV31SXvRiqQHCLTNB8YeSFbqG8Kol2D7LbIfNFvrbPZ41h7nD64GN4UHeaQ1jyBpTwq5v0XS6U8yZuC+P9ogI+c5nEX3M9pLtLKLqXg8N6Elg49lZGh+nREv3I4uad6a9sxXCk4AdJRCfVwd/7RYv9xa/IKYI97GBj+YT4GOIB/LCWhJl76wOWHA6W2gwlJjLT57CSvAv+o5XuZvQaX0A2MzhWB3gPsgwQlonbobEovWF2ot6JmlwDAEeXcQdiyhkMOIC1V6DY6dFSHcD+u1OeQQczY8cuep282c2G3OgIyyiPKd7a5NFN9G9zvbVIQ5fjB3PrGjyR82cY+a5QeIN8DhX7Vd4vNZGi935UvfTzRzd0vuay8Vb+x+pxmkIrN1z5xg+vgn1r3Y9chtuzDYrPXKJ+eQZf+5v6GN6XUGnB2eGGOnc0FGh53sv0/zy2fJYJ7aAh+BnX7l0IdhSKeQm8l3xasAqUDMcWBLKyEAochC1MN6fNEb23cukK5F1OgFBBptylBbHyB44EYN3BD2OCmDz6WxkFQ9IsmIJkvt+8q6LGMCmIWhHYU4bQCwA1R5nHZCTrlrvAKOcxaPtfhOTJu3pS4SYvAcqmWDv8W40qjxKgFhnY2nGD4TheoMCzEHXNKOEeKGcEnm6iMqpqaABhrVPSLKDUevaCFnIWceQ52/Ea3avMqA4KywFOVRnd6SwNuUwy70bmRp5N0UeCM15vZNQ= X-Forefront-PRVS: 02843AA9E0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(39410400002)(8676002)(5003940100001)(50466002)(48376002)(3846002)(2906002)(38730400002)(6116002)(36756003)(86362001)(4326008)(50226002)(1076002)(6636002)(2950100002)(6666003)(6486002)(305945005)(6512007)(53936002)(47776003)(66066001)(50986999)(54906002)(189998001)(5660300001)(76176999)(85782001)(7736002)(9686003)(33646002)(25786009)(42186005)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:SN1PR04MB1983; H:washi.fujisawa.hgst.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR04MB1983; 23:NevcAUXGsV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TyvdPx0LyhR+T20nELXoo7v3Z7nU02R2cNcg6iU85H0azDS5uGoKI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 7:LeDeSnRz/OFi0gV2z421PdfO7+ApXBq7Aul7/Q/Wim8lAAd9HieXfGZBxiVMySyAiUkxt3YJbNVnQvU1EM61mu2Vy6ChFDRhw8hDNPLeMlRgV8cBuh0NfbMz9vdf+905IuJ9INkAWLixbXQz5SsK5ZYPnLwY6y0d66sV1TC7D/H+fHPJw1u5ntlcVKoJI9LqBizWtUM7m1XYvrQZ8wM1n7MLZ5g+Z0dLdSAMGiaMQje/POsCcJ/Nb1yMmHsGGLxWO8cmiMUmaIi2hojdh2FJSRTOubArhAHAF03n1jlgpuVxWW4WsX+myPleD7dbwNX9tQwFYCZxC+br76NoLFOyRQ==; 20:QmaLOOkEYxxHO18+aaQfy39MaRrPQHtZCSnkzoJhEQeZSsaKJCx02RRZM5kFe0sNw9GD/ilqw3lxrJQUS9TY92PPVIzdc7L2qolhSy0udaHGHUjmErkgt2boGvDiM8fBdOucqiy1v2WH5i36cXCxOtgwDO2yIkok2UcgsbLVe2s= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 03:56:15.3868 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR04MB1983 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: Damien Le Moal The target drivers currently available will not operate correctly if a table target maps onto a host-managed zoned block device. To avoid problems, this patch introduces the new feature flag DM_TARGET_ZONED_HM for a target driver to explicitly state that it supports host-managed zoned block devices. This feature is checked in dm_get_device() to prevent the addition to a table of a target mapping to a host-managed zoned block device if the target type does not have the feature enabled. Note that as host-aware zoned block devices are backward compatible with regular block devices, they can be used by any of the current target types. This new feature is thus restricted to host-managed zoned block devices. Signed-off-by: Damien Le Moal --- drivers/md/dm-table.c | 23 +++++++++++++++++++++++ include/linux/device-mapper.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 3ad16d9..06d3b7b 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -388,6 +388,24 @@ dev_t dm_get_dev_t(const char *path) EXPORT_SYMBOL_GPL(dm_get_dev_t); /* + * Check if the target supports supports host-managed zoned block devices. + */ +static bool device_supported(struct dm_target *ti, struct dm_dev *dev) +{ + struct block_device *bdev = dev->bdev; + char b[BDEVNAME_SIZE]; + + if (bdev_zoned_model(bdev) == BLK_ZONED_HM && + !dm_target_zoned_hm(ti->type)) { + DMWARN("%s: Unsupported host-managed zoned block device %s", + dm_device_name(ti->table->md), bdevname(bdev, b)); + return false; + } + + return true; +} + +/* * Add a device to the list, or just increment the usage count if * it's already present. */ @@ -426,6 +444,11 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, } atomic_inc(&dd->count); + if (!device_supported(ti, dd->dm_dev)) { + dm_put_device(ti, dd->dm_dev); + return -ENOTSUPP; + } + *result = dd->dm_dev; return 0; } diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index a7e6903..b3c2408 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -214,6 +214,12 @@ struct target_type { #define dm_target_is_wildcard(type) ((type)->features & DM_TARGET_WILDCARD) /* + * Indicates that a target supports host-managed zoned block devices. + */ +#define DM_TARGET_ZONED_HM 0x00000010 +#define dm_target_zoned_hm(type) ((type)->features & DM_TARGET_ZONED_HM) + +/* * Some targets need to be sent the same WRITE bio severals times so * that they can send copies of it to different devices. This function * examines any supplied bio and returns the number of copies of it the