From patchwork Tue Sep 20 20:47:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9342391 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 A3D50607D0 for ; Tue, 20 Sep 2016 20:47:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 948C22989F for ; Tue, 20 Sep 2016 20:47:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 893D729970; Tue, 20 Sep 2016 20:47:58 +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=-1.1 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RDNS_NONE autolearn=no version=3.3.1 Received: from ml01.01.org (unknown [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79F142989F for ; Tue, 20 Sep 2016 20:47:57 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B683A1A1DF4; Tue, 20 Sep 2016 13:47:36 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ADAFB1A1DF4 for ; Tue, 20 Sep 2016 13:47:35 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 20 Sep 2016 13:47:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,370,1470726000"; d="scan'208";a="171147845" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by fmsmga004.fm.intel.com with ESMTP; 20 Sep 2016 13:47:34 -0700 Subject: [PATCH] dm flakey: add DAX support From: Dave Jiang To: snitzer@redhat.com, agk@redhat.com Date: Tue, 20 Sep 2016 13:47:34 -0700 Message-ID: <147440445480.62486.9559239844115396323.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dm-devel@redhat.com, fstests@vger.kernel.org, linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Change dm-flakey to implement direct_access function, flakey_direct_access(), which maps sector and calls direct_access function of its physical target device. This pretty much is a copy from DM Linear. This allows fs with DAX to pass in xfstests. It does not actually introduce data corruption and dropping writes unlike the non-DAX path. The main reason is due to the I/O path being out of dmflakey's control once direct_access() has been called. The the existing implementation cannot be adapted to DAX I/O path. The error injection will be introduced at a later date with more thought. Signed-off-by: Dave Jiang --- 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 6a2e8dd..cf182a7 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c @@ -408,9 +408,27 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_ return fn(ti, fc->dev, fc->start, ti->len, data); } +static long flakey_direct_access(struct dm_target *ti, sector_t sector, + void **kaddr, pfn_t *pfn, long size) +{ + struct flakey_c *fc = ti->private; + struct block_device *bdev = fc->dev->bdev; + struct blk_dax_ctl dax = { + .sector = flakey_map_sector(ti, sector), + .size = size, + }; + long ret; + + ret = bdev_direct_access(bdev, &dax); + *kaddr = dax.addr; + *pfn = dax.pfn; + + return ret; +} + static struct target_type flakey_target = { .name = "flakey", - .version = {1, 3, 1}, + .version = {1, 4, 0}, .module = THIS_MODULE, .ctr = flakey_ctr, .dtr = flakey_dtr, @@ -419,6 +437,7 @@ static struct target_type flakey_target = { .status = flakey_status, .prepare_ioctl = flakey_prepare_ioctl, .iterate_devices = flakey_iterate_devices, + .direct_access = flakey_direct_access, }; static int __init dm_flakey_init(void)