Bug 1110026

Summary: LVM cache: Unable to lvcreate cache LV from existing origin LV
Product: Red Hat Enterprise Linux 6 Reporter: Jonathan Earl Brassow <jbrassow>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Default / Unclassified (RHEL6) QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, msnitzer, nperic, prajnoha, prockai, zkabelac
Version: 6.6   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.117-1.el6 Doc Type: Bug Fix
Doc Text:
Correction of supported syntax removed support for incorrect lvcreate syntax for actual LV conversion. But in the cases tool may uniquely deduce conversion syntax from lvcreate command line, support has been restored to reduce the risk of incompatibilities with existing scripts and documentation.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:35:00 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:
Bug Depends On:    
Bug Blocks: 1119326    

Description Jonathan Earl Brassow 2014-06-16 20:46:06 UTC
It seems there has been a regression in the following commit:
commit 8a60cbcf45c553dfc168552cf9af3059359ec95d
Date:   Tue Mar 11 23:07:41 2014 +0100

    thin: always activate and deactive pool when creating
    
    When we create thin-pool we have used trick to keep
    volume active, but since we now support TEMPORARY flag,
    we could just localy active & deactive metadata LV,
    and let the thinpool through normal activation process.


It use to be that we could start with either a cache-pool LV or an origin and use 'lvcreate' to create its compliment and form the cache LV.  This is no longer possible since the above commit.

To reproduce:
# lvcreate -l 2 -n lv vg
# lvcreate --type cache -n lv_cachepool -l 1 vg/lv <-- should produce cache LV

Comment 1 Jonathan Earl Brassow 2014-08-27 12:43:30 UTC
not a blocker candidate due to tech preview status

Comment 2 Zdenek Kabelac 2014-09-25 08:09:45 UTC
IMHO this command is currently supported  - however the logic behind this command is not the best match.

Reason:

The primary user request in this command is to 'convert'  existing LV into cached LV  and for this 'create' cache pool.

So this is IMHO clear sign for 'lvconvert' command.

Lvcreate command should be left here rather for creation of cached LV.
(That's the reason why I'd propose to stop supporting this command).

Ideal end result is:

lvcreate --type cache -L10 -n my_cached_volume vg

creates 'cached' 10M sized volume  'my_cached_volume' with some 'implicitly created cache pool (i.e. lvolXXX) 

compare with:

lvcreate -V10 -n thin --thinpool vg/pool

this command fails when pool does not exist.

and we need to get match for:

lvcreate --type cache --cachepool vg/existing_cache -L10 -n volume  vg.

For pool creation we use:

lvcreate --type cache-pool -L10 vg
(and we should as well handle  'lvcreate --cachepool new_pool -L10 vg)

Obviously this logic is then getting greatly confused when we start to allow to use 'lvcreate vg/lv'  for conversion.

IMHO needs more discussion - and I'm almost sure should not support this type of command

Comment 3 Zdenek Kabelac 2014-09-25 09:24:47 UTC
I assume we should also possibly introduce  --poolsize option.


So then we have:


lvconvert --cache --poolsize 10M  vg/origin

and even 

lvconvert --cache  vg/origin
(when we define some policy like poolsize should be i.e. 10% of origin size)


It's probably matching on thinpool support as well:

lvconvert --thin [--poolsize xxx] vg/extorigin

Converts volume into 'external' origin with thinpool with some size.
This could be seen as a 'simple way' how to use thinpool for i.e. thin snapshot creation.

For now lvconvert requires to have 'precreated' pool data volume and I think we could skip this - we have already code to detect rotational media.

As for lvcreate  -

lvcreate --cache -L10 -n cached_volume vg

It should mean to create 'origin' of 10M and the make it a cache volume and create a cache pool - again either automatically by a policy - or with --poolsize option - or by giving existing cachepool (unlike with lvconvert) --cachepool  LV.

So we then have proper logic with:

lvcreate --cache --cachepool existing_cache_pool_lv -L10 -n new_cached_volume vg

But it's getting here somewhat complicated:

with thin pools - we have '-V' for virtual thin volumes - and -L is used for pool size.

So needs discussion which logic fits best current command layout.

Comment 4 Zdenek Kabelac 2014-09-25 14:53:18 UTC
*** Bug 1107345 has been marked as a duplicate of this bug. ***

Comment 5 Zdenek Kabelac 2014-09-25 14:55:55 UTC
So as mentioned in Bug 1107345 - in commit c95d43b28c5f89e1d96f2b16805ecd74eb4b02fb it's been already recognized there is syntax parsing problem.

So we need to allow only  vg/pool with lvcreate
And with lvconvert  we use  vg/lv  to specify lv for conversion.

Comment 7 Zdenek Kabelac 2014-11-05 14:42:54 UTC
Current git code base of 2.02.112 supports  syntax from BZ description again,

Comment 10 Nenad Peric 2015-04-22 13:59:06 UTC
Based on Comment 7 and Comment 8, and on the following test:

[root@tardis-02 ~]# vgcreate vg /dev/sdc1 /dev/sdd1
  Physical volume "/dev/sdc1" successfully created
  Physical volume "/dev/sdd1" successfully created
  Volume group "vg" successfully created

[root@tardis-02 ~]# lvcreate -l 50 -n normal_lv vg
  Logical volume "normal_lv" created.

[root@tardis-02 ~]# lvs -a
  LV        VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  normal_lv vg          -wi-a----- 200.00m                                                    
  lv_home   vg_tardis02 -wi-ao---- 224.88g                                                    
  lv_root   vg_tardis02 -wi-ao----  50.00g                                                    
  lv_swap   vg_tardis02 -wi-ao----   4.00g                                                    

[root@tardis-02 ~]# lvcreate --type cache -n lv_cachepool -l 10 vg/normal_lv
  Logical volume vg/normal_lv is now cached.

[root@tardis-02 ~]# lvs -a
  LV                   VG          Attr       LSize   Pool           Origin            Data%  Meta%  Move Log Cpy%Sync Convert
  [lv_cachepool]       vg          Cwi---C---  40.00m                                  0.78   0.39            0.00            
  [lv_cachepool_cdata] vg          Cwi-ao----  40.00m                                                                         
  [lv_cachepool_cmeta] vg          ewi-ao----   8.00m                                                                         
  [lvol0_pmspare]      vg          ewi-------   8.00m                                                                         
  normal_lv            vg          Cwi-a-C--- 200.00m [lv_cachepool] [normal_lv_corig] 0.78   0.39            0.00            
  [normal_lv_corig]    vg          owi-aoC--- 200.00m                                                                         
  lv_home              vg_tardis02 -wi-ao---- 224.88g                                                                         
  lv_root              vg_tardis02 -wi-ao----  50.00g                                                                         
  lv_swap              vg_tardis02 -wi-ao----   4.00g                    


I will mark this BZ as VERIFIED against the original comment and bug descrption.

Verified with:

lvm2-2.02.118-2.el6.x86_64

Comment 11 errata-xmlrpc 2015-07-22 07:35:00 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://rhn.redhat.com/errata/RHBA-2015-1411.html