[linux-lvm] lvm_t handles and thread-safety
zdenek.kabelac at gmail.com
Mon Aug 1 11:05:38 UTC 2011
Dne 1.8.2011 10:12, Alexander Lyakas napsal(a):
> Hello everybody,
> I am using stock ubuntu natty with lvmlib 2.02.66.
> In my application I would like to have several threads, each operating
> on a different VG.
> When I tried to share the same lvm_t handle between the threads, very
> soon I got segmentation faults in dm_hash operations. Looking at the
> code, I indeed saw that the contents of lvm_t are used without
lvm library is not thread safe and it's quite far from being thread safe.
So there is no point on having 2 handles on 2 VGs - it will not work.
> Are there any plans or intentions to provide some support for
> threading with lvmlib?
With current version of lvm2 code there is no way.
Just use the pthread mutex around the lvm command. It's serialized in kernel
anyway. So you cannot gain any speed by using threads. (Check the clvmd code.)
More information about the linux-lvm