Pull block fixes from Jens Axboe: "Nothing major in here - an nvme pull request with mostly auth/tcp fixes, and a single fix for ublk not setting segment count and size limits" * tag 'block-6.9-20240503' of git://git.kernel.dk/linux: nvme-tcp: strict pdu pacing to avoid send stalls on TLS nvmet: fix nvme status code when namespace is disabled nvmet-tcp: fix possible memory leak when tearing down a controller nvme: cancel pending I/O if nvme controller is in terminal state nvmet-auth: replace pr_debug() with pr_err() to report an error. nvmet-auth: return the error code to the nvmet_auth_host_hash() callers nvme: find numa distance only if controller has valid numa id ublk: remove segment count and size limits nvme: fix warn output about shared namespaces without CONFIG_NVME_MULTIPATH
Unified · Split
| @@ -2177,7 +2177,8 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) · 2176 unmodified lines | |||
| 2177 | .max_hw_sectors = p->max_sectors, | 2177 | .max_hw_sectors = p->max_sectors, |
| 2178 | .chunk_sectors = p->chunk_sectors, | 2178 | .chunk_sectors = p->chunk_sectors, |
| 2179 | .virt_boundary_mask = p->virt_boundary_mask, | 2179 | .virt_boundary_mask = p->virt_boundary_mask, |
| 2180 | 2180 | .max_segments = USHRT_MAX, | |
| 2181 | .max_segment_size = UINT_MAX, | ||
| 2181 | }; | 2182 | }; |
| 2182 | struct gendisk *disk; | 2183 | struct gendisk *disk; |
| 2183 | int ret = -EINVAL; | 2184 | int ret = -EINVAL; |
| @@ -628,27 +628,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, · 627 unmodified lines | |||
| 628 | } | 628 | } |
| 629 | EXPORT_SYMBOL_GPL(nvme_change_ctrl_state); | 629 | EXPORT_SYMBOL_GPL(nvme_change_ctrl_state); |
| 630 | 630 | ||
| 631 | /* | ||
| 632 | * Returns true for sink states that can't ever transition back to live. | ||
| 633 | */ | ||
| 634 | static bool nvme_state_terminal(struct nvme_ctrl *ctrl) | ||
| 635 | { | ||
| 636 | switch (nvme_ctrl_state(ctrl)) { | ||
| 637 | case NVME_CTRL_NEW: | ||
| 638 | case NVME_CTRL_LIVE: | ||
| 639 | case NVME_CTRL_RESETTING: | ||
| 640 | case NVME_CTRL_CONNECTING: | ||
| 641 | return false; | ||
| 642 | case NVME_CTRL_DELETING: | ||
| 643 | case NVME_CTRL_DELETING_NOIO: | ||
| 644 | case NVME_CTRL_DEAD: | ||
| 645 | return true; | ||
| 646 | default: | ||
| 647 | WARN_ONCE(1, "Unhandled ctrl state:%d", ctrl->state); | ||
| 648 | return true; | ||
| 649 | } | ||
| 650 | } | ||
| 651 | |||
| 652 | /* | 631 | /* |
| 653 | * Waits for the controller state to be resetting, or returns false if it is | 632 | * Waits for the controller state to be resetting, or returns false if it is |
| 654 | * not possible to ever transition to that state. | 633 | * not possible to ever transition to that state. |
| @@ -3681,7 +3660,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info) · 3026 unmodified lines | |||
| 3681 | "Found shared namespace %d, but multipathing not supported.\n", | 3660 | "Found shared namespace %d, but multipathing not supported.\n", |
| 3682 | info->nsid); | 3661 | info->nsid); |
| 3683 | dev_warn_once(ctrl->device, | 3662 | dev_warn_once(ctrl->device, |
| 3684 | "Support for shared namespaces without CONFIG_NVME_MULTIPATH is deprecated and will be removed in Linux 6.0\n."); | 3663 | "Support for shared namespaces without CONFIG_NVME_MULTIPATH is deprecated and will be removed in Linux 6.0.\n"); |
| 3685 | } | 3664 | } |
| 3686 | } | 3665 | } |
| 3687 | 3666 | ||
| @@ -247,7 +247,8 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node) · 246 unmodified lines | |||
| 247 | if (nvme_path_is_disabled(ns)) | 247 | if (nvme_path_is_disabled(ns)) |
| 248 | continue; | 248 | continue; |
| 249 | 249 | ||
| 250 | if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA) | 250 | if (ns->ctrl->numa_node != NUMA_NO_NODE && |
| 251 | READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA) | ||
| 251 | distance = node_distance(node, ns->ctrl->numa_node); | 252 | distance = node_distance(node, ns->ctrl->numa_node); |
| 252 | else | 253 | else |
| 253 | distance = LOCAL_DISTANCE; | 254 | distance = LOCAL_DISTANCE; |
| @@ -741,6 +741,27 @@ static inline bool nvme_is_aen_req(u16 qid, __u16 command_id) · 740 unmodified lines | |||
| 741 | nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH; | 741 | nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH; |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | /* | ||
| 745 | * Returns true for sink states that can't ever transition back to live. | ||
| 746 | */ | ||
| 747 | static inline bool nvme_state_terminal(struct nvme_ctrl *ctrl) | ||
| 748 | { | ||
| 749 | switch (nvme_ctrl_state(ctrl)) { | ||
| 750 | case NVME_CTRL_NEW: | ||
| 751 | case NVME_CTRL_LIVE: | ||
| 752 | case NVME_CTRL_RESETTING: | ||
| 753 | case NVME_CTRL_CONNECTING: | ||
| 754 | return false; | ||
| 755 | case NVME_CTRL_DELETING: | ||
| 756 | case NVME_CTRL_DELETING_NOIO: | ||
| 757 | case NVME_CTRL_DEAD: | ||
| 758 | return true; | ||
| 759 | default: | ||
| 760 | WARN_ONCE(1, "Unhandled ctrl state:%d", ctrl->state); | ||
| 761 | return true; | ||
| 762 | } | ||
| 763 | } | ||
| 764 | |||
| 744 | void nvme_complete_rq(struct request *req); | 765 | void nvme_complete_rq(struct request *req); |
| 745 | void nvme_complete_batch_req(struct request *req); | 766 | void nvme_complete_batch_req(struct request *req); |
| 746 | 767 | ||
| @@ -1286,6 +1286,9 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req) · 1285 unmodified lines | |||
| 1286 | u32 csts = readl(dev->bar + NVME_REG_CSTS); | 1286 | u32 csts = readl(dev->bar + NVME_REG_CSTS); |
| 1287 | u8 opcode; | 1287 | u8 opcode; |
| 1288 | 1288 | ||
| 1289 | if (nvme_state_terminal(&dev->ctrl)) | ||
| 1290 | goto disable; | ||
| 1291 | |||
| 1289 | /* If PCI error recovery process is happening, we cannot reset or | 1292 | /* If PCI error recovery process is happening, we cannot reset or |
| 1290 | * the recovery mechanism will surely fail. | 1293 | * the recovery mechanism will surely fail. |
| 1291 | */ | 1294 | */ |
| @@ -1390,8 +1393,11 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req) · 98 unmodified lines | |||
| 1390 | return BLK_EH_RESET_TIMER; | 1393 | return BLK_EH_RESET_TIMER; |
| 1391 | 1394 | ||
| 1392 | disable: | 1395 | disable: |
| 1393 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) | 1396 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) { |
| 1397 | if (nvme_state_terminal(&dev->ctrl)) | ||
| 1398 | nvme_dev_disable(dev, true); | ||
| 1394 | return BLK_EH_DONE; | 1399 | return BLK_EH_DONE; |
| 1400 | } | ||
| 1395 | 1401 | ||
| 1396 | nvme_dev_disable(dev, false); | 1402 | nvme_dev_disable(dev, false); |
| 1397 | if (nvme_try_sched_reset(&dev->ctrl)) | 1403 | if (nvme_try_sched_reset(&dev->ctrl)) |
| @@ -360,12 +360,18 @@ static inline void nvme_tcp_send_all(struct nvme_tcp_queue *queue) · 359 unmodified lines | |||
| 360 | } while (ret > 0); | 360 | } while (ret > 0); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | static inline bool nvme_tcp_queue_more(struct nvme_tcp_queue *queue) | 363 | static inline bool nvme_tcp_queue_has_pending(struct nvme_tcp_queue *queue) |
| 364 | { | 364 | { |
| 365 | return !list_empty(&queue->send_list) || | 365 | return !list_empty(&queue->send_list) || |
| 366 | !llist_empty(&queue->req_list); | 366 | !llist_empty(&queue->req_list); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | static inline bool nvme_tcp_queue_more(struct nvme_tcp_queue *queue) | ||
| 370 | { | ||
| 371 | return !nvme_tcp_tls(&queue->ctrl->ctrl) && | ||
| 372 | nvme_tcp_queue_has_pending(queue); | ||
| 373 | } | ||
| 374 | |||
| 369 | static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, | 375 | static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, |
| 370 | bool sync, bool last) | 376 | bool sync, bool last) |
| 371 | { | 377 | { |
| @@ -386,7 +392,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, · 14 unmodified lines | |||
| 386 | mutex_unlock(&queue->send_mutex); | 392 | mutex_unlock(&queue->send_mutex); |
| 387 | } | 393 | } |
| 388 | 394 | ||
| 389 | if (last && nvme_tcp_queue_more(queue)) | 395 | if (last && nvme_tcp_queue_has_pending(queue)) |
| 390 | queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work); | 396 | queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work); |
| 391 | } | 397 | } |
| 392 | 398 | ||
| @@ -285,9 +285,9 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response, · 284 unmodified lines | |||
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | if (shash_len != crypto_shash_digestsize(shash_tfm)) { | 287 | if (shash_len != crypto_shash_digestsize(shash_tfm)) { |
| 288 | pr_debug("%s: hash len mismatch (len %d digest %d)\n", | 288 | pr_err("%s: hash len mismatch (len %d digest %d)\n", |
| 289 | __func__, shash_len, | 289 | __func__, shash_len, |
| 290 | crypto_shash_digestsize(shash_tfm)); | 290 | crypto_shash_digestsize(shash_tfm)); |
| 291 | ret = -EINVAL; | 291 | ret = -EINVAL; |
| 292 | goto out_free_tfm; | 292 | goto out_free_tfm; |
| 293 | } | 293 | } |
| @@ -370,7 +370,7 @@ out_free_response: · 76 unmodified lines | |||
| 370 | nvme_auth_free_key(transformed_key); | 370 | nvme_auth_free_key(transformed_key); |
| 371 | out_free_tfm: | 371 | out_free_tfm: |
| 372 | crypto_free_shash(shash_tfm); | 372 | crypto_free_shash(shash_tfm); |
| 373 | return 0; | 373 | return ret; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response, | 376 | int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response, |
| @@ -754,6 +754,19 @@ static struct configfs_attribute *nvmet_ns_attrs[] = { · 753 unmodified lines | |||
| 754 | NULL, | 754 | NULL, |
| 755 | }; | 755 | }; |
| 756 | 756 | ||
| 757 | bool nvmet_subsys_nsid_exists(struct nvmet_subsys *subsys, u32 nsid) | ||
| 758 | { | ||
| 759 | struct config_item *ns_item; | ||
| 760 | char name[4] = {}; | ||
| 761 | |||
| 762 | if (sprintf(name, "%u", nsid) <= 0) | ||
| 763 | return false; | ||
| 764 | mutex_lock(&subsys->namespaces_group.cg_subsys->su_mutex); | ||
| 765 | ns_item = config_group_find_item(&subsys->namespaces_group, name); | ||
| 766 | mutex_unlock(&subsys->namespaces_group.cg_subsys->su_mutex); | ||
| 767 | return ns_item != NULL; | ||
| 768 | } | ||
| 769 | |||
| 757 | static void nvmet_ns_release(struct config_item *item) | 770 | static void nvmet_ns_release(struct config_item *item) |
| 758 | { | 771 | { |
| 759 | struct nvmet_ns *ns = to_nvmet_ns(item); | 772 | struct nvmet_ns *ns = to_nvmet_ns(item); |
| @@ -437,10 +437,13 @@ void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl) · 436 unmodified lines | |||
| 437 | u16 nvmet_req_find_ns(struct nvmet_req *req) | 437 | u16 nvmet_req_find_ns(struct nvmet_req *req) |
| 438 | { | 438 | { |
| 439 | u32 nsid = le32_to_cpu(req->cmd->common.nsid); | 439 | u32 nsid = le32_to_cpu(req->cmd->common.nsid); |
| 440 | struct nvmet_subsys *subsys = nvmet_req_subsys(req); | ||
| 440 | 441 | ||
| 441 | req->ns = xa_load(&nvmet_req_subsys(req)->namespaces, nsid); | 442 | req->ns = xa_load(&subsys->namespaces, nsid); |
| 442 | if (unlikely(!req->ns)) { | 443 | if (unlikely(!req->ns)) { |
| 443 | req->error_loc = offsetof(struct nvme_common_command, nsid); | 444 | req->error_loc = offsetof(struct nvme_common_command, nsid); |
| 445 | if (nvmet_subsys_nsid_exists(subsys, nsid)) | ||
| 446 | return NVME_SC_INTERNAL_PATH_ERROR; | ||
| 444 | return NVME_SC_INVALID_NS | NVME_SC_DNR; | 447 | return NVME_SC_INVALID_NS | NVME_SC_DNR; |
| 445 | } | 448 | } |
| 446 | 449 | ||
| @@ -543,6 +543,7 @@ void nvmet_subsys_disc_changed(struct nvmet_subsys *subsys, · 542 unmodified lines | |||
| 543 | struct nvmet_host *host); | 543 | struct nvmet_host *host); |
| 544 | void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, | 544 | void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, |
| 545 | u8 event_info, u8 log_page); | 545 | u8 event_info, u8 log_page); |
| 546 | bool nvmet_subsys_nsid_exists(struct nvmet_subsys *subsys, u32 nsid); | ||
| 546 | 547 | ||
| 547 | #define NVMET_MIN_QUEUE_SIZE 16 | 548 | #define NVMET_MIN_QUEUE_SIZE 16 |
| 548 | #define NVMET_MAX_QUEUE_SIZE 1024 | 549 | #define NVMET_MAX_QUEUE_SIZE 1024 |
| @@ -348,6 +348,7 @@ static int nvmet_tcp_check_ddgst(struct nvmet_tcp_queue *queue, void *pdu) · 347 unmodified lines | |||
| 348 | return 0; | 348 | return 0; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | /* If cmd buffers are NULL, no operation is performed */ | ||
| 351 | static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd) | 352 | static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd) |
| 352 | { | 353 | { |
| 353 | kfree(cmd->iov); | 354 | kfree(cmd->iov); |
| @@ -1581,13 +1582,9 @@ static void nvmet_tcp_free_cmd_data_in_buffers(struct nvmet_tcp_queue *queue) · 1227 unmodified lines | |||
| 1581 | struct nvmet_tcp_cmd *cmd = queue->cmds; | 1582 | struct nvmet_tcp_cmd *cmd = queue->cmds; |
| 1582 | int i; | 1583 | int i; |
| 1583 | 1584 | ||
| 1584 | for (i = 0; i < queue->nr_cmds; i++, cmd++) { | 1585 | for (i = 0; i < queue->nr_cmds; i++, cmd++) |
| 1585 | if (nvmet_tcp_need_data_in(cmd)) | 1586 | nvmet_tcp_free_cmd_buffers(cmd); |
| 1586 | nvmet_tcp_free_cmd_buffers(cmd); | 1587 | nvmet_tcp_free_cmd_buffers(&queue->connect); |
| 1587 | } | ||
| 1588 | |||
| 1589 | if (!queue->nr_cmds && nvmet_tcp_need_data_in(&queue->connect)) | ||
| 1590 | nvmet_tcp_free_cmd_buffers(&queue->connect); | ||
| 1591 | } | 1588 | } |
| 1592 | 1589 | ||
| 1593 | static void nvmet_tcp_release_queue_work(struct work_struct *w) | 1590 | static void nvmet_tcp_release_queue_work(struct work_struct *w) |