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

block: Add PR callouts for read keys and reservation

Add callouts for reading keys and reservations. This allows LIO to support
the READ_KEYS and READ_RESERVATION commands so it can export devices to
VMs for software like windows clustering.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20230407200551.12660-2-michael.christie@oracle.com
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Mike Christie and committed by
Martin K. Petersen
c787f1ba fe15c26e

+25
+25
include/linux/pr.h
··· 4 4 5 5 #include <uapi/linux/pr.h> 6 6 7 + struct pr_keys { 8 + u32 generation; 9 + u32 num_keys; 10 + u64 keys[]; 11 + }; 12 + 13 + struct pr_held_reservation { 14 + u64 key; 15 + u32 generation; 16 + enum pr_type type; 17 + }; 18 + 7 19 struct pr_ops { 8 20 int (*pr_register)(struct block_device *bdev, u64 old_key, u64 new_key, 9 21 u32 flags); ··· 26 14 int (*pr_preempt)(struct block_device *bdev, u64 old_key, u64 new_key, 27 15 enum pr_type type, bool abort); 28 16 int (*pr_clear)(struct block_device *bdev, u64 key); 17 + /* 18 + * pr_read_keys - Read the registered keys and return them in the 19 + * pr_keys->keys array. The keys array will have been allocated at the 20 + * end of the pr_keys struct, and pr_keys->num_keys must be set to the 21 + * number of keys the array can hold. If there are more than can fit 22 + * in the array, success will still be returned and pr_keys->num_keys 23 + * will reflect the total number of keys the device contains, so the 24 + * caller can retry with a larger array. 25 + */ 26 + int (*pr_read_keys)(struct block_device *bdev, 27 + struct pr_keys *keys_info); 28 + int (*pr_read_reservation)(struct block_device *bdev, 29 + struct pr_held_reservation *rsv); 29 30 }; 30 31 31 32 #endif /* LINUX_PR_H */