Bug 1796683

Summary: lvm unable to deal with splitting or removal of writecache volumes who's origin volumes are stacked
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, teigland, zkabelac
Version: 8.2Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: 8.0   
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: 2020-04-28 16:59:23 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:

Description Corey Marthaler 2020-01-30 23:22:15 UTC
Description of problem:

# Create a raid1 for the origin volume

[root@hayes-02 ~]# lvcreate  --type raid1 -m 1 -L 4G -n display_writecache writecache_sanity /dev/sdm1 /dev/sdn1
  Logical volume "display_writecache" created.
[root@hayes-02 ~]# lvcreate  -L 4G -n pool writecache_sanity /dev/sdp1
  Logical volume "pool" created.

[root@hayes-02 ~]# lvs -a -o +devices
  LV                            VG                Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                                                      
  display_writecache            writecache_sanity rwi-a-r--- 4.00g                                    100.00           display_writecache_rimage_0(0),display_writecache_rimage_1(0)
  [display_writecache_rimage_0] writecache_sanity iwi-aor--- 4.00g                                                     /dev/sdm1(1)                                                 
  [display_writecache_rimage_1] writecache_sanity iwi-aor--- 4.00g                                                     /dev/sdn1(1)                                                 
  [display_writecache_rmeta_0]  writecache_sanity ewi-aor--- 4.00m                                                     /dev/sdm1(0)                                                 
  [display_writecache_rmeta_1]  writecache_sanity ewi-aor--- 4.00m                                                     /dev/sdn1(0)                                                 
  pool                          writecache_sanity -wi-a----- 4.00g                                                     /dev/sdp1(0)                                                 


[root@hayes-02 ~]# lvchange -an writecache_sanity
[root@hayes-02 ~]# lvconvert --yes --type writecache --cachesettings 'writeback_jobs=1627 autocommit_blocks=2679 autocommit_time=2092' --cachevol writecache_sanity/pool writecache_sanity/display_writecache
  Logical volume writecache_sanity/display_writecache now has write cache.
[root@hayes-02 ~]# lvchange -ay writecache_sanity
[root@hayes-02 ~]# lvs -a -o +devices,segtype
  LV                            VG                Attr       LSize Pool        Origin                      Data%  Meta%  Move Log Cpy%Sync Convert Devices                                                       Type      
  display_writecache            writecache_sanity Cwi-a-C--- 4.00g [pool_cvol] [display_writecache_wcorig]                                         display_writecache_wcorig(0)                                  writecache
  [display_writecache_rimage_0] writecache_sanity iwi-aor--- 4.00g                                                                                 /dev/sdm1(1)                                                  linear    
  [display_writecache_rimage_1] writecache_sanity iwi-aor--- 4.00g                                                                                 /dev/sdn1(1)                                                  linear    
  [display_writecache_rmeta_0]  writecache_sanity ewi-aor--- 4.00m                                                                                 /dev/sdm1(0)                                                  linear    
  [display_writecache_rmeta_1]  writecache_sanity ewi-aor--- 4.00m                                                                                 /dev/sdn1(0)                                                  linear    
  [display_writecache_wcorig]   writecache_sanity rwi-aoC--- 4.00g                                                                100.00           display_writecache_rimage_0(0),display_writecache_rimage_1(0) raid1     
  [pool_cvol]                   writecache_sanity Cwi-aoC--- 4.00g                                                                                 /dev/sdp1(0)                                                  linear    

[root@hayes-02 ~]# lvchange -an writecache_sanity

# Split attempt
[root@hayes-02 ~]# lvconvert --splitcache writecache_sanity/display_writecache
  Cannot rename "display_writecache_wcorig": name format not recognized for internal LV "display_writecache_rimage_0"
  Failed to detach writecache from writecache_sanity/display_writecache

# Remove attempt
[root@hayes-02 ~]# lvremove -f writecache_sanity/display_writecache
  Cannot rename "display_writecache_wcorig": name format not recognized for internal LV "display_writecache_rimage_0"
  Failed to detach writecache from writecache_sanity/display_writecache
  Failed to detach writecache from writecache_sanity/display_writecache


Version-Release number of selected component (if applicable):
kernel-4.18.0-173.el8    BUILT: Fri Jan 24 06:02:03 CST 2020
lvm2-2.03.07-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
lvm2-libs-2.03.07-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
lvm2-dbusd-2.03.07-1.el8    BUILT: Mon Dec  2 00:12:23 CST 2019
lvm2-lockd-2.03.07-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
boom-boot-1.0-1.el8    BUILT: Fri Nov 29 05:18:30 CST 2019
device-mapper-1.02.167-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
device-mapper-libs-1.02.167-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
device-mapper-event-1.02.167-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019
device-mapper-event-libs-1.02.167-1.el8    BUILT: Mon Dec  2 00:09:32 CST 2019


How reproducible:
Everytime

Comment 1 David Teigland 2020-02-04 21:14:08 UTC
The problem seems to be related to this bit of code in remove_layer_from_lv() which I do not understand:

        /*
         * recuresively rename sub LVs
         *   currently supported only for thin data layer
         *   FIXME: without strcmp it breaks mirrors....
         */
        if (!strstr(layer_lv->name, "_mimage"))
                for (r = 0; r < DM_ARRAY_SIZE(_suffixes); ++r)
                        if (strstr(layer_lv->name, _suffixes[r]) == 0) {
                                lv_names.old = layer_lv->name;
                                lv_names.new = parent_lv->name;
                                if (!for_each_sub_lv(parent_lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
                                        return_0;
                                break;
                        }


That hunk of code ends up trying to incorrectly rename raid images based on the wcorig layer being removed.  If I simply remove that hunk of code the splitcache command works fine.  So the question is what the purpose of that code is, and how it should be properly disabled in this case.

Comment 2 David Teigland 2020-02-04 22:15:26 UTC
> The problem seems to be related to this bit of code in remove_layer_from_lv

Not a problem, it seems that I was using some old code to test, sorry for the noise.


fix in master
https://sourceware.org/git/?p=lvm2.git;a=commit;h=2a6078f96168e860474b42c42b1924fc353c4558


[root@null-05 lvm.git]# lvs -a foo
  LV              VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  fast            foo -wi-------  64.00m                                                    
  main            foo rwi---r--- 128.00m                                                    
  [main_rimage_0] foo Iwi---r--- 128.00m                                                    
  [main_rimage_1] foo Iwi---r--- 128.00m                                                    
  [main_rmeta_0]  foo ewi---r---   4.00m                                                    
  [main_rmeta_1]  foo ewi---r---   4.00m                                                    

[root@null-05 lvm.git]# lvconvert --type writecache --cachevol fast foo/main
Erase all existing data on foo/fast? [y/n]: y
  Logical volume foo/main now has write cache.

[root@null-05 lvm.git]# lvs -a foo
  LV                     VG  Attr       LSize   Pool        Origin        Data%  Meta%  Move Log Cpy%Sync Convert
  [fast_cvol]            foo Cwi---C---  64.00m                                                                  
  main                   foo Cwi---C--- 128.00m [fast_cvol] [main_wcorig]                                        
  [main_wcorig]          foo rwi---C--- 128.00m                                                                  
  [main_wcorig_rimage_0] foo Iwi---r--- 128.00m                                                                  
  [main_wcorig_rimage_1] foo Iwi---r--- 128.00m                                                                  
  [main_wcorig_rmeta_0]  foo ewi---r---   4.00m                                                                  
  [main_wcorig_rmeta_1]  foo ewi---r---   4.00m                                                                  

[root@null-05 lvm.git]# lvconvert --splitcache foo/main
  Logical volume foo/main write cache has been detached.

[root@null-05 lvm.git]# lvs -a foo
  LV              VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  fast            foo -wi-------  64.00m                                                    
  main            foo rwi---r--- 128.00m                                                    
  [main_rimage_0] foo Iwi---r--- 128.00m                                                    
  [main_rimage_1] foo Iwi---r--- 128.00m                                                    
  [main_rmeta_0]  foo ewi---r---   4.00m                                                    
  [main_rmeta_1]  foo ewi---r---   4.00m

Comment 4 Corey Marthaler 2020-02-20 21:02:34 UTC
Fixed verified in the latest rpms.

kernel-4.18.0-179.el8    BUILT: Fri Feb 14 17:03:01 CST 2020
lvm2-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
lvm2-libs-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
lvm2-dbusd-2.03.08-1.el8    BUILT: Tue Feb 11 07:42:51 CST 2020
lvm2-lockd-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020


[root@hayes-02 ~]# lvcreate  --type raid1 -m 1 -L 4G -n display_writecache writecache_sanity /dev/sdm1 /dev/sdn1
  Logical volume "display_writecache" created.
[root@hayes-02 ~]# lvcreate  -L 4G -n pool writecache_sanity /dev/sdp1
  Logical volume "pool" created.
[root@hayes-02 ~]# lvs -a -o +devices
  LV                            VG                Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                                      
  display_writecache            writecache_sanity rwi-a-r--- 4.00g                                    100.00           display_writecache_rimage_0(0),display_writec
  [display_writecache_rimage_0] writecache_sanity iwi-aor--- 4.00g                                                     /dev/sdm1(1)                                 
  [display_writecache_rimage_1] writecache_sanity iwi-aor--- 4.00g                                                     /dev/sdn1(1)                                 
  [display_writecache_rmeta_0]  writecache_sanity ewi-aor--- 4.00m                                                     /dev/sdm1(0)                                 
  [display_writecache_rmeta_1]  writecache_sanity ewi-aor--- 4.00m                                                     /dev/sdn1(0)                                 
  pool                          writecache_sanity -wi-a----- 4.00g                                                     /dev/sdp1(0)                                 
[root@hayes-02 ~]# lvchange -an writecache_sanity
[root@hayes-02 ~]# lvconvert --yes --type writecache --cachesettings 'writeback_jobs=1627 autocommit_blocks=2679 autocommit_time=2092' --cachevol writecache_sanity/
  Logical volume writecache_sanity/display_writecache now has write cache.
[root@hayes-02 ~]# lvchange -ay writecache_sanity
[root@hayes-02 ~]# lvs -a -o +devices,segtype
  LV                                   VG                Attr       LSize Pool        Origin                      Data%   Cpy%Sync Devices                          
  display_writecache                   writecache_sanity Cwi-a-C--- 4.00g [pool_cvol] [display_writecache_wcorig] 0.00             display_writecache_wcorig(0)     
  [display_writecache_wcorig]          writecache_sanity rwi-aoC--- 4.00g                                                 100.00   display_writecache_wcorig_rimage_
  [display_writecache_wcorig_rimage_0] writecache_sanity iwi-aor--- 4.00g                                                          /dev/sdm1(1)                     
  [display_writecache_wcorig_rimage_1] writecache_sanity iwi-aor--- 4.00g                                                          /dev/sdn1(1)                     
  [display_writecache_wcorig_rmeta_0]  writecache_sanity ewi-aor--- 4.00m                                                          /dev/sdm1(0)                     
  [display_writecache_wcorig_rmeta_1]  writecache_sanity ewi-aor--- 4.00m                                                          /dev/sdn1(0)                     
  [pool_cvol]                          writecache_sanity Cwi-aoC--- 4.00g                                                          /dev/sdp1(0)                     
[root@hayes-02 ~]# lvchange -an writecache_sanity

# Split attempt
[root@hayes-02 ~]# lvconvert --splitcache writecache_sanity/display_writecache
  Logical volume writecache_sanity/display_writecache write cache has been detached.
[root@hayes-02 ~]# echo $?
0

[root@hayes-02 ~]# lvcreate  --type raid1 -m 1 -L 4G -n display_writecache writecache_sanity /dev/sdm1 /dev/sdn1
  Logical Volume "display_writecache" already exists in volume group "writecache_sanity"
[root@hayes-02 ~]# lvs
  LV                 VG                Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  display_writecache writecache_sanity rwi---r--- 4.00g                                                    
  pool               writecache_sanity -wi------- 4.00g                                                    
[root@hayes-02 ~]# lvconvert --yes --type writecache --cachesettings 'writeback_jobs=1627 autocommit_blocks=2679 autocommit_time=2092' --cachevol writecache_sanity/
  Logical volume writecache_sanity/display_writecache now has write cache.

# Remove attempt
[root@hayes-02 ~]# lvremove -f writecache_sanity/display_writecache
  Logical volume "pool_cvol" successfully removed
  Logical volume "display_writecache" successfully removed
[root@hayes-02 ~]# echo $?
0

Comment 6 errata-xmlrpc 2020-04-28 16:59:23 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://access.redhat.com/errata/RHEA-2020:1881