Bug 1274494 - LVM shell: PVs missing after vgremove, PVs displayed after pvremove
LVM shell: PVs missing after vgremove, PVs displayed after pvremove
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: lvm2 (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Peter Rajnoha
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-22 15:56 EDT by Tony Asleson
Modified: 2015-10-30 12:02 EDT (History)
12 users (show)

See Also:
Fixed In Version: lvm2-2.02.133-1.fc24
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-30 12:02:16 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tony Asleson 2015-10-22 15:56:05 EDT
Description of problem:

When removing a VG using the lvm shell the associated PVs go missing.

Version-Release number of selected component (if applicable):

LVM version:     2.02.132(2) (2015-09-22)
Library version: 1.02.109 (2015-09-22)
Driver version:  4.33.0

How reproducible:

Every time

Steps to Reproduce:

[root@localhost test]# lvm
lvm> pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sdb        lvm2 ---  18.00g 18.00g
  /dev/sdc        lvm2 ---  18.00g 18.00g
  /dev/sdd        lvm2 ---  18.00g 18.00g
  /dev/sde        lvm2 ---  18.00g 18.00g
lvm> vgcreate fubar /dev/sdd /dev/sde
  Volume group "fubar" successfully created
lvm> vgremove fubar
  Volume group "fubar" successfully removed
lvm> pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sdb        lvm2 ---  18.00g 18.00g
  /dev/sdc        lvm2 ---  18.00g 18.00g
lvm> exit
  Exiting.
[root@localhost test]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sdb        lvm2 ---  18.00g 18.00g
  /dev/sdc        lvm2 ---  18.00g 18.00g
  /dev/sdd        lvm2 ---  18.00g 18.00g
  /dev/sde        lvm2 ---  18.00g 18.00g
[root@localhost test]# 

Actual results:

PVs are missing after the VG is removed

Expected results:

All the PVs are still available in the lvm shell

Additional info:
Comment 1 Peter Rajnoha 2015-10-23 04:01:46 EDT
Seems like an issue when lvmetad is used - this is not reproducible if lvmetad is disabled.
Comment 2 Peter Rajnoha 2015-10-23 04:37:31 EDT
The pvremove has different issue - the PV is displayed still even though PV has been removed already:

lvm> pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda          lvm2 ---  128.00m 128.00m
  /dev/vda2  fedora lvm2 a--   19.49g      0 
lvm> pvremove /dev/sda
  Labels on physical volume "/dev/sda" successfully wiped
lvm> pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda          lvm2 ---  128.00m 128.00m
  /dev/vda2  fedora lvm2 a--   19.49g      0
Comment 3 Peter Rajnoha 2015-10-23 09:21:46 EDT
Both bugs are used by leaving lvmcache in improper state.

 - the original report with the vgremove and then not seeing the PVs anymore is caused by this line in the code:


int lvmcache_update_vgname_and_id(struct lvmcache_info *info, struct lvmcache_vgsummary *vgsummary)
{
...
        /* When using lvmetad, the PV could not have become orphaned. */
        if (lvmetad_active() && is_orphan_vg(vgname) && info->vginfo)
                return 1;
...
}

I'm not quite sure why this condition is there (it's there since 2012 - so we could say it's there from the very beginning of lvmetad). For now, this doesn't make sense to me - if we're removing the VG, we surely need to update the lvmcache to move it from VG to orphan. This was not spotted because we don't test lvm shell much and with individual commands, we're not reusing lvmcache much - definitely not much after vgremove which is not a step in any complex internal LVM command sequence.

The scenario reported here worked correctly with the condition removed. I'll wait for the testsuite to complete to be sure though...


===

As for the other bug I noticed (comment #2), this is again lvmcache handling issue:

int pvremove_single(struct cmd_context *cmd, const char *pv_name ...
{
...
info = lvmcache_info_from_pvid(dev->pvid, 1);
...
... label_remove(dev))
...
if (info)
   lvmcache_del(info);
...
}


The problematic part is the lvmcache_info_from_pvid(dev->pvid, 1) where parameter where we used "1" is "return only valid infos". Since we're reusing lvmcache in the shell and when removing a PV, we definitely need to remove it from the lvmcache at the same time, no matter how it's marked in the lvmcache - we can't leave it behind as that may confuse the code that is run next - so the fix here is to switch the "1" to "0" to also include lvmcache entry that is not marked as valid.

Note You need to log in before you can comment on or make changes to this bug.