Bug 836720

Summary: LVMcache currently calls lvm pvs with each pv as an argument, this can lead to inconsistent results if the first pv does not hold an active mda (LVM BZ#83663)
Product: Red Hat Enterprise Linux 6 Reporter: Lee Yarwood <lyarwood>
Component: vdsmAssignee: Eduardo Warszawski <ewarszaw>
Status: CLOSED DUPLICATE QA Contact: Haim <hateya>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.3CC: abaron, bazulay, iheim, mkalinin, sputhenp, yeylon, ykaul
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-03 15:32:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 836663    
Bug Blocks: 759131    

Description Lee Yarwood 2012-06-30 11:19:15 UTC
Description of problem:

When creating or extending a V1 or V2 storage domain the LVMcache within vdsm provides an incorrect listing of PVs within a given VG due to a bug within the pvs command (BZ#836663). This then leads to incorrect or missing PV* entries within the metadata for a storage domain. This will become an issue when we attempt to create a vdisk with it's LV spanning or residing on this PV as we are unable to find the PV within our own storage domain metadata. This results in a 'meta data mapping failed' or MetaDataMappingError - 754 error from vdsm.

Version-Release number of selected component (if applicable):
All versions of vdsm where lvm 2.02.69 or greater is also present on the system.

How reproducible:
Always

Steps to Reproduce:
1. Create or extend a SD to hold more than a single PV.
2. Review the MD present for the PVs.
3. PV data is either missing or incorrect.
  
Actual results:
LVMcache provides LvMetadataRW or VgMetadataRW with an incorrect listing of the actual PVs present within the storage domain. This leads to either incorrect or missing PV entries in the metadata of either V1 or V2 based SDs.

Expected results:
As this is a pvs bug there are a number of things we could change here :

- Ensure pvs is always called with the PV with the active mda within the VG first.
- Stop calling pvs with the individual PVs as arguments. This would result in a complete scan but would require additional logic to ensure we only look at PVs in the VG we care about.
- Switch to using vgs -o +pv_name ${vguuid}.
- Add additional checking within LVMcache to ensure that the number of PVs reported from pvs is what we are expecting.

Additional info:

The following example is for a V2 storage domain with 5 PVs :

# vgs -o +pv_name
  VG                                   #PV #LV #SN Attr   VSize   VFree   PV                                      
  480a7532-cf70-4fc3-9341-65b9f3a0fa19   5   8   0 wz--n- 123.12g 114.25g /dev/mapper/1IET_00010002               
  480a7532-cf70-4fc3-9341-65b9f3a0fa19   5   8   0 wz--n- 123.12g 114.25g /dev/mapper/1IET_0001000a               
  480a7532-cf70-4fc3-9341-65b9f3a0fa19   5   8   0 wz--n- 123.12g 114.25g /dev/mapper/1IET_00010009               
  480a7532-cf70-4fc3-9341-65b9f3a0fa19   5   8   0 wz--n- 123.12g 114.25g /dev/mapper/1IET_00010001               
  480a7532-cf70-4fc3-9341-65b9f3a0fa19   5   8   0 wz--n- 123.12g 114.25g /dev/mapper/1IET_00010004               
  HostVG                                 1   2   0 wz--n-   1.23g      0  /dev/mapper/1ATA_QEMU_HARDDISK_QM00001p4

In my case only a single PV line was added to the VG tags :

# vgs -o +tags | grep MDT | sed -e 's/\,/\n/g' | grep PV
MDT_PV0=pv:1IET_00010002&44&uuid:hXHZco-TkdH-KDpI-XZks-AuW7-6tfQ-X9j0ws&44&pestart:0&44&pecount:197&44&mapoffset:0

When calling only pvs we see :

# pvs
  PV                                       VG                                   Fmt  Attr PSize  PFree 
  /dev/mapper/1ATA_QEMU_HARDDISK_QM00001p4 HostVG                               lvm2 a--   1.23g     0 
  /dev/mapper/1IET_00010001                480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_00010002                480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 15.75g
  /dev/mapper/1IET_00010004                480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_00010009                480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_0001000a                480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g

When calling pvs with each pv as an argument in the same manor as the LVMcache and also providing the PV with the MDA last we get :

# pvs /dev/mapper/1IET_0001000{1,4,9,a,2}
  PV                        VG                                   Fmt  Attr PSize  PFree 
  /dev/mapper/1IET_00010001                                      lvm2 a--  25.00g 25.00g
  /dev/mapper/1IET_00010002 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 15.75g
  /dev/mapper/1IET_00010004                                      lvm2 a--  25.00g 25.00g
  /dev/mapper/1IET_00010009                                      lvm2 a--  25.00g 25.00g
  /dev/mapper/1IET_0001000a                                      lvm2 a--  25.00g 25.00g

Calling pvs with this PV first gives us the correct results :

# pvs /dev/mapper/1IET_0001000{2,4,9,a,1}
  PV                        VG                                   Fmt  Attr PSize  PFree 
  /dev/mapper/1IET_00010001 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_00010002 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 15.75g
  /dev/mapper/1IET_00010004 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_00010009 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g
  /dev/mapper/1IET_0001000a 480a7532-cf70-4fc3-9341-65b9f3a0fa19 lvm2 a--  24.62g 24.62g

Comment 5 Ayal Baron 2012-07-02 11:28:35 UTC
Haim,  there is something I don't understand here.
In V2 storage domains we store this info for BC purposes only, but functionally this should not affect anything.  Can you get a MetaDataMappingError using V2?

Comment 6 Lee Yarwood 2012-07-02 14:22:22 UTC
My limited testing today against V2 domains with missing MDT_PVn lines appears to confirm that they are not impacted by this. I was able to create a vdisk with it's LV spanning multiple PVs without any errors being reported.

# lvs -o seg_all 480a7532-cf70-4fc3-9341-65b9f3a0fa19/7490f674-1878-4b48-96c4-dedae978b28c
  Type   #Str Stripe Stripe Region Region Chunk Chunk Start  Start SSize  Seg Tags PE Ranges                       Devices                      
  linear    1     0      0      0      0     0     0      0      0 24.62g          /dev/mapper/1IET_0001000a:0-196 /dev/mapper/1IET_0001000a(0) 
  linear    1     0      0      0      0     0     0  24.62g   197 24.62g          /dev/mapper/1IET_00010009:0-196 /dev/mapper/1IET_00010009(0) 
  linear    1     0      0      0      0     0     0  49.25g   394 24.62g          /dev/mapper/1IET_00010001:0-196 /dev/mapper/1IET_00010001(0) 
  linear    1     0      0      0      0     0     0  73.88g   591 24.62g          /dev/mapper/1IET_00010004:0-196 /dev/mapper/1IET_00010004(0) 
  linear    1     0      0      0      0     0     0  98.50g   788  1.50g          /dev/mapper/1IET_00010002:71-82 /dev/mapper/1IET_00010002(71)

Comment 7 Eduardo Warszawski 2012-07-03 15:32:05 UTC

*** This bug has been marked as a duplicate of bug 798635 ***