From patchwork Fri Feb 12 12:18:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Watson X-Patchwork-Id: 78885 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mx02.colomx.prod.int.phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1CCM1lj010855 for ; Fri, 12 Feb 2010 12:22:38 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx02.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1CCJN4u007538; Fri, 12 Feb 2010 07:19:26 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1CCJMX0021903 for ; Fri, 12 Feb 2010 07:19:22 -0500 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.7]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1CCJGZn030794 for ; Fri, 12 Feb 2010 07:19:16 -0500 Received: from smarthost01.mail.zen.net.uk (smarthost01.mail.zen.net.uk [212.23.3.140]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1CCJ0TM005163 for ; Fri, 12 Feb 2010 07:19:01 -0500 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1NfuU7-0002BJ-Rw; Fri, 12 Feb 2010 12:19:00 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) id 1NfuU7-00034Z-00; Fri, 12 Feb 2010 12:18:59 +0000 Date: Fri, 12 Feb 2010 12:18:59 +0000 From: Colin Watson To: dm-devel@redhat.com Message-ID: <20100212121859.GK4409@riva.ucam.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost01-IP: [82.69.40.219] X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.7 X-loop: dm-devel@redhat.com Cc: Yingying Zhao Subject: [dm-devel] [PATCH] Honour ALUA preference indicator X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 12 Feb 2010 12:22:38 +0000 (UTC) diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c index 0048a44..abf6232 100644 --- a/libmultipath/prioritizers/alua.c +++ b/libmultipath/prioritizers/alua.c @@ -37,6 +37,7 @@ get_alua_info(int fd) }; int rc; int tpg; + int aas; rc = get_target_port_group_support(fd); if (rc < 0) @@ -53,22 +54,27 @@ get_alua_info(int fd) rc = get_asymmetric_access_state(fd, tpg); if (rc < 0) return -ALUA_PRIO_GETAAS_FAILED; + aas = (rc & 0x0f); condlog(3, "aas = [%s]", - (rc < 4) ? aas_string[rc] : "invalid/reserved"); + (aas < 4) ? aas_string[aas] : "invalid/reserved"); return rc; } int getprio (struct path * pp) { int rc; + int aas; + int priopath; if (pp->fd < 0) return -ALUA_PRIO_NO_INFORMATION; rc = get_alua_info(pp->fd); if (rc >= 0) { - switch(rc) { + aas = (rc & 0x0f); + priopath = (rc & 0x80); + switch(aas) { case AAS_OPTIMIZED: rc = 50; break; @@ -81,6 +87,8 @@ int getprio (struct path * pp) default: rc = 0; } + if (priopath) + rc += 80; } else { switch(-rc) { case ALUA_PRIO_NOT_SUPPORTED: diff --git a/libmultipath/prioritizers/alua_spc3.h b/libmultipath/prioritizers/alua_spc3.h index bddbbdd..4bbdded 100644 --- a/libmultipath/prioritizers/alua_spc3.h +++ b/libmultipath/prioritizers/alua_spc3.h @@ -299,7 +299,7 @@ struct rtpg_tpg_dscr { static inline int rtpg_tpg_dscr_get_aas(struct rtpg_tpg_dscr *d) { - return (d->b0 & 0x0f); + return (d->b0 & 0x8f); } struct rtpg_data {