[RFC PATCH 2/2] nvme-tcp: remove send_mutex

From: Seiji Nishikawa

Date: Sat Nov 21 2026 - 20:20:25 EST


With the direct send path gone, io_work is the only context that sends
on a queue. A work item never runs concurrently with itself, so
send_mutex does not protect anything anymore.

Remove it, together with the mutex_trylock() in nvme_tcp_io_work() and
the got_send_mutex check, which is now always true.

Assisted-by: LLM
Signed-off-by: Seiji Nishikawa <snishika@xxxxxxxxxx>
---
drivers/nvme/host/tcp.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 2b832ac3068a..b116268fe2f5 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -142,7 +142,6 @@ struct nvme_tcp_queue {
int io_cpu;

struct mutex queue_lock;
- struct mutex send_mutex;
struct mutex pf_cache_lock;
struct llist_head req_list;
struct list_head send_list;
@@ -1482,18 +1481,13 @@ static void nvme_tcp_io_work(struct work_struct *w)

do {
bool pending = false;
- bool got_send_mutex = false;
int result;

- if (mutex_trylock(&queue->send_mutex)) {
- got_send_mutex = true;
- result = nvme_tcp_try_send(queue);
- mutex_unlock(&queue->send_mutex);
- if (result > 0)
- pending = true;
- else if (unlikely(result < 0))
- break;
- }
+ result = nvme_tcp_try_send(queue);
+ if (result > 0)
+ pending = true;
+ else if (unlikely(result < 0))
+ break;

result = nvme_tcp_try_recv(queue);
if (result > 0)
@@ -1501,13 +1495,8 @@ static void nvme_tcp_io_work(struct work_struct *w)
else if (unlikely(result < 0))
return;

- /*
- * did we get some space after spending time in recv?
- * Only check this if we could take send_mutex. Otherwise
- * the task holding it sends the requests and queues io_work
- * again after it releases the mutex.
- */
- if (got_send_mutex && nvme_tcp_queue_has_pending(queue) &&
+ /* did we get some space after spending time in recv? */
+ if (nvme_tcp_queue_has_pending(queue) &&
sk_stream_is_writeable(queue->sock->sk))
pending = true;

@@ -2087,7 +2076,6 @@ static void nvme_tcp_init_queue(struct nvme_tcp_ctrl *ctrl, int qid)

queue->ctrl = ctrl;
mutex_init(&queue->queue_lock);
- mutex_init(&queue->send_mutex);
mutex_init(&queue->pf_cache_lock);
INIT_WORK(&queue->io_work, nvme_tcp_io_work);
queue->hdr_digest = ctrl->ctrl.opts->hdr_digest;
@@ -2099,7 +2087,6 @@ static void nvme_tcp_exit_queue(struct nvme_tcp_ctrl *ctrl, int qid)
struct nvme_tcp_queue *queue = &ctrl->queues[qid];

mutex_destroy(&queue->queue_lock);
- mutex_destroy(&queue->send_mutex);
mutex_destroy(&queue->pf_cache_lock);
}

--
2.56.1