From patchwork Fri Apr 21 03:55:55 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: 9691725 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 BCE556038E for ; Fri, 21 Apr 2017 03:56:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B037428334 for ; Fri, 21 Apr 2017 03:56:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5203285E4; Fri, 21 Apr 2017 03:56:38 +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 3BB69284CF for ; Fri, 21 Apr 2017 03:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035037AbdDUD4h (ORCPT ); Thu, 20 Apr 2017 23:56:37 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:22545 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1035033AbdDUD4e (ORCPT ); Thu, 20 Apr 2017 23:56:34 -0400 X-IronPort-AV: E=Sophos;i="5.37,228,1488816000"; d="scan'208";a="12700255" Received: from mail-bl2nam02lp0085.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.85]) by ob1.hgst.iphmx.com with ESMTP; 21 Apr 2017 11:56:34 +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=JrzN3i95+o/OMvHvPfanhb3PeGOjVX8bRY+UfX79nCQ=; b=Nx+JqGwZL9oSrX2xGOfWku+NsEun/uyQ30dUN31mhotH/f5gWQeGrRVYqZYcKZ43ogIzimAPgT23vs/YHhpDvZNegjT7vQSYb7p/rONcGD8JrQ9eVln81OvTQ4fkM2rSGLDyM6p+CfBQYlN0FVu1SAjd8+jv0cUrtql6pPVvGRk= 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:29 +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 07/10] dm-flakey: Add support for zoned block devices Date: Fri, 21 Apr 2017 12:55:55 +0900 Message-Id: <20170421035558.2657-8-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: ce8ee9e8-8d99-4c3a-c3d6-08d4886a654d 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:hJeEJiR2r7kcu641F+AItYyj6k446DDpooplzQqdnfpt9WR9MNrBAqxGoyXZCFyVv4+linagaHFF2N0YMdCxQOpGkTadt9GNmGFuOWwEHG1cnqYb9ofQijqEn0uDgeEtX5p3ChZlM/1mp+yPNBJGVRkAct7oxjdI9c6Cocwea9Cni0RJaxCGrkmGjtOSfK1mvM7pDxg28dWlKWjI+kIVXE6KX4rgjZhPM/XuT9/Q16UMbXyhhR+Ug8B+g5zeZ4yViPJtgZueizgz+uTDRoQIrgeMo+E5mb/Ld5yQIroS3F7tSrEtrRxqvNSt6tbG9nG2igkCKHvu2RPOujed34IxdmywtnJexswmxec8POjCbwU=; 25:dvx2amvTGYlpEqu0HxW2GQTT05UB3KeWBND3o6BwdNVjJ7AOt+6W7GE9/N/wSTtbTd4AJZqqLoD7qwxPhF9X14bAlEuVIXbe/fFGLMfc0Pqnwfxh2WPlb1Q4Vk7ELc529OLO7gydkDoDdKRubtnzSUEeDYBn7ZEiGWRghr9VEjn2MVsJWreMte2PmqZhyIdpOJtxTykQ26lruHkE7ZpK++gx+qMvvLqF1v/BFbEAqi8gqOwf/VV3rHHwk4NIi+WnyEDYS0HW1hAP1+4i4S3YoLGF0JiKDmxsD1oBPMk3cjx41grdlf2ZHNPe2K/0S0m3EZAmGi8Zp5u6dZ3Hcjmj5doXKvZnHmVyUf3dwEuQViEQPZUTakMcL+upXLv1y05qdD6RbGkHc3ntB+/7fBWhL0E91mB0rq3I/OjHoX8x1wXcI561wHPnsHzS397dVE+WkgJU+EwTG96/IaMVDFahHg== X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 31:H06p/ol09lR6o+Jv7J0N9z+EPeWYL1JLM10xhiXtC+6V+vDR8jFL1+Cl62L5/D0SFYC3AysJK6HAfC5YS4OfnsBE51FvpTafvBWsdm7IBc+C4XPBVO3KOBRZzpi8L2mNCBNikdaffPOh5mkT/ROSRa3m8YumpPajlB4/LFIpDFJYVlXX9nqr4Bv6epfMFUclZxcCgOHZScrruywlNa8Rp9YYVwu1rjPB4myebsOwu70FGZ+Y7pJl1yjaJlWBrrOy; 20:gPfe9JZ6V0M1g0q0y+Sf8sRIBuK9XFO5oFsyR2w/UAhIs7FWTAq3vWDW4Uq/rPnDeX0ki1fAm1y4J11wRZhFIZ4NRWBHoxcKV3BJgA2licUFCFcdps3vkEtVCOXVkX5t9Jlgto8pa19FtWOfppRJ74mSxsmmWbCkZFPrCC1uC3wo5IxIyLLj7dAwmtRE/fJWu8FnlRB4WJD3CLWHIg6XA3rMK+Ot9pMiHySdGgy7cEU6u917+zcbI2ambYvE43iuH0HjqjNMcoDJEFrVjAZz7NpOdlAHp31dT26vt/lJyN//IbxXter3xeKbxFj4GDAury8249Qa9hiXqXylvpro4Wmesuoq8vOQbGfG+mZij0GrWC2dSrhRr8rf1h1ZZeW888JzLZOTwsBMeSPF5qFYIDYjx+64kdJCMpklwLXfANjlmKwykWgodp6nxhz1GKQp7muzc04JpV5VlmF7l+8ElxRgWoEJXU4+gqKI810mhz9u8eoexzLBYN+r7LQWYtot 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:RyXtw5EU2vn/P3YVvvPZCVtLwazPKtFXtyedw3iW+d9WztjUPLEt+d9TJi8JYPv0fSnrvoqqVpYX7+wiP5IL51fuAuQcRX0VvvxabYa1KOHvhRe9Ow5HJG3v8WOxHYIsQZCJa4w3o34Yo8+BWrCh+KMjb7DnQDa81ej2B63YxfGYLAXz2x8Lo0ulvNbqQx6eTOv8ao/I9IWrZALB9syo8qhLaqKQX98mNagLb2dtIJcK3NAVX2tWsnYhINsvcgJ3dFSU73cM/KSRA6k17Eii4TxRfO32l41cMXem9c6RJ505vSdiUzMjLuZb/9yPWuL6dJla/W12GlCLbIeiGUBBT4xRpN/quXBFKU7qtxrcGYsj9+g4fyqJfsBCR8jhSBWq5B1ija93k3bP8aS3X2FcXxOH7AtxmXMDF5uXr932qDHJRUCYUCPY6JShdHKOvk8twyqcXo/otNrrhyekLtystRfYQzDdLr5xrU+AId6J9LcvFKJX7YdYCjhMgfQh7dxckwsAVlKrapM5RVq9Wx6YWtclejdshwt3BvCU9e3zY+bs+f7NVIM67I81qKI1jWa0xLxLYlZIdtjvl0nfRC1cCxXVpHk1YNaWzfiABsEoHm2/xL+YyjKfhnBzSUgl6HsrCCvmKuu363I5Z1DIGLgK1qh8/8+sipR2UeWdfos39VmyOhB5tzfzpnK8pcCB1FAB+D7M3ABUY3OKV7TBKhSwb7z4HvCYX1NCcgAzP6Kbb+E= 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:opAyuT8IRQwllVS2QnIvhnI6jbJPw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pq6vF5Y4lKSq6GRRKq5d6k7cA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 7:ZVQGynZRUieNUu7JYuq9LildUvVy8Q10GT+z1UF9GNCpHOexbbhsa18LQ9mXUM1Ds496yvMpH4CY6+Zfk8PBFpNBbjyyuYlXP8Ox2vpCfJPuIFDagN40JW0pmU5lu9p7FF0S33buvVQEhJKmqKN0kxuLLDQONCS4j8R3hOo3NHYV/Oo3T67fuzog6YV0ULT7zFrg8rAmwNi3mWQz+8RuYBtt6kcRGl1QFvVUe8zZJThhIyAoM+oGhlZOkoewlksiRQBDa9mbfkPiN/OWWyiZlbST9RNJw212m155RhnZBFPAxUBHFXpPtH7BhjkFO4RJVKAjrKprgCd+0FdbWVeHiA==; 20:w9K2UgkXNbGGC/KjNSIOswAaC8qWwjSNU7qax7FppyIfu9OjWV8O8UK+1UAWi5aiDEPxk2bR4Ev0UT6VKP4cY60k0EUNBTGmm5gRLg87biDqlxuTMqe4XPQ/Ln5nt4HQJcsxVTGqj2oFu5SVHBYx9awVHMO3I3uy2lFAVxUAGFY= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 03:56:29.4022 (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 With the development of file system support for zoned block devices (e.g. f2fs), having dm-flakey support for these devices is interesting to improve testing. This patch adds support for zoned block devices in dm-flakey, both host-aware and host-managed. The target type feature is set to DM_TARGET_ZONED_HM indicate support for host-managed models. The remaining of the support adds hooks for remapping of REQ_OP_ZONE_RESET and REQ_OP_ZONE_REPORT bios. Additionally, in the bio completion path, (backward) remapping of a zone report reply is also added. Signed-off-by: Damien Le Moal --- drivers/md/dm-flakey.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index 13305a1..b419c85 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c @@ -251,6 +251,8 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) return 0; bad: + if (fc->dev) + dm_put_device(ti, fc->dev); kfree(fc); return r; } @@ -275,7 +277,7 @@ static void flakey_map_bio(struct dm_target *ti, struct bio *bio) struct flakey_c *fc = ti->private; bio->bi_bdev = fc->dev->bdev; - if (bio_sectors(bio)) + if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET) bio->bi_iter.bi_sector = flakey_map_sector(ti, bio->bi_iter.bi_sector); } @@ -306,6 +308,14 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); pb->bio_submitted = false; + /* Do not fail reset zone */ + if (bio_op(bio) == REQ_OP_ZONE_RESET) + goto map_bio; + + /* We need to remap reported zones, so remember the BIO iter */ + if (bio_op(bio) == REQ_OP_ZONE_REPORT) + goto map_bio; + /* Are we alive ? */ elapsed = (jiffies - fc->start_time) / HZ; if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { @@ -363,6 +373,14 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) struct flakey_c *fc = ti->private; struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); + if (bio_op(bio) == REQ_OP_ZONE_RESET) + return error; + + if (bio_op(bio) == REQ_OP_ZONE_REPORT) { + dm_remap_zone_report(ti, bio, fc->start); + return error; + } + if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && all_corrupt_bio_flags_match(bio, fc)) { @@ -446,6 +464,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_ static struct target_type flakey_target = { .name = "flakey", .version = {1, 4, 0}, + .features = DM_TARGET_ZONED_HM, .module = THIS_MODULE, .ctr = flakey_ctr, .dtr = flakey_dtr,