[PATCH] nvme: module parameter to disable pi checks

Chaitanya Kulkarni chaitanyak at nvidia.com
Wed Oct 23 13:01:43 PDT 2024


On 10/23/24 08:50, Keith Busch wrote:
>   
> +static bool disable_pi = false;
> +module_param(disable_pi, bool, 0444);
> +MODULE_PARM_DESC(disable_pi, "disable protection-information if used");
> +
>   /*
>    * nvme_wq - hosts nvme related works that are not reset or delete
>    * nvme_reset_wq - hosts nvme reset works
> @@ -1763,6 +1767,7 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
>   		struct queue_limits *lim, struct nvme_ns_info *info)
>   {
>   	struct blk_integrity *bi = &lim->integrity;
> +	int pi_type = head->pi_type;
>   
>   	memset(bi, 0, sizeof(*bi));
>   
> @@ -1777,7 +1782,10 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
>   	    !(head->features & NVME_NS_METADATA_SUPPORTED))
>   		return nvme_ns_has_pi(head);
>   
> -	switch (head->pi_type) {
> +	if (disable_pi)
> +		pi_type = 0;
> +
> +	switch (pi_type) {
>   	case NVME_NS_DPS_PI_TYPE3:
>   		switch (head->guard_type) {
>   		case NVME_NVM_NS_16B_GUARD:

may be we can get rid of the local var pi_type ? totally untested [1].

Irrespective of that :-

Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>

-ck

[1]

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 2f3b3911bce4..d587f541937e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1758,7 +1758,6 @@ static bool nvme_init_integrity(struct 
nvme_ns_head *head,
                 struct queue_limits *lim, struct nvme_ns_info *info)
  {
         struct blk_integrity *bi = &lim->integrity;
-       int pi_type = head->pi_type;

         memset(bi, 0, sizeof(*bi));

@@ -1774,9 +1773,9 @@ static bool nvme_init_integrity(struct 
nvme_ns_head *head,
                 return nvme_ns_has_pi(head);

         if (disable_pi)
-               pi_type = 0;
+               goto out;

-       switch (pi_type) {
+       switch (head->pi_type) {
         case NVME_NS_DPS_PI_TYPE3:
                 switch (head->guard_type) {
                 case NVME_NVM_NS_16B_GUARD:
@@ -1816,6 +1815,7 @@ static bool nvme_init_integrity(struct 
nvme_ns_head *head,
                 break;
         }

+out:
         bi->tuple_size = head->ms;
         bi->pi_offset = info->pi_offset;
         return true;




More information about the Linux-nvme mailing list