Skip to content

Commit 65579f4

Browse files
committed
CI: Test & fix Linux ZFS built-in build
ZFS can be built directly into the Linux kernel. Add a test build of this to the CI to verify it works. The test build is only enabled on Fedora runners (since they run the newest kernels) and is done in parallel with ZTS. The test build is done on vm2, since it typically finishes ~15min before vm1 and thus has time to spare. In addition: - Update 'copy-builtin' to check that $1 is a directory - Fix some VERIFYs that were causing the built-in build to fail Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #18234
1 parent 2032f21 commit 65579f4

File tree

8 files changed

+77
-10
lines changed

8 files changed

+77
-10
lines changed

.github/workflows/scripts/qemu-6-tests.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# 6) load openzfs module and run the tests
55
#
66
# called on runner: qemu-6-tests.sh
7-
# called on qemu-vm: qemu-6-tests.sh $OS $2 $3 [--lustre] [quick|default]
7+
# called on qemu-vm: qemu-6-tests.sh $OS $2 $3 [--lustre|--builtin] [quick|default]
88
#
99
# --lustre: Test build lustre in addition to the normal tests
10+
# --builtin: Test build ZFS as a kernel built-in in addition to the normal tests
1011
######################################################################
1112

1213
set -eu
@@ -50,6 +51,44 @@ function do_lustre_build() {
5051
}
5152
export -f do_lustre_build
5253

54+
# Test build ZFS into the kernel directly
55+
function do_builtin_build() {
56+
local rc=0
57+
# Get currently full kernel version (like '6.18.8')
58+
fullver=$(uname -r | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+')
59+
60+
# Get just the major ('6')
61+
major=$(echo $fullver | grep -Eo '^[0-9]+')
62+
(
63+
set -e
64+
65+
wget https://cdn.kernel.org/pub/linux/kernel/v${major}.x/linux-$fullver.tar.xz
66+
tar -xf $HOME/linux-$fullver.tar.xz
67+
cd $HOME/linux-$fullver
68+
make tinyconfig
69+
./scripts/config --enable EFI_PARTITON
70+
./scripts/config --enable BLOCK
71+
# BTRFS_FS is easiest config option to enable CONFIG_ZLIB_INFLATE|DEFLATE
72+
./scripts/config --enable BTRFS_FS
73+
yes "" | make oldconfig
74+
make prepare
75+
76+
cd $HOME/zfs
77+
./configure --with-linux=$HOME/linux-$fullver --enable-linux-builtin --enable-debug
78+
./copy-builtin $HOME/linux-$fullver
79+
80+
cd $HOME/linux-$fullver
81+
./scripts/config --enable ZFS
82+
yes "" | make oldconfig
83+
make -j `nproc`
84+
) &> /var/tmp/builtin.txt || rc=$?
85+
echo "$rc" > /var/tmp/builtin-exitcode.txt
86+
if [ "$rc" != "0" ] ; then
87+
echo "$rc" > /var/tmp/tests-exitcode.txt
88+
fi
89+
}
90+
export -f do_builtin_build
91+
5392
# called directly on the runner
5493
if [ -z ${1:-} ]; then
5594
cd "/var/tmp"
@@ -66,9 +105,15 @@ if [ -z ${1:-} ]; then
66105
# on almalinux*. At the time of writing, the vm2 tests were
67106
# completing roughly 15min before the vm1 tests, so it makes sense
68107
# to have vm2 do the build.
108+
#
109+
# In addition, we do an additional test build of ZFS as a Linux
110+
# kernel built-in on Fedora. Again, we do it on vm2 to exploit vm2's
111+
# early finish time.
69112
extra=""
70113
if [[ "$OS" == almalinux* ]] && [[ "$i" == "2" ]] ; then
71114
extra="--lustre"
115+
elif [[ "$OS" == fedora* ]] && [[ "$i" == "2" ]] ; then
116+
extra="--builtin"
72117
fi
73118

74119
daemonize -c /var/tmp -p vm${i}.pid -o vm${i}log.txt -- \
@@ -106,9 +151,13 @@ DEN="$1"
106151
shift
107152

108153
BUILD_LUSTRE=0
154+
BUILD_BUILTIN=0
109155
if [ "$1" == "--lustre" ] ; then
110156
BUILD_LUSTRE=1
111157
shift
158+
elif [ "$1" == "--builtin" ] ; then
159+
BUILD_BUILTIN=1
160+
shift
112161
fi
113162

114163
if [ "$1" == "quick" ] ; then
@@ -162,6 +211,9 @@ esac
162211
# The Lustre build on its own takes ~15min.
163212
if [ "$BUILD_LUSTRE" == "1" ] ; then
164213
do_lustre_build &
214+
elif [ "$BUILD_BUILTIN" == "1" ] ; then
215+
# Try building ZFS directly into the Linux kernel (not as a module)
216+
do_builtin_build &
165217
fi
166218

167219
# run functional testings and save exitcode

.github/workflows/scripts/qemu-8-summary.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ EOF
3333

3434
function showfile_tail() {
3535
echo "##[group]$2 (final lines)"
36-
tail -n 40 $1
36+
tail -n 80 $1
3737
echo "##[endgroup]"
3838
}
3939

@@ -66,6 +66,18 @@ for ((i=1; i<=VMs; i++)); do
6666
test -s "$file" && showfile_tail "$file" "$vm: Lustre build"
6767
fi
6868

69+
if [ -f vm$i/builtin-exitcode.txt ] ; then
70+
rv=$(< vm$i/builtin-exitcode.txt)
71+
if [ $rv = 0 ]; then
72+
vm="vm$i"
73+
else
74+
vm="vm$i"
75+
touch /tmp/have_failed_tests
76+
fi
77+
file="vm$i/builtin.txt"
78+
test -s "$file" && showfile_tail "$file" "$vm: Linux built-in build"
79+
fi
80+
6981
rv=$(cat vm$i/tests-exitcode.txt)
7082

7183
if [ $rv = 0 ]; then

copy-builtin

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ usage()
88
exit 1
99
}
1010

11-
[ "$#" -eq 1 ] || usage
11+
if ! [ -d "$1" ] ; then
12+
usage
13+
fi
1214
KERNEL_DIR="$1"
1315

1416
if ! [ -e 'zfs_config.h' ]
@@ -31,6 +33,7 @@ cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<EOF
3133
config ZFS
3234
tristate "ZFS filesystem support"
3335
depends on EFI_PARTITION
36+
depends on BLOCK
3437
select ZLIB_INFLATE
3538
select ZLIB_DEFLATE
3639
help

module/zfs/dataset_kstats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ dataset_kstats_rename(dataset_kstats_t *dk, const char *name)
212212
char *ds_name;
213213

214214
ds_name = KSTAT_NAMED_STR_PTR(&dkv->dkv_ds_name);
215-
ASSERT3S(ds_name, !=, NULL);
215+
ASSERT3P(ds_name, !=, NULL);
216216
(void) strlcpy(ds_name, name,
217217
KSTAT_NAMED_STR_BUFLEN(&dkv->dkv_ds_name));
218218
}

module/zfs/ddt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ ddt_configure(ddt_t *ddt, boolean_t new)
15081508
DMU_POOL_DIRECTORY_OBJECT, name, sizeof (uint64_t), 1,
15091509
&ddt->ddt_dir_object);
15101510
if (error == 0) {
1511-
ASSERT3U(spa->spa_meta_objset, ==, ddt->ddt_os);
1511+
ASSERT3P(spa->spa_meta_objset, ==, ddt->ddt_os);
15121512

15131513
error = zap_lookup(ddt->ddt_os, ddt->ddt_dir_object,
15141514
DDT_DIR_VERSION, sizeof (uint64_t), 1,

module/zfs/ddt_log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ ddt_log_update_entry(ddt_t *ddt, ddt_log_t *ddl, ddt_lightweight_entry_t *ddlwe)
262262
void
263263
ddt_log_entry(ddt_t *ddt, ddt_lightweight_entry_t *ddlwe, ddt_log_update_t *dlu)
264264
{
265-
ASSERT3U(dlu->dlu_dbp, !=, NULL);
265+
ASSERT3P(dlu->dlu_dbp, !=, NULL);
266266

267267
ddt_log_update_entry(ddt, ddt->ddt_log_active, ddlwe);
268268
ddt_histogram_add_entry(ddt, &ddt->ddt_log_histogram, ddlwe);
@@ -312,7 +312,7 @@ ddt_log_entry(ddt_t *ddt, ddt_lightweight_entry_t *ddlwe, ddt_log_update_t *dlu)
312312
void
313313
ddt_log_commit(ddt_t *ddt, ddt_log_update_t *dlu)
314314
{
315-
ASSERT3U(dlu->dlu_dbp, !=, NULL);
315+
ASSERT3P(dlu->dlu_dbp, !=, NULL);
316316
ASSERT3U(dlu->dlu_block+1, ==, dlu->dlu_ndbp);
317317
ASSERT3U(dlu->dlu_offset, >, 0);
318318

module/zfs/spa_misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ spa_vdev_enter(spa_t *spa)
12451245
mutex_enter(&spa->spa_vdev_top_lock);
12461246
mutex_enter(&spa_namespace_lock);
12471247

1248-
ASSERT0(spa->spa_export_thread);
1248+
ASSERT0P(spa->spa_export_thread);
12491249

12501250
vdev_autotrim_stop_all(spa);
12511251

@@ -1264,7 +1264,7 @@ spa_vdev_detach_enter(spa_t *spa, uint64_t guid)
12641264
mutex_enter(&spa->spa_vdev_top_lock);
12651265
mutex_enter(&spa_namespace_lock);
12661266

1267-
ASSERT0(spa->spa_export_thread);
1267+
ASSERT0P(spa->spa_export_thread);
12681268

12691269
vdev_autotrim_stop_all(spa);
12701270

module/zfs/zio_compress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ zio_compress_data(enum zio_compress c, abd_t *src, abd_t **dst, size_t s_len,
128128
uint8_t complevel;
129129
zio_compress_info_t *ci = &zio_compress_table[c];
130130

131-
ASSERT3U(ci->ci_compress, !=, NULL);
131+
ASSERT3P(ci->ci_compress, !=, NULL);
132132
ASSERT3U(s_len, >, 0);
133133

134134
complevel = ci->ci_level;

0 commit comments

Comments
 (0)