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 tag 'block-6.13-20250103' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:
"Collection of fixes for block. Particularly the target name overflow
has been a bit annoying, as it results in overwriting random memory
and hence shows up as triggering various other bugs.

- NVMe pull request via Keith:
- Fix device specific quirk for PRP list alignment (Robert)
- Fix target name overflow (Leo)
- Fix target write granularity (Luis)
- Fix target sleeping in atomic context (Nilay)
- Remove unnecessary tcp queue teardown (Chunguang)

- Simple cdrom typo fix"

* tag 'block-6.13-20250103' of git://git.kernel.dk/linux:
cdrom: Fix typo, 'devicen' to 'device'
nvme-tcp: remove nvme_tcp_destroy_io_queues()
nvmet-loop: avoid using mutex in IO hotpath
nvmet: propagate npwg topology
nvmet: Don't overflow subsysnqn
nvme-pci: 512 byte aligned dma pool segment quirk

+109 -82
+1 -1
drivers/cdrom/cdrom.c
··· 1106 1106 } 1107 1107 } 1108 1108 1109 - cd_dbg(CD_OPEN, "all seems well, opening the devicen"); 1109 + cd_dbg(CD_OPEN, "all seems well, opening the device\n"); 1110 1110 1111 1111 /* all seems well, we can open the device */ 1112 1112 ret = cdo->open(cdi, 0); /* open for data */
+5
drivers/nvme/host/nvme.h
··· 173 173 * MSI (but not MSI-X) interrupts are broken and never fire. 174 174 */ 175 175 NVME_QUIRK_BROKEN_MSI = (1 << 21), 176 + 177 + /* 178 + * Align dma pool segment size to 512 bytes 179 + */ 180 + NVME_QUIRK_DMAPOOL_ALIGN_512 = (1 << 22), 176 181 }; 177 182 178 183 /*
+7 -2
drivers/nvme/host/pci.c
··· 2834 2834 2835 2835 static int nvme_setup_prp_pools(struct nvme_dev *dev) 2836 2836 { 2837 + size_t small_align = 256; 2838 + 2837 2839 dev->prp_page_pool = dma_pool_create("prp list page", dev->dev, 2838 2840 NVME_CTRL_PAGE_SIZE, 2839 2841 NVME_CTRL_PAGE_SIZE, 0); 2840 2842 if (!dev->prp_page_pool) 2841 2843 return -ENOMEM; 2842 2844 2845 + if (dev->ctrl.quirks & NVME_QUIRK_DMAPOOL_ALIGN_512) 2846 + small_align = 512; 2847 + 2843 2848 /* Optimisation for I/Os between 4k and 128k */ 2844 2849 dev->prp_small_pool = dma_pool_create("prp list 256", dev->dev, 2845 - 256, 256, 0); 2850 + 256, small_align, 0); 2846 2851 if (!dev->prp_small_pool) { 2847 2852 dma_pool_destroy(dev->prp_page_pool); 2848 2853 return -ENOMEM; ··· 3612 3607 { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ 3613 3608 .driver_data = NVME_QUIRK_BOGUS_NID, }, 3614 3609 { PCI_DEVICE(0x1217, 0x8760), /* O2 Micro 64GB Steam Deck */ 3615 - .driver_data = NVME_QUIRK_QDEPTH_ONE }, 3610 + .driver_data = NVME_QUIRK_DMAPOOL_ALIGN_512, }, 3616 3611 { PCI_DEVICE(0x126f, 0x2262), /* Silicon Motion generic */ 3617 3612 .driver_data = NVME_QUIRK_NO_DEEPEST_PS | 3618 3613 NVME_QUIRK_BOGUS_NID, },
+7 -11
drivers/nvme/host/tcp.c
··· 2024 2024 return __nvme_tcp_alloc_io_queues(ctrl); 2025 2025 } 2026 2026 2027 - static void nvme_tcp_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove) 2028 - { 2029 - nvme_tcp_stop_io_queues(ctrl); 2030 - if (remove) 2031 - nvme_remove_io_tag_set(ctrl); 2032 - nvme_tcp_free_io_queues(ctrl); 2033 - } 2034 - 2035 2027 static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) 2036 2028 { 2037 2029 int ret, nr_queues; ··· 2168 2176 nvme_sync_io_queues(ctrl); 2169 2177 nvme_tcp_stop_io_queues(ctrl); 2170 2178 nvme_cancel_tagset(ctrl); 2171 - if (remove) 2179 + if (remove) { 2172 2180 nvme_unquiesce_io_queues(ctrl); 2173 - nvme_tcp_destroy_io_queues(ctrl, remove); 2181 + nvme_remove_io_tag_set(ctrl); 2182 + } 2183 + nvme_tcp_free_io_queues(ctrl); 2174 2184 } 2175 2185 2176 2186 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, ··· 2261 2267 nvme_sync_io_queues(ctrl); 2262 2268 nvme_tcp_stop_io_queues(ctrl); 2263 2269 nvme_cancel_tagset(ctrl); 2264 - nvme_tcp_destroy_io_queues(ctrl, new); 2270 + if (new) 2271 + nvme_remove_io_tag_set(ctrl); 2272 + nvme_tcp_free_io_queues(ctrl); 2265 2273 } 2266 2274 destroy_admin: 2267 2275 nvme_stop_keep_alive(ctrl);
+5 -4
drivers/nvme/target/admin-cmd.c
··· 139 139 unsigned long idx; 140 140 141 141 ctrl = req->sq->ctrl; 142 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 142 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 143 143 /* we don't have the right data for file backed ns */ 144 144 if (!ns->bdev) 145 145 continue; ··· 331 331 u32 count = 0; 332 332 333 333 if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) { 334 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) 334 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 335 335 if (ns->anagrpid == grpid) 336 336 desc->nsids[count++] = cpu_to_le32(ns->nsid); 337 + } 337 338 } 338 339 339 340 desc->grpid = cpu_to_le32(grpid); ··· 773 772 goto out; 774 773 } 775 774 776 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 775 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 777 776 if (ns->nsid <= min_endgid) 778 777 continue; 779 778 ··· 816 815 goto out; 817 816 } 818 817 819 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 818 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 820 819 if (ns->nsid <= min_nsid) 821 820 continue; 822 821 if (match_css && req->ns->csi != req->cmd->identify.csi)
+9 -14
drivers/nvme/target/configfs.c
··· 810 810 NULL, 811 811 }; 812 812 813 - bool nvmet_subsys_nsid_exists(struct nvmet_subsys *subsys, u32 nsid) 814 - { 815 - struct config_item *ns_item; 816 - char name[12]; 817 - 818 - snprintf(name, sizeof(name), "%u", nsid); 819 - mutex_lock(&subsys->namespaces_group.cg_subsys->su_mutex); 820 - ns_item = config_group_find_item(&subsys->namespaces_group, name); 821 - mutex_unlock(&subsys->namespaces_group.cg_subsys->su_mutex); 822 - return ns_item != NULL; 823 - } 824 - 825 813 static void nvmet_ns_release(struct config_item *item) 826 814 { 827 815 struct nvmet_ns *ns = to_nvmet_ns(item); ··· 2242 2254 const char *page, size_t count) 2243 2255 { 2244 2256 struct list_head *entry; 2257 + char *old_nqn, *new_nqn; 2245 2258 size_t len; 2246 2259 2247 2260 len = strcspn(page, "\n"); 2248 2261 if (!len || len > NVMF_NQN_FIELD_LEN - 1) 2249 2262 return -EINVAL; 2263 + 2264 + new_nqn = kstrndup(page, len, GFP_KERNEL); 2265 + if (!new_nqn) 2266 + return -ENOMEM; 2250 2267 2251 2268 down_write(&nvmet_config_sem); 2252 2269 list_for_each(entry, &nvmet_subsystems_group.cg_children) { ··· 2261 2268 if (!strncmp(config_item_name(item), page, len)) { 2262 2269 pr_err("duplicate NQN %s\n", config_item_name(item)); 2263 2270 up_write(&nvmet_config_sem); 2271 + kfree(new_nqn); 2264 2272 return -EINVAL; 2265 2273 } 2266 2274 } 2267 - memset(nvmet_disc_subsys->subsysnqn, 0, NVMF_NQN_FIELD_LEN); 2268 - memcpy(nvmet_disc_subsys->subsysnqn, page, len); 2275 + old_nqn = nvmet_disc_subsys->subsysnqn; 2276 + nvmet_disc_subsys->subsysnqn = new_nqn; 2269 2277 up_write(&nvmet_config_sem); 2270 2278 2279 + kfree(old_nqn); 2271 2280 return len; 2272 2281 } 2273 2282
+63 -45
drivers/nvme/target/core.c
··· 127 127 unsigned long idx; 128 128 u32 nsid = 0; 129 129 130 - xa_for_each(&subsys->namespaces, idx, cur) 130 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, cur) 131 131 nsid = cur->nsid; 132 132 133 133 return nsid; ··· 441 441 struct nvmet_subsys *subsys = nvmet_req_subsys(req); 442 442 443 443 req->ns = xa_load(&subsys->namespaces, nsid); 444 - if (unlikely(!req->ns)) { 444 + if (unlikely(!req->ns || !req->ns->enabled)) { 445 445 req->error_loc = offsetof(struct nvme_common_command, nsid); 446 - if (nvmet_subsys_nsid_exists(subsys, nsid)) 447 - return NVME_SC_INTERNAL_PATH_ERROR; 448 - return NVME_SC_INVALID_NS | NVME_STATUS_DNR; 446 + if (!req->ns) /* ns doesn't exist! */ 447 + return NVME_SC_INVALID_NS | NVME_STATUS_DNR; 448 + 449 + /* ns exists but it's disabled */ 450 + req->ns = NULL; 451 + return NVME_SC_INTERNAL_PATH_ERROR; 449 452 } 450 453 451 454 percpu_ref_get(&req->ns->ref); ··· 586 583 goto out_unlock; 587 584 588 585 ret = -EMFILE; 589 - if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES) 590 - goto out_unlock; 591 586 592 587 ret = nvmet_bdev_ns_enable(ns); 593 588 if (ret == -ENOTBLK) ··· 600 599 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 601 600 nvmet_p2pmem_ns_add_p2p(ctrl, ns); 602 601 603 - ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 604 - 0, GFP_KERNEL); 605 - if (ret) 606 - goto out_dev_put; 607 - 608 - if (ns->nsid > subsys->max_nsid) 609 - subsys->max_nsid = ns->nsid; 610 - 611 - ret = xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL); 612 - if (ret) 613 - goto out_restore_subsys_maxnsid; 614 - 615 602 if (ns->pr.enable) { 616 603 ret = nvmet_pr_init_ns(ns); 617 604 if (ret) 618 - goto out_remove_from_subsys; 605 + goto out_dev_put; 619 606 } 620 - 621 - subsys->nr_namespaces++; 622 607 623 608 nvmet_ns_changed(subsys, ns->nsid); 624 609 ns->enabled = true; 610 + xa_set_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); 625 611 ret = 0; 626 612 out_unlock: 627 613 mutex_unlock(&subsys->lock); 628 614 return ret; 629 - 630 - out_remove_from_subsys: 631 - xa_erase(&subsys->namespaces, ns->nsid); 632 - out_restore_subsys_maxnsid: 633 - subsys->max_nsid = nvmet_max_nsid(subsys); 634 - percpu_ref_exit(&ns->ref); 635 615 out_dev_put: 636 616 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 637 617 pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); ··· 631 649 goto out_unlock; 632 650 633 651 ns->enabled = false; 634 - xa_erase(&ns->subsys->namespaces, ns->nsid); 635 - if (ns->nsid == subsys->max_nsid) 636 - subsys->max_nsid = nvmet_max_nsid(subsys); 652 + xa_clear_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED); 637 653 638 654 list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) 639 655 pci_dev_put(radix_tree_delete(&ctrl->p2p_ns_map, ns->nsid)); 656 + 657 + mutex_unlock(&subsys->lock); 658 + 659 + if (ns->pr.enable) 660 + nvmet_pr_exit_ns(ns); 661 + 662 + mutex_lock(&subsys->lock); 663 + nvmet_ns_changed(subsys, ns->nsid); 664 + nvmet_ns_dev_disable(ns); 665 + out_unlock: 666 + mutex_unlock(&subsys->lock); 667 + } 668 + 669 + void nvmet_ns_free(struct nvmet_ns *ns) 670 + { 671 + struct nvmet_subsys *subsys = ns->subsys; 672 + 673 + nvmet_ns_disable(ns); 674 + 675 + mutex_lock(&subsys->lock); 676 + 677 + xa_erase(&subsys->namespaces, ns->nsid); 678 + if (ns->nsid == subsys->max_nsid) 679 + subsys->max_nsid = nvmet_max_nsid(subsys); 640 680 641 681 mutex_unlock(&subsys->lock); 642 682 ··· 675 671 wait_for_completion(&ns->disable_done); 676 672 percpu_ref_exit(&ns->ref); 677 673 678 - if (ns->pr.enable) 679 - nvmet_pr_exit_ns(ns); 680 - 681 674 mutex_lock(&subsys->lock); 682 - 683 675 subsys->nr_namespaces--; 684 - nvmet_ns_changed(subsys, ns->nsid); 685 - nvmet_ns_dev_disable(ns); 686 - out_unlock: 687 676 mutex_unlock(&subsys->lock); 688 - } 689 - 690 - void nvmet_ns_free(struct nvmet_ns *ns) 691 - { 692 - nvmet_ns_disable(ns); 693 677 694 678 down_write(&nvmet_ana_sem); 695 679 nvmet_ana_group_enabled[ns->anagrpid]--; ··· 691 699 { 692 700 struct nvmet_ns *ns; 693 701 702 + mutex_lock(&subsys->lock); 703 + 704 + if (subsys->nr_namespaces == NVMET_MAX_NAMESPACES) 705 + goto out_unlock; 706 + 694 707 ns = kzalloc(sizeof(*ns), GFP_KERNEL); 695 708 if (!ns) 696 - return NULL; 709 + goto out_unlock; 697 710 698 711 init_completion(&ns->disable_done); 699 712 700 713 ns->nsid = nsid; 701 714 ns->subsys = subsys; 715 + 716 + if (percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL)) 717 + goto out_free; 718 + 719 + if (ns->nsid > subsys->max_nsid) 720 + subsys->max_nsid = nsid; 721 + 722 + if (xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL)) 723 + goto out_exit; 724 + 725 + subsys->nr_namespaces++; 726 + 727 + mutex_unlock(&subsys->lock); 702 728 703 729 down_write(&nvmet_ana_sem); 704 730 ns->anagrpid = NVMET_DEFAULT_ANA_GRPID; ··· 728 718 ns->csi = NVME_CSI_NVM; 729 719 730 720 return ns; 721 + out_exit: 722 + subsys->max_nsid = nvmet_max_nsid(subsys); 723 + percpu_ref_exit(&ns->ref); 724 + out_free: 725 + kfree(ns); 726 + out_unlock: 727 + mutex_unlock(&subsys->lock); 728 + return NULL; 731 729 } 732 730 733 731 static void nvmet_update_sq_head(struct nvmet_req *req) ··· 1412 1394 1413 1395 ctrl->p2p_client = get_device(req->p2p_client); 1414 1396 1415 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) 1397 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) 1416 1398 nvmet_p2pmem_ns_add_p2p(ctrl, ns); 1417 1399 } 1418 1400
+1 -1
drivers/nvme/target/io-cmd-bdev.c
··· 36 36 */ 37 37 id->nsfeat |= 1 << 4; 38 38 /* NPWG = Namespace Preferred Write Granularity. 0's based */ 39 - id->npwg = lpp0b; 39 + id->npwg = to0based(bdev_io_min(bdev) / bdev_logical_block_size(bdev)); 40 40 /* NPWA = Namespace Preferred Write Alignment. 0's based */ 41 41 id->npwa = id->npwg; 42 42 /* NPDG = Namespace Preferred Deallocate Granularity. 0's based */
+7
drivers/nvme/target/nvmet.h
··· 24 24 25 25 #define NVMET_DEFAULT_VS NVME_VS(2, 1, 0) 26 26 27 + #define NVMET_NS_ENABLED XA_MARK_1 27 28 #define NVMET_ASYNC_EVENTS 4 28 29 #define NVMET_ERROR_LOG_SLOTS 128 29 30 #define NVMET_NO_ERROR_LOC ((u16)-1) ··· 33 32 #define NVMET_SN_MAX_SIZE 20 34 33 #define NVMET_FR_MAX_SIZE 8 35 34 #define NVMET_PR_LOG_QUEUE_SIZE 64 35 + 36 + #define nvmet_for_each_ns(xa, index, entry) \ 37 + xa_for_each(xa, index, entry) 38 + 39 + #define nvmet_for_each_enabled_ns(xa, index, entry) \ 40 + xa_for_each_marked(xa, index, entry, NVMET_NS_ENABLED) 36 41 37 42 /* 38 43 * Supported optional AENs:
+4 -4
drivers/nvme/target/pr.c
··· 60 60 goto success; 61 61 } 62 62 63 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 63 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 64 64 if (ns->pr.enable) 65 65 WRITE_ONCE(ns->pr.notify_mask, mask); 66 66 } ··· 1056 1056 * nvmet_pr_init_ns(), see more details in nvmet_ns_enable(). 1057 1057 * So just check ns->pr.enable. 1058 1058 */ 1059 - xa_for_each(&subsys->namespaces, idx, ns) { 1059 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, ns) { 1060 1060 if (ns->pr.enable) { 1061 1061 ret = nvmet_pr_alloc_and_insert_pc_ref(ns, ctrl->cntlid, 1062 1062 &ctrl->hostid); ··· 1067 1067 return 0; 1068 1068 1069 1069 free_per_ctrl_refs: 1070 - xa_for_each(&subsys->namespaces, idx, ns) { 1070 + nvmet_for_each_enabled_ns(&subsys->namespaces, idx, ns) { 1071 1071 if (ns->pr.enable) { 1072 1072 pc_ref = xa_erase(&ns->pr_per_ctrl_refs, ctrl->cntlid); 1073 1073 if (pc_ref) ··· 1087 1087 kfifo_free(&ctrl->pr_log_mgr.log_queue); 1088 1088 mutex_destroy(&ctrl->pr_log_mgr.lock); 1089 1089 1090 - xa_for_each(&ctrl->subsys->namespaces, idx, ns) { 1090 + nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) { 1091 1091 if (ns->pr.enable) { 1092 1092 pc_ref = xa_erase(&ns->pr_per_ctrl_refs, ctrl->cntlid); 1093 1093 if (pc_ref)