Bug 1572314 - lvconvert man page regarding s|--snapshot to "reverse" a prior split is misleading
Summary: lvconvert man page regarding s|--snapshot to "reverse" a prior split is misle...
Keywords:
Status: CLOSED DUPLICATE of bug 1557401
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: LVM and device-mapper development team
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-26 16:25 UTC by Corey Marthaler
Modified: 2018-04-27 14:27 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-27 14:27:40 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Corey Marthaler 2018-04-26 16:25:59 UTC
Description of problem:
I may be reading this incorrectly, however, when I read "reverse", to me it implies that it reinstates the prior COW state before the --splitsnapshot was ever executed. 

The reality is that using 'lvconvert -s' to "combine a former COW snapshot LV with a former origin" is no different than just creating a new snapshot at that point in time, and that any COW data that existed on the split snap before a convert back to snapshot is lost. Actually, once a snap is split, what value does it have? How would one use that split off COW?

lvconvert
       --splitsnapshot
              Separates a COW snapshot from its origin LV. The LV that is split off contains the chunks that differ from the origin LV along with metadata describing them. This LV can be
              wiped and then destroyed with lvremove.

       -s|--snapshot
              Combine a former COW snapshot LV with a former origin LV to reverse a previous --splitsnapshot command.



# Existing origin volume
[root@host-087 ~]# lvs -a -o +devices
  LV     VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices       
  origin snapper       -wi-ao----   4.00g                                                     /dev/sdb1(0)  

[root@host-087 ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/snapper-origin       4.0G   39M  3.7G   2% /mnt/origin

## Write 100 files to origin
[root@host-087 ~]# /usr/tests/sts-rhel7.5/bin/checkit -w /mnt/origin -f /tmp/origin -n 100
## Verify 100 files on origin
[root@host-087 ~]# /usr/tests/sts-rhel7.5/bin/checkit -w /mnt/origin -f /tmp/origin -v

## Create snapshot
[root@host-087 ~]# lvcreate -s /dev/snapper/origin -c 128 -n splitoff -L 2G
  Logical volume "splitoff" created.

[root@host-087 ~]# lvs -a -o +devices
  LV       VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        
  origin   snapper       owi-aos---   4.00g                                                     /dev/sdb1(0)   
  splitoff snapper       swi-a-s---   2.00g      origin 0.00                                    /dev/sdb1(1024)                                                                                                                                                             
                                                                                                                                                                                                                                                                            
[root@host-087 ~]# mount /dev/snapper/splitoff /mnt/snap                                                                                                                                                                                                                    
[root@host-087 ~]# df -h                                                                                                                                                                                                                                                    
Filesystem                       Size  Used Avail Use% Mounted on                                                                                                                                                                                                           
/dev/mapper/snapper-origin       4.0G   37M  3.8G   1% /mnt/origin                                                                                                                                                                                                          
/dev/mapper/snapper-splitoff     4.0G   37M  3.8G   1% /mnt/snap                                                                                                                                                                                                            
                                                                                                                                                                                                                                                              
## Verify 100 files on snapshot                                                                                                                                                                                                                               
[root@host-087 ~]# /usr/tests/sts-rhel7.5/bin/checkit -w /mnt/snap -f /tmp/origin -v                                                                                                                                                                          
                                                                                                                                                                                                                                                              
[root@host-087 ~]# umount /mnt/snap                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                              
## --splitsnapshot                                                                                                                                                                                                                                            
[root@host-087 ~]# lvconvert --yes --splitsnapshot snapper/splitoff                                                                                                                                                                                           
  Logical Volume snapper/splitoff split from its origin.                                                                                                                                                                                                      
                                                                                                                                                                                                                                                              
## Just a simple COW volume now, nolonger mountable                                                                                                                                                                                                           
[root@host-087 ~]# mount /dev/snapper/splitoff /mnt/snap                                                                                                                                                                                                      
mount: unknown filesystem type 'DM_snapshot_cow'

root@host-087 ~]# ls -l /mnt/origin/ | wc -l
102
## Remove the 100 files from the origin volume
[root@host-087 ~]# rm -rf /mnt/origin/*
[root@host-087 ~]# ls -l /mnt/origin/ | wc -l
1
[root@host-087 ~]# umount /mnt/origin

## No longer merge-able since it was split
[root@host-087 ~]# lvconvert --merge snapper/splitoff --yes
  snapper/splitoff is not read-only - refusing to merge.

## However the "is not read-only" is just a red herring since changing it to ro doesn't matter
[root@host-087 ~]# lvs -a -o +devices
  LV       VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        
  origin   snapper       -wi-a-----   4.00g                                                     /dev/sdb1(0)   
  splitoff snapper       -wi-a-----   2.00g                                                     /dev/sdb1(1024)

[root@host-087 ~]# lvchange -pr snapper/splitoff --yes
  Logical volume snapper/splitoff changed.

## See, still can't merge back even if RO until "converted" back to snap to "reverse" split.
[root@host-087 ~]# lvconvert --merge snapper/splitoff --yes
  Unable to merge non-mirror image snapper/splitoff.

## Convert back to snap, but it appears this doesn't "reverse" anything. This only just created a new snap at this point in time, no different than if I have just used lvcreate to create a new one
[root@host-087 ~]# lvconvert --yes -s snapper/origin snapper/splitoff
  WARNING: Converting logical volume snapper/splitoff to snapshot exception store.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  WARNING: snapper/splitoff not zeroed.
  Logical volume snapper/splitoff converted to snapshot.

## Merge back, if this was real reverse, then shouldn't that restore the files like if I have never merged the snap to begin with?
[root@host-087 ~]# lvconvert --merge snapper/splitoff --yes
  Merging of volume snapper/splitoff started.
  snapper/origin: Merged: 100.00%

[root@host-087 ~]# lvs -a -o +devices
  LV     VG            Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices       
  origin snapper       -wi-a-----   4.00g                                                     /dev/sdb1(0)  

## Remount, the files are gone. Really, once a snap is split, it's basically worthless unless I'm missing something?
[root@host-087 ~]# mount /dev/snapper/origin  /mnt/origin/
[root@host-087 ~]# ls -l /mnt/origin/ | wc -l
1




Version-Release number of selected component (if applicable):
3.10.0-862.el7.x86_64

lvm2-2.02.177-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
lvm2-libs-2.02.177-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
lvm2-cluster-2.02.177-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
lvm2-lockd-2.02.177-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
lvm2-python-boom-0.8.5-4.el7    BUILT: Fri Feb 16 13:37:10 CET 2018
cmirror-2.02.177-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
device-mapper-1.02.146-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
device-mapper-libs-1.02.146-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
device-mapper-event-1.02.146-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
device-mapper-event-libs-1.02.146-4.el7    BUILT: Fri Feb 16 13:22:31 CET 2018
device-mapper-persistent-data-0.7.3-3.el7    BUILT: Tue Nov 14 12:07:18 CET 2017

Comment 2 Zdenek Kabelac 2018-04-26 20:35:12 UTC
Man looks somewhat confusing.

By default conversion 'makes' really a new snapshot.

If user wants to 'prevent' zeroing of COW LV option  -Zn has to be specified.

--

This behavior is consistent across all conversion - i.e.
converting LV to thin-pool data/metadata make it look like just lvcreated

Same with cachepool.

If the old data are supposed to be preserved - user needs to know what he is doing and has to specify  '-Zn'.


I guess some enhancement of man page making this more clear is needed.

Comment 3 Marian Csontos 2018-04-27 08:26:16 UTC
...and is a duplicate  of Bug 1557401. Corey, feel free to close one or the other, whatever is more convenient for you.

Comment 4 Corey Marthaler 2018-04-27 14:27:40 UTC

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


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