Commit Graph

8719 Commits

Author SHA1 Message Date
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
Gleb Chesnokov
4649a6abd4 scst/include/backport.h, scst_sysfs: Prefer 'unsigned int' over bare 'unsigned'
The bare "unsigned" type implicitly means "unsigned int", but the preferred
coding style is to use the complete type name.

This patch fixes the following checkpatch warnings:

    WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
2022-08-09 19:38:00 +03:00
Gleb Chesnokov
1e168e6676 iscsi-scst: Fix spelling mistake in comment
Change 'compability' to 'compatibility'.

This patch fixes the following checkpatch warning:

    WARNING: 'compability' may be misspelled - perhaps 'compatibility'?
2022-08-09 19:38:00 +03:00
Gleb Chesnokov
d94c7fb06e scst_lib, scst_vdisk: Remove unlikely from IS_ERR_OR_NULL
This patch fixes the following checkpatch warnings:

    WARNING:LIKELY_MISUSE: nested (un)?likely() calls,
    IS_ERR_OR_NULL already uses unlikely() internally.
2022-08-09 19:38:00 +03:00
Gleb Chesnokov
b4e09bac10 nightly build: Update kernel versions 2022-08-02 15:17:10 +03:00
Gleb Chesnokov
7b55903875 mailmap: Update Gleb Chesnokov's email address
I have created a new dedicated email address for SCST. So add
information about it.

New email: gleb.chesnokov@scst.dev
2022-07-29 21:42:15 +03:00
Bart Van Assche
6641fa81bf ib_srpt: Remove the obsolete max_sge_delta kernel module parameter 2022-07-27 20:17:03 -07:00
Bart Van Assche
4b7b3e2c58 ib_srpt: Remove obsolete parameters and update documentation
Support for the ib_srpt_target_<n> target port names was removed in 2015.
Update the documentation that still uses this target port name format.
Remove all references to the obsolete ib_srpt kernel module parameters
use_port_guid_in_session_name and use_node_guid_in_target_name. Remove
the references from srpt/README to target port name formats that are no
longer supported.
2022-07-27 20:14:23 -07:00
Gleb Chesnokov
8ac0b4e6b4 scst_lib: Fix memory leak reported by Coverity
This patch fixes the following Coverity complaint:

    CID 275306 (#1 of 1): Resource leak (RESOURCE_LEAK)
    Variable cwrp going out of scope leaks the storage it points to.

In the scst_cmp_wr_local() function, we don't free 'cwrp' if the next
check after the memory allocation fails. Hence move this check before
allocating memory.

Fixes: 4525b04b2 ("scst: Reject inconsistent COMPARE AND WRITE commands")
2022-07-26 18:43:34 +03:00
Gleb Chesnokov
60e0a15f41 README.md: Use the preferred way to integrate the Coverity Scan Badge 2022-07-26 16:11:11 +03:00
Gleb Chesnokov
fabd3dadc9 github: Ignore errors when building SCST for Coverity
The GitHub virtual environment provides Ubuntu with a kernel that doesn't
support FCoE, causing the build to fail:

ERROR: modpost: "fc_seq_release" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_fc4_register_provider" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_lport_iterate" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_seq_els_rsp_send" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_seq_assign" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "_fc_frame_alloc" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_fill_reply_hdr" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_exch_done" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_fc4_deregister_provider" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
ERROR: modpost: "fc_frame_alloc_fill" [/root/gleb/SCST/scst/fcst/fcst.ko] undefined!
WARNING: modpost: suppressed 4 unresolved symbol warnings because there were too many)

Ignore these errors and continue building SCST to get all the information
for analysis.
2022-07-26 16:11:11 +03:00
Gleb Chesnokov
b6b23e9a0c README.md: Add Coverity Scan Badge 2022-07-25 14:41:32 +03:00
Gleb Chesnokov
4418538578 github: Add a GitHub action to run a Coverity scan upon push
Submit a build to the Coverity analyzer for every change in the
master branch.

You can find the results of Coverity's analysis here:
https://scan.coverity.com/projects/scst-project
2022-07-25 14:41:32 +03:00
Gleb Chesnokov
5c7fa24031 Makefile: Introduce the 'make cov-build'
Introduce a new helper target to build the SCST for the Coverity scan.
2022-07-25 14:41:32 +03:00
Gleb Chesnokov
1db47d2a3e scst_main: Fix up the error handling
We should clear sysfs during copy manager device registration failure.
Otherwise, we will not be able to re-register this device, since the
sysfs for it has already been created.
2022-07-23 20:46:21 +03:00
Gleb Chesnokov
4a02996629 scst_copy_mgr, initial inquiry: Fix up the error handling
1. scst_cm_send_init_inquiry() gets a reference on struct scst_device, but
   doesn't put it in case of an error, so this may cause a reference leak.

2. scst_cm_init_inq_finish() shouldn't put a reference on struct
   scst_device during the retry, since we have to hold the reference as
   long as there is a pointer to struct scst_device in the priv field.
   Otherwise, the retry command will run without holding the reference.

Fixes: ec3c6b5a ("scst_copy_mgr, initial inquiry: Hold a reference on
struct scst_device")
2022-07-23 20:46:21 +03:00
Gleb Chesnokov
f06a86e4aa scstadmin/scstadmin.sysfs/Makefile: Add makefile target
Most targets of this Makefile require a underlying Makefile to be
created before they are called. Otherwise you will get an error like
this:

  make -C scst-1.0.0 clean
  make[3]: Entering directory '/.../scst/scstadmin/scstadmin.sysfs/scst-1.0.0'
  make[3]: *** No rule to make target 'clean'.  Stop.

Hence add a target that creates a underlying Makefile and add it as a
dependency for all required targets.
2022-07-12 19:34:18 +03:00
Gleb Chesnokov
fa8f125ed8 scst_vdisk: Introduce the primitives for [de]activating a virt device
Currently we have several places where activating/deactivating of
virtual device happens:

  1. sysfs 'active' attribute
  2. on_alua_state_change_*() callback functions

They all use the same code to activate/deactivate virtual device.

Hence introduce the new vdisk_activate_dev() and vdisk_disable_dev()
helpers in order to reduce code duplication.

This patch doesn't change any functionality.
2022-07-12 16:02:44 +03:00
Gleb Chesnokov
904bd8428b scst_vdisk: Unbreak the RHEL 9 build 2022-07-11 22:03:32 +03:00
Gleb Chesnokov
b93b18731f scst_tg: Fix usage of the on_alua_state_change_*() callback functions
The use of the on_alua_state_change_*() callback functions was changed in
commit d333ce82 ("Restore the on_alua_state_change_*() callback functions")
in a such way that they are now only invoked if the state of a local target
port group is being modified.

But when compared to the old implementation, which was removed in commit
29548a4a ("scst: Remove the on_alua_state_change_*() callback functions"),
they won't be invoked for devices that do not have target devices, or have
only those that aren't included in the target group.

Hence additionally invoke these callbacks for such devices if the state of
a local target port group is being modified.

Fixes: https://github.com/SCST-project/scst/issues/55
2022-07-08 14:47:30 +03:00
Gleb Chesnokov
b07796ccca scst_tg: Introduce __scst_tg_have_tgt()
Introduce the helper function __scst_tg_have_tgt(), which purpose
is to check if the given target group contains the given target.
2022-07-08 14:47:30 +03:00
Gleb Chesnokov
0a25757b97 nightly build: Add UEK 7 kernels 2022-07-07 13:52:01 +03:00
Gleb Chesnokov
1139a7847d scst.spec.in, scst-dkms.spec.in: Unbreak the UEK 7 build 2022-07-07 13:52:01 +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
Gleb Chesnokov
828940842a iscsi-scst/usr/iscsi_adm.c: Fix use of uninitialized struct field
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.
2022-06-27 14:14:52 +03:00
Gleb Chesnokov
d9442eaa18 iscsi-scst: Fix use of uninitialized struct field
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.
2022-06-27 14:14:52 +03:00
Gleb Chesnokov
4399f2d109 scst_lib: Simplify redundant boolean expression
This was detected by Coverity.
2022-06-21 00:50:58 +03:00
Gleb Chesnokov
590d0c6d24 scst_vdisk: Make vdev_sysfs_process_active_store() more readable
This patch doesn't change any functionality.
2022-06-21 00:50:58 +03:00
Gleb Chesnokov
6f9e451360 scst: Display default SCST module parameters values
The 'modinfo scst' command lack of the information about default parameters
values. Hence this patch.
2022-06-20 16:08:18 +03:00
Gleb Chesnokov
19a03ed163 scst_main: Use bool type for boolean module params
This patch doesn't change any functionality.
2022-06-20 16:08:18 +03:00
Gleb Chesnokov
4123e521cc qla2x00t-32gbit: Remove unused 'ql_dm_tgt_ex_pct' parameter
The ql_dm_tgt_ex_pct parameter was introduced in commit ead038556f64
("qla2xxx: Add Dual mode support in the driver"). Then the use of this
parameter was dropped in commit 99e1b683c4be ("scsi: qla2xxx: Add
ql2xiniexchg parameter").

Thus, remove ql_dm_tgt_ex_pct since it is no longer used.

Link: https://lore.kernel.org/r/AM9PR10MB41185ADE95B92B4E6926BE639DD49@AM9PR10MB4118.EURPRD10.PROD.OUTLOOK.COM
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit aa2a4ded0505 upstream ]
2022-06-17 16:03:13 +03:00
Gleb Chesnokov
4b5e61abda qla2x00t-32gbit: Remove setting of 'req' and 'rsp' parameters
cppcheck reports
[drivers/scsi/qla2xxx/qla_mid.c:594]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[drivers/scsi/qla2xxx/qla_mid.c:620]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?

The functions qla25xx_free_req_que() and qla25xx_free_rsp_que() are
similar.  They free a 'req' and a 'rsp' parameter respectively. The last
statement of both functions is setting the parameter to NULL. This has no
effect and can be removed.

Link: https://lore.kernel.org/r/20220521201607.4145298-1-trix@redhat.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit e250bd2699e0 upstream ]
2022-06-17 16:03:13 +03:00
Gleb Chesnokov
323de1df4d qla2x00t-32gbit: edif: Remove unneeded variable
Fix the following coccicheck warning:

drivers/scsi/qla2xxx/qla_edif.c:660:11-15: Unneeded variable: "rval".

Return "0" on line 761.

Link: https://lore.kernel.org/r/20220426074334.9281-1-guozhengkui@vivo.com
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit 1497e95e22c3 upstream ]
2022-06-17 16:03:13 +03:00
Gleb Chesnokov
f36a96158b qla2x00t-32gbit: Remove unneeded flush_workqueue()
All work currently pending will be done first by calling
destroy_workqueue(). There is no need to flush it explicitly.

Link: https://lore.kernel.org/r/20220424062413.3220315-1-ran.jianping@zte.com.cn
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: ran jianping <ran.jianping@zte.com.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit cf97628fe1a1 upstream ]
2022-06-17 16:03:13 +03:00
Gleb Chesnokov
de226bdafe qla2x00t-32gbit: Remove free_sg command flag
The use of the free_sg command flag was dropped in commit 2c39b5ca2a8c
("qla2xxx: Remove SRR code"). Hence remove this flag and its check.

Link: https://lore.kernel.org/r/AS8PR10MB4952747D20B76DC8FE793CCA9DEE9@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit ad14649fc5ab upstream ]
2022-06-17 16:03:13 +03:00
Gleb Chesnokov
7e0974d6f4 scst_vdisk: Port to Linux kernel v5.19
Support for the following block layer changes in the Linux Kernel v5.19:
- 44abff2c0b97 ("block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD")
- 70200574cc22 ("block: remove QUEUE_FLAG_DISCARD")
2022-06-17 15:49:57 +03:00
Gleb Chesnokov
d989aa91f3 scst_lib: Port to Linux kernel v5.19
Support for the following block layer changes in the Linux Kernel v5.19:
- e2e530867245 ("blk-mq: remove the done argument to blk_execute_rq_nowait")
2022-06-17 15:49:57 +03:00
Gleb Chesnokov
55ba4339dd qla2x00t/doc/qla2x00t-howto.html: Add information about initiator and target modes
Qlogic documentation lack of the information about initiator and target modes
usage.
2022-06-16 13:30:21 +03:00
Gleb Chesnokov
f7fabfd200 qla2x00t: Remove pci-dma-compat wrapper API
The legacy API wrappers in include/linux/pci-dma-compat.h should go away as
they create unnecessary midlayering for include/linux/dma-mapping.h API.
Instead use dma-mapping.h API directly.

This patch fixes build for linux kernel v5.18.
2022-05-24 17:58:45 +03:00
Gleb Chesnokov
b3a55ba0c1 nightly build: Update kernel versions 2022-05-24 13:12:59 +03:00
Gleb Chesnokov
6be8d30745 scst_vdisk: Remove unused zero_copy flag
The old zero-copy implementation that used zero_copy flag was removed in
commit 19c9aec2 ("vdisk_fileio: Remove the page cache based zero-copy
implementation"). Hence remove this flag since it is no longer used.
2022-05-23 14:24:40 +03:00
Gleb Chesnokov
80958ae4ef qla2x00t-32gbit: Change the default qlini_mode to exclusive
By default the qlini_mode module parameter set initiator mode to 'enabled'.
This forces a SCST user to perform additional steps to activate the target mode.

Thus, change the default qlini_mode to simplify target mode usage, since
the SCST qla2xxx_scst module is usually only used with it.
2022-05-23 14:07:08 +03:00
Gleb Chesnokov
679ca7c14e qla2x00t-32gbit: Change preferred context for scst_cmd_init_done()
Calling scst_cmd_init_done() with SCST_CONTEXT_DIRECT from
sqa_qla2xxx_handle_cmd() cause a SCST READ commands to stall for
scst_user devices.

The problem is that scst_user devices use udev_cmd_threads for processing
SCST commands, so it's necessary to call the scst_user dev handler
callbacks from the SCST_CONTEXT_THREAD context.

For write commands, this is already done because scst_rx_data() always
processes commands with a THREAD context. But for READ commands, it
depends on passing the preferred context value to scst_cmd_init_done().

So pass the SCST_CONTEXT_THREAD or SCST_CONTEXT_TASKLET to
scst_cmd_init_done(). SCST_CONTEXT_TASKLET would also work, because
the context optimization in scst_init_cmd() will still set SCST_CONTEXT_THREAD
for READ commands.

Reported-by: Eitan Cohen <eitancohen456@gmail.com>
2022-05-23 13:51:27 +03:00
Gleb Chesnokov
2a0d4be31c www: Update SCST overview slides URL
Replace the broken URL of SCST overview slides with a working URL.
2022-05-18 11:14:17 +03:00
Gleb Chesnokov
4401a3e064 qla2x00t-32gbit: Do not call scst_unregister_target() twice
If there are any NPIV targets, sqa_exit() will call
scst_unregister_target() twice on them. The first is an explicit call,
the other is triggered by qlt_del_vtarget().

Calling scst_unregister_target() twice on the same target will cause
crash:

RIP: 0010:sqa_target_release+0x19/0x220 [qla2x00tgt]
Call Trace:
  scst_unregister_target+0x8e/0x330 [scst]
  sqa_qla2xxx_remove_target+0x63/0x70 [qla2x00tgt]
  qlt_release+0x1e0/0x260 [qla2xxx_scst]
  qlt_remove_target+0x46/0x1d0 [qla2xxx_scst]
  qla24xx_vport_delete+0x92/0x1e0 [qla2xxx_scst]
  fc_vport_terminate+0x45/0x170 [scsi_transport_fc]
  qlt_del_vtarget+0x142/0x15d [qla2x00tgt]
  fc_vport_terminate+0x45/0x170 [scsi_transport_fc]
  qlt_del_vtarget+0x142/0x15d [qla2x00tgt]
  sqa_exit+0xad/0xde4 [qla2x00tgt]

Therefore, call scst_unregister_target() only from qlt_del_vtarget()
2022-05-17 11:26:02 +03:00
Gleb Chesnokov
fa4cb77a87 qla2x00t-32gbit: Fix crash during deregistering an NPIV port
NPIV port deregistering processing is different from physical port
processing. We use the same handling for both of them, which causes
the crash when it's an NPIV port. Hence separate the common processing
logic depending on the type of port.

Reported-by: Rob Turk <robtu@rtist.nl>
2022-05-17 11:26:02 +03:00
Gleb Chesnokov
c20d0edef8 scst_vdisk: Fix build on RHEL 8.6
Reported-by: Gilbert Standen <gilstanden@hotmail.com>

Fixes: https://github.com/SCST-project/scst/issues/45
2022-05-16 11:39:37 +03:00
Gleb Chesnokov
dc99c021f0 qla2x00t-32gbit: Fix missed DMA unmap for aborted commands
Aborting commands that have already been sent to the firmware can
cause BUG in qlt_free_cmd(): BUG_ON(cmd->sg_mapped)

For instance:

 - Command passes rdx_to_xfer state, maps sgl, sends to the firmware

 - Reset occurs, qla2xxx performs ISP error recovery, aborts the command

 - Target stack calls qlt_abort_cmd() and then qlt_free_cmd()

 - BUG_ON(cmd->sg_mapped) in qlt_free_cmd() occurs because sgl was not
   unmapped

Thus, unmap sgl in qlt_abort_cmd() for commands with the aborted flag set.

Link: https://lore.kernel.org/r/AS8PR10MB4952D545F84B6B1DFD39EC1E9DEE9@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ commit 26f9ce53817a upstream ]
2022-05-15 16:40:51 +03:00