[lvm-devel] [PATCH] dmsetup: Set exit code to 1 if remove_all fails to remove all devices

Lukas Wunner lukas at wunner.de
Tue Dec 2 21:00:45 UTC 2014


Hi,

On Tue, Dec 02, 2014 at 08:16:00PM +0100, Zdenek Kabelac wrote:
> It really is meant to remove only not opened devices.

Sorry but that's not the point.

The interpretation of a program's exit status by the Shell is inverse
to the semantics in C. An exit status of 0 denotes success, a non-zero
exit status denotes failure.

The point is that, as evidenced by the dracut shutdown script I mentioned,
people expect the exit status of "dmsetup remove_all" to be non-zero if
the program failed to remove all devices. It's perfectly okay if it failed
to remove all devices. No need to remove devices that are still open.

But the program should *tell* the user that some devices could not be
closed (at the very least by returning with a non-zero exit status).

Right now the exit status of "dmsetup remove_all" is always 0, thus
pretending success.

As for the dracut shutdown script allegedly being broken: That script
was written by Harald Hoyer who works for the same company as you do
and is shipped with RHEL as well as Fedora. Just saying...

To provide some context: Dracut has a number of shutdown scripts that
are called round-robin until all succeed. This is useful for complex
LVM setups, e.g. a device mapper target layered on top of ZFS, with the
ZFS pool itself being backed by another device mapper target. To properly
untangle this, the dm-shutdown script should close the top-layered
device mapper target, next a zfs-shutdown script will export the zpool,
and finally another invocation of the dm-shutdown script will close
the bottom-layered device mapper target.

For this to work, the exit status of "dmsetup remove_all" must be
non-zero on failure, otherwise the dm-shutdown script cannot determine
whether it's work is done.

Therefore, please consider merging this patch.

Kind regards,

Lukas




More information about the lvm-devel mailing list