Bug 645488

Summary: Merged snapshot still present and throwing I/O errors after reboot
Product: Red Hat Enterprise Linux 6 Reporter: John Ruemker <jruemker>
Component: lvm2Assignee: Mike Snitzer <msnitzer>
Status: CLOSED ERRATA QA Contact: Corey Marthaler <cmarthal>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: agk, antillon.maurizio, cww, dwysocha, harald, heinzm, jbrassow, jeder, joe.thornber, mbroz, msnitzer, prajnoha, prockai
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.82-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 650959 (view as bug list) Environment:
Last Closed: 2011-05-19 14:26:57 UTC Type: ---
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: 651007    
Attachments:
Description Flags
lvmdump taken after merge and reboot
none
sosreport taken after merge and reboot
none
boot sequence captured from serial console after merge and reboot
none
verbose output of lvremove of snap volume
none
patch to fix merged snapshot cleanup, etc. none

Description John Ruemker 2010-10-21 16:06:20 UTC
Created attachment 454876 [details]
lvmdump taken after merge and reboot

Description of problem: 
After merging a snapshot of the root lv, upon reboot I/O errors are seen against the dm device for the snapshot (console-boot.log).  After this first reboot, the snapshot volume was still present and it appeared as if the merge was still in progress:

   # lvs -a
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316166656: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316224000: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 0: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 4096: Input/output error
     LV             VG          Attr   LSize   Origin  Snap%  Move Log Copy%  Convert
     lv_root        vg_dhcp5318 Owi-ao  10.54g           0.00                        
     [lv_root-snap] vg_dhcp5318 Swi-a-   1.17g lv_root 100.00                        
     lv_swap        vg_dhcp5318 -wi-ao 992.00m        


At first, the Snap% for lv_root was counting down to 0, but when it reached 0 nothing changed.  The snapshot was still present, and could not be removed:

   # lvremove vg_dhcp5318/lv_root-snap
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316166656: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316224000: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 0: Input/output error
     /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 4096: Input/output error
     Can't remove merging snapshot logical volume "lv_root-snap"

(-vvvv logs for lvremove attached as lvremove-vvvv.out).   I've now rebooted multiple times and the situation has not changed.

Version-Release number of selected component (if applicable): lvm2-2.02.72-8.el6.x86_64

How reproducible: Always (for me and my customer)

Steps to Reproduce:
Customer and I have both reproduced this problem in a KVM guest.  After installation, we add a 2nd device to the volume group and use it to create a snapshot of the root lv.  

  # pvcreate /dev/vdb
  # vgextend vg_dhcp5318 /dev/vdb
  # lvcreate -l 300 -s vg_dhcp5318/lv_root -n lv_root-snap
  
I make some changes to the system with yum, then merge the snapshot:

  # lvconvert --merge vg_dhcp5318/lv_root-snap
  Can't merge over open origin volume
  Merging of snapshot lv_root-snap will start next activation. 

Now reboot.
  
Actual results: I/O errors, and a snapshot that cannot be removed.


Expected results: No I/O errors, and the snapshot is automatically removed.


Additional info: Attaching sosreport and lvmdump.

Comment 1 John Ruemker 2010-10-21 16:07:13 UTC
Created attachment 454877 [details]
sosreport taken after merge and reboot

Comment 2 John Ruemker 2010-10-21 16:07:52 UTC
Created attachment 454878 [details]
boot sequence captured from serial console after merge and reboot

Comment 3 John Ruemker 2010-10-21 16:08:44 UTC
Created attachment 454879 [details]
verbose output of lvremove of snap volume

Comment 5 Mike Snitzer 2010-10-21 20:34:23 UTC
Looks like the lvm2 polldaemon code that tracks the snapshot% is not seeing the merge as complete even though 'dmsetup status' shows it is:

vg_dhcp5318-lv_root: 0 22102016 snapshot-merge 16/2457600 16

From Documentation/device-mapper/snapshot.txt

How to determine when a merging is complete
===========================================
The snapshot-merge and snapshot status lines end with:
  <sectors_allocated>/<total_sectors> <metadata_sectors>

Both <sectors_allocated> and <total_sectors> include both data and metadata.
During merging, the number of sectors allocated gets smaller and
smaller.  Merging has finished when the number of sectors holding data
is zero, in other words <sectors_allocated> == <metadata_sectors>.

I'll need to get back on the lvm2 snapshot-merge code bike to track down what regressed.. but I should be able to sort this out fairly quickly.


As for the IO errors, the reason you're seeing those is the various lvm commands will still try to access the old snapshot device even though it has been switched to use the "error" target (purposely done as part of the lvm's snapshot merge transaction):

# dmsetup status vg_dhcp5318-lv_root--snap
0 22102016 error 

So you'll get errors for any IO to that DM device:

# lvs
  /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316166656: Input/output error
  /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 11316224000: Input/output error
  /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 0: Input/output error
  /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at 4096: Input/output error
  LV      VG          Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_root vg_dhcp5318 Owi-ao  10.54g          0.00                        
  lv_swap vg_dhcp5318 -wi-ao 992.00m

Comment 6 Mike Snitzer 2010-10-21 20:37:49 UTC
(In reply to comment #5)
> Looks like the lvm2 polldaemon code that tracks the snapshot% is not seeing the
> merge as complete even though 'dmsetup status' shows it is:
> 
> vg_dhcp5318-lv_root: 0 22102016 snapshot-merge 16/2457600 16
...
> I'll need to get back on the lvm2 snapshot-merge code bike to track down what
> regressed.. but I should be able to sort this out fairly quickly.

This is definitely an lvm2 polldaemon issue.  I was able to clean things up with:

 lvchange --refresh vg_dhcp5318/lv_root

before:

# dmsetup status
vg_dhcp5318-lv_root--snap: 0 22102016 error
vg_dhcp5318-lv_root-real: 0 22102016 linear
vg_dhcp5318-lv_root--snap-cow: 0 2457600 linear
vg_dhcp5318-lv_swap: 0 2031616 linear
vg_dhcp5318-lv_root: 0 22102016 snapshot-merge 16/2457600 16

after:

# dmsetup status
vg_dhcp5318-lv_swap: 0 2031616 linear 
vg_dhcp5318-lv_root: 0 22102016 linear 

# lvs
  LV      VG          Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv_root vg_dhcp5318 -wi-ao  10.54g                                      
  lv_swap vg_dhcp5318 -wi-ao 992.00m

Comment 7 Alasdair Kergon 2010-10-22 12:09:20 UTC
(In reply to comment #5)

> So you'll get errors for any IO to that DM device:

> # lvs
>   /dev/mapper/vg_dhcp5318-lv_root--snap: read failed after 0 of 4096 at
> 11316166656: Input/output error

This should not be happening.  If current upstream does it, it needs to be fixed.

Comment 8 Mike Snitzer 2010-10-25 20:16:47 UTC
vgchange doesn't allow multiple actions to be taken (won't start both monitoring and polling):

# lvs -a
  LV      VG        Attr   LSize   Origin  Snap%  Move Log Copy%  Convert
  lv_root vg_f12lvm Owi-ao   7.30g           0.00                        
  [snap]  vg_f12lvm Swi-a- 200.00m lv_root 100.00                        
# /sbin/vgchange --monitor y --poll y vg_f12lvm 
  2 logical volume(s) in volume group "vg_f12lvm" monitored

# /sbin/vgchange --poll y vg_f12lvm 
  Background polling started for 1 logical volume(s) in volume group "vg_f12lvm"
# lvs
  LV      VG        Attr   LSize Origin Snap%  Move Log Copy%  Convert
  lv_root vg_f12lvm -wi-ao 7.30g


The way the code is written these options are mutually exclusive:

static int vgchange_single(...)
{
...
        else if (arg_count(cmd, monitor_ARG))
                r = _vgchange_monitoring(cmd, vg);

        else if (arg_count(cmd, poll_ARG))
                r = _vgchange_background_polling(cmd, vg);
...
}

Comment 9 Mike Snitzer 2010-10-26 02:24:16 UTC
Created attachment 455664 [details]
patch to fix merged snapshot cleanup, etc.

Patch that provides a backport of the relevant upstream fixes to RHEL6's lvm2.

Comment 22 Corey Marthaler 2011-04-04 20:56:36 UTC
Based on comments #13 and #15, the customer has verified that this issue is fixed in the latest rpms.

The 'reboot before merge' regression check added for this issue also passed (though it may not be the exact same case described in this bug). Marking verified.


2.6.32-128.el6.x86_64

lvm2-2.02.83-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
lvm2-libs-2.02.83-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
lvm2-cluster-2.02.83-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
udev-147-2.35.el6    BUILT: Wed Mar 30 07:32:05 CDT 2011
device-mapper-1.02.62-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
device-mapper-libs-1.02.62-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
device-mapper-event-1.02.62-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
device-mapper-event-libs-1.02.62-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011
cmirror-2.02.83-3.el6    BUILT: Fri Mar 18 09:31:10 CDT 2011



SCENARIO - [reboot_before_merge_starts]
Merge an inactive snapshot, then "reboot" the machine before the merge can take place
Making origin volume
Placing an ext filesystem on origin volume
mke2fs 1.41.12 (17-May-2010)
Mounting origin volume

Making snapshot of origin volume
Mounting snap volume

Attempt to merge snapshot snapper/merge_reboot
  Can't merge over open origin volume

  /var/lock/lvm/V_snapper: unlink failed: No such file or directory
Removing origin snapper/origin

Comment 23 errata-xmlrpc 2011-05-19 14:26:57 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0772.html