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 1152801 - LVM cache: Add ability to specify and display cache policy
Summary: LVM cache: Add ability to specify and display cache policy
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2
Version: 7.1
Hardware: Unspecified
OS: Unspecified
urgent
low
Target Milestone: rc
: ---
Assignee: Petr Rockai
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks: 1119326
TreeView+ depends on / blocked
 
Reported: 2014-10-15 01:40 UTC by Jonathan Earl Brassow
Modified: 2023-03-08 07:27 UTC (History)
11 users (show)

Fixed In Version: lvm2-2.02.114-4.el7
Doc Type: Technology Preview
Doc Text:
Description of the Technology Preview: It is now possible to display (using the 'lvs' command) and manipulate cache policy parameters for persistent cache volumes.
Clone Of:
Environment:
Last Closed: 2015-03-05 13:09:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0513 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2015-03-05 16:14:41 UTC

Description Jonathan Earl Brassow 2014-10-15 01:40:31 UTC
dm-cache policies are modular.  A user may be interested in changing the overall cache policy or various tunables within that policy.  There is currently no interface to make that happen.

There are currently two cache policies:
- mq: "multi-queue".  The only current cache policy useful for nominal usage.
- cleaner:  Used to flush a cache before changing or removing it.

While there may only be one cache policy ATM, there are several tunables that could be changed within that policy.  See the kernel documentation for more.

Comment 1 Petr Rockai 2014-11-03 19:58:50 UTC
Code (not exposed) exists to save the cache policy name and its parameters in LVM metadata. The current format to do this is as an "argv" style array encoded in a space-separated string. A more idiomatic (and structured) way to go about this would be to add a section to the LV stanza -- by a section I mean this:

cache_policy {
    param1 = "value1"
    param2 = "value2"
}

The config parser will happily work with this format, it captures the structure of the data (key-value pairs, with unstructured values) and is just as (if not more) future-proof as a string would be. The expectation is that all these parameters are serialised back into the argv-style array when passed into the kernel. This means we need to take care not to allow whitespace inside the values. Another restriction is that LVM should (at least for now) not interpret the cache_policy section, other than parsing/formatting the key-value relationships in the metadata form and in the kernel form. This is easily doable with the current config parser.

Comment 2 Petr Rockai 2014-11-03 20:11:01 UTC
The CLI side of things needs to be drafted up. It is unrealistic to have dm-persistent-data provide us with the admissible key/value pairs (i.e. validation of parameters) at this time. This might change in the future.

To allow users to manipulate the parameters, we would add an 'lvchange' flag (say, --cachepolicy) that would take the parameters in some suitable format on the commandline. If we allow repeats, it might be something like:

lvchange --cachepolicy param1=value1 --cachepolicy param2=value2 LV

(the alternative would be to allow only one --cachepolicy and take the param=value pairs comma-separated; I personally like the multi-arg variant better)

The main reason for extending lvchange with this (but not lvcreate or lvconvert) is validation: we don't want to store "bogus" metadata only to find out it is bogus at activation time (which may or may not be much later). With lvchange, we can restrict the users to change policy only on active cache LVs, and obtain the current (default) keys and values from the kernel. We can therefore validate at least the key names and if the values that are provided by the user turn out to be wrong, we could (at least in principle) fail gracefully before writing the (bogus) policy parameters into metadata.

When a better method for validating the parameters becomes available, we may add --cachepolicy to lvcreate and lvconvert as appropriate.

Comment 3 Petr Rockai 2014-11-03 21:39:20 UTC
After talking this through, we have the following consensus on --cachepolicy:

1) the argument to --cachepolicy will be a 'config tree', the same data type that
   --config currently uses
2) 'config tree' can be currently specified in the format
   'section { key1 = foo key2 = bar; }' -- we will extend this to use the
   more streamlined and CLI-friendly form 'section/key1=foo'
   (applies to both --cachepolicy and --config)
3) both --cachepolicy and --config will be made to 'cascade' within the 
   commandline; that is, --config a/b=x --config a/c=y will result in
   'a { b=x c=y }' (currently this is not the case and one of the values
   is entirely dropped instead)

This approach also separates commandline parsing from parameter validation, so in the future, we can substitute another validation approach without seriously breaking things. On the validation side, the current preference is to simply hard-code the list of policies and their options currently available in dm_cache in LVM. This would make it possible to also allow --cachepolicy with lvcreate and lvconvert, if we require that validation will always be possible ahead of time.

Comment 4 Alasdair Kergon 2014-11-26 12:16:08 UTC
Some code got added to lvchange recently, but similar changes still needed to lvcreate/lvconvert.

Comment 5 Petr Rockai 2014-11-26 12:44:39 UTC
Yes, lvchange is covered since c75ae0846e4c1a74fbd44d85837e2b6dc50e9783. Setting the options upon creation will use the same syntax/mechanism. Reporting may need to be sorted out too (currently only available via dmsetup AFAIK).

Comment 6 Petr Rockai 2014-12-01 11:43:45 UTC
Added lvcreate in 5b2726fc6142c734e06fa8b49ad856b2e47da9fc, still missing: lvconvert, reporting.

Comment 7 Petr Rockai 2014-12-17 13:50:03 UTC
The code for reporting cache policy and cache settings (with `lvs`) is in upstream commit 00ad13eb719607682dfcf17d99ad96cfd5603d14. This means lvcreate and lvchange can be used to change policy and policy settings, `lvs` has fields to report those (cache_policy and cache_settings, to mirror --cachepolicy and --cachesettings parameters). What remains is to add --cachepolicy and --cachesettings to `lvconvert` -- I'll create a separate BZ for that, as it's not a requirement for this BZ (even if a cache LV comes into existence via `lvconvert`, the policy can easily be tweaked by a followup `lvchange`).

Comment 11 Peter Rajnoha 2015-01-27 12:13:27 UTC
To QA: some info about cache policies and their settings:
https://www.kernel.org/doc/Documentation/device-mapper/cache-policies.txt

Comment 12 Nenad Peric 2015-01-27 12:27:53 UTC
Changed default sequential_threshold to 256 from the default 512 to trigger the display of the custom value in lvs. 

[root@tardis-03 ~]# lvchange vg/origin --cachesettings sequential_threshold=256
  Logical volume "origin" changed.

[root@tardis-03 ~]# lvs -aolv_name,cache_policy,cache_settings,cachemode
  LV              Cache Policy Cache Settings           Cachemode   
  home                                                              
  root                                                              
  swap                                                              
  [cache0]                                              writethrough
  [cache0_cdata]                                                    
  [cache0_cmeta]                                                    
  [lvol0_pmspare]                                                   
  origin          mq           sequential_threshold=256 writethrough
  [origin_corig]                                                    
[root@tardis-03 ~]# 


More details regarding the settings and cache policies can be found in kernel device-mapper documentation:

https://www.kernel.org/doc/Documentation/device-mapper/cache-policies.txt


Marking this as VERIFIED with:

lvm2-2.02.115-2.el7.x86_64

Comment 14 errata-xmlrpc 2015-03-05 13:09:53 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-0513.html


Note You need to log in before you can comment on or make changes to this bug.