Bug 1148592

Summary: lvconvert ignores '--cachemode writethrough' for cache pools
Product: Red Hat Enterprise Linux 7 Reporter: Jonathan Earl Brassow <jbrassow>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Cache Logical Volumes QA Contact: Cluster QE <mspqa-list>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: unspecified CC: agk, armin.hammer, bmarzins, bmr, cks-rhbugzilla, cmarthal, dwysocha, extras-qa, heinzm, jbrassow, jonathan, lvm-team, msnitzer, nperic, prajnoha, prockai, sreber, zkabelac
Version: 7.1   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.112-1.el7 Doc Type: Bug Fix
Doc Text:
Cachmode option supports options writethrough and writeback, however initial cache implementation missed proper code for writeback mode. New lvm2 code fixes the missing writaback support.
Story Points: ---
Clone Of: 1135639
: 1171634 1171637 (view as bug list) Environment:
Last Closed: 2015-03-05 13:09:38 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: 1135639    
Bug Blocks: 1119326, 1171634, 1171637    

Description Jonathan Earl Brassow 2014-10-01 19:46:40 UTC
+++ This bug was initially created as a clone of Bug #1135639 +++

Description of problem:

Despite claiming to support it, 'lvconvert --type cache-pool --cachemode
writethrough' silently creates a cache pool (and thus eventually a
cache) that is actually operating in writeback mode, thus exposing the
user to a completely unexpected possibility of data loss.

(I rate this as a high impact issue because of the potential for
unexpected data loss, in fact data loss that the user thought they
were explicitly insuring against by specifying writethrough instead of
writeback caching.)

I expect that this is an upstream bug.

Version-Release number of selected component (if applicable):

lvm2-2.02.106-1.fc20.x86_64

Steps to Reproduce:

Assume that you have an initial volume group testing and a logical
volume in it testing/test that you wish to add a writethrough cache
to. Then:

 # lvcreate -L 5G -n cache_data testing
 # lvcreate -L 500M -n cache_meta testing
 # lvconvert --type cache-pool --cachemode writethrough --poolmetadata testing/cache_meta testing/cache_data
 # lvconvert --type cache --cachepool testing/cache_data testing/test
 testing/test is now cached.

At this point the dm-cache device is created and set up. It should be
in writethrough mode, because that is what we set when we created the
cache-pool LV. However:

 # dmsetup status testing-test
 0 10485760 cache 8 174/128000 128 3/81920 37 79 0 0 0 3 0 1 writeback 2 migration_threshold 2048 mq 10 random_threshold 4 sequential_threshold 512 discard_promote_adjustment 1 read_promote_adjustment 4 write_promote_adjustment 8

The actual dm-cache device is in writeback mode, not writethrough (the
'1 writeback' in the status line). The dm-cache device is capable of
being in writethrough mode if we fiddle with it:

 # dmsetup table testing-test
 0 10485760 cache 253:5 253:4 253:6 128 0 default 0
 # dmsetup reload testing-test --table '0 10485760 cache 253:5 253:4 253:6 128 1 writethrough default 0'
 # dmsetup suspend testing-test; dmsetup resume testing-test
 # dmsetup status testing-test
 0 10485760 cache 8 174/128000 128 3/81920 49 67 0 0 0 0 0 1 writethrough 2 migration_threshold 2048 mq 10 random_threshold 4 sequential_threshold 512 discard_promote_adjustment 1 read_promote_adjustment 4 write_promote_adjustment 8

It now reports '1 writethrough'.

However if we reboot the machine this dm-cache device will go right back
to being in writeback mode.

--- Additional comment from Jonathan Earl Brassow on 2014-09-16 23:21:18 EDT ---

Fix committed upstream:
commit 9d57aa9a0fe00322cb188ad1f3103d57392546e7
Author: Jonathan Brassow <jbrassow>
Date:   Tue Sep 16 22:19:53 2014 -0500

    cache-pool:  Fix specification of cachemode when converting to cache-pool
    
    Failure to copy the 'feature_flags' lvconvert_param to the matching
    lv_segment field meant that when a user specified the cachemode argument,
    the request was not honored.

Comment 2 Corey Marthaler 2014-12-10 19:02:33 UTC
Fix verified in the latest rpms.

3.10.0-215.el7.x86_64
lvm2-2.02.114-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
lvm2-libs-2.02.114-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
lvm2-cluster-2.02.114-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
device-mapper-1.02.92-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
device-mapper-libs-1.02.92-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
device-mapper-event-1.02.92-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
device-mapper-event-libs-1.02.92-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014
device-mapper-persistent-data-0.4.1-2.el7    BUILT: Wed Nov 12 12:39:46 CST 2014
cmirror-2.02.114-2.el7    BUILT: Mon Dec  1 10:57:14 CST 2014



Added a quick check to the regression tests to verify what is in 'dmsetup status' matches what was passed to lvconvert.

Comment 4 errata-xmlrpc 2015-03-05 13:09:38 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