From patchwork Wed Sep 27 23:25:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9975029 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 0DF4060375 for ; Wed, 27 Sep 2017 23:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06D47293F8 for ; Wed, 27 Sep 2017 23:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF802293FD; Wed, 27 Sep 2017 23:32:18 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [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 F15C5293F8 for ; Wed, 27 Sep 2017 23:32:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F253921EC8CEE; Wed, 27 Sep 2017 16:29:02 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 35A8720945BD0 for ; Wed, 27 Sep 2017 16:29:00 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 16:32:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,447,1500966000"; d="scan'208"; a="1176482012" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga001.jf.intel.com with ESMTP; 27 Sep 2017 16:32:14 -0700 Subject: [ndctl PATCH] ndctl, create-namespace: fix --align= default for nfit_test From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 27 Sep 2017 16:25:50 -0700 Message-ID: <150655475033.40865.7840035470610962973.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Vishal reports: (after ndctl create-namepsace -t pmem --bus=nfit_test.0) I'm seeing that it is created as a memory mode namespace, but after cycling it, it comes up as raw and dmesg has: pfn7.0: bad offset: 0x2af000 dax disabled align: 0x200000 This arises from the hacks that nfit_test uses to emulate pmem with vmalloc(). Setting the alignment to 4K avoids these problems. For casual testing try to detect the nfit_test case and adjust the default alignment accordingly. Reported-by: Vishal Verma Signed-off-by: Dan Williams --- README.md | 5 +++++ ndctl/namespace.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 14ff0ccb1f51..1698e52b817d 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,8 @@ to /etc/depmod.d with the following contents: `override nd_btt * extra` `override nd_e820 * extra` `override nd_pmem * extra` + +The nfit_test module emulates pmem with memory allocated via vmalloc(). +One of the side effects is that this breaks 'physically contiguous' +assumptions in the driver. Use the '--align=4K option to 'ndctl +create-namespace' to avoid these corner case scenarios. diff --git a/ndctl/namespace.c b/ndctl/namespace.c index d26ed1289c33..077d5968d0e8 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -563,6 +563,19 @@ static int validate_namespace_options(struct ndctl_region *region, return -ENXIO; } + /* + * Fallback to a 4K default alignment if the region is + * not 2MB (typical default) aligned. This mainly helps + * the nfit_test use case where it is backed by vmalloc + * memory. + */ + if (param.align_default && (ndctl_region_get_resource(region) + & (SZ_2M - 1))) { + debug("%s: falling back to a 4K alignment\n", + region_name); + p->align = SZ_4K; + } + switch (p->align) { case SZ_4K: case SZ_2M: