Use sendmsg() conditionally with MSG_SPLICE_PAGES in write_data()
rather than calling sendpage().
Support for the following net layer changes in the Linux kernel v6.5:
- dc97391e6610 ("sock: Remove ->sendpage*() in favour of
sendmsg(MSG_SPLICE_PAGES)")
This patch carries out a refactoring of the sendpage functionality in
the write_data() function:
1. Reorganize the logic used to select the sock_sendpage function.
2. Streamline the data sending loop by reducing conditional branches and
eliminating labels.
3. Adjust the error handling for -EINTR and -EAGAIN to make the code
cleaner and easier to follow.
This patch doesn't change any functionality.
This patch introduces several improvements to the 'write iop loop' in
the write_data() function:
1. Move iop-related variables under the scope of the 'write iop loop'.
2. Eliminate the 'retry' label, use 'continue' instead for simplicity.
3. Remove the redundant 'rest' variable, use just 'res' instead.
This patch doesn't change any functionality.
This patch introduces several improvements to the write_data() function:
1. Remove the redundant 'sendpage' function pointer variable.
2. Update variables related to size to use the size_t type for better
type correctness and safety.
3. Introduce a new variable, 'parent_req', to store the
'write_cmnd->parent_req' pointer and reduce redundant accesses.
4. Fix several checkpatch warnings.
This patch doesn't change any functionality.
This patch changes the processing threads to use INTERRUPTIBLE sleep
states in the scst_wait_event_...() functions. This aims to avoid
warnings from the hung task detection checker and to prevent
unnecessary load counting.
Fixes: d8894cbd11 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity")
1. Set the default process state to TASK_UNINTERRUPTIBLE during sleep.
This change is made because our current code does not check whether a
process was interrupted by a signal.
2. Prefix all SCST wait_event-related macros with 'scst_'. This helps to
distinguish SCST-specific macros from those provided by the Linux
kernel itself.
3. Add the capability to return an error code when a process in a
non-TASK_UNINTERRUPTIBLE state is interrupted by a signal.
4. Divide the wait_event_locked function based on each lock type,
resulting in the following new functions: scst_wait_event_lock(),
scst_wait_event_lock_bh(), and scst_wait_event_lock_irq().
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.
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 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
Apparently the Linux kernel v4.20 iov_iter_kvec() function has been
backported to RHEL / CentOS 8.2. This patch fixes the following kernel
warning:
WARNING: CPU: 26 PID: 21141 at lib/iov_iter.c:1083 iov_iter_kvec+0x25/0x30
Call Trace:
fileio_exec_async+0x216/0x3a0 [scst_vdisk]
fileio_exec_write+0x3b9/0x450 [scst_vdisk]
vdev_do_job+0x34/0xc0 [scst_vdisk]
scst_do_real_exec+0x54/0x100 [scst]
scst_exec_check_blocking+0xbb/0x210 [scst]
scst_process_active_cmd+0x64d/0x1550 [scst]
scst_cmd_thread+0x170/0x5a0 [scst]
kthread+0x112/0x130
ret_from_fork+0x35/0x40
See also https://github.com/bvanassche/scst/issues/26.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9026 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This patch is necessary to make SCST work with Linux kernel v5.1 and
does not change any functionality. See also upstream commit 736706bee329
("get rid of legacy 'get_ds()' function").
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8057 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Zero-copy TCP/IP support is deprecated since a while and is no longer
supported for recent kernels. Hence remove it and also all references
to zero-copy TCP/IP support.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7809 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This makes it easier to add support for new kernel versions, e.g. kernel
version v4.14.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7260 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
The C language does not require to use an explicit cast when assigning
a void * pointer to a pointer of another type.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6633 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The second TM request can come while the old one, response for which is
going to be delayed, is still being processed, hence no response
prepared yet, so the delayed response should be dropped on the stage of
the new response preparing. Otherwise in this place the old delayed
response will trigger BUG_ON().
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6456 d57e44dd-8a1f-0410-8b47-8ef2f437770f