This is a "marginal" warning, but there are only six of them in the SCST code
and this fixes two of those.
session.c:105:4: warning: cast from function call of type void * to non-matching type _Bool [-Wbad-function-cast]
target.c:668:14: warning: cast from function call of type void * to non-matching type _Bool [-Wbad-function-cast]
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7200 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Waiting for other threads to release an object using code like
"while (object->refcnt > 0) msleep(100)" without holding a reference
on 'object' is wrong because the memory object points at may be freed
before or while this loop is in progress. Hence introduce a global
portal object count and wait on that count instead of waiting for
the per-portal reference count to reach zero.
The use-after-free was introduced in r6952 ("isert: faster release
of isert_scst module").
See also https://sourceforge.net/p/scst/tickets/2/.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7184 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This change helped a secondary problem I had under valgrind (due to some other
bug) with initiators timing out and reconnecting their sessions faster than the
threads were getting cleaned up (for one thing, valgrind only ever runs one
thread at a time).
It seems logical that the code in conn_lookup() would want to skip any
connection that's already known closing in this case, for the same reason it
searches the list in reverse. And the dropping connections don't have to drop
in order, so searching in reverse doesn't seem sufficient to avoid finding a
wrong (stale, closing) connection structure.
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7144 d57e44dd-8a1f-0410-8b47-8ef2f437770f
In an error path in iscsi_threads_pool_get(), when a new pool cannot be
allocated, if there is a pool on iscsi_thread_pools_list, it passes that back as
an alternative, so return zero in that case.
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7143 d57e44dd-8a1f-0410-8b47-8ef2f437770f
In scsi_cmnd_start() conn->rx_task is intended to be set only during the
call to _stage1_done, but there was no code to reset it. It doesn't
actually matter in execution, but it was a little confusing to wonder
and try to understand why it wasn't reset.
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7142 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Change local names of ioctl() and open() to not conflict with C library names.
This isn't really a bug in a strictly kernel-resident build, but the change
avoids symbol conflicts with libc when building for usermode.
Signed-off-by: David Butterfield <dab21774@gmail.com>
with some changes
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7138 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Add "XXX" comments in a few places about potential problems seen in SCST code,
for future investigation and possible repair.
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7123 d57e44dd-8a1f-0410-8b47-8ef2f437770f
casting const to non-const
uninitialized structure members
non-static local function
missing enumerated switch-value cases
Signed-off-by: David Butterfield <dab21774@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7122 d57e44dd-8a1f-0410-8b47-8ef2f437770f
If this attrubute is set, each iSCSI session for this initiator has
dedicated, i.e. not shared with other sessions, pool of the iscsi{wr,rd}
kernel threads.
Useful to control per-session CPU affinity to improve performance.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7069 d57e44dd-8a1f-0410-8b47-8ef2f437770f
It adds target_ip attribute containing target IP address in each
/sys/kernel/scst_tgt/targets/iscsi/TARGET/sessions/INITIATOR/INITIATOR_IP subdirectory.
It's useful to simplify monitoring management utilities
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7067 d57e44dd-8a1f-0410-8b47-8ef2f437770f
It's false positive, because responses live in the parent request's list
until last put for the parent.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7009 d57e44dd-8a1f-0410-8b47-8ef2f437770f
If rdma_accept fails the state of the qp is modified to error and all
posted recieve buffers will be flushed and because of the flush
the isert conn teardown flow will start.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6956 d57e44dd-8a1f-0410-8b47-8ef2f437770f
isert_delete_conn_dev function checks if it needs to close the connection
by checking that dev conn is not NULL.
We were missing set conn to null when freeing it and that caused working
with memory that was already freed.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6955 d57e44dd-8a1f-0410-8b47-8ef2f437770f
read/write events may arive after the isert connection has
started the teardown flow.
This scenario may occur on login logout stress.
It may lead to NULL derefrence bugs.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6953 d57e44dd-8a1f-0410-8b47-8ef2f437770f
If there is a dead connection we don't want to wait 60 seconds for
the connection timeout error.
So when closing the portal we close now all the connections
immediately without waiting for events to arrive.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6952 d57e44dd-8a1f-0410-8b47-8ef2f437770f
To avoid rare cases when checking ISERT_CONNECTION_EST bit
may lead to kref leak, we now take the third refcount earlier
before calling to rdma_accept.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6951 d57e44dd-8a1f-0410-8b47-8ef2f437770f
1) The race can happen after unreachable event handler close isert connection
and calling to rdma_disconnect from another thread on illegal cm_id.
For example call rdma_disconnect from isert_portal_release function.
2) It is also possible to get ESTABLISHED RDMACM event while rdma_disconnect
is called from another thread.
In established event we need to check conn is not in
teardown flow by checking the connection state with a mutex.
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6950 d57e44dd-8a1f-0410-8b47-8ef2f437770f