Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1344120

Summary: LVM cache: 'lvconvert --cachepolicy' fails to change cache policy (or even give an error)
Product: Red Hat Enterprise Linux 7 Reporter: Jonathan Earl Brassow <jbrassow>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, msnitzer, prajnoha, zkabelac
Version: 7.3   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-31 16:04: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:
Bug Depends On:    
Bug Blocks: 1469559    

Description Jonathan Earl Brassow 2016-06-08 19:49:34 UTC
[root@bp-01 ~]# lvcreate -L 5G -n lv vg
  Rounding up size to full physical extent 5.00 GiB
  Logical volume "lv" created.
[root@bp-01 ~]# lvcreate --type cache -L 500M -n cpool vg/lv
  Rounding up size to full physical extent 501.00 MiB
  Logical volume vg/lv is now cached.
[root@bp-01 ~]# lvconvert --cachepolicy mq vg/lv
[root@bp-01 ~]# vgcfgbackup vg
  Volume group "vg" successfully backed up.
[root@bp-01 ~]# grep policy /etc/lvm/backup/*
/etc/lvm/backup/vg:				policy = "smq"
[root@bp-01 ~]# dmsetup table
vg-cpool_cmeta: 0 12288 linear 8:17 10502144
rhel_bp--01-home: 0 854237184 linear 8:2 16517120
vg-lv: 0 10487808 cache 253:5 253:4 253:6 128 1 writethrough smq 0
rhel_bp--01-swap: 0 16515072 linear 8:2 2048
rhel_bp--01-root: 0 104857600 linear 8:2 870754304
vg-lv_corig: 0 10487808 linear 8:17 2048
vg-cpool_cdata: 0 1026048 linear 8:17 10514432
[root@bp-01 ~]# lvconvert --cachepolicy mq vg/cpool
  Can't convert internal LV vg/cpool.
[root@bp-01 ~]# lvconvert --cachepolicy puke vg/lv
[root@bp-01 ~]# echo $?
0
[root@bp-01 ~]# vgchange -an vg
  0 logical volume(s) in volume group "vg" now active
[root@bp-01 ~]# nano /etc/lvm/backup/vg
[root@bp-01 ~]# vgcfgrestore vg
  Restored volume group vg
[root@bp-01 ~]# vgchange -ay vg
  1 logical volume(s) in volume group "vg" now active
[root@bp-01 ~]# dmsetup table vg-lv
0 10487808 cache 253:4 253:3 253:5 128 1 writethrough mq 0

Comment 1 Corey Marthaler 2016-06-08 19:55:46 UTC
This is related to bugs 1269679 and 1284999.

Comment 2 Zdenek Kabelac 2016-06-09 08:23:49 UTC
Why would you want to use 'lvconvert'  when you want to 'change' settings ?

Supported command line here would be  'lvchange --cachepolicy'

We also do not validate 'policy name' - user is free to use whatever he could have localy - so ATM we fail on 'device-mapper: reload ioctl on (253:1) failed: Invalid argument'

We could however at least check 'modprobe dm_cache_puke'  - but I'm unsure if there are some strict naming rules with cache policy.


'lvconvert' accepts  --cachepolicy argument when you are converting some LV to be a cache-pool or cached volume.

Saying this - 'lvconvert' could be made smarter and probably deduce the 'change' operation and reroute to lvchange routine -  we already made some hack in 'lvcreate' for this since the  cache API might confuse users with operation types.

Comment 3 Jonathan Earl Brassow 2016-08-11 16:28:30 UTC
(In reply to Zdenek Kabelac from comment #2)
> Why would you want to use 'lvconvert'  when you want to 'change' settings ?

Your NEEDINFO must be to answer this question...

It's not what I "want", it is what I expected - perhaps in error.  I'll let you decide whether it is better to 1) mention to users that it is the wrong command, 2) improve documentation, or 3) make lvconvert call lvchange.

My thought was that since it changed on-disk LVM metadata that it would be 'lvconvert'.  I think that assumption may be in error.

Comment 4 Alasdair Kergon 2016-09-28 18:01:45 UTC
Changing cache policy would normally fit within the definition of 'lvchange' not 'lvconvert' as you're not converting the layout of the LV.  While we could detect this in lvconvert and translate it into the correct lvchange equivalent, let's finish cleaning up all the existing lvconvert functionality before adding even more!

Comment 6 David Teigland 2017-07-31 16:04:49 UTC
lvchange works, and using lvconvert now reports and error.

# lvconvert --cachepolicy mq bb/lv1
  Command does not accept option: --cachepolicy mq.

# lvs -o+cachepolicy bb/lv1
  LV   VG Attr       LSize Pool     Origin      Data%  Meta%  Cpy%Sync CachePolicy
  lv1  bb Cwi-a-C--- 1.00g [cache1] [lv1_corig] 0.01   2.83   0.00     mq         

# lvchange --cachepolicy smq bb/lv1
  Logical volume bb/lv1 changed.

# lvs -o+cachepolicy bb/lv1
  LV   VG Attr       LSize Pool     Origin      Data%  Meta%  Cpy%Sync CachePolicy
  lv1  bb Cwi-a-C--- 1.00g [cache1] [lv1_corig] 0.01   2.83   0.00     smq