From patchwork Mon May 1 17:53:11 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: 9706765 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 D5383602B5 for ; Mon, 1 May 2017 17:54:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA54F208C2 for ; Mon, 1 May 2017 17:54:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF06D2808F; Mon, 1 May 2017 17:54:00 +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 44270208C2 for ; Mon, 1 May 2017 17:54:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750738AbdEARx7 (ORCPT ); Mon, 1 May 2017 13:53:59 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:42560 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdEARx6 (ORCPT ); Mon, 1 May 2017 13:53:58 -0400 X-IronPort-AV: E=Sophos;i="5.37,401,1488816000"; d="scan'208";a="14501962" Received: from mail-bl2nam02lp0086.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.86]) by ob1.hgst.iphmx.com with ESMTP; 02 May 2017 01:53:58 +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=yg8Dh5v2ByUMWKsGwqlDQBV23Yo8n6c5Y/5IajTboHE=; b=cqh4oIIROOvDuLeJ6CrUYmtsrRrE3/UgQQivQjGeAySlPutimWNFVeJ3hNUnZeysCz1tfwjDEXewOsM9+dlq1LC7giXJEh7A5xjhv6DBIyzHyhEzMt0vfhpMVGUpbJAdersRbmMjJJZ8iK14bBnKrNhqgRMr15CLVG3+XQEx1V4= 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 BL2PR04MB1971.namprd04.prod.outlook.com (10.167.97.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Mon, 1 May 2017 17:53:52 +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 v2 07/10] dm-flakey: Add support for zoned block devices Date: Tue, 2 May 2017 02:53:11 +0900 Message-Id: <20170501175314.10922-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170501175314.10922-1-damien.lemoal@wdc.com> References: <20170501175314.10922-1-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BN6PR1301CA0002.namprd13.prod.outlook.com (10.174.84.143) To BL2PR04MB1971.namprd04.prod.outlook.com (10.167.97.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0476e2f3-798c-440d-d951-08d490bb0900 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BL2PR04MB1971; X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 3:6o+wDm51p7iqV94N3OixA/lCvcFo/dG/evi+mlRFTqz6OZsvJq9aPjyxDd8oCBTTImX688DawPSgVKpFp/ENiFjErVzJykqT9doVow49V00PrGifLfbqDvaK1lPhhzP07k5L9W0d2kVcifaNLPAp37jynfX1tzCZHxSfGiagJc/XQn9JX/QDoMVIOsGM3nehcq+pGWre/NmsifX4VWhryEb8aVWMfg8ckBWZWOfxwUJ2kqkgLXgGA+HiDVUiP3ePwwyYo5SsRh+eVf5M+boqOa07xUFCfMNVt2z9bqmY2LD2BHW7LfrhxWON86j/kEQG8yhJw0ZELZY0IShhiQkwNAhUHQ6VdKuYxP7uyinnYU8=; 25:EvO0NS6jfQmJ37Il2gAEBQF8fikpo7bxRRO7OW7u2SIbQQIZU7oCPRIsEN3xz104vVX0jdrRuwr+6JrctNNeK1yUUWddLWkYsL3ZRrDfjyiUXRhYFcr2y4p+sQreKyREdmwIg14BuzzJFeBh+5P2cGICe8MvB49qeP6l8pvbrT8io1jQ70ZEJh8eiZSgx7dZ/kjYFA3AMKqe3ZYDfp/TEwFzwweYemOJO3f9dTgp4ZYVcZNs2qZUYaKt06mFK/k64JMOP/wDgOBAlVx4n7W8p04GBu2iIgXI2ZFCiek05TLEl/Lzr7HqxAFal3548cw+pCf8Asi9vF1qk7o3MnCqyLZZnWLKwLv8bLd05UpTgyzsCdyXpLWRbJVEO+i+ea8vErYEHUtDkcpvtawNscV0hkSF+iCjchv3vH41ittYpBdc83inkoBOveqG4Vm+VqxndwYlIuYvOHaS1fAygXQPQQ== X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 31:u1QMWcFRfDYSPT9ShzeDUNXJxThbTe/CkU3+KOWbLmUP36PONpEOB9eYj8VTA6lF2KjI0204pD7bkf2L/Mqur76gRGkvj0v781oYvfhR9rwQdCUWIP3KKrgVxWT3O22n9INxYZ/i4pbddQMRxEjPx1stejkBGKmgOKYZj3z+TYnzjIYq1tC76JZfDcoylD0tcuL1F1GYAiHwTU3O417xhkXum4Ex03FZn2c3pM8/zAOL/Qq070OHch5oKUWDuSjn; 20:ftxCTXxIHYIefJF5NFTA0bYYUGVvecmBxGtKSbuK3aSjhdGBKxvXgpdOv1sXfU09fZ/d20GygtGYKQ5a5eV1BMMJHkI3szfaIC/KVhlF8WnA0iEDoQ5ZPgvAVWniUb4V6+HvtRcbADnflyVUCzbIaQ8c4+yc59PHcF3CxZfImVR8LoykMpyYbS6wbeI7q9NgFJCiz8wp/+AkIx+xwjTFNPpwNrkibHRLWZDwOES2Wmpv4Sw0mKQq6WthH+yq+/m5EOxXKcq/LwMxn8xEwulzvxSOFno/THRR+w0SgPrcTnrxQOpq7WyMkR+c6XdLkwF2LkVs9EbpdACrJSavg1PBx19z2ln+74bu9uCYZs+ovp4lqar+skn+kphOLAzBln5b+x8eYHtafAX+9zzxSYvKtkJMgR5UyztmAOrVVdWRt3rKNJ9daNT8dLsjVEhFYsNH5QuyNVzgjtbsER8IYppl65zXBH/3gpqr653SxyZqtpSSMqXSyzZ5yKJyZ5M9vJgb 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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(6072148); SRVR:BL2PR04MB1971; BCL:0; PCL:0; RULEID:; SRVR:BL2PR04MB1971; X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 4:ddwh9Z3OdKaNGos8CyXIeEuq9S3I+DobkyZDFH7ubqc317yLZlRY533k7UgNvbyhqNJ5q9yJte5IRibum1HmSRfh+ujTnpVemO+RU+r33q/Qvk3Hf907jHfF3XYOCU82hq0SjwtnCrAfHFp/aZQuMtTHvG/7sBcv0IgPptpCh0B/ySiRFLVER9NPxqF6n88ouGbzZNjuRbWxaiDgNN83JuSRvIhN7GGrgjCt0DwNusieA7zIZleuwL/XjTeHIDZGsmUMDFFHs2dSJ3oGzqUl/Vx78Fgxcw2YZ61gPknL4zrF+5ffi11CinL7FilGQsxJMUPgZvkjFj//cVdFQZIHfjr2fuN/rBe/wAixDq4JliBolFzAy0Q9BW3SoSDCHMfbgS2bCCEerPZo9ugKQCuCrEUpyIXl5T/Vj0MNtY0wfXagDtOt+5ifkAOmALd6iRvQDPD33ZkiWwuEs70oJfmb44iMCWR5lLzSX0ciaO1hoUWTehjmp7lDIpNbvE2BKn2IuOzhO1hT51JGLDHQPrGYG8ArX/H+ETsSI74hBIL45ZoSKPHVBmdcbEd28oTpQQGYei9iNQ7mt77rbnVPXcHgmGnY0vkSc0e2Ewyq+9NX6g0VMZNYCUc2RzQ0ZsNxF7vxSpo3l1ZUZrPozPwO+Fwe/8fL4t1bKOWfcoExAOkC3JbLYx3aofiNkxEiR95Yxcr8xgs5U+/TwlP9FpjPSELa+Zp/9jQ9wL9RoJBXKF9xWe4= X-Forefront-PRVS: 02945962BD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39450400003)(39840400002)(39860400002)(39400400002)(39410400002)(39850400002)(2950100002)(47776003)(50226002)(85782001)(25786009)(42186005)(7736002)(5660300001)(6636002)(305945005)(81166006)(6116002)(3846002)(8676002)(33646002)(54906002)(6666003)(53936002)(6486002)(9686003)(189998001)(6512007)(86362001)(1076002)(50466002)(2906002)(38730400002)(48376002)(4326008)(36756003)(76176999)(508600001)(50986999)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR04MB1971; H:washi.fujisawa.hgst.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR04MB1971; 23:gy/2gD1iZx+I+gplyNMJ7wkz/Aa2H+MJBDT76ybEl?= =?us-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agnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 7:tC+V1m1JF2Hbzb6NrgRpeWhdrcBqOspr1rFe09j95+AQ96Fn7MC+Df5cpCja1FGRWJXQn7As43k8Kb4V8+0JOovm264Mm8linebphFYME1e6VFZJFM+l0G0HoUlJJVw4Nsnh2hhBka74DOTDiHdcuLOBxOAIHUeRcDL1tajSnDHgbCbllRMLgeiQKv2JdMVcpXmAEX1E2ZEwBxavZs1zqi7x/Oe1gk0VRxCLf8ZgGQ8BGEgHYMSKhTW9dU087g79htWt6wDTFVc46EBTBnwGTcy/PFa4YcbAsrF4axt/NzSyEK17aFYYd21KUS2tTTnf7aQL5JHSeQpeuktNnfuS4Q==; 20:OHqUh2PkHWOKsjFVcvYlENE0MVIPaefRjTM/CyNb94G4u10f8SBqiHchCrXDK/v1ApQhN1K9NsAkz6fLWGBxg+JefbYWC1cLnvDJBamXWKJrM5PI0K9ZWFB3GysmYif3k96mSeub0xlM4uei6ZOnUofbH46iisyu56HTAVILYsg= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2017 17:53:52.9540 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR04MB1971 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 Reviewed-by: Hannes Reinecke --- 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,