Commit Graph

2010 Commits

Author SHA1 Message Date
David Disseldorp
957cc96232 test-tool: add COMPARE AND WRITE MiscompareSense test
This test checks regular sense/ascq values on miscompare as well as
the Information sense field, which should be set as follows:
  sense key set to MISCOMPARE and the additional sense code set to
  MISCOMPARE DURING VERIFY OPERATION. In the sense data (see 4.18 and
  SPC-5) the offset from the start of the Data-Out Buffer to the first
  byte of data that was not equal shall be reported in the INFORMATION
  field.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:58 +02:00
David Disseldorp
53c58f8aea lib: parse Information fixed sense field
This field is documented in SPC-5 (r17 4.4.3). Unlike the descriptor
type, the fixed Information field is four bytes wide.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:58 +02:00
David Disseldorp
6eb4b7b6e5 lib: parse Information sense descriptor type
The Information descriptor type is defined in SPC-5 (r17 4.4.2.2) and
may be used to provide the data offset on COMPARE_AND_WRITE miscompare.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:54:18 +02:00
David Disseldorp
02b9b01fa1 lib: check length for sense key specific sense data descriptors
Explicitly check that the sense data descriptor ADDITIONAL LENGTH field
matches the expected value for sense key specific sense data
descriptors.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:37:13 +02:00
David Disseldorp
34a632a04e lib: drop generic sense data descriptor VALID check
According to SPC-5 (r17), the sense data descriptor format follows:
byte	field
----	-----
0:	DESCRIPTOR TYPE
1:	ADDITIONAL LENGTH
2-n:	Sense data descriptor specific

The VALID bit is a sense data descriptor specific flag, and is not
present in the only sense data descriptor supported by libiscsi -
Sense key specific sense data descriptors.
Drop the generic VALID bit check, in preparation for handling it on
a sense data descriptor specific basis.

Suggested-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-10-19 14:23:12 +02:00
Bart Van Assche
971bac8cfb Merge pull request #343 from almilos/fix-sbc3-check
test-tool: add version descriptor checks for more SBC-3 versions
2020-09-11 14:57:12 -07:00
Aleksandr Miloserdov
f342056a52 test-tool: add version descriptor checks for more SBC-3 versions
If device claims SBC-3 version in its version descriptors it won't be marked as SBC-3 compliant.

This commit adds checks for:
* SBC-3 T10/BSR INCITS 514 revision 35
* SBC-3 T10/BSR INCITS 514 revision 36
* SBC-3 ANSI INCITS 514-2014
2020-09-11 13:26:26 +03:00
Bart Van Assche
2a34e8fe1e Merge pull request #342 from heroin-moose/fix-iscsi-cmdsn-tests
test-tool: Fix CmdSN tests
2020-09-03 17:14:06 -07:00
Consus
859070854d test-tool: Fix CmdSN tests
After commit 10868c491d CmdSN tests no
longer work because iscsi->cmdsn is incremented during the second test
phase (sending "good" TUR after "bad" TUR), so the resulting CmdSN is
not ExpCmdSN, but ExpCmdSN + 1 that is not acknowledged by the target.
This commit fixes the issue by setting iscsi->cmdsn to iscsi->expcmdsn - 1.

Affected tests:

 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooLow
 * iSCSI.iSCSIcmdsn.iSCSICmdSnTooHigh
2020-09-03 09:56:52 +03:00
Dharmesh Shah
5553d6bddf test-tool/test_async_lu_reset_simple: Move an assert statement
In the test iSCSI.iSCSITMF.LUNResetSimpleAsync
CU_ASSERT_EQUAL(reconnect_succeeded, 1) must be called after the async
TMF command completes. Hence move that assert into the TMF completion
callback.

This patch fixes a race condition.

[bvanassche: edited commit message]
2020-09-01 13:37:20 -07:00
Bart Van Assche
b5cd42e103 Remove an unused function from the iSER code
This was detected by clang.

Fixes: 68ce3363aa ("iser: dynamic memory region allocator")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-08-18 20:03:53 -07:00
Bart Van Assche
17fd81a69d Merge pull request #339 from ddiss/async_logout_during_write
test-tool: Add LogoutDuringIOAsync
2020-08-18 19:06:26 -07:00
David Disseldorp
54b3dcaa30 test-tool: add LogoutDuringIOAsync test case
This attempts to reproduce upstream LIO reports of a use after free bug
when logout occurs alongside concurrent I/O.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 17:12:28 +02:00
David Disseldorp
4080c09839 test-tool: rename async write dispatch/complete counters
Add an io_ prefix, to differentiate between I/O and future iSCSI Logout
request tracking.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 16:43:54 +02:00
Bart Van Assche
3f50a1462c Merge pull request #338 from ddiss/pdu_cancel_use_after_free
pdu: Fix use after free during cancellation
2020-08-18 07:00:27 -07:00
David Disseldorp
87272919ad pdu: fix use after free during cancellation
Fixes: 10868c4 ("libiscsi: Avoid discontinuities in cmdsn ordering in some cases")
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-18 15:38:43 +02:00
sanjay-cpu
e9cefe7e42 .travis.yml: Also build for the ppc64le architecture
[ bvanassche: Added amd64 architecture and edited commit message ]
2020-08-12 20:07:10 -07:00
Bart Van Assche
44facb175b Merge pull request #335 from qiankehan/iscsi-ls
iscsi-ls: Fix iser url scheme parsing
2020-08-12 19:59:57 -07:00
Bart Van Assche
fb0f3691ed Merge pull request #334 from heroin-moose/fix-hardcoded-block-size
test-tool: Use block_size instead of hardcoded 512 bytes
2020-08-11 18:35:51 -07:00
Bart Van Assche
0749990afb Merge pull request #333 from ddiss/iscsi-dd-cleanup
Iscsi-dd cleanup
2020-08-11 18:34:32 -07:00
Han Han
6db782bb0a iscsi-ls: Fix iser url scheme parsing
Libiscsi supports to parse two iscsi url schemes: 'iscsi://' and 'iser://'.
Fix the missing iser parsing, introduced from 12222077.

Signed-off-by: Han Han <hhan@redhat.com>
2020-08-11 21:57:12 +08:00
Consus
9e160e02b6 test-tool: Use block_size instead of hardcoded 512 bytes
Fix another couple of tests that fail on 4Kn drives:

* iSCSI.iSCSITMF.AbortTaskSimpleAsync
* iSCSI.iSCSITMF.LUNResetSimpleAsync
2020-08-10 15:59:49 +03:00
David Disseldorp
37e6e112b6 examples/iscsi-dd: use common init function for src and dst endpoints
Remove a bunch of duplicate code by sharing a function for source and
destination endpoint initialization.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-10 01:18:06 +02:00
David Disseldorp
eb4c8e20ff examples/iscsi-dd: use common iscsi_endpoint struct
Signed-off-by: David Disseldorp <ddiss@suse.de>
2020-08-10 00:35:28 +02:00
Ronnie Sahlberg
c54c4cd202 iscsi-perf: Add explicit casts to avoid two warnings
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-07-31 09:21:33 +10:00
Bart Van Assche
76f9578d1c Merge pull request #332 from bytedance/fix_cancellation_handling
Fix cancellation handling
2020-07-18 20:04:29 -07:00
Xie Yongji
ee47dc7338 socket: Make the pdu timeout handling aware of old iscsi context
We should check the pdus in old iscsi context when
scanning timeout tasks during reconnecting.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
2020-06-23 19:49:07 +08:00
wanghonghao
aad136e5b9 libiscsi: Make the cancellation aware of the pdus in old iscsi context
We should check the pdus in old iscsi context when
cancelling tasks.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-06-23 19:48:26 +08:00
Xie Yongji
e9c1f10258 pdu: Remove the checking for iscsi->is_loggedin in iscsi_cancel_pdus()
I don't see any problems that calling the callback
during connect/login in iscsi_cancel_pdus(). So let's
remove this check. Otherwise, we have no way to be aware
of a cancellation during login and cause something like
iscsi_login_sync() hangs.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
2020-06-23 19:45:18 +08:00
Xie Yongji
10868c491d libiscsi: Avoid discontinuities in cmdsn ordering in some cases
We should plug the cmdsn gap in order to continue
to use the session when the pdus is cancelled before
sending out.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
2020-06-23 19:45:14 +08:00
Bart Van Assche
0e9b29751c Merge pull request #331 from heroin-moose/fix-block-size
test-tool: Use block_size instead of hardcoded 512 bytes
2020-06-17 07:04:40 -07:00
Consus
7258fbfd83 test-tool: Use block_size instead of hardcoded 512 bytes
This commit fixes some tests (like ProutReserve) on pure 4k devices.
2020-06-17 15:50:44 +03:00
Bart Van Assche
bddbc01829 Merge pull request #330 from tmakatos/master
assorted RPM fixes
2020-06-05 21:13:44 -07:00
Thanos Makatos
9705017e37 exclude ld_iscsi.so from RPM
This is an omission from commit
e6bcdf5fdb.

Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-06-02 02:33:27 -07:00
Thanos Makatos
f82a899fc5 include iser-private.h in make dist tarball
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-06-01 05:58:01 -07:00
Bart Van Assche
33c66f2c39 test-tool, compare and write: Reduce maximum number of blocks from 256 to 255
Since the NUMBER OF LOGICAL BLOCKS field in the COMPARE AND WRITE command
is an 8 bit field, the maximum value that can be encoded is 255.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-21 18:39:49 -07:00
Bart Van Assche
b4d59cd29c test_compareandwrite_invalid_dataout_size: Simplify this test
Assign the NUMBER OF LOGICAL BLOCKS field in the COMPARE AND WRITE PDU
directly. Use the terminology from SBC-4, namely NUMBER OF LOGICAL BLOCKS
instead of TL.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-21 18:39:49 -07:00
Bart Van Assche
9fcdce3101 test-tool: Use asprintf() in sg_send_scsi_cmd()
Use asprintf() instead of snprintf() + strdup().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-15 10:40:00 -07:00
Bart Van Assche
b9effb556f test-tool: Fix a comment in sg_send_scsi_cmd()
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:50:57 -07:00
Bart Van Assche
6aa5acb659 test-tool: Split send_scsi_command()
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-14 11:47:56 -07:00
Bart Van Assche
e61d5d6241 Merge pull request #328 from bytedance/fix_rewrite_immediate_pdu_cmdsn
socket: fix rewrite cmdsn of immediate pdus
2020-05-14 10:37:25 -07:00
wanghonghao
7e59b9bd23 socket: fix rewrite cmdsn of immediate pdus
Cmdsn of a data-out pdu struct is less than `expcmdsn` since it's from its
cmd pdu. A data-out pdu doesn't carray a cmdsn on the wire actually, so it
doesn't matter to itself, but if we rewrite the cmdsn of a immediate pdu with
it, it will cause an error.

Related error logs:
libiscsi: iscsi_write_to_socket: outqueue[0]->cmdsn < expcmdsn (3648bab5 < 3648bab9) opcode 00 [iqn.2003-01.org.linux-iscsi.tgt0]
libiscsi: reconnect initiated [iqn.2003-01.org.linux-iscsi.tgt0]
libiscsi: connecting to portal 127.0.0.1 [iqn.2003-01.org.linux-iscsi.tgt0]
libiscsi: connection established (127.0.0.1:62404 -> 127.0.0.1) [iqn.2003-01.org.linux-iscsi.tgt0]

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-05-09 12:22:00 +08:00
Bart Van Assche
4db1e0a463 Merge pull request #325 from bytedance/iser_fix_chap_and_reduce_mallocs
iSER: fix compatibility with CHAP and eliminate unnecessary memory allocations
2020-04-14 19:00:03 -07:00
wanghonghao
a22a9bb7db iser: eliminate unnecessary memory allocations
Allocate `iser_pdu` from small allocation pool.
Lifecycle of `iscsi_in_pdu` is inside the function in iSER transport. Allocate
it on stack.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-14 18:49:10 +08:00
wanghonghao
2b9b097c35 iser: use login_resp_buf until login is finished
This commit is to fix compatibility with CHAP.

iSER transport only post `login_resp_buf` (which is larger than `rx_desc`) as
work request (WR) once, but there may be multiple requests and responses during
login phase (e.g. when CHAP is used) and login can't be finished in such cases.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-14 18:49:03 +08:00
Bart Van Assche
ce09f48f02 Merge pull request #324 from bytedance/iser_conn
Fix iSER connection establishment
2020-04-11 08:59:44 -07:00
wanghonghao
a03744c80a init: free iscsi->opaque before check mallocs/frees counter
Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-11 12:46:44 +08:00
wanghonghao
0659c74302 reconnect: collect mallocs/frees of the previous reconnection
Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-11 12:46:44 +08:00
wanghonghao
843a01cbd8 iser: aggregate ack completion queue (CQ) events
Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-11 12:46:40 +08:00
wanghonghao
bd9524b4ce iser: free tx_desc of queued/inflight pdus
tx_desc and memory region buffer assigned to iser pdus should be given back to
tx_desc list and allocator before free all memory regions.
This may happend during reconnecting/disconnecting.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-11 12:46:34 +08:00