404 Commits

Author SHA1 Message Date
Peter Lieven
247133c9e2 feat: allow targetname redirect
this patch adds an non-RFC extenstion to the redirect login response which allows
a target to temporarily redirect not only to a different target address but also to
a different targetname.

This is needed to allow scenarious in active/active storage clusters where each
node had its own targetname, but maps the same volumes behind equal LUN ids.

For this non-RFC behaviour the environment variable LIBISCSI_ALLLOW_TARGETNAME_REDIRECT
has to be set.

Signed-off-by: Peter Lieven <pl@dlhnet.de>
2025-09-11 19:51:00 +00:00
Peter Lieven
8c4e2ad46b feat: read and validate unit serial number after login
this patch adds a read of VPD page 0x80 (unit serial number) after successful login.

The serial is then validated on secutive reconnects to avoid the accidental mismatch
of LUN ids if some kind of remapping appears between loss of connection and a later
reconnect.

An additional url parameter force_usn is added to enforce the usn right from the beginning.
If not set via url or the new iscsi_set_unit_serial_number function the usn is learned
at the first successful login.

Signed-off-by: Peter Lieven <pl@dlhnet.de>
2025-09-11 15:15:42 +00:00
sahlberg
a8c3920ab8 Write the PDU directly to the socket if the socket is idle.
Signed-off-by: sahlberg <sahlberg@r10-0-1.rocky10.sahlberg>
2025-07-15 19:26:46 +10:00
Anatoliy Glagolev
19d05ab7a7 RTPG support
Implementing support of the Report Target Port Groups command.

Tested on Ubuntu against Pure Storage Flash Array
using designated unit tests and new iscsi-rtpg utility

./iscsi-rtpg  -i iqn.2005-03.org.open-iscsi:6feb2db21ea iscsi://192.168.1.12/iqn.2010-06.com.purestorage:flasharray.4e8d52d82e4b2c0f/1
RTPG retrieved 2 groups
Group 0x0000: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x10 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4a 0x4b 0x4c
0x4d 0x4e 0x4f 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67
0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71]
Group 0x0001: preferred 0, format 0x00, ALUA state ACTIVE-OPTIMIZED,flags 0x8f, status code 0x02, port count 65
Ports: [ 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x20 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7a
0x7b 0x7c 0x7d 0x7e 0x7f 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90 0x91 0x92 0x93 0x94 0x95
0x96 0x97 0x98 0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0 0xa1 0xa2]
2025-07-03 17:20:52 -06:00
lishiao
a81eacc0b1 iscsi: compute Data Digest for out_data segments 2025-06-17 11:57:38 +08:00
lishiao144
676afd07a0 Signed vs. unsigned byte mismatch in CHAP_R comparison 2025-05-29 11:50:20 +08:00
lishiao144
b4d1cd7907 MAX_CHAP_R_SIZE updata 2025-05-28 15:57:40 +08:00
Ronnie Sahlberg
fa37a2136c Apple: use mutexes instead of spinlocks on apple
Apple do not support spinlocks so we must remap to the much slower
mutexes instead if we think we are compiling for apple.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-05-03 20:49:46 +10:00
Ronnie Sahlberg
d5e3bf6175 Merge branch 'tst' 2025-04-26 11:30:58 +10:00
Ronnie Sahlberg
edd7d9b843 Remove the small allocations
This is not compatible with multithreading and would require a complete
re-design.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
8047421868 Protect some variables in iscsi_context by the spinlock
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
91cc1e4197 Protect outqueue and waitpdu with a spinlock
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
4593746363 Add spinlock primitives
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
3fc5d2996b iscsi_queue_pdu() can never fail, make it void
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
09ec037e34 Make the mutex symbols always available
so we do not need to wrap them inside an ifdef.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
1f91358c8a Flag variables in iscsi_context for multithreading audit
These variables may need to be protected by a mutex.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Ronnie Sahlberg
3c48aea225 Add initial multithreading support and example
This is the basic support for doing i/o in a separate worker thread.
It is still not threads safe but a start.
Now we need to protect all variables such as outqueue, waitpdu
and friends.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-04-26 08:56:16 +10:00
Peter Lieven
eb0853e36e fix: use correct maximum length for TargetName and InitiatorName
Signed-off-by: Peter Lieven <pl@dlhnet.de>
2025-03-26 13:28:23 +00:00
Ronnie Sahlberg
cb44ad4e26 Add multithreading helpers
Add an abstraction for mutexts and threads
that handles both pthread api and native win32 api

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-03-07 08:46:47 +10:00
Ronnie Sahlberg
b8d9fbf5e3 Add CHAP SHA3-256 support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-01-04 14:20:28 +10:00
Ronnie Sahlberg
34e83f7dbd Add support for CHAP with SHA-256
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-01-04 09:09:02 +10:00
Ronnie Sahlberg
95a0d98cfd Add support for CHAP using SHA1
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2025-01-04 00:59:02 +10:00
hongleiwang
29e626c0f4 feat: add iscsi_reset_next_reconnect interface
When an iSCSI connection enters the reconnection phase, the backoff
time (next_reconnect) increases with reconnection retry_cnt. However,
if the client detects that the target has recovered before reaching
next_reconnect, calling iscsi_reconnect/iscsi_force_reconnect has no
any effect, making fast reconnection impossible.

This patch introduces an interface to reset next_reconnect, so that
the client can reset the backoff time upon detecting target recovery
and achieve faster reconnection.

Resolves: https://github.com/sahlberg/libiscsi/issues/428

Signed-off-by: raywang <honglei.wang@smartx.com>
2024-10-30 18:29:33 +08:00
Ronnie Sahlberg
2227e7bda2 Merge pull request #400 from anatoliy-glagolev/master
lun_reset cancelling lun tasks only
2024-05-30 07:48:24 +10:00
Brian Meagher
882bcad53a Add support for Data Digest 2024-05-04 19:34:06 -07:00
zhenwei pi
a6a664e8cb Abstract value_string as common utility
Originally, we use this in scsi-lowlevel.c only, this works as static
function. It also could be used to dump ISCSI opcode, so move it into
common utils.h/utils.c.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-12-01 10:13:20 +08:00
zhenwei pi
283e99b322 Introduce helper function scsi_opcode_str
Convert SCSI opcode into string for trouble shooting.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-11-03 12:17:38 +08:00
Anatoliy Glagolev
35cf3a401c lun_reset cancelling lun tasks only
The existing implementation of iscsi_task_mgmt_lun_reset_async cancels
all tasks in ready-to-send and wait-for-completion queues.
If the ISCSI context has in-flight tasks for a different LUNs or
tasks that are not LUN-specific (such as NOPIN, NOPOUT), those tasks
are not supposed to be affected by the LUN reset.
Also, the tasks for the LUN being reset may have in-flight responses
not affected by a concurrent LUN reset; they have to be handled
accordingly.

This change cancels only the tasks for the LUN being reset if they are
in the ready-to-send queue ('outqueue'). The tasks in the wait-for-
completion queue should be cancelled on LUN reset completion.
For example:

    iscsi_task_mgmt_lun_reset_async(iscsi, lun, lun_reset_cb, ctxt);
    ....
....
void lun_reset_cb(struct iscsi_context * iscsi, int status,
                  void * command_data, void * private_data)
{
    // 'response' field per ISCSI spec rfc7143 section 11.6.1
    uint8_t iscsi_response = *(uint8_t *)command_data;
    if (iscsi_response == 0) {
        // The LUN has been reset. No further replies are expected
        // for in-flight tasks for that LUN. Explicitly cancelling
        // the tasks in wait-for-completion queue.
        for (.. scsi_task-s in flight ..) {
            iscsi_scsi_cancel_task(iscsi, task);
        }
    } ...
}
2023-09-26 15:03:30 -06:00
Anatoliy Glagolev
e4c4799f29 checking if task is in outqueue
Users need to check if a task is queued to send (not sent yet)
before invoking functions such as iscsi_task_mgmt_abort_task_async.
Otherwise, because task management requests are automatically
treated as "immediate", a request to abort a task is sent before
the task itself.

if (iscsi_scsi_is_task_in_outqueue(iscsi_, task_)) {
    iscsi_scsi_cancel_task(iscsi_, task_);
} else {
    iscsi_task_mgmt_abort_task_async(iscsi_, task_, AbortCb, context_);
}
2023-09-20 12:24:26 -06:00
zhenwei pi
7bf8091013 Add iscsi_set_fd_dup_cb
libiscsi is widely used by poll driven, include libiscsi itself,
QEMU. Using poll works fine after iscsi reconnect, but it does not work
in epoll, because the epoll event has been removed during duplicating
file descriptor in kernel.

Add a new function iscsi_set_fd_dup_cb to set callback, then uplayer
gets notified after duplicating. The following codes reproduce this
issue, and test this patch by compiling flags -DISCSI_FD_DUP_CB.

static void iscsi_epoll_event(struct iscsi_context *iscsi, int epollfd, bool new)
{
	static int epoll_event;
	struct epoll_event ev = { 0 };
	int pevent = iscsi_which_events(iscsi);
	int event = 0;

	if (pevent & POLLIN)
		event |= EPOLLIN;

	if (pevent & POLLOUT)
		event |= EPOLLOUT;

	ev.events = event;
	ev.data.fd = iscsi_get_fd(iscsi);
	if (new)
		epoll_ctl(epollfd, EPOLL_CTL_ADD, ev.data.fd, &ev);
	else if (epoll_event != event) {
		epoll_ctl(epollfd, EPOLL_CTL_MOD, ev.data.fd, &ev);
	}
	epoll_event = event;
}

static void iscsi_tsk_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data)
{
	printf("iscsi_tsk_cb status %d\n", status);
	exit(0);
}

static void iscsi_fd_dup_cb(struct iscsi_context *iscsi, void *opaque)
{
	int epollfd = *(int *)opaque;

	iscsi_epoll_event(iscsi, epollfd, true);
}

static void iscsi_on_pollout(struct iscsi_context *iscsi, struct iscsi_url *iscsi_url, int epollfd)
{
	static struct scsi_task *tsk = NULL;

	iscsi_service(iscsi, POLLOUT);
	if (!tsk) {
		tsk = iscsi_readcapacity16_task(iscsi, iscsi_url->lun, iscsi_tsk_cb, NULL);
		assert(tsk);
	}
}

int main(int argc, char *argv[])
{
	struct iscsi_context *iscsi;
	struct iscsi_url *iscsi_url;
	struct epoll_event ev, revent;
	int epollfd;

	iscsi = iscsi_create_context("dummy");
	assert(iscsi);

	iscsi_url = iscsi_parse_full_url(iscsi, argv[1]);
	assert(iscsi_url);

	iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL);
	iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
	assert(!iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun));

	epollfd = epoll_create1(0);
	iscsi_epoll_event(iscsi, epollfd, true);

	iscsi_set_fd_dup_cb(iscsi, iscsi_fd_dup_cb, &epollfd);
	iscsi_reconnect(iscsi);

	while (epoll_wait(epollfd, &revent, 1, 100) >= 0) {
		if (revent.events & EPOLLIN)
			iscsi_service(iscsi, POLLIN);

		if (revent.events & EPOLLOUT)
			iscsi_on_pollout(iscsi, iscsi_url, epollfd);

		iscsi_epoll_event(iscsi, epollfd, false);
	}

	return 0;
}

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2023-06-06 13:29:52 +08:00
John Levon
30dd7c6429 add iscsi_force_reconnect()
If a connection attempt is hung, then iscsi_reconnect() won't do anything. This
makes sense if we'd just re-try to connect to the same target, but if (for
example) login redirect might point us to a different, healthy, target, it
should be possible to restart the full connection process on request.

Signed-off-by: John Levon <john.levon@nutanix.com>
2022-01-17 13:14:49 -08:00
Bart Van Assche
3f9735b3a4 slist: Clean up the slist.h header file
Fix indentation, align backslashes, surround multiline macros with
do { } while (0) and remove the unused ISCSI_LIST_LENGTH() macro.
2021-09-05 20:00:02 -07:00
Li Feng
6b93325b39 slist: Make this header file compatible with C++
C++ requires explicit conversions from a void to a non-void pointer.

Signed-off-by: Li Feng <fengli@smartx.com>
[ bvanassche: edited commit message, removed casts and changed the declaration
  type ]
2021-09-05 20:00:02 -07:00
Bart Van Assche
c412ae0e1d scsi-lowlevel.h: Include <assert.h>
Checking whether static_assert() is defined must happen after <assert.h> has
been included. Hence include <assert.h>.
2021-09-05 20:00:02 -07:00
Ser01x
1c3e2083c9 lib: init version for 8Fh VPD page
The third-party copy (8Fh) VPD page helps to check the capabilities
supported by the copy manager.
2021-07-21 16:28:16 +00:00
Bart Van Assche
2a5a0b3291 Enable -Wno-unused-parameter
Instead of adding __attribute__((unused)) to unused arguments, add the
-Wno-unused-parameter compiler flag.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:41 -07:00
Bart Van Assche
ea6b2282d4 Use __attribute__((format(printf, ...))) directly
Instead of defining the macro _R_(), define __attribute__() as a macro for
compilers that do not support __attribute__(), namely Microsoft Visual
Studio.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 11:52:40 -07:00
Anastasia Kovaleva
1b7d1743ae test-tool: Add overwrite check for all test cases
Check if the residual data does not owerwrite existing data blocks has now
been added for all testing data to improve the uniformity of test runs,
increase test readability and remove the duplicate testing data records.
2021-02-08 15:28:26 +03:00
Anastasia Kovaleva
2e8c571955 test-tool: Refactoring residuals write tests
Looking at test_write10_residuals.c, test_write12_residuals.c and
test_write16_residuals.c tests the similarity of the testing scenario
can be found. There are several EDTL and SPDTL combinations which are
the same for different length write command tests. They form the core
of testing scenario of these commands. There aren't so much differences
in the way of testing these combinations itself either. It is possible
to move the main parameters describing the testing scenario into a
separate structure and move the scenario itself into a separate function.
It will increase the readability and reduce the duplicate code of these tests.
2021-02-08 15:23:49 +03:00
Hou Pu
03fa3f627c iser: fix segmentation fault when task management pdu is received
As iser_pdu->desc->data_dir is not initialised when sending a PDU.
The value remains what it was when it was used last time. Thus
a PDU could be considered to have data if it previously had and
might cause segmentation fault.

For example if a pdu is a reset task management task with no data
to transfer and the pdu is previously used as a read task. Thus
it would cause fault like below:

> struct scsi_iovector *iovector_in = &task->iovector_in;

0  0x00007ffff7bcb2d1 in iser_rcv_completion (rx_desc=0x555555b79e48, iser_conn=0x555555b573a0) at iser.c:1349
1  0x00007ffff7bcb53e in iser_handle_wc (wc=0x7fffffffdc00, iser_conn=0x555555b573a0) at iser.c:1426
2  0x00007ffff7bcb685 in cq_event_handler (iser_conn=0x555555b573a0) at iser.c:1468
3  0x00007ffff7bcb81b in cq_handle (iser_conn=0x555555b573a0) at iser.c:1516
4  0x00007ffff7bc8b28 in iscsi_iser_service (iscsi=0x555555b58710, revents=1) at iser.c:118
5  0x00007ffff7bc3862 in iscsi_service (iscsi=0x555555b58710, revents=1) at socket.c:1016
6  0x00007ffff7bc3f6c in event_loop (iscsi=0x555555b58710, state=0x7fffffffe000) at sync.c:71
7  0x00007ffff7bc4605 in iscsi_task_mgmt_sync (iscsi=0x555555b58710, lun=0, function=ISCSI_TM_LUN_RESET, ritt=4294967295, rcmdsn=0) at sync.c:281
8  0x00007ffff7bc46cf in iscsi_task_mgmt_lun_reset_sync (iscsi=0x555555b58710, lun=0) at sync.c:312
9  0x000055555555500d in iscsi_lun_reset_sync (iscsi=0x555555b58710) at iscsiclient_lun_reset.c:34
10 0x0000555555555680 in main (argc=7, argv=0x7fffffffe1c8) at iscsiclient_lun_reset.c:211

Signed-off-by: Hou Pu <houpu@bytedance.com>
2020-11-08 15:45:00 +08: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
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
2212021747 iser: enhance connection procedure
This patch is used to fix the following problems in the current connection
method:
1. iscsi_iser_connect() waits until the connection is established or failed,
and may block the caller for a long time.
2. Although there's a cm_thread handles communication events, but in fact it
has no effects after the connection is established.
3. Resources are not released properly after reconnection failed. And once we
try to reconnect again, the resources will leak permanently.
(see iscsi_reconnect()).

This patch eliminate cm_thread and handle communication events in the caller
thread.
Connection procedure:
1. Create a mock fd by eventfd() (or just use old_iscsi->fd while reconnecting),
and assign it to iscsi->fd.
2. Create communication event channel, make it non-blocking and dup the
notifier fd to iscsi->fd.
3. Handle communication events by iscsi_which_events()/iscsi_service() loop
until connection established or falied.
4. If connection is established successfully, dup the notifier fd of completion
queue (CQ) events to iscsi->fd.
5. Handle completion queue (CQ) events by iscsi_which_events()/iscsi_service()
loop.
The entire procedure is non-blocking.

After established, whenever iscsi_service() is called with revents=0 or
queue_pdu() is called with a NOP pdu, communication events will be checked.

When connection failed, iser transport cleanup itself before callbacks.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-07 10:38:37 +08:00
wanghonghao
68ce3363aa iser: dynamic memory region allocator
Implement an allocator for allocating memory region of different lengths.
The allocator registers 4MB memory chunks as memory regions, and select a
free segment from one of them each time.

4KB is the minimum allocation unit, and free segments in the same chunk can be
merged into a larger free segment by the rule of buddy allocation. As a result,
size of allocated segments will be power of 2, this may waste some space but
produces less fragments.

In each chunk, a complete binary tree (which is actully an array) is used
to maintain free segments. Each node records the order of the largest segment
can be allocated from its subtree. Here's a miniature example.

A chunk with all segments free:
level 4                         4(0x1)
level 3            3(0x2)                      3(0x3)
level 2     2(0x4)        2(0x5)       2(0x6)        2(0x7)
level 1 1(0x8) 1(0x9) 1(0xa) 1(0xb) 1(0xc) 1(0xd) 1(0xe) 1(0xf)

After allocate a 16KB(order=3) memory region:
level 4                         3(0x1)
level 3            0(0x2)                      3(0x3)
level 2     2(0x4)        2(0x5)       2(0x6)        2(0x7)
level 1 1(0x8) 1(0x9) 1(0xa) 1(0xb) 1(0xc) 1(0xd) 1(0xe) 1(0xf)

It tooks 1 comparison to determine if a chunk can satisfy and at most 11
loops to find the leftmost free segment meets the requirments.
The value of each node is not more than 11, and a 8-bit integer is enough
to store it, so only 2048 bytes is required for each tree. And since the
entire tree is in a contiguous piece of memory and no rotations are needed,
it's far more efficient than self-balancing trees of the same size.

Different 4MB chunks are linked as a list, and the selection order is from
head to tail each time. If no existing chunks can satisfy the allocation,
the allocator will register another 4M chunk and add it to the tail.
+---------+       +---------+      +---------+
|4MB chunk| --->  |4MB chunk| ---> |4MB chunk|
+---------+       +---------+      +---------+

In most cases, smaller IOs can always get memory regions from the first or
second chunk and never traverse the list too much, and if we really send a lot
of large IOs, the cost of the traversal is rarely critical.

At last, obviously, the chunks can only allocate a maximum of 4MB memory region,
if a larger memory region is needed, the allocater registers/deregisters a
memory region directly regardless of buffer.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2020-04-01 11:35:42 +08:00
David Disseldorp
c8992f45b1 test: add support for 0x0A type XCOPY segment descriptors
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>
2020-03-18 18:59:34 +01:00
Bart Van Assche
bac94c18b8 libiscsi: Reduce the size of struct iscsi_context
Reduce the size of struct iscsi_context by reordering the members of this
data structure. Additionally, change the rdma_ack_timeout value from
'unsigned char' into 'uint8_t' to make it clear that this variable
represents an integer.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-03-07 12:37:51 -08:00
zhenwei pi
6ed1ffb7b2 iser: support rdma ack timeout optimization
Since 2c1619edef61a03cb516efaa81750784c3071d10 for linux kernel and
55843c4ab8f559679d28c559cc4d681836be769b for rdma-core, rdma cma
supports RDMA_OPTION_ID_ACK_TIMEOUT. It's useful for RDMA out of
sequence case. Because this feature is added recently, we have to
check this in autogen.sh before building source code.

Depend on production enviroument, tunning rdma ack timeout could get
the best performance. Suggested by Bart and Ronnie, instead of using
a fixed timeout value, add two methods to set rdma ack timeout value.
1, add URL variable 'LIBISCSI_RDMA_ACK_TIMEOUT'. This could works
for a specified connection.
2, add env argument 'LIBISCSI_RDMA_ACK_TIMEOUT'. This works as a
common setting for all the connection of a process.

Test under different packet loss rate and different ack timeout, run
fio (iodepth=1) in a guest os, I got this result:
latency under packet loss rate 0.00001:
	timeout 19: avg 170.22, pct99.9 215
	timeout 10: avg 160.08, pct99.9 215
	timeout 8 : avg 146.39, pct99.9 177
	timeout 7 : avg 148.37, pct99.9 211

latency under packet loss rate 0.0001:
	timeout 19: avg 949.23, pct99.9 306
	timeout 10: avg 818.53, pct99.9 378
	timeout 8 : avg 615.84, pct99.9 189
	timeout 7 : avg 618.89, pct99.9 310

Base on this test report, setting ack timeout to 8(1048.576 usec) is
a good choice in my test enviroument.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-03-07 12:37:46 -08:00
Bart Van Assche
3804f3c2e0 Remove the discard_const() macro
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>
2020-02-28 21:54:49 -08:00
Bart Van Assche
0ad5c2c648 libiscsi: Fix a format specifier
Use %lu to format unsigned long instead of %d.

This was detected by Coverity.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-23 20:11:14 -08:00
wanghonghao
51391285d8 iser: remove __packed from struct iser_cm_hdr declaration
`__packed` is not defined previously, and was treated as a varible
declaration.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
2019-12-10 14:42:38 +08:00