From patchwork Fri Sep 11 18:23:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 46911 X-Patchwork-Delegate: bmarzins@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8BIVP2H026343 for ; Fri, 11 Sep 2009 18:31:25 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 71789619B9D; Fri, 11 Sep 2009 14:31:24 -0400 (EDT) Received: from int-mx05.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n8BIVMww012728 for ; Fri, 11 Sep 2009 14:31:22 -0400 Received: from ether.msp.redhat.com (ether.msp.redhat.com [10.15.80.119]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8BIVLW6018154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 11 Sep 2009 14:31:22 -0400 Received: from ether.msp.redhat.com (localhost.localdomain [127.0.0.1]) by ether.msp.redhat.com (8.14.1/8.14.1) with ESMTP id n8BIN9fH026917 for ; Fri, 11 Sep 2009 13:23:09 -0500 Received: (from bmarzins@localhost) by ether.msp.redhat.com (8.14.1/8.14.1/Submit) id n8BIN9xo026916 for dm-devel@redhat.com; Fri, 11 Sep 2009 13:23:09 -0500 Date: Fri, 11 Sep 2009 13:23:09 -0500 From: Benjamin Marzinski To: device-mapper development Message-ID: <20090911182308.GN15326@ether.msp.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] multipath-tools: Add preferred TPG prioritizer X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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. Signed-off-by: Benjamin Marzinski --- 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(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: multipath-tools-090902/libmultipath/prio.h =================================================================== --- multipath-tools-090902.orig/libmultipath/prio.h +++ 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" Index: multipath-tools-090902/libmultipath/prioritizers/alua.c =================================================================== --- multipath-tools-090902.orig/libmultipath/prioritizers/alua.c +++ 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; Index: multipath-tools-090902/libmultipath/prioritizers/alua_rtpg.c =================================================================== --- multipath-tools-090902.orig/libmultipath/prioritizers/alua_rtpg.c +++ 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 } } } Index: multipath-tools-090902/libmultipath/prioritizers/alua_spc3.h =================================================================== --- multipath-tools-090902.orig/libmultipath/prioritizers/alua_spc3.h +++ 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]; Index: multipath-tools-090902/libmultipath/prioritizers/Makefile =================================================================== --- multipath-tools-090902.orig/libmultipath/prioritizers/Makefile +++ 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)