Skip to content

Commit cbf3a95

Browse files
committed
Merge branch 'nvme-4.15' of git://git.infradead.org/nvme into for-linus
Pull a handful of NVMe fixes from Christoph that should go into 4.15.
2 parents 454be72 + 254beb8 commit cbf3a95

File tree

5 files changed

+52
-25
lines changed

5 files changed

+52
-25
lines changed

drivers/nvme/host/core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
13351335
struct nvme_ns *ns, struct nvme_id_ns *id)
13361336
{
13371337
sector_t capacity = le64_to_cpup(&id->nsze) << (ns->lba_shift - 9);
1338+
unsigned short bs = 1 << ns->lba_shift;
13381339
unsigned stream_alignment = 0;
13391340

13401341
if (ns->ctrl->nr_streams && ns->sws && ns->sgs)
@@ -1343,7 +1344,10 @@ static void nvme_update_disk_info(struct gendisk *disk,
13431344
blk_mq_freeze_queue(disk->queue);
13441345
blk_integrity_unregister(disk);
13451346

1346-
blk_queue_logical_block_size(disk->queue, 1 << ns->lba_shift);
1347+
blk_queue_logical_block_size(disk->queue, bs);
1348+
blk_queue_physical_block_size(disk->queue, bs);
1349+
blk_queue_io_min(disk->queue, bs);
1350+
13471351
if (ns->ms && !ns->ext &&
13481352
(ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
13491353
nvme_init_integrity(disk, ns->ms, ns->pi_type);
@@ -2987,6 +2991,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)
29872991
mutex_unlock(&ns->ctrl->namespaces_mutex);
29882992

29892993
synchronize_srcu(&ns->head->srcu);
2994+
nvme_mpath_check_last_path(ns);
29902995
nvme_put_ns(ns);
29912996
}
29922997

drivers/nvme/host/nvme.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@ static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
417417
rcu_assign_pointer(head->current_path, NULL);
418418
}
419419
struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
420+
421+
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
422+
{
423+
struct nvme_ns_head *head = ns->head;
424+
425+
if (head->disk && list_empty(&head->list))
426+
kblockd_schedule_work(&head->requeue_work);
427+
}
428+
420429
#else
421430
static inline void nvme_failover_req(struct request *req)
422431
{
@@ -448,6 +457,9 @@ static inline void nvme_mpath_remove_disk_links(struct nvme_ns *ns)
448457
static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
449458
{
450459
}
460+
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
461+
{
462+
}
451463
#endif /* CONFIG_NVME_MULTIPATH */
452464

453465
#ifdef CONFIG_NVM

drivers/nvme/host/pci.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,31 @@ static void **nvme_pci_iod_list(struct request *req)
448448
return (void **)(iod->sg + blk_rq_nr_phys_segments(req));
449449
}
450450

451+
static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)
452+
{
453+
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
454+
unsigned int avg_seg_size;
455+
456+
avg_seg_size = DIV_ROUND_UP(blk_rq_payload_bytes(req),
457+
blk_rq_nr_phys_segments(req));
458+
459+
if (!(dev->ctrl.sgls & ((1 << 0) | (1 << 1))))
460+
return false;
461+
if (!iod->nvmeq->qid)
462+
return false;
463+
if (!sgl_threshold || avg_seg_size < sgl_threshold)
464+
return false;
465+
return true;
466+
}
467+
451468
static blk_status_t nvme_init_iod(struct request *rq, struct nvme_dev *dev)
452469
{
453470
struct nvme_iod *iod = blk_mq_rq_to_pdu(rq);
454471
int nseg = blk_rq_nr_phys_segments(rq);
455472
unsigned int size = blk_rq_payload_bytes(rq);
456473

474+
iod->use_sgl = nvme_pci_use_sgls(dev, rq);
475+
457476
if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) {
458477
size_t alloc_size = nvme_pci_iod_alloc_size(dev, size, nseg,
459478
iod->use_sgl);
@@ -604,8 +623,6 @@ static blk_status_t nvme_pci_setup_prps(struct nvme_dev *dev,
604623
dma_addr_t prp_dma;
605624
int nprps, i;
606625

607-
iod->use_sgl = false;
608-
609626
length -= (page_size - offset);
610627
if (length <= 0) {
611628
iod->first_dma = 0;
@@ -715,8 +732,6 @@ static blk_status_t nvme_pci_setup_sgls(struct nvme_dev *dev,
715732
int entries = iod->nents, i = 0;
716733
dma_addr_t sgl_dma;
717734

718-
iod->use_sgl = true;
719-
720735
/* setting the transfer type as SGL */
721736
cmd->flags = NVME_CMD_SGL_METABUF;
722737

@@ -770,23 +785,6 @@ static blk_status_t nvme_pci_setup_sgls(struct nvme_dev *dev,
770785
return BLK_STS_OK;
771786
}
772787

773-
static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)
774-
{
775-
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
776-
unsigned int avg_seg_size;
777-
778-
avg_seg_size = DIV_ROUND_UP(blk_rq_payload_bytes(req),
779-
blk_rq_nr_phys_segments(req));
780-
781-
if (!(dev->ctrl.sgls & ((1 << 0) | (1 << 1))))
782-
return false;
783-
if (!iod->nvmeq->qid)
784-
return false;
785-
if (!sgl_threshold || avg_seg_size < sgl_threshold)
786-
return false;
787-
return true;
788-
}
789-
790788
static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
791789
struct nvme_command *cmnd)
792790
{
@@ -806,7 +804,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
806804
DMA_ATTR_NO_WARN))
807805
goto out;
808806

809-
if (nvme_pci_use_sgls(dev, req))
807+
if (iod->use_sgl)
810808
ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw);
811809
else
812810
ret = nvme_pci_setup_prps(dev, req, &cmnd->rw);

drivers/nvme/host/rdma.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,18 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work)
974974
blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
975975
nvme_start_queues(&ctrl->ctrl);
976976

977+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) {
978+
/* state change failure should never happen */
979+
WARN_ON_ONCE(1);
980+
return;
981+
}
982+
977983
nvme_rdma_reconnect_or_remove(ctrl);
978984
}
979985

980986
static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl)
981987
{
982-
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING))
988+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING))
983989
return;
984990

985991
queue_work(nvme_wq, &ctrl->err_work);
@@ -1753,6 +1759,12 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work)
17531759
nvme_stop_ctrl(&ctrl->ctrl);
17541760
nvme_rdma_shutdown_ctrl(ctrl, false);
17551761

1762+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) {
1763+
/* state change failure should never happen */
1764+
WARN_ON_ONCE(1);
1765+
return;
1766+
}
1767+
17561768
ret = nvme_rdma_configure_admin_queue(ctrl, false);
17571769
if (ret)
17581770
goto out_fail;

drivers/nvme/target/fcloop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ fcloop_delete_target_port(struct device *dev, struct device_attribute *attr,
10851085
const char *buf, size_t count)
10861086
{
10871087
struct fcloop_nport *nport = NULL, *tmpport;
1088-
struct fcloop_tport *tport;
1088+
struct fcloop_tport *tport = NULL;
10891089
u64 nodename, portname;
10901090
unsigned long flags;
10911091
int ret;

0 commit comments

Comments
 (0)