[PATCH] nvmet: allow setting ctrl to ready without iosqes/iocqes set

Sagi Grimberg sagi at grimberg.me
Wed Jun 30 11:50:06 PDT 2021


> From: Ran Anner <Ran.Anner at dell.com>
> 
> According to the spec we should fail creation of IO queues
> if iosqes or iocqes properties are not set

Would be good to add the specific section in the spec.

  but does not mention
> preventing from changing ctrl status to ready.
> We have seen host implementation which sets the property to 0x1
> and waits endlessly until ctrl status changes to ready.
> 
> Signed-off-by: Ran Anner <Ran.Anner at dell.com>
> ---
>   drivers/nvme/target/core.c        | 39 +------------------------------
>   drivers/nvme/target/fabrics-cmd.c |  9 +++++++
>   drivers/nvme/target/nvmet.h       | 34 +++++++++++++++++++++++++++
>   3 files changed, 44 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index adbede9ab7f3..559dc7354adb 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -1078,48 +1078,11 @@ void nvmet_req_free_sgls(struct nvmet_req *req)
>   }
>   EXPORT_SYMBOL_GPL(nvmet_req_free_sgls);
>   
> -static inline bool nvmet_cc_en(u32 cc)
> -{
> -	return (cc >> NVME_CC_EN_SHIFT) & 0x1;
> -}
> -
> -static inline u8 nvmet_cc_css(u32 cc)
> -{
> -	return (cc >> NVME_CC_CSS_SHIFT) & 0x7;
> -}
> -
> -static inline u8 nvmet_cc_mps(u32 cc)
> -{
> -	return (cc >> NVME_CC_MPS_SHIFT) & 0xf;
> -}
> -
> -static inline u8 nvmet_cc_ams(u32 cc)
> -{
> -	return (cc >> NVME_CC_AMS_SHIFT) & 0x7;
> -}
> -
> -static inline u8 nvmet_cc_shn(u32 cc)
> -{
> -	return (cc >> NVME_CC_SHN_SHIFT) & 0x3;
> -}
> -
> -static inline u8 nvmet_cc_iosqes(u32 cc)
> -{
> -	return (cc >> NVME_CC_IOSQES_SHIFT) & 0xf;
> -}
> -
> -static inline u8 nvmet_cc_iocqes(u32 cc)
> -{
> -	return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf;
> -}
> -
>   static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
>   {
>   	lockdep_assert_held(&ctrl->lock);
>   
> -	if (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES ||
> -	    nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES ||
> -	    nvmet_cc_mps(ctrl->cc) != 0 ||
> +	if (nvmet_cc_mps(ctrl->cc) != 0 ||
>   	    nvmet_cc_ams(ctrl->cc) != 0 ||
>   	    nvmet_cc_css(ctrl->cc) != 0) {
>   		ctrl->csts = NVME_CSTS_CFS;
> diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
> index 1420a8e3e0b1..421ab564ed5c 100644
> --- a/drivers/nvme/target/fabrics-cmd.c
> +++ b/drivers/nvme/target/fabrics-cmd.c
> @@ -259,6 +259,15 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
>   		goto out_ctrl_put;
>   	}
>   
> +	if (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES ||
> +			nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES) {

Can you indent to the start of the parenthesis?



More information about the Linux-nvme mailing list