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 Treat LUNs as 64bit numbers that the...
details: https://anonhg.NetBSD.org/src/rev/596120fbb990
branches: trunk
changeset: 781767:596120fbb990
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat Sep 29 07:18:21 2012 +0000
description:
Treat LUNs as 64bit numbers that they are.
Don't use broken 48bit accesses for ISID either.
This fixes the LUN ghosting problem on big-endian systems.
LUN handling is still incorrect because it assumes a LUN value < 256
and doesn't parse the 64bit LUN for extended formats.
diffstat:
external/bsd/iscsi/dist/include/iscsiutil.h | 37 ----------------------
external/bsd/iscsi/dist/src/lib/disk.c | 4 +-
external/bsd/iscsi/dist/src/lib/protocol.c | 47 ++++++++++++++--------------
3 files changed, 26 insertions(+), 62 deletions(-)
diffs (283 lines):
diff -r 6a6f2684c2f0 -r 596120fbb990 external/bsd/iscsi/dist/include/iscsiutil.h
--- a/external/bsd/iscsi/dist/include/iscsiutil.h Sat Sep 29 04:02:42 2012 +0000
+++ b/external/bsd/iscsi/dist/include/iscsiutil.h Sat Sep 29 07:18:21 2012 +0000
@@ -78,43 +78,6 @@
#include <syslog.h>
#endif
-#ifdef HAVE_SYS_BYTEORDER_H
-# include <sys/byteorder.h>
-# if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
-# undef _BIG_ENDIAN
-# define _BIG_ENDIAN 4321
-# define _BYTE_ORDER _BIG_ENDIAN
-# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
-# undef _LITTLE_ENDIAN
-# define _LITTLE_ENDIAN 1234
-# define _BYTE_ORDER _LITTLE_ENDIAN
-# endif
-#endif
-
-/*
- *
- */
-#if _BYTE_ORDER == 1234
-#define ISCSI_HTONLL6(x) (uint64_t) \
- ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uLL) >> 40)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uLL) >> 24)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uLL) >> 8)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uLL) << 8)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uLL) << 24)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuLL) << 40)))
-
-#define ISCSI_NTOHLL6(x) (uint64_t) \
- ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uLL) >> 40)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uLL) >> 24)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uLL) >> 8)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uLL) << 8)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uLL) << 24)) \
- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuLL) << 40)))
-#else
-#define ISCSI_HTONLL6(x) ((uint64_t)(x)&0x0000ffffffffffffuLL)
-#define ISCSI_NTOHLL6(x) ((uint64_t)(x)&0x0000ffffffffffffuLL)
-#endif
-
/*
* Debugging Levels
*/
diff -r 6a6f2684c2f0 -r 596120fbb990 external/bsd/iscsi/dist/src/lib/disk.c
--- a/external/bsd/iscsi/dist/src/lib/disk.c Sat Sep 29 04:02:42 2012 +0000
+++ b/external/bsd/iscsi/dist/src/lib/disk.c Sat Sep 29 07:18:21 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disk.c,v 1.7 2012/03/15 04:06:54 joerg Exp $ */
+/* $NetBSD: disk.c,v 1.8 2012/09/29 07:18:21 mlelstv Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -1098,7 +1098,7 @@
uint8_t lun;
cdb = args->cdb;
- lun = (uint8_t) (args->lun >> 32);
+ lun = (uint8_t) (args->lun >> 48);
cdbsize = &cdb[4];
/*
diff -r 6a6f2684c2f0 -r 596120fbb990 external/bsd/iscsi/dist/src/lib/protocol.c
--- a/external/bsd/iscsi/dist/src/lib/protocol.c Sat Sep 29 04:02:42 2012 +0000
+++ b/external/bsd/iscsi/dist/src/lib/protocol.c Sat Sep 29 07:18:21 2012 +0000
@@ -62,6 +62,7 @@
#include "iscsiprotocol.h"
#include "iscsiutil.h"
+#include <compat.h>
/*
@@ -88,7 +89,7 @@
header[0] |= 0x40; /* Immediate bit */
}
header[1] = cmd->function & 0x80; /* Function */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->ref_tag); /* Reference Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
@@ -111,7 +112,7 @@
}
cmd->immediate = ((header[0] & 0x40) == 0x40);
cmd->function = header[1] & 0x80;
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8)));
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8)));
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16)));
cmd->ref_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20)));
cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24)));
@@ -250,7 +251,7 @@
header[1] |= 0x80; /* Byte 1 bit 0 and Reserved */
length = (cmd->length & 0x00ffffff); /* Length */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Target Transfer Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
@@ -271,7 +272,7 @@
}
cmd->immediate = ((header[0] & 0x40) == 0x40); /* Immediate bit */
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Target Tranfer Tag */
cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* CmdSN */
@@ -324,7 +325,7 @@
header[1] |= 0x80; /* Reserved */
length = (cmd->length & 0x00ffffff); /* Length */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Target Transfer Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
@@ -345,7 +346,7 @@
return 1;
}
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Target Transfer Tag */
cmd->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* StatSN */
@@ -411,7 +412,7 @@
}
length = (cmd->length & 0x00ffffff); /* Length */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
@@ -434,7 +435,7 @@
cmd->final = ((header[1] & 0x80) == 0x80); /* Final bit */
cmd->cont = ((header[1] & 0x40) == 0x40); /* Continue bit */
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Transfer Tag */
cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* CmdSN */
@@ -498,7 +499,7 @@
}
length = (rsp->length & 0x00ffffff); /* Length */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(rsp->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(rsp->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(rsp->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(rsp->transfer_tag); /* Transfer Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(rsp->StatSN); /* StatSN */
@@ -521,7 +522,7 @@
rsp->final = ((header[1] & 0x80) == 0x80); /* Final bit */
rsp->cont = ((header[1] & 0x40) == 0x40); /* Continue bit */
rsp->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- rsp->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ rsp->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
rsp->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
rsp->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Transfer Tag */
rsp->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* StatSN */
@@ -597,7 +598,7 @@
header[4] = cmd->AHSlength; /* TotalAHSLength */
length = (cmd->length & 0x00ffffff); /* Length */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->isid); /* ISID */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->isid << 16); /* ISID */
*((uint16_t *) (void *) (header + 14)) = ISCSI_HTONS(cmd->tsih); /* TSIH */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Task Tag */
*((uint16_t *) (void *) (header + 20)) = ISCSI_HTONS(cmd->cid); /* CID */
@@ -625,7 +626,7 @@
cmd->version_min = header[3]; /* Version-Min */
cmd->AHSlength = header[4]; /* TotalAHSLength */
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->isid = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* ISID */
+ cmd->isid = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))) >> 16; /* ISID */
cmd->tsih = ISCSI_NTOHS(*((uint16_t *) (void *) (header + 14))); /* TSIH */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Task Tag */
cmd->cid = ISCSI_NTOHS(*((uint16_t *) (void *) (header + 20))); /* CID */
@@ -714,7 +715,7 @@
header[3] = rsp->version_active; /* Version-active */
header[4] = rsp->AHSlength; /* TotalAHSLength */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(rsp->length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(rsp->isid); /* ISID */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(rsp->isid << 16); /* ISID */
*((uint16_t *) (void *) (header + 14)) = ISCSI_HTONS(rsp->tsih); /* TSIH */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(rsp->tag); /* Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(rsp->StatSN); /* StatRn */
@@ -744,7 +745,7 @@
rsp->version_active = header[3]; /* Version-active */
rsp->AHSlength = header[4]; /* TotalAHSLength */
rsp->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- rsp->isid = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* ISID */
+ rsp->isid = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))) >> 16; /* ISID */
rsp->tsih = ISCSI_NTOHS(*((uint16_t *) (void *) (header + 14))); /* TSIH */
rsp->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
@@ -996,7 +997,7 @@
header[1] |= cmd->attr & 0x07; /* ATTR */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(cmd->length); /* DataSegmentLength */
header[4] = cmd->ahs_len; /* TotalAHSLength */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Task Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->trans_len); /* Expected Transfer
* Length */
@@ -1024,7 +1025,7 @@
cmd->ahs_len = header[4];
header[4] = 0x00;
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* DataSegmentLength */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Task Tag */
cmd->trans_len = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Expected Transfer
* Length */
@@ -1206,7 +1207,7 @@
header[1] |= 0x80;
length = (cmd->AHSlength & 0x00ffffff); /* AHSLength */
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(length); /* AHSLength */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
*((uint32_t *) (void *) (header + 24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
@@ -1230,7 +1231,7 @@
return 1;
}
cmd->AHSlength = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* TotalAHSLength */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16)));
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20)));
cmd->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24)));
@@ -1292,7 +1293,7 @@
header[1] |= 0x80; /* Final */
}
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(cmd->length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->tag); /* Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
*((uint32_t *) (void *) (header + 28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
@@ -1314,7 +1315,7 @@
}
cmd->final = (header[1] & 0x80) ? 1 : 0; /* Final */
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Tag */
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Transfer Tag */
cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 28))); /* ExpStatSN */
@@ -1402,7 +1403,7 @@
header[3] = cmd->status; /* Status */
}
*((uint32_t *) (void *) (header + 4)) = ISCSI_HTONL(cmd->length); /* Length */
- *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
+ *((uint64_t *) (void *) (header + 8)) = ISCSI_HTONLL(cmd->lun); /* LUN */
*((uint32_t *) (void *) (header + 16)) = ISCSI_HTONL(cmd->task_tag); /* Task Tag */
*((uint32_t *) (void *) (header + 20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
if (cmd->S_bit) {
@@ -1436,7 +1437,7 @@
cmd->S_bit = (header[1] & 0x01) ? 1 : 0; /* S Bit */
cmd->status = header[3];/* Status */
cmd->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- cmd->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ cmd->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
cmd->task_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 16))); /* Task Tag */
cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 20))); /* Transfer Tag */
cmd->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* StatSN */
@@ -1569,7 +1570,7 @@
}
msg->AHSlength = header[4]; /* TotalAHSLength */
msg->length = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 4))); /* Length */
- msg->lun = ISCSI_NTOHLL6(*((uint64_t *) (void *) (header + 8))); /* LUN */
+ msg->lun = ISCSI_NTOHLL(*((uint64_t *) (void *) (header + 8))); /* LUN */
msg->StatSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 24))); /* StatSN */
msg->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 28))); /* ExpCmdSN */
msg->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *) (void *) (header + 32))); /* MaxCmdSN */
Home |
Main Index |
Thread Index |
Old Index