]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nvme: Limit command retries
authorKeith Busch <keith.busch@intel.com>
Wed, 14 Dec 2016 22:38:35 +0000 (14:38 -0800)
committerDhaval Giani <dhaval.giani@oracle.com>
Sat, 21 Jan 2017 00:30:29 +0000 (19:30 -0500)
Many controller implementations will return errors to commands that will
not succeed, but without the DNR bit set. The driver previously retried
these commands an unlimited number of times until the command timeout
has exceeded, which takes an unnecessarilly long period of time.

This patch limits the number of retries a command can have, defaulting
to 5, but is user tunable at load or runtime.

The struct request's 'retries' field is used to track the number of
retries attempted. This is in contrast with scsi's use of this field,
which indicates how many retries are allowed.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Orabug: 25256529
Conflicts:
Patched the commits manually due to the lack of core.c file
drivers/nvme/host/pci.c
drivers/nvme/host/nvme.h

Signed-off-by: Ashok Vairavan <ashok.vairavan@intel.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 8d503dc6269e4519c4b00cabd1a8896d2691b074..499d04cd5150c69f8a2cb9b0c18ce4df7ecc6125 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kref.h>
 #include <linux/blk-mq.h>
 
+extern unsigned int nvme_max_retries;
 extern unsigned char nvme_io_timeout;
 #define NVME_IO_TIMEOUT        (nvme_io_timeout * HZ)
 
index 3881e96d87b2a8d0ff65fd28bc8fa3c1ef856329..27558d4ad8582672f0a72c967699cdf7fbc755b8 100644 (file)
@@ -65,6 +65,11 @@ static unsigned char shutdown_timeout = 5;
 module_param(shutdown_timeout, byte, 0644);
 MODULE_PARM_DESC(shutdown_timeout, "timeout in seconds for controller shutdown");
 
+unsigned int nvme_max_retries = 5;
+module_param_named(max_retries, nvme_max_retries, uint, 0644);
+MODULE_PARM_DESC(max_retries, "max number of retries a command may have");
+EXPORT_SYMBOL_GPL(nvme_max_retries);
+
 static int nvme_major;
 module_param(nvme_major, int, 0);
 
@@ -624,9 +629,12 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
 
        if (unlikely(status)) {
                if (!(status & NVME_SC_DNR || blk_noretry_request(req))
-                   && (jiffies - req->start_time) < req->timeout) {
+                   && (jiffies - req->start_time) < req->timeout &&
+                       req->retries < nvme_max_retries) {
                        unsigned long flags;
 
+                       req->retries++;
+                       requeue = true;
                        blk_mq_requeue_request(req);
                        spin_lock_irqsave(req->q->queue_lock, flags);
                        if (!blk_queue_stopped(req->q))
@@ -851,6 +859,11 @@ static void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
        if (req->cmd_flags & REQ_RAHEAD)
                dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH;
 
+       if (!(req->cmd_flags & REQ_DONTPREP)) {
+               req->retries = 0;
+               req->cmd_flags |= REQ_DONTPREP;
+       }
+
        memset(cmnd, 0, sizeof(*cmnd));
        cmnd->rw.opcode = (rq_data_dir(req) ? nvme_cmd_write : nvme_cmd_read);
        cmnd->rw.command_id = req->tag;