]> www.infradead.org Git - users/hch/block.git/commitdiff
xfs: wire up the ->mark_dead holder operation for log and RT devices blk_holder_ops
authorChristoph Hellwig <hch@lst.de>
Fri, 5 May 2023 13:49:39 +0000 (09:49 -0400)
committerChristoph Hellwig <hch@lst.de>
Fri, 5 May 2023 14:00:27 +0000 (10:00 -0400)
Implement a set of holder_ops that shut down the file system when the
block device used as log or RT device is removed undeneath the file
system.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_super.c

index 3abe5ae96cc59b00e5eefce7b3af509ebebb629f..9c2401d9548d83819a21f25d48350facadab459c 100644 (file)
@@ -377,6 +377,17 @@ disable_dax:
        return 0;
 }
 
+static void
+xfs_hop_mark_dead(
+       struct block_device     *bdev)
+{
+       xfs_force_shutdown(bdev->bd_holder, SHUTDOWN_DEVICE_REMOVED);
+}
+
+static const struct blk_holder_ops xfs_holder_ops = {
+       .mark_dead              = xfs_hop_mark_dead,
+};
+
 STATIC int
 xfs_blkdev_get(
        xfs_mount_t             *mp,
@@ -386,7 +397,7 @@ xfs_blkdev_get(
        int                     error = 0;
 
        *bdevp = blkdev_get_by_path(name, FMODE_READ|FMODE_WRITE|FMODE_EXCL,
-                                   mp, NULL);
+                                   mp, &xfs_holder_ops);
        if (IS_ERR(*bdevp)) {
                error = PTR_ERR(*bdevp);
                xfs_warn(mp, "Invalid device [%s], error=%d", name, error);