aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/block/genhd.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-05-25 08:12:56 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-01 07:44:32 -0600
commita8698707a1835be3abd12a3b28079a80999f8dee (patch)
treeaa913e2f7ea74fc5514d052b8bb4c89734dc031b /block/genhd.c
parentblock: move sync_blockdev from __blkdev_put to blkdev_put (diff)
downloadwireguard-linux-a8698707a1835be3abd12a3b28079a80999f8dee.tar.xz
wireguard-linux-a8698707a1835be3abd12a3b28079a80999f8dee.zip
block: move bd_mutex to struct gendisk
Replace the per-block device bd_mutex with a per-gendisk open_mutex, thus simplifying locking wherever we deal with partitions. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com> Link: https://lore.kernel.org/r/20210525061301.2242282-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/genhd.c b/block/genhd.c
index efe0db4d62f0..38d136a19484 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -591,10 +591,10 @@ void del_gendisk(struct gendisk *disk)
blk_integrity_del(disk);
disk_del_events(disk);
- mutex_lock(&disk->part0->bd_mutex);
+ mutex_lock(&disk->open_mutex);
disk->flags &= ~GENHD_FL_UP;
blk_drop_partitions(disk);
- mutex_unlock(&disk->part0->bd_mutex);
+ mutex_unlock(&disk->open_mutex);
fsync_bdev(disk->part0);
__invalidate_device(disk->part0, true);
@@ -1273,6 +1273,7 @@ struct gendisk *__alloc_disk_node(int minors, int node_id)
goto out_free_disk;
disk->node_id = node_id;
+ mutex_init(&disk->open_mutex);
xa_init(&disk->part_tbl);
if (xa_insert(&disk->part_tbl, 0, disk->part0, GFP_KERNEL))
goto out_destroy_part_tbl;
@@ -1525,7 +1526,7 @@ void disk_unblock_events(struct gendisk *disk)
* doesn't clear the events from @disk->ev.
*
* CONTEXT:
- * If @mask is non-zero must be called with bdev->bd_mutex held.
+ * If @mask is non-zero must be called with disk->open_mutex held.
*/
void disk_flush_events(struct gendisk *disk, unsigned int mask)
{