scsi: always send valid PREEMPT TYPE field
The SPC-6 specification says that the PREEMPT service action ignores the TYPE field when there is no reservation. However, the LIO Linux iSCSI target rejects commands with a zero TYPE field. The field never ends up being used in this case, so replace it with a "valid" value to work around the issue. Reported-by: Qing Wang <qinwang@redhat.com> Buglink: https://redhat.atlassian.net/browse/RHEL-155807 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Link: https://lore.kernel.org/r/20260401171927.396672-3-stefanha@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Stefan Hajnoczi committed
Apr 1, 2026 at 13:19 UTC
15a202656cd553911272f9666aa067c706fc3dfe
2 files changed
+20
hw/scsi/scsi-generic.c
+10
@@ -453,6 +453,16 @@ static bool scsi_generic_pr_preempt(SCSIDevice *s, uint64_t key,
453
uint64_t key_be = cpu_to_be64(key);
454
int ret;
455
456
+ /*
457
+ * The LIO iSCSI target in Linux up to at least version 7.0 rejects PREEMPT
458
+ * commands with a zero TYPE field although the SPC-6 specification says
459
+ * the field should be ignored when there is no persistent reservation.
460
+ * Work around this by choosing an arbitrary valid PR type value.
461
+ */
462
+ if (resv_type == 0) {
463
+ resv_type = PR_TYPE_WRITE_EXCLUSIVE;
464
+ }
465
+
466
cmd[0] = PERSISTENT_RESERVE_OUT;
467
cmd[1] = PRO_PREEMPT;
468
cmd[2] = resv_type & 0xf;
include/scsi/constants.h
+10
@@ -340,4 +340,14 @@
340
#define PRO_REGISTER_AND_MOVE 0x07
341
#define PRO_REPLACE_LOST_RESERVATION 0x08
342
343
+/*
344
+ * Persistent reservation types
345
+ */
346
+#define PR_TYPE_WRITE_EXCLUSIVE 0x1
347
+#define PR_TYPE_EXCLUSIVE_ACCESS 0x3
348
+#define PR_TYPE_WRITE_EXCLUSIVE_REG_ONLY 0x5
349
+#define PR_TYPE_EXCLUSIVE_ACCESS_REG_ONLY 0x6
350
+#define PR_TYPE_WRITE_EXCLUSIVE_ALL_REGS 0x7
351
+#define PR_TYPE_EXCLUSIVE_ACCESS_ALL_REGS 0x8
352
+
353
#endif