[PATCH 2/2] nvmet: fix a race condition between release_queue and io_work
Maurizio Lombardi
mlombard at redhat.com
Mon Nov 15 02:57:15 PST 2021
On Mon, Nov 15, 2021 at 11:00:04AM +0100, Maurizio Lombardi wrote:
>
> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
> index fb72e2d67fd5..d21b525fd4cb 100644
> --- a/drivers/nvme/target/tcp.c
> +++ b/drivers/nvme/target/tcp.c
> @@ -1450,7 +1450,9 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
> mutex_unlock(&nvmet_tcp_queue_mutex);
>
> nvmet_tcp_restore_socket_callbacks(queue);
> - flush_work(&queue->io_work);
> + cancel_work_sync(&queue->io_work);
> + /* stop accepting incoming data */
> + queue->rcv_state = NVMET_TCP_RECV_ERR;
>
> nvmet_tcp_uninit_data_in_cmds(queue);
> nvmet_sq_destroy(&queue->nvme_sq);
>
> If you don't perform a cancel_work_sync() you may race against a running
> io_work thread that may overwrite rcv_state with some other value.
This one works correctly.
Unless an unforseen problem arises, I am going to resubmit
the patchset soon.
Maurizio
More information about the Linux-nvme
mailing list