Skip to contentSkip to conversation

multipath: Add compability 'command' prio handler

PATCH In review Hannes Reinecke 2 participants 2 messages Feb 1, 2008 – Feb 5, 2008 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multipath: Add compability 'command' prio handler

Hi all,

with the move to the libprio framework we change the layout of the configuration file. Without advance warning to the user.

Not good.

So here's a patch to implement a compatible 'command' prio handler, which re-implements the old 'getprio' keyword handling on top of the existing libprio framework.
And we print a nice fat warning to the user.

As usual, comments etc are welcome.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Markus Rex, HRB 16746 (AG N�rnberg)

tree d55d7fa57eb2e37a2963d58f3ffecc61a2dcfd19 parent 435a721afbb87e1921637538668441726ccc1d9e author Hannes Reinecke <[email protected]> 1201878006 +0100 committer Hannes Reinecke <[email protected]> 1201878006 +0100

libprio: Add compability 'command' prio handler

The old 'getprio' callout functionality should be provided, as we cannot guarantee that the config files will be up to date. So re-implement the getprio callout and make sure the user is notified on startup.

0a2def51de718fbbc3629a02e14870d9f8af4c69

 libmultipath/config.h  |    3 ++
 libmultipath/dict.c    |   69 ++++++++++++++++++++++++++++++++++++++++++++++++
 libmultipath/propsel.c |   16 +++++++++++
 libmultipath/structs.h |    1 +
 libprio/Makefile       |    2 +-
 libprio/command.c      |   37 +++++++++++++++++++++++++
 libprio/command.h      |    7 +++++
 libprio/libprio.c      |    4 +++
 libprio/libprio.h      |    1 +
 9 files changed, 139 insertions(+), 1 deletions(-)
libmultipath/config.h +3 -0
index 7568d7b..d6403a8 100644
@@ -16,6 +16,7 @@ struct hwentry {
 	char * product;
 	char * revision;
 	char * getuid;
+	char * getprio;
 	char * features;
 	char * hwhandler;
 	char * selector;
@@ -37,6 +38,7 @@ struct mpentry {
 	char * wwid;
 	char * alias;
 	char * getuid;
+	char * getprio;
 	char * selector;
 
 	int pgpolicy;
@@ -73,6 +75,7 @@ struct config {
 	char * udev_dir;
 	char * selector;
 	char * getuid;
+	char * getprio;
 	char * features;
 	char * hwhandler;
 	char * bindings_file;
libmultipath/dict.c +69 -0

105 lines not on this page · raw message

libmultipath/propsel.c +16 -0
index bb2b2b7..7bc7083 100644
@@ -266,12 +266,28 @@ select_prio (struct path * pp)
 			pp->dev, prio_name(pp->prio));
 		return 0;
 	}
+	if (pp->hwe && pp->hwe->getprio) {
+		pp->getprio = pp->hwe->getprio;
+		pp->prio = prio_lookup(PRIO_COMMAND);
+		condlog(1, "%s: Using deprecated prio_callout '%s' (controller setting)\n"
+			"\tPlease fixup /etc/multipath.conf",
+			pp->dev, pp->hwe->getprio);
+		return 0;
+	}
 	if (conf->prio) {
 		pp->prio = conf->prio;
 		condlog(3, "%s: prio = %s (config file default)",
 			pp->dev, prio_name(pp->prio));
 		return 0;
 	}
+	if (conf->getprio) {
+		pp->getprio = conf->getprio;
+		pp->prio = prio_lookup(PRIO_COMMAND);
+		condlog(1, "%s: Using deprecated prio_callout '%s' (controller setting)\n"
+			"\tPlease fixup /etc/multipath.conf",
+			pp->dev, pp->hwe->getprio);
+		return 0;
+	}
 	pp->prio = prio_default();
 	condlog(3, "%s: prio = %s (internal default)",
 		pp->dev, prio_name(pp->prio));
libmultipath/structs.h +1 -0
index 2517782..6205f59 100644
@@ -120,6 +120,7 @@ struct path {
 	int priority;
 	int pgindex;
 	char * getuid;
+	char * getprio;
 	struct prio * prio;
 	struct checker checker;
 	struct multipath * mpp;
libprio/Makefile +1 -1
index 177a67b..127def6 100644
@@ -6,7 +6,7 @@ BUILD = glibc
 
 include ../Makefile.inc
 
-OBJS = libprio.o random.o const.o hp_sw.o emc.o rdac.o alua.o alua_rtpg.o netapp.o hds.o
+OBJS = libprio.o random.o const.o hp_sw.o emc.o rdac.o alua.o alua_rtpg.o netapp.o hds.o command.o
 
 CFLAGS += -I$(multipathdir)
 
libprio/command.c new file +37 -0
new file mode 100644
index 0000000..1154c59
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "../libcheckers/checkers.h"
+
+#include <vector.h>
+#include <structs.h>
+#include <callout.h>
+#include <debug.h>
+#include "libprio.h"
+
+int prio_command(struct path * pp)
+{
+	char buff[CALLOUT_MAX_SIZE];
+	char prio[16], *ptr;
+	int priority;
+
+	if (!pp->getprio)
+		return PRIO_UNDEF;
+
+	if (apply_format(pp->getprio, &buff[0], pp)) {
+		condlog(0, "error formatting prio callout command");
+		return PRIO_UNDEF;
+	} else if (execute_program(buff, prio, 16)) {
+		condlog(0, "error calling out %s", buff);
+		return PRIO_UNDEF;
+	}
+
+	condlog(3, "%s: priority %s", pp->dev, prio);
+	priority = strtoul(prio, &ptr, 10);
+	if (prio == ptr)
+		return PRIO_UNDEF;
+
+	return priority;
+}
libprio/command.h new file +7 -0
new file mode 100644
index 0000000..a1af97e
@@ -0,0 +1,7 @@
+#ifndef _COMMAND_H
+#define _COMMAND_H
+
+#define PRIO_COMMAND "command"
+int prio_command(struct path * pp);
+
+#endif
libprio/libprio.c +4 -0
index 2d7d479..bc79fa7 100644
@@ -37,6 +37,10 @@ static struct prio prioritizers[] = {
 		.getprio = prio_hp_sw
 	},
 	{
+		.name    = PRIO_COMMAND,
+		.getprio = prio_command
+	},
+	{
 		.name    = "",
 		.getprio = NULL
 	},
libprio/libprio.h +1 -0
index 978e14e..36d1eff 100644
@@ -16,6 +16,7 @@
 #include "netapp.h"
 #include "hds.h"
 #include "rdac.h"
+#include "command.h"
 
 #define DEFAULT_PRIO PRIO_CONST
 
#1 lore raw

Hi,

With this implementation,I think it is not necessary to have the 'getprio' field in the mpentry structure.

We want to have 'getprio' in the mpentry strcture and some more modifications in order to have LUN specific prio_callouts in device mapper.Here is the link for the patch.
http://www.redhat.com/archives/dm-devel/2007-December/msg00026.html

Thanks,
Veena

Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hannes Reinecke
Sent: Friday, February 01, 2008 8:38 PM
To: device-mapper development
Subject: [dm-devel] [PATCH] multipath: Add compability 'command' prio handler

Hi all,

with the move to the libprio framework we change the layout of the configuration file. Without advance warning to the user.

Not good.

So here's a patch to implement a compatible 'command' prio handler, which re-implements the old 'getprio' keyword handling on top of the existing libprio framework. And we print a nice fat warning to the user.

As usual, comments etc are welcome.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N rnberg
GF: Markus Rex, HRB 16746 (AG N rnberg)