VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Christoph Hellwig <hch@lst.de> 2021-04-06 08:22:56 +0200 committer: Jens Axboe <axboe@kernel.dk> 2021-04-08 10:24:36 -0600 commit: c76f48eb5c084b1e15c931ae8cc1826cd771d70d parent: d3c4a43d9291279c28b26757351a6ab72c110753
Commit Summary:
block: take bd_mutex around delete_partitions in del_gendisk
Diffstat:
2 files changed, 5 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);
 
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 536f7c5bb0b6..9fbaec466b51 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -531,6 +531,8 @@ void blk_drop_partitions(struct gendisk *disk)
 	struct disk_part_iter piter;
 	struct block_device *part;
 
+	lockdep_assert_held(&disk->part0->bd_mutex);
+
 	disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
 	while ((part = disk_part_iter_next(&piter)))
 		delete_partition(part);