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

Merge tag 'nvme-6.1-2022-09-20' of git://git.infradead.org/nvme into for-6.1/block

Pull NVMe updates from Christoph:

"nvme updates for Linux 6.1

- handle number of queue changes in the TCP and RDMA drivers
(Daniel Wagner)
- allow changing the number of queues in nvmet (Daniel Wagner)
- also consider host_iface when checking ip options (Daniel Wagner)
- don't map pages which can't come from HIGHMEM (Fabio M. De Francesco)
- avoid unnecessary flush bios in nvmet (Guixin Liu)
- shrink and better pack the nvme_iod structure (Keith Busch)
- add comment for unaligned "fake" nqn (Linjun Bao)
- print actual source IP address through sysfs "address" attr
(Martin Belanger)
- various cleanups (Jackie Liu, Wolfram Sang, Genjian Zhang)"

* tag 'nvme-6.1-2022-09-20' of git://git.infradead.org/nvme:
nvme-tcp: print actual source IP address through sysfs "address" attr
nvmet-tcp: don't map pages which can't come from HIGHMEM
nvme-pci: move iod dma_len fill gaps
nvme-pci: iod npages fits in s8
nvme-pci: iod's 'aborted' is a bool
nvme-pci: remove nvme_queue from nvme_iod
nvme: consider also host_iface when checking ip options
nvme-rdma: handle number of queue changes
nvme-tcp: handle number of queue changes
nvmet: expose max queues to configfs
nvmet: avoid unnecessary flush bio
nvmet-auth: remove redundant parameters req
nvmet-auth: clean up with done_kfree
nvme-auth: remove the redundant req->cqe->result.u16 assignment operation
nvme: move from strlcpy with unused retval to strscpy
nvme: add comment for unaligned "fake" nqn

+176 -91
+6 -2
drivers/nvme/host/core.c
··· 2696 2696 if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) { 2697 2697 nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE); 2698 2698 if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) { 2699 - strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); 2699 + strscpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); 2700 2700 return; 2701 2701 } 2702 2702 ··· 2704 2704 dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n"); 2705 2705 } 2706 2706 2707 - /* Generate a "fake" NQN per Figure 254 in NVMe 1.3 + ECN 001 */ 2707 + /* 2708 + * Generate a "fake" NQN similar to the one in Section 4.5 of the NVMe 2709 + * Base Specification 2.0. It is slightly different from the format 2710 + * specified there due to historic reasons, and we can't change it now. 2711 + */ 2708 2712 off = snprintf(subsys->subnqn, NVMF_NQN_SIZE, 2709 2713 "nqn.2014.08.org.nvmexpress:%04x%04x", 2710 2714 le16_to_cpu(id->vid), le16_to_cpu(id->ssvid));
+19 -6
drivers/nvme/host/fabrics.c
··· 49 49 goto out_unlock; 50 50 51 51 kref_init(&host->ref); 52 - strlcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); 52 + strscpy(host->nqn, hostnqn, NVMF_NQN_SIZE); 53 53 54 54 list_add_tail(&host->list, &nvmf_hosts); 55 55 out_unlock: ··· 971 971 return false; 972 972 973 973 /* 974 - * Checking the local address is rough. In most cases, none is specified 975 - * and the host port is selected by the stack. 974 + * Checking the local address or host interfaces is rough. 975 + * 976 + * In most cases, none is specified and the host port or 977 + * host interface is selected by the stack. 976 978 * 977 979 * Assume no match if: 978 - * - local address is specified and address is not the same 979 - * - local address is not specified but remote is, or vice versa 980 - * (admin using specific host_traddr when it matters). 980 + * - local address or host interface is specified and address 981 + * or host interface is not the same 982 + * - local address or host interface is not specified but 983 + * remote is, or vice versa (admin using specific 984 + * host_traddr/host_iface when it matters). 981 985 */ 982 986 if ((opts->mask & NVMF_OPT_HOST_TRADDR) && 983 987 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { ··· 989 985 return false; 990 986 } else if ((opts->mask & NVMF_OPT_HOST_TRADDR) || 991 987 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { 988 + return false; 989 + } 990 + 991 + if ((opts->mask & NVMF_OPT_HOST_IFACE) && 992 + (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { 993 + if (strcmp(opts->host_iface, ctrl->opts->host_iface)) 994 + return false; 995 + } else if ((opts->mask & NVMF_OPT_HOST_IFACE) || 996 + (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { 992 997 return false; 993 998 } 994 999
+33 -32
drivers/nvme/host/pci.c
··· 226 226 struct nvme_iod { 227 227 struct nvme_request req; 228 228 struct nvme_command cmd; 229 - struct nvme_queue *nvmeq; 230 229 bool use_sgl; 231 - int aborted; 232 - int npages; /* In the PRP list. 0 means small pool in use */ 233 - dma_addr_t first_dma; 230 + bool aborted; 231 + s8 nr_allocations; /* PRP list pool allocations. 0 means small 232 + pool in use */ 234 233 unsigned int dma_len; /* length of single DMA segment mapping */ 234 + dma_addr_t first_dma; 235 235 dma_addr_t meta_dma; 236 236 struct sg_table sgt; 237 237 }; ··· 430 430 { 431 431 struct nvme_dev *dev = set->driver_data; 432 432 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 433 - int queue_idx = (set == &dev->tagset) ? hctx_idx + 1 : 0; 434 - struct nvme_queue *nvmeq = &dev->queues[queue_idx]; 435 - 436 - BUG_ON(!nvmeq); 437 - iod->nvmeq = nvmeq; 438 433 439 434 nvme_req(req)->ctrl = &dev->ctrl; 440 435 nvme_req(req)->cmd = &iod->cmd; ··· 521 526 522 527 static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req) 523 528 { 524 - struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 529 + struct nvme_queue *nvmeq = req->mq_hctx->driver_data; 525 530 int nseg = blk_rq_nr_phys_segments(req); 526 531 unsigned int avg_seg_size; 527 532 ··· 529 534 530 535 if (!nvme_ctrl_sgl_supported(&dev->ctrl)) 531 536 return false; 532 - if (!iod->nvmeq->qid) 537 + if (!nvmeq->qid) 533 538 return false; 534 539 if (!sgl_threshold || avg_seg_size < sgl_threshold) 535 540 return false; ··· 543 548 dma_addr_t dma_addr = iod->first_dma; 544 549 int i; 545 550 546 - for (i = 0; i < iod->npages; i++) { 551 + for (i = 0; i < iod->nr_allocations; i++) { 547 552 __le64 *prp_list = nvme_pci_iod_list(req)[i]; 548 553 dma_addr_t next_dma_addr = le64_to_cpu(prp_list[last_prp]); 549 554 ··· 559 564 dma_addr_t dma_addr = iod->first_dma; 560 565 int i; 561 566 562 - for (i = 0; i < iod->npages; i++) { 567 + for (i = 0; i < iod->nr_allocations; i++) { 563 568 struct nvme_sgl_desc *sg_list = nvme_pci_iod_list(req)[i]; 564 569 dma_addr_t next_dma_addr = le64_to_cpu((sg_list[last_sg]).addr); 565 570 ··· 582 587 583 588 dma_unmap_sgtable(dev->dev, &iod->sgt, rq_dma_dir(req), 0); 584 589 585 - if (iod->npages == 0) 590 + if (iod->nr_allocations == 0) 586 591 dma_pool_free(dev->prp_small_pool, nvme_pci_iod_list(req)[0], 587 592 iod->first_dma); 588 593 else if (iod->use_sgl) ··· 644 649 nprps = DIV_ROUND_UP(length, NVME_CTRL_PAGE_SIZE); 645 650 if (nprps <= (256 / 8)) { 646 651 pool = dev->prp_small_pool; 647 - iod->npages = 0; 652 + iod->nr_allocations = 0; 648 653 } else { 649 654 pool = dev->prp_page_pool; 650 - iod->npages = 1; 655 + iod->nr_allocations = 1; 651 656 } 652 657 653 658 prp_list = dma_pool_alloc(pool, GFP_ATOMIC, &prp_dma); 654 659 if (!prp_list) { 655 - iod->npages = -1; 660 + iod->nr_allocations = -1; 656 661 return BLK_STS_RESOURCE; 657 662 } 658 663 list[0] = prp_list; ··· 664 669 prp_list = dma_pool_alloc(pool, GFP_ATOMIC, &prp_dma); 665 670 if (!prp_list) 666 671 goto free_prps; 667 - list[iod->npages++] = prp_list; 672 + list[iod->nr_allocations++] = prp_list; 668 673 prp_list[0] = old_prp_list[i - 1]; 669 674 old_prp_list[i - 1] = cpu_to_le64(prp_dma); 670 675 i = 1; ··· 739 744 740 745 if (entries <= (256 / sizeof(struct nvme_sgl_desc))) { 741 746 pool = dev->prp_small_pool; 742 - iod->npages = 0; 747 + iod->nr_allocations = 0; 743 748 } else { 744 749 pool = dev->prp_page_pool; 745 - iod->npages = 1; 750 + iod->nr_allocations = 1; 746 751 } 747 752 748 753 sg_list = dma_pool_alloc(pool, GFP_ATOMIC, &sgl_dma); 749 754 if (!sg_list) { 750 - iod->npages = -1; 755 + iod->nr_allocations = -1; 751 756 return BLK_STS_RESOURCE; 752 757 } 753 758 ··· 766 771 goto free_sgls; 767 772 768 773 i = 0; 769 - nvme_pci_iod_list(req)[iod->npages++] = sg_list; 774 + nvme_pci_iod_list(req)[iod->nr_allocations++] = sg_list; 770 775 sg_list[i++] = *link; 771 776 nvme_pci_sgl_set_seg(link, sgl_dma, entries); 772 777 } ··· 826 831 int rc; 827 832 828 833 if (blk_rq_nr_phys_segments(req) == 1) { 834 + struct nvme_queue *nvmeq = req->mq_hctx->driver_data; 829 835 struct bio_vec bv = req_bvec(req); 830 836 831 837 if (!is_pci_p2pdma_page(bv.bv_page)) { ··· 834 838 return nvme_setup_prp_simple(dev, req, 835 839 &cmnd->rw, &bv); 836 840 837 - if (iod->nvmeq->qid && sgl_threshold && 841 + if (nvmeq->qid && sgl_threshold && 838 842 nvme_ctrl_sgl_supported(&dev->ctrl)) 839 843 return nvme_setup_sgl_simple(dev, req, 840 844 &cmnd->rw, &bv); ··· 892 896 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 893 897 blk_status_t ret; 894 898 895 - iod->aborted = 0; 896 - iod->npages = -1; 899 + iod->aborted = false; 900 + iod->nr_allocations = -1; 897 901 iod->sgt.nents = 0; 898 902 899 903 ret = nvme_setup_cmd(req->q->queuedata, req); ··· 1013 1017 1014 1018 static __always_inline void nvme_pci_unmap_rq(struct request *req) 1015 1019 { 1016 - struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 1017 - struct nvme_dev *dev = iod->nvmeq->dev; 1020 + struct nvme_queue *nvmeq = req->mq_hctx->driver_data; 1021 + struct nvme_dev *dev = nvmeq->dev; 1018 1022 1019 - if (blk_integrity_rq(req)) 1023 + if (blk_integrity_rq(req)) { 1024 + struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 1025 + 1020 1026 dma_unmap_page(dev->dev, iod->meta_dma, 1021 1027 rq_integrity_vec(req)->bv_len, rq_data_dir(req)); 1028 + } 1029 + 1022 1030 if (blk_rq_nr_phys_segments(req)) 1023 1031 nvme_unmap_data(dev, req); 1024 1032 } ··· 1270 1270 1271 1271 static void abort_endio(struct request *req, blk_status_t error) 1272 1272 { 1273 - struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 1274 - struct nvme_queue *nvmeq = iod->nvmeq; 1273 + struct nvme_queue *nvmeq = req->mq_hctx->driver_data; 1275 1274 1276 1275 dev_warn(nvmeq->dev->ctrl.device, 1277 1276 "Abort status: 0x%x", nvme_req(req)->status); ··· 1332 1333 static enum blk_eh_timer_return nvme_timeout(struct request *req) 1333 1334 { 1334 1335 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 1335 - struct nvme_queue *nvmeq = iod->nvmeq; 1336 + struct nvme_queue *nvmeq = req->mq_hctx->driver_data; 1336 1337 struct nvme_dev *dev = nvmeq->dev; 1337 1338 struct request *abort_req; 1338 1339 struct nvme_command cmd = { }; ··· 1413 1414 atomic_inc(&dev->ctrl.abort_limit); 1414 1415 return BLK_EH_RESET_TIMER; 1415 1416 } 1416 - iod->aborted = 1; 1417 + iod->aborted = true; 1417 1418 1418 1419 cmd.abort.opcode = nvme_admin_abort_cmd; 1419 1420 cmd.abort.cid = nvme_cid(req); ··· 3560 3561 BUILD_BUG_ON(sizeof(struct nvme_create_sq) != 64); 3561 3562 BUILD_BUG_ON(sizeof(struct nvme_delete_queue) != 64); 3562 3563 BUILD_BUG_ON(IRQ_AFFINITY_MAX_SETS < 2); 3564 + BUILD_BUG_ON(DIV_ROUND_UP(nvme_pci_npages_prp(), NVME_CTRL_PAGE_SIZE) > 3565 + S8_MAX); 3563 3566 3564 3567 return pci_register_driver(&nvme_driver); 3565 3568 }
+21 -5
drivers/nvme/host/rdma.c
··· 696 696 return ret; 697 697 } 698 698 699 - static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl) 699 + static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl, 700 + int first, int last) 700 701 { 701 702 int i, ret = 0; 702 703 703 - for (i = 1; i < ctrl->ctrl.queue_count; i++) { 704 + for (i = first; i < last; i++) { 704 705 ret = nvme_rdma_start_queue(ctrl, i); 705 706 if (ret) 706 707 goto out_stop_queues; ··· 710 709 return 0; 711 710 712 711 out_stop_queues: 713 - for (i--; i >= 1; i--) 712 + for (i--; i >= first; i--) 714 713 nvme_rdma_stop_queue(&ctrl->queues[i]); 715 714 return ret; 716 715 } ··· 965 964 966 965 static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) 967 966 { 968 - int ret; 967 + int ret, nr_queues; 969 968 970 969 ret = nvme_rdma_alloc_io_queues(ctrl); 971 970 if (ret) ··· 981 980 goto out_free_tag_set; 982 981 } 983 982 984 - ret = nvme_rdma_start_io_queues(ctrl); 983 + /* 984 + * Only start IO queues for which we have allocated the tagset 985 + * and limitted it to the available queues. On reconnects, the 986 + * queue number might have changed. 987 + */ 988 + nr_queues = min(ctrl->tag_set.nr_hw_queues + 1, ctrl->ctrl.queue_count); 989 + ret = nvme_rdma_start_io_queues(ctrl, 1, nr_queues); 985 990 if (ret) 986 991 goto out_cleanup_connect_q; 987 992 ··· 1006 999 ctrl->ctrl.queue_count - 1); 1007 1000 nvme_unfreeze(&ctrl->ctrl); 1008 1001 } 1002 + 1003 + /* 1004 + * If the number of queues has increased (reconnect case) 1005 + * start all new queues now. 1006 + */ 1007 + ret = nvme_rdma_start_io_queues(ctrl, nr_queues, 1008 + ctrl->tag_set.nr_hw_queues + 1); 1009 + if (ret) 1010 + goto out_wait_freeze_timed_out; 1009 1011 1010 1012 return 0; 1011 1013
+41 -6
drivers/nvme/host/tcp.c
··· 1762 1762 nvme_tcp_stop_queue(ctrl, i); 1763 1763 } 1764 1764 1765 - static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl) 1765 + static int nvme_tcp_start_io_queues(struct nvme_ctrl *ctrl, 1766 + int first, int last) 1766 1767 { 1767 1768 int i, ret; 1768 1769 1769 - for (i = 1; i < ctrl->queue_count; i++) { 1770 + for (i = first; i < last; i++) { 1770 1771 ret = nvme_tcp_start_queue(ctrl, i); 1771 1772 if (ret) 1772 1773 goto out_stop_queues; ··· 1776 1775 return 0; 1777 1776 1778 1777 out_stop_queues: 1779 - for (i--; i >= 1; i--) 1778 + for (i--; i >= first; i--) 1780 1779 nvme_tcp_stop_queue(ctrl, i); 1781 1780 return ret; 1782 1781 } ··· 1902 1901 1903 1902 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) 1904 1903 { 1905 - int ret; 1904 + int ret, nr_queues; 1906 1905 1907 1906 ret = nvme_tcp_alloc_io_queues(ctrl); 1908 1907 if (ret) ··· 1918 1917 goto out_free_tag_set; 1919 1918 } 1920 1919 1921 - ret = nvme_tcp_start_io_queues(ctrl); 1920 + /* 1921 + * Only start IO queues for which we have allocated the tagset 1922 + * and limitted it to the available queues. On reconnects, the 1923 + * queue number might have changed. 1924 + */ 1925 + nr_queues = min(ctrl->tagset->nr_hw_queues + 1, ctrl->queue_count); 1926 + ret = nvme_tcp_start_io_queues(ctrl, 1, nr_queues); 1922 1927 if (ret) 1923 1928 goto out_cleanup_connect_q; 1924 1929 ··· 1943 1936 ctrl->queue_count - 1); 1944 1937 nvme_unfreeze(ctrl); 1945 1938 } 1939 + 1940 + /* 1941 + * If the number of queues has increased (reconnect case) 1942 + * start all new queues now. 1943 + */ 1944 + ret = nvme_tcp_start_io_queues(ctrl, nr_queues, 1945 + ctrl->tagset->nr_hw_queues + 1); 1946 + if (ret) 1947 + goto out_wait_freeze_timed_out; 1946 1948 1947 1949 return 0; 1948 1950 ··· 2546 2530 return queue->nr_cqe; 2547 2531 } 2548 2532 2533 + static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size) 2534 + { 2535 + struct nvme_tcp_queue *queue = &to_tcp_ctrl(ctrl)->queues[0]; 2536 + struct sockaddr_storage src_addr; 2537 + int ret, len; 2538 + 2539 + len = nvmf_get_address(ctrl, buf, size); 2540 + 2541 + ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src_addr); 2542 + if (ret > 0) { 2543 + if (len > 0) 2544 + len--; /* strip trailing newline */ 2545 + len += scnprintf(buf + len, size - len, "%ssrc_addr=%pISc\n", 2546 + (len) ? "," : "", &src_addr); 2547 + } 2548 + 2549 + return len; 2550 + } 2551 + 2549 2552 static const struct blk_mq_ops nvme_tcp_mq_ops = { 2550 2553 .queue_rq = nvme_tcp_queue_rq, 2551 2554 .commit_rqs = nvme_tcp_commit_rqs, ··· 2596 2561 .free_ctrl = nvme_tcp_free_ctrl, 2597 2562 .submit_async_event = nvme_tcp_submit_async_event, 2598 2563 .delete_ctrl = nvme_tcp_delete_ctrl, 2599 - .get_address = nvmf_get_address, 2564 + .get_address = nvme_tcp_get_address, 2600 2565 .stop_ctrl = nvme_tcp_stop_ctrl, 2601 2566 }; 2602 2567
+1 -1
drivers/nvme/target/admin-cmd.c
··· 449 449 if (req->port->inline_data_size) 450 450 id->sgls |= cpu_to_le32(1 << 20); 451 451 452 - strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); 452 + strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); 453 453 454 454 /* 455 455 * Max command capsule size is sqe + in-capsule data size.
+29
drivers/nvme/target/configfs.c
··· 1281 1281 CONFIGFS_ATTR(nvmet_subsys_, attr_pi_enable); 1282 1282 #endif 1283 1283 1284 + static ssize_t nvmet_subsys_attr_qid_max_show(struct config_item *item, 1285 + char *page) 1286 + { 1287 + return snprintf(page, PAGE_SIZE, "%u\n", to_subsys(item)->max_qid); 1288 + } 1289 + 1290 + static ssize_t nvmet_subsys_attr_qid_max_store(struct config_item *item, 1291 + const char *page, size_t cnt) 1292 + { 1293 + struct nvmet_port *port = to_nvmet_port(item); 1294 + u16 qid_max; 1295 + 1296 + if (nvmet_is_port_enabled(port, __func__)) 1297 + return -EACCES; 1298 + 1299 + if (sscanf(page, "%hu\n", &qid_max) != 1) 1300 + return -EINVAL; 1301 + 1302 + if (qid_max < 1 || qid_max > NVMET_NR_QUEUES) 1303 + return -EINVAL; 1304 + 1305 + down_write(&nvmet_config_sem); 1306 + to_subsys(item)->max_qid = qid_max; 1307 + up_write(&nvmet_config_sem); 1308 + return cnt; 1309 + } 1310 + CONFIGFS_ATTR(nvmet_subsys_, attr_qid_max); 1311 + 1284 1312 static struct configfs_attribute *nvmet_subsys_attrs[] = { 1285 1313 &nvmet_subsys_attr_attr_allow_any_host, 1286 1314 &nvmet_subsys_attr_attr_version, ··· 1316 1288 &nvmet_subsys_attr_attr_cntlid_min, 1317 1289 &nvmet_subsys_attr_attr_cntlid_max, 1318 1290 &nvmet_subsys_attr_attr_model, 1291 + &nvmet_subsys_attr_attr_qid_max, 1319 1292 #ifdef CONFIG_BLK_DEV_INTEGRITY 1320 1293 &nvmet_subsys_attr_attr_pi_enable, 1321 1294 #endif
+1 -1
drivers/nvme/target/discovery.c
··· 292 292 293 293 id->oaes = cpu_to_le32(NVMET_DISC_AEN_CFG_OPTIONAL); 294 294 295 - strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); 295 + strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); 296 296 297 297 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); 298 298
+4 -6
drivers/nvme/target/fabrics-cmd-auth.c
··· 177 177 return 0; 178 178 } 179 179 180 - static u16 nvmet_auth_failure2(struct nvmet_req *req, void *d) 180 + static u16 nvmet_auth_failure2(void *d) 181 181 { 182 182 struct nvmf_auth_dhchap_failure_data *data = d; 183 183 ··· 229 229 } 230 230 231 231 status = nvmet_copy_from_sgl(req, 0, d, tl); 232 - if (status) { 233 - kfree(d); 234 - goto done; 235 - } 232 + if (status) 233 + goto done_kfree; 236 234 237 235 data = d; 238 236 pr_debug("%s: ctrl %d qid %d type %d id %d step %x\n", __func__, ··· 308 310 goto done_kfree; 309 311 break; 310 312 case NVME_AUTH_DHCHAP_MESSAGE_FAILURE2: 311 - status = nvmet_auth_failure2(req, d); 313 + status = nvmet_auth_failure2(d); 312 314 if (status) { 313 315 pr_warn("ctrl %d qid %d: authentication failed (%d)\n", 314 316 ctrl->cntlid, req->sq->qid, status);
-1
drivers/nvme/target/fabrics-cmd.c
··· 332 332 req->cqe->result.u16 = cpu_to_le16(ctrl->cntlid); 333 333 334 334 pr_debug("adding queue %d to ctrl %d.\n", qid, ctrl->cntlid); 335 - req->cqe->result.u16 = cpu_to_le16(ctrl->cntlid); 336 335 if (nvmet_has_auth(ctrl)) 337 336 nvmet_init_auth(ctrl, req); 338 337
+8
drivers/nvme/target/io-cmd-bdev.c
··· 334 334 { 335 335 struct bio *bio = &req->b.inline_bio; 336 336 337 + if (!bdev_write_cache(req->ns->bdev)) { 338 + nvmet_req_complete(req, NVME_SC_SUCCESS); 339 + return; 340 + } 341 + 337 342 if (!nvmet_check_transfer_len(req, 0)) 338 343 return; 339 344 ··· 352 347 353 348 u16 nvmet_bdev_flush(struct nvmet_req *req) 354 349 { 350 + if (!bdev_write_cache(req->ns->bdev)) 351 + return 0; 352 + 355 353 if (blkdev_issue_flush(req->ns->bdev)) 356 354 return NVME_SC_INTERNAL | NVME_SC_DNR; 357 355 return 0;
+13 -31
drivers/nvme/target/tcp.c
··· 77 77 u32 pdu_len; 78 78 u32 pdu_recv; 79 79 int sg_idx; 80 - int nr_mapped; 81 80 struct msghdr recv_msg; 82 - struct kvec *iov; 81 + struct bio_vec *iov; 83 82 u32 flags; 84 83 85 84 struct list_head entry; ··· 166 167 static void nvmet_tcp_free_cmd(struct nvmet_tcp_cmd *c); 167 168 static void nvmet_tcp_finish_cmd(struct nvmet_tcp_cmd *cmd); 168 169 static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd); 169 - static void nvmet_tcp_unmap_pdu_iovec(struct nvmet_tcp_cmd *cmd); 170 170 171 171 static inline u16 nvmet_tcp_cmd_tag(struct nvmet_tcp_queue *queue, 172 172 struct nvmet_tcp_cmd *cmd) ··· 299 301 300 302 static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd) 301 303 { 302 - WARN_ON(unlikely(cmd->nr_mapped > 0)); 303 - 304 304 kfree(cmd->iov); 305 305 sgl_free(cmd->req.sg); 306 306 cmd->iov = NULL; 307 307 cmd->req.sg = NULL; 308 308 } 309 309 310 - static void nvmet_tcp_unmap_pdu_iovec(struct nvmet_tcp_cmd *cmd) 310 + static void nvmet_tcp_build_pdu_iovec(struct nvmet_tcp_cmd *cmd) 311 311 { 312 - struct scatterlist *sg; 313 - int i; 314 - 315 - sg = &cmd->req.sg[cmd->sg_idx]; 316 - 317 - for (i = 0; i < cmd->nr_mapped; i++) 318 - kunmap(sg_page(&sg[i])); 319 - 320 - cmd->nr_mapped = 0; 321 - } 322 - 323 - static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd) 324 - { 325 - struct kvec *iov = cmd->iov; 312 + struct bio_vec *iov = cmd->iov; 326 313 struct scatterlist *sg; 327 314 u32 length, offset, sg_offset; 315 + int nr_pages; 328 316 329 317 length = cmd->pdu_len; 330 - cmd->nr_mapped = DIV_ROUND_UP(length, PAGE_SIZE); 318 + nr_pages = DIV_ROUND_UP(length, PAGE_SIZE); 331 319 offset = cmd->rbytes_done; 332 320 cmd->sg_idx = offset / PAGE_SIZE; 333 321 sg_offset = offset % PAGE_SIZE; ··· 322 338 while (length) { 323 339 u32 iov_len = min_t(u32, length, sg->length - sg_offset); 324 340 325 - iov->iov_base = kmap(sg_page(sg)) + sg->offset + sg_offset; 326 - iov->iov_len = iov_len; 341 + iov->bv_page = sg_page(sg); 342 + iov->bv_len = sg->length; 343 + iov->bv_offset = sg->offset + sg_offset; 327 344 328 345 length -= iov_len; 329 346 sg = sg_next(sg); ··· 332 347 sg_offset = 0; 333 348 } 334 349 335 - iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov, 336 - cmd->nr_mapped, cmd->pdu_len); 350 + iov_iter_bvec(&cmd->recv_msg.msg_iter, READ, cmd->iov, 351 + nr_pages, cmd->pdu_len); 337 352 } 338 353 339 354 static void nvmet_tcp_fatal_error(struct nvmet_tcp_queue *queue) ··· 911 926 } 912 927 913 928 queue->rcv_state = NVMET_TCP_RECV_DATA; 914 - nvmet_tcp_map_pdu_iovec(cmd); 929 + nvmet_tcp_build_pdu_iovec(cmd); 915 930 cmd->flags |= NVMET_TCP_F_INIT_FAILED; 916 931 } 917 932 ··· 937 952 938 953 cmd->pdu_len = le32_to_cpu(data->data_length); 939 954 cmd->pdu_recv = 0; 940 - nvmet_tcp_map_pdu_iovec(cmd); 955 + nvmet_tcp_build_pdu_iovec(cmd); 941 956 queue->cmd = cmd; 942 957 queue->rcv_state = NVMET_TCP_RECV_DATA; 943 958 ··· 1006 1021 if (nvmet_tcp_need_data_in(queue->cmd)) { 1007 1022 if (nvmet_tcp_has_inline_data(queue->cmd)) { 1008 1023 queue->rcv_state = NVMET_TCP_RECV_DATA; 1009 - nvmet_tcp_map_pdu_iovec(queue->cmd); 1024 + nvmet_tcp_build_pdu_iovec(queue->cmd); 1010 1025 return 0; 1011 1026 } 1012 1027 /* send back R2T */ ··· 1126 1141 cmd->rbytes_done += ret; 1127 1142 } 1128 1143 1129 - nvmet_tcp_unmap_pdu_iovec(cmd); 1130 1144 if (queue->data_digest) { 1131 1145 nvmet_tcp_prep_recv_ddgst(cmd); 1132 1146 return 0; ··· 1395 1411 static void nvmet_tcp_finish_cmd(struct nvmet_tcp_cmd *cmd) 1396 1412 { 1397 1413 nvmet_req_uninit(&cmd->req); 1398 - nvmet_tcp_unmap_pdu_iovec(cmd); 1399 1414 nvmet_tcp_free_cmd_buffers(cmd); 1400 1415 } 1401 1416 ··· 1407 1424 if (nvmet_tcp_need_data_in(cmd)) 1408 1425 nvmet_req_uninit(&cmd->req); 1409 1426 1410 - nvmet_tcp_unmap_pdu_iovec(cmd); 1411 1427 nvmet_tcp_free_cmd_buffers(cmd); 1412 1428 } 1413 1429