aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2017-05-26 11:11:19 -0400
committerJens Axboe <axboe@fb.com>2017-05-26 11:11:19 -0400
commit8aa6382907fa495e6b8b8184b53e36d142ffd8da (patch)
tree16a22fc90548ee3edcb6e3ed1ffe4aa247bcadf2
parenta8ecdd7117ee68fe27009acc8021423870c1dcd7 (diff)
parent50af47d04ca530544b27affffb0722f158e2bb9c (diff)
Merge branch 'nvme-4.12' of git://git.infradead.org/nvme into for-linus
Christoph writes: "A couple of fixes for the next rc on the nvme front. Various FC fixes from James, controller removal fixes from Ming (including a block layer patch), a APST related device quirk from Andy, a RDMA fix for small queue depth device from Marta, as well as fixes for the lack of metadata support in non-PCIe drivers and the printk logging format from me."
-rw-r--r--block/blk-mq.c19
-rw-r--r--drivers/nvme/host/core.c65
-rw-r--r--drivers/nvme/host/fc.c147
-rw-r--r--drivers/nvme/host/nvme.h4
-rw-r--r--drivers/nvme/host/pci.c15
-rw-r--r--drivers/nvme/host/rdma.c20
-rw-r--r--drivers/nvme/target/loop.c2
-rw-r--r--include/linux/blk-mq.h1
8 files changed, 130 insertions, 143 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a69ad122ed66..f2224ffd225d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -628,25 +628,6 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q,
628} 628}
629EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list); 629EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
630 630
631void blk_mq_abort_requeue_list(struct request_queue *q)
632{
633 unsigned long flags;
634 LIST_HEAD(rq_list);
635
636 spin_lock_irqsave(&q->requeue_lock, flags);
637 list_splice_init(&q->requeue_list, &rq_list);
638 spin_unlock_irqrestore(&q->requeue_lock, flags);
639
640 while (!list_empty(&rq_list)) {
641 struct request *rq;
642
643 rq = list_first_entry(&rq_list, struct request, queuelist);
644 list_del_init(&rq->queuelist);
645 blk_mq_end_request(rq, -EIO);
646 }
647}
648EXPORT_SYMBOL(blk_mq_abort_requeue_list);
649
650struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag) 631struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
651{ 632{
652 if (tag < tags->nr_tags) { 633 if (tag < tags->nr_tags) {
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d5e0906262ea..a60926410438 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -925,6 +925,29 @@ static int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
925} 925}
926 926
927#ifdef CONFIG_BLK_DEV_INTEGRITY 927#ifdef CONFIG_BLK_DEV_INTEGRITY
928static void nvme_prep_integrity(struct gendisk *disk, struct nvme_id_ns *id,
929 u16 bs)
930{
931 struct nvme_ns *ns = disk->private_data;
932 u16 old_ms = ns->ms;
933 u8 pi_type = 0;
934
935 ns->ms = le16_to_cpu(id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ms);
936 ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
937
938 /* PI implementation requires metadata equal t10 pi tuple size */
939 if (ns->ms == sizeof(struct t10_pi_tuple))
940 pi_type = id->dps & NVME_NS_DPS_PI_MASK;
941
942 if (blk_get_integrity(disk) &&
943 (ns->pi_type != pi_type || ns->ms != old_ms ||
944 bs != queue_logical_block_size(disk->queue) ||
945 (ns->ms && ns->ext)))
946 blk_integrity_unregister(disk);
947
948 ns->pi_type = pi_type;
949}
950
928static void nvme_init_integrity(struct nvme_ns *ns) 951static void nvme_init_integrity(struct nvme_ns *ns)
929{ 952{
930 struct blk_integrity integrity; 953 struct blk_integrity integrity;
@@ -951,6 +974,10 @@ static void nvme_init_integrity(struct nvme_ns *ns)
951 blk_queue_max_integrity_segments(ns->queue, 1); 974 blk_queue_max_integrity_segments(ns->queue, 1);
952} 975}
953#else 976#else
977static void nvme_prep_integrity(struct gendisk *disk, struct nvme_id_ns *id,
978 u16 bs)
979{
980}
954static void nvme_init_integrity(struct nvme_ns *ns) 981static void nvme_init_integrity(struct nvme_ns *ns)
955{ 982{
956} 983}
@@ -997,37 +1024,22 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
997static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) 1024static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
998{ 1025{
999 struct nvme_ns *ns = disk->private_data; 1026 struct nvme_ns *ns = disk->private_data;
1000 u8 lbaf, pi_type; 1027 u16 bs;
1001 u16 old_ms;
1002 unsigned short bs;
1003
1004 old_ms = ns->ms;
1005 lbaf = id->flbas & NVME_NS_FLBAS_LBA_MASK;
1006 ns->lba_shift = id->lbaf[lbaf].ds;
1007 ns->ms = le16_to_cpu(id->lbaf[lbaf].ms);
1008 ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
1009 1028
1010 /* 1029 /*
1011 * If identify namespace failed, use default 512 byte block size so 1030 * If identify namespace failed, use default 512 byte block size so
1012 * block layer can use before failing read/write for 0 capacity. 1031 * block layer can use before failing read/write for 0 capacity.
1013 */ 1032 */
1033 ns->lba_shift = id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ds;
1014 if (ns->lba_shift == 0) 1034 if (ns->lba_shift == 0)
1015 ns->lba_shift = 9; 1035 ns->lba_shift = 9;
1016 bs = 1 << ns->lba_shift; 1036 bs = 1 << ns->lba_shift;
1017 /* XXX: PI implementation requires metadata equal t10 pi tuple size */
1018 pi_type = ns->ms == sizeof(struct t10_pi_tuple) ?
1019 id->dps & NVME_NS_DPS_PI_MASK : 0;
1020 1037
1021 blk_mq_freeze_queue(disk->queue); 1038 blk_mq_freeze_queue(disk->queue);
1022 if (blk_get_integrity(disk) && (ns->pi_type != pi_type ||
1023 ns->ms != old_ms ||
1024 bs != queue_logical_block_size(disk->queue) ||
1025 (ns->ms && ns->ext)))
1026 blk_integrity_unregister(disk);
1027 1039
1028 ns->pi_type = pi_type; 1040 if (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED)
1041 nvme_prep_integrity(disk, id, bs);
1029 blk_queue_logical_block_size(ns->queue, bs); 1042 blk_queue_logical_block_size(ns->queue, bs);
1030
1031 if (ns->ms && !blk_get_integrity(disk) && !ns->ext) 1043 if (ns->ms && !blk_get_integrity(disk) && !ns->ext)
1032 nvme_init_integrity(ns); 1044 nvme_init_integrity(ns);
1033 if (ns->ms && !(ns->ms == 8 && ns->pi_type) && !blk_get_integrity(disk)) 1045 if (ns->ms && !(ns->ms == 8 && ns->pi_type) && !blk_get_integrity(disk))
@@ -1605,7 +1617,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
1605 } 1617 }
1606 memcpy(ctrl->psd, id->psd, sizeof(ctrl->psd)); 1618 memcpy(ctrl->psd, id->psd, sizeof(ctrl->psd));
1607 1619
1608 if (ctrl->ops->is_fabrics) { 1620 if (ctrl->ops->flags & NVME_F_FABRICS) {
1609 ctrl->icdoff = le16_to_cpu(id->icdoff); 1621 ctrl->icdoff = le16_to_cpu(id->icdoff);
1610 ctrl->ioccsz = le32_to_cpu(id->ioccsz); 1622 ctrl->ioccsz = le32_to_cpu(id->ioccsz);
1611 ctrl->iorcsz = le32_to_cpu(id->iorcsz); 1623 ctrl->iorcsz = le32_to_cpu(id->iorcsz);
@@ -2098,7 +2110,6 @@ static void nvme_ns_remove(struct nvme_ns *ns)
2098 if (ns->ndev) 2110 if (ns->ndev)
2099 nvme_nvm_unregister_sysfs(ns); 2111 nvme_nvm_unregister_sysfs(ns);
2100 del_gendisk(ns->disk); 2112 del_gendisk(ns->disk);
2101 blk_mq_abort_requeue_list(ns->queue);
2102 blk_cleanup_queue(ns->queue); 2113 blk_cleanup_queue(ns->queue);
2103 } 2114 }
2104 2115
@@ -2436,8 +2447,16 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
2436 continue; 2447 continue;
2437 revalidate_disk(ns->disk); 2448 revalidate_disk(ns->disk);
2438 blk_set_queue_dying(ns->queue); 2449 blk_set_queue_dying(ns->queue);
2439 blk_mq_abort_requeue_list(ns->queue); 2450
2440 blk_mq_start_stopped_hw_queues(ns->queue, true); 2451 /*
2452 * Forcibly start all queues to avoid having stuck requests.
2453 * Note that we must ensure the queues are not stopped
2454 * when the final removal happens.
2455 */
2456 blk_mq_start_hw_queues(ns->queue);
2457
2458 /* draining requests in requeue list */
2459 blk_mq_kick_requeue_list(ns->queue);
2441 } 2460 }
2442 mutex_unlock(&ctrl->namespaces_mutex); 2461 mutex_unlock(&ctrl->namespaces_mutex);
2443} 2462}
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index dca7165fabcf..5b14cbefb724 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -45,8 +45,6 @@ enum nvme_fc_queue_flags {
45 45
46#define NVMEFC_QUEUE_DELAY 3 /* ms units */ 46#define NVMEFC_QUEUE_DELAY 3 /* ms units */
47 47
48#define NVME_FC_MAX_CONNECT_ATTEMPTS 1
49
50struct nvme_fc_queue { 48struct nvme_fc_queue {
51 struct nvme_fc_ctrl *ctrl; 49 struct nvme_fc_ctrl *ctrl;
52 struct device *dev; 50 struct device *dev;
@@ -165,8 +163,6 @@ struct nvme_fc_ctrl {
165 struct work_struct delete_work; 163 struct work_struct delete_work;
166 struct work_struct reset_work; 164 struct work_struct reset_work;
167 struct delayed_work connect_work; 165 struct delayed_work connect_work;
168 int reconnect_delay;
169 int connect_attempts;
170 166
171 struct kref ref; 167 struct kref ref;
172 u32 flags; 168 u32 flags;
@@ -1376,9 +1372,9 @@ done:
1376 complete_rq = __nvme_fc_fcpop_chk_teardowns(ctrl, op); 1372 complete_rq = __nvme_fc_fcpop_chk_teardowns(ctrl, op);
1377 if (!complete_rq) { 1373 if (!complete_rq) {
1378 if (unlikely(op->flags & FCOP_FLAGS_TERMIO)) { 1374 if (unlikely(op->flags & FCOP_FLAGS_TERMIO)) {
1379 status = cpu_to_le16(NVME_SC_ABORT_REQ); 1375 status = cpu_to_le16(NVME_SC_ABORT_REQ << 1);
1380 if (blk_queue_dying(rq->q)) 1376 if (blk_queue_dying(rq->q))
1381 status |= cpu_to_le16(NVME_SC_DNR); 1377 status |= cpu_to_le16(NVME_SC_DNR << 1);
1382 } 1378 }
1383 nvme_end_request(rq, status, result); 1379 nvme_end_request(rq, status, result);
1384 } else 1380 } else
@@ -1751,7 +1747,7 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
1751 dev_warn(ctrl->ctrl.device, 1747 dev_warn(ctrl->ctrl.device,
1752 "NVME-FC{%d}: transport association error detected: %s\n", 1748 "NVME-FC{%d}: transport association error detected: %s\n",
1753 ctrl->cnum, errmsg); 1749 ctrl->cnum, errmsg);
1754 dev_info(ctrl->ctrl.device, 1750 dev_warn(ctrl->ctrl.device,
1755 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); 1751 "NVME-FC{%d}: resetting controller\n", ctrl->cnum);
1756 1752
1757 /* stop the queues on error, cleanup is in reset thread */ 1753 /* stop the queues on error, cleanup is in reset thread */
@@ -2195,9 +2191,6 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
2195 if (!opts->nr_io_queues) 2191 if (!opts->nr_io_queues)
2196 return 0; 2192 return 0;
2197 2193
2198 dev_info(ctrl->ctrl.device, "creating %d I/O queues.\n",
2199 opts->nr_io_queues);
2200
2201 nvme_fc_init_io_queues(ctrl); 2194 nvme_fc_init_io_queues(ctrl);
2202 2195
2203 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); 2196 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
@@ -2268,9 +2261,6 @@ nvme_fc_reinit_io_queues(struct nvme_fc_ctrl *ctrl)
2268 if (ctrl->queue_count == 1) 2261 if (ctrl->queue_count == 1)
2269 return 0; 2262 return 0;
2270 2263
2271 dev_info(ctrl->ctrl.device, "Recreating %d I/O queues.\n",
2272 opts->nr_io_queues);
2273
2274 nvme_fc_init_io_queues(ctrl); 2264 nvme_fc_init_io_queues(ctrl);
2275 2265
2276 ret = blk_mq_reinit_tagset(&ctrl->tag_set); 2266 ret = blk_mq_reinit_tagset(&ctrl->tag_set);
@@ -2306,7 +2296,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
2306 int ret; 2296 int ret;
2307 bool changed; 2297 bool changed;
2308 2298
2309 ctrl->connect_attempts++; 2299 ++ctrl->ctrl.opts->nr_reconnects;
2310 2300
2311 /* 2301 /*
2312 * Create the admin queue 2302 * Create the admin queue
@@ -2403,9 +2393,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
2403 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 2393 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
2404 WARN_ON_ONCE(!changed); 2394 WARN_ON_ONCE(!changed);
2405 2395
2406 ctrl->connect_attempts = 0; 2396 ctrl->ctrl.opts->nr_reconnects = 0;
2407
2408 kref_get(&ctrl->ctrl.kref);
2409 2397
2410 if (ctrl->queue_count > 1) { 2398 if (ctrl->queue_count > 1) {
2411 nvme_start_queues(&ctrl->ctrl); 2399 nvme_start_queues(&ctrl->ctrl);
@@ -2536,26 +2524,32 @@ nvme_fc_delete_ctrl_work(struct work_struct *work)
2536 2524
2537 /* 2525 /*
2538 * tear down the controller 2526 * tear down the controller
2539 * This will result in the last reference on the nvme ctrl to 2527 * After the last reference on the nvme ctrl is removed,
2540 * expire, calling the transport nvme_fc_nvme_ctrl_freed() callback. 2528 * the transport nvme_fc_nvme_ctrl_freed() callback will be
2541 * From there, the transport will tear down it's logical queues and 2529 * invoked. From there, the transport will tear down it's
2542 * association. 2530 * logical queues and association.
2543 */ 2531 */
2544 nvme_uninit_ctrl(&ctrl->ctrl); 2532 nvme_uninit_ctrl(&ctrl->ctrl);
2545 2533
2546 nvme_put_ctrl(&ctrl->ctrl); 2534 nvme_put_ctrl(&ctrl->ctrl);
2547} 2535}
2548 2536
2549static int 2537static bool
2550__nvme_fc_del_ctrl(struct nvme_fc_ctrl *ctrl) 2538__nvme_fc_schedule_delete_work(struct nvme_fc_ctrl *ctrl)
2551{ 2539{
2552 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 2540 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING))
2553 return -EBUSY; 2541 return true;
2554 2542
2555 if (!queue_work(nvme_fc_wq, &ctrl->delete_work)) 2543 if (!queue_work(nvme_fc_wq, &ctrl->delete_work))
2556 return -EBUSY; 2544 return true;
2557 2545
2558 return 0; 2546 return false;
2547}
2548
2549static int
2550__nvme_fc_del_ctrl(struct nvme_fc_ctrl *ctrl)
2551{
2552 return __nvme_fc_schedule_delete_work(ctrl) ? -EBUSY : 0;
2559} 2553}
2560 2554
2561/* 2555/*
@@ -2581,6 +2575,35 @@ nvme_fc_del_nvme_ctrl(struct nvme_ctrl *nctrl)
2581} 2575}
2582 2576
2583static void 2577static void
2578nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
2579{
2580 /* If we are resetting/deleting then do nothing */
2581 if (ctrl->ctrl.state != NVME_CTRL_RECONNECTING) {
2582 WARN_ON_ONCE(ctrl->ctrl.state == NVME_CTRL_NEW ||
2583 ctrl->ctrl.state == NVME_CTRL_LIVE);
2584 return;
2585 }
2586
2587 dev_info(ctrl->ctrl.device,
2588 "NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n",
2589 ctrl->cnum, status);
2590
2591 if (nvmf_should_reconnect(&ctrl->ctrl)) {
2592 dev_info(ctrl->ctrl.device,
2593 "NVME-FC{%d}: Reconnect attempt in %d seconds.\n",
2594 ctrl->cnum, ctrl->ctrl.opts->reconnect_delay);
2595 queue_delayed_work(nvme_fc_wq, &ctrl->connect_work,
2596 ctrl->ctrl.opts->reconnect_delay * HZ);
2597 } else {
2598 dev_warn(ctrl->ctrl.device,
2599 "NVME-FC{%d}: Max reconnect attempts (%d) "
2600 "reached. Removing controller\n",
2601 ctrl->cnum, ctrl->ctrl.opts->nr_reconnects);
2602 WARN_ON(__nvme_fc_schedule_delete_work(ctrl));
2603 }
2604}
2605
2606static void
2584nvme_fc_reset_ctrl_work(struct work_struct *work) 2607nvme_fc_reset_ctrl_work(struct work_struct *work)
2585{ 2608{
2586 struct nvme_fc_ctrl *ctrl = 2609 struct nvme_fc_ctrl *ctrl =
@@ -2591,34 +2614,9 @@ nvme_fc_reset_ctrl_work(struct work_struct *work)
2591 nvme_fc_delete_association(ctrl); 2614 nvme_fc_delete_association(ctrl);
2592 2615
2593 ret = nvme_fc_create_association(ctrl); 2616 ret = nvme_fc_create_association(ctrl);
2594 if (ret) { 2617 if (ret)
2595 dev_warn(ctrl->ctrl.device, 2618 nvme_fc_reconnect_or_delete(ctrl, ret);
2596 "NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n", 2619 else
2597 ctrl->cnum, ret);
2598 if (ctrl->connect_attempts >= NVME_FC_MAX_CONNECT_ATTEMPTS) {
2599 dev_warn(ctrl->ctrl.device,
2600 "NVME-FC{%d}: Max reconnect attempts (%d) "
2601 "reached. Removing controller\n",
2602 ctrl->cnum, ctrl->connect_attempts);
2603
2604 if (!nvme_change_ctrl_state(&ctrl->ctrl,
2605 NVME_CTRL_DELETING)) {
2606 dev_err(ctrl->ctrl.device,
2607 "NVME-FC{%d}: failed to change state "
2608 "to DELETING\n", ctrl->cnum);
2609 return;
2610 }
2611
2612 WARN_ON(!queue_work(nvme_fc_wq, &ctrl->delete_work));
2613 return;
2614 }
2615
2616 dev_warn(ctrl->ctrl.device,
2617 "NVME-FC{%d}: Reconnect attempt in %d seconds.\n",
2618 ctrl->cnum, ctrl->reconnect_delay);
2619 queue_delayed_work(nvme_fc_wq, &ctrl->connect_work,
2620 ctrl->reconnect_delay * HZ);
2621 } else
2622 dev_info(ctrl->ctrl.device, 2620 dev_info(ctrl->ctrl.device,
2623 "NVME-FC{%d}: controller reset complete\n", ctrl->cnum); 2621 "NVME-FC{%d}: controller reset complete\n", ctrl->cnum);
2624} 2622}
@@ -2632,7 +2630,7 @@ nvme_fc_reset_nvme_ctrl(struct nvme_ctrl *nctrl)
2632{ 2630{
2633 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); 2631 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
2634 2632
2635 dev_warn(ctrl->ctrl.device, 2633 dev_info(ctrl->ctrl.device,
2636 "NVME-FC{%d}: admin requested controller reset\n", ctrl->cnum); 2634 "NVME-FC{%d}: admin requested controller reset\n", ctrl->cnum);
2637 2635
2638 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) 2636 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING))
@@ -2649,7 +2647,7 @@ nvme_fc_reset_nvme_ctrl(struct nvme_ctrl *nctrl)
2649static const struct nvme_ctrl_ops nvme_fc_ctrl_ops = { 2647static const struct nvme_ctrl_ops nvme_fc_ctrl_ops = {
2650 .name = "fc", 2648 .name = "fc",
2651 .module = THIS_MODULE, 2649 .module = THIS_MODULE,
2652 .is_fabrics = true, 2650 .flags = NVME_F_FABRICS,
2653 .reg_read32 = nvmf_reg_read32, 2651 .reg_read32 = nvmf_reg_read32,
2654 .reg_read64 = nvmf_reg_read64, 2652 .reg_read64 = nvmf_reg_read64,
2655 .reg_write32 = nvmf_reg_write32, 2653 .reg_write32 = nvmf_reg_write32,
@@ -2671,34 +2669,9 @@ nvme_fc_connect_ctrl_work(struct work_struct *work)
2671 struct nvme_fc_ctrl, connect_work); 2669 struct nvme_fc_ctrl, connect_work);
2672 2670
2673 ret = nvme_fc_create_association(ctrl); 2671 ret = nvme_fc_create_association(ctrl);
2674 if (ret) { 2672 if (ret)
2675 dev_warn(ctrl->ctrl.device, 2673 nvme_fc_reconnect_or_delete(ctrl, ret);
2676 "NVME-FC{%d}: Reconnect attempt failed (%d)\n", 2674 else
2677 ctrl->cnum, ret);
2678 if (ctrl->connect_attempts >= NVME_FC_MAX_CONNECT_ATTEMPTS) {
2679 dev_warn(ctrl->ctrl.device,
2680 "NVME-FC{%d}: Max reconnect attempts (%d) "
2681 "reached. Removing controller\n",
2682 ctrl->cnum, ctrl->connect_attempts);
2683
2684 if (!nvme_change_ctrl_state(&ctrl->ctrl,
2685 NVME_CTRL_DELETING)) {
2686 dev_err(ctrl->ctrl.device,
2687 "NVME-FC{%d}: failed to change state "
2688 "to DELETING\n", ctrl->cnum);
2689 return;
2690 }
2691
2692 WARN_ON(!queue_work(nvme_fc_wq, &ctrl->delete_work));
2693 return;
2694 }
2695
2696 dev_warn(ctrl->ctrl.device,
2697 "NVME-FC{%d}: Reconnect attempt in %d seconds.\n",
2698 ctrl->cnum, ctrl->reconnect_delay);
2699 queue_delayed_work(nvme_fc_wq, &ctrl->connect_work,
2700 ctrl->reconnect_delay * HZ);
2701 } else
2702 dev_info(ctrl->ctrl.device, 2675 dev_info(ctrl->ctrl.device,
2703 "NVME-FC{%d}: controller reconnect complete\n", 2676 "NVME-FC{%d}: controller reconnect complete\n",
2704 ctrl->cnum); 2677 ctrl->cnum);
@@ -2755,7 +2728,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2755 INIT_WORK(&ctrl->delete_work, nvme_fc_delete_ctrl_work); 2728 INIT_WORK(&ctrl->delete_work, nvme_fc_delete_ctrl_work);
2756 INIT_WORK(&ctrl->reset_work, nvme_fc_reset_ctrl_work); 2729 INIT_WORK(&ctrl->reset_work, nvme_fc_reset_ctrl_work);
2757 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); 2730 INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work);
2758 ctrl->reconnect_delay = opts->reconnect_delay;
2759 spin_lock_init(&ctrl->lock); 2731 spin_lock_init(&ctrl->lock);
2760 2732
2761 /* io queue count */ 2733 /* io queue count */
@@ -2819,7 +2791,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2819 ctrl->ctrl.opts = NULL; 2791 ctrl->ctrl.opts = NULL;
2820 /* initiate nvme ctrl ref counting teardown */ 2792 /* initiate nvme ctrl ref counting teardown */
2821 nvme_uninit_ctrl(&ctrl->ctrl); 2793 nvme_uninit_ctrl(&ctrl->ctrl);
2822 nvme_put_ctrl(&ctrl->ctrl);
2823 2794
2824 /* as we're past the point where we transition to the ref 2795 /* as we're past the point where we transition to the ref
2825 * counting teardown path, if we return a bad pointer here, 2796 * counting teardown path, if we return a bad pointer here,
@@ -2835,6 +2806,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2835 return ERR_PTR(ret); 2806 return ERR_PTR(ret);
2836 } 2807 }
2837 2808
2809 kref_get(&ctrl->ctrl.kref);
2810
2838 dev_info(ctrl->ctrl.device, 2811 dev_info(ctrl->ctrl.device,
2839 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n", 2812 "NVME-FC{%d}: new ctrl: NQN \"%s\"\n",
2840 ctrl->cnum, ctrl->ctrl.opts->subsysnqn); 2813 ctrl->cnum, ctrl->ctrl.opts->subsysnqn);
@@ -2971,7 +2944,7 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts)
2971static struct nvmf_transport_ops nvme_fc_transport = { 2944static struct nvmf_transport_ops nvme_fc_transport = {
2972 .name = "fc", 2945 .name = "fc",
2973 .required_opts = NVMF_OPT_TRADDR | NVMF_OPT_HOST_TRADDR, 2946 .required_opts = NVMF_OPT_TRADDR | NVMF_OPT_HOST_TRADDR,
2974 .allowed_opts = NVMF_OPT_RECONNECT_DELAY, 2947 .allowed_opts = NVMF_OPT_RECONNECT_DELAY | NVMF_OPT_CTRL_LOSS_TMO,
2975 .create_ctrl = nvme_fc_create_ctrl, 2948 .create_ctrl = nvme_fc_create_ctrl,
2976}; 2949};
2977 2950
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 29c708ca9621..9d6a070d4391 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -208,7 +208,9 @@ struct nvme_ns {
208struct nvme_ctrl_ops { 208struct nvme_ctrl_ops {
209 const char *name; 209 const char *name;
210 struct module *module; 210 struct module *module;
211 bool is_fabrics; 211 unsigned int flags;
212#define NVME_F_FABRICS (1 << 0)
213#define NVME_F_METADATA_SUPPORTED (1 << 1)
212 int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val); 214 int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
213 int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val); 215 int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
214 int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val); 216 int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4c2ff2bb26bc..d52701df7245 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -263,7 +263,7 @@ static void nvme_dbbuf_set(struct nvme_dev *dev)
263 c.dbbuf.prp2 = cpu_to_le64(dev->dbbuf_eis_dma_addr); 263 c.dbbuf.prp2 = cpu_to_le64(dev->dbbuf_eis_dma_addr);
264 264
265 if (nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0)) { 265 if (nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0)) {
266 dev_warn(dev->dev, "unable to set dbbuf\n"); 266 dev_warn(dev->ctrl.device, "unable to set dbbuf\n");
267 /* Free memory and continue on */ 267 /* Free memory and continue on */
268 nvme_dbbuf_dma_free(dev); 268 nvme_dbbuf_dma_free(dev);
269 } 269 }
@@ -1394,11 +1394,11 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)
1394 result = pci_read_config_word(to_pci_dev(dev->dev), PCI_STATUS, 1394 result = pci_read_config_word(to_pci_dev(dev->dev), PCI_STATUS,
1395 &pci_status); 1395 &pci_status);
1396 if (result == PCIBIOS_SUCCESSFUL) 1396 if (result == PCIBIOS_SUCCESSFUL)
1397 dev_warn(dev->dev, 1397 dev_warn(dev->ctrl.device,
1398 "controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n", 1398 "controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n",
1399 csts, pci_status); 1399 csts, pci_status);
1400 else 1400 else
1401 dev_warn(dev->dev, 1401 dev_warn(dev->ctrl.device,
1402 "controller is down; will reset: CSTS=0x%x, PCI_STATUS read failed (%d)\n", 1402 "controller is down; will reset: CSTS=0x%x, PCI_STATUS read failed (%d)\n",
1403 csts, result); 1403 csts, result);
1404} 1404}
@@ -1740,8 +1740,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1740 */ 1740 */
1741 if (pdev->vendor == PCI_VENDOR_ID_APPLE && pdev->device == 0x2001) { 1741 if (pdev->vendor == PCI_VENDOR_ID_APPLE && pdev->device == 0x2001) {
1742 dev->q_depth = 2; 1742 dev->q_depth = 2;
1743 dev_warn(dev->dev, "detected Apple NVMe controller, set " 1743 dev_warn(dev->ctrl.device, "detected Apple NVMe controller, "
1744 "queue depth=%u to work around controller resets\n", 1744 "set queue depth=%u to work around controller resets\n",
1745 dev->q_depth); 1745 dev->q_depth);
1746 } 1746 }
1747 1747
@@ -1759,7 +1759,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1759 if (dev->cmbsz) { 1759 if (dev->cmbsz) {
1760 if (sysfs_add_file_to_group(&dev->ctrl.device->kobj, 1760 if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
1761 &dev_attr_cmb.attr, NULL)) 1761 &dev_attr_cmb.attr, NULL))
1762 dev_warn(dev->dev, 1762 dev_warn(dev->ctrl.device,
1763 "failed to add sysfs attribute for CMB\n"); 1763 "failed to add sysfs attribute for CMB\n");
1764 } 1764 }
1765 } 1765 }
@@ -2047,6 +2047,7 @@ static int nvme_pci_reset_ctrl(struct nvme_ctrl *ctrl)
2047static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = { 2047static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
2048 .name = "pcie", 2048 .name = "pcie",
2049 .module = THIS_MODULE, 2049 .module = THIS_MODULE,
2050 .flags = NVME_F_METADATA_SUPPORTED,
2050 .reg_read32 = nvme_pci_reg_read32, 2051 .reg_read32 = nvme_pci_reg_read32,
2051 .reg_write32 = nvme_pci_reg_write32, 2052 .reg_write32 = nvme_pci_reg_write32,
2052 .reg_read64 = nvme_pci_reg_read64, 2053 .reg_read64 = nvme_pci_reg_read64,
@@ -2293,6 +2294,8 @@ static const struct pci_device_id nvme_id_table[] = {
2293 { PCI_VDEVICE(INTEL, 0x0a54), 2294 { PCI_VDEVICE(INTEL, 0x0a54),
2294 .driver_data = NVME_QUIRK_STRIPE_SIZE | 2295 .driver_data = NVME_QUIRK_STRIPE_SIZE |
2295 NVME_QUIRK_DEALLOCATE_ZEROES, }, 2296 NVME_QUIRK_DEALLOCATE_ZEROES, },
2297 { PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
2298 .driver_data = NVME_QUIRK_NO_DEEPEST_PS },
2296 { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ 2299 { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */
2297 .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, 2300 .driver_data = NVME_QUIRK_IDENTIFY_CNS, },
2298 { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ 2301 { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index dd1c6deef82f..28bd255c144d 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1038,6 +1038,19 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
1038 nvme_rdma_wr_error(cq, wc, "SEND"); 1038 nvme_rdma_wr_error(cq, wc, "SEND");
1039} 1039}
1040 1040
1041static inline int nvme_rdma_queue_sig_limit(struct nvme_rdma_queue *queue)
1042{
1043 int sig_limit;
1044
1045 /*
1046 * We signal completion every queue depth/2 and also handle the
1047 * degenerated case of a device with queue_depth=1, where we
1048 * would need to signal every message.
1049 */
1050 sig_limit = max(queue->queue_size / 2, 1);
1051 return (++queue->sig_count % sig_limit) == 0;
1052}
1053
1041static int nvme_rdma_post_send(struct nvme_rdma_queue *queue, 1054static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
1042 struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge, 1055 struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
1043 struct ib_send_wr *first, bool flush) 1056 struct ib_send_wr *first, bool flush)
@@ -1065,9 +1078,6 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
1065 * Would have been way to obvious to handle this in hardware or 1078 * Would have been way to obvious to handle this in hardware or
1066 * at least the RDMA stack.. 1079 * at least the RDMA stack..
1067 * 1080 *
1068 * This messy and racy code sniplet is copy and pasted from the iSER
1069 * initiator, and the magic '32' comes from there as well.
1070 *
1071 * Always signal the flushes. The magic request used for the flush 1081 * Always signal the flushes. The magic request used for the flush
1072 * sequencer is not allocated in our driver's tagset and it's 1082 * sequencer is not allocated in our driver's tagset and it's
1073 * triggered to be freed by blk_cleanup_queue(). So we need to 1083 * triggered to be freed by blk_cleanup_queue(). So we need to
@@ -1075,7 +1085,7 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
1075 * embedded in request's payload, is not freed when __ib_process_cq() 1085 * embedded in request's payload, is not freed when __ib_process_cq()
1076 * calls wr_cqe->done(). 1086 * calls wr_cqe->done().
1077 */ 1087 */
1078 if ((++queue->sig_count % 32) == 0 || flush) 1088 if (nvme_rdma_queue_sig_limit(queue) || flush)
1079 wr.send_flags |= IB_SEND_SIGNALED; 1089 wr.send_flags |= IB_SEND_SIGNALED;
1080 1090
1081 if (first) 1091 if (first)
@@ -1782,7 +1792,7 @@ static int nvme_rdma_reset_ctrl(struct nvme_ctrl *nctrl)
1782static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { 1792static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = {
1783 .name = "rdma", 1793 .name = "rdma",
1784 .module = THIS_MODULE, 1794 .module = THIS_MODULE,
1785 .is_fabrics = true, 1795 .flags = NVME_F_FABRICS,
1786 .reg_read32 = nvmf_reg_read32, 1796 .reg_read32 = nvmf_reg_read32,
1787 .reg_read64 = nvmf_reg_read64, 1797 .reg_read64 = nvmf_reg_read64,
1788 .reg_write32 = nvmf_reg_write32, 1798 .reg_write32 = nvmf_reg_write32,
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index feb497134aee..e503cfff0337 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -558,7 +558,7 @@ static int nvme_loop_reset_ctrl(struct nvme_ctrl *nctrl)
558static const struct nvme_ctrl_ops nvme_loop_ctrl_ops = { 558static const struct nvme_ctrl_ops nvme_loop_ctrl_ops = {
559 .name = "loop", 559 .name = "loop",
560 .module = THIS_MODULE, 560 .module = THIS_MODULE,
561 .is_fabrics = true, 561 .flags = NVME_F_FABRICS,
562 .reg_read32 = nvmf_reg_read32, 562 .reg_read32 = nvmf_reg_read32,
563 .reg_read64 = nvmf_reg_read64, 563 .reg_read64 = nvmf_reg_read64,
564 .reg_write32 = nvmf_reg_write32, 564 .reg_write32 = nvmf_reg_write32,
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index c47aa248c640..fcd641032f8d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -238,7 +238,6 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
238 bool kick_requeue_list); 238 bool kick_requeue_list);
239void blk_mq_kick_requeue_list(struct request_queue *q); 239void blk_mq_kick_requeue_list(struct request_queue *q);
240void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs); 240void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs);
241void blk_mq_abort_requeue_list(struct request_queue *q);
242void blk_mq_complete_request(struct request *rq); 241void blk_mq_complete_request(struct request *rq);
243 242
244bool blk_mq_queue_stopped(struct request_queue *q); 243bool blk_mq_queue_stopped(struct request_queue *q);