Skip to contentSkip to conversation

multipath-tools: Add preferred TPG prioritizer

PATCH In review Benjamin Marzinski 2 participants 3 messages Sep 11, 2009 – Sep 14, 2009 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipath-tools: Add preferred TPG prioritizer

Instead of using the Target port's Asymmetric Access State to determine priority, some users what to use the preferred port bit. This patch makes a new prioritizer, based off the ALUA prioritizer, but using the preferred port bit instead.

---
 libmultipath/prio.h                   |    1 +
 libmultipath/prioritizers/Makefile    |   10 ++++++++++
 libmultipath/prioritizers/alua.c      |    7 +++++++
 libmultipath/prioritizers/alua_rtpg.c |    4 ++++
 libmultipath/prioritizers/alua_spc3.h |    6 ++++++
 5 files changed, 28 insertions(+)
libmultipath/prio.h +1 -0
Index: multipath-tools-090902/libmultipath/prio.h
===================================================================
@@ -16,6 +16,7 @@
  * Known prioritizers for use in hwtable.c
  */
 #define PRIO_ALUA "alua"
+#define PRIO_TPG_PREF "tpg_pref"
 #define PRIO_CONST "const"
 #define PRIO_EMC "emc"
 #define PRIO_HDS "hds"
libmultipath/prioritizers/alua.c +7 -0
Index: multipath-tools-090902/libmultipath/prioritizers/alua.c
===================================================================
@@ -28,6 +28,12 @@
 int
 get_alua_info(int fd)
 {
+#ifdef TPG_PREF
+	char * aas_string[] = {
+		[AAS_OPTIMIZED]		= "preferred",
+		[AAS_STANDBY]		= "non-preferred",
+	};
+#else
 	char *	aas_string[] = {
 		[AAS_OPTIMIZED]		= "active/optimized",
 		[AAS_NON_OPTIMIZED]	= "active/non-optimized",
@@ -35,6 +41,7 @@ get_alua_info(int fd)
 		[AAS_UNAVAILABLE]	= "unavailable",
 		[AAS_TRANSITIONING]	= "transitioning between states",
 	};
+#endif
 	int	rc;
 	int	tpg;
 
libmultipath/prioritizers/alua_rtpg.c +4 -0
Index: multipath-tools-090902/libmultipath/prioritizers/alua_rtpg.c
===================================================================
@@ -293,7 +293,11 @@ get_asymmetric_access_state(int fd, unsi
 					"group.\n");
 			} else {
 				PRINT_DEBUG("pref=%i\n", dscr->b0);
+#ifdef TPG_PREF
+				rc = rtpg_tpg_dscr_get_pref(dscr);
+#else
 				rc = rtpg_tpg_dscr_get_aas(dscr);
+#endif
 			}
 		}
 	}
libmultipath/prioritizers/alua_spc3.h +6 -0
Index: multipath-tools-090902/libmultipath/prioritizers/alua_spc3.h
===================================================================
@@ -302,6 +302,12 @@ rtpg_tpg_dscr_get_aas(struct rtpg_tpg_ds
 	return (d->b0 & 0x0f);
 }
 
+static inline int
+rtpg_tpg_dscr_get_pref(struct rtpg_tpg_dscr *d)
+{
+	return ((d->b0 & 0x80)?AAS_OPTIMIZED:AAS_STANDBY);
+}
+
 struct rtpg_data {
 	unsigned char			length[4];		/* size-4 */
 	struct rtpg_tpg_dscr		data[0];
libmultipath/prioritizers/Makefile +10 -0
Index: multipath-tools-090902/libmultipath/prioritizers/Makefile
===================================================================
@@ -11,6 +11,7 @@ LIBS = \
 	libprioemc.so \
 	libpriordac.so \
 	libprioalua.so \
+	libpriotpg_pref.so \
 	libprionetapp.so \
 	libpriohds.so
 
@@ -21,9 +22,18 @@ all: $(LIBS)
 libprioalua.so: alua.o alua_rtpg.o
 	$(CC) $(SHARED_FLAGS) -o $@ $^
 
+libpriotpg_pref.so: pref.o pref_rtpg.o
+	$(CC) $(SHARED_FLAGS) -o $@ $^
+
 libprio%.so: %.o
 	$(CC) $(SHARED_FLAGS) -o $@ $^
 
+pref.o: alua.c
+	$(CC) $(CFLAGS) -DTPG_PREF -c -o $@ $<
+
+pref_rtpg.o: alua_rtpg.c
+	$(CC) $(CFLAGS) -DTPG_PREF -c -o $@ $<
+
 install: $(LIBS)
 	$(INSTALL_PROGRAM) -m 755 libprio*.so $(DESTDIR)$(libdir)
 
#1 lore raw
Quoted 5 lines · Benjamin Marzinski

Instead of using the Target port's Asymmetric Access State to determine priority, some users what to use the preferred port bit. This patch makes a new prioritizer, based off the ALUA prioritizer, but using the preferred port bit instead.

Please, no.

This would mean that 'tpg_pref' would evaluate the PREF bit _only_, with total disregard to the other settings.

We should be updating the existing 'alua' prioritizer to evaluate the PREF bit together with the existing AAS status; then we could be using it for all scenarios.

I think I got a patch somewhere ...

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)
author maintainer
#2 lore raw
Quoted 11 lines · Hannes Reinecke
Quoted 5 lines · Benjamin Marzinski

Instead of using the Target port's Asymmetric Access State to determine priority, some users what to use the preferred port bit. This patch makes a new prioritizer, based off the ALUA prioritizer, but using the preferred port bit instead.

Please, no.

This would mean that 'tpg_pref' would evaluate the PREF bit _only_, with total disregard to the other settings.

The PREF bit isn't static. It can change whenever the AAS status changes. I'd like to think that most devices do something sane like removing the PREF bit from offline and unavailable ports. Perhaps that is hoping for too much. So making sure that the preferred port is a sane choice makes sense. I'm not sure what you patch does, but I got the feeling that people wanted to choose, for instance, a preferred standby port over a non-preferred active port. If you have a patch that does that, I'm all for it. Otherwise, I can add some logic to make sure that the preferred port is a reasonable one (not unavailable or offline).

How does that sound?

-Ben

Quoted 19 lines

We should be updating the existing 'alua' prioritizer to evaluate the PREF bit together with the existing AAS status; then we could be using it for all scenarios.

I think I got a patch somewhere ...

Cheers,

Hannes

Signature · 9 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)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel