Fixing SCST 3.9 Compilation On RHEL 9.7 & RHEL 10.1
Hey guys! Today, we're diving deep into the nitty-gritty of resolving compilation issues with SCST-3.9 on the pre-release versions of RHEL9.7 and RHEL10.1. If you've been banging your head against the wall trying to get this to work, you're in the right place. Let's break it down and get you back on track!
Understanding the Compilation Challenges
When dealing with storage technologies, encountering compilation errors can be a major roadblock. In our case, SCST (SCSI Target Subsystem), a crucial component for creating iSCSI targets, ran into some snags during compilation on the pre-release versions of RHEL9.7 and RHEL10.1. These issues are primarily due to changes in the kernel and the removal of certain SCSI opcodes, which can be a real headache if you're not prepared. Getting into the specifics, the compilation process stalled because of deprecated functions and missing definitions within the kernel versions used by these RHEL releases. Specifically, the function bio_add_pc_page was removed, and the SCSI opcodes RELEASE and RESERVE were also deprecated. These changes meant that the older SCST-3.9 code was no longer compatible without modifications. Understanding these underlying causes is the first step toward implementing effective solutions and ensuring that your storage subsystems work as expected.
RHEL9.7 Compilation Errors and Solutions
Let's start with RHEL9.7. The primary issue here is the removal of the bio_add_pc_page function from kernel version 5.14.0-578.el9, which impacts the compilation of SCST-3.9. If you're seeing errors like:
/root/ontap_mediator.7Sl8ZY/project/project/dist/scst/scst-3.9/scst/src/scst_lib.c:8557:30: error: implicit declaration of function 'bio_add_pc_page'; did you mean 'bio_add_page'? [-Werror=implicit-function-declaration]
8557 | rc = bio_add_pc_page(q, bio, page, bytes, offset);
| ^~~~~~~~~~~~~~~
| bio_add_page
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:249: /root/ontap_mediator.7Sl8ZY/project/project/dist/scst/scst-3.9/scst/src/scst_lib.o] Error 1
You're in the right boat! The error message implicit declaration of function 'bio_add_pc_page' clearly indicates that the function bio_add_pc_page is no longer recognized by the kernel. This function was indeed removed in kernel version 5.14.0-578.el9, as documented in the merge request. Since RHEL9.7 uses kernel 5.14.0-611.2.1, you'll need a workaround. So, to fix this, the solution is to use a kernel version check. By checking the kernel version during the compilation process, you can conditionally call the appropriate function. If the kernel version is older than the one where bio_add_pc_page was removed, use bio_add_pc_page; otherwise, use bio_add_page(bio, page, bytes, offset). This ensures compatibility across different kernel versions. This involves adding a conditional statement in your code that checks the kernel version and calls the appropriate function based on the result. This approach maintains compatibility with older kernels while adapting to the changes in newer versions.
RHEL10.1 Compilation Errors and Solutions
Moving on to RHEL10.1, we face a different set of challenges. Here, the issues stem from the removal of the SCSI opcodes RELEASE and RESERVE from the newer kernel. Plus, there are some missing double quotes in macro definitions. If you encounter errors like:
/root/project/project-1/project-1/dist/scst/scst-3.9/scst/src/scst_lib.c:236:22: error: 'RESERVE' undeclared here (not in a function); did you mean 'RESERVE_6'?
236 | .od_opcode = RESERVE,
| ^~~~~~~
| RESERVE_6
/root/project/project-1/project-1/dist/scst/scst-3.9/scst/src/scst_lib.c:246:22: error: 'RELEASE' undeclared here (not in a function); did you mean 'RELEASE_6'?
246 | .od_opcode = RELEASE,
| ^~~~~~~
| RELEASE_6
And:
/root/project/project-1/project-1/dist/scst/scst-3.9/scst/src/dev_handlers/../../include/backport.h:1008:33: error: expected ',' or ';' before 'SCST'
1008 | #define SCST_NAMESPACE SCST
| ^~~~
./include/linux/moduleparam.h:26:61: note: in definition of macro '__MODULE_INFO'
26 | = __MODULE_INFO_PREFIX __stringify(tag) "=" info
| ^~~~
./include/linux/module.h:299:33: note: in expansion of macro 'MODULE_INFO'
299 | #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns)
| ^~~~~~~~~~~
/root/project/project-1/project-1/dist/scst/scst-3.9/scst/src/dev_handlers/scst_cdrom.c:235:1: note: in expansion of macro 'MODULE_IMPORT_NS'
235 | MODULE_IMPORT_NS(SCST_NAMESPACE);
| ^~~~~~~~~~~~~~~~
/root/project/project-1/project-1/dist/scst/scst-3.9/scst/src/dev_handlers/scst_cdrom.c:235:18: note: in expansion of macro 'SCST_NAMESPACE'
235 | MODULE_IMPORT_NS(SCST_NAMESPACE);
| ^~~~~~~~~~~~~~
You've got the RHEL10.1 blues. To address these issues, you can apply the following patch to backport.h:
diff -ruN scst-3.9/scst/include/backport.h scst-3.9-patched/scst/include/backport.h
---
--- a/scst-3.9/scst/include/backport.h
2025-10-08 14:46:14.753350503 -0400
+++
b/scst-3.9-patched/scst/include/backport.h
2025-10-08 15:28:55.847231856 -0400
@@ -390,6 +390,14 @@
}
#endif
+
#ifndef RELEASE
+#define RELEASE RELEASE_6
+#endif
+
+#ifndef RESERVE
+#define RESERVE RESERVE_6
+#endif
+
/* <linux/compiler.h> */
@@ -1005,9 +1005,9 @@
/* <linux/module.h> */
@@ - #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0)
-#define SCST_NAMESPACE SCST
-#define SCST_QLA16_NAMESPACE QLA16GB
-#define SCST_QLA32_NAMESPACE QLA32GB
-+#define SCST_NAMESPACE "SCST"
+#define SCST_QLA16_NAMESPACE "QLA16GB"
+#define SCST_QLA32_NAMESPACE "QLA32GB"
#else
#define SCST_NAMESPACE "SCST"
#define SCST_QLA16_NAMESPACE "QLA16GB"
This patch addresses the missing RELEASE and RESERVE definitions by aliasing them to RELEASE_6 and RESERVE_6, respectively. Additionally, it adds the missing double quotes to the macro definitions for SCST_NAMESPACE, SCST_QLA16_NAMESPACE, and SCST_QLA32_NAMESPACE. By applying this patch, you should be able to overcome these compilation errors and successfully build SCST-3.9 on RHEL10.1.
Applying the Solutions: Step-by-Step
- For RHEL9.7:
- Locate the
scst_lib.cfile in thescst/srcdirectory. - Add a kernel version check around the
bio_add_pc_pagecall. - Replace
bio_add_pc_page(q, bio, page, bytes, offset)with a conditional call to eitherbio_add_pc_pageorbio_add_pagebased on the kernel version.
- Locate the
- For RHEL10.1:
- Apply the provided patch to the
backport.hfile located in thescst/includedirectory. - Ensure that the patch is applied cleanly without any conflicts.
- Apply the provided patch to the
Best Practices for Kernel Module Compilation
- Always check the kernel version: Before compiling kernel modules, make sure to check the kernel version and any specific configurations that might affect the compilation process.
- Use appropriate backporting techniques: When dealing with older code on newer kernels, use backporting techniques to ensure compatibility. This might involve adding conditional checks or aliasing deprecated functions.
- Keep your codebase updated: Regularly update your codebase to align with the latest kernel APIs and features. This reduces the chances of encountering compilation errors due to deprecated functions or missing definitions.
- Test thoroughly: After applying any patches or workarounds, test your code thoroughly to ensure that it functions as expected. This includes both unit tests and integration tests.
Conclusion
So, there you have it! By understanding the specific issues in RHEL9.7 and RHEL10.1 and applying the appropriate solutions, you can successfully compile SCST-3.9 and keep your storage subsystems running smoothly. Remember to always stay updated with kernel changes and adapt your code accordingly. Happy compiling, and feel free to reach out if you have any more questions!
For more information about the SCST project, you can visit the official website: SCST Project