Clear persistent reservations before sending the first SCSI command to the
target to avoid that that command fails due to persistent reservations left
behind by a previous run of the test tool.
Avoid that a subsequent test fails if a test did not remove the persistent
reservations it obtained.
Make sure that clear_pr() returns -1 if clearing persistent reservations
fails.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
In a production system, the examples are not needed.
Add a configure option to disable building the examples.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
When doing a production system, the production environment has been
pre-validated (with this test-toll or by other means), so the teest-tool
is not needed in production.
Add a configure option to disable building test-tool.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
When doing cross-compilation, the tests are meant to be run on the
target. However, they are currently not installed, so it does not make
sense to build tehm to start with.
Additionally, when doing a system for production, those tests are not
needed anyway.
Add a configure option to disable building the tests altogether.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
The ac_cv_-prefix variables are supposed to be settable from the command
line, à-la: ./configure ac_cv_foo=no
The canonical way of doing so is to use AC_CACHE_VAL() or AC_CACHE_CHECK().
The latter is to be preferred in our case, as it handles printing the
message for us.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
The ISCSI_HEADER_SIZE macro accesses iscsi->header_size, so pass it in
as a parameter to make it easier to follow callers.
Signed-off-by: David Disseldorp <ddiss@suse.de>
ISCSI_HEADER_SIZE is determined based on the iscsi->header_digest
setting, which may change via iscsi_process_pdu().
Signed-off-by: David Disseldorp <ddiss@suse.de>
iscsi_create_context() calls srand() every time a new context is
generated. That practice is questionable, as the seed does not need to
change before each call to rand(). As a matter of fact, doing so defeats
the purpose of using rand() altogether. Furthermore, the current
implementation is not thread safe.
This improves ISID generation by using /dev/urandom (when available) as
a seed, and calling srand() only once. In case of errors, fallback to
using something similar to the previous implementation (albeit
thread-safe).
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
strncpy use in iscsi_reconnect is just fine. Do not warn for it, and
also do not warn if clang does not recognize the flag.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
The old code is effectively always posting iser_conn->min_posted_rx
descriptors, since it is
if (outstanding + iser_conn->min_posted_rx <= iser_conn->qp_max_recv_dtos) {
if(iser_conn->qp_max_recv_dtos - outstanding > iser_conn->min_posted_rx)
count = iser_conn->min_posted_rx;
else
count = iser_conn->qp_max_recv_dtos - outstanding;
which is equivalent to
if(iser_conn->qp_max_recv_dtos - outstanding >= iser_conn->min_posted_rx)
if(iser_conn->qp_max_recv_dtos - outstanding > iser_conn->min_posted_rx)
count = iser_conn->min_posted_rx;
else
count = iser_conn->min_posted_rx;
So the "if" is redundant and the "min_posted_rx" is actually behaving more
like a _maximum_ number of posted descriptors in one iser_post_recvm.
Fix it with the (presumably) intended logic and remove a goto along
the way.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
The current random seed for determining a new context's ISID is
calculated by XOR'ing time(), getpid() and "iscsi". When invoked from
iscsi_reconnect(), all three inputs are likely to be identical,
resulting on identical ISIDs.
That happens because iscsi_reconnect() malloc()s a temporary "iscsi"
which is then free()d at the end of the call. Successive calls to
malloc() (from that function) are therefore likely to reuse the same
address for the context.
When multiple sessions are used for different LUNs of the same target,
and reconnects happen within the same second (the precision given by
time()), then multiple login attempts will happen with identical values,
violating the ISID RULE as described in Section 3.4.3 of RFC3270.
This fixes the issue by introducing a sequence number to the ISID seed
generation.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
The current iscsi context in iscsi_reconnect() is called "old_iscsi",
whilst the temporary context is called "iscsi". That is rather
confusing, and this fixes that by calling the current context "iscsi"
and the temporary context "tmp_iscsi".
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
This fixes some identation in iscsi_reconnect_cb() where whitespaces
were used instead of hard tabs.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
When target claim it support maximum writesame length to the total blocks number, when
we trigger 0blocks writesame opertion, we should expect it to be succeed instread of failure.
This test registers PR key and then sends a PR-In read-keys request with
an ALLOCATION LENGTH value that forces response truncation. Ensure that
the ADDITIONAL LENGTH is *not* modified as a result of the truncation.
This test currently passes against TGT but fails against LIO (fix
pending).
Signed-off-by: David Disseldorp <ddiss@suse.de>
When unmarshalling a SCSI_PERSISTENT_RESERVE_READ_KEYS response,
scsi_persistentreservein_datain_unmarshall() assumes that the ADDITIONAL
LENGTH field represents the number of keys packed in the key array.
This is incorrect as key array data buffer may be truncated while
ADDITIONAL LENGTH is left in tact, as per SPC5r17 4.2.5.6:
If the information being transferred to the Data-In Buffer includes
fields containing counts ..., then the contents of these fields shall
not be altered to reflect the truncation, if any, that results from an
insufficient ALLOCATION LENGTH value, unless the standard that
describes the Data-In Buffer format states otherwise.
Determine the number of keys returned based on the minimum of the
data-in length and the ADDITIONAL LENGTH value.
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>
The helper function -2 return paths already print this message, so the
duplicate in the caller can be dropped.
Signed-off-by: David Disseldorp <ddiss@suse.de>
The code was implicitly dependent on container_of from
inifiniband/verbs.h, however that's been removed in rdma-core
latest release:
ce0274acff
Define container_of locally if it's not already defined
Make sure that the end-of-LUN test happens at the end of the LUN instead
of at the start of the LUN.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Since the argument num_blocks - i is passed as the LBA argument
to COMPAREANDWRITE(), avoid that a negative number is passed.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Avoid that building with gcc 7 fails as follows:
iscsi-dd.c: In function 'cscd_ident_inq':
iscsi-dd.c:405:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (prev_type <= desig->designator_type) {
^
iscsi-dd.c:409:4: note: here
default:
^~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>