diff mbox series

[1/4] target: core: fix preempt and abort for allreg res

Message ID 20220907135851.3756-2-d.bogdanov@yadro.com
State Superseded
Headers show
Series target: fix bugs in Persistent Reservations | expand

Commit Message

Dmitry Bogdanov Sept. 7, 2022, 1:58 p.m. UTC
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>
---
 drivers/target/target_core_pr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bart Van Assche Sept. 7, 2022, 4:18 p.m. UTC | #1
On 9/7/22 06:58, Dmitry Bogdanov wrote:
> -		if (pr_reg->pr_res_key != sa_res_key)
> +		if ((sa_res_key) && (pr_reg->pr_res_key != sa_res_key))
>   			continue;

Please do not introduce superfluous parentheses. Four parentheses can be 
left out from the above code without affecting readability.

Thanks,

Bart.
Dmitry Bogdanov Sept. 8, 2022, 8:34 a.m. UTC | #2
On Wed, Sep 07, 2022 at 09:18:57AM -0700, Bart Van Assche wrote:
> 
> On 9/7/22 06:58, Dmitry Bogdanov wrote:
> > -             if (pr_reg->pr_res_key != sa_res_key)
> > +             if ((sa_res_key) && (pr_reg->pr_res_key != sa_res_key))
> >                       continue;
> 
> Please do not introduce superfluous parentheses. Four parentheses can be
> left out from the above code without affecting readability.
Ok, will remove.

BR,
 Dmitry
diff mbox series

Patch

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index a1d67554709f..738ee7137462 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;