[Ocfs2-tools-devel] [PATCH 6/6] ocfs2-tools: support powerpath dev as heartbeat dev

Junxiao Bi junxiao.bi at oracle.com
Mon Jun 29 01:29:31 PDT 2015


This makes emc powerpath device can be used as heartbeat
device of ocfs2.

Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
---
 include/tools-internal/scandisk.h |    2 ++
 libtools-internal/scandisk.c      |   57 +++++++++++++++++++++++++++++++++++++
 o2cb_ctl/o2cb_scandisk.c          |    2 ++
 3 files changed, 61 insertions(+)

diff --git a/include/tools-internal/scandisk.h b/include/tools-internal/scandisk.h
index ac69d9d..d822e29 100644
--- a/include/tools-internal/scandisk.h
+++ b/include/tools-internal/scandisk.h
@@ -72,6 +72,7 @@ struct devnode {
 	int md;			/* 0 nothing to do with raid, 1 is raid,
 				 * 2 is raid slave - data from /proc/mdstat */
 	int mapper;		/* 0 nothing, 1 we believe it's a devmap dev */
+	int power;		/* 0 nothing, 1 we believe it is powerpath device */
 	void *filter;		/* your filter output.. whatever it is */
 };
 
@@ -92,6 +93,7 @@ struct devlisthead {
 				 * /proc/mdstat */
 	int mapper;		/* set to 1 if we were able to run
 				 * something against mapper */
+	int power;		/* set to 1 if we detected a powerpath device */
 };
 
 typedef void (*devfilter) (struct devnode * cur, void *arg);
diff --git a/libtools-internal/scandisk.c b/libtools-internal/scandisk.c
index 2f5245e..0ad21a2 100644
--- a/libtools-internal/scandisk.c
+++ b/libtools-internal/scandisk.c
@@ -466,6 +466,60 @@ static int scanmapper(struct devlisthead *devlisthead)
 	return 1;
 }
 
+/* scanpower parses /proc/devices to identify what maj are associated
+ * with powerpath devices
+ */
+static int scanpower(struct devlisthead *devlisthead)
+{
+	struct devnode *startnode;
+	FILE *fp;
+	char line[4096];
+	char major[4];
+	char device[64];
+	int maj, start = 0;
+	int found = 0;
+
+	fp = fopen("/proc/devices", "r");
+	if (!fp)
+		return 0;
+
+	while (fgets(line, sizeof(line), fp) != NULL) {
+		memset(major, 0, 4);
+		memset(device, 0, 64);
+
+		if (strlen(line) > 4096)
+			continue;
+
+		if (!strncmp(line, "Block devices:", 13)) {
+			start = 1;
+			continue;
+		}
+
+		if (!start)
+			continue;
+
+		sscanf(line, "%s %s", major, device);
+
+		if (!strncmp(device, "power", 5)) {
+			found = 1;
+			maj = atoi(major);
+			startnode = devlisthead->devnode;
+
+			while (startnode) {
+				if (startnode->maj == maj)
+					startnode->power = 1;
+
+				startnode = startnode->next;
+			}
+
+		}
+
+	}
+
+	fclose(fp);
+	return found;
+}
+
 /* scan through the list and execute the custom filter for each entry */
 static void run_filter(struct devlisthead *devlisthead,
 		       devfilter filter, void *filter_args)
@@ -781,7 +835,10 @@ struct devlisthead *scan_for_dev(struct devlisthead *devlisthead,
 
 	/* from now on we don't alloc mem ourselves but only add info */
 	devlisthead->mdstat = scanmdstat(devlisthead);
+
 	devlisthead->mapper = scanmapper(devlisthead);
+
+	devlisthead->power = scanpower(devlisthead);
 	if (filter)
 		run_filter(devlisthead, filter, filter_args);
 
diff --git a/o2cb_ctl/o2cb_scandisk.c b/o2cb_ctl/o2cb_scandisk.c
index 6cd3635..2fcc650 100644
--- a/o2cb_ctl/o2cb_scandisk.c
+++ b/o2cb_ctl/o2cb_scandisk.c
@@ -124,6 +124,8 @@ static void add_to_list(struct list_head *device_list, struct devnode *node)
 	while (path) {
 		if (node->mapper)
 			add = !strncmp(path->path, "/dev/mapper/", 12);
+		else if (node->power)
+			add = !strncmp(path->path, "/dev/emcpower", 13);
 		else {
 			add = !strncmp(path->path, "/dev/sd", 7);
 			if (!add)
-- 
1.7.9.5




More information about the Ocfs2-tools-devel mailing list