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.9-20240405' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:

- NVMe pull request via Keith:
- Atomic queue limits fixes (Christoph)
- Fabrics fixes (Hannes, Daniel)

- Discard overflow fix (Li)

- Cleanup fix for null_blk (Damien)

* tag 'block-6.9-20240405' of git://git.kernel.dk/linux:
nvme-fc: rename free_ctrl callback to match name pattern
nvmet-fc: move RCU read lock to nvmet_fc_assoc_exists
nvmet: implement unique discovery NQN
nvme: don't create a multipath node for zero capacity devices
nvme: split nvme_update_zone_info
nvme-multipath: don't inherit LBA-related fields for the multipath node
block: fix overflow in blk_ioctl_discard()
nullblk: Fix cleanup order in null_add_dev() error path

+133 -37
+3 -2
block/ioctl.c
··· 96 96 unsigned long arg) 97 97 { 98 98 uint64_t range[2]; 99 - uint64_t start, len; 99 + uint64_t start, len, end; 100 100 struct inode *inode = bdev->bd_inode; 101 101 int err; 102 102 ··· 117 117 if (len & 511) 118 118 return -EINVAL; 119 119 120 - if (start + len > bdev_nr_bytes(bdev)) 120 + if (check_add_overflow(start, len, &end) || 121 + end > bdev_nr_bytes(bdev)) 121 122 return -EINVAL; 122 123 123 124 filemap_invalidate_lock(inode->i_mapping);
+2 -2
drivers/block/null_blk/main.c
··· 1965 1965 1966 1966 out_ida_free: 1967 1967 ida_free(&nullb_indexes, nullb->index); 1968 - out_cleanup_zone: 1969 - null_free_zoned_dev(dev); 1970 1968 out_cleanup_disk: 1971 1969 put_disk(nullb->disk); 1970 + out_cleanup_zone: 1971 + null_free_zoned_dev(dev); 1972 1972 out_cleanup_tags: 1973 1973 if (nullb->tag_set == &nullb->__tag_set) 1974 1974 blk_mq_free_tag_set(nullb->tag_set);
+32 -9
drivers/nvme/host/core.c
··· 2076 2076 bool vwc = ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT; 2077 2077 struct queue_limits lim; 2078 2078 struct nvme_id_ns_nvm *nvm = NULL; 2079 + struct nvme_zone_info zi = {}; 2079 2080 struct nvme_id_ns *id; 2080 2081 sector_t capacity; 2081 2082 unsigned lbaf; ··· 2089 2088 if (id->ncap == 0) { 2090 2089 /* namespace not allocated or attached */ 2091 2090 info->is_removed = true; 2092 - ret = -ENODEV; 2091 + ret = -ENXIO; 2093 2092 goto out; 2094 2093 } 2094 + lbaf = nvme_lbaf_index(id->flbas); 2095 2095 2096 2096 if (ns->ctrl->ctratt & NVME_CTRL_ATTR_ELBAS) { 2097 2097 ret = nvme_identify_ns_nvm(ns->ctrl, info->nsid, &nvm); ··· 2100 2098 goto out; 2101 2099 } 2102 2100 2101 + if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && 2102 + ns->head->ids.csi == NVME_CSI_ZNS) { 2103 + ret = nvme_query_zone_info(ns, lbaf, &zi); 2104 + if (ret < 0) 2105 + goto out; 2106 + } 2107 + 2103 2108 blk_mq_freeze_queue(ns->disk->queue); 2104 - lbaf = nvme_lbaf_index(id->flbas); 2105 2109 ns->head->lba_shift = id->lbaf[lbaf].ds; 2106 2110 ns->head->nuse = le64_to_cpu(id->nuse); 2107 2111 capacity = nvme_lba_to_sect(ns->head, le64_to_cpu(id->nsze)); ··· 2120 2112 capacity = 0; 2121 2113 nvme_config_discard(ns, &lim); 2122 2114 if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && 2123 - ns->head->ids.csi == NVME_CSI_ZNS) { 2124 - ret = nvme_update_zone_info(ns, lbaf, &lim); 2125 - if (ret) { 2126 - blk_mq_unfreeze_queue(ns->disk->queue); 2127 - goto out; 2128 - } 2129 - } 2115 + ns->head->ids.csi == NVME_CSI_ZNS) 2116 + nvme_update_zone_info(ns, &lim, &zi); 2130 2117 ret = queue_limits_commit_update(ns->disk->queue, &lim); 2131 2118 if (ret) { 2132 2119 blk_mq_unfreeze_queue(ns->disk->queue); ··· 2204 2201 } 2205 2202 2206 2203 if (!ret && nvme_ns_head_multipath(ns->head)) { 2204 + struct queue_limits *ns_lim = &ns->disk->queue->limits; 2207 2205 struct queue_limits lim; 2208 2206 2209 2207 blk_mq_freeze_queue(ns->head->disk->queue); ··· 2216 2212 set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info)); 2217 2213 nvme_mpath_revalidate_paths(ns); 2218 2214 2215 + /* 2216 + * queue_limits mixes values that are the hardware limitations 2217 + * for bio splitting with what is the device configuration. 2218 + * 2219 + * For NVMe the device configuration can change after e.g. a 2220 + * Format command, and we really want to pick up the new format 2221 + * value here. But we must still stack the queue limits to the 2222 + * least common denominator for multipathing to split the bios 2223 + * properly. 2224 + * 2225 + * To work around this, we explicitly set the device 2226 + * configuration to those that we just queried, but only stack 2227 + * the splitting limits in to make sure we still obey possibly 2228 + * lower limitations of other controllers. 2229 + */ 2219 2230 lim = queue_limits_start_update(ns->head->disk->queue); 2231 + lim.logical_block_size = ns_lim->logical_block_size; 2232 + lim.physical_block_size = ns_lim->physical_block_size; 2233 + lim.io_min = ns_lim->io_min; 2234 + lim.io_opt = ns_lim->io_opt; 2220 2235 queue_limits_stack_bdev(&lim, ns->disk->part0, 0, 2221 2236 ns->head->disk->disk_name); 2222 2237 ret = queue_limits_commit_update(ns->head->disk->queue, &lim);
+2 -2
drivers/nvme/host/fc.c
··· 2428 2428 * controller. Called after last nvme_put_ctrl() call 2429 2429 */ 2430 2430 static void 2431 - nvme_fc_nvme_ctrl_freed(struct nvme_ctrl *nctrl) 2431 + nvme_fc_free_ctrl(struct nvme_ctrl *nctrl) 2432 2432 { 2433 2433 struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); 2434 2434 ··· 3384 3384 .reg_read32 = nvmf_reg_read32, 3385 3385 .reg_read64 = nvmf_reg_read64, 3386 3386 .reg_write32 = nvmf_reg_write32, 3387 - .free_ctrl = nvme_fc_nvme_ctrl_freed, 3387 + .free_ctrl = nvme_fc_free_ctrl, 3388 3388 .submit_async_event = nvme_fc_submit_async_event, 3389 3389 .delete_ctrl = nvme_fc_delete_ctrl, 3390 3390 .get_address = nvmf_get_address,
+10 -2
drivers/nvme/host/nvme.h
··· 1036 1036 } 1037 1037 #endif /* CONFIG_NVME_MULTIPATH */ 1038 1038 1039 + struct nvme_zone_info { 1040 + u64 zone_size; 1041 + unsigned int max_open_zones; 1042 + unsigned int max_active_zones; 1043 + }; 1044 + 1039 1045 int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, 1040 1046 unsigned int nr_zones, report_zones_cb cb, void *data); 1041 - int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf, 1042 - struct queue_limits *lim); 1047 + int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf, 1048 + struct nvme_zone_info *zi); 1049 + void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim, 1050 + struct nvme_zone_info *zi); 1043 1051 #ifdef CONFIG_BLK_DEV_ZONED 1044 1052 blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req, 1045 1053 struct nvme_command *cmnd,
+20 -13
drivers/nvme/host/zns.c
··· 35 35 return 0; 36 36 } 37 37 38 - int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf, 39 - struct queue_limits *lim) 38 + int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf, 39 + struct nvme_zone_info *zi) 40 40 { 41 41 struct nvme_effects_log *log = ns->head->effects; 42 42 struct nvme_command c = { }; ··· 89 89 goto free_data; 90 90 } 91 91 92 - ns->head->zsze = 93 - nvme_lba_to_sect(ns->head, le64_to_cpu(id->lbafe[lbaf].zsze)); 94 - if (!is_power_of_2(ns->head->zsze)) { 92 + zi->zone_size = le64_to_cpu(id->lbafe[lbaf].zsze); 93 + if (!is_power_of_2(zi->zone_size)) { 95 94 dev_warn(ns->ctrl->device, 96 - "invalid zone size:%llu for namespace:%u\n", 97 - ns->head->zsze, ns->head->ns_id); 95 + "invalid zone size: %llu for namespace: %u\n", 96 + zi->zone_size, ns->head->ns_id); 98 97 status = -ENODEV; 99 98 goto free_data; 100 99 } 100 + zi->max_open_zones = le32_to_cpu(id->mor) + 1; 101 + zi->max_active_zones = le32_to_cpu(id->mar) + 1; 101 102 102 - blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ns->queue); 103 - lim->zoned = 1; 104 - lim->max_open_zones = le32_to_cpu(id->mor) + 1; 105 - lim->max_active_zones = le32_to_cpu(id->mar) + 1; 106 - lim->chunk_sectors = ns->head->zsze; 107 - lim->max_zone_append_sectors = ns->ctrl->max_zone_append; 108 103 free_data: 109 104 kfree(id); 110 105 return status; 106 + } 107 + 108 + void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim, 109 + struct nvme_zone_info *zi) 110 + { 111 + lim->zoned = 1; 112 + lim->max_open_zones = zi->max_open_zones; 113 + lim->max_active_zones = zi->max_active_zones; 114 + lim->max_zone_append_sectors = ns->ctrl->max_zone_append; 115 + lim->chunk_sectors = ns->head->zsze = 116 + nvme_lba_to_sect(ns->head, zi->zone_size); 117 + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ns->queue); 111 118 } 112 119 113 120 static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns,
+47
drivers/nvme/target/configfs.c
··· 1613 1613 return ERR_PTR(-EINVAL); 1614 1614 } 1615 1615 1616 + if (sysfs_streq(name, nvmet_disc_subsys->subsysnqn)) { 1617 + pr_err("can't create subsystem using unique discovery NQN\n"); 1618 + return ERR_PTR(-EINVAL); 1619 + } 1620 + 1616 1621 subsys = nvmet_subsys_alloc(name, NVME_NQN_NVME); 1617 1622 if (IS_ERR(subsys)) 1618 1623 return ERR_CAST(subsys); ··· 2164 2159 2165 2160 static struct config_group nvmet_hosts_group; 2166 2161 2162 + static ssize_t nvmet_root_discovery_nqn_show(struct config_item *item, 2163 + char *page) 2164 + { 2165 + return snprintf(page, PAGE_SIZE, "%s\n", nvmet_disc_subsys->subsysnqn); 2166 + } 2167 + 2168 + static ssize_t nvmet_root_discovery_nqn_store(struct config_item *item, 2169 + const char *page, size_t count) 2170 + { 2171 + struct list_head *entry; 2172 + size_t len; 2173 + 2174 + len = strcspn(page, "\n"); 2175 + if (!len || len > NVMF_NQN_FIELD_LEN - 1) 2176 + return -EINVAL; 2177 + 2178 + down_write(&nvmet_config_sem); 2179 + list_for_each(entry, &nvmet_subsystems_group.cg_children) { 2180 + struct config_item *item = 2181 + container_of(entry, struct config_item, ci_entry); 2182 + 2183 + if (!strncmp(config_item_name(item), page, len)) { 2184 + pr_err("duplicate NQN %s\n", config_item_name(item)); 2185 + up_write(&nvmet_config_sem); 2186 + return -EINVAL; 2187 + } 2188 + } 2189 + memset(nvmet_disc_subsys->subsysnqn, 0, NVMF_NQN_FIELD_LEN); 2190 + memcpy(nvmet_disc_subsys->subsysnqn, page, len); 2191 + up_write(&nvmet_config_sem); 2192 + 2193 + return len; 2194 + } 2195 + 2196 + CONFIGFS_ATTR(nvmet_root_, discovery_nqn); 2197 + 2198 + static struct configfs_attribute *nvmet_root_attrs[] = { 2199 + &nvmet_root_attr_discovery_nqn, 2200 + NULL, 2201 + }; 2202 + 2167 2203 static const struct config_item_type nvmet_root_type = { 2204 + .ct_attrs = nvmet_root_attrs, 2168 2205 .ct_owner = THIS_MODULE, 2169 2206 }; 2170 2207
+7
drivers/nvme/target/core.c
··· 1541 1541 } 1542 1542 1543 1543 down_read(&nvmet_config_sem); 1544 + if (!strncmp(nvmet_disc_subsys->subsysnqn, subsysnqn, 1545 + NVMF_NQN_SIZE)) { 1546 + if (kref_get_unless_zero(&nvmet_disc_subsys->ref)) { 1547 + up_read(&nvmet_config_sem); 1548 + return nvmet_disc_subsys; 1549 + } 1550 + } 1544 1551 list_for_each_entry(p, &port->subsystems, entry) { 1545 1552 if (!strncmp(p->subsys->subsysnqn, subsysnqn, 1546 1553 NVMF_NQN_SIZE)) {
+10 -7
drivers/nvme/target/fc.c
··· 1115 1115 } 1116 1116 1117 1117 static bool 1118 - nvmet_fc_assoc_exits(struct nvmet_fc_tgtport *tgtport, u64 association_id) 1118 + nvmet_fc_assoc_exists(struct nvmet_fc_tgtport *tgtport, u64 association_id) 1119 1119 { 1120 1120 struct nvmet_fc_tgt_assoc *a; 1121 + bool found = false; 1121 1122 1123 + rcu_read_lock(); 1122 1124 list_for_each_entry_rcu(a, &tgtport->assoc_list, a_list) { 1123 - if (association_id == a->association_id) 1124 - return true; 1125 + if (association_id == a->association_id) { 1126 + found = true; 1127 + break; 1128 + } 1125 1129 } 1130 + rcu_read_unlock(); 1126 1131 1127 - return false; 1132 + return found; 1128 1133 } 1129 1134 1130 1135 static struct nvmet_fc_tgt_assoc * ··· 1169 1164 ran = ran << BYTES_FOR_QID_SHIFT; 1170 1165 1171 1166 spin_lock_irqsave(&tgtport->lock, flags); 1172 - rcu_read_lock(); 1173 - if (!nvmet_fc_assoc_exits(tgtport, ran)) { 1167 + if (!nvmet_fc_assoc_exists(tgtport, ran)) { 1174 1168 assoc->association_id = ran; 1175 1169 list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list); 1176 1170 done = true; 1177 1171 } 1178 - rcu_read_unlock(); 1179 1172 spin_unlock_irqrestore(&tgtport->lock, flags); 1180 1173 } while (!done); 1181 1174