Bug 645488 - Merged snapshot still present and throwing I/O errors after reboot
Merged snapshot still present and throwing I/O errors after reboot
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2 (Show other bugs)
6.0
x86_64 Linux
high Severity high
: rc
: ---
Assigned To: Mike Snitzer
Corey Marthaler
: ZStream
Depends On:
Blocks: 651007
  Show dependency treegraph
 
Reported: 2010-10-21 12:06 EDT by John Ruemker
Modified: 2011-05-19 10:26 EDT (History)
13 users (show)

See Also:
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 10:26:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
lvmdump taken after merge and reboot (21.98 KB, application/x-gzip)
2010-10-21 12:06 EDT, John Ruemker
no flags Details
sosreport taken after merge and reboot (236.95 KB, application/x-xz)
2010-10-21 12:07 EDT, John Ruemker
no flags Details
boot sequence captured from serial console after merge and reboot (17.18 KB, text/plain)
2010-10-21 12:07 EDT, John Ruemker
no flags Details
verbose output of lvremove of snap volume (19.21 KB, application/octet-stream)
2010-10-21 12:08 EDT, John Ruemker
no flags Details
patch to fix merged snapshot cleanup, etc. (6.88 KB, patch)
2010-10-25 22:24 EDT, Mike Snitzer
no flags Details | Diff

  None (edit)
Description John Ruemker 2010-10-21 12:06:20 EDT
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 12:07:13 EDT
Created attachment 454877 [details]
sosreport taken after merge and reboot
Comment 2 John Ruemker 2010-10-21 12:07:52 EDT
Created attachment 454878 [details]
boot sequence captured from serial console after merge and reboot
Comment 3 John Ruemker 2010-10-21 12:08:44 EDT
Created attachment 454879 [details]
verbose output of lvremove of snap volume
Comment 5 Mike Snitzer 2010-10-21 16:34:23 EDT
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 16:37:49 EDT
(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 08:09:20 EDT
(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 16:16:47 EDT
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-25 22:24:16 EDT
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 16:56:36 EDT
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 10:26:57 EDT
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

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