mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
block: move bdev_mark_dead out of disk_check_media_change
disk_check_media_change is mostly called from ->open where it makes little sense to mark the file system on the device as dead, as we are just opening it. So instead of calling bdev_mark_dead from disk_check_media_change move it into the few callers that are not in an open instance. This avoid calling into bdev_mark_dead and thus taking s_umount with open_mutex held. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231017184823.1383356-4-hch@lst.de Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
51b4cb4f3e
commit
6e57236ed6
@ -1019,14 +1019,13 @@ void bdev_mark_dead(struct block_device *bdev, bool surprise)
|
|||||||
|
|
||||||
invalidate_bdev(bdev);
|
invalidate_bdev(bdev);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_DASD_MODULE
|
|
||||||
/*
|
/*
|
||||||
* Drivers should not use this directly, but the DASD driver has historically
|
* New drivers should not use this directly. There are some drivers however
|
||||||
* had a shutdown to offline mode that doesn't actually remove the gendisk
|
* that needs this for historical reasons. For example, the DASD driver has
|
||||||
* that otherwise looks a lot like a safe device removal.
|
* historically had a shutdown to offline mode that doesn't actually remove the
|
||||||
|
* gendisk that otherwise looks a lot like a safe device removal.
|
||||||
*/
|
*/
|
||||||
EXPORT_SYMBOL_GPL(bdev_mark_dead);
|
EXPORT_SYMBOL_GPL(bdev_mark_dead);
|
||||||
#endif
|
|
||||||
|
|
||||||
void sync_bdevs(bool wait)
|
void sync_bdevs(bool wait)
|
||||||
{
|
{
|
||||||
|
@ -266,11 +266,8 @@ static unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
|
|||||||
* disk_check_media_change - check if a removable media has been changed
|
* disk_check_media_change - check if a removable media has been changed
|
||||||
* @disk: gendisk to check
|
* @disk: gendisk to check
|
||||||
*
|
*
|
||||||
* Check whether a removable media has been changed, and attempt to free all
|
* Returns %true and marks the disk for a partition rescan whether a removable
|
||||||
* dentries and inodes and invalidates all block device page cache entries in
|
* media has been changed, and %false if the media did not change.
|
||||||
* that case.
|
|
||||||
*
|
|
||||||
* Returns %true if the media has changed, or %false if not.
|
|
||||||
*/
|
*/
|
||||||
bool disk_check_media_change(struct gendisk *disk)
|
bool disk_check_media_change(struct gendisk *disk)
|
||||||
{
|
{
|
||||||
@ -278,12 +275,11 @@ bool disk_check_media_change(struct gendisk *disk)
|
|||||||
|
|
||||||
events = disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE |
|
events = disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE |
|
||||||
DISK_EVENT_EJECT_REQUEST);
|
DISK_EVENT_EJECT_REQUEST);
|
||||||
if (!(events & DISK_EVENT_MEDIA_CHANGE))
|
if (events & DISK_EVENT_MEDIA_CHANGE) {
|
||||||
return false;
|
|
||||||
|
|
||||||
bdev_mark_dead(disk->part0, true);
|
|
||||||
set_bit(GD_NEED_PART_SCAN, &disk->state);
|
set_bit(GD_NEED_PART_SCAN, &disk->state);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(disk_check_media_change);
|
EXPORT_SYMBOL(disk_check_media_change);
|
||||||
|
|
||||||
|
@ -1760,8 +1760,10 @@ static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
|
|||||||
/* invalidate the buffer track to force a reread */
|
/* invalidate the buffer track to force a reread */
|
||||||
BufferDrive = -1;
|
BufferDrive = -1;
|
||||||
set_bit(drive, &fake_change);
|
set_bit(drive, &fake_change);
|
||||||
if (disk_check_media_change(disk))
|
if (disk_check_media_change(disk)) {
|
||||||
|
bdev_mark_dead(disk->part0, true);
|
||||||
floppy_revalidate(disk);
|
floppy_revalidate(disk);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -3215,8 +3215,10 @@ static int invalidate_drive(struct gendisk *disk)
|
|||||||
/* invalidate the buffer track to force a reread */
|
/* invalidate the buffer track to force a reread */
|
||||||
set_bit((long)disk->private_data, &fake_change);
|
set_bit((long)disk->private_data, &fake_change);
|
||||||
process_fd_request();
|
process_fd_request();
|
||||||
if (disk_check_media_change(disk))
|
if (disk_check_media_change(disk)) {
|
||||||
|
bdev_mark_dead(disk->part0, true);
|
||||||
floppy_revalidate(disk);
|
floppy_revalidate(disk);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user