From patchwork Fri Sep 11 14:33:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bmarzins@sourceware.org X-Patchwork-Id: 46866 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 n8BEXjcw026674 for ; Fri, 11 Sep 2009 14:33:45 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 A90FF619B38; Fri, 11 Sep 2009 10:33:44 -0400 (EDT) Received: from int-mx02.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 n8BEXh9Y014268 for ; Fri, 11 Sep 2009 10:33:43 -0400 Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.9]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8BEXhYX027691 for ; Fri, 11 Sep 2009 10:33:43 -0400 Received: from sourceware.org (sourceware.org [209.132.176.174]) by mx1.redhat.com (8.13.8/8.13.8) with SMTP id n8BEXTPt008874 for ; Fri, 11 Sep 2009 10:33:29 -0400 Received: (qmail 2133 invoked by uid 9475); 11 Sep 2009 14:33:29 -0000 Date: 11 Sep 2009 14:33:29 -0000 Message-ID: <20090911143329.2131.qmail@sourceware.org> From: bmarzins@sourceware.org To: dm-cvs@sourceware.org, dm-devel@redhat.com X-RedHat-Spam-Score: -4 (RCVD_IN_DNSWL_MED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.9 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] multipath-tools/libcheckers readsector0.c 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 CVSROOT: /cvs/dm Module name: multipath-tools Branch: RHEL5_FC6 Changes by: bmarzins@sourceware.org 2009-09-11 14:33:28 Modified files: libcheckers : readsector0.c Log message: Backported scsi sense buffer retry code from upstream. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libcheckers/readsector0.c.diff?cvsroot=dm&only_with_tag=RHEL5_FC6&r1=1.5&r2=1.5.2.1 --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- multipath-tools/libcheckers/readsector0.c 2006/07/13 19:49:22 1.5 +++ multipath-tools/libcheckers/readsector0.c 2009/09/11 14:33:28 1.5.2.1 @@ -14,6 +14,7 @@ #include "checkers.h" #include "../libmultipath/sg_include.h" +#include "../libmultipath/debug.h" #define SENSE_BUFF_LEN 32 @@ -50,6 +51,7 @@ int res; int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; int sz_ind; + int retry_count = 3; memset(rdCmd, 0, cdbsz); sz_ind = 1; @@ -75,6 +77,8 @@ if (diop && *diop) io_hdr.flags |= SG_FLAG_DIRECT_IO; +retry: + memset(senseBuff, 0, SENSE_BUFF_LEN); while (((res = ioctl(sg_fd, SG_IO, &io_hdr)) < 0) && (EINTR == errno)); if (res < 0) { @@ -89,6 +93,24 @@ (0 == io_hdr.driver_status)) { return PATH_UP; } else { + int key = 0; + + if (io_hdr.sb_len_wr > 3) { + if (senseBuff[0] == 0x72 || senseBuff[0] == 0x73) + key = senseBuff[1] & 0x0f; + else if (io_hdr.sb_len_wr > 13 && + ((senseBuff[0] & 0x7f) == 0x70 || + (senseBuff[0] & 0x7f) == 0x71)) + key = senseBuff[2] & 0x0f; + } + + /* + * Retry if UNIT_ATTENTION check condition. + */ + if (key == 0x6) { + if (--retry_count) + goto retry; + } return PATH_DOWN; } }