loop.c (ee1400dda31814d0a61c964ad87da6880edec0e2) | loop.c (11d9ea6f2ca69237d35d6c55755beba3e006b106) |
---|---|
1/* 2 * NVMe over Fabrics loopback device. 3 * Copyright (c) 2015-2016 HGST, a Western Digital Company. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 57 unchanged lines hidden (view full) --- 66static struct nvmet_port *nvmet_loop_port; 67 68static LIST_HEAD(nvme_loop_ctrl_list); 69static DEFINE_MUTEX(nvme_loop_ctrl_mutex); 70 71static void nvme_loop_queue_response(struct nvmet_req *nvme_req); 72static void nvme_loop_delete_ctrl(struct nvmet_ctrl *ctrl); 73 | 1/* 2 * NVMe over Fabrics loopback device. 3 * Copyright (c) 2015-2016 HGST, a Western Digital Company. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms and conditions of the GNU General Public License, 7 * version 2, as published by the Free Software Foundation. 8 * --- 57 unchanged lines hidden (view full) --- 66static struct nvmet_port *nvmet_loop_port; 67 68static LIST_HEAD(nvme_loop_ctrl_list); 69static DEFINE_MUTEX(nvme_loop_ctrl_mutex); 70 71static void nvme_loop_queue_response(struct nvmet_req *nvme_req); 72static void nvme_loop_delete_ctrl(struct nvmet_ctrl *ctrl); 73 |
74static struct nvmet_fabrics_ops nvme_loop_ops; | 74static const struct nvmet_fabrics_ops nvme_loop_ops; |
75 76static inline int nvme_loop_queue_idx(struct nvme_loop_queue *queue) 77{ 78 return queue - queue->ctrl->queues; 79} 80 81static void nvme_loop_complete_rq(struct request *req) 82{ --- 86 unchanged lines hidden (view full) --- 169 ret = nvme_loop_is_ready(queue, req); 170 if (unlikely(ret)) 171 return ret; 172 173 ret = nvme_setup_cmd(ns, req, &iod->cmd); 174 if (ret) 175 return ret; 176 | 75 76static inline int nvme_loop_queue_idx(struct nvme_loop_queue *queue) 77{ 78 return queue - queue->ctrl->queues; 79} 80 81static void nvme_loop_complete_rq(struct request *req) 82{ --- 86 unchanged lines hidden (view full) --- 169 ret = nvme_loop_is_ready(queue, req); 170 if (unlikely(ret)) 171 return ret; 172 173 ret = nvme_setup_cmd(ns, req, &iod->cmd); 174 if (ret) 175 return ret; 176 |
177 blk_mq_start_request(req); |
|
177 iod->cmd.common.flags |= NVME_CMD_SGL_METABUF; 178 iod->req.port = nvmet_loop_port; 179 if (!nvmet_req_init(&iod->req, &queue->nvme_cq, | 178 iod->cmd.common.flags |= NVME_CMD_SGL_METABUF; 179 iod->req.port = nvmet_loop_port; 180 if (!nvmet_req_init(&iod->req, &queue->nvme_cq, |
180 &queue->nvme_sq, &nvme_loop_ops)) { 181 nvme_cleanup_cmd(req); 182 blk_mq_start_request(req); 183 nvme_loop_queue_response(&iod->req); | 181 &queue->nvme_sq, &nvme_loop_ops)) |
184 return BLK_STS_OK; | 182 return BLK_STS_OK; |
185 } | |
186 187 if (blk_rq_payload_bytes(req)) { 188 iod->sg_table.sgl = iod->first_sgl; 189 if (sg_alloc_table_chained(&iod->sg_table, 190 blk_rq_nr_phys_segments(req), 191 iod->sg_table.sgl)) 192 return BLK_STS_RESOURCE; 193 194 iod->req.sg = iod->sg_table.sgl; 195 iod->req.sg_cnt = blk_rq_map_sg(req->q, req, iod->sg_table.sgl); 196 iod->req.transfer_len = blk_rq_payload_bytes(req); 197 } 198 | 183 184 if (blk_rq_payload_bytes(req)) { 185 iod->sg_table.sgl = iod->first_sgl; 186 if (sg_alloc_table_chained(&iod->sg_table, 187 blk_rq_nr_phys_segments(req), 188 iod->sg_table.sgl)) 189 return BLK_STS_RESOURCE; 190 191 iod->req.sg = iod->sg_table.sgl; 192 iod->req.sg_cnt = blk_rq_map_sg(req->q, req, iod->sg_table.sgl); 193 iod->req.transfer_len = blk_rq_payload_bytes(req); 194 } 195 |
199 blk_mq_start_request(req); 200 | |
201 schedule_work(&iod->work); 202 return BLK_STS_OK; 203} 204 205static void nvme_loop_submit_async_event(struct nvme_ctrl *arg) 206{ 207 struct nvme_loop_ctrl *ctrl = to_loop_ctrl(arg); 208 struct nvme_loop_queue *queue = &ctrl->queues[0]; --- 461 unchanged lines hidden (view full) --- 670} 671 672static void nvme_loop_remove_port(struct nvmet_port *port) 673{ 674 if (port == nvmet_loop_port) 675 nvmet_loop_port = NULL; 676} 677 | 196 schedule_work(&iod->work); 197 return BLK_STS_OK; 198} 199 200static void nvme_loop_submit_async_event(struct nvme_ctrl *arg) 201{ 202 struct nvme_loop_ctrl *ctrl = to_loop_ctrl(arg); 203 struct nvme_loop_queue *queue = &ctrl->queues[0]; --- 461 unchanged lines hidden (view full) --- 665} 666 667static void nvme_loop_remove_port(struct nvmet_port *port) 668{ 669 if (port == nvmet_loop_port) 670 nvmet_loop_port = NULL; 671} 672 |
678static struct nvmet_fabrics_ops nvme_loop_ops = { | 673static const struct nvmet_fabrics_ops nvme_loop_ops = { |
679 .owner = THIS_MODULE, 680 .type = NVMF_TRTYPE_LOOP, 681 .add_port = nvme_loop_add_port, 682 .remove_port = nvme_loop_remove_port, 683 .queue_response = nvme_loop_queue_response, 684 .delete_ctrl = nvme_loop_delete_ctrl, 685}; 686 --- 41 unchanged lines hidden --- | 674 .owner = THIS_MODULE, 675 .type = NVMF_TRTYPE_LOOP, 676 .add_port = nvme_loop_add_port, 677 .remove_port = nvme_loop_remove_port, 678 .queue_response = nvme_loop_queue_response, 679 .delete_ctrl = nvme_loop_delete_ctrl, 680}; 681 --- 41 unchanged lines hidden --- |