From 56bb6c0fa6726befb8057f28af04af7c81d5bd8b Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Fri, 26 Apr 2024 17:00:51 +0300 Subject: [PATCH 01/26] nightly build, scripts: Remove svn support Remove deprecated svn support. --- nightly/bin/nightly | 23 ++++++----------------- scripts/clean-source-tree | 11 +---------- scripts/list-non-source-files | 6 +----- scripts/list-source-files | 17 ++--------------- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/nightly/bin/nightly b/nightly/bin/nightly index 9173eeac5..9034d0b40 100755 --- a/nightly/bin/nightly +++ b/nightly/bin/nightly @@ -12,11 +12,7 @@ # Returns the revision number of the source files with date $1. get_revision() { - if svn info . >/dev/null 2>&1; then - svn info -r "{$1}" "${scst_repo}" | sed -n 's/^Revision: //p' - else - git log --before="$1" | head -n 1 | cut -f2 -d ' ' - fi + git log --before="$1" | head -n 1 | cut -f2 -d ' ' } runcmd () { @@ -54,11 +50,7 @@ usage () { #---------------------------------------------------------------------------- scst_rootdir="$(dirname "$(dirname "$(cd "$(dirname "$0")" && echo "$PWD")")")" -if svn info . >/dev/null 2>&1; then - scst_repo="$(svn info "$scst_rootdir" | sed -n -e 's|\+ssh://[^@]*@|://|' -e 's/^URL: //p')" -else - scst_repo="$scst_rootdir" -fi +scst_repo="$scst_rootdir" sendmail_opts="" run_if_unchanged="false" @@ -151,13 +143,10 @@ for logfile in old new ; do # Check out and run the tests. runcmd ${logfile} \ "Checking out SCST source tree" \ - "if svn info . >/dev/null 2>&1; then \ - svn co -q -r {${date}} ${scst_repo} ${ABT_TMPDIR}/scst; \ - else \ - ( rmdir ${ABT_TMPDIR}/scst && \ - git clone -q ${scst_repo} ${ABT_TMPDIR}/scst && \ - cd ${ABT_TMPDIR}/scst && git reset --hard ${rev} ); \ - fi" && + "( rmdir ${ABT_TMPDIR}/scst && \ + git clone -q ${scst_repo} ${ABT_TMPDIR}/scst && \ + cd ${ABT_TMPDIR}/scst && git reset --hard ${rev} ); \ + " && runcmd ${logfile} \ "Running regression tests" \ "cd ${ABT_TMPDIR}/scst && \ diff --git a/scripts/clean-source-tree b/scripts/clean-source-tree index a41d41ebe..a141dbf12 100755 --- a/scripts/clean-source-tree +++ b/scripts/clean-source-tree @@ -48,16 +48,7 @@ done for d in "${@-.}"; do ( if cd "$d"; then - if [ -e .svn ]; then - if ! type -p svn >&/dev/null; then - echo "$0: svn: not found." - exit 0 - fi - "$(dirname "$0")"/list-non-source-files | - while read -r f; do - if ! word_in_list "$f" "${exclude[@]}"; then rm -rf -- "$f"; fi; - done - elif [ -e .git ] || [ -e ../.git ]; then + if [ -e .git ] || [ -e ../.git ]; then if ! type -p git >&/dev/null; then echo "$0: git: not found." exit 0 diff --git a/scripts/list-non-source-files b/scripts/list-non-source-files index 7b3a3141c..d6568863b 100755 --- a/scripts/list-non-source-files +++ b/scripts/list-non-source-files @@ -18,11 +18,7 @@ prefix_matches() { for d in "${@-.}"; do ( cd "$d" && - if [ -e .svn ]; then - svn status --no-ignore | - grep '^[I?] ' | - cut -c8- - elif git branch >&/dev/null; then + if git branch >&/dev/null; then exec 3< <(find . -type f | cut -c3- | grep -v '^\.git/' | sort) git ls-tree -r HEAD | cut -f2 -d' ' | sort | while read -r f; do diff --git a/scripts/list-source-files b/scripts/list-source-files index 56e3f1c51..139fa1e39 100755 --- a/scripts/list-source-files +++ b/scripts/list-source-files @@ -5,25 +5,12 @@ list_source_files() { d="$(cd "$1" && echo "$PWD")" r="$d" - while [ "$r" != "/" ] && [ ! -e "$r/.svn" ] && [ ! -e "$r/.git" ] && + while [ "$r" != "/" ] && [ ! -e "$r/.git" ] && [ ! -e "$r/.hg" ]; do r="$(dirname "$r")" done - if [ -e "$r/.svn" ]; then - ( - cd "$d" || exit $? - svn status -v | \ - grep -vE '^[D?]|^Performing|^$' | \ - cut -c3- | \ - while read -r a b c f; do - if [ -f "$f" ] || [ -h "$f" ]; then - echo "$a $b $c" >/dev/null - echo "$f" - fi - done - ) - elif [ -e "$r/.git" ]; then + if [ -e "$r/.git" ]; then subdir="${d#"${r}"}" if [ "$r" != "" ]; then ( cd "$d" && git ls-tree --name-only -r HEAD ) | sed "s|^$subdir/||" From d3a2faecffb46170857ab8b506aa12d562416ecb Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 2 May 2024 15:42:33 +0300 Subject: [PATCH 02/26] scripts/run-regression-tests: Explicitly set KBUILD_MODPOST_WARN=1 This fixes the run-regression-tests build against kernel versions >= v6.3. See also commit 5573b4daa26a ("kbuild: do not automatically add -w option to modpost") # v6.3. --- scripts/run-regression-tests | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index d5f65d84f..764e9d757 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -387,7 +387,7 @@ function compile_kernel { if (cd "${outputdir}/linux-$k" \ && make -s modules_prepare \ && make -s scripts \ - && for subdir; do LC_ALL=C make -j$(nproc) -k M="${subdir}"; done + && for subdir; do LC_ALL=C KBUILD_MODPOST_WARN=1 make -j$(nproc) -k M="${subdir}"; done ) &> "${outputfile}" then local errors warnings @@ -417,9 +417,9 @@ function run_sparse { if (cd "${outputdir}/linux-$k" \ && make -s modules_prepare \ && make -s scripts \ - && if grep -q '^CONFIG_PPC=y$' .config; then LC_ALL=C make -k M=arch/powerpc/lib; fi \ + && if grep -q '^CONFIG_PPC=y$' .config; then LC_ALL=C KBUILD_MODPOST_WARN=1 make -k M=arch/powerpc/lib; fi \ && for subdir; do - LC_ALL=C make -k C=2 CF="-D__CHECK_ENDIAN__ -DCONFIG_SPARSE_RCU_POINTER" M="${subdir}" + LC_ALL=C KBUILD_MODPOST_WARN=1 make -k C=2 CF="-D__CHECK_ENDIAN__ -DCONFIG_SPARSE_RCU_POINTER" M="${subdir}" done ) &> "${outputfile}" then @@ -458,9 +458,9 @@ function run_smatch { make -s oldconfig "${outputfile}" then @@ -490,7 +490,7 @@ function run_checkstack { cd "${outputdir}/linux-$1" \ && make -s modules_prepare \ && make -s scripts \ - && LC_ALL=C make -k checkstack + && LC_ALL=C KBUILD_MODPOST_WARN=1 make -k checkstack ) &> "${outputfile}" echo "See also ${outputfile}." return 0 @@ -507,7 +507,7 @@ function run_namespacecheck { cd "${outputdir}/linux-$1" \ && make -s modules_prepare \ && make -s scripts \ - && LC_ALL=C make -k namespacecheck + && LC_ALL=C KBUILD_MODPOST_WARN=1 make -k namespacecheck ) &> "${outputfile}" echo "See also ${outputfile}." return 0 @@ -524,7 +524,7 @@ function run_headers_check { cd "${outputdir}/linux-$1" \ && make -s modules_prepare \ && make -s scripts \ - && LC_ALL=C make -k headers_check + && LC_ALL=C KBUILD_MODPOST_WARN=1 make -k headers_check ) &> "${outputfile}" local errors errors=$(grep -c '^[^ ]' "${outputfile}") @@ -544,7 +544,7 @@ function run_make_htmldocs { cd "${outputdir}/linux-$1" \ && make -s modules_prepare \ && make -s scripts \ - && LC_ALL=C make -k htmldocs + && LC_ALL=C KBUILD_MODPOST_WARN=1 make -k htmldocs ) &> "${outputfile}" echo "See also ${outputfile}." return 0 From 71abad275e1838d3639122e85b36e211e8006c6b Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 2 May 2024 16:17:38 +0300 Subject: [PATCH 03/26] scst/include/backport.h: Fix backport for new stable kernels This patch fixes the build against kernel versions >= 5.10.210. --- scst/include/backport.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 5798e7cf2..d611afea1 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -933,13 +933,15 @@ static inline void kvfree(void *addr) #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) && \ (LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(5, 15, 0) >> 8 || \ LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 54)) && \ + (LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(5, 10, 0) >> 8 || \ + LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 210)) && \ (!defined(RHEL_RELEASE_CODE) || \ RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 0)) && \ (!defined(UEK_KABI_RENAME) || \ LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) /* * See also commit a8749a35c3990 ("mm: vmalloc: introduce array allocation functions") # v5.18, - * v5.15.54. + * v5.15.54, v5.10.210. */ static inline void *vmalloc_array(size_t n, size_t size) { From 48ef50966a17a8cad4821250373c6d38735a9bde Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 2 May 2024 16:33:18 +0300 Subject: [PATCH 04/26] 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. --- scst/include/backport.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index d611afea1..1e85c95c4 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1675,7 +1675,8 @@ static inline void scsi_build_sense(struct scsi_cmnd *scmd, int desc, LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 203)) && \ (!defined(RHEL_RELEASE_CODE) || \ RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(8, 7) || \ - RHEL_RELEASE_CODE -0 == RHEL_RELEASE_VERSION(9, 0)) + RHEL_RELEASE_CODE -0 == RHEL_RELEASE_VERSION(9, 0)) && \ + !defined(UEK_KABI_RENAME) /* * See also 51f3a4788928 ("scsi: core: Introduce the scsi_cmd_to_rq() * function") # v5.15. @@ -1733,7 +1734,9 @@ static inline unsigned int scsi_prot_interval(struct scsi_cmnd *scmd) !(LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(5, 15, 0) >> 8 && \ LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 136)) && \ (!defined(RHEL_RELEASE_CODE) || \ - RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 1)) + RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 1)) && \ + (!defined(UEK_KABI_RENAME) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) /* * See also commit 11b68e36b167 ("scsi: core: Call scsi_done directly") # v5.16. * See also commit d2746cdfd5e5 ("scsi: core: Rename scsi_mq_done() into scsi_done() and export From 52b5e841cf97c4c39919b74394695bde0a11fe08 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Fri, 3 May 2024 10:03:50 +0300 Subject: [PATCH 05/26] scst/include/backport.h: Fix backport for new stable kernels This patch fixes the build against kernel versions >= 6.6.23. --- scst/include/backport.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 1e85c95c4..5de409079 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -282,9 +282,11 @@ static inline void blkdev_put_backport(struct block_device *bdev, void *holder) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0) && \ + (LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(6, 6, 0) >> 8 || \ + LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 23)) /* - * See also commit e719b4d15674 ("block: Provide bdev_open_* functions") # v6.7. + * See also commit e719b4d15674 ("block: Provide bdev_open_* functions") # v6.7, v6.6.23. */ struct bdev_handle { struct block_device *bdev; From 8a1a7fab1d47f36a17826c5fc350e436453e72b4 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Fri, 3 May 2024 11:39:51 +0300 Subject: [PATCH 06/26] scst/include/backport.h: Fix the build against UEK kernels Commit 48ef50966a17 ("scst/include/backport.h: Port to the latest UEK kernels") broke the build for UEK kernel versions before v5.4.17-2136. Fix it. --- scst/include/backport.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 5de409079..3ab377c80 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1678,7 +1678,9 @@ static inline void scsi_build_sense(struct scsi_cmnd *scmd, int desc, (!defined(RHEL_RELEASE_CODE) || \ RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(8, 7) || \ RHEL_RELEASE_CODE -0 == RHEL_RELEASE_VERSION(9, 0)) && \ - !defined(UEK_KABI_RENAME) + (!defined(UEK_KABI_RENAME) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 17) || \ + !defined(SB_I_SKIP_SYNC)) /* * See also 51f3a4788928 ("scsi: core: Introduce the scsi_cmd_to_rq() * function") # v5.15. From 1ea7200d5515e88f932e2be7d5851f962639116b Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:34:58 +0300 Subject: [PATCH 07/26] qla2x00t-32gbit: use DEFINE_SHOW_STORE_ATTRIBUTE() helper for debugfs Use DEFINE_SHOW_STORE_ATTRIBUTE() helper for read-write file to reduce some duplicated code. Link: https://lkml.kernel.org/r/20230905024835.43219-4-yangxingui@huawei.com Signed-off-by: Luo Jiaxing Co-developed-by: Xingui Yang Signed-off-by: Xingui Yang Reviewed-by: Andy Shevchenko Cc: Al Viro Cc: Animesh Manna Cc: Anshuman Gupta Cc: Damien Le Moal Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Himanshu Madhani Cc: James Bottomley Cc: John Garry Cc: Martin K. Petersen Cc: Uma Shankar Cc: Xiang Chen Cc: Zeng Tao Signed-off-by: Andrew Morton [ commit a9d56ce053da upstream ] --- qla2x00t-32gbit/qla_dfs.c | 59 +++++---------------------------------- 1 file changed, 7 insertions(+), 52 deletions(-) diff --git a/qla2x00t-32gbit/qla_dfs.c b/qla2x00t-32gbit/qla_dfs.c index e0b55d23c..a4715de9c 100644 --- a/qla2x00t-32gbit/qla_dfs.c +++ b/qla2x00t-32gbit/qla_dfs.c @@ -532,51 +532,22 @@ qla_dfs_naqp_show(struct seq_file *s, void *unused) * * Example for creating "TEST" sysfs file: * 1. struct qla_hw_data { ... struct dentry *dfs_TEST; } - * 2. QLA_DFS_SETUP_RD(TEST, scsi_qla_host_t); + * 2. QLA_DFS_SETUP_RD(TEST); * 3. In qla2x00_dfs_setup(): * QLA_DFS_CREATE_FILE(ha, TEST, 0600, ha->dfs_dir, vha); * 4. In qla2x00_dfs_remove(): * QLA_DFS_REMOVE_FILE(ha, TEST); */ -#define QLA_DFS_SETUP_RD(_name, _ctx_struct) \ -static int \ -qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ -{ \ - _ctx_struct *__ctx = inode->i_private; \ - \ - return single_open(file, qla_dfs_##_name##_show, __ctx); \ -} \ - \ -static const struct file_operations qla_dfs_##_name##_ops = { \ - .open = qla_dfs_##_name##_open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ -}; +#define QLA_DFS_SETUP_RD(_name) DEFINE_SHOW_ATTRIBUTE(qla_dfs_##_name) -#define QLA_DFS_SETUP_RW(_name, _ctx_struct) \ -static int \ -qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ -{ \ - _ctx_struct *__ctx = inode->i_private; \ - \ - return single_open(file, qla_dfs_##_name##_show, __ctx); \ -} \ - \ -static const struct file_operations qla_dfs_##_name##_ops = { \ - .open = qla_dfs_##_name##_open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ - .write = qla_dfs_##_name##_write, \ -}; +#define QLA_DFS_SETUP_RW(_name) DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_##_name) #define QLA_DFS_ROOT_CREATE_FILE(_name, _perm, _ctx) \ do { \ if (!qla_dfs_##_name) \ qla_dfs_##_name = debugfs_create_file(#_name, \ _perm, qla2x00_dfs_root, _ctx, \ - &qla_dfs_##_name##_ops); \ + &qla_dfs_##_name##_fops); \ } while (0) #define QLA_DFS_ROOT_REMOVE_FILE(_name) \ @@ -591,7 +562,7 @@ static const struct file_operations qla_dfs_##_name##_ops = { \ do { \ (_struct)->dfs_##_name = debugfs_create_file(#_name, \ _perm, _parent, _ctx, \ - &qla_dfs_##_name##_ops) \ + &qla_dfs_##_name##_fops) \ } while (0) #define QLA_DFS_REMOVE_FILE(_struct, _name) \ @@ -602,14 +573,6 @@ static const struct file_operations qla_dfs_##_name##_ops = { \ } \ } while (0) -static int -qla_dfs_naqp_open(struct inode *inode, struct file *file) -{ - struct scsi_qla_host *vha = inode->i_private; - - return single_open(file, qla_dfs_naqp_show, vha); -} - static ssize_t qla_dfs_naqp_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) @@ -657,15 +620,7 @@ qla_dfs_naqp_write(struct file *file, const char __user *buffer, kfree(buf); return rc; } - -static const struct file_operations dfs_naqp_ops = { - .open = qla_dfs_naqp_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = qla_dfs_naqp_write, -}; - +QLA_DFS_SETUP_RW(naqp); int qla2x00_dfs_setup(scsi_qla_host_t *vha) @@ -711,7 +666,7 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha) if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) { ha->tgt.dfs_naqp = debugfs_create_file("naqp", - 0400, ha->dfs_dir, vha, &dfs_naqp_ops); + 0400, ha->dfs_dir, vha, &qla_dfs_naqp_fops); if (IS_ERR(ha->tgt.dfs_naqp)) { ql_log(ql_log_warn, vha, 0xd011, "Unable to create debugFS naqp node.\n"); From e322287f898394f91e2dc986794d0440901316ec Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:14:58 +0300 Subject: [PATCH 08/26] 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. --- scst/include/backport.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 3ab377c80..97e46c9fa 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1354,6 +1354,27 @@ static const struct file_operations __name ## _fops = { \ } #endif +/* + * See also commit 9cba82bba500 ("seq_file: add helper macro to define + * attribute for rw file") # v6.7. + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0) +#define DEFINE_SHOW_STORE_ATTRIBUTE(__name) \ +static int __name ## _open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, __name ## _show, inode->i_private); \ +} \ + \ +static const struct file_operations __name ## _fops = { \ + .owner = THIS_MODULE, \ + .open = __name ## _open, \ + .read = seq_read, \ + .write = __name ## _write, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) && \ From aabf1cedc3618ef12e7fd5e71063ceba1c9e6c91 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:35:17 +0300 Subject: [PATCH 09/26] qla2x00t-32gbit: Prevent command send on chip reset Currently IOCBs are allowed to push through while chip reset could be in progress. During chip reset the outstanding_cmds array is cleared twice. Once when any command on this array is returned as failed and secondly when the array is initialize to zero. If a command is inserted on to the array between these intervals, then the command will be lost. Check for chip reset before sending IOCB. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-2-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 4895009c4bb7 upstream ] --- qla2x00t-32gbit/qla_init.c | 8 ++++++-- qla2x00t-32gbit/qla_iocb.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 68d9d220c..d44fa5da6 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -1193,8 +1193,12 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) return rval; done_free_sp: - /* ref: INIT */ - kref_put(&sp->cmd_kref, qla2x00_sp_release); + /* + * use qla24xx_async_gnl_sp_done to purge all pending gnl request. + * kref_put is call behind the scene. + */ + sp->u.iocb_cmd.u.mbx.in_mb[0] = MBS_COMMAND_ERROR; + qla24xx_async_gnl_sp_done(sp, QLA_COMMAND_ERROR); fcport->flags &= ~(FCF_ASYNC_SENT); done: fcport->flags &= ~(FCF_ASYNC_ACTIVE); diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index e045f39cb..45ba8d5f8 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -2603,6 +2603,33 @@ void qla2x00_sp_release(struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref); + struct scsi_qla_host *vha = sp->vha; + + switch (sp->type) { + case SRB_CT_PTHRU_CMD: + /* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */ + if (sp->u.iocb_cmd.u.ctarg.req && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) { + dma_free_coherent(&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.req_allocated_size, + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req = NULL; + } + if (sp->u.iocb_cmd.u.ctarg.rsp && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) { + dma_free_coherent(&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, + sp->u.iocb_cmd.u.ctarg.rsp, + sp->u.iocb_cmd.u.ctarg.rsp_dma); + sp->u.iocb_cmd.u.ctarg.rsp = NULL; + } + break; + default: + break; + } sp->free(sp); } @@ -2708,7 +2735,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, */ sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); if (!sp) { - kfree(fcport); + qla2x00_free_fcport(fcport); ql_log(ql_log_info, vha, 0x70e6, "SRB allocation failed\n"); return -ENOMEM; @@ -2763,6 +2790,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, if (rval != QLA_SUCCESS) { /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); + qla2x00_free_fcport(fcport); return QLA_FUNCTION_FAILED; } @@ -2772,6 +2800,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, fcport->d_id.b.area, fcport->d_id.b.al_pa); wait_for_completion(&elsio->u.els_logo.comp); + qla2x00_free_fcport(fcport); /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); @@ -3935,7 +3964,7 @@ qla2x00_start_sp(srb_t *sp) return -EAGAIN; } - pkt = __qla2x00_alloc_iocbs(sp->qpair, sp); + pkt = qla2x00_alloc_iocbs_ready(sp->qpair, sp); if (!pkt) { rval = -EAGAIN; ql_log(ql_log_warn, vha, 0x700c, From f91f314b3a5ce1699776ccdd247dd068add5fb65 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:35:48 +0300 Subject: [PATCH 10/26] qla2x00t-32gbit: Fix N2N stuck connection Disk failed to rediscover after chip reset error injection. The chip reset happens at the time when a PLOGI is being sent. This causes a flag to be left on which blocks the retry. Clear the blocking flag. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-3-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 881eb861ca38 upstream ] --- qla2x00t-32gbit/qla_gbl.h | 2 +- qla2x00t-32gbit/qla_iocb.c | 32 +++++++++++--------------------- qla2x00t-32gbit/qla_os.c | 2 +- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index ea684de65..355c64a65 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -44,7 +44,7 @@ extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *); extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *); extern int qla24xx_els_dcmd_iocb(scsi_qla_host_t *, int, port_id_t); -extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *, bool); +extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *); extern void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha, struct els_plogi *els_plogi); diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index 45ba8d5f8..a67123b88 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -3057,7 +3057,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res) int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, - fc_port_t *fcport, bool wait) + fc_port_t *fcport) { srb_t *sp; struct srb_iocb *elsio = NULL; @@ -3072,8 +3072,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, if (!sp) { ql_log(ql_log_info, vha, 0x70e6, "SRB allocation failed\n"); - fcport->flags &= ~FCF_ASYNC_ACTIVE; - return -ENOMEM; + goto done; } fcport->flags |= FCF_ASYNC_SENT; @@ -3082,9 +3081,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, ql_dbg(ql_dbg_io, vha, 0x3073, "%s Enter: PLOGI portid=%06x\n", __func__, fcport->d_id.b24); - if (wait) - sp->flags = SRB_WAKEUP_ON_COMP; - sp->type = SRB_ELS_DCMD; sp->name = "ELS_DCMD"; sp->fcport = fcport; @@ -3100,7 +3096,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, if (!elsio->u.els_plogi.els_plogi_pyld) { rval = QLA_FUNCTION_FAILED; - goto out; + goto done_free_sp; } resp_ptr = elsio->u.els_plogi.els_resp_pyld = @@ -3109,7 +3105,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, if (!elsio->u.els_plogi.els_resp_pyld) { rval = QLA_FUNCTION_FAILED; - goto out; + goto done_free_sp; } ql_dbg(ql_dbg_io, vha, 0x3073, "PLOGI %p %p\n", ptr, resp_ptr); @@ -3125,7 +3121,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, if (els_opcode == ELS_DCMD_PLOGI && DBELL_ACTIVE(vha)) { struct fc_els_flogi *p = ptr; - p->fl_csp.sp_features |= cpu_to_be16(FC_SP_FT_SEC); } @@ -3134,10 +3129,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, sizeof(*elsio->u.els_plogi.els_plogi_pyld)); - init_completion(&elsio->u.els_plogi.comp); rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) { - rval = QLA_FUNCTION_FAILED; + fcport->flags |= FCF_LOGIN_NEEDED; + set_bit(RELOGIN_NEEDED, &vha->dpc_flags); + goto done_free_sp; } else { ql_dbg(ql_dbg_disc, vha, 0x3074, "%s PLOGI sent, hdl=%x, loopid=%x, to port_id %06x from port_id %06x\n", @@ -3145,21 +3141,15 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, fcport->d_id.b24, vha->d_id.b24); } - if (wait) { - wait_for_completion(&elsio->u.els_plogi.comp); - - if (elsio->u.els_plogi.comp_status != CS_COMPLETE) - rval = QLA_FUNCTION_FAILED; - } else { - goto done; - } + return rval; -out: - fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); +done_free_sp: qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi); /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); done: + fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); + qla2x00_set_fcport_disc_state(fcport, DSC_DELETED); return rval; } diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 52e8018a5..fdc91e788 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -5656,7 +5656,7 @@ qla2x00_do_work(struct scsi_qla_host *vha) break; case QLA_EVT_ELS_PLOGI: qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI, - e->u.fcport.fcport, false); + e->u.fcport.fcport); break; case QLA_EVT_SA_REPLACE: rc = qla24xx_issue_sa_replace_iocb(vha, e); From 869135ef83b30bdb8ed41c80ca3fa388f7ab43c1 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:36:05 +0300 Subject: [PATCH 11/26] qla2x00t-32gbit: Split FCE|EFT trace control Current code combines the allocation of FCE|EFT trace buffers and enables the features all in 1 step. Split this step into separate steps in preparation for follow-on patch to allow user to have a choice to enable / disable FCE trace feature. Cc: stable@vger.kernel.org Reported-by: kernel test robot Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-4-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 76a192e1a566 upstream ] --- qla2x00t-32gbit/qla_init.c | 102 +++++++++++++++---------------------- 1 file changed, 41 insertions(+), 61 deletions(-) diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index d44fa5da6..0a1510962 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -2669,6 +2669,40 @@ qla83xx_nic_core_fw_load(scsi_qla_host_t *vha) return rval; } +static void qla_enable_fce_trace(scsi_qla_host_t *vha) +{ + int rval; + struct qla_hw_data *ha = vha->hw; + + if (ha->fce) { + ha->flags.fce_enabled = 1; + memset(ha->fce, 0, fce_calc_size(ha->fce_bufs)); + rval = qla2x00_enable_fce_trace(vha, + ha->fce_dma, ha->fce_bufs, ha->fce_mb, &ha->fce_bufs); + + if (rval) { + ql_log(ql_log_warn, vha, 0x8033, + "Unable to reinitialize FCE (%d).\n", rval); + ha->flags.fce_enabled = 0; + } + } +} + +static void qla_enable_eft_trace(scsi_qla_host_t *vha) +{ + int rval; + struct qla_hw_data *ha = vha->hw; + + if (ha->eft) { + memset(ha->eft, 0, EFT_SIZE); + rval = qla2x00_enable_eft_trace(vha, ha->eft_dma, EFT_NUM_BUFFERS); + + if (rval) { + ql_log(ql_log_warn, vha, 0x8034, + "Unable to reinitialize EFT (%d).\n", rval); + } + } +} /* * qla2x00_initialize_adapter * Initialize board. @@ -3675,9 +3709,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) } static void -qla2x00_init_fce_trace(scsi_qla_host_t *vha) +qla2x00_alloc_fce_trace(scsi_qla_host_t *vha) { - int rval; dma_addr_t tc_dma; void *tc; struct qla_hw_data *ha = vha->hw; @@ -3706,27 +3739,17 @@ qla2x00_init_fce_trace(scsi_qla_host_t *vha) return; } - rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, - ha->fce_mb, &ha->fce_bufs); - if (rval) { - ql_log(ql_log_warn, vha, 0x00bf, - "Unable to initialize FCE (%d).\n", rval); - dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma); - return; - } - ql_dbg(ql_dbg_init, vha, 0x00c0, "Allocated (%d KB) for FCE...\n", FCE_SIZE / 1024); - ha->flags.fce_enabled = 1; ha->fce_dma = tc_dma; ha->fce = tc; + ha->fce_bufs = FCE_NUM_BUFFERS; } static void -qla2x00_init_eft_trace(scsi_qla_host_t *vha) +qla2x00_alloc_eft_trace(scsi_qla_host_t *vha) { - int rval; dma_addr_t tc_dma; void *tc; struct qla_hw_data *ha = vha->hw; @@ -3751,14 +3774,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *vha) return; } - rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); - if (rval) { - ql_log(ql_log_warn, vha, 0x00c2, - "Unable to initialize EFT (%d).\n", rval); - dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); - return; - } - ql_dbg(ql_dbg_init, vha, 0x00c3, "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); @@ -3766,13 +3781,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *vha) ha->eft = tc; } -static void -qla2x00_alloc_offload_mem(scsi_qla_host_t *vha) -{ - qla2x00_init_fce_trace(vha); - qla2x00_init_eft_trace(vha); -} - void qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) { @@ -3827,10 +3835,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) if (ha->tgt.atio_ring) mq_size += ha->tgt.atio_q_length * sizeof(request_t); - qla2x00_init_fce_trace(vha); + qla2x00_alloc_fce_trace(vha); if (ha->fce) fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; - qla2x00_init_eft_trace(vha); + qla2x00_alloc_eft_trace(vha); if (ha->eft) eft_size = EFT_SIZE; } @@ -4260,7 +4268,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) struct qla_hw_data *ha = vha->hw; struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; unsigned long flags; - uint16_t fw_major_version; int done_once = 0; if (IS_P3P_TYPE(ha)) { @@ -4327,7 +4334,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) goto failed; enable_82xx_npiv: - fw_major_version = ha->fw_major_version; if (IS_P3P_TYPE(ha)) qla82xx_check_md_needed(vha); else @@ -4356,12 +4362,11 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) if (rval != QLA_SUCCESS) goto failed; - if (!fw_major_version && !(IS_P3P_TYPE(ha))) - qla2x00_alloc_offload_mem(vha); - if (ql2xallocfwdump && !(IS_P3P_TYPE(ha))) qla2x00_alloc_fw_dump(vha); + qla_enable_fce_trace(vha); + qla_enable_eft_trace(vha); } else { goto failed; } @@ -7494,7 +7499,6 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha) int qla2x00_abort_isp(scsi_qla_host_t *vha) { - int rval; uint8_t status = 0; struct qla_hw_data *ha = vha->hw; struct scsi_qla_host *vp, *tvp; @@ -7588,31 +7592,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) if (IS_QLA81XX(ha) || IS_QLA8031(ha)) qla2x00_get_fw_version(vha); - if (ha->fce) { - ha->flags.fce_enabled = 1; - memset(ha->fce, 0, - fce_calc_size(ha->fce_bufs)); - rval = qla2x00_enable_fce_trace(vha, - ha->fce_dma, ha->fce_bufs, ha->fce_mb, - &ha->fce_bufs); - if (rval) { - ql_log(ql_log_warn, vha, 0x8033, - "Unable to reinitialize FCE " - "(%d).\n", rval); - ha->flags.fce_enabled = 0; - } - } - if (ha->eft) { - memset(ha->eft, 0, EFT_SIZE); - rval = qla2x00_enable_eft_trace(vha, - ha->eft_dma, EFT_NUM_BUFFERS); - if (rval) { - ql_log(ql_log_warn, vha, 0x8034, - "Unable to reinitialize EFT " - "(%d).\n", rval); - } - } } else { /* failed the ISP abort */ vha->flags.online = 1; if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { From 10c4006caacbbec0d70297cbb9302a6b6a72bf12 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:36:23 +0300 Subject: [PATCH 12/26] qla2x00t-32gbit: Update manufacturer detail Update manufacturer detail from "Marvell Semiconductor, Inc." to "Marvell". Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-5-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 688fa069fda6 upstream ] --- qla2x00t-32gbit/qla_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index f009d2cfa..a777885be 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -125,7 +125,7 @@ typedef union { #include "qla_nvme.h" #define QLA2XXX_DRIVER_NAME "qla2xxx" #define QLA2XXX_APIDEV "ql2xapidev" -#define QLA2XXX_MANUFACTURER "Marvell Semiconductor, Inc." +#define QLA2XXX_MANUFACTURER "Marvell" /* * We have MAILBOX_REGISTER_COUNT sized arrays in a few places, From 0929d8125f8d7f5656b7dca3acd02e3742de3e69 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:36:41 +0300 Subject: [PATCH 13/26] qla2x00t-32gbit: NVME|FCP prefer flag not being honored Changing of [FCP|NVME] prefer flag in flash has no effect on driver. For device that supports both FCP + NVMe over the same connection, driver continues to connect to this device using the previous successful login mode. On completion of flash update, adapter will be reset. Driver will reset the prefer flag based on setting from flash. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-6-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 69aecdd41010 upstream ] --- qla2x00t-32gbit/qla_init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 0a1510962..6a1af567e 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -7504,6 +7504,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) struct scsi_qla_host *vp, *tvp; struct req_que *req = ha->req_q_map[0]; unsigned long flags; + fc_port_t *fcport; if (vha->flags.online) { qla2x00_abort_isp_cleanup(vha); @@ -7572,6 +7573,15 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) "ISP Abort - ISP reg disconnect post nvmram config, exiting.\n"); return status; } + + /* User may have updated [fcp|nvme] prefer in flash */ + list_for_each_entry(fcport, &vha->vp_fcports, list) { + if (NVME_PRIORITY(ha, fcport)) + fcport->do_prli_nvme = 1; + else + fcport->do_prli_nvme = 0; + } + if (!qla2x00_restart_isp(vha)) { clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); @@ -7642,6 +7652,14 @@ qla2x00_abort_isp(scsi_qla_host_t *vha) atomic_inc(&vp->vref_count); spin_unlock_irqrestore(&ha->vport_slock, flags); + /* User may have updated [fcp|nvme] prefer in flash */ + list_for_each_entry(fcport, &vp->vp_fcports, list) { + if (NVME_PRIORITY(ha, fcport)) + fcport->do_prli_nvme = 1; + else + fcport->do_prli_nvme = 0; + } + qla2x00_vp_abort_isp(vp); spin_lock_irqsave(&ha->vport_slock, flags); From 5a325ea4a7be5426faa5c8dbafef02b1e3a5269a Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:36:58 +0300 Subject: [PATCH 14/26] qla2x00t-32gbit: Fix command flush on cable pull System crash due to command failed to flush back to SCSI layer. BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI CPU: 27 PID: 793455 Comm: kworker/u130:6 Kdump: loaded Tainted: G OE --------- - - 4.18.0-372.9.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 Workqueue: nvme-wq nvme_fc_connect_ctrl_work [nvme_fc] RIP: 0010:__wake_up_common+0x4c/0x190 Code: 24 10 4d 85 c9 74 0a 41 f6 01 04 0f 85 9d 00 00 00 48 8b 43 08 48 83 c3 08 4c 8d 48 e8 49 8d 41 18 48 39 c3 0f 84 f0 00 00 00 <49> 8b 41 18 89 54 24 08 31 ed 4c 8d 70 e8 45 8b 29 41 f6 c5 04 75 RSP: 0018:ffff95f3e0cb7cd0 EFLAGS: 00010086 RAX: 0000000000000000 RBX: ffff8b08d3b26328 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8b08d3b26320 RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffe8 R10: 0000000000000000 R11: ffff95f3e0cb7a60 R12: ffff95f3e0cb7d20 R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8b2fdf6c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000002f1e410002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: __wake_up_common_lock+0x7c/0xc0 qla_nvme_ls_req+0x355/0x4c0 [qla2xxx] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae1407ca000 from port 21:32:00:02:ac:07:ee:b8 loop_id 0x02 s_id 01:02:00 logout 1 keep 0 els_logo 0 ? __nvme_fc_send_ls_req+0x260/0x380 [nvme_fc] qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:00:02:ac:07:ee:b8 state transitioned from ONLINE to LOST - portid=010200. ? nvme_fc_send_ls_req.constprop.42+0x1a/0x45 [nvme_fc] qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320002ac07eeb8. rport ffff8ae598122000 roles 1 ? nvme_fc_connect_ctrl_work.cold.63+0x1e3/0xa7d [nvme_fc] qla2xxx [0000:12:00.1]-f084:3: qlt_free_session_done: se_sess 0000000000000000 / sess ffff8ae14801e000 from port 21:32:01:02:ad:f7:ee:b8 loop_id 0x04 s_id 01:02:01 logout 1 keep 0 els_logo 0 ? __switch_to+0x10c/0x450 ? process_one_work+0x1a7/0x360 qla2xxx [0000:12:00.1]-207d:3: FCPort 21:32:01:02:ad:f7:ee:b8 state transitioned from ONLINE to LOST - portid=010201. ? worker_thread+0x1ce/0x390 ? create_worker+0x1a0/0x1a0 qla2xxx [0000:12:00.1]-2109:3: qla2x00_schedule_rport_del 21320102adf7eeb8. rport ffff8ae3b2312800 roles 70 ? kthread+0x10a/0x120 qla2xxx [0000:12:00.1]-2112:3: qla_nvme_unregister_remote_port: unregister remoteport on ffff8ae14801e000 21320102adf7eeb8 ? set_kthread_struct+0x40/0x40 qla2xxx [0000:12:00.1]-2110:3: remoteport_delete of ffff8ae14801e000 21320102adf7eeb8 completed. ? ret_from_fork+0x1f/0x40 qla2xxx [0000:12:00.1]-f086:3: qlt_free_session_done: waiting for sess ffff8ae14801e000 logout The system was under memory stress where driver was not able to allocate an SRB to carry out error recovery of cable pull. The failure to flush causes upper layer to start modifying scsi_cmnd. When the system frees up some memory, the subsequent cable pull trigger another command flush. At this point the driver access a null pointer when attempting to DMA unmap the SGL. Add a check to make sure commands are flush back on session tear down to prevent the null pointer access. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-7-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit a27d4d0e7de3 upstream ] --- qla2x00t-32gbit/qla_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qla2x00t-32gbit/qla_target.c b/qla2x00t-32gbit/qla_target.c index 6ef76bd52..48c4f86e4 100644 --- a/qla2x00t-32gbit/qla_target.c +++ b/qla2x00t-32gbit/qla_target.c @@ -1077,6 +1077,16 @@ void qlt_free_session_done(struct work_struct *work) "%s: sess %p logout completed\n", __func__, sess); } + /* check for any straggling io left behind */ + if (!(sess->flags & FCF_FCP2_DEVICE) && + qla2x00_eh_wait_for_pending_commands(sess->vha, sess->d_id.b24, 0, WAIT_TARGET)) { + ql_log(ql_log_warn, vha, 0x3027, + "IO not return. Resetting.\n"); + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + qla2x00_wait_for_chip_reset(vha); + } + if (sess->logo_ack_needed) { sess->logo_ack_needed = 0; qla24xx_async_notify_ack(vha, sess, From b0dd719ad27a4361b743de940ef599250b050f1d Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:37:24 +0300 Subject: [PATCH 15/26] qla2x00t-32gbit: Fix double free of the ha->vp_map pointer Coverity scan reported potential risk of double free of the pointer ha->vp_map. ha->vp_map was freed in qla2x00_mem_alloc(), and again freed in function qla2x00_mem_free(ha). Assign NULL to vp_map and kfree take care of NULL. Cc: stable@vger.kernel.org Signed-off-by: Saurav Kashyap Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-8-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit e288285d4778 upstream ] --- qla2x00t-32gbit/qla_os.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index fdc91e788..20742d26b 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -4673,6 +4673,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, ha->init_cb_dma = 0; fail_free_vp_map: kfree(ha->vp_map); + ha->vp_map = NULL; fail: ql_log(ql_log_fatal, NULL, 0x0030, "Memory allocation failure.\n"); From f9329cc7e65423b6ffcc5b06629aaa057c7d3468 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:37:47 +0300 Subject: [PATCH 16/26] qla2x00t-32gbit: Fix double free of fcport The server was crashing after LOGO because fcport was getting freed twice. -----------[ cut here ]----------- kernel BUG at mm/slub.c:371! invalid opcode: 0000 1 SMP PTI CPU: 35 PID: 4610 Comm: bash Kdump: loaded Tainted: G OE --------- - - 4.18.0-425.3.1.el8.x86_64 #1 Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021 RIP: 0010:set_freepointer.part.57+0x0/0x10 RSP: 0018:ffffb07107027d90 EFLAGS: 00010246 RAX: ffff9cb7e3150000 RBX: ffff9cb7e332b9c0 RCX: ffff9cb7e3150400 RDX: 0000000000001f37 RSI: 0000000000000000 RDI: ffff9cb7c0005500 RBP: fffff693448c5400 R08: 0000000080000000 R09: 0000000000000009 R10: 0000000000000000 R11: 0000000000132af0 R12: ffff9cb7c0005500 R13: ffff9cb7e3150000 R14: ffffffffc06990e0 R15: ffff9cb7ea85ea58 FS: 00007ff6b79c2740(0000) GS:ffff9cb8f7ec0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055b426b7d700 CR3: 0000000169c18002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: kfree+0x238/0x250 qla2x00_els_dcmd_sp_free+0x20/0x230 [qla2xxx] ? qla24xx_els_dcmd_iocb+0x607/0x690 [qla2xxx] qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? qla2x00_issue_logo+0x28c/0x2a0 [qla2xxx] ? kernfs_fop_write+0x11e/0x1a0 Remove one of the free calls and add check for valid fcport. Also use function qla2x00_free_fcport() instead of kfree(). Cc: stable@vger.kernel.org Signed-off-by: Saurav Kashyap Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-9-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 82f522ae0d97 upstream ] --- qla2x00t-32gbit/qla_iocb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index a67123b88..85c3b9a66 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -2653,7 +2653,8 @@ static void qla2x00_els_dcmd_sp_free(srb_t *sp) { struct srb_iocb *elsio = &sp->u.iocb_cmd; - kfree(sp->fcport); + if (sp->fcport) + qla2x00_free_fcport(sp->fcport); if (elsio->u.els_logo.els_logo_pyld) dma_free_coherent(&sp->vha->hw->pdev->dev, DMA_POOL_SIZE, @@ -2766,6 +2767,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, if (!elsio->u.els_logo.els_logo_pyld) { /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); + qla2x00_free_fcport(fcport); return QLA_FUNCTION_FAILED; } @@ -2800,7 +2802,6 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, fcport->d_id.b.area, fcport->d_id.b.al_pa); wait_for_completion(&elsio->u.els_logo.comp); - qla2x00_free_fcport(fcport); /* ref: INIT */ kref_put(&sp->cmd_kref, qla2x00_sp_release); From b7481e82ef5b97c7418839338a1d210b577d212b Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:40:43 +0300 Subject: [PATCH 17/26] qla2x00t-32gbit: Change debug message during driver unload Upon driver unload, purge_mbox flag is set and the heartbeat monitor thread detects this flag and does not send the mailbox command down to FW with a debug message "Error detected: purge[1] eeh[0] cmd=0x0, Exiting". This being not a real error, change the debug message. Cc: stable@vger.kernel.org Signed-off-by: Saurav Kashyap Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-10-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit b5a30840727a upstream ] --- qla2x00t-32gbit/qla_mbx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qla2x00t-32gbit/qla_mbx.c b/qla2x00t-32gbit/qla_mbx.c index 21ec32b4f..0cd6f3e14 100644 --- a/qla2x00t-32gbit/qla_mbx.c +++ b/qla2x00t-32gbit/qla_mbx.c @@ -194,7 +194,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) if (ha->flags.purge_mbox || chip_reset != ha->chip_reset || ha->flags.eeh_busy) { ql_log(ql_log_warn, vha, 0xd035, - "Error detected: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n", + "Purge mbox: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n", ha->flags.purge_mbox, ha->flags.eeh_busy, mcp->mb[0]); rval = QLA_ABORTED; goto premature_exit; From f8f70db99be0698cd2e868caa3777291c54137f0 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:38:26 +0300 Subject: [PATCH 18/26] qla2x00t-32gbit: Delay I/O Abort on PCI error Currently when PCI error is detected, I/O is aborted manually through the ABORT IOCB mechanism which is not guaranteed to succeed. Instead, wait for the OS or system to notify driver to wind down I/O through the pci_error_handlers api. Set eeh_busy flag to pause all traffic and wait for I/O to drain. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-11-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 591c1fdf2016 upstream ] --- qla2x00t-32gbit/qla_attr.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qla2x00t-32gbit/qla_attr.c b/qla2x00t-32gbit/qla_attr.c index c35bdddfe..ed07226e6 100644 --- a/qla2x00t-32gbit/qla_attr.c +++ b/qla2x00t-32gbit/qla_attr.c @@ -2812,7 +2812,13 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport) return; if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { - qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); + /* Will wait for wind down of adapter */ + ql_dbg(ql_dbg_aer, fcport->vha, 0x900c, + "%s pci offline detected (id %06x)\n", __func__, + fcport->d_id.b24); + qla_pci_set_eeh_busy(fcport->vha); + qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, + 0, WAIT_TARGET); return; } } @@ -2834,7 +2840,11 @@ qla2x00_terminate_rport_io(struct fc_rport *rport) vha = fcport->vha; if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { - qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); + /* Will wait for wind down of adapter */ + ql_dbg(ql_dbg_aer, fcport->vha, 0x900b, + "%s pci offline detected (id %06x)\n", __func__, + fcport->d_id.b24); + qla_pci_set_eeh_busy(vha); qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, 0, WAIT_TARGET); return; From 6c6f6759a6c4d0516231adc7ef965eb63405fb47 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:38:44 +0300 Subject: [PATCH 19/26] qla2x00t-32gbit: Update version to 10.02.09.200-k Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20240227164127.36465-12-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit b8260ca37930 upstream ] --- qla2x00t-32gbit/qla_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qla2x00t-32gbit/qla_version.h b/qla2x00t-32gbit/qla_version.h index d903563e9..7627fd807 100644 --- a/qla2x00t-32gbit/qla_version.h +++ b/qla2x00t-32gbit/qla_version.h @@ -6,9 +6,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "10.02.09.100-k" +#define QLA2XXX_VERSION "10.02.09.200-k" #define QLA_DRIVER_MAJOR_VER 10 #define QLA_DRIVER_MINOR_VER 2 #define QLA_DRIVER_PATCH_VER 9 -#define QLA_DRIVER_BETA_VER 100 +#define QLA_DRIVER_BETA_VER 200 From 3e0408fca6e91e6bc4867c9103c12642c2eaf4b6 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 25 Apr 2024 16:38:58 +0300 Subject: [PATCH 20/26] qla2x00t-32gbit: Fix off by one in qla_edif_app_getstats() The app_reply->elem[] array is allocated earlier in this function and it has app_req.num_ports elements. Thus this > comparison needs to be >= to prevent memory corruption. Fixes: 7878f22a2e03 ("scsi: qla2xxx: edif: Add getfcinfo and statistic bsgs") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/5c125b2f-92dd-412b-9b6f-fc3a3207bd60@moroto.mountain Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen [ commit 4406e4176f47 upstream ] --- qla2x00t-32gbit/qla_edif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qla2x00t-32gbit/qla_edif.c b/qla2x00t-32gbit/qla_edif.c index 96b45f630..1ce6c82c4 100644 --- a/qla2x00t-32gbit/qla_edif.c +++ b/qla2x00t-32gbit/qla_edif.c @@ -1101,7 +1101,7 @@ qla_edif_app_getstats(scsi_qla_host_t *vha, BSG_JOB_TYPE *bsg_job) list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { if (fcport->edif.enable) { - if (pcnt > app_req.num_ports) + if (pcnt >= app_req.num_ports) break; app_reply->elem[pcnt].rekey_count = From 3fba8e48e1e76047b0d02ed3d74f8a83f5124c3b Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Thu, 22 Feb 2024 16:46:30 -0800 Subject: [PATCH 21/26] scst_lib: Allow REPORT LUNS to operate on an unsupported LUN Initiators will attempt to send LUN 0 INQUIRY and REPORT LUNS commands when connecting to a target. Add scst_set_lun_not_supported_report_luns to handle the case when REPORT LUNs is sent to an unsupported LUN. Also, in scst_set_lun_not_supported_inquiry report a valid vendor identification string to promote better initiator behavior. --- scst/src/scst_lib.c | 143 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index bbb4c61bc..88239217e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -57,6 +57,9 @@ #include "scst_mem.h" #include "scst_pres.h" +/* 8 byte ASCII Vendor */ +#define SCST_NOLUN_VENDOR "SCST " + /* * List and IRQ lock to globally serialize all STPG commands. Needed to * prevent deadlock, if (1) a device group contains multiple devices and @@ -1919,6 +1922,10 @@ static int scst_set_lun_not_supported_inquiry(struct scst_cmd *cmd) buf[2] = 6; /* Device complies to SPC-4 */ buf[4] = len - 4; + /* Set T10 Vendor identification */ + if (len >= 16) + memcpy(&(buf[8]), SCST_NOLUN_VENDOR, 8); + TRACE_BUFFER("INQUIRY for not supported LUN set", buf, len); cmd->data_direction = SCST_DATA_READ; @@ -1933,6 +1940,140 @@ static int scst_set_lun_not_supported_inquiry(struct scst_cmd *cmd) return res; } +static int scst_set_lun_not_supported_report_luns(struct scst_cmd *cmd) +{ + uint8_t *buf; + int dev_cnt = 0; + struct scatterlist *sg; + struct scst_tgt_dev *tgt_dev = NULL; + int i, len; + int res = 0; + int offs, overflow = 0; + + TRACE_ENTRY(); + + if (cmd->status != 0) { + TRACE_MGMT_DBG("cmd %p already has status %x set", + cmd, cmd->status); + res = -EEXIST; + goto out; + } + + if ((cmd->cdb[2] != 0) && (cmd->cdb[2] != 2)) { + TRACE(TRACE_MINOR, + "Unsupported SELECT REPORT value %#x in REPORT LUNS command", + cmd->cdb[2]); + scst_set_invalid_field_in_cdb(cmd, 2, 0); + goto out; + } + + if (cmd->sg == NULL) { + if (cmd->bufflen == 0) { + int bufflen = get_unaligned_be32(&cmd->cdb[6]); + + cmd->bufflen = bufflen ? max_t(int, 8, bufflen) : 8; + } + + /* + * If target driver preparing data buffer using tgt_alloc_data_buf() + * callback, it is responsible to copy the sense to its buffer + * in xmit_response(). + */ + if (cmd->tgt_i_data_buf_alloced && (cmd->tgt_i_sg != NULL)) { + cmd->sg = cmd->tgt_i_sg; + cmd->sg_cnt = cmd->tgt_i_sg_cnt; + TRACE_MEM("Tgt used for REPORTS LUNS (not supported LUN): cmd %p", + cmd); + goto go; + } + + cmd->sg = scst_alloc_sg(cmd->bufflen, GFP_ATOMIC, &cmd->sg_cnt); + if (cmd->sg == NULL) { + PRINT_ERROR("Unable to alloc sg for REPORTS LUNS (not supported LUN)"); + res = 1; + goto out; + } + + TRACE_MEM( + "sg %p (cnt %d, len %d) allocated for REPORTS LUNS (not supported LUN): cmd %p", + cmd->sg, cmd->sg_cnt, cmd->bufflen, cmd); + } + +go: + sg = cmd->sg; + len = sg->length; + + TRACE_MEM("sg %p (len %d) for REPORTS LUNS for cmd %p", sg, len, cmd); + + buf = sg_virt(sg); + len = max_t(int, 8, len); + + memset(buf, 0, len); + offs = 8; + + rcu_read_lock(); + for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) { + struct list_head *head = &cmd->sess->sess_tgt_dev_list[i]; + + list_for_each_entry_rcu(tgt_dev, head, + sess_tgt_dev_list_entry) { + struct scst_tgt_dev_UA *ua; + + if (!overflow) { + if ((len - offs) < 8) { + overflow = 1; + goto inc_dev_cnt; + } + *(__force __be64 *)&buf[offs] + = scst_pack_lun(tgt_dev->lun, + cmd->sess->acg->addr_method); + offs += 8; + } +inc_dev_cnt: + dev_cnt++; + + /* Clear sense_reported_luns_data_changed UA. */ + spin_lock_bh(&tgt_dev->tgt_dev_lock); + list_for_each_entry(ua, &tgt_dev->UA_list, + UA_list_entry) { + if (scst_analyze_sense(ua->UA_sense_buffer, + ua->UA_valid_sense_len, + SCST_SENSE_ALL_VALID, + SCST_LOAD_SENSE(scst_sense_reported_luns_data_changed))) { + TRACE_DBG( + "Freeing not needed REPORTED LUNS DATA CHANGED UA %p", + ua); + scst_tgt_dev_del_free_UA(tgt_dev, ua); + break; + } + } + spin_unlock_bh(&tgt_dev->tgt_dev_lock); + } + } + rcu_read_unlock(); + + /* Set the response header */ + dev_cnt *= 8; + put_unaligned_be32(dev_cnt, buf); + + dev_cnt += 8; + if (dev_cnt < len) + len = dev_cnt; + + TRACE_BUFFER("REPORTS LUNS for not supported LUN set", buf, len); + + cmd->data_direction = SCST_DATA_READ; + scst_set_resp_data_len(cmd, len); + + cmd->completed = 1; + cmd->resid_possible = 1; + +out: + TRACE_EXIT_RES(res); + + return res; +} + /* * scst_set_cmd_error() - set error in the command and fill the sense buffer. * @@ -1955,6 +2096,8 @@ int scst_set_cmd_error(struct scst_cmd *cmd, int key, int asc, int ascq) key, asc, ascq); else if (cmd->cdb[0] == INQUIRY) res = scst_set_lun_not_supported_inquiry(cmd); + else if (cmd->cdb[0] == REPORT_LUNS) + res = scst_set_lun_not_supported_report_luns(cmd); else goto do_sense; From 7c4e07414afb990e52cc4f6afade215a98ec657a Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Fri, 3 May 2024 13:55:26 +0300 Subject: [PATCH 22/26] .github/workflows: Add a GitHub action to run regression tests upon push Introduce a new GitHub action that automatically runs the scripts/run_regression_tests script upon each push to the master branch. --- .github/workflows/run_regression_tests.yaml | 66 +++++++++++++++++++++ scripts/kernel-functions | 5 ++ scripts/run-regression-tests | 4 +- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/run_regression_tests.yaml diff --git a/.github/workflows/run_regression_tests.yaml b/.github/workflows/run_regression_tests.yaml new file mode 100644 index 000000000..60f2580fb --- /dev/null +++ b/.github/workflows/run_regression_tests.yaml @@ -0,0 +1,66 @@ +name: Regression tests upon push + +on: + push: + branches: + - master + +jobs: + regression_tests: + name: ${{matrix.version}} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: [ + '6.8.7', + '6.7.12', + '6.6.28', + '6.1.87', + '5.15.156', + '5.10.215', + '5.4.274', + '4.19.312', + '4.14.336', + '4.9.337', + '3.18.140', + '3.10.108', + '5.14.0-284.30.1.el9_2^AlmaLinux^9.2', + '4.18.0-513.24.1.el8_9^AlmaLinux^8.9', + '4.18.0-477.13.1.el8_8^AlmaLinux^8.8', + '3.10.0-1160.108.1.el7^CentOS^7.9.2009', + '5.15.0-205.149.5.1.el9uek^UEK^9', + '5.4.17-2136.330.7.1.el8uek^UEK^8', + '5.4.17-2102.206.1.el7uek^UEK^7', + '4.1.12-124.48.6.el6uek^UEK^6' + ] + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Install libelf-dev + run: | + sudo apt-get install -y libelf-dev + + - name: Install sparse + run: | + sudo apt-get install sparse + + - name: Install smatch + run: | + git clone https://github.com/error27/smatch.git + cd smatch + make -j + sudo BINDIR=/bin SHAREDIR=/home/runner/share make install + + - name: Run regression tests + run: | + err=0 + + ./scripts/run-regression-tests -l -q -k -d /tmp/scst-${{matrix.version}} ${{matrix.version}}-nc-ns-nm | tee output.txt + + cat output.txt | grep -A1 "Compiling the patched kernel" | grep -e "FAILED" -e "[^0] errors" > /dev/null 2>&1 && err=1 + + rm -f output.txt + + exit $err diff --git a/scripts/kernel-functions b/scripts/kernel-functions index 336baf8e2..21d904e5f 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -60,7 +60,9 @@ function download_kernel { [12].*) series="${series:0:3}";; *) series="${series/.*/}.x";; esac + mkdir -p "${kernel_downloads}" || return $? + test -w "${kernel_downloads}" || return $? ( cd "${kernel_downloads}" || return $? @@ -826,6 +828,9 @@ function download_and_extract_distro_rpm { local kver=$1 local distro=$2 local release=$3 + + mkdir -p "${kernel_downloads}" || return $? + ( cd "${kernel_downloads}" || exit $? read -a urls -r <<<"$(get_srpm_urls "$distro" "$release" x86_64 | diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index 764e9d757..4d761f1f0 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -466,9 +466,9 @@ function run_smatch { then local errors warnings errors=$(grep -c ' error:' "${outputfile}") - warnings=$(grep -c ' warning:' "${outputfile}") + warnings=$(grep -c ' warn:' "${outputfile}") echo "${errors} errors / ${warnings} warnings." - grep -E ' info:| warning:| error:' < "${outputfile}" | + grep -E ' info:| warn:| error:' < "${outputfile}" | sed 's/^\([^:]*\):[0-9:]* /\1: /;s/\((see line \)[0-9]*\()\)/\1...\2/' | sort | uniq -c From 2df4770666b2070b8802c325e57e25028baa3822 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 3 Feb 2023 19:47:29 +0500 Subject: [PATCH 23/26] Update packaging bits to build scst-dbg package This commits updates the Debian packaging bits to build scst-dbg package for kernel modules linked with debug kernel. SCST kernel modules linked with debug kernel need to packaged differently so that they can co-exist with SCST package for modules built for production kernel. The updates in packaging bits are minimal would only apply if KVERS environment variable is configured for debug kernel for TrueNAS SCALE. Signed-off-by: Umer Saleem --- Makefile | 14 ++++++++++---- debian/control.dbgmodules | 18 ++++++++++++++++++ debian/rules | 9 +++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 debian/control.dbgmodules diff --git a/Makefile b/Makefile index bdcca8243..d4374f7e0 100644 --- a/Makefile +++ b/Makefile @@ -429,10 +429,16 @@ dpkg: ../scst_$(VERSION).orig.tar.gz echo "KVER=$(KVER)" && \ sed 's/%{scst_version}/$(VERSION)/' \ debian/scst.dkms && \ - sed 's/%{KVER}/$(KVER)/' \ - debian/scst.preinst && \ - sed 's/%{KVER}/$(KVER)/' \ - debian/scst.postinst && \ + if echo "$(KVER)" | grep -q "debug+truenas"; then \ + mv debian/scst.install debian/scst-dbg.install && \ + sed 's/%{KVER}/$(KVER)/' \ + debian/scst-dbg.postinst; \ + else \ + sed 's/%{KVER}/$(KVER)/' \ + debian/scst.preinst && \ + sed 's/%{KVER}/$(KVER)/' \ + debian/scst.postinst; \ + fi && \ output_files=( \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.deb \ ../*_$(VERSION)-$(DEBIAN_REVISION)_*.ddeb \ diff --git a/debian/control.dbgmodules b/debian/control.dbgmodules new file mode 100644 index 000000000..eb17723bb --- /dev/null +++ b/debian/control.dbgmodules @@ -0,0 +1,18 @@ +Source: scst +Section: net +Priority: optional +Maintainer: Vladislav Bolkhovitin +Build-Depends: debhelper (>= 9), + quilt, + dpkg-dev (>= 1.13.19) +Standards-Version: 4.1.1 +Homepage: http://scst.sourceforge.net + +Package: scst-dbg +Architecture: any +Depends: ${misc:Depends} +Conflicts: scst-dkms +Description: Generic SCSI target framework + SCST is a SCSI target framework that allows local block device data to be + accessed over a storage network via the iSCSI, FC, SRP or FCoE protocol. + This package contains the SCST kernel modules. diff --git a/debian/rules b/debian/rules index 8424310e4..ba515b7a3 100755 --- a/debian/rules +++ b/debian/rules @@ -33,8 +33,13 @@ VERSION:=$(shell head -n1 debian/changelog | sed 's/.*(\([0-9.]*\).*).*/\1/') clean: dh_testdir && \ dh_prep -Xqla_isp/TAGS -Xdebian/changelog && \ - scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst.preinst \ - -x debian/scst.postinst + if echo "$(KVER)" | grep -q "debug+truenas"; then \ + scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst-dbg.install \ + -x debian/scst-dbg.postinst ; \ + else \ + scripts/clean-source-tree -x debian/changelog -x debian/compat -x debian/scst.preinst \ + -x debian/scst.postinst ; \ + fi build: [ -n "$(QLA_INI_DIR)" ] && \ From 74a2c021163d6f32fb49fca98fd12038127bdfdb Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Wed, 10 May 2023 01:02:35 +0400 Subject: [PATCH 24/26] Specify linux headers dependencies in control file --- debian/control | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 2286c3d3f..ab082f512 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,10 @@ Section: net Priority: optional Maintainer: Vladislav Bolkhovitin Build-Depends: debhelper (>= 9), + linux-headers-truenas-production-amd64, + linux-headers-truenas-debug-amd64, + linux-image-truenas-production-amd64, + linux-image-truenas-debug-amd64, quilt, dpkg-dev (>= 1.13.19) Standards-Version: 4.1.1 @@ -10,7 +14,11 @@ Homepage: http://scst.sourceforge.net Package: scst Architecture: any -Depends: ${misc:Depends} +Depends: linux-headers-truenas-production-amd64, + linux-headers-truenas-debug-amd64, + linux-image-truenas-production-amd64, + linux-image-truenas-debug-amd64, + ${misc:Depends} Conflicts: scst-dkms Description: Generic SCSI target framework SCST is a SCSI target framework that allows local block device data to be From eedaedcf5a3b7853555e9cb2cc08d3d05683aea7 Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Wed, 24 Jan 2024 15:50:14 -0800 Subject: [PATCH 25/26] Disable unused expensive code in addVirtualTarget The code to enable all hardware targets before creating virtual ones becomes more expensive as the target count climbs. --- scstadmin/scstadmin.sysfs/scstadmin | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 84e539a61..9bfbe5f02 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -3031,6 +3031,9 @@ sub addVirtualTarget { my $errorString; my $targets; + # Disable this code. Never used but gets expensive as the + # target count climbs. + if (0) { # Enable all hardware targets before creating virtual ones ($targets, $errorString) = $SCST->targets($driver); foreach my $_target (@{$targets}) { @@ -3042,6 +3045,7 @@ sub addVirtualTarget { enableTarget($driver, $_target); } } + } print "\t-> Creating target '$target' for driver '$driver': "; my $rc = $SCST->addVirtualTarget($driver, $target, $attributes); From 48479cbbdcf1c2c24c4ee24444618cdf64973cec Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Mon, 29 Jan 2024 12:31:32 -0800 Subject: [PATCH 26/26] When stopping scst turn off cluster_mode in parallel --- scstadmin/init.d/scst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scstadmin/init.d/scst b/scstadmin/init.d/scst index 9490e1b29..f7dcb3a01 100755 --- a/scstadmin/init.d/scst +++ b/scstadmin/init.d/scst @@ -269,6 +269,17 @@ stop_scst() { return 1 fi + # Disable iSCSI + if [ -f /sys/kernel/scst_tgt/targets/iscsi/enabled ]; then + echo 0 > /sys/kernel/scst_tgt/targets/iscsi/enabled + fi + + # Turn off any cluster_mode in parallel + for cm in /sys/kernel/scst_tgt/devices/*/cluster_mode ; do + echo 0 > "$cm" & + done + wait + unload_scst }