Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5483462imm; Tue, 26 Jun 2018 12:03:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI7Cx267H5oZMAOpXe59t71TTcsBiaRbCUTUwI6UcSTUSI2P86lsAS6IoQq5352uw3ZxUxf X-Received: by 2002:a17:902:57c3:: with SMTP id g3-v6mr2866280plj.116.1530039788745; Tue, 26 Jun 2018 12:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530039788; cv=none; d=google.com; s=arc-20160816; b=Plcwj+YW87A08pxTOqUDCq2GjEbpqOZft/XHzUubLdjkSTu8FyDug40BH+A8z62uC4 +0XBHLNNCt9Q1eBrlfEUb4uC8f2dhMkly2KOPDOtezA+RaTt9muWxASpyiUHdYc0qzWN oDDAAYwVLX7pN2WQUQeSNlZImLupiKm11uiQFa8KjqvF2HlYOWCWLbb+5/npLgoz197Q uR9Hnjrn72IOvVmvZStYB4SBm1Tsyk1sLdRLI727RIibZ/zLbxjiNRFQdm68gC2D7fCV k7mOOicSwzcG3nBTtJP3UeRE1By0HmbGfPXxCirXEEFH0cr/MM83b3c0A3hDrlq9DhuY oyeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=obxmLO+N/PoM6UdDJr3SgVv3YOnrDK3rvJK1DzVZ1Wc=; b=DQX7Z2WEc033pxMBf1Qrl/mCuKyeqc5+i/NUJBt9IMTTaj4QO55ytM68sXpQnTNK7w h8ZN9qngYznWAx6A8BtNI9qbsnhV3rhFwSa+MvbcR18nvf92mcdNqnGunxFRMk/qkg4m YJEia7LjgN5JWVpUewciXQW75Stg0vg85tTX2T9kbRuUgyvkrIjb4YUo1rUesDbyUMbZ Dc/EwiHn6QudOdV8QOABe5MN+62C/jI2cZ1C5AxHCbRWNlf+Gy6RwuWgemxGIV8awN2e 3uf7NlinEKG9Bn4hutVYCUNc+HY9Rfy8xWNYQkU3S4VfR6KyOp4zPTopybjQDSydiA1f rrnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si2060767plo.61.2018.06.26.12.02.53; Tue, 26 Jun 2018 12:03:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754886AbeFZSAI (ORCPT + 99 others); Tue, 26 Jun 2018 14:00:08 -0400 Received: from mga07.intel.com ([134.134.136.100]:23715 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754820AbeFZR7g (ORCPT ); Tue, 26 Jun 2018 13:59:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 10:59:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,275,1526367600"; d="scan'208";a="50086624" Received: from theros.lm.intel.com ([10.232.112.164]) by fmsmga007.fm.intel.com with ESMTP; 26 Jun 2018 10:59:35 -0700 From: Ross Zwisler To: Toshi Kani , Mike Snitzer , dm-devel@redhat.com Cc: Ross Zwisler , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v3 3/3] dm: prevent DAX mounts if not supported Date: Tue, 26 Jun 2018 11:59:32 -0600 Message-Id: <20180626175932.8899-4-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180626175932.8899-1-ross.zwisler@linux.intel.com> References: <20180626175932.8899-1-ross.zwisler@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently device_supports_dax() just checks to see if the QUEUE_FLAG_DAX flag is set on the device's request queue to decide whether or not the device supports filesystem DAX. Really we should be using bdev_dax_supported() like filesystems do at mount time. This performs other tests like checking to make sure the dax_direct_access() path works. Conditionally set QUEUE_FLAG_DAX on the DM device's request queue based on whether all underlying devices support DAX. Now that bdev_dax_supported() explicitly checks for this flag, this will ensure that filesystems built upon DM devices will only be able to mount with DAX if all underlying devices also support DAX. Signed-off-by: Ross Zwisler Fixes: commit 545ed20e6df6 ("dm: add infrastructure for DAX support") Cc: stable@vger.kernel.org --- drivers/md/dm-ioctl.c | 5 +++++ drivers/md/dm-table.c | 7 +++---- drivers/md/dm.c | 3 +-- include/linux/device-mapper.h | 5 +++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b810ea77e6b1..0055bdbee5b1 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1350,6 +1350,11 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si goto err_unlock_md_type; } + if (dm_table_supports_dax(t)) + blk_queue_flag_set(QUEUE_FLAG_DAX, md->queue); + else + blk_queue_flag_clear(QUEUE_FLAG_DAX, md->queue); + dm_unlock_md_type(md); /* stage inactive table */ diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 938766794c2e..c673b4a51fb2 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -885,12 +885,10 @@ EXPORT_SYMBOL_GPL(dm_table_set_type); static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { - struct request_queue *q = bdev_get_queue(dev->bdev); - - return q && blk_queue_dax(q); + return bdev_dax_supported(dev->bdev, PAGE_SIZE); } -static bool dm_table_supports_dax(struct dm_table *t) +bool dm_table_supports_dax(struct dm_table *t) { struct dm_target *ti; unsigned i; @@ -909,6 +907,7 @@ static bool dm_table_supports_dax(struct dm_table *t) return true; } +EXPORT_SYMBOL_GPL(dm_table_supports_dax); static bool dm_table_does_not_support_partial_completion(struct dm_table *t); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index e65429a29c06..bef5a3f243ed 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, if (len < 1) goto out; nr_pages = min(len, nr_pages); - if (ti->type->direct_access) - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); out: dm_put_live_table(md, srcu_idx); diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 6fb0808e87c8..45ea9e1f9af9 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -461,6 +461,11 @@ void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callback */ void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type); +/* + * Check to see if this target type and all table devices support DAX. + */ +bool dm_table_supports_dax(struct dm_table *t); + /* * Finally call this to make the table ready for use. */ -- 2.14.4