blk-mq: pass a reserved argument to the timeout handler
authorChristoph Hellwig <hch@lst.de>
Sat, 13 Sep 2014 23:40:13 +0000 (16:40 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 22 Sep 2014 18:00:07 +0000 (12:00 -0600)
Allow blk-mq to pass an argument to the timeout handler to indicate
if we're timing out a reserved or regular command.  For many drivers
those need to be handled different.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c
drivers/scsi/scsi_lib.c
include/linux/blk-mq.h

index 298d6e36066111649eab99db4685f3783824f205..d12f1983d4937f7a67cf4e7a4bcea7b2640ed488 100644 (file)
@@ -530,7 +530,7 @@ struct blk_mq_timeout_data {
        unsigned int next_set;
 };
 
-static void blk_mq_rq_timed_out(struct request *req)
+static void blk_mq_rq_timed_out(struct request *req, bool reserved)
 {
        struct blk_mq_ops *ops = req->q->mq_ops;
        enum blk_eh_timer_return ret = BLK_EH_RESET_TIMER;
@@ -548,7 +548,7 @@ static void blk_mq_rq_timed_out(struct request *req)
                return;
 
        if (ops->timeout)
-               ret = ops->timeout(req);
+               ret = ops->timeout(req, reserved);
 
        switch (ret) {
        case BLK_EH_HANDLED:
@@ -576,7 +576,7 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
 
        if (time_after_eq(jiffies, rq->deadline)) {
                if (!blk_mark_rq_complete(rq))
-                       blk_mq_rq_timed_out(rq);
+                       blk_mq_rq_timed_out(rq, reserved);
        } else if (!data->next_set || time_after(data->next, rq->deadline)) {
                data->next = rq->deadline;
                data->next_set = 1;
index 73ce7d27f5c81b5b0334a0e7671bc35c41f0a701..86b1156edb82b9d682df2d59b6964eb41065c9d6 100644 (file)
@@ -1932,6 +1932,14 @@ out:
        return ret;
 }
 
+static enum blk_eh_timer_return scsi_timeout(struct request *req,
+               bool reserved)
+{
+       if (reserved)
+               return BLK_EH_RESET_TIMER;
+       return scsi_times_out(req);
+}
+
 static int scsi_init_request(void *data, struct request *rq,
                unsigned int hctx_idx, unsigned int request_idx,
                unsigned int numa_node)
@@ -2043,7 +2051,7 @@ static struct blk_mq_ops scsi_mq_ops = {
        .map_queue      = blk_mq_map_queue,
        .queue_rq       = scsi_queue_rq,
        .complete       = scsi_softirq_done,
-       .timeout        = scsi_times_out,
+       .timeout        = scsi_timeout,
        .init_request   = scsi_init_request,
        .exit_request   = scsi_exit_request,
 };
index 0eb0f642be4b63ce05da808b0e3a305ac4bf37a9..325349559fb07887d8dad987e4a28b4759bc58ac 100644 (file)
@@ -79,6 +79,7 @@ struct blk_mq_tag_set {
 
 typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *, bool);
 typedef struct blk_mq_hw_ctx *(map_queue_fn)(struct request_queue *, const int);
+typedef enum blk_eh_timer_return (timeout_fn)(struct request *, bool);
 typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int);
 typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int);
 typedef int (init_request_fn)(void *, struct request *, unsigned int,
@@ -103,7 +104,7 @@ struct blk_mq_ops {
        /*
         * Called on request timeout
         */
-       rq_timed_out_fn         *timeout;
+       timeout_fn              *timeout;
 
        softirq_done_fn         *complete;