]> www.infradead.org Git - users/hch/block.git/commitdiff
block: avoid repeated work in blk_mark_disk_dead
authorChristoph Hellwig <hch@lst.de>
Fri, 5 May 2023 12:48:01 +0000 (08:48 -0400)
committerChristoph Hellwig <hch@lst.de>
Fri, 5 May 2023 13:38:44 +0000 (09:38 -0400)
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 <hch@lst.de>
block/genhd.c

index 461999e94899374f53cf192c595eff27d7c02669..9a35b8443f0b5f2c6a2b055806542d93dc5b0102 100644 (file)
@@ -586,7 +586,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);