On 2020/8/4 22:37, Johannes Thumshirn wrote: > On 04/08/2020 16:34, Coly Li wrote: >> On 2020/8/4 22:31, Johannes Thumshirn wrote: >>> On 04/08/2020 16:23, Coly Li wrote: >>>> This is the procedure to reproduce the panic, >>>> # modprobe scsi_debug delay=0 dev_size_mb=2048 max_queue=1 >>>> # losetup -f /dev/nvme0n1 --direct-io=on >>>> # blkdiscard /dev/loop0 -o 0 -l 0x200 >>> >>> losetup -f /dev/sdX isn't it? >>> >> >> In my case, I use a NVMe SSD as the backing device of the loop device. >> Because I don't have a scsi lun. >> >> And loading scsi_debug module seems necessary, otherwise the discard >> process just hang and I cannot see the kernel panic (I don't know why yet). > > OK, now that's highly interesting. Does it also happen if you back loop with > a file? loop_config_discard() has different cases for the different backing > devices/files. S > No, for a file backing, q->limits.discard_granularity is set to inode->i_sb->s_blocksize. And the encrypted loop device does not support discard.
Such issue just only happens on a device backing loop device which announces supporting discard. Without Ming's fix to loop device driver, discard on LBA 0 will trigger the BUG() panic in my setup (Maybe it is more easier to trigger this BUG() panic with scsi lun). Coly Li