165 Commits

Author SHA1 Message Date
Gleb Chesnokov
f85736549a iscsi-scst: Remove access to page->index
There is no need to print out page->index as part of the debug message.
2025-08-05 16:37:31 +03:00
Gleb Chesnokov
f52ae117b8 scst: Port to Linux kernel v6.13
Support for the following changes in the Linux kernel v6.13:

- cdd30ebb1b9f ("module: Convert symbol namespace to string literal")

Fixes: https://github.com/SCST-project/scst/issues/273
2025-01-20 18:54:10 +03:00
Gleb Chesnokov
3a54209167 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +03:00
Gleb Chesnokov
16a17c259b iscsi-scst: Port to Linux kernel v6.5
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)")
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
324bf62e28 iscsi-scst: Refactor sendpage functionality in write_data()
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.
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
c1f7510d80 iscsi-scst: Improve 'write iop loop' in write_data()
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.
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
b5294cbf38 iscsi-scst: Improve write_data()
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.
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
bdf867ffd1 scst: Use scst_wait_event_...() with INTERRUPTIBLE sleep
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")
2023-06-27 17:11:13 +03:00
Gleb Chesnokov
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().
2023-06-20 09:53:50 +03:00
Gleb Chesnokov
46ad98f072 scst: Remove else after a break or return
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.
2022-08-09 19:38:00 +03:00
Gleb Chesnokov
90485f0c97 iscsi-scst: Fix up the error handling to avoid crash
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
2022-06-28 18:46:30 +03:00
Gleb Chesnokov
276aeeb211 iscsi-scst: Make exit_tx() return void
exit_tx() doesn't change the return variable res, so make it return
void.

This patch doesn't change any functionality.
2022-06-28 18:46:30 +03:00
Gleb Chesnokov
33861d0a6d iscsi-scst: Suppress a Coverity taint complaint
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.
2022-06-27 14:14:52 +03:00
Bart Van Assche
a673470ce3 scst, iscsi-scst: Use struct kvec instead of struct iovec for kernel data
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
2020-11-27 03:45:16 +00:00
Bart Van Assche
186798cec4 Use the fallthrough macro instead of a comment
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9166 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2020-09-16 14:28:36 +00:00
Bart Van Assche
f7b704ee99 scst, iscsi-scst: Port to RHEL / CentOS 8.2
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
2020-06-17 01:35:53 +00:00
Bart Van Assche
a94c8eaf0f scst: Move the set_fs() calls into scst_{read,write}v()
This patch does not change any functionality.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8066 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2019-03-21 02:56:46 +00:00
Bart Van Assche
3b76bc5b1f Use KERNEL_DS instead of get_ds()
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
2019-03-18 00:24:56 +00:00
Bart Van Assche
0655c3e76a iscsi-scst: Fix a use-after-free
Avoid that KASAN reports the following complaint:

BUG: KASAN: slab-out-of-bounds in f/0xdc4 [iscsi_scst]
Read of size 8 at addr ffff888be35fd0ec by task iscsiwr0_71/3289

CPU: 42 PID: 3289 Comm: iscsiwr0_71 Tainted: G
sos.debug #1
Hardware name: To be filled by O.E.M.
Call Trace:
 dump_stack+0x8e/0xc8
 print_address_description+0x73/0x238
 kasan_report+0x228/0x251
 check_memory_region+0x126/0x12c
 __asan_loadN+0xf/0x11
 write_data+0x5df/0xdc4 [iscsi_scst]
 iscsi_do_send+0x20/0x67 [iscsi_scst]
 iscsi_send+0x1f0/0x574 [iscsi_scst]
 scst_do_job_wr+0x2ef/0x549 [iscsi_scst]
 istwr+0x366/0x4a2 [iscsi_scst]
 kthread+0x1df/0x1ef
 ret_from_fork+0x3a/0x50

Allocated by task 3063:
 save_stack_trace+0x1b/0x1d
 kasan_kmalloc.part.1+0x62/0xee
 kasan_kmalloc+0x7f/0x8b
 kasan_slab_alloc+0x12/0x14
 kmem_cache_alloc+0x13d/0x27a
 mempool_alloc_slab+0x15/0x17
 mempool_alloc+0xdb/0x1f3
 scst_alloc_aen+0x96/0x223 [scst]
 scst_gen_aen_or_ua+0x16b/0x3d2 [scst]
 scst_capacity_data_changed+0x147/0x1cd [scst]
 vdev_size_process_store+0x1b5/0x1f4 [scst_vdisk]
 scst_process_sysfs_works+0x187/0x2a1 [scst]
 sysfs_work_thread_fn+0x301/0x42b [scst]
 kthread+0x1df/0x1ef
 ret_from_fork+0x3a/0x50

Reported-by: Marc Smith <msmith626@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8056 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2019-03-18 00:23:05 +00:00
Bart Van Assche
d1f7b0aae8 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8050 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2019-03-11 03:57:09 +00:00
Bart Van Assche
9df67df132 iscsi-scst: Fix 32-bit compiler warnings
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7910 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2019-02-08 03:43:35 +00:00
Bart Van Assche
5a1474df43 scst, iscsi-scst: Port to Linux kernel v4.20
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7810 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2018-11-10 17:51:41 +00:00
Bart Van Assche
e79fcbd8f3 iscsi-scst: Remove zero-copy TCP/IP support
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
2018-11-10 17:50:59 +00:00
Bart Van Assche
e2a17c6a24 Change 'long long int' int 'long long'
This patch does not change any functionality.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7505 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2018-10-14 03:57:53 +00:00
Vladislav Bolkhovitin
f549829482 Copyrights updated
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7396 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2018-04-12 03:49:10 +00:00
Bart Van Assche
7c550d4724 iscsi-scst: UEK 4.1.12-103.9.7.el7uek.x86_64 build fix
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7272 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2017-12-19 16:35:40 +00:00
Bart Van Assche
4c05086b59 scst, iscsi-scst: Introduce scst_read(), scst_write(), scst_readv() and scst_writev()
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
2017-11-13 05:50:44 +00:00
Bart Van Assche
9e35afe1e0 Annotate fall-through in switch statements in a form recognized by gcc 7
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7216 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2017-08-27 15:28:57 +00:00
Vladislav Bolkhovitin
e5e4531049 iscsi-scst: cleanup
There's no need to end-align the padding. Plus, it's not optimal to
access front misaligned memory

Reported-by: David Butterfield <dab21774@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7195 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2017-05-25 02:11:06 +00:00
Vladislav Bolkhovitin
68fa7e1a0d Copyright updates
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7146 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2017-04-22 03:19:52 +00:00
Vladislav Bolkhovitin
eaa99a8770 Fix a few minor "extra" compiler warnings (mostly "const" issues)
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
2017-04-14 01:03:25 +00:00
Vladislav Bolkhovitin
a2e0916fbf Fix a few compiler messages issued when some extra warnings are enabled:
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
2017-04-13 23:58:32 +00:00
Bart Van Assche
7f1d8c91b1 iscsi-scst: Port to Linux kernel versions >= v4.7
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7021 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2016-10-26 21:33:50 +00:00
Bart Van Assche
eff3021fb5 scst: Port to Linux kernel v4.6
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6835 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2016-03-24 04:08:12 +00:00
Vladislav Bolkhovitin
83d0cb0f46 iscsi-scst: fix possible recursive locking
cmnd_done() called from cmnd_put() can take cmd_list_lock, so it must
not be called under it.

Reported and tested by David Chen <david.chen@osnexus.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6821 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2016-03-02 04:13:42 +00:00
Vladislav Bolkhovitin
a1b613af75 iscsi-scst: clarify comment
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6811 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2016-02-19 03:12:53 +00:00
Vladislav Bolkhovitin
fa2f54ac9e Copyrights updated
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6787 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2016-01-22 04:04:43 +00:00
Bart Van Assche
469fe4a42c iscsi-scst: Remove superfluous casts
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
2015-11-09 19:51:17 +00:00
Bart Van Assche
7614eafd64 iscsi-scst: Insert a blank line after declarations
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6616 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-11-07 00:00:42 +00:00
Vladislav Bolkhovitin
45d7f40ec1 Improve release logging
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6478 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-08-25 02:57:51 +00:00
Vladislav Bolkhovitin
e5e54f312b iscsi-scst: Move old TM response dropping to preparing new response stage
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
2015-07-31 01:09:58 +00:00
Bart Van Assche
79c8bf1f7c iscsi-scst, isert-scst: One trace flags variable per kernel module
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6397 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-23 15:01:17 +00:00
Bart Van Assche
26cda0eb38 iscsi-scst: Annotate fall-through cases for Coverity
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6364 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-17 00:18:23 +00:00
Bart Van Assche
63cb4a9d40 iscsi-scst: Fix indentation
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6363 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-17 00:09:23 +00:00
Bart Van Assche
7c3b2c4ca6 iscsi-scst: Fix spelling in a source code comment
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6321 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-16 15:53:31 +00:00
Bart Van Assche
0d9d6a6f57 isert-scst: Fix in-tree build
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6312 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-12 16:15:45 +00:00
Bart Van Assche
6aaeca1cd9 Merge iser branch r6234 into trunk
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6235 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-06-10 15:35:26 +00:00
Vladislav Bolkhovitin
1e78126962 iscsi-scst: update for 3.19 kernels
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> with some improvements



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6187 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-04-24 02:54:52 +00:00
Vladislav Bolkhovitin
5cc7555cd9 iscsi-scst: Rework sparse annotations
Do not declare kernel pointers as __user but instead cast these to
__user just before assigning these to iov_base.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6156 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-03-26 00:33:45 +00:00
Vladislav Bolkhovitin
fe38e4acb2 Copyrights updated
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6146 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2015-03-19 00:01:03 +00:00