summaryrefslogtreecommitdiffstats
path: root/0001-for-upstream-add-tpg_pref-prioritizer.patch
blob: 93b0af2e09dd0a22a83e279688db14eee6a33935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From faf6bfc96b98562626e0ea12aecb582032ff4cab Mon Sep 17 00:00:00 2001
From: Fabio M. Di Nitto <fdinitto@redhat.com>
Date: Mon, 19 Oct 2009 07:02:02 +0200
Subject: [PATCH 1/1] for-upstream: add tpg_pref prioritizer

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 fc9277f... 1f40859... M	libmultipath/prio.h
:100644 100644 949a60a... 5021c04... M	libmultipath/prioritizers/Makefile
:100644 100644 0048a44... 22513ab... M	libmultipath/prioritizers/alua.c
:100644 100644 0531052... cd9c29d... M	libmultipath/prioritizers/alua_rtpg.c
:100644 100644 bddbbdd... daf95a6... M	libmultipath/prioritizers/alua_spc3.h
 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(+), 0 deletions(-)

diff --git a/libmultipath/prio.h b/libmultipath/prio.h
index fc9277f..1f40859 100644
--- a/libmultipath/prio.h
+++ b/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"
diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile
index 949a60a..5021c04 100644
--- a/libmultipath/prioritizers/Makefile
+++ b/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)
 
diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c
index 0048a44..22513ab 100644
--- a/libmultipath/prioritizers/alua.c
+++ b/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;
 
diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c
index 0531052..cd9c29d 100644
--- a/libmultipath/prioritizers/alua_rtpg.c
+++ b/libmultipath/prioritizers/alua_rtpg.c
@@ -293,7 +293,11 @@ get_asymmetric_access_state(int fd, unsigned int tpg)
 					"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
 			}
 		}
 	}
diff --git a/libmultipath/prioritizers/alua_spc3.h b/libmultipath/prioritizers/alua_spc3.h
index bddbbdd..daf95a6 100644
--- a/libmultipath/prioritizers/alua_spc3.h
+++ b/libmultipath/prioritizers/alua_spc3.h
@@ -302,6 +302,12 @@ rtpg_tpg_dscr_get_aas(struct rtpg_tpg_dscr *d)
 	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];
-- 
1.6.5.1