[PATCH v2 05/20] dm: Add support for block PR read keys/reservation.
Mike Christie
michael.christie at oracle.com
Mon Aug 8 17:04:04 PDT 2022
This adds support in dm for the block PR read keys and read reservation
callouts.
Signed-off-by: Mike Christie <michael.christie at oracle.com>
---
drivers/md/dm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 60549b65c799..1b15295bdf24 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -3313,12 +3313,56 @@ static int dm_pr_clear(struct block_device *bdev, u64 key)
return r;
}
+static int dm_pr_read_keys(struct block_device *bdev, struct pr_keys *keys,
+ u32 keys_len)
+{
+ struct mapped_device *md = bdev->bd_disk->private_data;
+ const struct pr_ops *ops;
+ int r, srcu_idx;
+
+ r = dm_prepare_ioctl(md, &srcu_idx, &bdev);
+ if (r < 0)
+ goto out;
+
+ ops = bdev->bd_disk->fops->pr_ops;
+ if (ops && ops->pr_read_keys)
+ r = ops->pr_read_keys(bdev, keys, keys_len);
+ else
+ r = -EOPNOTSUPP;
+out:
+ dm_unprepare_ioctl(md, srcu_idx);
+ return r;
+}
+
+static int dm_pr_read_reservation(struct block_device *bdev,
+ struct pr_held_reservation *rsv)
+{
+ struct mapped_device *md = bdev->bd_disk->private_data;
+ const struct pr_ops *ops;
+ int r, srcu_idx;
+
+ r = dm_prepare_ioctl(md, &srcu_idx, &bdev);
+ if (r < 0)
+ goto out;
+
+ ops = bdev->bd_disk->fops->pr_ops;
+ if (ops && ops->pr_read_reservation)
+ r = ops->pr_read_reservation(bdev, rsv);
+ else
+ r = -EOPNOTSUPP;
+out:
+ dm_unprepare_ioctl(md, srcu_idx);
+ return r;
+}
+
static const struct pr_ops dm_pr_ops = {
.pr_register = dm_pr_register,
.pr_reserve = dm_pr_reserve,
.pr_release = dm_pr_release,
.pr_preempt = dm_pr_preempt,
.pr_clear = dm_pr_clear,
+ .pr_read_keys = dm_pr_read_keys,
+ .pr_read_reservation = dm_pr_read_reservation,
};
static const struct block_device_operations dm_blk_dops = {
--
2.18.2
More information about the Linux-nvme
mailing list