Bug 1434027

Summary: creation of thinpool and thin virt volume in one cmd is no longer possible
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Thin Provisioning QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, prockai, rbednar, teigland, thornber, zkabelac
Version: 7.4Keywords: Regression
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.169-3.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 21:49:49 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 2017-03-20 15:05:16 UTC
Description of problem:
Is this no longer supported in 7.4?

[root@host-113 ~]# vgs
  VG            #PV #LV #SN Attr   VSize   VFree  
  snapper_thinp   7   0   0 wz--n- 146.97g 146.97g

[root@host-113 ~]# lvcreate  --thinpool POOL1 -L 100M --virtualsize 100M snapper_thinp
  Invalid option for command: --virtualsize.

[root@host-113 ~]# lvcreate  --thinpool POOL4 -L 100M -V 100M snapper_thinp
  Invalid option for command: --virtualsize.



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

lvm2-2.02.169-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
lvm2-libs-2.02.169-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
lvm2-cluster-2.02.169-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
device-mapper-1.02.138-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
device-mapper-libs-1.02.138-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
device-mapper-event-1.02.138-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
device-mapper-event-libs-1.02.138-0.1253.el7    BUILT: Fri Mar 17 09:27:00 CDT 2017
device-mapper-persistent-data-0.6.3-1.el7    BUILT: Fri Jul 22 05:29:13 CDT 2016

Comment 2 Corey Marthaler 2017-03-20 15:15:33 UTC
7.3 behavior:

[root@host-119 ~]# lvcreate  --thinpool POOL1 -L 100M --virtualsize 100M snapper_thinp
  Using default stripesize 64.00 KiB.
  Logical volume "lvol1" created.

[root@host-119 ~]# lvcreate  --thinpool POOL4 -L 100M -V 100M snapper_thinp
  Using default stripesize 64.00 KiB.
  Logical volume "lvol2" created.

[root@host-119 ~]# lvs -a -o +devices
  LV              VG            Attr       LSize   Pool  Data% Meta% Devices
  POOL1           snapper_thinp twi-aotz-- 100.00m       0.00  0.98  POOL1_tdata(0)
  [POOL1_tdata]   snapper_thinp Twi-ao---- 100.00m                   /dev/sda1(1)
  [POOL1_tmeta]   snapper_thinp ewi-ao----   4.00m                   /dev/sdb1(0)
  POOL4           snapper_thinp twi-aotz-- 100.00m       0.00  0.98  POOL4_tdata(0)
  [POOL4_tdata]   snapper_thinp Twi-ao---- 100.00m                   /dev/sda1(26)
  [POOL4_tmeta]   snapper_thinp ewi-ao----   4.00m                   /dev/sdb1(1)
  [lvol0_pmspare] snapper_thinp ewi-------   4.00m                   /dev/sda1(0)
  lvol1           snapper_thinp Vwi-a-tz-- 100.00m POOL1 0.00
  lvol2           snapper_thinp Vwi-a-tz-- 100.00m POOL4 0.00

Comment 3 Alasdair Kergon 2017-03-20 15:39:08 UTC
Looks like a simple regression.

Comment 4 Zdenek Kabelac 2017-03-20 16:57:00 UTC
Syntax was supported from version 2.02.89:

lvcreate.c:

	else if (arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG))
		segtype_str = "thin";


presence of '--thinpool' implied  thin construction of not told otherwise...

Comment 5 Alasdair Kergon 2017-03-20 18:09:13 UTC
Is this the closest match, missing --thinpool?

lvcreate --size SizeMB --virtualsize SizeMB VG
OO: --type thin, --type snapshot, --thin, --snapshot, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
--stripes Number, --stripesize SizeKB
OP: PV ...
IO: --mirrors 0
ID: lvcreate_thin_vol_with_thinpool_or_sparse_snapshot
DESC: Create a thin LV, first creating a thin pool for it
DESC: (infers --type thin).


OO_LVCREATE_POOL: --poolmetadatasize SizeMB, --poolmetadataspare Bool, --chunksize SizeKB

Comment 8 David Teigland 2017-03-21 02:16:16 UTC
Commit in comment 6 is not correct because in cases where --thinpool is used with that cmd def, it is indistinguishable from other cmd defs.  I believe the correct fix is this patch is below.  This patch also fixes another small problem with this def (it shouldn't include --type thin in the OO list because when used that would make it indistinct from the cmd def listed just above).

The cmd def updated by this patch is uniquely defined by three features:
1. it requires --thinpool option
2. it requires --size option
3. it requires --virtualsize option

With those three things required, it can optionally include --thin, without being confused with any other cmd def.
It cannot optionally include --type thin because that would be confused with the cmd def above it.


diff --git a/tools/command-lines.in b/tools/command-lines.in
index 2fec553cc5e6..f12f815548f4 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1016,8 +1016,8 @@ DESC: Create a thin LV, first creating a thin pool for it,
 DESC: where the new thin pool is named by the --thinpool arg.
 
 # alternate form of lvcreate --type thin
-lvcreate --thin --virtualsize SizeMB --size SizeMB --thinpool LV_new
-OO: --type thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
+lvcreate --virtualsize SizeMB --size SizeMB --thinpool LV_new
+OO: --thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
 --stripes Number, --stripesize SizeKB
 OP: PV ...
 IO: --mirrors 0

Comment 9 David Teigland 2017-03-21 02:42:25 UTC
That patch doesn't quite address the issue in the original description because it's missing the VG pos arg.  We need another cmd def that is the same but takes a VG pos arg.  I also found a couple more problems where similar cmd defs should not include optional --type thin or --thin because using them would make them indistinct from others.  Here's the latest patch that should clear up the issues I've found so far.  This patch is based on code without the patch in comment 6 which should be reversed first.


diff --git a/tools/command-lines.in b/tools/command-lines.in
index 2fec553cc5e6..f8a5e573f37d 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1016,8 +1016,21 @@ DESC: Create a thin LV, first creating a thin pool for it,
 DESC: where the new thin pool is named by the --thinpool arg.
 
 # alternate form of lvcreate --type thin
-lvcreate --thin --virtualsize SizeMB --size SizeMB --thinpool LV_new
-OO: --type thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
+lvcreate --virtualsize SizeMB --size SizeMB --thinpool LV_new
+OO: --thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
+--stripes Number, --stripesize SizeKB
+OP: PV ...
+IO: --mirrors 0
+ID: lvcreate_thin_vol_and_thinpool
+DESC: Create a thin LV, first creating a thin pool for it,
+DESC: where the new thin pool is named by the --thinpool arg
+DESC: (variant, infers --type thin).
+FLAGS: SECONDARY_SYNTAX
+
+# same as prev but accepts VG pos arg
+# alternate form of lvcreate --type thin
+lvcreate --virtualsize SizeMB --size SizeMB --thinpool LV_new VG
+OO: --thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
 --stripes Number, --stripesize SizeKB
 OP: PV ...
 IO: --mirrors 0
@@ -1042,7 +1055,7 @@ FLAGS: SECONDARY_SYNTAX
 
 # alternate form of lvcreate --type thin
 lvcreate --thin --virtualsize SizeMB --size SizeMB LV_new|VG
-OO: --type thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
+OO: OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
 --stripes Number, --stripesize SizeKB
 OP: PV ...
 IO: --mirrors 0
@@ -1056,7 +1069,7 @@ FLAGS: SECONDARY_SYNTAX
 ---
 
 lvcreate --size SizeMB --virtualsize SizeMB VG
-OO: --type thin, --type snapshot, --thin, --snapshot, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
+OO: --type snapshot, --snapshot, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
 --stripes Number, --stripesize SizeKB
 OP: PV ...
 IO: --mirrors 0

Comment 10 David Teigland 2017-03-21 02:56:22 UTC
Sent patch in comment 9 via email and pushed to dev-dct-thin-defs1

Comment 11 David Teigland 2017-03-22 03:07:59 UTC
Fixed in
https://sourceware.org/git/?p=lvm2.git;a=commit;h=14c4d32247808fc0c32944a09ea06611244fdb3d

commands: fix combined thin pool and vol create defs

Fixes command defs related to creating a new thin pool and
then a new thin lv in the new pool.

1. lvcreate --size --virtualsize --thinpool
   Needs a cmd def, it was missing.
   The def is unique by the three required
   options: size, virtualsize and thinpool.

2. lvcreate --size --virtualsize --thinpool VG
   Needs a cmd def, it was missing.
   The def is unique by the three required
   options: size, virtualsize and thinpool,
   and one required positional arg: VG.

3. lvcreate --thin --virtualsize --size LV_new|VG
   This existing def should not accept an optional
   --type thin, which if used makes it indistinct
   from another def.

4. lvcreate --size --virtualsize VG
   This existing def should not accept an optional
   --type thin or --thin, which if used makes it
   indistinct from other defs (e.g. 3)

Comment 12 Corey Marthaler 2017-03-24 21:16:28 UTC
Similar issue, changing minor/major while also activating:

# RHEL7.4
3.10.0-626.el7.x86_64 / lvm2-2.02.169-0.1263.el7.x86_64

[root@host-117 ~]# lvs -a -o +devices
  LV                       VG              Attr       LSize   Pool             Data%  Meta%  Devices                  
  [lvol0_pmspare]          thinpool_3_9687 ewi-------   4.00m                                /dev/sdc1(0)             
  thinpool_3_96870         thinpool_3_9687 twi-aotz--   1.00g                  0.00   1.46   thinpool_3_96870_tdata(0)
  [thinpool_3_96870_tdata] thinpool_3_9687 Twi-ao----   1.00g                                /dev/sdc1(1)             
  [thinpool_3_96870_tmeta] thinpool_3_9687 ewi-ao----   4.00m                                /dev/sda1(0)             
  virt1                    thinpool_3_9687 Vwi-a-tz-- 500.00m thinpool_3_96870 0.00
  virt2                    thinpool_3_9687 Vwi-a-tz-- 500.00m thinpool_3_96870 0.00
  virt3                    thinpool_3_9687 Vwi-a-tz-- 500.00m thinpool_3_96870 0.00
  virt4                    thinpool_3_9687 Vwi-a-tz-- 500.00m thinpool_3_96870 0.00
  virt5                    thinpool_3_9687 Vwi-a-tz-- 500.00m thinpool_3_96870 0.00

[root@host-117 ~]#  lvchange -aye -f -My --major 255 --minor 164 /dev/thinpool_3_9687/virt4
  Invalid option for command: --activate.




# RHEL7.3
[root@host-119 ~]# lvcreate --activate y --thinpool thinpool_3_96870 -L 1G VG
  Using default stripesize 64.00 KiB.
  Logical volume "thinpool_3_96870" created.

[root@host-119 ~]# lvcreate --activate y --virtualsize 500M -T VG/thinpool_3_96870 -n virt4
  Using default stripesize 64.00 KiB.
  Logical volume "virt4" created.

[root@host-119 ~]# lvs -a -o +devices
  LV                       VG  Attr       LSize   Pool             Data%  Meta% Devices
  [lvol0_pmspare]          VG  ewi-------   4.00m                               /dev/sda1(0)
  thinpool_3_96870         VG  twi-aotz--   1.00g                  0.00   1.07  thinpool_3_96870_tdata(0)
  [thinpool_3_96870_tdata] VG  Twi-ao----   1.00g                               /dev/sda1(1)
  [thinpool_3_96870_tmeta] VG  ewi-ao----   4.00m                               /dev/sdh1(0)
  virt4                    VG  Vwi-a-tz-- 500.00m thinpool_3_96870 0.00                                                             

[root@host-119 ~]# lvchange -aye -f -My --major 255 --minor 164 /dev/VG/virt4
  WARNING: Ignoring supplied major number 255 - kernel assigns major numbers dynamically. Using major number 253 instead.
  Logical volume VG/virt4 changed.

Comment 14 Corey Marthaler 2017-03-30 16:04:17 UTC
Marking this bug verified in the latest rpms. I'll file a new bug for the issue listed in comment #12.


[root@host-076 ~]# lvcreate  --thinpool POOL1 -L 100M --virtualsize 100M snapper_thinp
  Using default stripesize 64.00 KiB.
  Logical volume "lvol1" created.
[root@host-076 ~]# lvcreate  --thinpool POOL4 -L 100M -V 100M snapper_thinp
  Using default stripesize 64.00 KiB.
  Logical volume "lvol2" created.


3.10.0-635.el7.x86_64

lvm2-2.02.169-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
lvm2-libs-2.02.169-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
lvm2-cluster-2.02.169-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
device-mapper-1.02.138-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
device-mapper-libs-1.02.138-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
device-mapper-event-1.02.138-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
device-mapper-event-libs-1.02.138-3.el7    BUILT: Wed Mar 29 09:17:46 CDT 2017
device-mapper-persistent-data-0.7.0-0.1.rc6.el7    BUILT: Mon Mar 27 10:15:46 CDT 2017

Comment 15 errata-xmlrpc 2017-08-01 21:49:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2222