]> git.baikalelectronics.ru Git - kernel.git/commit
block: Try to handle busy underlying device on discard
authorJan Kara <jack@suse.cz>
Mon, 22 Feb 2021 09:48:09 +0000 (10:48 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 5 Mar 2021 18:29:26 +0000 (11:29 -0700)
commit8bc6caf20a28f58f3d1f00c46bbcbec3660c9f4c
treec6d98f1c5f06f7e4bdbfe11d2eff27624e66a3df
parent8475918608ac9e8b116ee857088a16e6f48c0d64
block: Try to handle busy underlying device on discard

Commit 9a568a57976a ("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).

Link: https://bugzilla.kernel.org/show_bug.cgi?id=211167
Fixes: 9a568a57976a ("block: Do not discard buffers under a mounted filesystem")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/block_dev.c