Skip to content

Commit fb15ffd

Browse files
committed
Merge commit '50abcc179e0c9ca667feb223b26ea406d5c4c556' of git://git.infradead.org/nvme into block-6.9
Pull NVMe fixes from Keith. * git://git.infradead.org/nvme: 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 nvme: fix warn output about shared namespaces without CONFIG_NVME_MULTIPATH
2 parents eaf4a9b + 50abcc1 commit fb15ffd

File tree

10 files changed

+65
-38
lines changed

10 files changed

+65
-38
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -628,27 +628,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
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)
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,27 @@ static inline bool nvme_is_aen_req(u16 qid, __u16 command_id)
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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,9 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
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)
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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,18 @@ static inline void nvme_tcp_send_all(struct nvme_tcp_queue *queue)
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,
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
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 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,19 @@ static struct configfs_attribute *nvmet_ns_attrs[] = {
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,13 @@ void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl)
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ void nvmet_subsys_disc_changed(struct nvmet_subsys *subsys,
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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ static int nvmet_tcp_check_ddgst(struct nvmet_tcp_queue *queue, void *pdu)
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)
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)

0 commit comments

Comments
 (0)