Type 0x0A segment descriptors provide a 32-bit wide number-of-bytes
field, allowing for much larger copy offloads with a single segment
descriptor.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The SPC4r37 specification defines XCOPY Segment Descriptor lengths for
each SD type. The spec defined SD lengths don't account for the four SD
header bytes. To make it easier to match the spec to the implementation,
use the spec defined lengths in get_desc_len() with a four byte SD
header addition.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Declare dynamically allocated strings as 'char *' instead of 'const char *'.
Remove the discard_const() macro. Do not test whether or not a pointer is
NULL before calling free() because it is allowed to pass NULL to free().
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Since it is easy to trigger a stack overflow with variable-length arrays,
use dynamic memory allocation instead of VLAs. Add -Wvla to the compiler
options such that no new VLAs get introduced.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
All users have now been changed to overload via the iscsi_ctx transport
callback, so the dlsym based overloading can now be dropped.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Accepting an Allocation Length parameter allows us to test for
truncation of response data, as per SPC5r17 4.2.5.6:
The device server shall terminate transfers to the Data-In Buffer when
the number of bytes or blocks specified by the ALLOCATION LENGTH field
have been transferred or when all available data have been
transferred, whichever is less.
With this change, all existing prin_read_keys() callers continue to use
same ALLOCATION LENGTH value as earlier (16K).
Signed-off-by: David Disseldorp <ddiss@suse.de>
<iscsi-url> parameter absent handled for SCSI devices.
* Verbose logging segfault fixed.
* For ioctl case, if reservation conflicts hits it is not considered as
test case failure.
We do need a default: arm here as the switch is not supposed to deal with
all possible values for the enum.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
We need to use iovectors for iSER to work as it requires that the vectors
are attached to the task before we queue the task.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
The iscsi cmdsn tests are noisy and generate a lot of [FAILURE]
warnings for things that are expected.
Fix this by do the plumbing to allow using a EXPECT_STATUS_TIMEOUT
for commands we expect will never be replied to and will thus time out.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Move the scsi_free_scsi_task() call from receive_copy_results() to the
callers of this function to avoid that accessing the unmarshalled data
triggers a use-after-free.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
The test tool is simplistic and uses the synchronous API. In this API
we will only poll() the socket and process events during the lifetime of any
iscsi_*_sync() calls.
A problem with this approach arises with multipath tests. When iscsi-test-cu
is used with multiple devices we will first open a session for each
multipath leg, but then as most tests are only using the first device we end
up with creating secondary sessions we don't do any iscsi_*_sync() calls on
for very long times. If a target is set up to send NOPs on these
secondary paths it will not get any responses and eventually tear down the
connection.
To avoid this, try to make sure we service any secondary paths we have
created by calling iscsi_service(POLLIN|POLLOUT) every few seconds
to make sure we do service and respond to any NOPs.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
test_iscsi_tur_until_good() dispatches TUR requests until the target has
cleared all UAs for the given sd, or the maximum number of retries is
reached.
This helper function is useful for any test that needs to deal with UAs
(e.g. PRs), so should be moved out into common code.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Issue a Persistent Reservation Out PREEMPT request, with keys and type
provided.
PREEMPT allows for the removal of registrations, and replacement of
reservations.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Issue a Persistent Reservation In REPORT CAPABILITIES request and parse
the response. Callers can obtain the unmarshalled response data via the
_rcaps parameter.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The test_report_supported_opcodes_one_command() sends SCSI commands
to the target for which the target has to reply with ILLEGAL REQUEST
/ INVALID FIELD IN CDB. Avoid that such a reply is misinterpret as
"command not supported" by checking the field offset in the sense
descriptor. See also patch "test tool: Detect unsupported opcodes
correctly" (commit ID fe9620092c).
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Extend struct scsi_sense with sense specific descriptor information,
introduce the function scsi_parse_sense_data() and let that function
parse the sense specific descriptor.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
I didn't set up the transfer length properly for the vectored SG_IO
support in the previous patch, which makes some implementations
of the ioctl unhappy. Fix this up per the spec.
Command like PERSISTENT RESERVE OUT fill out DATA OUT data in their
CDB setup routine, but the SG_IO code doesn't look at that, leading
to a segfault when issueing such commands. Fix this by copying over
some code from the iSCSI path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
This allows all tests to properly work on /dev/sg nodes instead
of segfaulting when a test is written the iSCSI-specific APIs.
Signed-off-by: Christoph Hellwig <hch@lst.de>
The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.
When libscsi is built using clang instead of gcc, those errors are reported:
iscsi-perf.c:256:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
comparison of array 'iscsi_url->user' not equal to a null
pointer is always true [-Werror,-Wtautological-pointer-compare]
Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.
Signed-off-by: Stefan Weil <sw@weilnetz.de>