Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1509036

Summary: dm table not updated after automatic lvm segment merge
Product: Red Hat Enterprise Linux 7 Reporter: John Pittman <jpittman>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Changing Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: medium    
Priority: medium CC: agk, alex.wang, cmarthal, heinzm, jbrassow, jmagrini, loberman, mcsontos, msnitzer, nweddle, orion, prajnoha, tcleveng, zkabelac
Version: 7.4   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-20 15:09:59 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:    
Bug Blocks: 1784876    

Description John Pittman 2017-11-02 18:51:34 UTC
Description of problem:

The device-mapper table is not being updated after an automatic segment merge made possible by a pvmove.  It seems the on-disk metadata is updated, but not in the kernel.

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

device-mapper-1.02.140-8.el7.x86_64
lvm2-2.02.171-8.el7.x86_64
kernel-3.10.0-693.2.2.el7.x86_64

Steps to Reproduce:

- Create volume group and span one logical volume across two PVs so that it has 2 segments:

[root@localhost ~]# vgcreate seg_vg /dev/sdb /dev/sdc
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.
  Volume group "seg_vg" successfully created
  
[root@localhost ~]# lvcreate -n lv1 -l 200 seg_vg /dev/sdb:0-99 /dev/sdc:0-99
  Logical volume "lv1" created.

- Verify that we indeed have two segments, both in lvm and device-mapper:

[root@localhost ~]# lvs -o +devices,seg_pe_ranges
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        PE Ranges         
  root rhel   -wi-ao----  <6.20g                                                     /dev/sda2(205) /dev/sda2:205-1790
  swap rhel   -wi-ao---- 820.00m                                                     /dev/sda2(0)   /dev/sda2:0-204   
  lv1  seg_vg -wi-ao---- 800.00m                                                     /dev/sdb(0)    /dev/sdb:0-99     <==== segment 1
  lv1  seg_vg -wi-ao---- 800.00m                                                     /dev/sdc(0)    /dev/sdc:0-99     <==== segment 2
  
[root@localhost ~]# dmsetup table seg_vg-lv1
0 819200 linear 8:16 2048          <=== segment 1
819200 819200 linear 8:32 2048     <=== segment 2

- Move the segment in sdc to a position directly after the sdb segment.  This will trigger the automatic merge of these segments:

[root@localhost ~]# pvmove /dev/sdc:0-99 /dev/sdb:100-199
  /dev/sdc: Moved: 2.00%
  /dev/sdc: Moved: 100.00%
  
- Verify lvm shows one segment and unknown (X) attributes:

[root@localhost ~]# lvs -o +devices,seg_pe_ranges
  WARNING: Cannot find matching striped segment for seg_vg/lv1.
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        PE Ranges         
  root rhel   -wi-ao----  <6.20g                                                     /dev/sda2(205) /dev/sda2:205-1790
  swap rhel   -wi-ao---- 820.00m                                                     /dev/sda2(0)   /dev/sda2:0-204   
  lv1  seg_vg -wi-XX--X- 800.00m                                                     /dev/sdb(0)    /dev/sdb:0-199      <==== 1 segment

- Verify device-mapper shows 2 segments:

[root@localhost ~]# dmsetup table seg_vg-lv1
0 819200 linear 8:16 2048                    <==== 1 segment
819200 819200 linear 8:16 821248             <==== 2 segments

- Remediate by refreshing the volume group:

[root@localhost ~]# vgchange --refresh seg_vg

- Verify lvm and device-mapper are consistent:

[root@localhost ~]# lvs -o +devices,seg_pe_ranges
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        PE Ranges         
  root rhel   -wi-ao----  <6.20g                                                     /dev/sda2(205) /dev/sda2:205-1790
  swap rhel   -wi-ao---- 820.00m                                                     /dev/sda2(0)   /dev/sda2:0-204   
  lv1  seg_vg -wi-ao---- 800.00m                                                     /dev/sdb(0)    /dev/sdb:0-199    
  
[root@localhost ~]# dmsetup table seg_vg-lv1
0 1638400 linear 8:16 2048

Actual results:

kernel state is not refreshed

Expected results:

kernel state should be consistent w/ lvm with no intervention after the merge

Comment 6 Zdenek Kabelac 2020-01-17 14:13:53 UTC
This was already fixed in  2.02.177  (upstream commit c489dd2e1764216de07be80d36b1025fb4f6fc85)

Comment 9 Corey Marthaler 2020-04-15 17:00:22 UTC
# This appears to work effortlessly in the current rhel7.9 rpms, no need for the vgchange --refresh. Adding ack, but feel free to just close WORKSFORME.

[root@mckinley-01 ~]# vgcreate seg_vg /dev/mapper/mpatha2 /dev/mapper/mpathb2
  Volume group "seg_vg" successfully created
[root@mckinley-01 ~]# lvcreate -n lv1 -l 200 seg_vg /dev/mapper/mpatha2:0-99 /dev/mapper/mpathb2:0-99
  Logical volume "lv1" created.

[root@mckinley-01 ~]# lvs -o +devices,seg_pe_ranges
  LV   VG               Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                PE Ranges               
  lv1  seg_vg           -wi-a-----  800.00m                                                     /dev/mapper/mpatha2(0) /dev/mapper/mpatha2:0-99
  lv1  seg_vg           -wi-a-----  800.00m                                                     /dev/mapper/mpathb2(0) /dev/mapper/mpathb2:0-99
[root@mckinley-01 ~]#  dmsetup table seg_vg-lv1
0 819200 linear 253:4 65543
819200 819200 linear 253:8 65543
[root@mckinley-01 ~]# pvmove /dev/mapper/mpathb2:0-99 /dev/mapper/mpatha2:100-199
  /dev/mapper/mpathb2: Moved: 0.00%
  /dev/mapper/mpathb2: Moved: 100.00%

# This appears to work effortlessly in the current rhel7.9 rpms, no need for the vgchange --refresh
[root@mckinley-01 ~]# lvs -o +devices,seg_pe_ranges
  LV   VG               Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                PE Ranges                
  lv1  seg_vg           -wi-a-----  800.00m                                                     /dev/mapper/mpatha2(0) /dev/mapper/mpatha2:0-199
[root@mckinley-01 ~]#  dmsetup table seg_vg-lv1
0 1638400 linear 253:4 65543

[root@mckinley-01 ~]# vgchange --refresh seg_vg
[root@mckinley-01 ~]# lvs -o +devices,seg_pe_ranges
  LV   VG               Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                PE Ranges                
  lv1  seg_vg           -wi-a-----  800.00m                                                     /dev/mapper/mpatha2(0) /dev/mapper/mpatha2:0-199