[PATCH] nvme: enable retries for authentication commands

Hannes Reinecke hare at suse.de
Thu Jan 25 08:20:18 PST 2024


On 1/25/24 16:48, Christoph Hellwig wrote:
> On Thu, Jan 25, 2024 at 08:42:10AM -0700, Jens Axboe wrote:
>> On 1/25/24 6:09 AM, hare at kernel.org wrote:
>>> From: Hannes Reinecke <hare at suse.de>
>>>
>>> Authentication commands are normal NVMe commands, and as such
>>> can return a status where NVME_SC_DNR is not set, indicating
>>> that the command should be retried.
>>> Rather than checking NVME_SC_DNR manually for each command completion
>>> this patch adds a flag 'retry' to __nvme_submit_sync_cmd(), causing
>>> the REQ_FAILFAST_DRIVER option to be cleared and the command to
>>> be retried via the normal mechanism.
>>
>> Can we please do this without adding Yet Another parameter to that
>> function?
> 
> Heh, I wrote about the same reply a few minutes ago.  I'll try to think
> what we can do instead.

We could do something like this:

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8ebdfd623e0f..200326dc33c1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1057,6 +1057,8 @@ int __nvme_submit_sync_cmd(struct request_queue 
*q, struct nvme_command *cmd,
         if (IS_ERR(req))
                 return PTR_ERR(req);
         nvme_init_request(req, cmd);
+       if (flags & BLK_MQ_REQ_RETRY)
+               req->cmd_flags &= ~REQ_FAILFAST_DRIVER;

         if (buffer && bufflen) {
                 ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 1ab3081c82ed..7983e1abb622 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -719,6 +719,8 @@ enum {
         BLK_MQ_REQ_RESERVED     = (__force blk_mq_req_flags_t)(1 << 1),
         /* set RQF_PM */
         BLK_MQ_REQ_PM           = (__force blk_mq_req_flags_t)(1 << 2),
+       /* enable command retries */
+       BLK_MQ_REQ_RETRY        = (__force blk_mq_req_flags_t)(1 << 3),
  };

  struct request *blk_mq_alloc_request(struct request_queue *q, 
blk_opf_t opf,

but that's arguably a misuse of block layer flags ...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Ivo Totev, Andrew McDonald,
Werner Knoblich




More information about the Linux-nvme mailing list