If rand_key() is called twive within the same second it would return the
same key both times. Not very random.
Redo how rand_key() works to make it more likely to be random and more likely
that two consequtive calls do not yield the same result.
Reported-by: CyberLoiter <yanming.xiao@gmail.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
ascq is NULL if there are no ascqs provided for this failure mode.
Do not try to dereference the 0-th element in this array before checking
that the array has at least one element.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
From Adam Endrodi <adam.endrodi@nsn.com>
Fix a bug and clear is_corked during socket disconnect so that we
can re-use the context for a new connection.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
set_tcp_sockopt in particular conflicts with libnfs's function of the same
name and prevents a a program from statically linking against both libnfs and
libiscsi.
Similar fix should also go into libnfs.
Remove the flags tests for READ* and replace them with a test for the DPO
and FUA bits.
IF the device claims DPOFUA support in modesense then the READ* CDBs
MUST allow these two flags. IF the device does NOT claim DPOFUA then any
READ* CDB with these flags must fail with invalod field in cdb.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
- Fix UNMAP tests
- Build updates
- Check residuals also when status != GOOD
- Add WSNZ bit to the tests
- Various test updates
- Fix bug in scsi_create_task so it sets cdb_len correctly
- Add a getter function for scsi task status and sense
- Fixes and workarounds for Dell Equallogic issues
- Be more flexible when allowing for unit attentions during connect time
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
We forgot to set task->cdb_size which means all tasks we create with this
function becomes test unit ready :-(
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Dell Equallogic storages may redirect connections from one member of a multi member storage
group to another. When the member that has the volume lead changes the storage issues
an async disconnect request message. The correct behaviour would be to either fail all I/O requests
with a check condition (waiting for logout) or fullfil requests until the time specified
in the disconnect request message has elapsed and then drop the connection. In firwamre 7.x
however the storage sometimes cancels requests with SENSE KEY:ILLEGAL_REQUEST(5)
ASCQ:LOGICAL_UNIT_NOT_SUPPORTED(0x2500). This leads to I/O errors propagated to the application.
This patch was reported in May 2014 to Dell and the initial bug 71409 has been fixed in 7.0.7.
However, the first fix did not entirely solve the problem and bug 73732 has been raised.
This patch adds an environment variable LIBISCSI_DROP_CONN_ON_ASYNC_EVENT1 which if set leads
to an immediate drop of the connection when such an async event is received. This is ugly, but
works around the I/O errors.
Signed-off-by: Peter Lieven <pl@kamp.de>
There is no agreement among the T10 committee whether a SCSI target should
report "invalid opcode", "invalid field in CDB" or "invalid field in
parameter list" if the opcode consists of two bytes. Hence accept all three
sense codes for two-byte opcodes. For more information see also Frederick
Knight, RE: INVALID COMMAND OPERATION CODE, T10 Reflector, 16 May 2008
(http://t10.org/ftp/t10/t10r/2008/r0805167.htm).
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
In the READ CAPACITY response support for logical block provisioning
is indicated via the LBPME (logical block provisioning management
enabled) bit. Since the logical block provisioning VPD page (B2h)
is optional, only query it if LBPME = 1.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
According to RFC 3720 the data associated with a SCSI WRITE command
is sent via Data-Out PDU's. Update log texts accordingly and also
make the capitalization of DataSN consistent with RFC 3720.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
A quote from SPC-4: "When using the MODE SENSE command, a
parameters saveable (PS) bit set to one indicates that the mode
page may be saved by the logical unit in a nonvolatile, vendor
specific location. A PS bit set to zero indicates that the device
server is not able to save the supported parameters. When using
the MODE SELECT command, the PS bit is reserved."
Hence clear the PS bit after having queried a mode page via MODE
SENSE and before changing it via MODE SELECT.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Some implementations may send oversized data coming back from Inquiry.
Warn about this instead of failing the test but then perform additional
checks that the padding MUST be zero or else fail the test.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Lets not use a whitelist of UnitAttentions that we consume during the connect
phase. Instead we can just loop and fail after the 10th.
If there are more than 10 UAs then we have a problem, otherwise
just consume them all, forget them and then pass control back to the caller.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
valgrind does not know that sense will be initialized by the ioctl
so we need to to it explicitely to keep it from warning us.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>