block: don't hold open_mutex over disk_flush_events
authorChristoph Hellwig <hch@lst.de>
Tue, 18 Jan 2022 08:54:51 +0000 (09:54 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 19 Jan 2022 15:19:56 +0000 (16:19 +0100)
The only interesting state here is ev->clearing, and that is protected by
ev->lock already.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/bdev.c
block/disk-events.c

index a301a4264419c01167ec326ddb121d0bd5d396e7..f1fda6dd6be5246bded6d542092447fa0fa3173e 100644 (file)
@@ -930,9 +930,9 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
         * event.  This is to ensure detection of media removal commanded
         * from userland - e.g. eject(1).
         */
-       mutex_lock(&disk->open_mutex);
        disk_flush_events(disk, DISK_EVENT_MEDIA_CHANGE);
 
+       mutex_lock(&disk->open_mutex);
        if (bdev_is_partition(bdev))
                blkdev_put_part(bdev, mode);
        else
index 8d5496e7592a50044e288f8101b3749eeb1acf12..9887d5ab933ce69e0f74093b04dcb94a092b6b2a 100644 (file)
@@ -144,9 +144,6 @@ void disk_unblock_events(struct gendisk *disk)
  * Schedule immediate event checking on @disk if not blocked.  Events in
  * @mask are scheduled to be cleared from the driver.  Note that this
  * doesn't clear the events from @disk->ev.
- *
- * CONTEXT:
- * If @mask is non-zero must be called with disk->open_mutex held.
  */
 void disk_flush_events(struct gendisk *disk, unsigned int mask)
 {