Skip to content

Commit ab6860f

Browse files
Christoph Hellwigbrauner
authored andcommitted
block: simplify the disk_force_media_change interface
Hard code the events to DISK_EVENT_MEDIA_CHANGE as that is the only useful use case, and drop the superfluous return value. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Message-Id: <20230811100828.1897174-9-hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 0c1c9a2 commit ab6860f

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

block/disk-events.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,25 +294,18 @@ EXPORT_SYMBOL(disk_check_media_change);
294294
* @disk: the disk which will raise the event
295295
* @events: the events to raise
296296
*
297-
* Generate uevents for the disk. If DISK_EVENT_MEDIA_CHANGE is present,
298-
* attempt to free all dentries and inodes and invalidates all block
297+
* Should be called when the media changes for @disk. Generates a uevent
298+
* and attempts to free all dentries and inodes and invalidates all block
299299
* device page cache entries in that case.
300-
*
301-
* Returns %true if DISK_EVENT_MEDIA_CHANGE was raised, or %false if not.
302300
*/
303-
bool disk_force_media_change(struct gendisk *disk, unsigned int events)
301+
void disk_force_media_change(struct gendisk *disk)
304302
{
305-
disk_event_uevent(disk, events);
306-
307-
if (!(events & DISK_EVENT_MEDIA_CHANGE))
308-
return false;
309-
303+
disk_event_uevent(disk, DISK_EVENT_MEDIA_CHANGE);
310304
inc_diskseq(disk);
311305
if (__invalidate_device(disk->part0, true))
312306
pr_warn("VFS: busy inodes on changed media %s\n",
313307
disk->disk_name);
314308
set_bit(GD_NEED_PART_SCAN, &disk->state);
315-
return true;
316309
}
317310
EXPORT_SYMBOL_GPL(disk_force_media_change);
318311

drivers/block/loop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
603603
goto out_err;
604604

605605
/* and ... switch */
606-
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
606+
disk_force_media_change(lo->lo_disk);
607607
blk_mq_freeze_queue(lo->lo_queue);
608608
mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
609609
lo->lo_backing_file = file;
@@ -1067,7 +1067,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
10671067
/* suppress uevents while reconfiguring the device */
10681068
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 1);
10691069

1070-
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
1070+
disk_force_media_change(lo->lo_disk);
10711071
set_disk_ro(lo->lo_disk, (lo->lo_flags & LO_FLAGS_READ_ONLY) != 0);
10721072

10731073
lo->use_dio = lo->lo_flags & LO_FLAGS_DIRECT_IO;
@@ -1171,7 +1171,7 @@ static void __loop_clr_fd(struct loop_device *lo, bool release)
11711171
if (!release)
11721172
blk_mq_unfreeze_queue(lo->lo_queue);
11731173

1174-
disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE);
1174+
disk_force_media_change(lo->lo_disk);
11751175

11761176
if (lo->lo_flags & LO_FLAGS_PARTSCAN) {
11771177
int err;

include/linux/blkdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ static inline int bdev_read_only(struct block_device *bdev)
750750
}
751751

752752
bool set_capacity_and_notify(struct gendisk *disk, sector_t size);
753-
bool disk_force_media_change(struct gendisk *disk, unsigned int events);
753+
void disk_force_media_change(struct gendisk *disk);
754754

755755
void add_disk_randomness(struct gendisk *disk) __latent_entropy;
756756
void rand_initialize_disk(struct gendisk *disk);

0 commit comments

Comments
 (0)