scsi: register again after PREEMPT without reservation
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> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20260401171927.396672-4-stefanha@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Stefan Hajnoczi committed
Apr 1, 2026 at 13:19 UTC
b9a3b329d09dea5a4692de483419693ef0e23052
1 file changed
+10
hw/scsi/scsi-generic.c
+10
@@ -513,6 +513,16 @@ bool scsi_generic_pr_state_preempt(SCSIDevice *s, Error **errp)
513
if (!scsi_generic_pr_preempt(s, key, resv_type, errp)) {
514
return false;
515
}
516
+
517
+ /*
518
+ * Some SCSI targets, like the Linux LIO target, remove our
519
+ * registration when preempting without a reservation (resv_type is 0).
520
+ * Try to register again but ignore the error since a RESERVATION
521
+ * CONFLICT is expected if our registration remained in place.
522
+ */
523
+ if (resv_type == 0) {
524
+ scsi_generic_pr_register(s, key, NULL);
525
+ }
526
}
527
return true;
528
}