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, one for NVMe from Keith, and a set for nvme-{rdma,t,f}
from the usual suspects, fixing actual problems that would be a shame
to release 4.9 with"

* 'for-linus' of git://git.kernel.dk/linux-block:
nvme/pci: Don't free queues on error
nvmet-rdma: drain the queue-pair just before freeing it
nvme-rdma: stop and free io queues on connect failure
nvmet-rdma: don't forget to delete a queue from the list of connection failed
nvmet: Don't queue fatal error work if csts.cfs is set
nvme-rdma: reject non-connect commands before the queue is live
nvmet-rdma: Fix possible NULL deref when handling rdma cm events

+65 -23
+4 -14
drivers/nvme/host/pci.c
··· 1242 1242 1243 1243 result = nvme_enable_ctrl(&dev->ctrl, cap); 1244 1244 if (result) 1245 - goto free_nvmeq; 1245 + return result; 1246 1246 1247 1247 nvmeq->cq_vector = 0; 1248 1248 result = queue_request_irq(nvmeq); 1249 1249 if (result) { 1250 1250 nvmeq->cq_vector = -1; 1251 - goto free_nvmeq; 1251 + return result; 1252 1252 } 1253 1253 1254 - return result; 1255 - 1256 - free_nvmeq: 1257 - nvme_free_queues(dev, 0); 1258 1254 return result; 1259 1255 } 1260 1256 ··· 1313 1317 max = min(dev->max_qid, dev->queue_count - 1); 1314 1318 for (i = dev->online_queues; i <= max; i++) { 1315 1319 ret = nvme_create_queue(dev->queues[i], i); 1316 - if (ret) { 1317 - nvme_free_queues(dev, i); 1320 + if (ret) 1318 1321 break; 1319 - } 1320 1322 } 1321 1323 1322 1324 /* ··· 1454 1460 result = queue_request_irq(adminq); 1455 1461 if (result) { 1456 1462 adminq->cq_vector = -1; 1457 - goto free_queues; 1463 + return result; 1458 1464 } 1459 1465 return nvme_create_io_queues(dev); 1460 - 1461 - free_queues: 1462 - nvme_free_queues(dev, 1); 1463 - return result; 1464 1466 } 1465 1467 1466 1468 static void nvme_del_queue_end(struct request *req, int error)
+39 -3
drivers/nvme/host/rdma.c
··· 83 83 NVME_RDMA_Q_CONNECTED = (1 << 0), 84 84 NVME_RDMA_IB_QUEUE_ALLOCATED = (1 << 1), 85 85 NVME_RDMA_Q_DELETING = (1 << 2), 86 + NVME_RDMA_Q_LIVE = (1 << 3), 86 87 }; 87 88 88 89 struct nvme_rdma_queue { ··· 625 624 626 625 for (i = 1; i < ctrl->queue_count; i++) { 627 626 ret = nvmf_connect_io_queue(&ctrl->ctrl, i); 628 - if (ret) 629 - break; 627 + if (ret) { 628 + dev_info(ctrl->ctrl.device, 629 + "failed to connect i/o queue: %d\n", ret); 630 + goto out_free_queues; 631 + } 632 + set_bit(NVME_RDMA_Q_LIVE, &ctrl->queues[i].flags); 630 633 } 631 634 635 + return 0; 636 + 637 + out_free_queues: 638 + nvme_rdma_free_io_queues(ctrl); 632 639 return ret; 633 640 } 634 641 ··· 721 712 if (ret) 722 713 goto stop_admin_q; 723 714 715 + set_bit(NVME_RDMA_Q_LIVE, &ctrl->queues[0].flags); 716 + 724 717 ret = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); 725 718 if (ret) 726 719 goto stop_admin_q; ··· 772 761 773 762 nvme_stop_keep_alive(&ctrl->ctrl); 774 763 775 - for (i = 0; i < ctrl->queue_count; i++) 764 + for (i = 0; i < ctrl->queue_count; i++) { 776 765 clear_bit(NVME_RDMA_Q_CONNECTED, &ctrl->queues[i].flags); 766 + clear_bit(NVME_RDMA_Q_LIVE, &ctrl->queues[i].flags); 767 + } 777 768 778 769 if (ctrl->queue_count > 1) 779 770 nvme_stop_queues(&ctrl->ctrl); ··· 1391 1378 return BLK_EH_HANDLED; 1392 1379 } 1393 1380 1381 + /* 1382 + * We cannot accept any other command until the Connect command has completed. 1383 + */ 1384 + static inline bool nvme_rdma_queue_is_ready(struct nvme_rdma_queue *queue, 1385 + struct request *rq) 1386 + { 1387 + if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) { 1388 + struct nvme_command *cmd = (struct nvme_command *)rq->cmd; 1389 + 1390 + if (rq->cmd_type != REQ_TYPE_DRV_PRIV || 1391 + cmd->common.opcode != nvme_fabrics_command || 1392 + cmd->fabrics.fctype != nvme_fabrics_type_connect) 1393 + return false; 1394 + } 1395 + 1396 + return true; 1397 + } 1398 + 1394 1399 static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx, 1395 1400 const struct blk_mq_queue_data *bd) 1396 1401 { ··· 1424 1393 int ret; 1425 1394 1426 1395 WARN_ON_ONCE(rq->tag < 0); 1396 + 1397 + if (!nvme_rdma_queue_is_ready(queue, rq)) 1398 + return BLK_MQ_RQ_QUEUE_BUSY; 1427 1399 1428 1400 dev = queue->device->dev; 1429 1401 ib_dma_sync_single_for_cpu(dev, sqe->dma, ··· 1577 1543 error = nvmf_connect_admin_queue(&ctrl->ctrl); 1578 1544 if (error) 1579 1545 goto out_cleanup_queue; 1546 + 1547 + set_bit(NVME_RDMA_Q_LIVE, &ctrl->queues[0].flags); 1580 1548 1581 1549 error = nvmf_reg_read64(&ctrl->ctrl, NVME_REG_CAP, &ctrl->cap); 1582 1550 if (error) {
+7 -3
drivers/nvme/target/core.c
··· 838 838 839 839 void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl) 840 840 { 841 - ctrl->csts |= NVME_CSTS_CFS; 842 - INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler); 843 - schedule_work(&ctrl->fatal_err_work); 841 + mutex_lock(&ctrl->lock); 842 + if (!(ctrl->csts & NVME_CSTS_CFS)) { 843 + ctrl->csts |= NVME_CSTS_CFS; 844 + INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler); 845 + schedule_work(&ctrl->fatal_err_work); 846 + } 847 + mutex_unlock(&ctrl->lock); 844 848 } 845 849 EXPORT_SYMBOL_GPL(nvmet_ctrl_fatal_error); 846 850
+15 -3
drivers/nvme/target/rdma.c
··· 951 951 952 952 static void nvmet_rdma_destroy_queue_ib(struct nvmet_rdma_queue *queue) 953 953 { 954 + ib_drain_qp(queue->cm_id->qp); 954 955 rdma_destroy_qp(queue->cm_id); 955 956 ib_free_cq(queue->cq); 956 957 } ··· 1067 1066 spin_lock_init(&queue->rsp_wr_wait_lock); 1068 1067 INIT_LIST_HEAD(&queue->free_rsps); 1069 1068 spin_lock_init(&queue->rsps_lock); 1069 + INIT_LIST_HEAD(&queue->queue_list); 1070 1070 1071 1071 queue->idx = ida_simple_get(&nvmet_rdma_queue_ida, 0, 0, GFP_KERNEL); 1072 1072 if (queue->idx < 0) { ··· 1246 1244 1247 1245 if (disconnect) { 1248 1246 rdma_disconnect(queue->cm_id); 1249 - ib_drain_qp(queue->cm_id->qp); 1250 1247 schedule_work(&queue->release_work); 1251 1248 } 1252 1249 } ··· 1270 1269 { 1271 1270 WARN_ON_ONCE(queue->state != NVMET_RDMA_Q_CONNECTING); 1272 1271 1273 - pr_err("failed to connect queue\n"); 1272 + mutex_lock(&nvmet_rdma_queue_mutex); 1273 + if (!list_empty(&queue->queue_list)) 1274 + list_del_init(&queue->queue_list); 1275 + mutex_unlock(&nvmet_rdma_queue_mutex); 1276 + 1277 + pr_err("failed to connect queue %d\n", queue->idx); 1274 1278 schedule_work(&queue->release_work); 1275 1279 } 1276 1280 ··· 1358 1352 case RDMA_CM_EVENT_ADDR_CHANGE: 1359 1353 case RDMA_CM_EVENT_DISCONNECTED: 1360 1354 case RDMA_CM_EVENT_TIMEWAIT_EXIT: 1361 - nvmet_rdma_queue_disconnect(queue); 1355 + /* 1356 + * We might end up here when we already freed the qp 1357 + * which means queue release sequence is in progress, 1358 + * so don't get in the way... 1359 + */ 1360 + if (queue) 1361 + nvmet_rdma_queue_disconnect(queue); 1362 1362 break; 1363 1363 case RDMA_CM_EVENT_DEVICE_REMOVAL: 1364 1364 ret = nvmet_rdma_device_removal(cm_id, queue);