mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-19 14:04:17 +03:00
dev-cache: also index VGIDs and LVIDs if using persistent .cache file
If we're using persistent .cache file, we're reading this file instead of traversing the /dev content. Fix missing indexing by VGID and LVID here - hook this into persistent_filter_load where we populate device cache from persistent .cache file instead of scanning /dev. For example, inducing situation in which we warn about different device actually used than what LVM thinks should be used based on metadata: $ lsblk -s /dev/vg/lvol0 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vg-lvol0 253:4 0 124M 0 lvm `-loop1 7:1 0 128M 0 loop $ lvmconfig --type diff global { use_lvmetad=0 } devices { obtain_device_list_from_udev=0 } (obtain_device_list_from_udev=0 also means the persistent .cache file is used) Before this patch - pvs is fine as it does the dev scan, but lvs relies on persistent .cache file and it misses the VGID/LVID indices to check and warn about incorrect devices used: $ pvs Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1 Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1 WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0. PV VG Fmt Attr PSize PFree /dev/loop0 vg lvm2 a-- 124.00m 0 $ lvs Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1 Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1 LV VG Attr LSize lvol0 vg -wi-a----- 124.00m With this patch applied - both pvs and lvs is fine - the indices are always created correctly (lvs just an example here, other LVM commands that rely on persistent .cache file are fixed with this patch too): $ pvs Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1 Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1 WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0. PV VG Fmt Attr PSize PFree /dev/loop0 vg lvm2 a-- 124.00m 0 $ lvs Found duplicate PV B9gXTHkIdEIiMVwcOoT2LX3Ywh4YIHgR: using /dev/loop0 not /dev/loop1 Using duplicate PV /dev/loop0 without holders, ignoring /dev/loop1 WARNING: Device mismatch detected for vg/lvol0 which is accessing /dev/loop1 instead of /dev/loop0. LV VG Attr LSize lvol0 vg -wi-a----- 124.00m
This commit is contained in:
parent
91bb202ded
commit
8c27c52749
@ -1,5 +1,6 @@
|
||||
Version 2.02.149 -
|
||||
==================================
|
||||
Fix device mismatch detection for LV if persistent .cache file is used.
|
||||
Fix holder device not being found in /dev while sysfs has it during dev scan.
|
||||
|
||||
Version 2.02.148 - 26th March 2016
|
||||
|
@ -527,6 +527,10 @@ static int _index_dev_by_vgid_and_lvid(struct device *dev)
|
||||
struct device_list *dl_vgid, *dl_lvid;
|
||||
int r = 0;
|
||||
|
||||
if (dev->vgid)
|
||||
/* already indexed */
|
||||
return 1;
|
||||
|
||||
/* Get holders for device. */
|
||||
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/holders/", dm_sysfs_dir(), (int) MAJOR(dev->dev), (int) MINOR(dev->dev)) < 0) {
|
||||
log_error("%s: dm_snprintf failed for path to holders directory.", devname);
|
||||
@ -848,7 +852,7 @@ bad:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _add_devs_to_index(void)
|
||||
int dev_cache_index_devs(void)
|
||||
{
|
||||
struct btree_iter *iter = btree_first(_cache.devices);
|
||||
struct device *dev;
|
||||
@ -887,7 +891,7 @@ static void _insert_dirs(struct dm_list *dirs)
|
||||
"device cache fully", dl->dir);
|
||||
}
|
||||
|
||||
(void) _add_devs_to_index();
|
||||
(void) dev_cache_index_devs();
|
||||
}
|
||||
|
||||
#else /* UDEV_SYNC_SUPPORT */
|
||||
|
@ -31,6 +31,7 @@ struct dev_filter {
|
||||
unsigned use_count;
|
||||
};
|
||||
|
||||
int dev_cache_index_devs(void);
|
||||
struct dm_list *dev_cache_get_dev_list_for_vgid(const char *vgid);
|
||||
struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid);
|
||||
|
||||
|
@ -129,6 +129,8 @@ int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out
|
||||
if (dm_hash_get_num_entries(pf->devices)) {
|
||||
/* We populated dev_cache ourselves */
|
||||
dev_cache_scan(0);
|
||||
if (!dev_cache_index_devs())
|
||||
stack;
|
||||
r = 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user