mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-18 16:56:09 +07:00
block: Try to handle busy underlying device on discard
commit 56887cffe946bb0a90c74429fa94d6110a73119d upstream. Commit384d87ef2c
("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:384d87ef2c
("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a534778492
commit
d44c9780ed
@ -123,12 +123,21 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode,
|
||||
err = bd_prepare_to_claim(bdev, claimed_bdev,
|
||||
truncate_bdev_range);
|
||||
if (err)
|
||||
return err;
|
||||
goto invalidate;
|
||||
}
|
||||
truncate_inode_pages_range(bdev->bd_inode->i_mapping, lstart, lend);
|
||||
if (claimed_bdev)
|
||||
bd_abort_claiming(bdev, claimed_bdev, truncate_bdev_range);
|
||||
return 0;
|
||||
|
||||
invalidate:
|
||||
/*
|
||||
* Someone else has handle exclusively open. Try invalidating instead.
|
||||
* The 'end' argument is inclusive so the rounding is safe.
|
||||
*/
|
||||
return invalidate_inode_pages2_range(bdev->bd_inode->i_mapping,
|
||||
lstart >> PAGE_SHIFT,
|
||||
lend >> PAGE_SHIFT);
|
||||
}
|
||||
EXPORT_SYMBOL(truncate_bdev_range);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user