Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/iscsi/dist/src/lib implement REPORT LUNS for no...



details:   https://anonhg.NetBSD.org/src/rev/69030ac29a8c
branches:  trunk
changeset: 750972:69030ac29a8c
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Jan 20 10:33:08 2010 +0000

description:
implement REPORT LUNS for non-zero LUNs correctly.

diffstat:

 external/bsd/iscsi/dist/src/lib/disk.c |  38 ++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 13 deletions(-)

diffs (62 lines):

diff -r 47999ca77c2d -r 69030ac29a8c external/bsd/iscsi/dist/src/lib/disk.c
--- a/external/bsd/iscsi/dist/src/lib/disk.c    Wed Jan 20 09:05:12 2010 +0000
+++ b/external/bsd/iscsi/dist/src/lib/disk.c    Wed Jan 20 10:33:08 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.c,v 1.4 2010/01/20 00:58:49 yamt Exp $ */
+/* $NetBSD: disk.c,v 1.5 2010/01/20 10:33:08 yamt Exp $ */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -765,15 +765,31 @@
 
 /* handle REPORT LUNs SCSI command */
 static int
-report_luns(uint64_t *data, int64_t luns)
+report_luns(uint8_t *data, uint64_t luns)
 {
-       uint64_t        i;
-       int32_t         off;
+       uint64_t i;
+       uint32_t len;
+
+       len = 8;
+       for (i = 0; i < luns; i++) {
+               uint8_t *p = &data[len];
 
-       for (i = 0, off = 8 ; i < (uint64_t)luns ; i++, off += sizeof(i)) {
-               data[(int)i] = ISCSI_HTONLL(i);
+               if (i < 256) {
+                       memset(p, 0, 8);
+                       p[1] = (uint8_t)(i & 0xff);
+                       len += 8;
+               } else if (i < 16384) {
+                       memset(p, 0, 8);
+                       p[0] = (uint8_t)(0x40 | ((i >> 8) & 0x3f));
+                       p[1] = (uint8_t)(i & 0xff);
+                       len += 8;
+               } else {
+                       /* XXX */
+               }
        }
-       return off;
+       *((uint32_t *)(void *)data) = ISCSI_HTONL(len - 8);
+       memset(&data[4], 0, 4);
+       return len;
 }
 
 /* handle persistent reserve in command */
@@ -1309,12 +1325,8 @@
 
        case REPORT_LUNS:
                iscsi_trace(TRACE_SCSI_CMD, "REPORT LUNS\n");
-               args->length = report_luns(
-                               (uint64_t *)(void *)&args->send_data[8],
-                               (off_t)disks.v[sess->d].luns);
-               *((uint32_t *)(void *)args->send_data) =
-                               ISCSI_HTONL(disks.v[sess->d].luns *
-                               sizeof(uint64_t));
+               args->length = report_luns(args->send_data,
+                               disks.v[sess->d].luns);
                args->input = 8;
                args->status = SCSI_SUCCESS;
                break;



Home | Main Index | Thread Index | Old Index