History

Merge tag 'block-6.9-20240503' of git://git.kernel.dk/linux

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

Linus Torvalds committed 2 years ago

Commit 3d25a942 parents 7dc78c7 fb15ffd11 files · +67 −39Browse files

Unified · Split

11 files
  1. drivers/block/ublk_drv.c +2 −1
  2. drivers/nvme/host/core.c +1 −22
  3. drivers/nvme/host/multipath.c +2 −1
  4. drivers/nvme/host/nvme.h +21 −0
  5. drivers/nvme/host/pci.c +7 −1
  6. drivers/nvme/host/tcp.c +8 −2
  7. drivers/nvme/target/auth.c +4 −4
  8. drivers/nvme/target/configfs.c +13 −0
  9. drivers/nvme/target/core.c +4 −1
  10. drivers/nvme/target/nvmet.h +1 −0
  11. drivers/nvme/target/tcp.c +4 −7
drivers/block/ublk_drv.c+2−1
@@ -2177,7 +2177,8 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) · 2176 unmodified lines
21772177 .max_hw_sectors = p->max_sectors,
21782178 .chunk_sectors = p->chunk_sectors,
21792179 .virt_boundary_mask = p->virt_boundary_mask,
2180−
2180+ .max_segments = USHRT_MAX,
2181+ .max_segment_size = UINT_MAX,
21812182 };
21822183 struct gendisk *disk;
21832184 int ret = -EINVAL;
drivers/nvme/host/core.c+1−22
@@ -628,27 +628,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, · 627 unmodified lines
628628 }
629629 EXPORT_SYMBOL_GPL(nvme_change_ctrl_state);
630630
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−
652631 /*
653632 * Waits for the controller state to be resetting, or returns false if it is
654633 * 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
36813660 "Found shared namespace %d, but multipathing not supported.\n",
36823661 info->nsid);
36833662 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");
36853664 }
36863665 }
36873666
drivers/nvme/host/multipath.c+2−1
@@ -247,7 +247,8 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node) · 246 unmodified lines
247247 if (nvme_path_is_disabled(ns))
248248 continue;
249249
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)
251252 distance = node_distance(node, ns->ctrl->numa_node);
252253 else
253254 distance = LOCAL_DISTANCE;
drivers/nvme/host/nvme.h+21−0
@@ -741,6 +741,27 @@ static inline bool nvme_is_aen_req(u16 qid, __u16 command_id) · 740 unmodified lines
741741 nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH;
742742 }
743743
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+
744765 void nvme_complete_rq(struct request *req);
745766 void nvme_complete_batch_req(struct request *req);
746767
drivers/nvme/host/pci.c+7−1
@@ -1286,6 +1286,9 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req) · 1285 unmodified lines
12861286 u32 csts = readl(dev->bar + NVME_REG_CSTS);
12871287 u8 opcode;
12881288
1289+ if (nvme_state_terminal(&dev->ctrl))
1290+ goto disable;
1291+
12891292 /* If PCI error recovery process is happening, we cannot reset or
12901293 * the recovery mechanism will surely fail.
12911294 */
@@ -1390,8 +1393,11 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req) · 98 unmodified lines
13901393 return BLK_EH_RESET_TIMER;
13911394
13921395 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);
13941399 return BLK_EH_DONE;
1400+ }
13951401
13961402 nvme_dev_disable(dev, false);
13971403 if (nvme_try_sched_reset(&dev->ctrl))
drivers/nvme/host/tcp.c+8−2
@@ -360,12 +360,18 @@ static inline void nvme_tcp_send_all(struct nvme_tcp_queue *queue) · 359 unmodified lines
360360 } while (ret > 0);
361361 }
362362
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)
364364 {
365365 return !list_empty(&queue->send_list) ||
366366 !llist_empty(&queue->req_list);
367367 }
368368
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+
369375 static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
370376 bool sync, bool last)
371377 {
@@ -386,7 +392,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, · 14 unmodified lines
386392 mutex_unlock(&queue->send_mutex);
387393 }
388394
389− if (last && nvme_tcp_queue_more(queue))
395+ if (last && nvme_tcp_queue_has_pending(queue))
390396 queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
391397 }
392398
drivers/nvme/target/auth.c+4−4
@@ -285,9 +285,9 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response, · 284 unmodified lines
285285 }
286286
287287 if (shash_len != crypto_shash_digestsize(shash_tfm)) {
288− pr_debug("%s: hash len mismatch (len %d digest %d)\n",
289− __func__, shash_len,
290− crypto_shash_digestsize(shash_tfm));
288+ pr_err("%s: hash len mismatch (len %d digest %d)\n",
289+ __func__, shash_len,
290+ crypto_shash_digestsize(shash_tfm));
291291 ret = -EINVAL;
292292 goto out_free_tfm;
293293 }
@@ -370,7 +370,7 @@ out_free_response: · 76 unmodified lines
370370 nvme_auth_free_key(transformed_key);
371371 out_free_tfm:
372372 crypto_free_shash(shash_tfm);
373− return 0;
373+ return ret;
374374 }
375375
376376 int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
drivers/nvme/target/configfs.c+13−0
@@ -754,6 +754,19 @@ static struct configfs_attribute *nvmet_ns_attrs[] = { · 753 unmodified lines
754754 NULL,
755755 };
756756
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+
757770 static void nvmet_ns_release(struct config_item *item)
758771 {
759772 struct nvmet_ns *ns = to_nvmet_ns(item);
drivers/nvme/target/core.c+4−1
@@ -437,10 +437,13 @@ void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl) · 436 unmodified lines
437437 u16 nvmet_req_find_ns(struct nvmet_req *req)
438438 {
439439 u32 nsid = le32_to_cpu(req->cmd->common.nsid);
440+ struct nvmet_subsys *subsys = nvmet_req_subsys(req);
440441
441− req->ns = xa_load(&nvmet_req_subsys(req)->namespaces, nsid);
442+ req->ns = xa_load(&subsys->namespaces, nsid);
442443 if (unlikely(!req->ns)) {
443444 req->error_loc = offsetof(struct nvme_common_command, nsid);
445+ if (nvmet_subsys_nsid_exists(subsys, nsid))
446+ return NVME_SC_INTERNAL_PATH_ERROR;
444447 return NVME_SC_INVALID_NS | NVME_SC_DNR;
445448 }
446449
drivers/nvme/target/nvmet.h+1−0
@@ -543,6 +543,7 @@ void nvmet_subsys_disc_changed(struct nvmet_subsys *subsys, · 542 unmodified lines
543543 struct nvmet_host *host);
544544 void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
545545 u8 event_info, u8 log_page);
546+bool nvmet_subsys_nsid_exists(struct nvmet_subsys *subsys, u32 nsid);
546547
547548 #define NVMET_MIN_QUEUE_SIZE 16
548549 #define NVMET_MAX_QUEUE_SIZE 1024
drivers/nvme/target/tcp.c+4−7
@@ -348,6 +348,7 @@ static int nvmet_tcp_check_ddgst(struct nvmet_tcp_queue *queue, void *pdu) · 347 unmodified lines
348348 return 0;
349349 }
350350
351+/* If cmd buffers are NULL, no operation is performed */
351352 static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd)
352353 {
353354 kfree(cmd->iov);
@@ -1581,13 +1582,9 @@ static void nvmet_tcp_free_cmd_data_in_buffers(struct nvmet_tcp_queue *queue) · 1227 unmodified lines
15811582 struct nvmet_tcp_cmd *cmd = queue->cmds;
15821583 int i;
15831584
1584− for (i = 0; i < queue->nr_cmds; i++, cmd++) {
1585− if (nvmet_tcp_need_data_in(cmd))
1586− nvmet_tcp_free_cmd_buffers(cmd);
1587− }
1588−
1589− if (!queue->nr_cmds && nvmet_tcp_need_data_in(&queue->connect))
1590− nvmet_tcp_free_cmd_buffers(&queue->connect);
1585+ for (i = 0; i < queue->nr_cmds; i++, cmd++)
1586+ nvmet_tcp_free_cmd_buffers(cmd);
1587+ nvmet_tcp_free_cmd_buffers(&queue->connect);
15911588 }
15921589
15931590 static void nvmet_tcp_release_queue_work(struct work_struct *w)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t