zfs: zpool crashes when compatibility file is missing
If a pool was created with a compatibility file which later goes missing, it crashes on various zpool commands. (I dont know WHY the file is needed after creating the zpool)
Recreating an empty file solves the issue. Its probably a libc issue since ubuntu doesnt have this problem.
Expected situation (on ubuntu 20):
ws1# echo > compat.txt; dd if=/dev/zero of=disk.bin bs=1M count=100; zpool create -o compatibility=/root/compat.txt test2 /root/disk.bin; zpool list test2; rm compat.txt; zpool list test2 ; zpool destroy test2
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.0175743 s, 6.0 GB/s
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
test2 80M 174K 79.8M - - - 0% 1.00x ONLINE -
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
test2 80M 174K 79.8M - - - 0% 1.00x ONLINE -
ws1# zfs --version
zfs-2.1.5-1~20.04.york0
zfs-kmod-2.1.5-1~20.04.york0
On alpine:
alpine:~# echo > compat.txt; dd if=/dev/zero of=disk.bin bs=1M count=100; zpool create -o compatibility=/root/compat.txt test2 /root/disk.bin; zpool list test2; rm compat.txt; zpool list test2 ; zpool destroy te
st2
100+0 records in
100+0 records out
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
test2 80M 166K 79.8M - - - 0% 1.00x ONLINE -
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Illegal instruction
alpine:~# zfs --version
zfs-2.1.5-1
zfs-kmod-2.1.5-1
Partial strace:
....
open("/etc/hostid", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
writev(1, [{iov_base="rpool 7.50G 172M 7.33G "..., iov_len=79}, {iov_base="\n", iov_len=1}], 2rpool 7.50G 172M 7.33G - - 0% 2% 1.00x ONLINE -
) = 80
open("/proc/sys/kernel/spl/hostid", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 6
fcntl(6, F_SETFD, FD_CLOEXEC) = 0
fcntl(6, F_SETFD, FD_CLOEXEC) = 0
read(6, "0\n", 1024) = 2
lseek(6, -1, SEEK_CUR) = 1
close(6) = 0
open("/etc/hostid", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/zfs/compatibility.d", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
open("/usr/share/zfs/compatibility.d", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat(-1, "/root/compat.txt", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(-1, "/root/compat.txt", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
close(-1) = -1 EBADF (Bad file descriptor)
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x7f5510fb52bc} ---
+++ killed by SIGILL
Linux alpine 5.15.74-0-lts #1 (closed)-Alpine SMP Sat, 15 Oct 2022 18:26:49 +0000 x86_64 Linux Alpine 3.16