Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: add a mark_dead holder operation

Add a mark_dead method to blk_holder_ops that is called from blk_mark_disk_dead
to notify the holder that the block device it is using has been marked dead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Christian Brauner <brauner@kernel.org>
Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Link: https://lore.kernel.org/r/20230601094459.1350643-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
f55e017c 0718afd4

+25
+24
block/genhd.c
··· 565 565 } 566 566 EXPORT_SYMBOL(device_add_disk); 567 567 568 + static void blk_report_disk_dead(struct gendisk *disk) 569 + { 570 + struct block_device *bdev; 571 + unsigned long idx; 572 + 573 + rcu_read_lock(); 574 + xa_for_each(&disk->part_tbl, idx, bdev) { 575 + if (!kobject_get_unless_zero(&bdev->bd_device.kobj)) 576 + continue; 577 + rcu_read_unlock(); 578 + 579 + mutex_lock(&bdev->bd_holder_lock); 580 + if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead) 581 + bdev->bd_holder_ops->mark_dead(bdev); 582 + mutex_unlock(&bdev->bd_holder_lock); 583 + 584 + put_device(&bdev->bd_device); 585 + rcu_read_lock(); 586 + } 587 + rcu_read_unlock(); 588 + } 589 + 568 590 /** 569 591 * blk_mark_disk_dead - mark a disk as dead 570 592 * @disk: disk to mark as dead ··· 614 592 * Prevent new I/O from crossing bio_queue_enter(). 615 593 */ 616 594 blk_queue_start_drain(disk->queue); 595 + 596 + blk_report_disk_dead(disk); 617 597 } 618 598 EXPORT_SYMBOL_GPL(blk_mark_disk_dead); 619 599
+1
include/linux/blkdev.h
··· 1471 1471 #endif 1472 1472 1473 1473 struct blk_holder_ops { 1474 + void (*mark_dead)(struct block_device *bdev); 1474 1475 }; 1475 1476 1476 1477 struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,