diff mbox series

[04/11] block: Add PR callouts for read keys and reservation

Message ID 20220603065536.5641-5-michael.christie@oracle.com (mailing list archive)
State New, archived
Headers show
Series Use block pr_ops in LIO | expand

Commit Message

Mike Christie June 3, 2022, 6:55 a.m. UTC
Add callouts for reading keys and reservations.

Note: This only initially adds the struct definitions in the kernel as I'm
not sure if we wanted to export the interface to userspace yet. We may
want to refine internally for LIO and when we can enable it for NVMe then
add the finished interface to userspace.

The latter is not done, because NVMe's report reservation command is
similar to SCSI's read full status where they return a remote and local
ID as well as the key/reservation info. However, a lot of SCSI devices
don't do remote/local ID parts correctly. It seems that read full status
might not be used very often so does not get a lot of testing.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 include/linux/pr.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Christoph Hellwig June 20, 2022, 7:14 a.m. UTC | #1
On Fri, Jun 03, 2022 at 01:55:29AM -0500, Mike Christie wrote:
> Add callouts for reading keys and reservations.
> 
> Note: This only initially adds the struct definitions in the kernel as I'm
> not sure if we wanted to export the interface to userspace yet. We may
> want to refine internally for LIO and when we can enable it for NVMe then
> add the finished interface to userspace.

Yes, this sounds like a good plan.  I can see how they would be useful
for userspace, but I'm also perfectly fine with us not locking ourselves
into an ABI quite yet.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/include/linux/pr.h b/include/linux/pr.h
index 94ceec713afe..21a8eb8b34b5 100644
--- a/include/linux/pr.h
+++ b/include/linux/pr.h
@@ -4,6 +4,18 @@ 
 
 #include <uapi/linux/pr.h>
 
+struct pr_keys {
+	u32	generation;
+	u32	num_keys;
+	u64	keys[];
+};
+
+struct pr_held_reservation {
+	u64	key;
+	u32	type;
+	u32	generation;
+};
+
 struct pr_ops {
 	int (*pr_register)(struct block_device *bdev, u64 old_key, u64 new_key,
 			u32 flags);
@@ -14,6 +26,10 @@  struct pr_ops {
 	int (*pr_preempt)(struct block_device *bdev, u64 old_key, u64 new_key,
 			enum pr_type type, bool abort);
 	int (*pr_clear)(struct block_device *bdev, u64 key);
+	int (*pr_read_keys)(struct block_device *bdev,
+			    struct pr_keys *keys_info, int keys_info_len);
+	int (*pr_read_reservation)(struct block_device *bdev,
+				   struct pr_held_reservation *rsv);
 };
 
 #endif /* LINUX_PR_H */