Re: [PATCH 2/2] block: fix a race between del_gendisk and BLKRRPART

From
Ming Lei <hidden>
Date
2021-05-15 06:35:43
Reply to
Christoph Hellwig, 2021-05-14
On Fri, May 14, 2021 at 03:18:42PM +0200, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
From: Gulam Mohamed <redacted>

When BLKRRPART is called concurrently with del_gendisk, the partitions
rescan can create a stale partition that will never be be cleaned up.

Fix this by checking the the disk is up before rescanning partitions
while under bd_mutex.

Signed-off-by: Gulam Mohamed <redacted>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 580bae995b87..4494411fa4d3 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1244,6 +1244,9 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
 
 	lockdep_assert_held(&bdev->bd_mutex);
 
+	if (!(disk->flags & GENHD_FL_UP))
+		return -ENXIO;
+
 rescan:
 	if (bdev->bd_part_count)
 		return -EBUSY;
Reviewed-by: Ming Lei <redacted>

-- 
Ming
Thread (9 messages) 9 messages, 4 authors, last reply 2021-05-20
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help