From 8b965bd3d5df808aef2012494602cc0cf73d7398 Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 23 Oct 2015 14:11:16 +0200 Subject: [PATCH] pvremove: make sure even invalid info is removed from lvmcache on pvremove The lvmcache info might be resued, most notably in lvm shell. We need to be sure that even lvmcache_info marked as invalid is removed from the lvmcache so it does not confuse any subsequent code/commands executed later on. Problematic example with the lvm shell: lvm> pvs PV VG Fmt Attr PSize PFree /dev/sda lvm2 --- 128.00m 128.00m Before this patch (/dev/sda still displayed in a way): ====================================================== lvm> pvremove /dev/sda Labels on physical volume "/dev/sda" successfully wiped (without lvmetad) lvm> pvs No physical volume label read from /dev/sda (with lvmetad) lvm> pvs PV VG Fmt Attr PSize PFree /dev/sda lvm2 --- 128.00m 128.00m With this patch applied: ======================== lvm> pvremove /dev/sda Labels on physical volume "/dev/sda" successfully wiped (without lvmetad) lvm> pvs (with lvmetad) lvm> pvs --- WHATS_NEW | 1 + lib/metadata/pv_manip.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 8ffbecaf2..6462e1878 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.133 - ====================================== + Fix lvmcache to not cache even invalid info about PV which got removed. Support checking of memlock daemon counter. Allow all log levels to be used with the lvmetad -l option. Add optional shutdown when idle support for lvmetad. diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c index ce7f66140..e48fe42a1 100644 --- a/lib/metadata/pv_manip.c +++ b/lib/metadata/pv_manip.c @@ -781,7 +781,7 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name, goto out; } - info = lvmcache_info_from_pvid(dev->pvid, 1); + info = lvmcache_info_from_pvid(dev->pvid, 0); if (!dev_test_excl(dev)) { /* FIXME Detect whether device-mapper is still using the device */