aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-04-06 08:22:56 +0200
committerJens Axboe <axboe@kernel.dk>2021-04-08 10:24:36 -0600
commitc76f48eb5c084b1e15c931ae8cc1826cd771d70d (patch)
treee077b28cd7d52c2f98be76d4faf699341f7393b2 /block/genhd.c
parentblock: refactor blk_drop_partitions (diff)
downloadlinux-dev-c76f48eb5c084b1e15c931ae8cc1826cd771d70d.tar.xz
linux-dev-c76f48eb5c084b1e15c931ae8cc1826cd771d70d.zip
block: take bd_mutex around delete_partitions in del_gendisk
There is nothing preventing an ioctl from trying do delete partition concurrenly with del_gendisk, so take open_mutex to serialize against that. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210406062303.811835-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 8303ec67fd70..e3f3c2321773 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -680,7 +680,11 @@ void del_gendisk(struct gendisk *disk)
* disk is marked as dead (GENHD_FL_UP cleared).
*/
down_write(&bdev_lookup_sem);
+
+ mutex_lock(&disk->part0->bd_mutex);
blk_drop_partitions(disk);
+ mutex_unlock(&disk->part0->bd_mutex);
+
fsync_bdev(disk->part0);
__invalidate_device(disk->part0, true);