All of lore.kernel.org
 help / color / mirror / Atom feed
* multipath-tools/libcheckers readsector0.c
@ 2009-09-11 14:33 bmarzins
  0 siblings, 0 replies; only message in thread
From: bmarzins @ 2009-09-11 14:33 UTC (permalink / raw)
  To: dm-cvs, dm-devel

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

--- 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;
 	}
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-11 14:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-11 14:33 multipath-tools/libcheckers readsector0.c bmarzins

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.