All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	qemu-block@nongnu.org, Fam Zheng <fam@euphon.net>
Subject: Re: [PATCH 3/3] scsi: register again after PREEMPT without reservation
Date: Wed, 1 Apr 2026 14:30:57 -0400	[thread overview]
Message-ID: <20260401183057.GA400282@fedora> (raw)
In-Reply-To: <31ba8b4f-972c-4ec5-8366-8e668fef6a64@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2353 bytes --]

On Wed, Apr 01, 2026 at 07:34:40PM +0200, Paolo Bonzini wrote:
> On 4/1/26 19:19, Stefan Hajnoczi wrote:
> > The SCSI specification says PREEMPT without a reservation removes all
> > registrations with the given key. Try to register again after PREEMPT
> > since our key will have been removed.
> > 
> > In practice some SCSI targets keep the calling I_T nexus' registration
> > instead of removing it. Therefore we need to handle both the
> > spec-compliant and the non-compliant behavior.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >   hw/scsi/scsi-generic.c | 10 ++++++++++
> >   1 file changed, 10 insertions(+)
> > 
> > diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
> > index 349dea6bdd..5182f9236d 100644
> > --- a/hw/scsi/scsi-generic.c
> > +++ b/hw/scsi/scsi-generic.c
> > @@ -513,6 +513,16 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp)
> >           if (!scsi_generic_pr_preempt(s, key, resv_type, errp)) {
> >               return false;
> >           }
> > +
> > +        /*
> > +         * Some SCSI targets, like the Linux LIO target, remove our
> > +         * registration when preempting without a reservation (resv_type is 0).
> > +         * Try to register again but ignore the error since a RESERVATION
> > +         * CONFLICT is expected if our registration remained in place.
> > +         */
> > +        if (resv_type == 0) {
> > +            scsi_generic_pr_register(s, key, NULL);
> > +        }
> 
> Hi Stefan,
> 
> I'm replying here for both patch 2 and patch 3.
> 
> Can this happen after the previous patch?  (Also it's conflicting to say  in
> patch 2 that LIO rejects PREEMPT, but also in this one that LIO unregisters
> the key).

Yes. Both patches are needed.

The first patch gets LIO to process the PREEMPT. Before LIO would just
fail the command.

But once LIO processes the PREEMPT, we hit the next problem: PREEMPT
completes but our registration has been removed. So now we need to
register again after PREEMPT.

> And for patch 2, is a RELEASE needed after issuing PREEMPT with an
> artificial PR_TYPE_WRITE_EXCLUSIVE?

No, because PREEMPT will not acquire a reservation when there is no
reservation holder with the given key. PREEMPT will only remove
registrations in that case.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-04-01 19:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 17:19 [PATCH 0/3] scsi: PR live migration PREEMPT fixes Stefan Hajnoczi
2026-04-01 17:19 ` [PATCH 1/3] scsi: adjust error_prepend() formatting Stefan Hajnoczi
2026-04-01 17:19 ` [PATCH 2/3] scsi: always send valid PREEMPT TYPE field Stefan Hajnoczi
2026-04-01 17:19 ` [PATCH 3/3] scsi: register again after PREEMPT without reservation Stefan Hajnoczi
2026-04-01 17:34   ` Paolo Bonzini
2026-04-01 18:30     ` Stefan Hajnoczi [this message]
2026-04-02 10:39       ` Paolo Bonzini
2026-05-08 14:40 ` [PATCH 0/3] scsi: PR live migration PREEMPT fixes Paolo Bonzini

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=20260401183057.GA400282@fedora \
    --to=stefanha@redhat.com \
    --cc=fam@euphon.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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 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.