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 1383427

Summary: dmsetup does not reflect the changed cache mode when moving from writethrough -> writeback
Product: Red Hat Enterprise Linux 7 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Changing Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED NOTABUG Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, prockai, zkabelac
Version: 7.3   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-22 20:17:40 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:
Attachments:
Description Flags
verbose lvchange attempt none

Description Corey Marthaler 2016-10-10 15:07:52 UTC
Description of problem:
[root@host-126 ~]# lvcreate  -L 4G -n corigin test                                                                                                                                                                                                             
  Logical volume "corigin" created.                                                                                                                                                                                                                                       
[root@host-126 ~]# lvcreate  --yes --type cache-pool --cachepolicy mq --cachemode writethrough -L 500M test/cpool 
  Using default stripesize 64.00 KiB.
  Logical volume "cpool" created.
[root@host-126 ~]# lvconvert --yes --type cache --cachepool test/cpool test/corigin
  Logical volume test/corigin is now cached.

[root@host-126 ~]# lvs -a -o +devices,cachemode,cachepolicy
  LV              VG    Attr       LSize   Pool    Origin          Data%  Meta%  Cpy%Sync Devices          CacheMode    CachePolicy
  corigin         test  Cwi-a-C---   4.00g [cpool] [corigin_corig] 0.00   1.07   0.00     corigin_corig(0) writethrough mq
  [corigin_corig] test  owi-aoC---   4.00g                                                /dev/sdc1(0)
  [cpool]         test  Cwi---C--- 500.00m                         0.00   1.07   0.00     cpool_cdata(0)   writethrough mq
  [cpool_cdata]   test  Cwi-ao---- 500.00m                                                /dev/sdc1(1028)
  [cpool_cmeta]   test  ewi-ao----   8.00m                                                /dev/sdc1(1026)
  [lvol0_pmspare] test  ewi-------   8.00m                                                /dev/sdc1(1024)

[root@host-126 ~]# dmsetup table
test-cpool_cdata: 0 1024000 linear 8:33 8423424
test-cpool_cmeta: 0 16384 linear 8:33 8407040
test-corigin_corig: 0 8388608 linear 8:33 2048
test-corigin: 0 8388608 cache 253:4 253:3 253:5 128 1 writethrough mq 0

[root@host-126 ~]# lvchange --cachepolicy cleaner --cachemode writeback test/corigin
  Logical volume test/corigin changed.

[root@host-126 ~]# lvs -a -o +devices,cachemode,cachepolicy
  LV              VG    Attr       LSize   Pool    Origin          Data%  Meta%  Cpy%Sync Devices          CacheMode CachePolicy
  corigin         test  Cwi-a-C---   4.00g [cpool] [corigin_corig] 0.04   1.56   0.00     corigin_corig(0) writeback cleaner
  [corigin_corig] test  owi-aoC---   4.00g                                                /dev/sdc1(0)
  [cpool]         test  Cwi---C--- 500.00m                         0.04   1.56   0.00     cpool_cdata(0)   writeback cleaner
  [cpool_cdata]   test  Cwi-ao---- 500.00m                                                /dev/sdc1(1028)
  [cpool_cmeta]   test  ewi-ao----   8.00m                                                /dev/sdc1(1026)
  [lvol0_pmspare] test  ewi-------   8.00m                                                /dev/sdc1(1024)

# Was not updated to "writeback"
[root@host-126 ~]# dmsetup table
test-cpool_cdata: 0 1024000 linear 8:33 8423424
test-cpool_cmeta: 0 16384 linear 8:33 8407040
test-corigin_corig: 0 8388608 linear 8:33 2048
test-corigin: 0 8388608 cache 253:4 253:3 253:5 128 1 writethrough cleaner 0

[root@host-126 ~]# vgchange -an test
  0 logical volume(s) in volume group "test" now active
[root@host-126 ~]# vgchange -ay test
  1 logical volume(s) in volume group "test" now active

# Was still not updated to "writeback"
[root@host-126 ~]# dmsetup table
test-cpool_cdata: 0 1024000 linear 8:33 8423424
test-cpool_cmeta: 0 16384 linear 8:33 8407040
test-corigin_corig: 0 8388608 linear 8:33 2048
test-corigin: 0 8388608 cache 253:3 253:2 253:4 128 1 writethrough cleaner 0


Version-Release number of selected component (if applicable):
lvm2-2.02.166-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
lvm2-libs-2.02.166-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
lvm2-cluster-2.02.166-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
device-mapper-1.02.135-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
device-mapper-libs-1.02.135-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
device-mapper-event-1.02.135-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
device-mapper-event-libs-1.02.135-1.el7    BUILT: Wed Sep 28 02:26:52 CDT 2016
device-mapper-persistent-data-0.6.3-1.el7    BUILT: Fri Jul 22 05:29:13 CDT 2016


How reproducible:
Everytime

Comment 2 Corey Marthaler 2016-10-10 15:21:01 UTC
Created attachment 1208891 [details]
verbose lvchange attempt

Comment 3 Corey Marthaler 2016-10-10 15:32:46 UTC
writeback -> writethrough appears to work fine.


[root@host-126 ~]# lvcreate  -L 4G -n corigin test
  Logical volume "corigin" created.
[root@host-126 ~]# lvcreate  --yes --type cache-pool --cachepolicy mq --cachemode writeback -L 500M test/cpool
  Using default stripesize 64.00 KiB.
  Logical volume "cpool" created.
[root@host-126 ~]# lvconvert --yes --type cache --cachepool test/cpool test/corigin
  Logical volume test/corigin is now cached.

[root@host-126 ~]# lvs -a -o +devices,cachemode,cachepolicy
  LV              VG   Attr       LSize   Pool    Origin          Data% Meta% Cpy%Sync Devices          CacheMode CachePolicy
  corigin         test Cwi-a-C---   4.00g [cpool] [corigin_corig] 0.00  1.07  0.00     corigin_corig(0) writeback mq
  [corigin_corig] test owi-aoC---   4.00g                                              /dev/sda1(0)
  [cpool]         test Cwi---C--- 500.00m                         0.00  1.07  0.00     cpool_cdata(0)   writeback mq
  [cpool_cdata]   test Cwi-ao---- 500.00m                                              /dev/sda1(1028)
  [cpool_cmeta]   test ewi-ao----   8.00m                                              /dev/sda1(1026)
  [lvol0_pmspare] test ewi-------   8.00m                                              /dev/sda1(1024)

[root@host-126 ~]# dmsetup table
test-cpool_cdata: 0 1024000 linear 8:1 8423424
test-cpool_cmeta: 0 16384 linear 8:1 8407040
test-corigin_corig: 0 8388608 linear 8:1 2048
test-corigin: 0 8388608 cache 253:4 253:3 253:5 128 1 writeback mq 0

[root@host-126 ~]# lvchange --cachepolicy cleaner --cachemode writethrough test/corigin
  Flushing 1 blocks for cache test/corigin.
  Logical volume test/corigin changed.

[root@host-126 ~]# lvs -a -o +devices,cachemode,cachepolicy
  LV              VG   Attr       LSize   Pool    Origin          Data% Meta% Cpy%Sync Devices          CacheMode    CachePolicy
  corigin         test Cwi-a-C---   4.00g [cpool] [corigin_corig] 0.00  1.56  0.00     corigin_corig(0) writethrough cleaner
  [corigin_corig] test owi-aoC---   4.00g                                              /dev/sda1(0)
  [cpool]         test Cwi---C--- 500.00m                         0.00  1.56  0.00     cpool_cdata(0)   writethrough cleaner
  [cpool_cdata]   test Cwi-ao---- 500.00m                                              /dev/sda1(1028)
  [cpool_cmeta]   test ewi-ao----   8.00m                                              /dev/sda1(1026)
  [lvol0_pmspare] test ewi-------   8.00m                                              /dev/sda1(1024)

[root@host-126 ~]# dmsetup table
test-cpool_cdata: 0 1024000 linear 8:1 8423424
test-cpool_cmeta: 0 16384 linear 8:1 8407040
test-corigin_corig: 0 8388608 linear 8:1 2048
test-corigin: 0 8388608 cache 253:4 253:3 253:5 128 1 writethrough cleaner 0

Comment 4 Zdenek Kabelac 2017-01-22 20:17:40 UTC
Yep - this is intended logic - 'cleaner' policy requires  'writethrough' cache mode to be used. It doesn't work in writeback and may eventually cause endless clearing loop.

Once the 'cleaner' policy is switched to 'smq/mq' it goes to the right cache mode.

If this is not documented somewhere - like it's RFE for man page enhancement.

The command code works properly and does the right thing.