From patchwork Mon Jul 16 17:01:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527271 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 B97DD60348 for ; Mon, 16 Jul 2018 17:11:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4D6228D80 for ; Mon, 16 Jul 2018 17:11:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97D8F28D8F; Mon, 16 Jul 2018 17:11:21 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18FF428D80 for ; Mon, 16 Jul 2018 17:11:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C25DD6B0277; Mon, 16 Jul 2018 13:11:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BAD336B0278; Mon, 16 Jul 2018 13:11:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A27A46B0279; Mon, 16 Jul 2018 13:11:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 59F016B0277 for ; Mon, 16 Jul 2018 13:11:19 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id 70-v6so25091003plc.1 for ; Mon, 16 Jul 2018 10:11:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=zXjZdsI+rGRMd290/1MRn8K51F4sLlAegV0MP8DbO0s=; b=e2oAWnud39WPjqprYN2rdobHfv25/fj7bXzuuIi57whYXB6ZseKmm1usiXw5s8R27X K0cgtFljW6KcsNNV6mBdFVQSYs418hP2s5ZI2xvtJ1U1jDinb4pD3yTPKFvA5j5FWG0l dvDdAyBos6VQzbwHT0wq2q1+HYC4Qk0CP8oifl8ATYu1XEo3BtEbr9A05dp8j8ueWvti 8I7JiSk/FH+CyIMQ8n1XD8AU6XOS9iifF6e7Ar9tpCio4nV7Sbv/ewr+BMBCNBrPOlMF /hs1D6IxgF7yUY1pDCrB4t6Sg09dHn6kAGMkwiau3/8spRhSTZRV/A3BiQ2hqk69ZtEt WJJA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlHfOAN4a5eTlI7zApwbG4HMoV+uG+X3PvFcWTyyebqTmfmNu1QH 1ASTaCQU2UXv2JNzVWg0FhLpaOVyOD0ywlK5Spsl7hFi2vLmzuC9+BCpxsIQNpkU1tGpGZVIpTw P9R3uL6wb1vaK9mzKj09bANA1JSV59y76HSEsqiKH2sh5iCl8RLE2F1mqPj738/jlTA== X-Received: by 2002:a17:902:5381:: with SMTP id c1-v6mr17225741pli.137.1531761079025; Mon, 16 Jul 2018 10:11:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcnPZQ5rBYgveZwz6tDk/MdLODOtBFQW+J4+gKArD9xo7d29KMFKOnx1WCdIUaweWLbTlk+ X-Received: by 2002:a17:902:5381:: with SMTP id c1-v6mr17225693pli.137.1531761078257; Mon, 16 Jul 2018 10:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761078; cv=none; d=google.com; s=arc-20160816; b=j4LaIquPuI+UZPhyslf8LFq2VW7KQxIBFSJmbZpmIMqVRyUundK4mvyleRvWpn39oP CW/6ga9aOEaVBbHQsKnLM8thZdq4TG6kQRivwilwBfjoHGtN7t4QQvb8k9YjtFnZ3l7u QTIJnKYbT4/VI8esqkKA7S92K8F44dn/x3WSh3eH+/CcwPl8AL/NNvMrqsdYhb0cLOxl Za5BDYZwXhU6SGhqQEmcDtdZgMisTHcCDxzg4I0qgunA5h+Tgx3pPLm4O5ixBk/k+olx DBNRuyxQxmwus5TjbthHt1EKTYQcwd88Q4ZPO3iSHDXueKDe40x5oPYCjGiqvg7FJf0N C51Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=zXjZdsI+rGRMd290/1MRn8K51F4sLlAegV0MP8DbO0s=; b=r9Ma8uvKvvCh97UhjP2d6mwFkTLOEC9vAjlJmN7kv+F2Jbk8/rfnUIwl4WgZu/13ZK 3TgMyquVgU31M7/wNcFZr7R4Sw8Z1LQ6Ne3m0FN9ih7wKVLA6CQFj/+gv19tJMDEMzdt TtLrTCIGtDhLDhbqT316et1bM+aIxoFGGubxb9LwjE6Nl+TDuI3BjQsLqkksEmw5Qi9t vXBAhuZLIdswPGqCSl8A0Q5chxkv6FwhY73hIhhWaoSYzIQ7bCo1glycJb6/aKFtWtAt k4EESGRyRXMBjmgyRBYVfSuzt9OebQ7SmC66snqAXlrFfARGdM8QmPxTnfLyk8Ha6W// L6Vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id n10-v6si4631587plp.328.2018.07.16.10.11.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:11:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="65094363" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 16 Jul 2018 10:11:18 -0700 Subject: [PATCH v2 11/14] filesystem-dax: Make mount time pfn validation a debug check From: Dan Williams To: akpm@linux-foundation.org Cc: Jan Kara , Christoph Hellwig , Ross Zwisler , vishal.l.verma@intel.com, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Mon, 16 Jul 2018 10:01:19 -0700 Message-ID: <153176047958.12695.16209413909835344164.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Do not ask for dax_direct_access() to retrieve a pfn in the DAX_DRIVER_DEBUG=n case. This avoids an early call to memmap_sync() in the driver. Now that QUEUE_FLAG_DAX usage has been fixed the validation of the pfn is only useful for dax driver developers. It is safe to assume that pmem, dcssblk, and device-mapper-dax are correct with respect to dax operation, so only retrieve the pfn for debug builds when qualifying a new dax driver, if one ever arrives. The moves the first consumption of a pfn from ->direct_access() to the first dax mapping fault, rather than initial filesystem mount. I.e. more time for memmap init to run in the background. Cc: Jan Kara Cc: Christoph Hellwig Cc: Ross Zwisler Signed-off-by: Dan Williams --- drivers/dax/Kconfig | 10 ++++++++ drivers/dax/super.c | 64 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index e0700bf4893a..b32f8827b983 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -9,6 +9,16 @@ menuconfig DAX if DAX +config DAX_DRIVER_DEBUG + bool "DAX: driver debug" + help + Enable validation of the page frame objects returned from a + driver's 'direct_access' operation. This validation is + performed relative to the requirements of the FS_DAX and + FS_DAX_LIMITED configuration options. If you are validating + the implementation of a dax device driver say Y otherwise + say N. + config DEV_DAX tristate "Device DAX: direct access mapping device" depends on TRANSPARENT_HUGEPAGE diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 903d9c473749..65851919e59a 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -72,6 +72,41 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev) EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev); #endif +static bool validate_dax_pfn(pfn_t *pfn) +{ + bool dax_enabled = false; + + /* + * Unless debugging a new dax driver, or new dax architecture + * support there is no need to check the pfn. Delay the kernel's + * first need for a dax pfn until first userspace dax fault. + */ + if (!pfn) + return true; + + if (IS_ENABLED(CONFIG_FS_DAX_LIMITED) && pfn_t_special(*pfn)) { + /* + * An arch that has enabled the pmem api should also + * have its drivers support pfn_t_devmap() + * + * This is a developer warning and should not trigger in + * production. dax_flush() will crash since it depends + * on being able to do (page_address(pfn_to_page())). + */ + WARN_ON(IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API)); + dax_enabled = true; + } else if (pfn_t_devmap(*pfn)) { + struct dev_pagemap *pgmap; + + pgmap = get_dev_pagemap(pfn_t_to_pfn(*pfn), NULL); + if (pgmap && pgmap->type == MEMORY_DEVICE_FS_DAX) + dax_enabled = true; + put_dev_pagemap(pgmap); + } + + return dax_enabled; +} + /** * __bdev_dax_supported() - Check if the device supports dax for filesystem * @bdev: block device to check @@ -85,11 +120,10 @@ EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev); bool __bdev_dax_supported(struct block_device *bdev, int blocksize) { struct dax_device *dax_dev; - bool dax_enabled = false; + pfn_t _pfn, *pfn; pgoff_t pgoff; int err, id; void *kaddr; - pfn_t pfn; long len; char buf[BDEVNAME_SIZE]; @@ -113,8 +147,10 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) return false; } + pfn = IS_ENABLED(CONFIG_DAX_DRIVER_DEBUG) ? &_pfn : NULL; + id = dax_read_lock(); - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); + len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, pfn); dax_read_unlock(id); put_dax(dax_dev); @@ -125,27 +161,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize) return false; } - if (IS_ENABLED(CONFIG_FS_DAX_LIMITED) && pfn_t_special(pfn)) { - /* - * An arch that has enabled the pmem api should also - * have its drivers support pfn_t_devmap() - * - * This is a developer warning and should not trigger in - * production. dax_flush() will crash since it depends - * on being able to do (page_address(pfn_to_page())). - */ - WARN_ON(IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API)); - dax_enabled = true; - } else if (pfn_t_devmap(pfn)) { - struct dev_pagemap *pgmap; - - pgmap = get_dev_pagemap(pfn_t_to_pfn(pfn), NULL); - if (pgmap && pgmap->type == MEMORY_DEVICE_FS_DAX) - dax_enabled = true; - put_dev_pagemap(pgmap); - } - - if (!dax_enabled) { + if (!validate_dax_pfn(pfn)) { pr_debug("%s: error: dax support not enabled\n", bdevname(bdev, buf)); return false;