mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Cc: linux-nvme@lists.infradead.org, axboe@kernel.dk, hch@lst.de,
	sagi@grimberg.me, hare@kernel.org, sgogte@purestorage.com,
	wagi@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] nvme-tcp: fix request PDU size when header digest is enabled
Date: Tue, 27 Oct 2026 17:04:50 -0600	[thread overview]
Message-ID: <auEuEoILz3cndXOV@kbusch-mbp> (raw)
In-Reply-To: <20261027194710.334495-1-christian.aurichzm@gmail.com>

On Tue, Oct 27, 2026 at 04:47:10PM -0300, Christian Aurich Zanettini Martins wrote:
> Since commit 61b0ed3be81b ("nvme-tcp: parallelize I/O queue allocation
> and startup") the I/O tag set is allocated before the I/O queues.
> nvme_tcp_init_request() sizes the PDU with nvme_tcp_hdgst_len(queue),
> but queue->hdr_digest is only set later by nvme_tcp_alloc_queue(), so
> every I/O PDU is allocated without room for the header digest.
> 
> With hdr_digest enabled, the digest is then written 4 bytes past the
> PDU, over the header of the next PDU in the page_frag cache, and the
> target drops the connection on the first I/O:
> 
>   nvmet_tcp: unexpected pdu type 159
>   nvmet: ctrl 1 fatal error occurred!
> 
> Queues that a later reconnect adds for the first time have the same
> problem.
> 
> Set queue->hdr_digest when allocating the controller, together with
> pf_cache_lock, so it is valid before any request is initialized.

Thanks, applied to nvme-7.4.

> @@ -1948,7 +1948,6 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
>  		}
>  	}
>  
> -	queue->hdr_digest = nctrl->opts->hdr_digest;
>  	queue->data_digest = nctrl->opts->data_digest;
>  
>  	rcv_pdu_size = sizeof(struct nvme_tcp_rsp_pdu) +
> @@ -3098,10 +3097,13 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
>  	/*
>  	 * The I/O tag set is allocated before the I/O queues, and initializing
>  	 * its requests already allocates the PDUs from the page frag caches of
> -	 * the queues, so initialize their locks here.
> +	 * the queues, sized by their header digest setting, so set up the
> +	 * locks and hdr_digest here.
>  	 */
> -	for (i = 0; i < ctrl->ctrl.queue_count; i++)
> +	for (i = 0; i < ctrl->ctrl.queue_count; i++) {
>  		mutex_init(&ctrl->queues[i].pf_cache_lock);
> +		ctrl->queues[i].hdr_digest = opts->hdr_digest;
> +	}

A follow on bonus patch can clean this up a bit by introducing a helper
function, maybe nvme_tcp_init_queue(), and initialize all the basic
fields there.

      reply	other threads:[~2026-10-27 23:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 19:47 Christian Aurich Zanettini Martins
2026-10-27 23:04 ` Keith Busch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=auEuEoILz3cndXOV@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=christian.aurichzm@gmail.com \
    --cc=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=sgogte@purestorage.com \
    --cc=wagi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®