]> git.baikalelectronics.ru Git - kernel.git/commitdiff
blk-mq: update ->init_request and ->exit_request prototypes
authorChristoph Hellwig <hch@lst.de>
Mon, 1 May 2017 16:19:08 +0000 (10:19 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 2 May 2017 13:52:08 +0000 (07:52 -0600)
Remove the request_idx parameter, which can't be used safely now that we
support I/O schedulers with blk-mq.  Except for a superflous check in
mtip32xx it was unused anyway.

Also pass the tag_set instead of just the driver data - this allows drivers
to avoid some code duplication in a follow on cleanup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
14 files changed:
block/blk-mq.c
drivers/block/loop.c
drivers/block/mtip32xx/mtip32xx.c
drivers/block/nbd.c
drivers/block/rbd.c
drivers/block/virtio_blk.c
drivers/md/dm-rq.c
drivers/mtd/ubi/block.c
drivers/nvme/host/fc.c
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/target/loop.c
drivers/scsi/scsi_lib.c
include/linux/blk-mq.h

index bf90684a007a21c6aa5068b3b2e3746e8e1accff..b81e4a7cd7f25c0167b826dd65a0788085eef98f 100644 (file)
@@ -1655,8 +1655,7 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
 
                        if (!rq)
                                continue;
-                       set->ops->exit_request(set->driver_data, rq,
-                                               hctx_idx, i);
+                       set->ops->exit_request(set, rq, hctx_idx);
                        tags->static_rqs[i] = NULL;
                }
        }
@@ -1787,8 +1786,7 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
 
                        tags->static_rqs[i] = rq;
                        if (set->ops->init_request) {
-                               if (set->ops->init_request(set->driver_data,
-                                               rq, hctx_idx, i,
+                               if (set->ops->init_request(set, rq, hctx_idx,
                                                node)) {
                                        tags->static_rqs[i] = NULL;
                                        goto fail;
@@ -1849,14 +1847,10 @@ static void blk_mq_exit_hctx(struct request_queue *q,
                struct blk_mq_tag_set *set,
                struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
 {
-       unsigned flush_start_tag = set->queue_depth;
-
        blk_mq_tag_idle(hctx);
 
        if (set->ops->exit_request)
-               set->ops->exit_request(set->driver_data,
-                                      hctx->fq->flush_rq, hctx_idx,
-                                      flush_start_tag + hctx_idx);
+               set->ops->exit_request(set, hctx->fq->flush_rq, hctx_idx);
 
        blk_mq_sched_exit_hctx(q, hctx, hctx_idx);
 
@@ -1889,7 +1883,6 @@ static int blk_mq_init_hctx(struct request_queue *q,
                struct blk_mq_hw_ctx *hctx, unsigned hctx_idx)
 {
        int node;
-       unsigned flush_start_tag = set->queue_depth;
 
        node = hctx->numa_node;
        if (node == NUMA_NO_NODE)
@@ -1933,9 +1926,8 @@ static int blk_mq_init_hctx(struct request_queue *q,
                goto sched_exit_hctx;
 
        if (set->ops->init_request &&
-           set->ops->init_request(set->driver_data,
-                                  hctx->fq->flush_rq, hctx_idx,
-                                  flush_start_tag + hctx_idx, node))
+           set->ops->init_request(set, hctx->fq->flush_rq, hctx_idx,
+                                  node))
                goto free_fq;
 
        if (hctx->flags & BLK_MQ_F_BLOCKING)
index 994403efee19de163238b62e722fb6a478b5f7d5..28d932906f24c19e7250e6c69ec903b4a4460761 100644 (file)
@@ -1697,9 +1697,8 @@ static void loop_queue_work(struct kthread_work *work)
        loop_handle_cmd(cmd);
 }
 
-static int loop_init_request(void *data, struct request *rq,
-               unsigned int hctx_idx, unsigned int request_idx,
-               unsigned int numa_node)
+static int loop_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
        struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq);
 
index 9108be601a64911a7ddb7ed832a2be53397621e5..96fe6500e941fd5a9ecff1c6eec6160c60f85895 100644 (file)
@@ -3818,10 +3818,10 @@ static int mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
        return BLK_MQ_RQ_QUEUE_ERROR;
 }
 
-static void mtip_free_cmd(void *data, struct request *rq,
-                         unsigned int hctx_idx, unsigned int request_idx)
+static void mtip_free_cmd(struct blk_mq_tag_set *set, struct request *rq,
+                         unsigned int hctx_idx)
 {
-       struct driver_data *dd = data;
+       struct driver_data *dd = set->driver_data;
        struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
 
        if (!cmd->command)
@@ -3831,20 +3831,12 @@ static void mtip_free_cmd(void *data, struct request *rq,
                                cmd->command, cmd->command_dma);
 }
 
-static int mtip_init_cmd(void *data, struct request *rq, unsigned int hctx_idx,
-                        unsigned int request_idx, unsigned int numa_node)
+static int mtip_init_cmd(struct blk_mq_tag_set *set, struct request *rq,
+                        unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct driver_data *dd = data;
+       struct driver_data *dd = set->driver_data;
        struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
 
-       /*
-        * For flush requests, request_idx starts at the end of the
-        * tag space.  Since we don't support FLUSH/FUA, simply return
-        * 0 as there's nothing to be done.
-        */
-       if (request_idx >= MTIP_MAX_COMMAND_SLOTS)
-               return 0;
-
        cmd->command = dmam_alloc_coherent(&dd->pdev->dev, CMD_DMA_ALLOC_SZ,
                        &cmd->command_dma, GFP_KERNEL);
        if (!cmd->command)
index ac376b9b852d69677f292eba1afb15df419fe769..6b98ec2a38245978659ce60f30c948b324ee1866 100644 (file)
@@ -1396,12 +1396,11 @@ static void nbd_dbg_close(void)
 
 #endif
 
-static int nbd_init_request(void *data, struct request *rq,
-                           unsigned int hctx_idx, unsigned int request_idx,
-                           unsigned int numa_node)
+static int nbd_init_request(struct blk_mq_tag_set *set, struct request *rq,
+                           unsigned int hctx_idx, unsigned int numa_node)
 {
        struct nbd_cmd *cmd = blk_mq_rq_to_pdu(rq);
-       cmd->nbd = data;
+       cmd->nbd = set->driver_data;
        return 0;
 }
 
index 089ac4179919d2b3b678dc23c373b457842580d3..3670e8dd03fe383dc6570fef16bbffa2784d61e8 100644 (file)
@@ -4307,9 +4307,8 @@ out:
        return ret;
 }
 
-static int rbd_init_request(void *data, struct request *rq,
-               unsigned int hctx_idx, unsigned int request_idx,
-               unsigned int numa_node)
+static int rbd_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
        struct work_struct *work = blk_mq_rq_to_pdu(rq);
 
index f94614257462c33d058bcadd22347c69060fdd40..94173de1efaab18b07924ed0c8431dbb6ba5ca34 100644 (file)
@@ -573,11 +573,10 @@ static const struct device_attribute dev_attr_cache_type_rw =
        __ATTR(cache_type, S_IRUGO|S_IWUSR,
               virtblk_cache_type_show, virtblk_cache_type_store);
 
-static int virtblk_init_request(void *data, struct request *rq,
-               unsigned int hctx_idx, unsigned int request_idx,
-               unsigned int numa_node)
+static int virtblk_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct virtio_blk *vblk = data;
+       struct virtio_blk *vblk = set->driver_data;
        struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq);
 
 #ifdef CONFIG_VIRTIO_BLK_SCSI
index bff7e3bdb4ed1d6bf8ff367e11fa13749dfd6776..522d4fa8db64bbd59bbdd25c23d880bda9266293 100644 (file)
@@ -719,11 +719,10 @@ int dm_old_init_request_queue(struct mapped_device *md, struct dm_table *t)
        return 0;
 }
 
-static int dm_mq_init_request(void *data, struct request *rq,
-                      unsigned int hctx_idx, unsigned int request_idx,
-                      unsigned int numa_node)
+static int dm_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       return __dm_rq_init_rq(data, rq);
+       return __dm_rq_init_rq(set->driver_data, rq);
 }
 
 static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
index 51f2be8889b575cdc1a1f207696d41d620753108..5497e65439df6458cc02d1e6cef0b42c581a7add 100644 (file)
@@ -334,10 +334,9 @@ static int ubiblock_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 }
 
-static int ubiblock_init_request(void *data, struct request *req,
-                                unsigned int hctx_idx,
-                                unsigned int request_idx,
-                                unsigned int numa_node)
+static int ubiblock_init_request(struct blk_mq_tag_set *set,
+               struct request *req, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
        struct ubiblock_pdu *pdu = blk_mq_rq_to_pdu(req);
 
index 4976db56e351901dcc2da7a56312105389b82276..70e689bf1cad286869922764ccd52f1872e92524 100644 (file)
@@ -1172,12 +1172,12 @@ __nvme_fc_exit_request(struct nvme_fc_ctrl *ctrl,
 }
 
 static void
-nvme_fc_exit_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx)
+nvme_fc_exit_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx)
 {
        struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
 
-       return __nvme_fc_exit_request(data, op);
+       return __nvme_fc_exit_request(set->driver_data, op);
 }
 
 static int
@@ -1434,11 +1434,10 @@ out_on_error:
 }
 
 static int
-nvme_fc_init_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+nvme_fc_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct nvme_fc_ctrl *ctrl = data;
+       struct nvme_fc_ctrl *ctrl = set->driver_data;
        struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
        struct nvme_fc_queue *queue = &ctrl->queues[hctx_idx+1];
 
@@ -1446,11 +1445,10 @@ nvme_fc_init_request(void *data, struct request *rq,
 }
 
 static int
-nvme_fc_init_admin_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+nvme_fc_init_admin_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct nvme_fc_ctrl *ctrl = data;
+       struct nvme_fc_ctrl *ctrl = set->driver_data;
        struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
        struct nvme_fc_queue *queue = &ctrl->queues[0];
 
index c8541c3dcd19dbbf16e1f9b687a5a30fad0eb6d8..56a315bd4d9627213e8a49a13ade68da74007a88 100644 (file)
@@ -356,11 +356,11 @@ static void nvme_admin_exit_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_i
        nvmeq->tags = NULL;
 }
 
-static int nvme_admin_init_request(void *data, struct request *req,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_admin_init_request(struct blk_mq_tag_set *set,
+               struct request *req, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
-       struct nvme_dev *dev = data;
+       struct nvme_dev *dev = set->driver_data;
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = dev->queues[0];
 
@@ -383,11 +383,10 @@ static int nvme_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
        return 0;
 }
 
-static int nvme_init_request(void *data, struct request *req,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_init_request(struct blk_mq_tag_set *set, struct request *req,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct nvme_dev *dev = data;
+       struct nvme_dev *dev = set->driver_data;
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = dev->queues[hctx_idx + 1];
 
index 29cf88ac3f61d65bdb972960ff4bddb2abe69ae5..dd1c6deef82fcf509b5c04af20d9df1c17746d9b 100644 (file)
@@ -315,16 +315,16 @@ static void __nvme_rdma_exit_request(struct nvme_rdma_ctrl *ctrl,
                        DMA_TO_DEVICE);
 }
 
-static void nvme_rdma_exit_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx)
+static void nvme_rdma_exit_request(struct blk_mq_tag_set *set,
+               struct request *rq, unsigned int hctx_idx)
 {
-       return __nvme_rdma_exit_request(data, rq, hctx_idx + 1);
+       return __nvme_rdma_exit_request(set->driver_data, rq, hctx_idx + 1);
 }
 
-static void nvme_rdma_exit_admin_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx)
+static void nvme_rdma_exit_admin_request(struct blk_mq_tag_set *set,
+               struct request *rq, unsigned int hctx_idx)
 {
-       return __nvme_rdma_exit_request(data, rq, 0);
+       return __nvme_rdma_exit_request(set->driver_data, rq, 0);
 }
 
 static int __nvme_rdma_init_request(struct nvme_rdma_ctrl *ctrl,
@@ -358,18 +358,18 @@ out_free_qe:
        return -ENOMEM;
 }
 
-static int nvme_rdma_init_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_rdma_init_request(struct blk_mq_tag_set *set,
+               struct request *rq, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
-       return __nvme_rdma_init_request(data, rq, hctx_idx + 1);
+       return __nvme_rdma_init_request(set->driver_data, rq, hctx_idx + 1);
 }
 
-static int nvme_rdma_init_admin_request(void *data, struct request *rq,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_rdma_init_admin_request(struct blk_mq_tag_set *set,
+               struct request *rq, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
-       return __nvme_rdma_init_request(data, rq, 0);
+       return __nvme_rdma_init_request(set->driver_data, rq, 0);
 }
 
 static int nvme_rdma_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
index 304f1c87c160cb0feccfaad3b28148db33bb2c82..feb497134aeea662092424804073be9ed104c464 100644 (file)
@@ -230,18 +230,19 @@ static int nvme_loop_init_iod(struct nvme_loop_ctrl *ctrl,
        return 0;
 }
 
-static int nvme_loop_init_request(void *data, struct request *req,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_loop_init_request(struct blk_mq_tag_set *set,
+               struct request *req, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
-       return nvme_loop_init_iod(data, blk_mq_rq_to_pdu(req), hctx_idx + 1);
+       return nvme_loop_init_iod(set->driver_data, blk_mq_rq_to_pdu(req),
+                       hctx_idx + 1);
 }
 
-static int nvme_loop_init_admin_request(void *data, struct request *req,
-                               unsigned int hctx_idx, unsigned int rq_idx,
-                               unsigned int numa_node)
+static int nvme_loop_init_admin_request(struct blk_mq_tag_set *set,
+               struct request *req, unsigned int hctx_idx,
+               unsigned int numa_node)
 {
-       return nvme_loop_init_iod(data, blk_mq_rq_to_pdu(req), 0);
+       return nvme_loop_init_iod(set->driver_data, blk_mq_rq_to_pdu(req), 0);
 }
 
 static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
index 1c3e87d6c48f19132ea87eab5186a86464e248d9..327b10206d63d11908101f79ff888986b08cf359 100644 (file)
@@ -1999,11 +1999,10 @@ static enum blk_eh_timer_return scsi_timeout(struct request *req,
        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)
+static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx, unsigned int numa_node)
 {
-       struct Scsi_Host *shost = data;
+       struct Scsi_Host *shost = set->driver_data;
        struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
 
        cmd->sense_buffer =
@@ -2014,10 +2013,10 @@ static int scsi_init_request(void *data, struct request *rq,
        return 0;
 }
 
-static void scsi_exit_request(void *data, struct request *rq,
-               unsigned int hctx_idx, unsigned int request_idx)
+static void scsi_exit_request(struct blk_mq_tag_set *set, struct request *rq,
+               unsigned int hctx_idx)
 {
-       struct Scsi_Host *shost = data;
+       struct Scsi_Host *shost = set->driver_data;
        struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
 
        scsi_free_sense_buffer(shost, cmd->sense_buffer);
index f3e5e1de1bdb95480b9199a120b5b46c370646b7..a104832e7ae5e448ac2b2faeaffcd5fdc6f4dda6 100644 (file)
@@ -86,9 +86,9 @@ typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, const struct blk_mq_queue_data
 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,
+typedef int (init_request_fn)(struct blk_mq_tag_set *set, struct request *,
                unsigned int, unsigned int);
-typedef void (exit_request_fn)(void *, struct request *, unsigned int,
+typedef void (exit_request_fn)(struct blk_mq_tag_set *set, struct request *,
                unsigned int);
 typedef int (reinit_request_fn)(void *, struct request *);