Bug 1284128

Summary: thin and cache pool create commands should be consistent
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: 7.2   
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: 2015-11-21 10:55:18 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 2015-11-20 23:01:00 UTC
Description of problem:
Shouldn't all these create commands behave the same whether it's a cache or thin pool being created? 


# --[thin,cache]-pool                                                                                                                                                             
[root@host-122 ~]# lvcreate --thin-pool POOL1 -L 100M vg                                                                                                                           
  Logical volume "POOL1" created.                                                                                                                                                        
[root@host-122 ~]# lvcreate --cache-pool POOL2 -L 100M vg                                                                                                                                     
  Ambiguous syntax, please create --type cache-pool POOL2 separately.


# --type [thin,cache]-pool
[root@host-122 ~]# lvcreate --type thin-pool POOL3 -L 100M vg
  Volume group "POOL3" not found
[root@host-122 ~]# lvcreate --type cache-pool POOL4 -L 100M vg
  Volume group "POOL4" not found


# --type [thin,cache]-pool -n
[root@host-122 ~]# lvcreate --type thin-pool -n POOL5 -L 100M vg
  Logical volume "POOL5" created.
[root@host-122 ~]# lvcreate --type cache-pool -n POOL6 -L 100M vg
  Logical volume "POOL6" created.


# --[thin,cache]pool
[root@host-122 ~]# lvcreate --thinpool POOL7 -L 100M vg
  Logical volume "POOL7" created.
[root@host-122 ~]# lvcreate --cachepool POOL8 -L 100M vg
  Ambiguous syntax, please create --type cache-pool POOL8 separately.


# --[thin,cache]pool -n
[root@host-122 ~]# lvcreate --thinpool -n POOL9 -L 100M vg
  Logical volume name "-n" is invalid.
  Run `lvcreate --help' for more information.
[root@host-122 ~]# lvcreate --cachepool -n POOL10 -L 100M vg
  Logical volume name "-n" is invalid.
  Run `lvcreate --help' for more information.


# --type [thin,cache]pool -n 
[root@host-122 ~]# lvcreate --type thinpool -n POOL11 -L 100M vg
  WARNING: Unrecognised segment type thinpool
  Invalid argument for --type: thinpool
  Error during parsing of command line.
[root@host-122 ~]# lvcreate --type cachepool -n POOL12 -L 100M vg
  WARNING: Unrecognised segment type cachepool
  Invalid argument for --type: cachepool
  Error during parsing of command line.


[root@host-122 ~]# lvs -a -o +devices
  LV              VG  Attr       LSize   Pool Origin Data%  Meta% Devices       
  POOL1           vg  twi-a-tz-- 100.00m             0.00   0.88  POOL1_tdata(0)
  [POOL1_tdata]   vg  Twi-ao---- 100.00m                          /dev/sda1(1)  
  [POOL1_tmeta]   vg  ewi-ao----   4.00m                          /dev/sdh1(0)  
  POOL5           vg  twi-a-tz-- 100.00m             0.00   0.88  POOL5_tdata(0)
  [POOL5_tdata]   vg  Twi-ao---- 100.00m                          /dev/sda1(26) 
  [POOL5_tmeta]   vg  ewi-ao----   4.00m                          /dev/sdh1(1)  
  POOL6           vg  Cwi---C--- 100.00m                          POOL6_cdata(0)
  [POOL6_cdata]   vg  Cwi------- 100.00m                          /dev/sda1(54) 
  [POOL6_cmeta]   vg  ewi-------   8.00m                          /dev/sda1(52) 
  POOL7           vg  twi-a-tz-- 100.00m             0.00   0.88  POOL7_tdata(0)
  [POOL7_tdata]   vg  Twi-ao---- 100.00m                          /dev/sda1(79) 
  [POOL7_tmeta]   vg  ewi-ao----   4.00m                          /dev/sdh1(2)  
  [lvol0_pmspare] vg  ewi-------   8.00m                          /dev/sda1(0)  
  [lvol0_pmspare] vg  ewi-------   8.00m                          /dev/sda1(51) 


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

lvm2-2.02.130-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
lvm2-libs-2.02.130-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
lvm2-cluster-2.02.130-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
device-mapper-1.02.107-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
device-mapper-libs-1.02.107-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
device-mapper-event-1.02.107-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
device-mapper-event-libs-1.02.107-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
device-mapper-persistent-data-0.5.5-1.el7    BUILT: Thu Aug 13 09:58:10 CDT 2015
cmirror-2.02.130-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015
sanlock-3.2.4-1.el7    BUILT: Fri Jun 19 12:48:49 CDT 2015
sanlock-lib-3.2.4-1.el7    BUILT: Fri Jun 19 12:48:49 CDT 2015
lvm2-lockd-2.02.130-5.el7    BUILT: Wed Oct 14 08:27:29 CDT 2015

Comment 1 Zdenek Kabelac 2015-11-21 10:55:18 UTC
(In reply to Corey Marthaler from comment #0)
> Description of problem:
> Shouldn't all these create commands behave the same whether it's a cache or
> thin pool being created? 

So let's go one-by-one

> 
> 
> # --[thin,cache]-pool                                                       
> 
> [root@host-122 ~]# lvcreate --thin-pool POOL1 -L 100M vg                    
> 
>   Logical volume "POOL1" created.                                           
> 
> [root@host-122 ~]# lvcreate --cache-pool POOL2 -L 100M vg                   
> 
>   Ambiguous syntax, please create --type cache-pool POOL2 separately.


--type thin-pool       !=    --thin-pool|--thinpool
--type cache-pool       !=    --cache-pool|--cachepool

For 'thin-pool' we have implemented 'cheat' support into command line,
so if the tool 'guesses' you wanted to create POOL1  it will do it.

However for cache - we cannot 'cheat' since it's not actually clear
(ambigous) if you wanted to create 'cachedLV' or  'cachepool'

With thin - case is simple - without -V  you cannot create thin volume
so the only thing you could create is pool.




> # --type [thin,cache]-pool
> [root@host-122 ~]# lvcreate --type thin-pool POOL3 -L 100M vg
>   Volume group "POOL3" not found
> [root@host-122 ~]# lvcreate --type cache-pool POOL4 -L 100M vg
>   Volume group "POOL4" not found


Correct -   --type  takes argument   thin-pool,cache-pool
So first 'free' arg is volume group name - in this case POOL3, POOL4



> 
> 
> # --type [thin,cache]-pool -n
> [root@host-122 ~]# lvcreate --type thin-pool -n POOL5 -L 100M vg
>   Logical volume "POOL5" created.
> [root@host-122 ~]# lvcreate --type cache-pool -n POOL6 -L 100M vg
>   Logical volume "POOL6" created.

Correct -   --name of pool is given and name of volume group is 'vg'
(first free arg on line)

> 
> 
> # --[thin,cache]pool
> [root@host-122 ~]# lvcreate --thinpool POOL7 -L 100M vg
>   Logical volume "POOL7" created.
> [root@host-122 ~]# lvcreate --cachepool POOL8 -L 100M vg
>   Ambiguous syntax, please create --type cache-pool POOL8 separately.


Opposite case for the first case.

Worth to note here -  for a while lvm2 now support arbitrary amount
of '-' in option name  i.e. --thin-pool  == --t-h-i-n-p-o-o-l
and many other variants basically from any option name  all '-' are dropped and
this gives you the 'base' option name.


So let's reapeat this case  '--type thinpool'  !=  --thinpool

--thinpool takes argument  poolname

so lvcreate 'knows' pool name, knows size and knows  VG name and can create.

The cache case is 'ambiguous' - if POOL8 doesn't exists command doesn't know if you wanted to create cache-pool or cached LV.

In future it's possible we will have some 'policy' to pick 'cachepool' size according to LV size (i.e. 10% of LV size), but until this happens,
we report  ambiguous syntax error...



> 
> 
> # --[thin,cache]pool -n
> [root@host-122 ~]# lvcreate --thinpool -n POOL9 -L 100M vg
>   Logical volume name "-n" is invalid.
>   Run `lvcreate --help' for more information.
> [root@host-122 ~]# lvcreate --cachepool -n POOL10 -L 100M vg
>   Logical volume name "-n" is invalid.
>   Run `lvcreate --help' for more information.

--thin  !=  --thinpool
--cache !=  --cachepool


--thin       takes no argument
--cache      takes no argument 

--thinpool <poolname>
--cachepool <poolname>


> # --type [thin,cache]pool -n 
> [root@host-122 ~]# lvcreate --type thinpool -n POOL11 -L 100M vg
>   WARNING: Unrecognised segment type thinpool
>   Invalid argument for --type: thinpool
>   Error during parsing of command line.
> [root@host-122 ~]# lvcreate --type cachepool -n POOL12 -L 100M vg
>   WARNING: Unrecognised segment type cachepool
>   Invalid argument for --type: cachepool
>   Error during parsing of command line.


Name of 'segment type'  is   cache-pool,  thin-pool
We may eventually add support for  segment aliases
so tool will make   thin-pool == thinpool.

Possibly RFE this separately.

---

So overall no bug here - everything works as expected.
(The situation is worse with 'lvconvert' - that command needs fixes)