941 Commits

Author SHA1 Message Date
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
34b1edd045 scst.h: Fix multiple checkpatch warnings
This patch does not change any functionality.
2024-12-28 14:59:04 +03:00
Dhananjay Kamble
70cf2f6271 scst: Unbreak the RHEL 9.5 build 2024-11-07 19:32:26 +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
ceba304d08 qla2x00t-32gbit: Avoid possible run-time warning with long model_num
The prior strlcpy() replacement of strncpy() here (which was
later replaced with strscpy()) expected pinfo->model_num (and
pinfo->model_description) to be NUL-terminated, but it is possible
it was not, as the code pattern here shows vha->hw->model_number (and
vha->hw->model_desc) being exactly 1 character larger, and the replaced
strncpy() was copying only up to the size of the source character
array. Replace this with memtostr(), which is the unambiguous way to
convert a maybe not-NUL-terminated character array into a NUL-terminated
string.

Fixes: 527e9b704c3d ("scsi: qla2xxx: Use memcpy() and strlcpy() instead of strcpy() and strncpy()")
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240410023155.2100422-5-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
[ commit c3408c4ae041 upstream ]
2024-07-15 11:54:23 +03:00
Gleb Chesnokov
5f4eee5fc9 scst_lib: use bdev_nr_bytes(bdev) instead of i_size_read(bdev->bd_inode)
Use the helper to query the size of a block device in bytes.
2024-07-08 13:45:29 +03:00
Gleb Chesnokov
ad35eef335 scst/include/backport.h: Port to Linux kernel v6.10
Support for the following fs layer changes in the Linux kernel v6.10:

- 7c98f7cb8fda ("remove call_{read,write}_iter() functions")
2024-07-08 13:45:29 +03:00
Gleb Chesnokov
e322287f89 scst/include/backport.h: Backport DEFINE_SHOW_STORE_ATTRIBUTE()
Support the previous commit against kernel versions before v6.7.

See also commit 9cba82bba500 ("seq_file: add helper macro to define
attribute for rw file") # v6.7.
2024-05-03 12:50:49 +03:00
Gleb Chesnokov
8a1a7fab1d scst/include/backport.h: Fix the build against UEK kernels
Commit 48ef50966a ("scst/include/backport.h: Port to the latest UEK
kernels") broke the build for UEK kernel versions before v5.4.17-2136.
Fix it.
2024-05-03 12:18:43 +03:00
Gleb Chesnokov
52b5e841cf scst/include/backport.h: Fix backport for new stable kernels
This patch fixes the build against kernel versions >= 6.6.23.
2024-05-03 12:18:43 +03:00
Gleb Chesnokov
48ef50966a scst/include/backport.h: Port to the latest UEK kernels
This patch fixes the build against UEK kernel versions
5.4.17-2136.330.7.1.el8uek, 5.15.0-205.149.5.1.el9uek.
2024-05-02 17:20:01 +03:00
Gleb Chesnokov
71abad275e scst/include/backport.h: Fix backport for new stable kernels
This patch fixes the build against kernel versions >= 5.10.210.
2024-05-02 17:20:01 +03:00
Gleb Chesnokov
12f9b6e681 scst_lib, scst_vdisk: Port to Linux kernel v6.9
Support for the following block layer changes in the Linux kernel v6.9:

- f3a608827d1f ("bdev: open block device as files")
- b1211a25c4fe ("bdev: make bdev_{release, open_by_dev}() private to
  block layer")
2024-04-25 16:10:21 +03:00
Gleb Chesnokov
974001f66f scst/include/backport.h, scst_vdisk: Port to Linux kernel v6.8
Support for the following block layer changes in the Linux kernel v6.8:

- e719b4d15674 ("block: Provide bdev_open_* functions")
- cd34758c5238 ("block: Remove blkdev_get_by_*() functions")
2024-02-16 13:52:34 +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
Brian Meagher
df039cb3e9 scst.h, scst, device handlers: Fix scst_replace_port_info
scst_pass_through_cmd_done can run in interrupt context, and call
scst_replace_port_info, which in turn was calling scst_lookup_tg_id.
Since scst_lookup_tg_id does a mutex_lock, we should not call it from
interrupt context.

Add scst_cmd_inquired_dev_ident and use in various locations.
2024-01-12 10:50:15 +03:00
Gleb Chesnokov
50e1babd39 scst/include/backport.h: Fix backport for new stable kernels
This patch fixes the build against kernel versions 5.4.263, 5.10.203,
5.15.136.
2024-01-10 19:34:49 +03:00
Gleb Chesnokov
7a48f02640 scst/include/backport.h: Port to the latest UEK 7 kernel
This patch fixes the build against UEK kernel 5.15.0-201.135.6.el9uek.
2024-01-10 19:34:49 +03:00
Gleb Chesnokov
d3da391be8 scst/include/backport.h: Unbreak the RHEL 8.9 build 2023-12-27 21:13:12 +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
12fd0ea93e scst/include/backport.h: Backport some debugfs functions
Support the previous commit against kernel versions before v5.0.

See also commit ff9fb72bc077 ("debugfs: return error values,
not NULL") # v5.0.
2023-10-10 15:10:02 +03:00
Gleb Chesnokov
60c26136bf scst/include/backport.h: Unbreak the RHEL 9.3 build
Fixes: https://github.com/SCST-project/scst/issues/167
2023-10-09 09:46:21 +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
d74330aed2 qla2x00t-32gbit: Backport to older kernel versions
Unbreak the build for the previous commit against kernel versions
before v5.16.

See also commit 3080ea5553cc ("stddef: Introduce DECLARE_FLEX_ARRAY()
helper") # v5.16.
2023-07-19 11:35:51 +03:00
Gleb Chesnokov
7a1d0ddaf5 qla2x00t-32gbit: Backport to older kernel versions
Unbreak the build for the previous commit against kernel versions
before v5.1.
2023-07-19 11:35:51 +03:00
Gleb Chesnokov
606430be29 scst/include/backport.h: Improve the RHEL 9.2 backport
This was detected by smatch.
2023-07-19 11:35:51 +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
a62b094f4f scst_user: Port to Linux kernel v6.5
Support for the following mm layer changes in the Linux kernel v6.5:

- 54d020692b34 ("mm/gup: remove unused vmas parameter from
  get_user_pages()")
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
76750f3352 scst: Port to Linux kernel v6.5
Support for the following block layer changes in the Linux kernel v6.5:

- 05bdb9965305 ("block: replace fmode_t with a block-specific type for
  block open flags")
- 0718afd47f70 ("block: introduce holder ops")
- 2736e8eeb0cc ("block: use the holder as indication for exclusive opens")
2023-07-10 10:34:57 +03:00
Gleb Chesnokov
6a925490fd scst: Confirm percpu refs has scheduled and switched to atomic
This patch replaces percpu_ref_kill() with percpu_ref_kill_and_confirm()
to guarantee safe usage of references in atomic mode immediately
afterwards.

This change ensures accurate checking of active commands following the
initial reference killing.

Reported-by: Lev Vainblat <lev@zadarastorage.com>
2023-06-28 19:31:45 +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
2c5c12c017 scst_lib: Enable scst_sync_ext_block_dev() to handle signals
This patch modifies scst_sync_ext_block_dev() to support INTERRUPTIBLE
waiting and handle signal-induced waiting cancellation. To achieve this,
the waitqueue head is moved from the stack and allocated with the blocker.
Additionally, reference counting and its management are added to the
blocker to handle memory freeing from multiple contexts.

Fixes: https://github.com/SCST-project/scst/issues/164
2023-06-20 09:53:50 +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
334d29c96a scst.h: Unify names in prepare_to_wait_exclusive_head()
Use the standardized version of the name for wait_queue_head and
wait_queue_entry variables.

This patch doesn't change any functionality.
2023-06-20 09:53:50 +03:00
Gleb Chesnokov
3b0ab93c93 scst/include/backport.h: Unbreak the RHEL 9.3 build
Fixes: https://github.com/SCST-project/scst/issues/167
2023-06-13 17:49:50 +03:00
Brian Meagher
92db6a9fc5 scst_pres,scst_dlm: Fix broken UNIT ATTENTION for remote PR registrants
Previously, when scst_pr_send_ua_reg attempted to deliver a UNIT ATTENTION
to a registrant that was on another node in a dlm-based HA cluster, the
unit attention was dropped.

Rectify by adding a pr_reg_queue_rem_ua function to struct scst_cl_ops and
calling it from scst_pr_send_ua_reg.

Each registrant will maintain an incoming 'queue' of unit attentions by
adding next_rem_ua_idx to the registrant data maintained in the DLM.  This
will tell the other nodes which PR_REG_UA_LOCK lock to create in the
lockspace in order to 'send' a unit attention to the registrant.

Further, each node will also maintain two lists (pending and sent) for the
outgoing unit attentions from this node to a registrant.  When the
recipient has read all the sent unit attentions (and cleared
next_rem_ua_idx), then the sent list may be cleared.
2023-05-10 10:31:51 +03:00
Brian Meagher
c326e96886 scst_lib,scst_sysfs: Add aen_disabled setting
Add a setting to scst_tgt that can prevent scst_gen_aen_or_ua from
generating an AEN, even if the underlying transport is capable of
transmitting them.  It will instead generate a UA.
2023-04-17 20:31:58 +03:00
Gleb Chesnokov
6f9a595f24 scst/include/backport.h: Fix the RHEL 9.0 build
Commit 9be09fd68b ("scst/include/backport.h: Fix building on
RHEL 8.8") fixed the build for RHEL 8.8, but at the same time, it
broke the build for RHEL 9.0.
2023-04-06 13:02:25 +03:00
Gleb Chesnokov
70dfb06c40 scst: Fix a checkpatch complaint about whitespace
This patch fixes the following checkpatch warnings:

    WARNING:SPACE_BEFORE_TAB: please, no space before tabs.
2023-04-04 11:47:44 +03:00
Robert Blackhart
9be09fd68b scst/include/backport.h: Fix building on RHEL 8.8
This fixes a compilation issue with RHEL 8.8 in scst/include/backport.h.
This is the same issue as was seen for RHEL 8.7 in #77
2023-04-03 14:15:55 +03:00
Gleb Chesnokov
906b1c8368 qla2x00t-32gbit: Port to Linux kernel v6.3
Support for the following fc changes in the Linux kernel v6.3:
- 64fd2ba977b1 ("scsi: scsi_transport_fc: Add an additional flag to fc_host_fpin_rcv()")
2023-03-06 20:30:43 +03:00
Gleb Chesnokov
c9476f104c scst: Port to Linux kernel v6.3
Support for the following scsi core changes in the Linux kernel v6.3:
- d0949565811f ("scsi: core: Add struct for args to execution functions")
2023-03-06 13:35:11 +03:00
Gleb Chesnokov
8068b10cac scst/include/backport.h: Fix the CentOS / RHEL 7.[012345] builds
See also PR https://github.com/SCST-project/scst/pull/132.
2023-02-19 17:01:38 +03:00
Gleb Chesnokov
250c9cd76a scst: Fix a version string mismatch
Make the SCST_VERSION_STRING macro revision-independent, because it
causes a version string mismatch for SCST-dependent modules where the
revision is not exported.

Fixes: a86e5c55ea ("Makefile, scst: Add revision to SCST version macro")
Fixes: https://github.com/SCST-project/scst/issues/130
2023-02-12 17:44:32 +03:00
Gleb Chesnokov
a86e5c55ea Makefile, scst: Add revision to SCST version macro
Add SCST revision to SCST_VERSION_STRING macro. This might be useful
for issues reporting/investigation.
2023-01-29 16:31:20 +03:00
Brian Meagher
cbc8d5ee9b scst/include/backport.h: Do not set rq->end_io to NULL
Fix a regression introduced during d989aa91f3 ("scst_lib: Port to
Linux kernel v5.19") that breaks dev_disk operation.

The kernel function blk_execute_rq_nowait will set rq->end_io to the
done parameter, so pass in the existing rq->end_io rather than NULL
to prevent zeroing it.

Fixes: d989aa91f3 ("scst_lib: Port to Linux kernel v5.19")
[ glebchesn: added patch description ]
2023-01-05 20:37:27 +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
7dc56a07bf scst: Backport the PTR_ERR_OR_ZERO() function
Unbreak the build for the previous commit against kernel versions
before v3.12.

Fixes: ee6312ac5a ("scst_vdisk, qla2x00t-32gbit: Use PTR_ERR_OR_ZERO
instead of IS_ERR and PTR_ERR")
2022-12-27 16:23:46 +03:00