aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/scsi/scsi_common.c
diff options
context:
space:
mode:
authorMike Christie <michael.christie@oracle.com>2023-04-07 15:05:38 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2023-04-11 21:55:35 -0400
commit0af7b5e2362d3b67334f20e49138d89141dc24d3 (patch)
tree0a95e36506583f2024262627154a34dca92d4ceb /drivers/scsi/scsi_common.c
parentscsi: Move sd_pr_type to scsi_common (diff)
downloadwireguard-linux-0af7b5e2362d3b67334f20e49138d89141dc24d3.tar.xz
wireguard-linux-0af7b5e2362d3b67334f20e49138d89141dc24d3.zip
scsi: Add support for block PR read keys/reservation
This adds support in sd.c for the block PR read keys and read reservation callouts, so upper layers like LIO can get the PR info that's been setup using the existing pr callouts and return it to initiators. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20230407200551.12660-6-michael.christie@oracle.com Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/scsi_common.c')
-rw-r--r--drivers/scsi/scsi_common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c
index 11bf6c275d4e..b7a7a2eea887 100644
--- a/drivers/scsi/scsi_common.c
+++ b/drivers/scsi/scsi_common.c
@@ -64,6 +64,27 @@ const char *scsi_device_type(unsigned type)
}
EXPORT_SYMBOL(scsi_device_type);
+enum pr_type scsi_pr_type_to_block(enum scsi_pr_type type)
+{
+ switch (type) {
+ case SCSI_PR_WRITE_EXCLUSIVE:
+ return PR_WRITE_EXCLUSIVE;
+ case SCSI_PR_EXCLUSIVE_ACCESS:
+ return PR_EXCLUSIVE_ACCESS;
+ case SCSI_PR_WRITE_EXCLUSIVE_REG_ONLY:
+ return PR_WRITE_EXCLUSIVE_REG_ONLY;
+ case SCSI_PR_EXCLUSIVE_ACCESS_REG_ONLY:
+ return PR_EXCLUSIVE_ACCESS_REG_ONLY;
+ case SCSI_PR_WRITE_EXCLUSIVE_ALL_REGS:
+ return PR_WRITE_EXCLUSIVE_ALL_REGS;
+ case SCSI_PR_EXCLUSIVE_ACCESS_ALL_REGS:
+ return PR_EXCLUSIVE_ACCESS_ALL_REGS;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(scsi_pr_type_to_block);
+
enum scsi_pr_type block_pr_type_to_scsi(enum pr_type type)
{
switch (type) {