Commit Graph

1855 Commits

Author SHA1 Message Date
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
Ronnie Sahlberg
6da503eba5 Merge pull request #283 from yann-morin-1998/yem/no-test
buildsys: add options to disable part of the build, fix cunit detection
2019-02-05 13:10:11 +10:00
Ronnie Sahlberg
d397e7d369 Merge pull request #284 from bvanassche/master
Three bug fixes for the libiscsi test tool
2019-02-05 13:08:58 +10:00
Bart Van Assche
16435a917d iscsi-test-cu: Improve persistent reservation clearing
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>
2019-01-13 11:53:09 -08:00
Bart Van Assche
1bd1232a2a Move the clear_pr() function definition
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:52:47 -08:00
Bart Van Assche
663aad13ba Avoid that iscsi_reconnect() crashes
In the else branch, set the tmp_iscsi->old_iscsi pointer instead of the
iscsi->old_iscsi pointer.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:48:28 -08:00
Bart Van Assche
a15c2a5c61 test-tool/test_prin_read_keys_truncate: Do not crash if PERSISTENT RESERVE IN fails
Do not try to dereference the 'rk' pointer if it is NULL.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2019-01-13 11:48:08 -08:00
Yann E. MORIN
a8d54cc82d buildsys: add option to enable/disable building the examples
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>
2018-12-04 10:47:34 +01:00
Yann E. MORIN
eec4954986 buildsys: add option to enable/disable build of test-tool
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>
2018-12-04 09:27:32 +01:00
Yann E. MORIN
fb2e460df9 buildsys: add option to enable/disable building tests
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>
2018-12-04 09:27:32 +01:00
Yann E. MORIN
b8a28fad54 buildsys: handle ac_cv_cunit as a true cache-val
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>
2018-12-04 09:27:30 +01:00
Ronnie Sahlberg
ac9a8e5aed Merge pull request #279 from ddiss/fix-nopin-data
fix NOP-In data segment handling and cleanup ISCSI_HEADER_SIZE usage
2018-10-30 09:08:47 +10:00
David Disseldorp
9d31150e9d socket: improve ISCSI_HEADER_SIZE readability
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>
2018-10-25 23:38:59 +02:00
David Disseldorp
009892b017 socket: calculate hdr_size once per PDU process loop
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>
2018-10-25 23:38:59 +02:00
David Disseldorp
96dc6e7ebd socket: check for malloc failure before dereference
Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-10-25 23:38:59 +02:00
David Disseldorp
d7530757df examples: don't assume NOP-In data is zero terminated
Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-10-25 23:38:59 +02:00
David Disseldorp
15021faf19 lib: properly pass through NOP-In data segment
data_pos corresponds to the data_segment_length (+ padding), so should
always be passed to the NOP-In callback if greater than zero.

Fixes: https://github.com/sahlberg/libiscsi/issues/278

Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-10-25 23:38:41 +02:00
Ronnie Sahlberg
04d6c326b8 Add some missing includes
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2018-10-17 05:43:10 +10:00
Ronnie Sahlberg
83dbc4ff84 Merge pull request #275 from franciozzy/isid_2
Call srand() only once
2018-10-17 05:39:44 +10:00
Ronnie Sahlberg
6fa5eaff13 Merge pull request #274 from bonzini/for-gcc-8
Fix warnings from Coverity and GCC 8
2018-10-09 08:11:58 +10:00
Felipe Franciosi
41af44eba1 iscsi_create_context: call srand() only once
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>
2018-10-05 18:10:07 +01:00
Paolo Bonzini
bffafc1c30 avoid truncation when logging message that includes target name 2018-10-04 14:06:39 +02:00
Paolo Bonzini
679d0abe7c avoid fallthrough 2018-10-04 14:06:39 +02:00
Paolo Bonzini
4728d4eaa6 do not warn for strncpy
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>
2018-10-04 14:06:39 +02:00
Paolo Bonzini
f507c94774 sync: remove unnecessary checks
state is always non-NULL in iscsi_sync_cb and iscsi_discovery_cb.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-10-04 14:06:39 +02:00
Paolo Bonzini
f0fcee72c4 iser: fix posting of receive descriptors
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>
2018-10-04 14:06:39 +02:00
Ronnie Sahlberg
a7a14cc66c Merge pull request #271 from SexyC/master
Fix the 0 blocks writesame failed when target claims supporting maxim…
2018-10-02 06:45:14 +10:00
Ronnie Sahlberg
8f8632f0be Merge pull request #273 from franciozzy/isid_fix
Isid fix
2018-10-02 06:43:59 +10:00
Ronnie Sahlberg
29c0075ce7 Merge pull request #272 from franciozzy/reconnect_fixes
Reconnect fixes
2018-10-02 06:43:21 +10:00
Paolo Bonzini
346fb947cb iser_rcv_completion: unify error handling
Move the iscsi_set_error to iser_post_recv, and avoid leaking the
input buffer "in".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-10-01 13:22:36 +02:00
Felipe Franciosi
50fb64df91 iscsi_create_context: improve ISID randomness
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>
2018-09-30 19:32:06 +01:00
Felipe Franciosi
1891d502a0 iscsi_reconnect: improve local variable naming
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>
2018-09-30 11:38:38 +01:00
Felipe Franciosi
b377eece90 lib/connect.c: Fix whitespace formatting
This fixes some identation in iscsi_reconnect_cb() where whitespaces
were used instead of hard tabs.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2018-09-30 11:12:30 +01:00
yayang1
8a3375e459 Fix the 0 blocks writesame failed when target claims supporting maximum writesame length to LUN's total blocks number.
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.
2018-09-28 02:31:28 +00:00
Ronnie Sahlberg
36548b4669 Merge pull request #267 from ddiss/prin_readkeys_truncate
fix handling of and test truncated PR-in read-keys responses
2018-06-01 08:04:27 +10:00
David Disseldorp
ab0e40d689 test-tool: add PrinReadKeys.Truncate test
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>
2018-05-31 23:31:17 +02:00
David Disseldorp
c88e9715ab lib/scsi: fix SCSI_PERSISTENT_RESERVE_READ_KEYS handling
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>
2018-05-31 23:10:28 +02:00
David Disseldorp
31ab1e1ac9 test-tool: add prin_read_keys() allocation_len parameter
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>
2018-05-31 23:08:39 +02:00
David Disseldorp
58642c6d72 tests: drop duplicate PR-unsupported log messages
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>
2018-05-29 16:43:19 +02:00
Ronnie Sahlberg
054528ed2d Merge pull request #265 from crobinso/container_of
iser: Use local container_of definition
2018-05-01 09:23:43 +10:00
Cole Robinson
f1feb218e2 iser: Use local container_of definition
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
2018-04-30 18:11:05 -04:00
Ronnie Sahlberg
8d5d0b241d Merge pull request #263 from bvanassche/master
Various fixes for the libiscsi test tool
2018-03-07 13:19:39 +10:00
Bart Van Assche
4d1918859f test-tool: Avoid crashes due to NULL-pointer dereferences
Avoid that certain test failures cause the test tool to trigger a
segmentation fault.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:25 -08:00
Bart Van Assche
8f2abea4de test-tool/test_compareandwrite_simple: Limit the number of blocks used
Make sure that 'maxbl' does not exceed the LUN capacity.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:25 -08:00
Bart Van Assche
18de10174b test-tool/test_compareandwrite_simple(): Fix end-of-LUN test
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>
2018-03-02 14:02:22 -08:00
Bart Van Assche
8f468b14fc test-tool/test_compareandwrite_*: Stop at end of medium
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>
2018-03-02 14:02:18 -08:00
Bart Van Assche
fee9eb9423 test-tool/test_async_lu_reset_simple: Continue upon reconnect error
Instead of stopping all tests if a reconnect fails, only stop
test_async_lu_reset_simple.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:18 -08:00
Bart Van Assche
ba8cac6b05 test-tool, check_result(): Make failure output more informative
If a SCSI command fails, report the SCSI status code.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
2018-03-02 14:02:18 -08:00
Bart Van Assche
3cd40965a0 libiscsi: Port to gcc 7
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>
2018-03-02 14:02:18 -08:00
Ronnie Sahlberg
7e459df828 Add iscsi_set_no_autoreconnect to the def and syms files
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2018-01-06 07:44:44 +10:00