On Tue, Feb 16, 2021 at 02:38:49PM +0100, Jan Kara wrote: > Apparently there are several userspace programs that depend on being > able to call BLKDISCARD ioctl without the ability to grab bdev > exclusively - namely FUSE filesystems have the device open without > O_EXCL (the kernel has the bdev open with O_EXCL) so the commit breaks > fstrim(8) for such filesystems. Also LVM when shrinking LV opens PV and > discards ranges released from LV but that PV may be already open > exclusively by someone else (see bugzilla link below for more details). > > This reverts commit 384d87ef2c954fc58e6c5fd8253e4a1984f5fe02. I think that is a bad idea. We fixed the problem for a reason. I think the right fix is to just do nothing if the device hasn't been opened with O_EXCL and can't be reopened with it, just don't do anything but also don't return an error. After all discard and thus BLKDISCARD is purely advisory.