Command failed with status code 5

Paul van Genderen-Tjie A Loi <[email protected]>
Newsgroups gmane.linux.lvm.devel
Message-ID <[email protected]>
Hello,

Invoking "vgscan --mknodes" or "vgmknodes" can result in the following
error message: Command failed with status code 5. Furthermore, it is
possible for this particular message to be printed regardless of any
actual failure. The exit code of the commands match the printed code.

For instance, using QEMU utilities to create a block device:
qemu-img -f qcow2 testmknodes.qcow2 20G
qemu-nbd --connect=/dev/nbd0 testmknodes.qcow2
pvcreate /dev/nbd0
vgcreate testvg /dev/nbd0
lvcreate -l 100%FREE --thinpool testtp testvg
lvcreate -V 10G --thinpool testtp testvg

Everything works as expected until the thin LV is created. In case of
additional errors, please ensure both "dm_thin_pool" and "nbd" modules
are loaded into the kernel. After creating volumes this way and they're
configured to be activated (the default), the commands fail.

Status code 5 matches ECMD_FAILED which is defined in tools/errors.h and
is returned by _vgmknodes_single in tools/vgmknodes.c
_vgmknodes_single calls lv_mknodes which calls dev_manager_mknodes and
that function resides in lib/activate/dev_manager.c

dev_manager_mknodes by default returns 0 (line 2057) and this return
value is only changed on 2 conditions, the first of which using a nested
if statement. The nested if omits an else clause and adding one right
there has fixed the problem for me. Diff attached.

I've tested this against commit e84b00964 running on Linux 6.1.38 and
6.3.12. There may well be other use cases that trigger this failure
condition and I must admit that I've only tested the thin pool case.

Regards,
Paul

--
lvm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/lvm-devel
dev_manager_mknodes.diff (text/x-diff, 376 B)
--- lvm2~/lib/activate/dev_manager.c
+++ lvm2/lib/activate/dev_manager.c
@@ -2066,6 +2066,7 @@ int dev_manager_mknodes(const struct logical_volume *lv)
 		/* read-only component LV is also made visible */
 		if (_lv_has_mknode(lv) || (dminfo.read_only && lv_is_component(lv)))
 			r = _dev_manager_lv_mknodes(lv);
+		else r = 1;
 	} else
 		r = _dev_manager_lv_rmnodes(lv);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.