From: sashiko-bot@kernel.org
To: "Bin Luo" <luob87709@gmail.com>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet-fc: hold queue reference while freeing FCP IOD
Date: Wed, 25 Nov 2026 12:15:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-233339@kernel.org> (raw)
In-Reply-To: <20261125115444.783-1-luob87709@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvmet-fc: redundant back-to-back kref_get() and put in
nvmet_fc_free_fcp_iod()
--
commit 6c7c03981acb44ae799c2343512f506b50503766
Author: Bin Luo <luob87709@gmail.com>
nvmet-fc: hold queue reference while freeing FCP IOD
This commit holds a reference on the target queue in
nvmet_fc_free_fcp_iod() until after queue list operations and deferred
work submission complete.
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index 5d6c1c79508af..0b3a44886c3df 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
> @@ -733,6 +733,9 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue,
>
> tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq);
>
> + /* Hold queue across the FOD reference put and queue/list accesses. */
> + kref_get(&queue->ref);
> +
> /* release the queue lookup reference on the completed IO */
> nvmet_fc_tgt_q_put(queue);
>
> @@ -742,6 +745,7 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue,
> if (!deferfcp) {
> list_add_tail(&fod->fcp_list, &fod->queue->fod_list);
> spin_unlock_irqrestore(&queue->qlock, flags);
> + nvmet_fc_tgt_q_put(queue);
> return;
> }
>
> @@ -774,6 +778,7 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue,
> */
>
> queue_work(queue->work_q, &fod->defer_work);
> + nvmet_fc_tgt_q_put(queue);
> }
[Severity: Low]
Can nvmet_fc_free_fcp_iod() drop the early nvmet_fc_tgt_q_put(queue)
instead of pairing it with a kref_get(&queue->ref) right above it?
Since nvmet_fc_tgt_q_put() calls kref_put(&queue->ref, ...), taking
queue->ref and immediately putting it performs two back-to-back atomic
operations on queue->ref that cancel each other out on every FCP I/O
completion. Removing the early nvmet_fc_tgt_q_put() and letting the two
new puts at the exit paths release the completing FOD's lookup reference
directly would avoid the extra atomic operations.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125115444.783-1-luob87709@gmail.com?part=1
next prev parent reply other threads:[~2026-11-25 12:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:54 [PATCH] nvmet-fc: hold queue reference while freeing FCP IOD Bin Luo
2026-11-25 12:15 ` sashiko-bot [this message]
2026-11-25 13:48 ` Greg KH
2026-11-25 13:50 ` Greg KH
2026-11-26 5:16 ` [PATCH v2] nvmet-fc: put queue ref after FCP IOD cleanup Bin Luo
2026-11-26 8:42 ` Christoph Hellwig
2026-11-30 15:56 ` Keith Busch
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=sashiko-outbox-233339@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=luob87709@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.