Skip to contentSkip to conversation

nvmet-tcp: remove a redundant line in nvmet_tcp_release_queue_work

PATCH In review Tomas Henzl 2 participants 4 messages Oct 6, 2025 – Oct 13, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet-tcp: remove a redundant line in nvmet_tcp_release_queue_work

cancel_work_sync(&queue->io_work) is called twice, remove the second instance.

---
 drivers/nvme/target/tcp.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvme/target/tcp.c +0 -1
index 470bf37e5a63..a1d0f6b18b2c 100644
@@ -1577,7 +1577,6 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
 	nvmet_tcp_uninit_data_in_cmds(queue);
 	nvmet_sq_destroy(&queue->nvme_sq);
 	nvmet_cq_put(&queue->nvme_cq);
-	cancel_work_sync(&queue->io_work);
 	nvmet_tcp_free_cmd_data_in_buffers(queue);
 	/* ->sock will be released by fput() */
 	fput(queue->sock->file);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 13 lines · Tomas Henzl

cancel_work_sync(&queue->io_work) is called twice, remove the second instance.

---
 drivers/nvme/target/tcp.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvme/target/tcp.c +0 -0
index 470bf37e5a63..a1d0f6b18b2c 100644

drivers/nvme/target/tcp.c static void nvmet_tcp_release_queue_work(struct work_struct *w) · line 1582

Quoted 7 lines
drivers/nvme/target/tcp.c +0 -1
@@ -1577,7 +1577,6 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
 	nvmet_tcp_uninit_data_in_cmds(queue);
 	nvmet_sq_destroy(&queue->nvme_sq);
 	nvmet_cq_put(&queue->nvme_cq);
-	cancel_work_sync(&queue->io_work);
 	nvmet_tcp_free_cmd_data_in_buffers(queue);
 	/* ->sock will be released by fput() */
 	fput(queue->sock->file);

I am not sure it's safe to remove it because io_work can potentially re-enqueue itself.

The second call to cancel_work_sync(), after rcv_state is set to NVMET_TCP_RECV_ERR, should ensure that no more "io_work"s are pending on the workqueue.

Maurizio

#2 lore raw
Quoted 9 lines · Maurizio Lombardi
Quoted 8 lines · Tomas Henzl

cancel_work_sync(&queue->io_work) is called twice, remove the second instance.

---
 drivers/nvme/target/tcp.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 16 lines

drivers/nvme/target/tcp.c static void nvmet_tcp_release_queue_work(struct work_struct *w) · line 1582

Quoted 12 lines
drivers/nvme/target/tcp.c +0 -1
index 470bf37e5a63..a1d0f6b18b2c 100644
@@ -1577,7 +1577,6 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
 	nvmet_tcp_uninit_data_in_cmds(queue);
 	nvmet_sq_destroy(&queue->nvme_sq);
 	nvmet_cq_put(&queue->nvme_cq);
-	cancel_work_sync(&queue->io_work);
 	nvmet_tcp_free_cmd_data_in_buffers(queue);
 	/* ->sock will be released by fput() */
 	fput(queue->sock->file);

I am not sure it's safe to remove it because io_work can potentially re-enqueue itself.

Small correction, the problem isn't io_work re-enqueing itself (the first cancel_work_sync() prevents that); I think the real problem is that nvmet_sq_destroy() could end up calling nvmet_tcp_queue_response() which enqueues io_work again.

Maurizio

#3 lore raw
Quoted 27 lines · Maurizio Lombardi
Quoted 9 lines · Maurizio Lombardi
Quoted 8 lines · Tomas Henzl

cancel_work_sync(&queue->io_work) is called twice, remove the second instance.

---
 drivers/nvme/target/tcp.c | 1 -
 1 file changed, 1 deletion(-)
Quoted 16 lines

drivers/nvme/target/tcp.c static void nvmet_tcp_release_queue_work(struct work_struct *w) · line 1582

Quoted 12 lines
drivers/nvme/target/tcp.c +0 -1
index 470bf37e5a63..a1d0f6b18b2c 100644
@@ -1577,7 +1577,6 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
 	nvmet_tcp_uninit_data_in_cmds(queue);
 	nvmet_sq_destroy(&queue->nvme_sq);
 	nvmet_cq_put(&queue->nvme_cq);
-	cancel_work_sync(&queue->io_work);
 	nvmet_tcp_free_cmd_data_in_buffers(queue);
 	/* ->sock will be released by fput() */
 	fput(queue->sock->file);

I am not sure it's safe to remove it because io_work can potentially re-enqueue itself.

Quoted 4 lines

Small correction, the problem isn't io_work re-enqueing itself (the first cancel_work_sync() prevents that); I think the real problem is that nvmet_sq_destroy() could end up calling nvmet_tcp_queue_response() which enqueues io_work again.

The NVMET_TCP_RECV_ERR sate would make the workqueue finish quickly but sure we don't want a running workqueue.

Let's drop this patch.

tomash

Quoted 3 lines

Maurizio