From 3eaf2b6d0498e9f5167d04261ad3e3a853ae3f82 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Fri, 3 Feb 2023 19:47:29 +0500 Subject: [PATCH 1/5] 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 8cb67fd480eb1ac39819e7de3b2c3ccc34ec7079 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Wed, 10 May 2023 01:02:35 +0400 Subject: [PATCH 2/5] 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 4a7f8bbb60c4dd714c65a3d37f5cfdc474ec46a7 Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Wed, 24 Jan 2024 15:50:14 -0800 Subject: [PATCH 3/5] 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 28af5b48ad51c651da7f91d09a3dbbea75c3f35a Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Mon, 29 Jan 2024 12:31:32 -0800 Subject: [PATCH 4/5] 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 } From 0a314fe1c0ed5ad76c06c4cb18ee4be7709cd87e Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Thu, 2 May 2024 12:22:56 -0700 Subject: [PATCH 5/5] scst/include/backport.h: Update backport for Linux kernel 6.6.23 The following was backported to Linux kernel 6.6.23 - dd0bd4291250 (block: Provide bdev_open_* functions) --- scst/include/backport.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 5798e7cf2..f8596ab17 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -282,9 +282,10 @@ 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, 6, 23) /* * See also commit e719b4d15674 ("block: Provide bdev_open_* functions") # v6.7. + * Also backported to 6.6.23 in commit dd0bd4291250 */ struct bdev_handle { struct block_device *bdev;