diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index dd53fb96f..b211d6b4d 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3464,10 +3464,15 @@ static int iscsi_tcp_send_locally(struct iscsi_cmnd *req, static void iscsi_tcp_conn_close(struct iscsi_conn *conn, int flags) { - if (!flags) - conn->sock->sk->sk_prot->disconnect(conn->sock->sk, 0); - else + struct sock *sk = conn->sock->sk; + + if (!flags) { + lock_sock(sk); + sk->sk_prot->disconnect(sk, 0); + release_sock(sk); + } else { conn->sock->ops->shutdown(conn->sock, flags); + } } static int iscsi_xmit_response(struct scst_cmd *scst_cmd) diff --git a/qla2x00t/qla_dbg.c b/qla2x00t/qla_dbg.c index 4ce10d7c3..0a96d1e09 100644 --- a/qla2x00t/qla_dbg.c +++ b/qla2x00t/qla_dbg.c @@ -2265,11 +2265,11 @@ ql_dbg(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...) if (vha != NULL) { const struct pci_dev *pdev = vha->hw->pdev; /* : Message */ - pr_warning("%s [%s]-%04x:%ld: ", + pr_warn("%s [%s]-%04x:%ld: ", QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, vha->host_no); } else { - pr_warning("%s [%s]-%04x: ", + pr_warn("%s [%s]-%04x: ", QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset); } @@ -2306,7 +2306,7 @@ ql_dbg_pci(uint32_t level, struct pci_dev *pdev, int32_t id, va_start(va, fmt); /* : Message */ - pr_warning("%s [%s]-%04x: ", + pr_warn("%s [%s]-%04x: ", QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset); vprintk(fmt, va); @@ -2356,7 +2356,7 @@ ql_log(uint32_t level, scsi_qla_host_t *vha, int32_t id, const char *fmt, ...) pr_err("%s", pbuf); break; case ql_log_info: - pr_warning("%s", pbuf); + pr_warn("%s", pbuf); break; default: pr_info("%s", pbuf); @@ -2406,7 +2406,7 @@ ql_log_pci(uint32_t level, struct pci_dev *pdev, int32_t id, pr_err("%s", pbuf); break; case ql_log_info: - pr_warning("%s", pbuf); + pr_warn("%s", pbuf); break; default: pr_info("%s", pbuf); diff --git a/qla2x00t/qla_def.h b/qla2x00t/qla_def.h index 31d4e79ca..6991e9016 100644 --- a/qla2x00t/qla_def.h +++ b/qla2x00t/qla_def.h @@ -1796,7 +1796,7 @@ typedef struct fc_port { #define FCS_DEVICE_LOST 3 #define FCS_ONLINE 4 -static const char *port_state_str[] = { +static const char *const port_state_str[] = { "Unknown", "UNCONFIGURED", "DEAD", diff --git a/scripts/checkpatch b/scripts/checkpatch index bddb1b765..d9519526c 100755 --- a/scripts/checkpatch +++ b/scripts/checkpatch @@ -3,6 +3,8 @@ ignore=( CONSTANT_COMPARISON LINUX_VERSION_CODE + LONG_LINE + LONG_LINE_COMMENT LONG_LINE_STRING RETURN_VOID SPDX_LICENSE_TAG diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 5d8a61a03..8800e589e 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -114,7 +114,6 @@ function specialize_patch { "$(dirname "$0")/specialize-patch" \ "${specialize_patch_options[@]}" \ -v kernel_version="${kver3}" \ - -v SCSI_EXEC_REQ_FIFO_DEFINED="${scsi_exec_req_fifo_defined}" \ -v SCST_IO_CONTEXT="${scst_io_context}" else cat diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 40563a6fa..eb28570a4 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -226,14 +226,6 @@ function evaluate(stmnt, pattern, arg, op, result) { gsub("defined\\(UEK_KABI_RENAME\\)", "0", stmnt) - if (SCSI_EXEC_REQ_FIFO_DEFINED != "") - { - gsub("defined[[:blank:]]+SCSI_EXEC_REQ_FIFO_DEFINED", - SCSI_EXEC_REQ_FIFO_DEFINED, stmnt) - gsub("defined[[:blank:]]*\\([[:blank:]]*SCSI_EXEC_REQ_FIFO_DEFINED[[:blank:]]*\\)", - SCSI_EXEC_REQ_FIFO_DEFINED, stmnt) - } - if (SCST_IO_CONTEXT != "") { gsub("defined[[:blank:]]+SCST_IO_CONTEXT", SCST_IO_CONTEXT, stmnt) @@ -428,7 +420,6 @@ function handle_if(evaluated) && $0 ~ "GENERATING_UPSTREAM_PATCH" \ || $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \ || ($0 ~ "CONFIG_SCST_PROC" && config_scst_proc_undefined) \ - || ($0 ~ "SCSI_EXEC_REQ_FIFO_DEFINED" && SCSI_EXEC_REQ_FIFO_DEFINED!="") \ || ($0 ~ "SCST_IO_CONTEXT" && SCST_IO_CONTEXT != "")) { } @@ -523,19 +514,9 @@ function process_preprocessor_statement(evaluated, condition) { printf "/* debug specialize-patch: (g2) %s: output = %d */\n", \ evaluated, output } - if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \ - && SCSI_EXEC_REQ_FIFO_DEFINED != "" \ - || evaluated ~ "^+#define SCST_IO_CONTEXT$" \ - && SCST_IO_CONTEXT != "" \ - || (evaluated ~ "^+#define CONFIG_SCST_PROC$" \ - && config_scst_proc_undefined)) - { - discard = 1 - delete_next_blank_line = 1 - } - else if (output && (!condition || \ - decision[if_nesting_level + (evaluated ~ "^+#endif$")] \ - !~ "^+#(el|)if [01]")) + if (output && (!condition || \ + decision[if_nesting_level + (evaluated ~ "^+#endif$")] \ + !~ "^+#(el|)if [01]")) { if (evaluated == "+#if undecided" \ || (evaluated !~ "^+#if" \ diff --git a/scst/include/backport.h b/scst/include/backport.h index 0ece4c6b0..32d624d5d 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -853,6 +853,17 @@ static inline void lockdep_unregister_key(struct lock_class_key *key) } #endif +/* + * See also commit 5facae4f3549 ("locking/lockdep: Remove unused @nested + * argument from lock_release()"). + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) +#undef rwlock_release +#define rwlock_release(l, i) lock_release(l, 1, i) +#undef mutex_release +#define mutex_release(l, i) lock_release(l, 0, i) +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) /* @@ -1148,7 +1159,7 @@ static inline bool percpu_ref_is_zero(struct percpu_ref *ref) #define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) #define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) #define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) #define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) #endif /* pr_emerg */ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 613259b94..e333a7b16 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2718,7 +2718,7 @@ out_err: goto out; } -static int vdisk_parse(struct scst_cmd *cmd) +static int fileio_parse(struct scst_cmd *cmd) { int res, rc; @@ -3312,6 +3312,14 @@ static enum compl_status_e fileio_exec_async(struct vdisk_cmd_params *p) } #endif +static void blockio_on_free_cmd(struct scst_cmd *cmd) +{ + if (!scst_cmd_get_dh_data_buff_alloced(cmd)) + return; + sgv_pool_free(cmd->sgv, &cmd->dev->dev_mem_lim); + cmd->sgv = NULL; +} + static void vdisk_on_free_cmd_params(const struct vdisk_cmd_params *p) { if (!p->execute_async) { @@ -3403,6 +3411,29 @@ out: return res; } +static int blockio_alloc(struct scst_cmd *cmd) +{ + struct scst_tgt_dev *tgt_dev = cmd->tgt_dev; + struct sgv_pool *pool = tgt_dev->pools[raw_smp_processor_id()]; + int res = SCST_CMD_STATE_DEFAULT; + + if (cmd->sg && (cmd->sg->offset & 511) == 0) + return res; + + WARN_ON_ONCE(cmd->sgv); + cmd->sg = sgv_pool_alloc(pool, cmd->bufflen, cmd->cmd_gfp_mask, 0, + &cmd->sg_cnt, &cmd->sgv, + &cmd->dev->dev_mem_lim, NULL); + if (!cmd->sg) { + res = SCST_CMD_STATE_STOP; + goto out; + } + scst_cmd_set_dh_data_buff_alloced(cmd); + +out: + return res; +} + static enum scst_exec_res blockio_exec(struct scst_cmd *cmd) { struct scst_vdisk_dev *virt_dev = cmd->dev->dh_priv; @@ -9871,7 +9902,7 @@ static const struct attribute *vdisk_fileio_attrs[] = { NULL, }; -static const char *fileio_add_dev_params[] = { +static const char *const fileio_add_dev_params[] = { "async", "blocksize", "cluster_mode", @@ -9909,7 +9940,7 @@ static struct scst_dev_type vdisk_file_devtype = { .detach = vdisk_detach, .attach_tgt = vdisk_attach_tgt, .detach_tgt = vdisk_detach_tgt, - .parse = vdisk_parse, + .parse = fileio_parse, .exec = fileio_exec, .on_free_cmd = fileio_on_free_cmd, .task_mgmt_fn_done = vdisk_task_mgmt_fn_done, @@ -9962,7 +9993,7 @@ static const struct attribute *vdisk_blockio_attrs[] = { NULL, }; -static const char *blockio_add_dev_params[] = { +static const char *const blockio_add_dev_params[] = { "active", "bind_alua_state", "blocksize", @@ -9995,7 +10026,9 @@ static struct scst_dev_type vdisk_blk_devtype = { .attach_tgt = vdisk_attach_tgt, .detach_tgt = vdisk_detach_tgt, .parse = non_fileio_parse, + .dev_alloc_data_buf = blockio_alloc, .exec = blockio_exec, + .on_free_cmd = blockio_on_free_cmd, .on_alua_state_change_start = blockio_on_alua_state_change_start, .on_alua_state_change_finish = blockio_on_alua_state_change_finish, .task_mgmt_fn_done = vdisk_task_mgmt_fn_done, @@ -10038,7 +10071,7 @@ static const struct attribute *vdisk_nullio_attrs[] = { NULL, }; -static const char *nullio_add_dev_params[] = { +static const char *const nullio_add_dev_params[] = { "blocksize", "cluster_mode", "dif_mode", diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a0b69aa02..e3c832110 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -147,8 +147,6 @@ int hex_to_bin(char ch) EXPORT_SYMBOL(hex_to_bin); #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) || \ - !defined(SCSI_EXEC_REQ_FIFO_DEFINED) static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) int nents_to_copy, size_t copy_len, @@ -156,7 +154,6 @@ static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #else int nents_to_copy, size_t copy_len); #endif -#endif static void scst_free_descriptors(struct scst_cmd *cmd); static bool sg_cmp(struct scatterlist *dst_sg, struct scatterlist *src_sg, @@ -8393,7 +8390,6 @@ out: } #endif -#if !defined(SCSI_EXEC_REQ_FIFO_DEFINED) /* * Can switch to the next dst_sg element, so, to copy to strictly only * one dst_sg element, it must be either last in the chain, or @@ -8545,7 +8541,6 @@ static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, out: return res; } -#endif /* !defined(SCSI_EXEC_REQ_FIFO_DEFINED) */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && \ diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index b3a00f745..f03210d4e 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -48,10 +48,8 @@ details. #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) && \ - !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && \ !defined(CONFIG_SCST_STRICT_SERIALIZING) -#warning Patch scst_exec_req_fifo- was not applied on \ -your kernel and CONFIG_SCST_STRICT_SERIALIZING is not defined. \ +#warning CONFIG_SCST_STRICT_SERIALIZING has not been defined. \ Pass-through dev handlers will not work. #endif @@ -979,7 +977,7 @@ out: if (res == 0) lock_acquired(&scst_suspend_dep_map, _RET_IP_); else - rwlock_release(&scst_suspend_dep_map, 1, _RET_IP_); + rwlock_release(&scst_suspend_dep_map, _RET_IP_); #endif TRACE_EXIT_RES(res); @@ -1059,7 +1057,7 @@ void scst_resume_activity(void) TRACE_ENTRY(); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) - rwlock_release(&scst_suspend_dep_map, 1, _RET_IP_); + rwlock_release(&scst_suspend_dep_map, _RET_IP_); #endif mutex_lock(&scst_suspend_mutex); @@ -1538,7 +1536,6 @@ int __scst_register_dev_driver(struct scst_dev_type *dev_type, goto out; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) && \ - !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && \ !defined(CONFIG_SCST_STRICT_SERIALIZING) if (dev_type->exec == NULL) { PRINT_ERROR("Pass-through dev handlers (handler \"%s\") not " diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 94d84f9eb..47483eec9 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -457,12 +457,9 @@ static inline int scst_exec_req(struct scsi_device *sdev, #if defined(CONFIG_SCST_STRICT_SERIALIZING) return scsi_execute_async(sdev, cmd, cmd_len, data_direction, (void *)sgl, bufflen, nents, timeout, retries, privdata, done, gfp); -#elif !defined(SCSI_EXEC_REQ_FIFO_DEFINED) +#else WARN_ON(1); return -1; -#else - return scsi_execute_async_fifo(sdev, cmd, cmd_len, data_direction, - (void *)sgl, bufflen, nents, timeout, retries, privdata, done, gfp); #endif } #endif diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index c756c39b9..3d6bc0432 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -464,7 +464,7 @@ static void scst_process_sysfs_works(void) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) if (work->dep_map) - mutex_release(work->dep_map, 0, _RET_IP_); + mutex_release(work->dep_map, _RET_IP_); #endif spin_lock(&sysfs_work_lock); @@ -1213,7 +1213,7 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, out_free: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) lock_acquired(dep_map, _RET_IP_); - mutex_release(dep_map, 0, _RET_IP_); + mutex_release(dep_map, _RET_IP_); #endif kfree(name);