Remove the else because the if statement has a break or return statement.
This patch fixes the following checkpatch warnings:
WARNING:UNNECESSARY_ELSE: else is not generally useful after a break
or return.
kmem_cache_destroy() can handle NULL pointer correctly, so there is no need
to check NULL pointer before calling kmem_cache_destroy().
For kernel versions before v4.3 there is a backport of
kmem_cache_destroy() that checks for a null pointer.
This patch fixes the following checkpatch warnings:
WARNING:NEEDLESS_IF: kmem_cache_destroy(NULL) is safe and this check
is probably not required
Change 'compability' to 'compatibility'.
This patch fixes the following checkpatch warning:
WARNING: 'compability' may be misspelled - perhaps 'compatibility'?
This patch should fix the following bug:
iscsi-scst: ***ERROR***: Sending data failed: initiator ..., write_size 0, write_state 1, res 0
iscsi-scst: ***CRITICAL ERROR***: 0 6 31
------------[ cut here ]------------
kernel BUG at /usr/src/packages/BUILD/scst-3.7.0.8695/iscsi-scst/kernel/nthread.c:1517!
invalid opcode: 0000 [#1] SMP NOPTI
CPU: 12 PID: 997595 Comm: iscsiwr0_14 ...
...
RIP: 0010:iscsi_send+0x877/0x8b0 [iscsi_scst]
Call Trace:
istwr+0x123/0x3b0 [iscsi_scst]
kthread+0x120/0x136
ret_from_fork+0x24/0x36
-------------------------------------
What happens:
- istwr() calls scst_do_job_wr().
- scst_do_job_wr() calls iscsi_send().
- iscsi_send() sets the 'res' variable to 0 during error
in one of three possible places:
iscsi_do_send(), tx_padding(), tx_ddigest().
- All of these functions call exit_tx() which sets conn->write_state to TX_END.
- After iscsi_send() has completed for the current iteration, the next time
it processes iscsi_conn with conn->write_state == TX_END,
which will call BUG() in the switch default case.
Therefore, remove the res == 0 check in iscsi_send() to handle TX_END state.
Fixes: https://github.com/SCST-project/scst/issues/12
Suppress the following (false positive) Coverity complaint:
CID 271578 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer (*ref_cmd).scst_cmd to
scst_set_delivery_status, which dereferences it
(*ref_cmd).scst_aen is set when (*ref_cmd).scst_state == ISCSI_CMD_STATE_AEN
and vice versa, so the Coverity complaint is a false positive. Hence rewrite
the code to suppress this complaint and make the code cleaner.
This patch fixes the following Coverity complaint:
CID 271601 (#1 of 1): Uninitialized scalar variable (UNINIT)
uninit_use_in_call: Using uninitialized value req.
Field req.cid is uninitialized when calling iscsid_request.
This patch fixes the following Coverity complaint:
CID 271606 (#1 of 1): Uninitialized scalar variable (UNINIT)
uninit_use_in_call: Using uninitialized value event.
Field event.target_name is uninitialized when calling __event_send.
There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should
no longer be used[2].
This code was transformed with the help of Coccinelle:
($ spatch --jobs $(getconf _NPROCESSORS_ONLN) --sp-file script.cocci --include-headers --dir . > output.patch)
@@
identifier S, member, array;
type T1, T2;
@@
struct S {
...
T1 member;
T2 array[
- 0
];
};
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays
Link: https://github.com/KSPP/linux/issues/78
Add the opportunity to globally specify multiple addresses, which
iSCSI/iSER portal will listen on.
There is a way to specify the addresses for a target, on which
portals it will be available, using the allowed_portal parameter.
There is also a way to set this globally via the iscsi-scstd
--address parameter. The problem is that the last option allows
you to specify only one local address. So extend this functionality
to specify more then one address.
Also increase the maximum number of listening addresses to 32.
Signed-off-by: Aleksandr Dyadyushkin <alextalker@ya.ru>
Move PRINT_ERROR to the body of RDMA_CM_EVENT_CONNECT_REQUET because only
it can return an error and not log information about it.
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
[bvanassche: modified patch title]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9486 d57e44dd-8a1f-0410-8b47-8ef2f437770f
During processing RDMA_CM_EVENT_ADDR_CHANGE event rdma_bind_addr in isert_setup_id function from isert_cm_evt_listener_handler returns error -98 [EADDRINUSE].
In principle, it is logical, because at that time the socket address was still bound to the old cma_id which will be destroyed via rdma_destroy_id only after processing the RDMA_CM_EVENT_ADDR_CHANGE event.
Move the creation of the cma_id in workqueue context and delete old cma_id directly, not through returning the error code to the upper level.
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9484 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Introduce the function isert_setup_id(). This function creates and sets up
an RDMA CM ID. Move the isert_portal_listen() call into isert_portal_create().
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
[ bvanassche: edited patch description and dropped support for older kernel
versions in the PRINT_INFO() statement ]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9481 d57e44dd-8a1f-0410-8b47-8ef2f437770f
When the low level driver exercises the hot unplug they would call
rdma_cm cma_remove_one which would fire DEVICE_REMOVAL event to all cma
consumers. Now, if consumer doesn't make sure they destroy all IB
objects created on that IB device instance prior to finalizing all
processing of DEVICE_REMOVAL callback, rdma_cm will let the lld to
de-register with IB core and destroy the IB device instance. And if the
consumer calls (say) ib_dereg_mr(), it will crash since that dev object
is NULL.
In the current implementation, iser-target just initiates the cleanup
and returns from DEVICE_REMOVAL callback. This deferred work creates a
race between iser-target cleaning IB objects(say MR) and lld destroying
IB device instance.
This patch includes the following fixes
-> make sure that consumer frees all IB objects associated with device
instance
-> return non-zero from the callback to destroy the rdma_cm id
Signed-off-by: Raju Rangoju <rajur@chelsio.com>
Acked-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Doug Ledford <dledford@redhat.com>
See also upstream commit 63b268d232b8 ("IB/isert: Properly release
resources on DEVICE_REMOVAL")
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
[ bvanassche: edited patch description and moved a break statement into a code
block ]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9480 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Minimize the diffs with the upstream code base by introducing the function
isert_conn_init().
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
[ bvanassche: edited patch description ]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9478 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Move the isert_cm_disconnect_handler() definition, pass the event type to
isert_cm_evt_listener_handler() instead of the struct rdma_cm_event pointer
and change the return value of isert_cm_evt_listener_handler() from 0 /
-EINVAL into -1.
Signed-off-by: Chesnokov Gleb <Chesnokov.G@raidix.com>
[ bvanassche: made the patch description more detailed ]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9473 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The previous commit removed support for building with clang. Restore support
for building with clang without breaking cross-compilation support.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9209 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This patch does not change any functionality but removes multiple __force
__user casts.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9197 d57e44dd-8a1f-0410-8b47-8ef2f437770f
mm_segment_t, get_fs() and set_fs() have been removed from Linux kernel
v5.10. Instead of adding more #ifdef / #endif directives, provide backports
for this typedef and these functions in iscsi_scst.h.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9189 d57e44dd-8a1f-0410-8b47-8ef2f437770f
In Linux kernel v5.9 use of the KERNEL_SOCKPTR() function is mandatory
when calling setsockopt(). Implement that function for kernels before v5.9.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9149 d57e44dd-8a1f-0410-8b47-8ef2f437770f