Bug 2081808

Summary: lvremove general protection fault with record_lvs_history turned on
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
lvm2 sub component: Thin Provisioning QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, thornber, zkabelac
Version: 9.1Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.16-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2081809 (view as bug list) Environment:
Last Closed: 2022-11-15 11:20:43 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:    
Bug Blocks: 2081809    

Description Corey Marthaler 2022-05-04 16:57:35 UTC
Description of problem:
kernel-5.14.0-70.13.1.el9_0    BUILT: Thu Apr 14 11:16:36 AM CDT 2022
lvm2-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022
lvm2-libs-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022

[root@hayes-02 ~]# lvs -a -o +devices
  LV              VG            Attr       LSize Pool Origin  Data%  Meta%  Move Log Cpy%Sync Convert Devices      
  POOL            snapper_thinp twi-aot--- 1.00g              18.19  15.62                            POOL_tdata(0)
  [POOL_tdata]    snapper_thinp Twi-ao---- 1.00g                                                      /dev/sdb1(1) 
  [POOL_tmeta]    snapper_thinp ewi-ao---- 4.00m                                                      /dev/sdh1(0) 
  [lvol0_pmspare] snapper_thinp ewi------- 4.00m                                                      /dev/sdb1(0) 
  origin          snapper_thinp Vwi-a-t--- 1.00g POOL         16.18                                                
  other1          snapper_thinp Vwi-a-t--- 1.00g POOL         0.00                                                 
  other2          snapper_thinp Vwi-a-t--- 1.00g POOL         0.00                                                 
  other3          snapper_thinp Vwi-a-t--- 1.00g POOL         0.00                                                 
  other4          snapper_thinp Vwi-a-t--- 1.00g POOL         0.00                                                 
  other5          snapper_thinp Vwi-a-t--- 1.00g POOL         0.00                                                 
  stack10         snapper_thinp Vwi-aot--- 1.00g POOL stack9  16.18                                                
  stack11         snapper_thinp Vwi-aot--- 1.00g POOL stack10 16.18                                                
  stack12         snapper_thinp Vwi-aot--- 1.00g POOL stack11 16.18                                                
  stack3          snapper_thinp Vwi-aot--- 1.00g POOL         16.18                                                
  stack4          snapper_thinp Vwi-aot--- 1.00g POOL stack3  16.18                                                
  stack5          snapper_thinp Vwi-aot--- 1.00g POOL stack4  16.18                                                
  stack6          snapper_thinp Vwi-aot--- 1.00g POOL stack5  16.18                                                
  stack7          snapper_thinp Vwi-aot--- 1.00g POOL stack6  16.18                                                
  stack8          snapper_thinp Vwi-aot--- 1.00g POOL stack7  16.18                                                
  stack9          snapper_thinp Vwi-aot--- 1.00g POOL stack8  16.18                                                
[root@hayes-02 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
Segmentation fault (core dumped)

May  4 11:37:14 hayes-02 kernel: traps: lvremove[2915] general protection fault ip:55fcce5c7006 sp:7ffe3136ccd0 error:0 in lvm[55fcce58e000+184000]


Core was generated by `lvremove --yes --select lv_name=stack1 || origin=stack1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  _do_lvs_with_info_and_status_single (cmd=0x55fcd0a19a30, lv=0x562d32596e493348, do_info=0, do_status=0, handle=0x55fcd0b7b658) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/reporter.c:165
165             if (lv_is_merging_origin(lv))
(gdb) bt
#0  _do_lvs_with_info_and_status_single (cmd=0x55fcd0a19a30, lv=0x562d32596e493348, do_info=0, do_status=0, handle=0x55fcd0b7b658) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/reporter.c:165
#1  0x000055fcce5d0e78 in _report_all_in_lv (do_lv_seg_status=<optimized out>, do_lv_info=<optimized out>, type=<optimized out>, lv=0x562d32596e493348, handle=0x55fcd0b7b658, cmd=0x55fcd0a19a30)
    at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/reporter.c:587
#2  report_for_selection (cmd=0x55fcd0a19a30, cmd@entry=0x0, parent_handle=parent_handle@entry=0x55fcd0b197b0, pv=pv@entry=0x0, vg=0x55fcd0b89370, vg@entry=0x0, lv=lv@entry=0x562d32596e493348)
    at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/reporter.c:685
#3  0x000055fcce5d21de in select_match_lv (lv=0x562d32596e493348, vg=0x0, handle=0x55fcd0b197b0, cmd=0x0) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/toollib.c:1844
#4  select_match_lv (cmd=cmd@entry=0x55fcd0a19a30, handle=handle@entry=0x55fcd0b197b0, vg=vg@entry=0x55fcd0b89370, lv=0x562d32596e493348) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/toollib.c:1835
#5  0x000055fcce5d06a9 in process_each_lv_in_vg (cmd=0x55fcd0a19a30, vg=0x55fcd0b89370, arg_lvnames=0x7ffe3136d490, tags_in=<optimized out>, stop_on_error=0, handle=0x55fcd0b197b0, check_single_lv=0x0, 
    process_single_lv=0x55fcce5d6f70 <lvremove_single>) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/toollib.c:3219
#6  0x000055fcce5d43f8 in _process_lv_vgnameid_list (process_single_lv=0x55fcce5d6f70 <lvremove_single>, check_single_lv=0x0, handle=0x55fcd0b197b0, arg_tags=0x7ffe3136d480, arg_lvnames=0x7ffe3136d460, 
    arg_vgnames=0x7ffe3136d470, vgnameids_to_process=0x7ffe3136d440, read_flags=1310720, cmd=0x55fcd0a19a30) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/toollib.c:3649
#7  process_each_lv (cmd=0x55fcd0a19a30, argc=<optimized out>, argv=<optimized out>, one_vgname=<optimized out>, one_lvname=<optimized out>, read_flags=<optimized out>, handle=0x55fcd0b197b0, 
    check_single_lv=<optimized out>, process_single_lv=<optimized out>) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/toollib.c:3806
#8  0x000055fcce5b80f8 in lvremove (cmd=<optimized out>, argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/lvremove.c:29
#9  0x000055fcce5b460b in lvm_run_command (cmd=<optimized out>, argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/lvmcmdline.c:3297
#10 0x000055fcce5b6211 in lvm2_main (argc=4, argv=0x7ffe3136d968) at /usr/src/debug/lvm2-2.03.14-4.el9.x86_64/tools/lvmcmdline.c:3826
#11 0x00007fc3d5a49e50 in __libc_start_call_main (main=main@entry=0x55fcce590d50 <main>, argc=argc@entry=4, argv=argv@entry=0x7ffe3136d968) at ../sysdeps/nptl/libc_start_call_main.h:58
#12 0x00007fc3d5a49efc in __libc_start_main_impl (main=0x55fcce590d50 <main>, argc=4, argv=0x7ffe3136d968, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe3136d958)
    at ../csu/libc-start.c:409
#13 0x000055fcce590e25 in _start ()


Version-Release number of selected component (if applicable):
kernel-5.14.0-70.13.1.el9_0    BUILT: Thu Apr 14 11:16:36 AM CDT 2022
lvm2-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022
lvm2-libs-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022


How reproducible:
Everytime

Comment 2 Corey Marthaler 2022-07-15 19:54:23 UTC
Fix verified in the latest rpms.

kernel-5.14.0-127.el9    BUILT: Sat Jul  9 06:54:36 AM CDT 2022
lvm2-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022
lvm2-libs-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022

[root@hayes-03 ~]# grep record_lvs_history /etc/lvm/lvm.conf 
        # Configuration option metadata/record_lvs_history.
        record_lvs_history = 1


SCENARIO - [snap_of_thin_snaps]
Create a snapshot and then attempt multiple levels of snaps of snaps

Making pool volume
lvcreate --yes  --thinpool POOL -L 1G --profile thin-performance --zero n --poolmetadatasize 4M snapper_thinp

Sanity checking pool device (POOL) metadata
thin_check /dev/mapper/snapper_thinp-meta_swap.635
examining superblock
examining devices tree
examining mapping tree
checking space map counts

Making origin volume
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n origin
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other1
  WARNING: Sum of all thin volume sizes (2.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other2
  WARNING: Sum of all thin volume sizes (3.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other3
  WARNING: Sum of all thin volume sizes (4.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other4
  WARNING: Sum of all thin volume sizes (5.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other5
  WARNING: Sum of all thin volume sizes (6.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Placing an xfs filesystem on origin volume
Mounting origin volume

Writing files to /mnt/origin
Checking files on /mnt/origin

syncing before snap creation...
Making snapshot of origin volume
lvcreate --yes  -y -k n -s /dev/snapper_thinp/origin -n stack1

Create a chain of snapshots of snapshots, mount and verify origin I/O exists
lvcreate --yes  -k n -s /dev/snapper_thinp/stack1 -n stack2
  WARNING: Sum of all thin volume sizes (8.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack2

lvcreate --yes  -k n -s /dev/snapper_thinp/stack2 -n stack3
  WARNING: Sum of all thin volume sizes (9.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack3

lvcreate --yes  -k n -s /dev/snapper_thinp/stack3 -n stack4
  WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack4

lvcreate --yes  -k n -s /dev/snapper_thinp/stack4 -n stack5
  WARNING: Sum of all thin volume sizes (11.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack5

lvcreate --yes  -k n -s /dev/snapper_thinp/stack5 -n stack6
  WARNING: Sum of all thin volume sizes (12.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack6

lvcreate --yes  -k n -s /dev/snapper_thinp/stack6 -n stack7
  WARNING: Sum of all thin volume sizes (13.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack7

lvcreate --yes  -k n -s /dev/snapper_thinp/stack7 -n stack8
  WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack8

lvcreate --yes  -k n -s /dev/snapper_thinp/stack8 -n stack9
  WARNING: Sum of all thin volume sizes (15.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack9

lvcreate --yes  -k n -s /dev/snapper_thinp/stack9 -n stack10
  WARNING: Sum of all thin volume sizes (16.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack10

lvcreate --yes  -k n -s /dev/snapper_thinp/stack10 -n stack11
  WARNING: Sum of all thin volume sizes (17.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack11

lvcreate --yes  -k n -s /dev/snapper_thinp/stack11 -n stack12
  WARNING: Sum of all thin volume sizes (18.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Checking files on /mnt/stack12

Now break the chain connection to the origin by removing the 1st and 2nd snap devices, and verify origin I/O continues to exist in the remaining snapshots
lvremove --yes --select 'lv_name=stack1 || origin=stack1'

Break up the remaing chain by verifying I/O and removing every other stacked snap
Checking files on /mnt/stack3

Removing stack4 and verifying I/0 on stack5
Removing snap volume snapper_thinp/stack4
lvremove -f /dev/snapper_thinp/stack4
Checking files on /mnt/stack5

Removing stack6 and verifying I/0 on stack7
Removing snap volume snapper_thinp/stack6
lvremove -f /dev/snapper_thinp/stack6
Checking files on /mnt/stack7

Removing stack8 and verifying I/0 on stack9
Removing snap volume snapper_thinp/stack8
lvremove -f /dev/snapper_thinp/stack8
Checking files on /mnt/stack9

Removing stack10 and verifying I/0 on stack11
Removing snap volume snapper_thinp/stack10
lvremove -f /dev/snapper_thinp/stack10
Checking files on /mnt/stack11

Removing stack12 and verifying I/0 on stack13
Removing snap volume snapper_thinp/stack12
lvremove -f /dev/snapper_thinp/stack12

Clean up the remaining snaps in the broken chain
Removing snap volume snapper_thinp/stack3
lvremove -f /dev/snapper_thinp/stack3
Removing snap volume snapper_thinp/stack5
lvremove -f /dev/snapper_thinp/stack5
Removing snap volume snapper_thinp/stack7
lvremove -f /dev/snapper_thinp/stack7
Removing snap volume snapper_thinp/stack9
lvremove -f /dev/snapper_thinp/stack9
Removing snap volume snapper_thinp/stack11
lvremove -f /dev/snapper_thinp/stack11
Removing thin origin and other virtual thin volumes
Removing pool snapper_thinp/POOL

Comment 5 Corey Marthaler 2022-07-27 21:24:12 UTC
Fix verified in the latest kernel/lvm2 rpms.

kernel-5.14.0-131.el9    BUILT: Mon Jul 18 02:51:09 PM CDT 2022
lvm2-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022
lvm2-libs-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022



[root@hayes-03 tmp]# grep record_lvs_history /etc/lvm/lvm.conf 
        # Configuration option metadata/record_lvs_history.
        record_lvs_history = 1



SCENARIO - [snap_of_thin_snaps]
Create a snapshot and then attempt multiple levels of snaps of snaps

Making pool volume
lvcreate --yes  --thinpool POOL -L 1G  --zero n --poolmetadatasize 4M snapper_thinp

Sanity checking pool device (POOL) metadata
thin_check /dev/mapper/snapper_thinp-meta_swap.401
examining superblock
examining devices tree
examining mapping tree
checking space map counts

Making origin volume
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n origin
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other1
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other2
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other3
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other4
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other5
Placing an xfs filesystem on origin volume
Mounting origin volume

Writing files to /mnt/origin
Checking files on /mnt/origin

syncing before snap creation...
Making snapshot of origin volume
lvcreate --yes  -y -k n -s /dev/snapper_thinp/origin -n stack1

Create a chain of snapshots of snapshots, mount and verify origin I/O exists
lvcreate --yes  -k n -s /dev/snapper_thinp/stack1 -n stack2
Checking files on /mnt/stack2

lvcreate --yes  -k n -s /dev/snapper_thinp/stack2 -n stack3
Checking files on /mnt/stack3

lvcreate --yes  -k n -s /dev/snapper_thinp/stack3 -n stack4
Checking files on /mnt/stack4

lvcreate --yes  -k n -s /dev/snapper_thinp/stack4 -n stack5
Checking files on /mnt/stack5

lvcreate --yes  -k n -s /dev/snapper_thinp/stack5 -n stack6
Checking files on /mnt/stack6

lvcreate --yes  -k n -s /dev/snapper_thinp/stack6 -n stack7
Checking files on /mnt/stack7

lvcreate --yes  -k n -s /dev/snapper_thinp/stack7 -n stack8
Checking files on /mnt/stack8

lvcreate --yes  -k n -s /dev/snapper_thinp/stack8 -n stack9
Checking files on /mnt/stack9

lvcreate --yes  -k n -s /dev/snapper_thinp/stack9 -n stack10
Checking files on /mnt/stack10

lvcreate --yes  -k n -s /dev/snapper_thinp/stack10 -n stack11
Checking files on /mnt/stack11

lvcreate --yes  -k n -s /dev/snapper_thinp/stack11 -n stack12
Checking files on /mnt/stack12

Now break the chain connection to the origin by removing the 1st and 2nd snap devices, and verify origin I/O continues to exist in the remaining snapshots
lvremove --yes --select 'lv_name=stack1 || origin=stack1'

Break up the remaing chain by verifying I/O and removing every other stacked snap
Checking files on /mnt/stack3

Removing stack4 and verifying I/0 on stack5
Removing snap volume snapper_thinp/stack4
lvremove -f /dev/snapper_thinp/stack4
Checking files on /mnt/stack5

Removing stack6 and verifying I/0 on stack7
Removing snap volume snapper_thinp/stack6
lvremove -f /dev/snapper_thinp/stack6
Checking files on /mnt/stack7

Removing stack8 and verifying I/0 on stack9
Removing snap volume snapper_thinp/stack8
lvremove -f /dev/snapper_thinp/stack8
Checking files on /mnt/stack9

Removing stack10 and verifying I/0 on stack11
Removing snap volume snapper_thinp/stack10
lvremove -f /dev/snapper_thinp/stack10
Checking files on /mnt/stack11

Removing stack12 and verifying I/0 on stack13
Removing snap volume snapper_thinp/stack12
lvremove -f /dev/snapper_thinp/stack12

Clean up the remaining snaps in the broken chain
Removing snap volume snapper_thinp/stack3
lvremove -f /dev/snapper_thinp/stack3
Removing snap volume snapper_thinp/stack5
lvremove -f /dev/snapper_thinp/stack5
Removing snap volume snapper_thinp/stack7
lvremove -f /dev/snapper_thinp/stack7
Removing snap volume snapper_thinp/stack9
lvremove -f /dev/snapper_thinp/stack9
Removing snap volume snapper_thinp/stack11
lvremove -f /dev/snapper_thinp/stack11
Removing thin origin and other virtual thin volumes
Removing pool snapper_thinp/POOL

Comment 7 errata-xmlrpc 2022-11-15 11:20:43 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-2022:8358