Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"A set of fixes for the current series in the realm of block.

Like the previous pull request, the meat of it are fixes for the nvme
fabrics/target code. Outside of that, just one fix from Gabriel for
not doing a queue suspend if we didn't get the admin queue setup in
the first place"

* 'for-linus' of git://git.kernel.dk/linux-block:
nvme-rdma: add back dependency on CONFIG_BLOCK
nvme-rdma: fix null pointer dereference on req->mr
nvme-rdma: use ib_client API to detect device removal
nvme-rdma: add DELETING queue flag
nvme/quirk: Add a delay before checking device ready for memblaze device
nvme: Don't suspend admin queue that wasn't created
nvme-rdma: destroy nvme queue rdma resources on connect failure
nvme_rdma: keep a ref on the ctrl during delete/flush
iw_cxgb4: block module unload until all ep resources are released
iw_cxgb4: call dev_put() on l2t allocation failure

+90 -75
+5 -1
drivers/infiniband/hw/cxgb4/cm.c
··· 333 333 334 334 spin_lock_irqsave(&ep->com.dev->lock, flags); 335 335 _remove_handle(ep->com.dev, &ep->com.dev->hwtid_idr, ep->hwtid, 0); 336 + if (idr_is_empty(&ep->com.dev->hwtid_idr)) 337 + wake_up(&ep->com.dev->wait); 336 338 spin_unlock_irqrestore(&ep->com.dev->lock, flags); 337 339 } 338 340 ··· 2119 2117 } 2120 2118 ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, 2121 2119 n, pdev, rt_tos2priority(tos)); 2122 - if (!ep->l2t) 2120 + if (!ep->l2t) { 2121 + dev_put(pdev); 2123 2122 goto out; 2123 + } 2124 2124 ep->mtu = pdev->mtu; 2125 2125 ep->tx_chan = cxgb4_port_chan(pdev); 2126 2126 ep->smac_idx = cxgb4_tp_smt_idx(adapter_type,
+5
drivers/infiniband/hw/cxgb4/device.c
··· 872 872 static void c4iw_dealloc(struct uld_ctx *ctx) 873 873 { 874 874 c4iw_rdev_close(&ctx->dev->rdev); 875 + WARN_ON_ONCE(!idr_is_empty(&ctx->dev->cqidr)); 875 876 idr_destroy(&ctx->dev->cqidr); 877 + WARN_ON_ONCE(!idr_is_empty(&ctx->dev->qpidr)); 876 878 idr_destroy(&ctx->dev->qpidr); 879 + WARN_ON_ONCE(!idr_is_empty(&ctx->dev->mmidr)); 877 880 idr_destroy(&ctx->dev->mmidr); 881 + wait_event(ctx->dev->wait, idr_is_empty(&ctx->dev->hwtid_idr)); 878 882 idr_destroy(&ctx->dev->hwtid_idr); 879 883 idr_destroy(&ctx->dev->stid_idr); 880 884 idr_destroy(&ctx->dev->atid_idr); ··· 996 992 mutex_init(&devp->rdev.stats.lock); 997 993 mutex_init(&devp->db_mutex); 998 994 INIT_LIST_HEAD(&devp->db_fc_list); 995 + init_waitqueue_head(&devp->wait); 999 996 devp->avail_ird = devp->rdev.lldi.max_ird_adapter; 1000 997 1001 998 if (c4iw_debugfs_root) {
+1
drivers/infiniband/hw/cxgb4/iw_cxgb4.h
··· 263 263 struct idr stid_idr; 264 264 struct list_head db_fc_list; 265 265 u32 avail_ird; 266 + wait_queue_head_t wait; 266 267 }; 267 268 268 269 static inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev)
+8 -1
drivers/nvme/host/pci.c
··· 1693 1693 nvme_suspend_queue(dev->queues[i]); 1694 1694 1695 1695 if (csts & NVME_CSTS_CFS || !(csts & NVME_CSTS_RDY)) { 1696 - nvme_suspend_queue(dev->queues[0]); 1696 + /* A device might become IO incapable very soon during 1697 + * probe, before the admin queue is configured. Thus, 1698 + * queue_count can be 0 here. 1699 + */ 1700 + if (dev->queue_count) 1701 + nvme_suspend_queue(dev->queues[0]); 1697 1702 } else { 1698 1703 nvme_disable_io_queues(dev); 1699 1704 nvme_disable_admin_queue(dev, shutdown); ··· 2116 2111 { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ 2117 2112 .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, 2118 2113 { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ 2114 + .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, 2115 + { PCI_DEVICE(0x1c5f, 0x0540), /* Memblaze Pblaze4 adapter */ 2119 2116 .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, 2120 2117 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, 2121 2118 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) },
+71 -73
drivers/nvme/host/rdma.c
··· 82 82 83 83 enum nvme_rdma_queue_flags { 84 84 NVME_RDMA_Q_CONNECTED = (1 << 0), 85 + NVME_RDMA_IB_QUEUE_ALLOCATED = (1 << 1), 86 + NVME_RDMA_Q_DELETING = (1 << 2), 85 87 }; 86 88 87 89 struct nvme_rdma_queue { ··· 293 291 if (IS_ERR(req->mr)) { 294 292 ret = PTR_ERR(req->mr); 295 293 req->mr = NULL; 294 + goto out; 296 295 } 297 296 298 297 req->mr->need_inval = false; ··· 483 480 484 481 static void nvme_rdma_destroy_queue_ib(struct nvme_rdma_queue *queue) 485 482 { 486 - struct nvme_rdma_device *dev = queue->device; 487 - struct ib_device *ibdev = dev->dev; 483 + struct nvme_rdma_device *dev; 484 + struct ib_device *ibdev; 488 485 486 + if (!test_and_clear_bit(NVME_RDMA_IB_QUEUE_ALLOCATED, &queue->flags)) 487 + return; 488 + 489 + dev = queue->device; 490 + ibdev = dev->dev; 489 491 rdma_destroy_qp(queue->cm_id); 490 492 ib_free_cq(queue->ib_cq); 491 493 ··· 541 533 ret = -ENOMEM; 542 534 goto out_destroy_qp; 543 535 } 536 + set_bit(NVME_RDMA_IB_QUEUE_ALLOCATED, &queue->flags); 544 537 545 538 return 0; 546 539 ··· 561 552 562 553 queue = &ctrl->queues[idx]; 563 554 queue->ctrl = ctrl; 555 + queue->flags = 0; 564 556 init_completion(&queue->cm_done); 565 557 566 558 if (idx > 0) ··· 600 590 return 0; 601 591 602 592 out_destroy_cm_id: 593 + nvme_rdma_destroy_queue_ib(queue); 603 594 rdma_destroy_id(queue->cm_id); 604 595 return ret; 605 596 } ··· 619 608 620 609 static void nvme_rdma_stop_and_free_queue(struct nvme_rdma_queue *queue) 621 610 { 622 - if (!test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags)) 611 + if (test_and_set_bit(NVME_RDMA_Q_DELETING, &queue->flags)) 623 612 return; 624 613 nvme_rdma_stop_queue(queue); 625 614 nvme_rdma_free_queue(queue); ··· 663 652 return 0; 664 653 665 654 out_free_queues: 666 - for (; i >= 1; i--) 655 + for (i--; i >= 1; i--) 667 656 nvme_rdma_stop_and_free_queue(&ctrl->queues[i]); 668 657 669 658 return ret; ··· 772 761 { 773 762 struct nvme_rdma_ctrl *ctrl = container_of(work, 774 763 struct nvme_rdma_ctrl, err_work); 764 + int i; 775 765 776 766 nvme_stop_keep_alive(&ctrl->ctrl); 767 + 768 + for (i = 0; i < ctrl->queue_count; i++) 769 + clear_bit(NVME_RDMA_Q_CONNECTED, &ctrl->queues[i].flags); 770 + 777 771 if (ctrl->queue_count > 1) 778 772 nvme_stop_queues(&ctrl->ctrl); 779 773 blk_mq_stop_hw_queues(ctrl->ctrl.admin_q); ··· 1321 1305 return ret; 1322 1306 } 1323 1307 1324 - /** 1325 - * nvme_rdma_device_unplug() - Handle RDMA device unplug 1326 - * @queue: Queue that owns the cm_id that caught the event 1327 - * 1328 - * DEVICE_REMOVAL event notifies us that the RDMA device is about 1329 - * to unplug so we should take care of destroying our RDMA resources. 1330 - * This event will be generated for each allocated cm_id. 1331 - * 1332 - * In our case, the RDMA resources are managed per controller and not 1333 - * only per queue. So the way we handle this is we trigger an implicit 1334 - * controller deletion upon the first DEVICE_REMOVAL event we see, and 1335 - * hold the event inflight until the controller deletion is completed. 1336 - * 1337 - * One exception that we need to handle is the destruction of the cm_id 1338 - * that caught the event. Since we hold the callout until the controller 1339 - * deletion is completed, we'll deadlock if the controller deletion will 1340 - * call rdma_destroy_id on this queue's cm_id. Thus, we claim ownership 1341 - * of destroying this queue before-hand, destroy the queue resources, 1342 - * then queue the controller deletion which won't destroy this queue and 1343 - * we destroy the cm_id implicitely by returning a non-zero rc to the callout. 1344 - */ 1345 - static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue) 1346 - { 1347 - struct nvme_rdma_ctrl *ctrl = queue->ctrl; 1348 - int ret = 0; 1349 - 1350 - /* Own the controller deletion */ 1351 - if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 1352 - return 0; 1353 - 1354 - dev_warn(ctrl->ctrl.device, 1355 - "Got rdma device removal event, deleting ctrl\n"); 1356 - 1357 - /* Get rid of reconnect work if its running */ 1358 - cancel_delayed_work_sync(&ctrl->reconnect_work); 1359 - 1360 - /* Disable the queue so ctrl delete won't free it */ 1361 - if (test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags)) { 1362 - /* Free this queue ourselves */ 1363 - nvme_rdma_stop_queue(queue); 1364 - nvme_rdma_destroy_queue_ib(queue); 1365 - 1366 - /* Return non-zero so the cm_id will destroy implicitly */ 1367 - ret = 1; 1368 - } 1369 - 1370 - /* Queue controller deletion */ 1371 - queue_work(nvme_rdma_wq, &ctrl->delete_work); 1372 - flush_work(&ctrl->delete_work); 1373 - return ret; 1374 - } 1375 - 1376 1308 static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id, 1377 1309 struct rdma_cm_event *ev) 1378 1310 { ··· 1362 1398 nvme_rdma_error_recovery(queue->ctrl); 1363 1399 break; 1364 1400 case RDMA_CM_EVENT_DEVICE_REMOVAL: 1365 - /* return 1 means impliciy CM ID destroy */ 1366 - return nvme_rdma_device_unplug(queue); 1401 + /* device removal is handled via the ib_client API */ 1402 + break; 1367 1403 default: 1368 1404 dev_err(queue->ctrl->ctrl.device, 1369 1405 "Unexpected RDMA CM event (%d)\n", ev->event); ··· 1664 1700 static int nvme_rdma_del_ctrl(struct nvme_ctrl *nctrl) 1665 1701 { 1666 1702 struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl); 1667 - int ret; 1703 + int ret = 0; 1668 1704 1705 + /* 1706 + * Keep a reference until all work is flushed since 1707 + * __nvme_rdma_del_ctrl can free the ctrl mem 1708 + */ 1709 + if (!kref_get_unless_zero(&ctrl->ctrl.kref)) 1710 + return -EBUSY; 1669 1711 ret = __nvme_rdma_del_ctrl(ctrl); 1670 - if (ret) 1671 - return ret; 1672 - 1673 - flush_work(&ctrl->delete_work); 1674 - 1675 - return 0; 1712 + if (!ret) 1713 + flush_work(&ctrl->delete_work); 1714 + nvme_put_ctrl(&ctrl->ctrl); 1715 + return ret; 1676 1716 } 1677 1717 1678 1718 static void nvme_rdma_remove_ctrl_work(struct work_struct *work) ··· 1973 2005 .create_ctrl = nvme_rdma_create_ctrl, 1974 2006 }; 1975 2007 2008 + static void nvme_rdma_add_one(struct ib_device *ib_device) 2009 + { 2010 + } 2011 + 2012 + static void nvme_rdma_remove_one(struct ib_device *ib_device, void *client_data) 2013 + { 2014 + struct nvme_rdma_ctrl *ctrl; 2015 + 2016 + /* Delete all controllers using this device */ 2017 + mutex_lock(&nvme_rdma_ctrl_mutex); 2018 + list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) { 2019 + if (ctrl->device->dev != ib_device) 2020 + continue; 2021 + dev_info(ctrl->ctrl.device, 2022 + "Removing ctrl: NQN \"%s\", addr %pISp\n", 2023 + ctrl->ctrl.opts->subsysnqn, &ctrl->addr); 2024 + __nvme_rdma_del_ctrl(ctrl); 2025 + } 2026 + mutex_unlock(&nvme_rdma_ctrl_mutex); 2027 + 2028 + flush_workqueue(nvme_rdma_wq); 2029 + } 2030 + 2031 + static struct ib_client nvme_rdma_ib_client = { 2032 + .name = "nvme_rdma", 2033 + .add = nvme_rdma_add_one, 2034 + .remove = nvme_rdma_remove_one 2035 + }; 2036 + 1976 2037 static int __init nvme_rdma_init_module(void) 1977 2038 { 2039 + int ret; 2040 + 1978 2041 nvme_rdma_wq = create_workqueue("nvme_rdma_wq"); 1979 2042 if (!nvme_rdma_wq) 1980 2043 return -ENOMEM; 2044 + 2045 + ret = ib_register_client(&nvme_rdma_ib_client); 2046 + if (ret) { 2047 + destroy_workqueue(nvme_rdma_wq); 2048 + return ret; 2049 + } 1981 2050 1982 2051 nvmf_register_transport(&nvme_rdma_transport); 1983 2052 return 0; ··· 2022 2017 2023 2018 static void __exit nvme_rdma_cleanup_module(void) 2024 2019 { 2025 - struct nvme_rdma_ctrl *ctrl; 2026 - 2027 2020 nvmf_unregister_transport(&nvme_rdma_transport); 2028 - 2029 - mutex_lock(&nvme_rdma_ctrl_mutex); 2030 - list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) 2031 - __nvme_rdma_del_ctrl(ctrl); 2032 - mutex_unlock(&nvme_rdma_ctrl_mutex); 2033 - 2021 + ib_unregister_client(&nvme_rdma_ib_client); 2034 2022 destroy_workqueue(nvme_rdma_wq); 2035 2023 } 2036 2024