Bug 979631

Summary: request for clarification: removal of ext origin while snaps refer to it
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Default / Unclassified QA Contact: cluster-qe <cluster-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: medium CC: agk, heinzm, jbrassow, msnitzer, prajnoha, prockai, thornber, zkabelac
Version: 7.0Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-06-29 22:08:35 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:

Description Corey Marthaler 2013-06-28 22:53:48 UTC
Description of problem:
One of the thin pool test test cases is:

- [STS TODO]no drop of external origin keeping thin snap of it

Which Heinz said means: "It shouldn't be possible to remove an external origin _whilst_ one or more snapshots refer to it."

However it appears the is possible to do just that. Is this expected behavior?


# REMOVE THE CONVERTED EXT ORIGIN VOLUME
SCENARIO - [remove_origin_under_snap]
Create a snapshot and then attempt to remove it's origin
Making origin volume
lvcreate --thinpool POOL -L 1G snapper_thinp
Sanity checking pool device metadata
(thin_check /dev/mapper/snapper_thinp-POOL_tmeta)
Create LV to be used as an EXTERNAL origin device
lvcreate -L 1G -n origin snapper_thinp
Converting LV into an external thin origin device
lvconvert --thinpool snapper_thinp/POOL --originname extorigin -T origin
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other1
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other2
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other3
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other4
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other5
Making snapshot of origin volume
lvcreate -s /dev/snapper_thinp/origin -n remove_origin_under_snap
Attempt to remove origin volume

[root@qalvm-01 ~]# lvs -a -o +devices
  LV                       Attr      LSize  Pool Origin    Data%  Devices
  POOL                     twi-a-tz-  1.00g                  0.00 POOL_tdata(0)
  [POOL_tdata]             Twi-ao---  1.00g                       /dev/vdh1(0)
  [POOL_tmeta]             ewi-ao---  4.00m                       /dev/vdd1(0)
  extorigin                ori------  1.00g                       /dev/vdg1(0)
  origin                   Vwi-a-tz-  1.00g POOL extorigin   0.00
  other1                   Vwi-a-tz-  1.00g POOL             0.00
  other2                   Vwi-a-tz-  1.00g POOL             0.00
  other3                   Vwi-a-tz-  1.00g POOL             0.00
  other4                   Vwi-a-tz-  1.00g POOL             0.00
  other5                   Vwi-a-tz-  1.00g POOL             0.00
  remove_origin_under_snap Vwi-a-tz-  1.00g POOL origin      0.00

# ATTEMPT TO REMOVE THE "CONVERTED" EXT ORIGIN:
[root@qalvm-01 ~]# lvremove snapper_thinp/extorigin
Removing external origin "extorigin" will remove 2 dependent volume(s). Proceed? [y/n]: y
Do you really want to remove active logical volume origin? [y/n]: y
  Logical volume "origin" successfully removed
Do you really want to remove active logical volume remove_origin_under_snap? [y/n]: y
  Logical volume "remove_origin_under_snap" successfully removed
  Logical volume "extorigin" successfully removed

[root@qalvm-01 ~]# lvs -a -o +devices
  LV           Attr      LSize  Pool Origin Data%  Devices
  POOL         twi-a-tz-  1.00g               0.00 POOL_tdata(0)
  [POOL_tdata] Twi-ao---  1.00g                    /dev/vdh1(0)
  [POOL_tmeta] ewi-ao---  4.00m                    /dev/vdd1(0)
  other1       Vwi-a-tz-  1.00g POOL          0.00
  other2       Vwi-a-tz-  1.00g POOL          0.00
  other3       Vwi-a-tz-  1.00g POOL          0.00
  other4       Vwi-a-tz-  1.00g POOL          0.00
  other5       Vwi-a-tz-  1.00g POOL          0.00



# REMOVE THE PHYSICAL EXT ORIGIN VOLUME
SCENARIO - [remove_origin_under_snap]
Create a snapshot and then attempt to remove it's origin
Making origin volume
lvcreate --thinpool POOL -L 1G snapper_thinp
  device-mapper: remove ioctl on  failed: Device or resource busy
Sanity checking pool device metadata
(thin_check /dev/mapper/snapper_thinp-POOL_tmeta)
Create LV to be used as an EXTERNAL origin device
lvcreate -L 1G -n origin snapper_thinp
Converting LV into an external thin origin device
lvconvert --thinpool snapper_thinp/POOL --originname extorigin -T origin
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other1
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other2
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other3
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other4
lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other5
Making snapshot of origin volume
lvcreate -s /dev/snapper_thinp/origin -n remove_origin_under_snap
Attempt to remove origin volume

[root@qalvm-01 ~]# lvs -a -o +devices
  LV                       Attr      LSize  Pool Origin    Data%  Devices
  POOL                     twi-a-tz-  1.00g                  0.00 POOL_tdata(0)
  [POOL_tdata]             Twi-ao---  1.00g                       /dev/vdh1(0)
  [POOL_tmeta]             ewi-ao---  4.00m                       /dev/vdd1(0)
  extorigin                ori------  1.00g                       /dev/vdg1(0)
  origin                   Vwi-a-tz-  1.00g POOL extorigin   0.00
  other1                   Vwi-a-tz-  1.00g POOL             0.00
  other2                   Vwi-a-tz-  1.00g POOL             0.00
  other3                   Vwi-a-tz-  1.00g POOL             0.00
  other4                   Vwi-a-tz-  1.00g POOL             0.00
  other5                   Vwi-a-tz-  1.00g POOL             0.00
  remove_origin_under_snap Vwi-a-tz-  1.00g POOL origin      0.00

# ATTEMPT TO REMOVE THE "PHYSICAL" EXT ORIGIN:
[root@qalvm-01 ~]# lvremove snapper_thinp/origin
Do you really want to remove active logical volume origin? [y/n]: y
  Logical volume "origin" successfully removed
[root@qalvm-01 ~]# lvs -a -o +devices
  LV                       Attr      LSize  Pool Origin    Data%  Devices
  POOL                     twi-a-tz-  1.00g                  0.00 POOL_tdata(0)
  [POOL_tdata]             Twi-ao---  1.00g                       /dev/vdh1(0)
  [POOL_tmeta]             ewi-ao---  4.00m                       /dev/vdd1(0)
  extorigin                ori------  1.00g                       /dev/vdg1(0)
  other1                   Vwi-a-tz-  1.00g POOL             0.00
  other2                   Vwi-a-tz-  1.00g POOL             0.00
  other3                   Vwi-a-tz-  1.00g POOL             0.00
  other4                   Vwi-a-tz-  1.00g POOL             0.00
  other5                   Vwi-a-tz-  1.00g POOL             0.00
  remove_origin_under_snap Vwi-a-tz-  1.00g POOL extorigin   0.00


Version-Release number of selected component (if applicable):
3.8.0-0.40.el7.x86_64
lvm2-2.02.99-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
lvm2-libs-2.02.99-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
lvm2-cluster-2.02.99-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
device-mapper-1.02.78-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
device-mapper-libs-1.02.78-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
device-mapper-event-1.02.78-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
device-mapper-event-libs-1.02.78-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013
cmirror-2.02.99-0.57.el7    BUILT: Mon Jun 17 08:28:21 CDT 2013

Comment 1 Zdenek Kabelac 2013-06-29 22:08:35 UTC
(In reply to Corey Marthaler from comment #0)
> Description of problem:
> One of the thin pool test test cases is:
> 
> - [STS TODO]no drop of external origin keeping thin snap of it
> 
> Which Heinz said means: "It shouldn't be possible to remove an external
> origin _whilst_ one or more snapshots refer to it."


yes 'external origin' must be kept intact in all cases 
(only 'read-only' activation is allowed)
But there is possibly some minor misunderstanding which LV is 'external origin'.
It's the LV providing data for unprovisioned areas.

> 
> However it appears the is possible to do just that. Is this expected
> behavior?
> 
> # REMOVE THE CONVERTED EXT ORIGIN VOLUME
> SCENARIO - [remove_origin_under_snap]
> Create a snapshot and then attempt to remove it's origin
> Making origin volume
> lvcreate --thinpool POOL -L 1G snapper_thinp
> Sanity checking pool device metadata
> (thin_check /dev/mapper/snapper_thinp-POOL_tmeta)
> Create LV to be used as an EXTERNAL origin device
> lvcreate -L 1G -n origin snapper_thinp
> Converting LV into an external thin origin device
> lvconvert --thinpool snapper_thinp/POOL --originname extorigin -T origin

Converts 'origin' volume into  'extorigin'
and  'origin' itself will become as a regular writable thin volume.

> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other1
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other2
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other3
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other4
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other5
> Making snapshot of origin volume
> lvcreate -s /dev/snapper_thinp/origin -n remove_origin_under_snap
> Attempt to remove origin volume
> 
> [root@qalvm-01 ~]# lvs -a -o +devices
>   LV                       Attr      LSize  Pool Origin    Data%  Devices
>   POOL                     twi-a-tz-  1.00g                  0.00
> POOL_tdata(0)
>   [POOL_tdata]             Twi-ao---  1.00g                     /dev/vdh1(0)
>   [POOL_tmeta]             ewi-ao---  4.00m                     /dev/vdd1(0)
>   extorigin                ori------  1.00g                     /dev/vdg1(0)
  ^^^^^^^^^^^^
This volume is external origin (in lvm2's terminology)

>   origin                   Vwi-a-tz-  1.00g POOL extorigin   0.00
   ^^^^^^^^^
Thin volume which is using external origin 'extorigin'

>   other1                   Vwi-a-tz-  1.00g POOL             0.00
>   other2                   Vwi-a-tz-  1.00g POOL             0.00
>   other3                   Vwi-a-tz-  1.00g POOL             0.00
>   other4                   Vwi-a-tz-  1.00g POOL             0.00
>   other5                   Vwi-a-tz-  1.00g POOL             0.00
>   remove_origin_under_snap Vwi-a-tz-  1.00g POOL origin      0.00
> 
> # ATTEMPT TO REMOVE THE "CONVERTED" EXT ORIGIN:
> [root@qalvm-01 ~]# lvremove snapper_thinp/extorigin
> Removing external origin "extorigin" will remove 2 dependent volume(s).
> Proceed? [y/n]: y
> Do you really want to remove active logical volume origin? [y/n]: y
>   Logical volume "origin" successfully removed
> Do you really want to remove active logical volume remove_origin_under_snap?
> [y/n]: y
>   Logical volume "remove_origin_under_snap" successfully removed
>   Logical volume "extorigin" successfully removed

Tools knows the dependency and gives the user a choice to remove all related volumes.

Removal of external origin 'extorigin' triggers removal of 2 related thin volumes - 'origin' and 'remove_origin_under_snap' which both needs external origin for showing data from unprovisioned blocks.


> 
> [root@qalvm-01 ~]# lvs -a -o +devices
>   LV           Attr      LSize  Pool Origin Data%  Devices
>   POOL         twi-a-tz-  1.00g               0.00 POOL_tdata(0)
>   [POOL_tdata] Twi-ao---  1.00g                    /dev/vdh1(0)
>   [POOL_tmeta] ewi-ao---  4.00m                    /dev/vdd1(0)
>   other1       Vwi-a-tz-  1.00g POOL          0.00
>   other2       Vwi-a-tz-  1.00g POOL          0.00
>   other3       Vwi-a-tz-  1.00g POOL          0.00
>   other4       Vwi-a-tz-  1.00g POOL          0.00
>   other5       Vwi-a-tz-  1.00g POOL          0.00
> 
> 
> 
> # REMOVE THE PHYSICAL EXT ORIGIN VOLUME
> SCENARIO - [remove_origin_under_snap]
> Create a snapshot and then attempt to remove it's origin
> Making origin volume
> lvcreate --thinpool POOL -L 1G snapper_thinp
>   device-mapper: remove ioctl on  failed: Device or resource busy
> Sanity checking pool device metadata
> (thin_check /dev/mapper/snapper_thinp-POOL_tmeta)
> Create LV to be used as an EXTERNAL origin device
> lvcreate -L 1G -n origin snapper_thinp
> Converting LV into an external thin origin device
> lvconvert --thinpool snapper_thinp/POOL --originname extorigin -T origin
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other1
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other2
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other3
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other4
> lvcreate --virtualsize 1G --thinpool snapper_thinp/POOL -n other5
> Making snapshot of origin volume
> lvcreate -s /dev/snapper_thinp/origin -n remove_origin_under_snap
> Attempt to remove origin volume
> 
> [root@qalvm-01 ~]# lvs -a -o +devices
>   LV                       Attr      LSize  Pool Origin    Data%  Devices
>   POOL                     twi-a-tz-  1.00g                  0.00
> POOL_tdata(0)
>   [POOL_tdata]             Twi-ao---  1.00g                      
> /dev/vdh1(0)
>   [POOL_tmeta]             ewi-ao---  4.00m                      
> /dev/vdd1(0)
>   extorigin                ori------  1.00g                      
> /dev/vdg1(0)
>   origin                   Vwi-a-tz-  1.00g POOL extorigin   0.00
>   other1                   Vwi-a-tz-  1.00g POOL             0.00
>   other2                   Vwi-a-tz-  1.00g POOL             0.00
>   other3                   Vwi-a-tz-  1.00g POOL             0.00
>   other4                   Vwi-a-tz-  1.00g POOL             0.00
>   other5                   Vwi-a-tz-  1.00g POOL             0.00
>   remove_origin_under_snap Vwi-a-tz-  1.00g POOL origin      0.00
> 
> # ATTEMPT TO REMOVE THE "PHYSICAL" EXT ORIGIN:
> [root@qalvm-01 ~]# lvremove snapper_thinp/origin
> Do you really want to remove active logical volume origin? [y/n]: y
>   Logical volume "origin" successfully removed

yep - here is no problem with removal of 'origin' volume.

> [root@qalvm-01 ~]# lvs -a -o +devices
>   LV                       Attr      LSize  Pool Origin    Data%  Devices
>   POOL                     twi-a-tz-  1.00g                  0.00
> POOL_tdata(0)
>   [POOL_tdata]             Twi-ao---  1.00g                      /dev/vdh1(0)
>   [POOL_tmeta]             ewi-ao---  4.00m                      /dev/vdd1(0)
>   extorigin                ori------  1.00g                      /dev/vdg1(0)
>   other1                   Vwi-a-tz-  1.00g POOL             0.00
>   other2                   Vwi-a-tz-  1.00g POOL             0.00
>   other3                   Vwi-a-tz-  1.00g POOL             0.00
>   other4                   Vwi-a-tz-  1.00g POOL             0.00
>   other5                   Vwi-a-tz-  1.00g POOL             0.00
>   remove_origin_under_snap Vwi-a-tz-  1.00g POOL extorigin   0.00

Removed 'origin' volume is now replaced with external origin 'extorigin' volume directly. 
So this VG has 1 external origin LV - 'extorigin'  and 1 thin volume 'remove_origin_under_snap' which is it for unprovisioned areas.

Hopefully clear.

Note - you could create very long chain of external origins even between different pools - however the usability and understandability of such metadata and table mapping is questionable....