Regression: lvremove fails to remove all LVs if one is in use

Bug #2054131 reported by Gunnar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lvm2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

When attempting to remove multiple logical volumes (LVs) with the `lvremove -y` command, if any of the LVs are in use, the command fails but still causes the LVs to disappear from the system. However, these LVs reappear upon reactivating the volume group (VG), indicating they were not properly removed. This behavior can lead to confusion and inconsistent state of the VG and LVs.

The expected behavior, observed in previous versions, was to fully remove all not-in-use LVs while leaving the ones that are in use unchanged. This regression in functionality can disrupt workflows that rely on lvremove to accurately reflect the state of LVs post-operation, leading to administrative confusion and potential data management issues.

Environments:
 Affected:
  - LVM versions:
   LVM version: 2.03.16(2) (2022-05-18)
   Library version: 1.02.185 (2022-05-18)
   Driver version: 4.48.0
  - Operating System: Ubuntu 23.10

 Unaffected:
  - LVM versions:
   LVM version: 2.03.11(2) (2021-01-08)
   Library version: 1.02.175 (2021-01-08)
   Driver version: 4.48.0
  - Operating System: Ubuntu 22.04

Script to Reproduce:
```
#!/bin/bash
IFS=$'\n\t'
set -euox pipefail

echo ==== Setup
cd $(mktemp -d)
dd if=/dev/zero of=bug.img bs=1G count=1
loop=$(losetup -fP bug.img --show)
pvcreate $loop
vgcreate bug_vg $loop
lvcreate -L 4M -n p1 bug_vg
lvcreate -L 4M -n p2 bug_vg
lvcreate -L 4M -n p3 bug_vg
mkfs.fat /dev/mapper/bug_vg-p2
mkdir x
mount /dev/mapper/bug_vg-p2 x

echo ==== Setup done, bug_vg p2 is now in use

lsblk $loop

set +e
# this command exits with exit code 5
lvremove -y /dev/bug_vg/*
echo $?
set -e

lsblk $loop
echo ==== Activate the vg again
vgchange -aay bug_vg
echo ==== Observe removed LVs are back
lsblk $loop
umount x
rmdir x

echo ==== bug_vg p2 is no longer in use, remove again

lvremove -y /dev/bug_vg/*

lsblk $loop
echo ==== Activate the vg again
vgchange -aay bug_vg
echo ==== Observe removed LVs stay gone this time
lsblk $loop

echo cleanup

vgremove bug_vg
pvremove $loop
losetup -d $loop
rm bug.img
```

Tags: lvm lvm2 lvremove
Revision history for this message
Gunnar (gunnargu) wrote :
Revision history for this message
Gunnar (gunnargu) wrote :
Gunnar (gunnargu)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.