Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: don't abort the preempting host itself
Date: Fri, 20 Nov 2026 16:32:35 +0800	[thread overview]
Message-ID: <f7a83440-6fdc-4b8d-aa63-3677ce4e21f7@linux.alibaba.com> (raw)
In-Reply-To: <sashiko-outbox-224708@kernel.org>



在 2026/11/20 16:18, sashiko-bot@kernel.org 写道:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] nvmet: nvmet_pr_unreg_all_host_by_prkey() skips abort on
>   false pc_ref premise
> --
>
> commit 07f50eedfd5f5e5d148cd9fefe65d629fc37077e
> Author: Guixin Liu <kanie@linux.alibaba.com>
>
> nvmet: don't abort the preempting host itself
>
> This commit skips calling nvmet_pr_set_ctrl_to_abort() for the issuing
> host in nvmet_pr_unreg_all_host_by_prkey() when handling a Reservation
> Acquire command with the Preempt and Abort action.
>
>> diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
>> index 8c818f24815bd..ed530d7362f5b 100644
>> --- a/drivers/nvme/target/pr.c
>> +++ b/drivers/nvme/target/pr.c
>> @@ -502,7 +502,14 @@ static u16 nvmet_pr_unreg_all_host_by_prkey(struct nvmet_req *req, u64 prkey,
>>  		if (reg->rkey == prkey) {
>>  			status = NVME_SC_SUCCESS;
>>  			uuid_copy(&hostid, &reg->hostid);
>> -			if (abort)
>> +			/*
>> +			 * Aborting is best effort (NVMe Base Specification
>> +			 * section 8.1.25.7): skip the issuing host, as the
>> +			 * abort flow would otherwise wait for the preempt
>> +			 * command itself, which holds a reference on its
>> +			 * controller's per-controller ref until it completes.
>> +			 */
>> +			if (abort && !uuid_equal(&hostid, send_hostid))
>>  				nvmet_pr_set_ctrl_to_abort(req, &hostid);
>>  			nvmet_pr_unregister_one(pr, reg);
>>  			if (!uuid_equal(&hostid, send_hostid))
> [Severity: Medium]
> Does a Reservation Acquire command actually hold a reference on pc_ref?
>
> In nvmet_parse_io_cmd(), nvmet_parse_pr_cmd() returns 0 for reservation
> opcodes and returns early before reaching nvmet_pr_get_ns_pc_ref():
>
> drivers/nvme/target/core.c:nvmet_parse_io_cmd() {
> 	...
> 	if (req->ns->pr.enable) {
> 		ret = nvmet_parse_pr_cmd(req);
> 		if (!ret)
> 			return ret;
> 	}
> 	...
> 	if (req->ns->pr.enable) {
> 		ret = nvmet_pr_check_cmd_access(req);
> 		if (ret)
> 			return ret;
>
> 		ret = nvmet_pr_get_ns_pc_ref(req);
> 	}
> 	...
> }
>
> Because that is the only caller of nvmet_pr_get_ns_pc_ref(), the preempt
> command itself never holds a reference on pc_ref->ref and cannot cause the
> self-deadlock described here.  Skipping nvmet_pr_set_ctrl_to_abort() for
> send_hostid instead stops nvmet from waiting for in-flight I/O commands on
> the newly unregistered issuing host's controllers to drain before
> completing the Preempt and Abort command.
Sashiko is right, Please ignore this patch.
>



  reply	other threads:[~2026-11-20  8:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  8:06 [PATCH] nvmet: don't abort the preempting host itself Guixin Liu
2026-11-20  8:18 ` sashiko-bot
2026-11-20  8:32   ` Guixin Liu [this message]
2026-11-20 17:24 ` Christoph Hellwig

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=f7a83440-6fdc-4b8d-aa63-3677ce4e21f7@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=linux-nvme@lists.infradead.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox