From patchwork Wed Aug 30 02:11:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9928653 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 8163D602B9 for ; Wed, 30 Aug 2017 02:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BBE727853 for ; Wed, 30 Aug 2017 02:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60EBE27C0B; Wed, 30 Aug 2017 02:18:07 +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 190A027853 for ; Wed, 30 Aug 2017 02:18:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D4C0221E95DE6; Tue, 29 Aug 2017 19:15:25 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 4729821E95DE3 for ; Tue, 29 Aug 2017 19:15:24 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2017 19:18:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,446,1498546800"; d="scan'208";a="129741411" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga002.jf.intel.com with ESMTP; 29 Aug 2017 19:18:04 -0700 Subject: [ndctl PATCH v2 08/10] ndctl: refresh region type after init_labels From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 29 Aug 2017 19:11:41 -0700 Message-ID: <150405910100.22171.16178052413106856140.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <150405905872.22171.7217183939530397385.stgit@dwillia2-desk3.amr.corp.intel.com> References: <150405905872.22171.7217183939530397385.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: , Cc: Ryon Jensen Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Given that init_labels can change a region from hosting namespaces with an 'nstype' of ND_DEVICE_NAMESPACE_IO to ND_DEVICE_NAMESPACE_PMEM, arrange for ndctl_dimm_init_labels() to trigger the region to refresh these attributes when it is next enabled. Reported-by: Ryon Jensen Signed-off-by: Dan Williams --- ndctl/lib/dimm.c | 12 ++++++++++++ ndctl/lib/libndctl.c | 11 +++++++++++ ndctl/lib/private.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c index 0fd8d9e30b93..49cf7cb9be6f 100644 --- a/ndctl/lib/dimm.c +++ b/ndctl/lib/dimm.c @@ -422,8 +422,10 @@ static int write_label_index(struct ndctl_dimm *dimm, NDCTL_EXPORT int ndctl_dimm_init_labels(struct ndctl_dimm *dimm, enum ndctl_namespace_version v) { + struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm); struct nvdimm_data *ndd = &dimm->ndd; + struct ndctl_region *region; int i; if (!ndd->cmd_read) { @@ -432,6 +434,16 @@ NDCTL_EXPORT int ndctl_dimm_init_labels(struct ndctl_dimm *dimm, return -EINVAL; } + ndctl_region_foreach(bus, region) { + struct ndctl_dimm *match; + + ndctl_dimm_foreach_in_region(region, match) + if (match == dimm) { + region_flag_refresh(region); + break; + } + } + for (i = 0; i < 2; i++) { int rc; diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 9c65646ac3e9..f52ecfe9d142 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -152,6 +152,7 @@ struct ndctl_region { int btts_init; int pfns_init; int daxs_init; + int refresh_type; unsigned long long size; char *region_path; char *region_buf; @@ -2400,10 +2401,20 @@ NDCTL_EXPORT int ndctl_region_enable(struct ndctl_region *region) return -ENXIO; } + if (region->refresh_type) { + region->refresh_type = 0; + region_set_type(region, region->region_buf); + } + dbg(ctx, "%s: enabled\n", devname); return 0; } +void region_flag_refresh(struct ndctl_region *region) +{ + region->refresh_type = 1; +} + NDCTL_EXPORT void ndctl_region_cleanup(struct ndctl_region *region) { free_stale_namespaces(region); diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index 808e77da07ca..cfea5f75fcde 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -101,6 +101,8 @@ struct ndctl_dimm { int format[0]; }; +void region_flag_refresh(struct ndctl_region *region); + /** * struct ndctl_ctx - library user context to find "nd" instances *