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

Lukas Wunner lukas at wunner.de
Sat Dec 6 21:25:19 UTC 2014


Hi,

On Tue, Dec 02, 2014 at 10:12:29PM +0100, Zdenek Kabelac wrote:
> remove_all - means to remove all CLOSED (unused) devices.
> It should return 'fail' if there is failure during command execution
> (i.e. mem alloc fail)  - but it will not report error if there
> are left devices.

The blkdeactivate.sh script (which you've suggested) uses "dmsetup remove".

It turns out that "dmsetup remove" does fail with a non-zero exit status
if one tries to remove a device which is still in use. On the other hand,
as stated before "dmsetup remove_all" does *not* fail with a non-zero exit
status if it couldn't remove all devices.

So the behaviour of dmsetup is inconsistent. That precisely is fixed
by the proposed patch. I find it bewildering that you call this a
"valid and expected behaviour" even though it is inconsistent.

I went ahead and changed the dracut shutdown script to loop over all
devices and call "dmsetup remove" on each of them. When testing it
I discovered that calling "dmsetup remove" on an (unused) crypt device
causes the system to hang on shutdown. Perhaps the ioctl() is blocking?
Should crypt devices only be removed with cryptsetup, not with
"dmsetup remove"?

Kernel 3.14.15, LVM2 2.02.109


> I'm just 100% sure that usage of 'remove_all' is not a generally usable
> feature - it's purely mean for developers to help then cleanup
> dm tables - it's not meant to be used by  'scripts' to cleanup user devices
> and return errors if there are some device left - it's plain miss-use.

That is not documented in the manpage. The manpage merely says:
"Use with care!"

I propose that the manpage be amended so as to prevent others from
"miss-using" this command, as your colleague Harald Hoyer apparently
did.


Kind regards,

Lukas




More information about the lvm-devel mailing list