lvresize in test mode sends BLKDISCARD to SSD block devices, this will result in the file system corruption
Hello List,
I found a bug for lvresize command, this issue can be reproduced by lvm2-2.02.178 code base. The reproduce steps are as below,
1) create a LV on a SSD based partition, then format this LV with ext4 file system, and mount this LV. e.g.
linux-cy2k:/ # lsblk
...
sdc 8:32 0 37.3G 0 disk ??sdc1 8:33 0 2G 0 part [SWAP] ??sdc2 8:34 0 14.7G 0 part ? ??cluster--vg1-test--lv 254:20 0 14G 0 lvm /mnt/ext4 <<= this LV ??sdc3 8:35 0 20.6G 0 part
2) enable issue discards to a logical volumes's underlying physical volume via edit "/etc/lvm/lvm.conf" file. e.g.
linux-cy2k:/ # vi /etc/lvm/lvm.conf
set "issue_discards = 1"
3) run lvresize command in test mode.
e.g.
inux-cy2k:/ # lvresize -v -n -L -10GB /dev/cluster-vg1/test-lv --test
4) unmount this LV, then mount this LV again.
You will probably encounter the file system on this LV is corrupted. e.g.
linux-cy2k:~ # mount /dev/cluster-vg1/test-lv /mnt/ext4/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/cluster--vg1-test--lv,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try dmesg | tail or so.
linux-cy2k:~ # dmesg
[3711112.342424] JBD2: no valid journal superblock found [3711112.342429] EXT4-fs (dm-20): error loading journal
To summarize, I think this behavior is a bug and is very dangerous,
the command in test mode should not send BLKDISCARD to the underlying block device, the BLKDISCARD command will make the related sectors on the block device be trimmed (lost data).
Thanks
Gang
Dne 22.6.2018 v 11:31 Gang He napsal(a):
Quoted 4 lines
Hello List,
I found a bug for lvresize command, this issue can be reproduced by lvm2-2.02.178 code base. The reproduce steps are as below,
Hi
Good catch - yep - it seem in this case ioctl operation are flowing to device even in test mode.
Please create BZ for lvm2 on this issue.
Zdenek
Quoted 47 lines
1) create a LV on a SSD based partition, then format this LV with ext4 file system, and mount this LV. e.g.
linux-cy2k:/ # lsblk
...sdc 8:32 0 37.3G 0 disk ??sdc1 8:33 0 2G 0 part [SWAP] ??sdc2 8:34 0 14.7G 0 part ? ??cluster--vg1-test--lv 254:20 0 14G 0 lvm /mnt/ext4 <<= this LV ??sdc3 8:35 0 20.6G 0 part2) enable issue discards to a logical volumes's underlying physical volume via edit "
/etc/lvm/lvm.conf" file. e.g.
linux-cy2k:/ # vi/etc/lvm/lvm.conf
set "issue_discards= 1"3) run lvresize command in test mode.
e.g.
inux-cy2k:/ # lvresize -v -n -L -10GB/dev/cluster-vg1/test-lv--test4) unmount this LV, then mount this LV again.
You will probably encounter the file system on this LV is corrupted. e.g.
linux-cy2k:~ # mount/dev/cluster-vg1/test-lv/mnt/ext4/
mount: wrong fs type, bad option, bad superblock on/dev/mapper/cluster--vg1-test--lv,
missing codepage or helper program, or other errorIn some cases useful info is found in syslog - try dmesg | tail or so.
linux-cy2k:~ # dmesg
[3711112.342424] JBD2: no valid journal superblock found [3711112.342429] EXT4-fs (dm-20): error loading journalTo summarize, I think this behavior is a bug and is very dangerous,
the command in test mode should not send BLKDISCARD to the underlying block device, the BLKDISCARD command will make the related sectors on the block device be trimmed (lost data).Thanks
Gang--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel
Hello Zdenek,
Thank for your quick response.
I opened a bug in redhat bugzilla for this issue.
The bug link is https://bugzilla.redhat.com/show_bug.cgi?id=1595500
Thanks
Gang
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 6/22/2018 at 9:34 pm, in message
<[email protected]>, Zdenek Kabelac
Quoted 73 lines · <[email protected]> wrote:
Dne 22.6.2018 v 11:31 Gang He napsal(a):
Quoted 3 lines
Hello List,
I found a bug for lvresize command, this issue can be reproduced by
lvm2-2.02.178 code base.
Quoted 1 line
The reproduce steps are as below,
Hi
Good catch - yep - it seem in this case ioctl operation are flowing to device
even in test mode.Please create BZ for lvm2 on this issue.
Zdenek
Quoted 1 line
1) create a LV on a SSD based partition, then format this LV with ext4 file
system, and mount this LV.
Quoted 7 lines
e.g.
linux-cy2k:/ # lsblk
...sdc 8:32 0 37.3G 0 disk ??sdc1 8:33 0 2G 0 part [SWAP] ??sdc2 8:34 0 14.7G 0 part ? ??cluster--vg1-test--lv 254:20 0 14G 0 lvm /mnt/ext4 <<= thisLV
Quoted 3 lines
??sdc3 8:35 0 20.6G 0 part
2) enable issue discards to a logical volumes's underlying physical volume
via edit "
/etc/lvm/lvm.conf" file.Quoted 8 lines
e.g.
linux-cy2k:/ # vi/etc/lvm/lvm.conf
set "issue_discards= 1"3) run lvresize command in test mode.
e.g.
inux-cy2k:/ # lvresize -v -n -L -10GB/dev/cluster-vg1/test-lv--testQuoted 5 lines
4) unmount this LV, then mount this LV again.
You will probably encounter the file system on this LV is corrupted. e.g.
linux-cy2k:~ # mount/dev/cluster-vg1/test-lv/mnt/ext4/
mount: wrong fs type, bad option, bad superblock on
/dev/mapper/cluster--vg1-test--lv,Quoted 11 lines
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try dmesg | tail or so.
linux-cy2k:~ # dmesg
[3711112.342424] JBD2: no valid journal superblock found [3711112.342429] EXT4-fs (dm-20): error loading journalTo summarize, I think this behavior is a bug and is very dangerous, the command in test mode should not send BLKDISCARD to the underlying block
device,
Quoted 1 line
the BLKDISCARD command will make the related sectors on the block device be
trimmed (lost data).
Quoted 11 lines
Thanks
Gang--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel