Skip to content

Commit 468f098

Browse files
committed
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
2 parents 0979962 + bffd2b6 commit 468f098

File tree

7 files changed

+28
-23
lines changed

7 files changed

+28
-23
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,7 +2844,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
28442844
}
28452845

28462846
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)
28482848
{
28492849
struct nvme_ctrl *ctrl = ns->ctrl;
28502850
bool is_shared = id->nmic & (1 << 0);
@@ -2860,8 +2860,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
28602860
ret = PTR_ERR(head);
28612861
goto out_unlock;
28622862
}
2863-
2864-
*new = true;
28652863
} else {
28662864
struct nvme_ns_ids ids;
28672865

@@ -2873,8 +2871,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
28732871
ret = -EINVAL;
28742872
goto out_unlock;
28752873
}
2876-
2877-
*new = false;
28782874
}
28792875

28802876
list_add_tail(&ns->siblings, &head->list);
@@ -2945,7 +2941,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
29452941
struct nvme_id_ns *id;
29462942
char disk_name[DISK_NAME_LEN];
29472943
int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT;
2948-
bool new = true;
29492944

29502945
ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
29512946
if (!ns)
@@ -2971,7 +2966,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
29712966
if (id->ncap == 0)
29722967
goto out_free_id;
29732968

2974-
if (nvme_init_ns_head(ns, nsid, id, &new))
2969+
if (nvme_init_ns_head(ns, nsid, id))
29752970
goto out_free_id;
29762971
nvme_setup_streams_ns(ctrl, ns);
29772972

@@ -3037,8 +3032,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
30373032
pr_warn("%s: failed to register lightnvm sysfs group for identification\n",
30383033
ns->disk->disk_name);
30393034

3040-
if (new)
3041-
nvme_mpath_add_disk(ns->head);
3035+
nvme_mpath_add_disk(ns->head);
30423036
nvme_mpath_add_disk_links(ns);
30433037
return;
30443038
out_unlink_ns:

drivers/nvme/host/fabrics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ EXPORT_SYMBOL_GPL(nvmf_should_reconnect);
493493
*/
494494
int nvmf_register_transport(struct nvmf_transport_ops *ops)
495495
{
496-
if (!ops->create_ctrl || !ops->module)
496+
if (!ops->create_ctrl)
497497
return -EINVAL;
498498

499499
down_write(&nvmf_transports_rwsem);

drivers/nvme/host/multipath.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,16 @@ void nvme_mpath_add_disk(struct nvme_ns_head *head)
198198
{
199199
if (!head->disk)
200200
return;
201-
device_add_disk(&head->subsys->dev, head->disk);
202-
if (sysfs_create_group(&disk_to_dev(head->disk)->kobj,
203-
&nvme_ns_id_attr_group))
204-
pr_warn("%s: failed to create sysfs group for identification\n",
205-
head->disk->disk_name);
201+
202+
mutex_lock(&head->subsys->lock);
203+
if (!(head->disk->flags & GENHD_FL_UP)) {
204+
device_add_disk(&head->subsys->dev, head->disk);
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);
206211
}
207212

208213
void nvme_mpath_add_disk_links(struct nvme_ns *ns)

drivers/nvme/host/pci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
14591459
nvmeq->cq_vector = qid - 1;
14601460
result = adapter_alloc_cq(dev, qid, nvmeq);
14611461
if (result < 0)
1462-
return result;
1462+
goto release_vector;
14631463

14641464
result = adapter_alloc_sq(dev, qid, nvmeq);
14651465
if (result < 0)
@@ -1473,9 +1473,12 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
14731473
return result;
14741474

14751475
release_sq:
1476+
dev->online_queues--;
14761477
adapter_delete_sq(dev, qid);
14771478
release_cq:
14781479
adapter_delete_cq(dev, qid);
1480+
release_vector:
1481+
nvmeq->cq_vector = -1;
14791482
return result;
14801483
}
14811484

drivers/nvme/host/rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static void nvme_rdma_unmap_data(struct nvme_rdma_queue *queue,
10511051
struct nvme_rdma_device *dev = queue->device;
10521052
struct ib_device *ibdev = dev->dev;
10531053

1054-
if (!blk_rq_bytes(rq))
1054+
if (!blk_rq_payload_bytes(rq))
10551055
return;
10561056

10571057
if (req->mr) {
@@ -1166,7 +1166,7 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue *queue,
11661166

11671167
c->common.flags |= NVME_CMD_SGL_METABUF;
11681168

1169-
if (!blk_rq_bytes(rq))
1169+
if (!blk_rq_payload_bytes(rq))
11701170
return nvme_rdma_set_sg_null(c);
11711171

11721172
req->sg_table.sgl = req->first_sgl;

drivers/nvme/target/core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,12 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
520520
goto fail;
521521
}
522522

523-
/* either variant of SGLs is fine, as we don't support metadata */
524-
if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF &&
525-
(flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METASEG)) {
523+
/*
524+
* For fabrics, PSDT field shall describe metadata pointer (MPTR) that
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)) {
526529
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
527530
goto fail;
528531
}

drivers/nvme/target/loop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
184184
return BLK_STS_OK;
185185
}
186186

187-
if (blk_rq_bytes(req)) {
187+
if (blk_rq_payload_bytes(req)) {
188188
iod->sg_table.sgl = iod->first_sgl;
189189
if (sg_alloc_table_chained(&iod->sg_table,
190190
blk_rq_nr_phys_segments(req),
@@ -193,7 +193,7 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
193193

194194
iod->req.sg = iod->sg_table.sgl;
195195
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);
197197
}
198198

199199
blk_mq_start_request(req);

0 commit comments

Comments
 (0)