Commit 384d87ef2c95 ("block: Do not discard buffers under a mounted
filesystem") made paths issuing discard or zeroout requests to the
underlying device try to grab block device in exclusive mode. If that
failed we returned EBUSY to userspace. This however caused unexpected
fallout in userspace where e.g. FUSE filesystems issue discard requests
from userspace daemons although the device is open exclusively by the
kernel. Also shrinking of logical volume by LVM issues discard requests
to a device which may be claimed exclusively because there's another LV
on the same PV. So to avoid these userspace regressions, fall back to
invalidate_inode_pages2_range() instead of returning EBUSY to userspace
and return EBUSY only of that call fails as well (meaning that there's
indeed someone using the particular device range we are trying to
discard).
Hmm.. The referenced commit [1] is in 5.11.0-11 (which is based on stable 5.11.7).
[1] 1f1dc991e3ea10f 4c3fd8a7fb
commit 73dfbeb7fdb1c9f
Author: Jan Kara <email address hidden>
Date: Mon Feb 22 10:48:09 2021 +0100
block: Try to handle busy underlying device on discard
BugLink: https:/ /bugs.launchpad .net/bugs/ 1919492
commit 56887cffe946bb0 a90c74429fa94d6 110a73119d upstream.
Commit 384d87ef2c95 ("block: Do not discard buffers under a mounted inode_pages2_ range() instead of returning EBUSY to userspace
filesystem") made paths issuing discard or zeroout requests to the
underlying device try to grab block device in exclusive mode. If that
failed we returned EBUSY to userspace. This however caused unexpected
fallout in userspace where e.g. FUSE filesystems issue discard requests
from userspace daemons although the device is open exclusively by the
kernel. Also shrinking of logical volume by LVM issues discard requests
to a device which may be claimed exclusively because there's another LV
on the same PV. So to avoid these userspace regressions, fall back to
invalidate_
and return EBUSY only of that call fails as well (meaning that there's
indeed someone using the particular device range we are trying to
discard).