diff options
author | Mike Christie <michael.christie@oracle.com> | 2023-04-07 15:05:37 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2023-04-11 21:55:35 -0400 |
commit | 0730b1632b7e803aad81ff19a4fda964a9d97053 (patch) | |
tree | 18c4940800f3752654928ae63a614232d8870dac /drivers/scsi/scsi_common.c | |
parent | 20bebccbc45db71b4a55c465fcc1be37d5daed0d (diff) | |
download | linux-stable-0730b1632b7e803aad81ff19a4fda964a9d97053.tar.gz linux-stable-0730b1632b7e803aad81ff19a4fda964a9d97053.tar.bz2 linux-stable-0730b1632b7e803aad81ff19a4fda964a9d97053.zip |
scsi: Move sd_pr_type to scsi_common
LIO is going to want to do the same block to/from SCSI pr types as sd.c
so this moves the sd_pr_type helper to scsi_common and renames it. The
next patch will then also add a helper to go from the SCSI value to the
block one for use with PERSISTENT_RESERVE_IN commands.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20230407200551.12660-5-michael.christie@oracle.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
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>
Diffstat (limited to 'drivers/scsi/scsi_common.c')
-rw-r--r-- | drivers/scsi/scsi_common.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c index 6e50e81a8216..11bf6c275d4e 100644 --- a/drivers/scsi/scsi_common.c +++ b/drivers/scsi/scsi_common.c @@ -8,6 +8,7 @@ #include <linux/string.h> #include <linux/errno.h> #include <linux/module.h> +#include <uapi/linux/pr.h> #include <asm/unaligned.h> #include <scsi/scsi_common.h> @@ -63,6 +64,27 @@ const char *scsi_device_type(unsigned type) } EXPORT_SYMBOL(scsi_device_type); +enum scsi_pr_type block_pr_type_to_scsi(enum pr_type type) +{ + switch (type) { + case PR_WRITE_EXCLUSIVE: + return SCSI_PR_WRITE_EXCLUSIVE; + case PR_EXCLUSIVE_ACCESS: + return SCSI_PR_EXCLUSIVE_ACCESS; + case PR_WRITE_EXCLUSIVE_REG_ONLY: + return SCSI_PR_WRITE_EXCLUSIVE_REG_ONLY; + case PR_EXCLUSIVE_ACCESS_REG_ONLY: + return SCSI_PR_EXCLUSIVE_ACCESS_REG_ONLY; + case PR_WRITE_EXCLUSIVE_ALL_REGS: + return SCSI_PR_WRITE_EXCLUSIVE_ALL_REGS; + case PR_EXCLUSIVE_ACCESS_ALL_REGS: + return SCSI_PR_EXCLUSIVE_ACCESS_ALL_REGS; + } + + return 0; +} +EXPORT_SYMBOL_GPL(block_pr_type_to_scsi); + /** * scsilun_to_int - convert a scsi_lun to an int * @scsilun: struct scsi_lun to be converted. |