racing libdevmapper calls
Hello,
The following command :
# dmsetup remove foo;echo "0 10 linear 8:16 63"|dmsetup create foo & echo "0 20 linear 8:16 63"|dmsetup create foo
will quite easily produce error message like :
"device-mapper ioctl cmd 3 failed: Device or resource busy"
Is it designed behaviour ?
Can't we expect libdevmapper to serialize its ioctls ?
multipath(8), being run in storms by udev, has trouble with this. Ideas ?
Regards,
cvaroqui
Quoted 6 lines · Christophe Varoqui
Hello,
The following command :
# dmsetup remove foo;echo "0 10 linear 8:16 63"|dmsetup create foo & echo "0 20 linear 8:16 63"|dmsetup create foo
Quoted 9 lines
will quite easily produce error message like :
"device-mapper ioctl cmd 3 failed: Device or resource busy"Is it designed behaviour ?
Can't we expect libdevmapper to serialize its ioctls ?multipath(8), being run in storms by udev, has trouble with this. Ideas ?
I realize this example is trivially flawed : 2nd ioctl will necessarily fail, and the message is appropriate in this case.
But in multipath(8), I tried something like :
if (map exists) /* through DM_DEVICE_INFO */
DM_DEVICE_RELOAD
else
DM_DEVICE_CREATE
Which translate like :
# dmsetup remove foo;echo "0 10 linear 8:16 63"|dmsetup create foo & dmsetup info foo || echo "0 20 linear 8:16 63"|dmsetup create foo
But I can't seem to avoid the "device-mapper ioctl cmd 3 failed: Device or resource busy" messages.
Regards,
cvaroqui
Alasdair G Kergon
maintainerNeither libdevmapper nor dmsetup does any locking.
It's easy to make the case for dmsetup to include locking - but dmsetup is only meant as a diagnostic tool so it's hardly an important feature to add.
DM_DEVICE_CREATE with a table supplied is *not* an atomic operation. It only exists to provide backwards-compatibility for the original version of the ioctls (when it *was* atomic). It's perfectly OK still to use it when convenient, but you have to remember it's actually performing *two* ioctls:
DM_DEV_CREATE
DM_TABLE_LOAD
If you need finer-level control, you may be better off calling those two separately i.e. DM_DEVICE_CREATE without a table (if the device doesn't already exist) then DM_DEVICE_RELOAD.
Alasdair
Signature · 1 line
[email protected]
Quoted 12 lines · Alasdair G Kergon
Neither libdevmapper nor dmsetup does any locking.
It's easy to make the case for dmsetup to include locking - but dmsetup is only meant as a diagnostic tool so it's hardly an important feature to add.
DM_DEVICE_CREATEwith a table supplied is *not* an atomic operation. It only exists to provide backwards-compatibility for the original version of the ioctls (when it *was* atomic). It's perfectly OK still to use it when convenient, but you have to remember it's actually performing *two* ioctls:
Quoted 7 lines
DM_DEV_CREATE
DM_TABLE_LOADIf you need finer-level control, you may be better off calling those two separately i.e.
DM_DEVICE_CREATEwithout a table (if the device doesn't already exist) thenDM_DEVICE_RELOAD.
Thanks, this information is very valuable and to the point.
Regards,
cvaroqui