From a4f75764d16bed317276b05a9fe2c179ef61680d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 1 Jun 2023 11:44:48 +0200 Subject: [PATCH] block: avoid repeated work in blk_mark_disk_dead Check if GD_DEAD is already set in blk_mark_disk_dead, and don't duplicate the work already done. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Christian Brauner Acked-by: Dave Chinner Reviewed-by: Dave Chinner Link: https://lore.kernel.org/r/20230601094459.1350643-6-hch@lst.de Signed-off-by: Jens Axboe --- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index aa327314905e..6fa926a02d85 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -575,7 +575,9 @@ void blk_mark_disk_dead(struct gendisk *disk) /* * Fail any new I/O. */ - set_bit(GD_DEAD, &disk->state); + if (test_and_set_bit(GD_DEAD, &disk->state)) + return; + if (test_bit(GD_OWNS_QUEUE, &disk->state)) blk_queue_flag_set(QUEUE_FLAG_DYING, disk->queue);