[Debian-ha-commits] [ocfs2-tools] 36/58: ocfs2-tools: support powerpath dev as heartbeat dev

Valentin Vidic vvidic-guest at moszumanska.debian.org
Tue Jun 20 13:40:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

vvidic-guest pushed a commit to branch upstream
in repository ocfs2-tools.

commit 4d5c8ceee5ee97b721323aa04ec51f8d6247f9c8
Author: Junxiao Bi <junxiao.bi at oracle.com>
Date:   Thu Jun 25 09:35:25 2015 +0800

    ocfs2-tools: support powerpath dev as heartbeat dev
    
    This makes emc powerpath device can be used as heartbeat
    device of ocfs2.
    
    Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
    Reviewed-by: Srinivas Eeda <srinivas.eeda 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 fca7d34..5209de2 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 7adea65..4083e9f 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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-ha/ocfs2-tools.git



More information about the Debian-HA-Commits mailing list