summaryrefslogtreecommitdiffstats
path: root/lib/label
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2011-05-28 09:48:14 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2011-05-28 09:48:14 +0000
commitc08c564e216834ddce5e6c97ee365bf763fb0781 (patch)
treecdc50c811a3756e905c96529c91a650a5ffced11 /lib/label
parent10c7d802a04b4f92b933a8fb287127370c424e72 (diff)
downloadlvm2-c08c564e216834ddce5e6c97ee365bf763fb0781.tar.gz
lvm2-c08c564e216834ddce5e6c97ee365bf763fb0781.tar.xz
lvm2-c08c564e216834ddce5e6c97ee365bf763fb0781.zip
Use new dev_open_readonly fn to prevent opening devices for read-write when not necessary.
Before, we used vg_write_lock_held call to determnine the way a device is opened. Unfortunately, this opened many devices in RW mode when it was not really necessary. With the OPTIONS+="watch" rule used in the udev rules, this could fire numerous events while closing such devices (and it caused useless scans from within udev rules in return). A common bug we hit with this was with the lvremove command which was unable to remove the LV since it was being opened from within the udev rules. This patch should minimize such situations (at least with respect to LVM handling of devices). Though there's still a possibility someone will open a device 'outside' in parallel and fire the event based on the watch rule when closing a device once opened for RW.
Diffstat (limited to 'lib/label')
-rw-r--r--lib/label/label.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/label/label.c b/lib/label/label.c
index c622812f..f1efecfe 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -272,7 +272,7 @@ int label_read(struct device *dev, struct label **result,
return 1;
}
- if (!dev_open(dev)) {
+ if (!dev_open_readonly(dev)) {
stack;
if ((info = info_from_pvid(dev->pvid, 0)))
@@ -352,7 +352,7 @@ int label_verify(struct device *dev)
struct lvmcache_info *info;
int r = 0;
- if (!dev_open(dev)) {
+ if (!dev_open_readonly(dev)) {
if ((info = info_from_pvid(dev->pvid, 0)))
lvmcache_update_vgname_and_id(info, info->fmt->orphan_vg_name,
info->fmt->orphan_vg_name,