[PATCH v2 08/20] nvme: Add helper to convert to a pr_ops PR type
Chaitanya Kulkarni
chaitanyak at nvidia.com
Tue Aug 9 04:12:09 PDT 2022
On 8/8/22 17:04, Mike Christie wrote:
> This adds a helper to go from the NVMe spec PR type value to the block
> layer pr_type, so for Reservation Report support we can convert from its
> value.
>
> Signed-off-by: Mike Christie <michael.christie at oracle.com>
> ---
> drivers/nvme/host/core.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3f223641f321..0dc768ae0c16 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2064,6 +2064,26 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> }
> }
>
> +static enum pr_type block_pr_type(u8 nvme_type)
> +{
> + switch (nvme_type) {
> + case 1:
> + return PR_WRITE_EXCLUSIVE;
> + case 2:
> + return PR_EXCLUSIVE_ACCESS;
> + case 3:
> + return PR_WRITE_EXCLUSIVE_REG_ONLY;
> + case 4:
> + return PR_EXCLUSIVE_ACCESS_REG_ONLY;
> + case 5:
> + return PR_WRITE_EXCLUSIVE_ALL_REGS;
> + case 6:
> + return PR_EXCLUSIVE_ACCESS_ALL_REGS;
> + default:
> + return 0;
> + }
> +}
> +
missing caller for this one ? and we can use a sparse array
to remove the switch case for every new nvme_type.
-ck
More information about the Linux-nvme
mailing list