682 Commits

Author SHA1 Message Date
Gleb Chesnokov
9003543f45 scst: Port to Linux kernel v7.0
Support for the following changes in the Linux kernel v7.0:

  - e3b2cf6e5dba ("kernfs: pass struct ns_common instead of
    const void * for namespace tags")
2026-04-12 15:38:24 +03:00
Gleb Chesnokov
8a3b257c33 scst: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Linux kernel Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci against the SCST tree.

This patch doesn't change any functionality.
2026-04-12 15:38:24 +03:00
Brian M
7a4ab042e6 iscsi-scst: Fix performance regression
A recent change in iscsi_threads_pool_get changed 2 from being the
minimum count to the maximum.  Rectify.
2026-03-04 11:41:03 +03:00
Gleb Chesnokov
b2a1f6e66a Bump the version number to 3.11.0-pre
These changes have been generated by running the following command:

$ scripts/update-version 3 11 0 -pre
2025-12-29 13:06:44 +03:00
Gleb Chesnokov
d4cb03e2b8 Bump the version number to 3.10.0
These changes have been generated by running the following command:

$ scripts/update-version 3 10 0
2025-12-29 12:40:21 +03:00
Gleb Chesnokov
b5777ff929 scst: annotate workqueues for WQ_PERCPU / WQ_UNBOUND
Upstream workqueue changes introduce a new WQ_PERCPU flag and plan to
switch alloc_workqueue()'s default from per-CPU to unbound

To kepp SCST behaviour unchanged across kernels, this patch makes all
alloc_workqueue() users explicit about whether they want per-CPU or
unbound queues.
2025-12-10 21:42:47 +03:00
Gleb Chesnokov
3928d6d74f iscsi-scst: Drop redundant 'extern' from function prototypes
This patch does not change any functionality.
2025-10-21 12:18:36 +03:00
Gleb Chesnokov
2c69fe018c scst: Use block layer helpers to calculate num of queues
The calculation of the upper limit for queues does not depend solely on
the number of online CPUs; for example, the isolcpus kernel
command-line option must also be considered.

To account for this, the block layer provides a helper function to
retrieve the maximum number of queues. Use it to set an appropriate
upper queue number limit.
2025-10-01 22:11:28 +03:00
Tony Battersby
63f2375fe4 kbuild: Remove stack protector flags
-fstack-protector-strong is controlled by the in-tree
CONFIG_STACKPROTECTOR_STRONG config option.  If the flag is set without
the config option, scst fails to build:
ERROR: modpost: "__stack_chk_fail" [scst/src/scst.ko] undefined!

-fstack-clash-protection is disabled in the kernel's Makefile due to an
incompatibility with randomize_kstack_offset.

Fixes: 86d3d4bb1d ("kbuild: Enable additional compiler warnings")
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
2025-09-08 16:40:12 +03:00
Gleb Chesnokov
1ba89c391e iscsi-scst: Accept CRC32 or LIBCRC32C for crc32c() across kernels
Kernel v6.15+ removed LIBCRC32C and switched in-tree users to CRC32.
Keep older kernels working by accepting either CRC32 or LIBCRC32C in
Kconfig and preprocessor guards, so crc32c() usage compiles and links
on both old and new kernels.
2025-08-18 13:23:30 +03:00
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
977904d33a scst: Use separate sysfs_emit_at() for emitting SCST_SYSFS_KEY_MARK
Replace combined sysfs_emit() calls with separate sysfs_emit() and
sysfs_emit_at() invocations when emitting SCST_SYSFS_KEY_MARK in sysfs
attribute show handlers.

This improves code clarity and consistency, explicitly handling the
conditional addition of SCST_SYSFS_KEY_MARK.

This patch does not change any functionality.
2025-05-19 20:46:54 +03:00
Gleb Chesnokov
0e8fdad5e4 scst: Use sysfs_emit/sysfs_emit_at instead of scnprintf()
Replace scnprintf() with sysfs_emit() and sysfs_emit_at() in sysfs show handlers.

These helper functions are specifically designed for sysfs output, providing safer
handling of buffer lengths and consistency across kernel sysfs interfaces.

This patch does not change any functionality.
2025-05-19 20:46:54 +03:00
Gleb Chesnokov
989802f48d scst: Replace snprintf() with scnprintf()
Replace snprintf() with scnprintf() in two places:

- code paths that build up a buffer incrementally
- sysfs attribute “show” handlers

scnprintf() guarantees its return value is the number of bytes actually
written (never exceeding the buffer), preventing potential overruns.

This patch does not change any functionality.
2025-05-19 20:46:54 +03:00
Gleb Chesnokov
9cbca53830 scst: Replace sprintf() with scnprintf() in sysfs callbacks
Replace all uses of sprintf() with scnprintf() in sysfs attribute
callbacks to eliminate the risk of buffer overflows.

This patch does not change any functionality.
2025-05-16 16:37:43 +03:00
Gleb Chesnokov
d21b6f1457 scst: Port to Linux kernel v6.15
Support for the following changes in the Linux kernel v6.15:

- 8fa7292fee5c ("treewide: Switch/rename to timer_delete[_sync]()")
2025-05-14 18:36:46 +03:00
Gleb Chesnokov
86d3d4bb1d kbuild: Enable additional compiler warnings
Add additional compiler flags to improve code compliance.
2025-03-25 18:57:32 +03:00
Gleb Chesnokov
191a74d127 scst: Fix recently introduced Coverity warnings
Add error handling for recently introduced SHA256 and SHA3-256 APIs.
2025-03-25 16:09:35 +03:00
Brian M
6c5e8ad16a iscsi-scst: Add transport name to sys entry for connection
This will make it possible to distinguish iSCSI-TCP connections
from iSER connections.
2025-01-29 13:00:08 +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
2bdc19a61f Bump the version number to 3.10.0-pre
These changes have been generated by running the following command:

$ scripts/update-version 3 10 0 -pre
2024-12-28 17:14:54 +03:00
Gleb Chesnokov
a68cb8e94d Bump the version number to 3.9.0
These changes have been generated by running the following command:

$ scripts/update-version 3 9 0
2024-12-28 16:44:09 +03:00
Gleb Chesnokov
60dc638b1b iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +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
ae5ea42594 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +03:00
Gleb Chesnokov
8aa93714e6 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +03:00
Gleb Chesnokov
1414c9dda3 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +03:00
Gleb Chesnokov
ec80741a24 iscsi-scst: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-11-16 14:33:58 +03:00
Gleb Chesnokov
61f365f96e scst: Expand all create*_workqueue() invocations
The workqueue maintainer wants to remove the create*_workqueue() macros
because these macros always set the WQ_MEM_RECLAIM flag and because these
only support literal workqueue names. Hence this patch that replaces the
create*_workqueue() invocations with the definition of this macro. The
WQ_MEM_RECLAIM flag has been retained because I think that flag is necessary
for workqueues created by storage drivers.
2024-11-07 14:02:05 +03:00
Gleb Chesnokov
256d695afa scst: Port to Linux kernel v6.12
Support for the following changes in the Linux kernel v6.12:

- 5f60d5f6bbc1 ("move asm/unaligned.h to linux/unaligned.h")
- cb787f4ac0c2 ("[tree-wide] finally take no_llseek out")
2024-11-07 13:21:25 +03:00
Gleb Chesnokov
188256792c Bump the version number to 3.9.0-pre
These changes have been generated by running the following command:

$ scripts/update-version 3 9 0 -pre
2024-01-15 15:33:45 +03:00
Gleb Chesnokov
1171841931 Bump the version number to 3.8.0
These changes have been generated by running the following command:

$ scripts/update-version 3 8 0
2024-01-15 13:59:19 +03:00
Gleb Chesnokov
2d243a71e7 scst: Unbreak the RHEL 9.4 build
Fixes: https://github.com/SCST-project/scst/issues/201
2023-12-27 18:27:42 +03:00
Gleb Chesnokov
4b840aeee3 scst: Do not use WQ_MEM_RECLAIM flag for workqueues
According to kernel documentation, this flag should be set if the
workqueue will be involved in the kernel's memory reclamation flow.
Since it is not, there is no need for the driver's WQ to have this
flag set so remove it.
2023-07-21 10:38:52 +03:00
Gleb Chesnokov
1f0ce86f3c scst: Fix removal of deprecated create_workqueue()
create_workqueue() was replaced with alloc_workqueue() with max_active set
to 0. However, the original create_workqueue() implicitly set max_active
to 1.

This change has led to unexpected bugs because previously, work items
could only be executed one by one. With the change, they can now be
executed simultaneously.

This patch fixes the issue by restoring max_active to 1.

Fixes: f4686e9102 ("scst: Remove deprecated create_workqueue()")
Fixes: https://github.com/SCST-project/scst/issues/179
2023-07-21 10:38:52 +03:00
Gleb Chesnokov
87235dfe3a scst: Use vmalloc_array() and vcalloc()
Use vmalloc_array() and vcalloc() to protect against multiplication
overflows.

The changes were done using the following Coccinelle
semantic patch:

// <smpl>
@initialize:ocaml@
@@

let rename alloc =
  match alloc with
    "vmalloc" -> "vmalloc_array"
  | "vzalloc" -> "vcalloc"
  | _ -> failwith "unknown"

@@
    size_t e1,e2;
    constant C1, C2;
    expression E1, E2, COUNT, x1, x2, x3;
    typedef u8;
    typedef __u8;
    type t = {u8,__u8,char,unsigned char};
    identifier alloc = {vmalloc,vzalloc};
    fresh identifier realloc = script:ocaml(alloc) { rename alloc };
@@

(
      alloc(x1*x2*x3)
|
      alloc(C1 * C2)
|
      alloc((sizeof(t)) * (COUNT), ...)
|
-     alloc((e1) * (e2))
+     realloc(e1, e2)
|
-     alloc((e1) * (COUNT))
+     realloc(COUNT, e1)
|
-     alloc((E1) * (E2))
+     realloc(E1, E2)
)
// </smpl>
2023-07-21 10:38:34 +03:00
Gleb Chesnokov
bc9ec6f9e7 scst: Replace all strlcpy() with strscpy()
strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NULL-terminated [1].

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
2023-07-19 10:54:35 +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
68461f5876 scst: Remove support for RHEL5/6
The SCST has dropped support for RHEL5/6 since v3.6.
2023-05-10 13:24:47 +03:00
Gleb Chesnokov
faac0a1964 scst: Port to Linux kernel v6.4
Support for the following driver core changes in the Linux kernel v6.4:
- 1aaba11da9aa ("driver core: class: remove module * from class_create()")
- 2243acd50ac4 ("driver core: class: remove struct class_interface * from callbacks")
2023-04-28 15:22:58 +03:00
Gleb Chesnokov
b78582f34d Bump the version number to 3.8.0-pre
These changes have been generated by running the following command:

$ scripts/update-version 3 8 0 -pre
2022-12-28 17:08:44 +03:00
Gleb Chesnokov
1ef10b852d Bump the version number to 3.7.0
These changes have been generated by running the following command:

$ scripts/update-version 3 7 0
2022-12-27 16:47:20 +03:00
Gleb Chesnokov
f4686e9102 scst: Remove deprecated create_workqueue()
alloc_workqueue() replaces deprecated create_workqueue().
2022-11-04 13:26:20 +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
ebae8bd223 scst: Remove unnecessary null check
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
2022-08-09 19:38:00 +03:00