Bug 2165691

Summary: should the LV be extended when --fs resize is used and an inactive LUKS device exists on top, causing the fs check to fail?
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Changing 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: 9.2Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.21-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:53:27 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 2023-01-30 19:14:13 UTC
Description of problem:
LV + LUKs, where the LV is active, but the LUKS is not. Using --fs resize will cause lvextend's fs check to fail and the error code will be non zero, however, the resize of the volume will still happen.


SCENARIO - luks_no_fs_inactive_resizefs_extend:  Create a variety of Encrypted LUKS LV types and attempt to extend the size while INACTIVE and w/o a filesystem, but with the use of --fs resize
adding entry to the devices file for /dev/sda
creating PV on virt-557.cluster-qe.lab.eng.brq.redhat.com using device /dev/sda
creating VG on virt-557.cluster-qe.lab.eng.brq.redhat.com using PV(s) /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde
vgcreate    resize_matrix /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde
  Volume group "resize_matrix" successfully created
 
lvcreate --yes --type linear -n resize_lv  -L 30G resize_matrix  
Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Logical volume "resize_lv" created.
 
'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv'
'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks'
'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks'
deactivating LV resize_lv on virt-557.cluster-qe.lab.eng.brq.redhat.com
lvchange --yes -an  resize_matrix/resize_lv
Adding additional space to resize_matrix/resize_lv on virt-557.cluster-qe.lab.eng.brq.redhat.com
lvextend --yes --fs resize -L +446M resize_matrix/resize_lv
 
 
[root@virt-557 ~]# lvs -a -o +devices
  LV        VG            Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices    
  resize_lv resize_matrix -wi------- 30.00g                                                     /dev/sda(0)
 
[root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv
  Rounding size to boundary between physical extents: 448.00 MiB.
  Logical volume resize_matrix/resize_lv must be active for file system resize.
 
[root@virt-557 ~]# lvchange -ay resize_matrix
 
[root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv
  Rounding size to boundary between physical extents: 448.00 MiB.
  Size of logical volume resize_matrix/resize_lv changed from 30.00 GiB (7680 extents) to <30.44 GiB (7792 extents).
  Cannot find active LUKS dm-crypt device using resize_matrix/resize_lv.
  File system extend error.
  Logical volume resize_matrix/resize_lv successfully resized.
[root@virt-557 ~]# echo $?
5
 
[root@virt-557 ~]# echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks
[root@virt-557 ~]# lvextend --yes --fs resize -L +446M resize_matrix/resize_lv
  Rounding size to boundary between physical extents: 448.00 MiB.
  Size of logical volume resize_matrix/resize_lv changed from <30.44 GiB (7792 extents) to <30.88 GiB (7904 extents).
  File system found on crypt device /dev/dm-3 on LV resize_matrix/resize_lv.
  No file system found on /dev/dm-3.
  Logical volume resize_matrix/resize_lv successfully resized.
[root@virt-557 ~]# echo $?
0


Version-Release number of selected component (if applicable):
kernel-5.14.0-239.el9    BUILT: Thu Jan 19 04:29:56 PM CET 2023
lvm2-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023
lvm2-libs-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023

Comment 1 David Teigland 2023-01-30 23:09:12 UTC
> # lvextend --yes --fs resize -L +446M resize_matrix/resize_lv
>  Rounding size to boundary between physical extents: 448.00 MiB.
>  Size of logical volume resize_matrix/resize_lv changed from 30.00 GiB (7680 extents) to <30.44 GiB (7792 extents).
>  Cannot find active LUKS dm-crypt device using resize_matrix/resize_lv.
>  File system extend error.
>  Logical volume resize_matrix/resize_lv successfully resized.
> # echo $?
> 5

This is not ideal and can be improved.

lvextend --resizefs should fail in the case where crypto_LUKS is seen on the LV, but the crypt device is missing.

Failing is correct because the user requested resizefs, but lvextend is unable to do it. (It's unable to even look for a fs when the crypt device is missing, but we assume there would be a fs there since the user has requested resizing it.)

In the example above, lvextend would ideally fail before extending the LV.  That's not always possible for resizefs, but when it is possible it's the preferred behavior.  In this case we can easily do that, and with that fixed, the example looks like this:

$ echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/test/foo
$ echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/test/foo foocr
$ cryptsetup luksClose foocr
$ lvextend -L+32M --resizefs test/foo
  LUKS dm-crypt device must be active for fs resize.
$ echo $?
5

Comment 3 David Teigland 2023-01-31 21:33:54 UTC
*** Bug 2165771 has been marked as a duplicate of this bug. ***

Comment 6 Corey Marthaler 2023-05-16 19:27:57 UTC
Marking Verified:Tested in the latest rpms.

kernel-5.14.0-306.el9    BUILT: Sat Apr 29 05:45:15 PM CEST 2023
lvm2-2.03.21-1.el9    BUILT: Fri Apr 21 02:33:33 PM CEST 2023
lvm2-libs-2.03.21-1.el9    BUILT: Fri Apr 21 02:33:33 PM CEST 2023



lvcreate --yes --type striped -n resize_lv  -L 30G -i 2 resize_matrix  
Using default stripesize 64.00 KiB.
  Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Logical volume "resize_lv" created.

'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv'
'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks'
'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks'
deactivating LV resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvchange --yes -an  resize_matrix/resize_lv

Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvextend --yes --fs resize -L +420M resize_matrix/resize_lv 
Logical volume resize_matrix/resize_lv must be active for file system resize.

activating LV resize_lv -ay on grant-01.6a2m.lab.eng.bos.redhat.com
lvchange --yes -ay  resize_matrix/resize_lv

Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvextend --yes --fs resize -L +519M resize_matrix/resize_lv 
LUKS dm-crypt device must be active for fs resize.

PRE:31457280.0 POST:31457280.0
lvremove  -f resize_matrix/resize_lv
Logical volume "resize_lv" successfully removed.

Comment 9 Corey Marthaler 2023-05-26 14:48:18 UTC
Works in the latest build as well. Marking VERIFIED.

kernel-5.14.0-306.el9    BUILT: Sat Apr 29 05:45:15 PM CEST 2023
lvm2-2.03.21-2.el9    BUILT: Thu May 25 12:03:04 AM CEST 2023
lvm2-libs-2.03.21-2.el9    BUILT: Thu May 25 12:03:04 AM CEST 2023



------------------------------------------------------------
lvcreate --yes --type raid1 -n resize_lv  -L 30G -m 2 resize_matrix  
Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Wiping crypto_LUKS signature on /dev/resize_matrix/resize_lv.
  Logical volume "resize_lv" created.

lvconvert --yes  --raidintegrity y resize_matrix/resize_lv
  Using integrity block size 512 for unknown file system block size, logical block size 512, physical block size 4096.
  Logical volume resize_matrix/resize_lv has added integrity.
'echo "Str0ngP455w0rd###" | cryptsetup luksFormat /dev/resize_matrix/resize_lv'
'echo "Str0ngP455w0rd###" | cryptsetup luksOpen /dev/resize_matrix/resize_lv resize_luks'
'echo "Str0ngP455w0rd###" | cryptsetup luksClose resize_luks'
deactivating LV resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvchange --yes -an  resize_matrix/resize_lv
Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvextend --yes --fs resize -L +602M resize_matrix/resize_lv 
Logical volume resize_matrix/resize_lv must be active for file system resize.
activating LV resize_lv -ay on grant-01.6a2m.lab.eng.bos.redhat.com
lvchange --yes -ay  resize_matrix/resize_lv
Adding additional space to resize_matrix/resize_lv on grant-01.6a2m.lab.eng.bos.redhat.com
lvextend --yes --fs resize -L +557M resize_matrix/resize_lv 
LUKS dm-crypt device must be active for fs resize.
PRE:31457280.0 POST:31457280.0
lvremove  -f resize_matrix/resize_lv
Logical volume "resize_lv" successfully removed.

Comment 12 errata-xmlrpc 2023-11-07 08:53:27 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 (lvm2 bug fix and enhancement update), 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/RHBA-2023:6633