* [PATCH] scsi: target: core: Parse APTPL res_type and res_scope as hex
@ 2026-11-01 1:21 Ciro Iriarte
0 siblings, 0 replies; only message in thread
From: Ciro Iriarte @ 2026-11-01 1:21 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: target-devel, linux-scsi, linux-kernel, stable
core_scsi3_update_aptpl_buf() saves the reservation holder's type and
scope to the APTPL metadata file as zero-padded hex ("res_type=%02x",
"res_scope=%02x"), but target_pr_res_aptpl_metadata_store() reads them
back with "%d" tokens and match_int(), which parse with base 0. A
leading zero selects octal, so match_token() parses only the "0" of
"res_type=08", the trailing "8" makes the token not match, and the field
is ignored as unknown. An Exclusive Access - All Registrants holder
(type 0x8) is left with type 0 and the write fails with -EINVAL and
Illegal PR type: 0x00 for reservation holder
Userspace that restores APTPL state by writing the saved records back
to pr/res_aptpl_metadata (rtslib-fb does this when it recreates a
storage object) therefore loses every type 8 reservation across a
target restart, and with rtslib the storage object creation fails. The
other valid types (1, 3, 5, 6, 7) and scope 0 only work because their
octal and decimal values coincide.
Keep the on-disk format and parse both fields as hex. The valid type
and scope values have the same hex and decimal representation, so
records written in decimal by hand keep working.
Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Cc: stable@vger.kernel.org
Signed-off-by: Ciro Iriarte <ciro.iriarte+software@gmail.com>
---
drivers/target/target_core_configfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 2b19a9560..a45bb3d56 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2126,8 +2126,8 @@ static match_table_t tokens = {
{Opt_initiator_sid, "initiator_sid=%s"},
{Opt_sa_res_key, "sa_res_key=%s"},
{Opt_res_holder, "res_holder=%d"},
- {Opt_res_type, "res_type=%d"},
- {Opt_res_scope, "res_scope=%d"},
+ {Opt_res_type, "res_type=%x"},
+ {Opt_res_scope, "res_scope=%x"},
{Opt_res_all_tg_pt, "res_all_tg_pt=%d"},
{Opt_mapped_lun, "mapped_lun=%u"},
{Opt_target_fabric, "target_fabric=%s"},
@@ -2229,13 +2229,13 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
res_holder = arg;
break;
case Opt_res_type:
- ret = match_int(args, &arg);
+ ret = match_hex(args, &arg);
if (ret)
goto out;
type = (u8)arg;
break;
case Opt_res_scope:
- ret = match_int(args, &arg);
+ ret = match_hex(args, &arg);
if (ret)
goto out;
break;
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-01 1:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01 1:21 [PATCH] scsi: target: core: Parse APTPL res_type and res_scope as hex Ciro Iriarte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®