* [PATCH v2 0/4] target: fix bugs in Persistent Reservations
@ 2022-09-09 9:04 Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 1/4] target: core: fix preempt and abort for allreg res Dmitry Bogdanov
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09 9:04 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux, Dmitry Bogdanov
This patch set fixes few rare bugs and deviations from standard in
PREEMPT AND ABORT and REGISTER AND MOVE operations.
v2:
remove superfluous parentheses
fix indentation
Dmitry Bogdanov (4):
target: core: fix preempt and abort for allreg res
target: core: fix memory leak in preempt_and_abort
target: core: abort all preempted regs if requested
target: core: new key must be used for moved PR
drivers/target/target_core_pr.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] target: core: fix preempt and abort for allreg res
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
@ 2022-09-09 9:04 ` Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 2/4] target: core: fix memory leak in preempt_and_abort Dmitry Bogdanov
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09 9:04 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux, Dmitry Bogdanov
Match a key only if SARK is not zero according to SPC-4 and the comment
above the code:
If an all registrants persistent reservation is present and the SERVICE
ACTION RESERVATION KEY field is set to zero, then all registrations
shall be removed except for that of the I_T nexus that is being used
for the PERSISTENT RESERVE OUT command;
Without this patch in case of SARK==0 no registrants will be removed.
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
v2:
remove superfluous parentheses
---
drivers/target/target_core_pr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index a1d67554709f..1521a97ddac2 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -3022,7 +3022,7 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
if (calling_it_nexus)
continue;
- if (pr_reg->pr_res_key != sa_res_key)
+ if (sa_res_key && pr_reg->pr_res_key != sa_res_key)
continue;
pr_reg_nacl = pr_reg->pr_reg_nacl;
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] target: core: fix memory leak in preempt_and_abort
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 1/4] target: core: fix preempt and abort for allreg res Dmitry Bogdanov
@ 2022-09-09 9:04 ` Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 3/4] target: core: abort all preempted regs if requested Dmitry Bogdanov
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09 9:04 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux, Dmitry Bogdanov
Always release preempt_and_abort_list to avoid memory leak of
t10_pr_registration objects in it.
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_pr.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 1521a97ddac2..e3869576f254 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -2956,13 +2956,14 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
__core_scsi3_complete_pro_preempt(dev, pr_reg_n,
(preempt_type == PREEMPT_AND_ABORT) ? &preempt_and_abort_list : NULL,
type, scope, preempt_type);
-
- if (preempt_type == PREEMPT_AND_ABORT)
- core_scsi3_release_preempt_and_abort(
- &preempt_and_abort_list, pr_reg_n);
}
+
spin_unlock(&dev->dev_reservation_lock);
+ if (preempt_type == PREEMPT_AND_ABORT)
+ core_scsi3_release_preempt_and_abort(
+ &preempt_and_abort_list, pr_reg_n);
+
if (pr_tmpl->pr_aptpl_active)
core_scsi3_update_and_write_aptpl(cmd->se_dev, true);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] target: core: abort all preempted regs if requested
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 1/4] target: core: fix preempt and abort for allreg res Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 2/4] target: core: fix memory leak in preempt_and_abort Dmitry Bogdanov
@ 2022-09-09 9:04 ` Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 4/4] target: core: new key must be used for moved PR Dmitry Bogdanov
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09 9:04 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux, Dmitry Bogdanov
According to SPC the preempted commands shall be always aborted.
SPC-4: 5.12.11.2.6 Preempting and aborting
c) all commands from the I_T nexus(es) associated with the persistent
reservations or registrations being preempted (i.e., preempted commands)
except the PERSISTENT RESERVE OUT command itself shall be aborted as
defined in SAM-5;
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_pr.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index e3869576f254..6a5f9504a481 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -2960,9 +2960,23 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
spin_unlock(&dev->dev_reservation_lock);
- if (preempt_type == PREEMPT_AND_ABORT)
+ /*
+ * SPC-4 5.12.11.2.6 Preempting and aborting
+ * The actions described in this subclause shall be performed
+ * for all I_T nexuses that are registered with the non-zero
+ * SERVICE ACTION RESERVATION KEY value, without regard for
+ * whether the preempted I_T nexuses hold the persistent
+ * reservation. If the SERVICE ACTION RESERVATION KEY field is
+ * set to zero and an all registrants persistent reservation is
+ * present, the device server shall abort all commands for all
+ * registered I_T nexuses.
+ */
+ if (preempt_type == PREEMPT_AND_ABORT) {
+ core_tmr_lun_reset(dev, NULL, &preempt_and_abort_list,
+ cmd);
core_scsi3_release_preempt_and_abort(
&preempt_and_abort_list, pr_reg_n);
+ }
if (pr_tmpl->pr_aptpl_active)
core_scsi3_update_and_write_aptpl(cmd->se_dev, true);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] target: core: new key must be used for moved PR
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
` (2 preceding siblings ...)
2022-09-09 9:04 ` [PATCH v2 3/4] target: core: abort all preempted regs if requested Dmitry Bogdanov
@ 2022-09-09 9:04 ` Dmitry Bogdanov
2022-09-29 21:44 ` [PATCH v2 0/4] target: fix bugs in Persistent Reservations Mike Christie
2022-10-01 9:04 ` Martin K. Petersen
5 siblings, 0 replies; 7+ messages in thread
From: Dmitry Bogdanov @ 2022-09-09 9:04 UTC (permalink / raw)
To: Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux, Dmitry Bogdanov
According to SPC4 5.12.8:
e) Retain the reservation key specified in the SERVICE ACTION
RESERVATION KEY field and associated information;
But currently sa_res_key is only used for the not existing I_T nexus.
The patch adds a changing of the key for the existing I_T nexus the PR
moved to.
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
v2:
fix indentation
---
drivers/target/target_core_pr.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 6a5f9504a481..1493b1d01194 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -3440,8 +3440,6 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
* transport protocols where port names are not required;
* d) Register the reservation key specified in the SERVICE ACTION
* RESERVATION KEY field;
- * e) Retain the reservation key specified in the SERVICE ACTION
- * RESERVATION KEY field and associated information;
*
* Also, It is not an error for a REGISTER AND MOVE service action to
* register an I_T nexus that is already registered with the same
@@ -3463,6 +3461,12 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
iport_ptr);
new_reg = 1;
+ } else {
+ /*
+ * e) Retain the reservation key specified in the SERVICE ACTION
+ * RESERVATION KEY field and associated information;
+ */
+ dest_pr_reg->pr_res_key = sa_res_key;
}
/*
* f) Release the persistent reservation for the persistent reservation
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] target: fix bugs in Persistent Reservations
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
` (3 preceding siblings ...)
2022-09-09 9:04 ` [PATCH v2 4/4] target: core: new key must be used for moved PR Dmitry Bogdanov
@ 2022-09-29 21:44 ` Mike Christie
2022-10-01 9:04 ` Martin K. Petersen
5 siblings, 0 replies; 7+ messages in thread
From: Mike Christie @ 2022-09-29 21:44 UTC (permalink / raw)
To: Dmitry Bogdanov, Martin Petersen, target-devel
Cc: Bart Van Assche, linux-scsi, linux
On 9/9/22 4:04 AM, Dmitry Bogdanov wrote:
> This patch set fixes few rare bugs and deviations from standard in
> PREEMPT AND ABORT and REGISTER AND MOVE operations.
>
> v2:
> remove superfluous parentheses
> fix indentation
>
> Dmitry Bogdanov (4):
> target: core: fix preempt and abort for allreg res
> target: core: fix memory leak in preempt_and_abort
> target: core: abort all preempted regs if requested
> target: core: new key must be used for moved PR
Reviewed-by: Mike Christie <michael.christie@oracle.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] target: fix bugs in Persistent Reservations
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
` (4 preceding siblings ...)
2022-09-29 21:44 ` [PATCH v2 0/4] target: fix bugs in Persistent Reservations Mike Christie
@ 2022-10-01 9:04 ` Martin K. Petersen
5 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2022-10-01 9:04 UTC (permalink / raw)
To: Dmitry Bogdanov
Cc: Martin Petersen, target-devel, Bart Van Assche, linux-scsi, linux
Dmitry,
> This patch set fixes few rare bugs and deviations from standard in
> PREEMPT AND ABORT and REGISTER AND MOVE operations.
Applied to 6.1/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-01 9:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 9:04 [PATCH v2 0/4] target: fix bugs in Persistent Reservations Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 1/4] target: core: fix preempt and abort for allreg res Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 2/4] target: core: fix memory leak in preempt_and_abort Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 3/4] target: core: abort all preempted regs if requested Dmitry Bogdanov
2022-09-09 9:04 ` [PATCH v2 4/4] target: core: new key must be used for moved PR Dmitry Bogdanov
2022-09-29 21:44 ` [PATCH v2 0/4] target: fix bugs in Persistent Reservations Mike Christie
2022-10-01 9:04 ` Martin K. Petersen
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.