diff options
author | Jens Axboe <axboe@kernel.dk> | 2018-02-28 14:18:58 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-02-28 14:18:58 -0500 |
commit | 468f098734ab095b72d8af26bcd4bcb2ed31a3be (patch) | |
tree | 657b08428562785483129b470c8017b70c38c1aa | |
parent | 0979962f5490abe75b3e2befb07a564fa0cf631b (diff) | |
parent | bffd2b61670feef18d2535e9b53364d270a1c991 (diff) |
Merge branch 'for-jens' of git://git.infradead.org/nvme into for-linus
Pull NVMe fixes from Keith for 4.16-rc.
* 'for-jens' of git://git.infradead.org/nvme:
nvmet: fix PSDT field check in command format
nvme-multipath: fix sysfs dangerously created links
nvme-pci: Fix nvme queue cleanup if IRQ setup fails
nvmet-loop: use blk_rq_payload_bytes for sgl selection
nvme-rdma: use blk_rq_payload_bytes instead of blk_rq_bytes
nvme-fabrics: don't check for non-NULL module in nvmf_register_transport
-rw-r--r-- | drivers/nvme/host/core.c | 12 | ||||
-rw-r--r-- | drivers/nvme/host/fabrics.c | 2 | ||||
-rw-r--r-- | drivers/nvme/host/multipath.c | 15 | ||||
-rw-r--r-- | drivers/nvme/host/pci.c | 5 | ||||
-rw-r--r-- | drivers/nvme/host/rdma.c | 4 | ||||
-rw-r--r-- | drivers/nvme/target/core.c | 9 | ||||
-rw-r--r-- | drivers/nvme/target/loop.c | 4 |
7 files changed, 28 insertions, 23 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0fe7ea35c221..817e5e2766da 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -2844,7 +2844,7 @@ out: | |||
2844 | } | 2844 | } |
2845 | 2845 | ||
2846 | static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, | 2846 | static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, |
2847 | struct nvme_id_ns *id, bool *new) | 2847 | struct nvme_id_ns *id) |
2848 | { | 2848 | { |
2849 | struct nvme_ctrl *ctrl = ns->ctrl; | 2849 | struct nvme_ctrl *ctrl = ns->ctrl; |
2850 | bool is_shared = id->nmic & (1 << 0); | 2850 | bool is_shared = id->nmic & (1 << 0); |
@@ -2860,8 +2860,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, | |||
2860 | ret = PTR_ERR(head); | 2860 | ret = PTR_ERR(head); |
2861 | goto out_unlock; | 2861 | goto out_unlock; |
2862 | } | 2862 | } |
2863 | |||
2864 | *new = true; | ||
2865 | } else { | 2863 | } else { |
2866 | struct nvme_ns_ids ids; | 2864 | struct nvme_ns_ids ids; |
2867 | 2865 | ||
@@ -2873,8 +2871,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, | |||
2873 | ret = -EINVAL; | 2871 | ret = -EINVAL; |
2874 | goto out_unlock; | 2872 | goto out_unlock; |
2875 | } | 2873 | } |
2876 | |||
2877 | *new = false; | ||
2878 | } | 2874 | } |
2879 | 2875 | ||
2880 | list_add_tail(&ns->siblings, &head->list); | 2876 | list_add_tail(&ns->siblings, &head->list); |
@@ -2945,7 +2941,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) | |||
2945 | struct nvme_id_ns *id; | 2941 | struct nvme_id_ns *id; |
2946 | char disk_name[DISK_NAME_LEN]; | 2942 | char disk_name[DISK_NAME_LEN]; |
2947 | int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT; | 2943 | int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT; |
2948 | bool new = true; | ||
2949 | 2944 | ||
2950 | ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); | 2945 | ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); |
2951 | if (!ns) | 2946 | if (!ns) |
@@ -2971,7 +2966,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) | |||
2971 | if (id->ncap == 0) | 2966 | if (id->ncap == 0) |
2972 | goto out_free_id; | 2967 | goto out_free_id; |
2973 | 2968 | ||
2974 | if (nvme_init_ns_head(ns, nsid, id, &new)) | 2969 | if (nvme_init_ns_head(ns, nsid, id)) |
2975 | goto out_free_id; | 2970 | goto out_free_id; |
2976 | nvme_setup_streams_ns(ctrl, ns); | 2971 | nvme_setup_streams_ns(ctrl, ns); |
2977 | 2972 | ||
@@ -3037,8 +3032,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) | |||
3037 | pr_warn("%s: failed to register lightnvm sysfs group for identification\n", | 3032 | pr_warn("%s: failed to register lightnvm sysfs group for identification\n", |
3038 | ns->disk->disk_name); | 3033 | ns->disk->disk_name); |
3039 | 3034 | ||
3040 | if (new) | 3035 | nvme_mpath_add_disk(ns->head); |
3041 | nvme_mpath_add_disk(ns->head); | ||
3042 | nvme_mpath_add_disk_links(ns); | 3036 | nvme_mpath_add_disk_links(ns); |
3043 | return; | 3037 | return; |
3044 | out_unlink_ns: | 3038 | out_unlink_ns: |
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 5dd4ceefed8f..a1c58e35075e 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c | |||
@@ -493,7 +493,7 @@ EXPORT_SYMBOL_GPL(nvmf_should_reconnect); | |||
493 | */ | 493 | */ |
494 | int nvmf_register_transport(struct nvmf_transport_ops *ops) | 494 | int nvmf_register_transport(struct nvmf_transport_ops *ops) |
495 | { | 495 | { |
496 | if (!ops->create_ctrl || !ops->module) | 496 | if (!ops->create_ctrl) |
497 | return -EINVAL; | 497 | return -EINVAL; |
498 | 498 | ||
499 | down_write(&nvmf_transports_rwsem); | 499 | down_write(&nvmf_transports_rwsem); |
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 3b211d9e58b8..b7e5c6db4d92 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c | |||
@@ -198,11 +198,16 @@ void nvme_mpath_add_disk(struct nvme_ns_head *head) | |||
198 | { | 198 | { |
199 | if (!head->disk) | 199 | if (!head->disk) |
200 | return; | 200 | return; |
201 | device_add_disk(&head->subsys->dev, head->disk); | 201 | |
202 | if (sysfs_create_group(&disk_to_dev(head->disk)->kobj, | 202 | mutex_lock(&head->subsys->lock); |
203 | &nvme_ns_id_attr_group)) | 203 | if (!(head->disk->flags & GENHD_FL_UP)) { |
204 | pr_warn("%s: failed to create sysfs group for identification\n", | 204 | device_add_disk(&head->subsys->dev, head->disk); |
205 | head->disk->disk_name); | 205 | if (sysfs_create_group(&disk_to_dev(head->disk)->kobj, |
206 | &nvme_ns_id_attr_group)) | ||
207 | pr_warn("%s: failed to create sysfs group for identification\n", | ||
208 | head->disk->disk_name); | ||
209 | } | ||
210 | mutex_unlock(&head->subsys->lock); | ||
206 | } | 211 | } |
207 | 212 | ||
208 | void nvme_mpath_add_disk_links(struct nvme_ns *ns) | 213 | void nvme_mpath_add_disk_links(struct nvme_ns *ns) |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 73036d2fbbd5..5933a5c732e8 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -1459,7 +1459,7 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) | |||
1459 | nvmeq->cq_vector = qid - 1; | 1459 | nvmeq->cq_vector = qid - 1; |
1460 | result = adapter_alloc_cq(dev, qid, nvmeq); | 1460 | result = adapter_alloc_cq(dev, qid, nvmeq); |
1461 | if (result < 0) | 1461 | if (result < 0) |
1462 | return result; | 1462 | goto release_vector; |
1463 | 1463 | ||
1464 | result = adapter_alloc_sq(dev, qid, nvmeq); | 1464 | result = adapter_alloc_sq(dev, qid, nvmeq); |
1465 | if (result < 0) | 1465 | if (result < 0) |
@@ -1473,9 +1473,12 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) | |||
1473 | return result; | 1473 | return result; |
1474 | 1474 | ||
1475 | release_sq: | 1475 | release_sq: |
1476 | dev->online_queues--; | ||
1476 | adapter_delete_sq(dev, qid); | 1477 | adapter_delete_sq(dev, qid); |
1477 | release_cq: | 1478 | release_cq: |
1478 | adapter_delete_cq(dev, qid); | 1479 | adapter_delete_cq(dev, qid); |
1480 | release_vector: | ||
1481 | nvmeq->cq_vector = -1; | ||
1479 | return result; | 1482 | return result; |
1480 | } | 1483 | } |
1481 | 1484 | ||
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 3a51ed50eff2..4d84a73ee12d 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c | |||
@@ -1051,7 +1051,7 @@ static void nvme_rdma_unmap_data(struct nvme_rdma_queue *queue, | |||
1051 | struct nvme_rdma_device *dev = queue->device; | 1051 | struct nvme_rdma_device *dev = queue->device; |
1052 | struct ib_device *ibdev = dev->dev; | 1052 | struct ib_device *ibdev = dev->dev; |
1053 | 1053 | ||
1054 | if (!blk_rq_bytes(rq)) | 1054 | if (!blk_rq_payload_bytes(rq)) |
1055 | return; | 1055 | return; |
1056 | 1056 | ||
1057 | if (req->mr) { | 1057 | if (req->mr) { |
@@ -1166,7 +1166,7 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue *queue, | |||
1166 | 1166 | ||
1167 | c->common.flags |= NVME_CMD_SGL_METABUF; | 1167 | c->common.flags |= NVME_CMD_SGL_METABUF; |
1168 | 1168 | ||
1169 | if (!blk_rq_bytes(rq)) | 1169 | if (!blk_rq_payload_bytes(rq)) |
1170 | return nvme_rdma_set_sg_null(c); | 1170 | return nvme_rdma_set_sg_null(c); |
1171 | 1171 | ||
1172 | req->sg_table.sgl = req->first_sgl; | 1172 | req->sg_table.sgl = req->first_sgl; |
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 0bd737117a80..a78029e4e5f4 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c | |||
@@ -520,9 +520,12 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, | |||
520 | goto fail; | 520 | goto fail; |
521 | } | 521 | } |
522 | 522 | ||
523 | /* either variant of SGLs is fine, as we don't support metadata */ | 523 | /* |
524 | if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF && | 524 | * For fabrics, PSDT field shall describe metadata pointer (MPTR) that |
525 | (flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METASEG)) { | 525 | * contains an address of a single contiguous physical buffer that is |
526 | * byte aligned. | ||
527 | */ | ||
528 | if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF)) { | ||
526 | status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; | 529 | status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; |
527 | goto fail; | 530 | goto fail; |
528 | } | 531 | } |
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 7991ec3a17db..861d1509b22b 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c | |||
@@ -184,7 +184,7 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
184 | return BLK_STS_OK; | 184 | return BLK_STS_OK; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (blk_rq_bytes(req)) { | 187 | if (blk_rq_payload_bytes(req)) { |
188 | iod->sg_table.sgl = iod->first_sgl; | 188 | iod->sg_table.sgl = iod->first_sgl; |
189 | if (sg_alloc_table_chained(&iod->sg_table, | 189 | if (sg_alloc_table_chained(&iod->sg_table, |
190 | blk_rq_nr_phys_segments(req), | 190 | blk_rq_nr_phys_segments(req), |
@@ -193,7 +193,7 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
193 | 193 | ||
194 | iod->req.sg = iod->sg_table.sgl; | 194 | iod->req.sg = iod->sg_table.sgl; |
195 | iod->req.sg_cnt = blk_rq_map_sg(req->q, req, 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_bytes(req); | 196 | iod->req.transfer_len = blk_rq_payload_bytes(req); |
197 | } | 197 | } |
198 | 198 | ||
199 | blk_mq_start_request(req); | 199 | blk_mq_start_request(req); |