nvme: allocate the keep alive request using BLK_MQ_REQ_NOWAIT
authorChristoph Hellwig <hch@lst.de>
Wed, 3 Mar 2021 12:51:47 +0000 (13:51 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 18 Mar 2021 04:38:48 +0000 (05:38 +0100)
To avoid an error recovery deadlock where the keep alive work is waiting
for a request and thus can't be flushed to make progress for tearing down
the controller.  Also print the error code returned from
blk_mq_alloc_request to help debugging any future issues in this code.

Based on an earlier patch from Hannes Reinecke <hare@suse.de>.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
drivers/nvme/host/core.c

index 45d510a..83d6740 100644 (file)
@@ -1242,10 +1242,10 @@ static void nvme_keep_alive_work(struct work_struct *work)
        }
 
        rq = nvme_alloc_request(ctrl->admin_q, &ctrl->ka_cmd,
-                               BLK_MQ_REQ_RESERVED);
+                               BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
        if (IS_ERR(rq)) {
                /* allocation failure, reset the controller */
-               dev_err(ctrl->device, "keep-alive failed\n");
+               dev_err(ctrl->device, "keep-alive failed: %ld\n", PTR_ERR(rq));
                nvme_reset_ctrl(ctrl);
                return;
        }