All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Pavel Tatashin <pasha.tatashin@soleen.com>
Subject: [ndctl PATCH v3 02/10] libdaxctl: cache 'subsystem' in daxctl_ctx
Date: Thu, 16 May 2019 16:40:45 -0600	[thread overview]
Message-ID: <20190516224053.3655-3-vishal.l.verma@intel.com> (raw)
In-Reply-To: <20190516224053.3655-1-vishal.l.verma@intel.com>

The 'DAX subsystem' in effect is determined at region or device init
time, and dictates the sysfs base paths for all device/region
operations. In preparation for adding bind/unbind functionality, cache
the subsystem as determined at init time in the library context.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 daxctl/lib/libdaxctl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 70f896b..f8f5b8c 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -46,6 +46,7 @@ struct daxctl_ctx {
 	void *userdata;
 	int regions_init;
 	struct list_head regions;
+	enum dax_subsystem subsys;
 };
 
 /**
@@ -96,6 +97,7 @@ DAXCTL_EXPORT int daxctl_new(struct daxctl_ctx **ctx)
 	dbg(c, "log_priority=%d\n", c->ctx.log_priority);
 	*ctx = c;
 	list_head_init(&c->regions);
+	c->subsys = DAX_UNKNOWN;
 
 	return 0;
 }
@@ -454,14 +456,18 @@ static void dax_devices_init(struct daxctl_region *region)
 	for (i = 0; i < ARRAY_SIZE(dax_subsystems); i++) {
 		char *region_path;
 
-		if (i == DAX_BUS)
+		if (i == DAX_BUS) {
 			region_path = region->region_path;
-		else if (i == DAX_CLASS) {
+			if (ctx->subsys == DAX_UNKNOWN)
+				ctx->subsys = DAX_BUS;
+		} else if (i == DAX_CLASS) {
 			if (asprintf(&region_path, "%s/dax",
 						region->region_path) < 0) {
 				dbg(ctx, "region path alloc fail\n");
 				continue;
 			}
+			if (ctx->subsys == DAX_UNKNOWN)
+				ctx->subsys = DAX_CLASS;
 		} else
 			continue;
 		sysfs_device_parse(ctx, region_path, daxdev_fmt, region,
@@ -539,6 +545,8 @@ static void __dax_regions_init(struct daxctl_ctx *ctx, enum dax_subsystem subsys
 		free(dev_path);
 		if (!region)
 			err(ctx, "add_dax_region() for %s failed\n", de->d_name);
+		if (ctx->subsys == DAX_UNKNOWN)
+			ctx->subsys = subsys;
 	}
 	closedir(dir);
 }
-- 
2.20.1

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2019-05-16 22:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 22:40 [ndctl PATCH v3 00/10] daxctl: add a new reconfigure-device command Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 01/10] libdaxctl: add interfaces in support of device modes Vishal Verma
2019-05-16 22:40 ` Vishal Verma [this message]
2019-05-16 22:40 ` [ndctl PATCH v3 03/10] libdaxctl: add interfaces to enable/disable devices Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 04/10] libdaxctl: add interfaces to get/set the online state for a node Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 05/10] daxctl/list: add numa_node for device listings Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 06/10] libdaxctl: add an interface to get the mode for a dax device Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 07/10] daxctl: add a new reconfigure-device command Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 08/10] Documentation/daxctl: add a man page for daxctl-reconfigure-device Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 09/10] contrib/ndctl: fix region-id completions for daxctl Vishal Verma
2019-05-16 22:40 ` [ndctl PATCH v3 10/10] contrib/ndctl: add bash-completion for daxctl-reconfigure-device Vishal Verma
2019-05-17 15:30 ` [ndctl PATCH v3 00/10] daxctl: add a new reconfigure-device command Pavel Tatashin
2019-05-17 17:38   ` Verma, Vishal L
2019-05-17 17:41     ` Pavel Tatashin
2019-05-20 23:34       ` Verma, Vishal L
2019-05-22 18:05         ` Verma, Vishal L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190516224053.3655-3-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=pasha.tatashin@soleen.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.