Module Name:    src
Committed By:   sborrill
Date:           Tue Feb 22 13:04:31 UTC 2011

Modified Files:
        src/external/bsd/iscsi/dist/src/initiator: iscsi-initiator.c

Log Message:
Retry read capacity. Device may not be ready on first access, so need to
wait and re-issue. From Daisuke Aoyama (author of istgt).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
    src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c
diff -u src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c:1.6 src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c:1.7
--- src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c:1.6	Mon Feb 21 17:48:43 2011
+++ src/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c	Tue Feb 22 13:04:31 2011
@@ -701,8 +701,22 @@
 		}
 
 		/* stuff size into st.st_size */
-		(void) read_capacity(u, 0, &lbac, &blocksize);
-		sti.st.st_size = ((uint64_t)lbac + 1) * blocksize;
+		{
+			int retry = 5;
+			while (retry > 0) {
+				if (read_capacity(u, 0, &lbac, &blocksize) == 0)
+					break;
+				retry--;
+				iscsi_warn(__FILE__, __LINE__,
+				    "read_capacity failed - retrying %d\n", retry);
+				sleep(1);
+			}
+			if (retry == 0) {
+				iscsi_err(__FILE__, __LINE__, "read_capacity failed - giving up\n");
+				break;
+			}
+		}
+		sti.st.st_size = (off_t)(((uint64_t)lbac + 1) * blocksize);
 		sti.target = u;
 
 		tv.v[tv.c].host = strdup(tinfo.name);

Reply via email to