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 2162144 - lvresize should only resize crypt device when resizing file system
Summary: lvresize should only resize crypt device when resizing file system
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: lvm2
Version: 9.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: David Teigland
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-01-18 22:37 UTC by David Teigland
Modified: 2023-09-19 04:32 UTC (History)
10 users (show)

Fixed In Version: lvm2-2.03.17-6.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 08:23:51 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker CLUSTERQE-6368 0 None None None 2023-01-24 17:08:05 UTC
Red Hat Issue Tracker RHELPLAN-145660 0 None None None 2023-01-18 22:41:29 UTC
Red Hat Product Errata RHBA-2023:2544 0 None None None 2023-05-09 08:24:05 UTC

Description David Teigland 2023-01-18 22:37:44 UTC
Description of problem:

There are a couple cases where lvreduce, without --resizefs being set, will resize a crypt device on the LV.  lvresize should only resize the LV unless --resizefs is set, which allows it to go beyond the LV and handle the fs and potential crypt layer.


extend tests use commands:
lvcreate -n lv -L512M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr
lvextend [--fs resize] -L640M test/lv
cryptsetup resize lvcr  (new size 1306624 sectors)
resize2fs /dev/mapper/lvcr (new size 653312 1k blocks)

reduce tests use commands:
lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr
resize2fs /dev/mapper/lvcr 522240k (new size 130560 4k blocks)
cryptsetup resize --size 1044480 lvcr 
lvreduce [--fs resize] -L512M test/lv


1. extend with --fs resize
--------------------------

a) lvextend --fs resize LV
   lvextend extends lv
   lvextend extends crypt
   lvextend extends fs

b) lvextend --fs resize LV + resize2fs
   lvextend extends lv
   lvextend extends crypt
   lvextend extends fs
   resize2fs no op

c) lvextend --fs resize LV + cryptsetup resize
   lvextend extends lv
   lvextend extends crypt
   lvextend extends fs
   cryptsetup no op

d) lvextend --fs resize LV + cryptsetup resize + resize2fs
   lvextend extends lv
   lvextend extends crypt
   lvextend extends fs
   cryptsetup no op
   resize2fs no op

2. extend without --fs resize
-----------------------------

a) lvextend LV
   lvextend extends lv
   crypt untouched (remains smaller than lv)
   fs untouched (remains smaller than lv)

b) lvextend LV + resize2fs
   lvextend extends lv
   crypt untouched (remains smaller than lv)
   resize2fs no op

c) lvextend LV + cryptsetup resize
   lvextend extends lv
   cryptsetup extends crypt
   fs untouched (remains smaller than lv and crypt)

d) lvextend LV + cryptsetup resize + resize2fs
   lvextend extends lv
   cryptsetup extends crypt
   resize2fs extends fs

3. reduce with --fs resize
--------------------------

a) lvreduce --fs resize LV
   lvreduce reduces fs
   lvreduce reduces crypt
   lvreduce reduces lv

b) resize2fs + lvreduce --fs resize LV
   resize2fs reduces fs
   lvreduce reduces crypt
   lvreduce reduces lv

c) resize2fs + cryptsetup resize + lvreduce --fs resize LV
   resize2fs reduces fs
   cryptsetup reduces crypt
   # OLD lvreduce tries reducing crypt (a no op that could be skipped)
   lvreduce reduces lv

4. reduce without --fs resize
-----------------------------

a) lvreduce LV
   lvreduce fails and suggests --fs resize

b) resize2fs + lvreduce LV
   resize2fs reduces fs
   # OLD lvreduce reduces crypt (FIXME: fail and suggest --fs resize)
   # OLD lvreduce reduces lv
   lvreduce fails and suggests --fs resize

c) resize2fs + cryptsetup resize + lvreduce LV
   resize2fs reduces fs
   cryptsetup reduces crypt
   # OLD lvreduce tries reducing crypt (a no op that could be skipped)
   lvreduce reduces lv


before/after examples of changes
--------------------------------


3.c (old)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ cryptsetup resize --size 1044480 lvcr

$ lvreduce -L512M --fs resize test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
cryptsetup resize 1044480 sectors /dev/dm-3
cryptsetup done
  Size of logical volume test/lv changed from 640.00 MiB (160 extents) to 512.00 MiB (128 extents).
  Logical volume test/lv successfully resized.

3.c (new)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ cryptsetup resize --size 1044480 lvcr

$ lvreduce -L512M --fs resize test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
  crypt device is already reduced to 534773760 bytes.
  Size of logical volume test/lv changed from 640.00 MiB (160 extents) to 512.00 MiB (128 extents).
  Logical volume test/lv successfully resized.

4.b (old)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ lvreduce -L512M test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
cryptsetup resize 1044480 sectors /dev/dm-3
cryptsetup done
  Size of logical volume test/lv changed from 640.00 MiB (160 extents) to 512.00 MiB (128 extents).
  Logical volume test/lv successfully resized.

4.b (new)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ lvreduce -L512M test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
  crypt reduce is required (see --resizefs or cryptsetup resize.)

4.c (old)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ cryptsetup resize --size 1044480 lvcr

$ lvreduce -L512M test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
cryptsetup resize 1044480 sectors /dev/dm-3
cryptsetup done
  Size of logical volume test/lv changed from 640.00 MiB (160 extents) to 512.00 MiB (128 extents).
  Logical volume test/lv successfully resized.

4.c (new)
---------

lvcreate -n lv -L 640M test
echo 93R4P4pIqAH8 | cryptsetup luksFormat -i1 --type luks1 /dev/test/lv
echo 93R4P4pIqAH8 | cryptsetup luksOpen /dev/test/lv lvcr
mkfs.ext4 /dev/mapper/lvcr

$ resize2fs /dev/mapper/lvcr 522240k
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mapper/lvcr to 130560 (4k) blocks.
The filesystem on /dev/mapper/lvcr is now 130560 (4k) blocks long.

$ cryptsetup resize --size 1044480 lvcr

$ lvreduce -L512M test/lv
  File system found on crypt device /dev/dm-3 on LV test/lv.
  File system size 534773760b is adjusted for crypt data offset 2097152b.
  File system ext4+crypto_LUKS found on test/lv.
  File system size (510.00 MiB) is equal to the requested size (510.00 MiB).
  File system reduce is not needed, skipping.
  crypt device is already reduced to 534773760 bytes.
  Size of logical volume test/lv changed from 640.00 MiB (160 extents) to 512.00 MiB (128 extents).
  Logical volume test/lv successfully resized.


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 David Teigland 2023-01-18 22:44:15 UTC
Corey pointed out these unexpected cryptsetup resize commands in some tests he was running:

[root@virt-557 ~]# lvextend --yes -L +808M resize_matrix/resize_lv 
  Size of logical volume resize_matrix/resize_lv changed from <31.58 GiB (8084 extents) to <32.37 GiB (8286 extents).
  Logical volume resize_matrix/resize_lv successfully resized.
[root@virt-557 ~]# lvreduce --yes -L -560M resize_matrix/resize_lv 
  File system found on crypt device /dev/dm-3 on LV resize_matrix/resize_lv.
  File system size 34150023168b is adjusted for crypt data offset 16777216b.
  File system ext4+crypto_LUKS found on resize_matrix/resize_lv.
  File system size (29.98 GiB) is smaller than the requested size (31.80 GiB).
  File system reduce is not needed, skipping.
cryptsetup resize 66699264 sectors /dev/dm-3
Enter passphrase for /dev/mapper/resize_matrix-resize_lv:

Comment 3 David Teigland 2023-01-19 20:35:55 UTC
*** Bug 2162305 has been marked as a duplicate of this bug. ***

Comment 4 Jonathan Earl Brassow 2023-01-24 03:34:12 UTC
ITR? DTM?

Comment 6 Corey Marthaler 2023-02-14 14:35:24 UTC
Marking Verified:Fixed in the latest build.

kernel-5.14.0-252.el9    BUILT: Wed Feb  1 03:30:10 PM CET 2023
lvm2-2.03.17-6.el9    BUILT: Thu Feb  9 09:52:52 PM CET 2023
lvm2-libs-2.03.17-6.el9    BUILT: Thu Feb  9 09:52:52 PM CET 2023


The example in comment #1 no longer prompts for (or requires) a LUKS password when the lvreduce command determines that the filesystem is not to be reduced.

[root@virt-008 ~]# lvextend --yes -L +870M resize_matrix/resize_lv 
  Rounding size to boundary between physical extents: 872.00 MiB.
  Size of logical volume resize_matrix/resize_lv changed from 30.00 GiB (7680 extents) to 30.85 GiB (7898 extents).
  Logical volume resize_matrix/resize_lv successfully resized.

[root@virt-008 ~]# lvreduce --yes -L -543M resize_matrix/resize_lv
  Rounding size to boundary between physical extents: 540.00 MiB.
  File system found on crypt device /dev/dm-3 on LV resize_matrix/resize_lv.
  File system size 32543604736b is adjusted for crypt data offset 16777216b.
  File system ext4+crypto_LUKS found on resize_matrix/resize_lv.
  File system size (29.98 GiB) is smaller than the requested size (<30.31 GiB).
  File system reduce is not needed, skipping.
  crypt device is already reduced to 32195477504 bytes.
  Size of logical volume resize_matrix/resize_lv changed from 30.85 GiB (7898 extents) to 30.32 GiB (7763 extents).
  Logical volume resize_matrix/resize_lv successfully resized.

[root@virt-008 ~]# lvreduce --yes -L -543M --fs resize resize_matrix/resize_lv
  Rounding size to boundary between physical extents: 540.00 MiB.
  File system found on crypt device /dev/dm-3 on LV resize_matrix/resize_lv.
  File system size 32891731968b is adjusted for crypt data offset 16777216b.
  File system ext4+crypto_LUKS found on resize_matrix/resize_lv.
  File system size (29.98 GiB) is smaller than the requested size (30.63 GiB).
  File system reduce is not needed, skipping.
  crypt device is already reduced to 32195477504 bytes.
  Size of logical volume resize_matrix/resize_lv changed from <31.18 GiB (7981 extents) to <30.65 GiB (7846 extents).
  Logical volume resize_matrix/resize_lv successfully resized.

Comment 9 Corey Marthaler 2023-02-16 17:27:40 UTC
LUKS + LVM resize regression testing is complete on the latest build. Marking VERIFIED.

kernel-5.14.0-252.el9    BUILT: Wed Feb  1 03:30:10 PM CET 2023
lvm2-2.03.17-7.el9    BUILT: Thu Feb 16 03:24:54 PM CET 2023
lvm2-libs-2.03.17-7.el9    BUILT: Thu Feb 16 03:24:54 PM CET 2023
lvm2-dbusd-2.03.17-7.el9    BUILT: Thu Feb 16 03:25:07 PM CET 2023


    luks_ext4_active_reduce_no_resizefs --  Create an Encrypted LUKs EXT4 filesysem and attempt to reduce the size while ACTIVE but w/o --fs resize 
    luks_ext4_active_reduce_ignorefs --  Create an Encrypted LUKs EXT4 filesysem and reduce the size while ACTIVE, using --fs ignore which could potentially cause corruption
    luks_ext4_active_reduce_resizefs --  Create an Encrypted LUKs EXT4 filesysem and reduce the size while ACTIVE, using --fs resize and --resizefs (bug 2157591) 
    luks_ext4_inactive_reduce_no_resizefs --  Create an Encrypted LUKs EXT4 filesysem and attempt to reduce the size while INACTIVE w/o --fs resize 
    luks_ext4_active_reduce_wo_touching_fs_space --  Create an Encrypted LUKs EXT4 filesysem, extend the volume, and then reduce the space wo touching the filesystem area while ACTIVE (bug 2157591|2162144) 
    luks_ext4_inactive_reduce_wo_touching_fs_space --  Create an Encrypted LUKs EXT4 filesysem, extend the volume, and then reduce the space wo touching the filesystem area while INACTIVE 
    luks_no_fs_active_reduce --  Create a variety of Encrypted LUKS LV types and reduce the size while ACTIVE and w/o a filesystem 
    luks_no_fs_inactive_reduce --  Create a variety of Encrypted LUKS LV types and attempt to reduce the size while INACTIVE and w/o a filesystem 
    luks_ext4_active_extend_no_resizefs --  Create an Encrypted LUKs EXT4 filesysem and extend the size while ACTIVE w/o using the --fs resize flag 
    luks_ext4_inactive_extend_no_resizefs --  Create an Encrypted LUKs EXT4 filesysem and extend the size while INACTIVE w/o using the --fs resize flag 
    luks_no_fs_active_extend --  Create a variety of Encrypted LUKS LV types and extend the size while ACTIVE and w/o a filesystem 
    luks_no_fs_inactive_extend --  Create a variety of Encrypted LUKS LV types and attempt to extend the size while INACTIVE and w/o a filesystem 
    luks_no_fs_active_resizefs_extend --  Create a variety of Encrypted LUKS LV types and attempt to extend the size while ACTIVE and w/o a filesystem, but with the use of --fs resize 
    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 (bug 2165691) 
    luks_ext4_active_online_traditional_resizefs_fsresize_fsignore_extend --  Create an Encrypted LUKs EXT4 filesystem on a variety of LV types and extend the size while ACTIVE and ONLINE, using the traditional --resizefs flag as well as --fs resize, and --fs ignore

Comment 11 errata-xmlrpc 2023-05-09 08:23:51 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:2544

Comment 12 Red Hat Bugzilla 2023-09-19 04:32:37 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


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