Skip to contentSkip to conversation

target: fix __transport_register_session locking

PATCH Applied Mike Christie 3 participants 3 messages Jul 15, 2018 – Jul 19, 2018 SCSI target

lore
Share & tools
lore
#0 lore raw

PATCH 3/15 target: fix __transport_register_session locking

When __transport_register_session is called from transport_register_session irqs will already have been disabled, so we do not want the unlock irq call to enable them until the higher level has done the final spin_unlock_irqrestore/spin_unlock_irq.

This has __transport_register_session use the save/restore call.

---
 drivers/target/target_core_transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/target/target_core_transport.c +3 -2
index 6324743..75ddbbb 100644
@@ -347,6 +347,7 @@ void __transport_register_session(
 {
 	const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo;
 	unsigned char buf[PR_REG_ISID_LEN];
+	unsigned long flags;
 
 	se_sess->se_tpg = se_tpg;
 	se_sess->fabric_sess_ptr = fabric_sess_ptr;
@@ -384,7 +385,7 @@ void __transport_register_session(
 			WARN_ON(hex2bin((u8 *)&se_sess->sess_bin_isid, buf, 6));
 		}
 
-		spin_lock_irq(&se_nacl->nacl_sess_lock);
+		spin_lock_irqsave(&se_nacl->nacl_sess_lock, flags);
 		/*
 		 * The se_nacl->nacl_sess pointer will be set to the
 		 * last active I_T Nexus for each struct se_node_acl.
@@ -393,7 +394,7 @@ void __transport_register_session(
 
 		list_add_tail(&se_sess->sess_acl_list,
 			      &se_nacl->acl_sess_list);
-		spin_unlock_irq(&se_nacl->nacl_sess_lock);
+		spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags);
 	}
 	list_add_tail(&se_sess->sess_list, &se_tpg->tpg_sess_list);
 
Signature · 1 line
2.7.2
Reviewed-by Bart Van Assche +ADw-bart.vanassche+AEA-wdc.com+AD4- on v1 3/15
#1 lore raw

On Sun, 2018-07-15 at 18:16 -0500, Mike Christie wrote:
+AD4- When +AF8AXw-transport+AF8-register+AF8-session is called from +AD4- transport+AF8-register+AF8-session irqs will already have been disabled, +AD4- so we do not want the unlock irq call to enable them until +AD4- the higher level has done the final
+AD4- spin+AF8-unlock+AF8-irqrestore/spin+AF8-unlock+AF8-irq. +AD4-
+AD4- This has +AF8AXw-transport+AF8-register+AF8-session use the save/restore +AD4- call.

Reviewed-by Bart Van Assche +ADw-bart.vanassche+AEA-wdc.com+AD4-
Reviewed-by on v1 3/15
#2 lore raw
In reply to Mike Christie
Quoted 5 lines · Mike Christie

When __transport_register_session is called from transport_register_session irqs will already have been disabled, so we do not want the unlock irq call to enable them until the higher level has done the final spin_unlock_irqrestore/spin_unlock_irq.

if you use up your line length this could be:

so we do not want the unlock irq call to enable them until the higher level has done the final spin_unlock_irqrestore/spin_unlock_irq.

Quoted 3 lines

This has __transport_register_session use the save/restore call.

Can be condensed as well.

Otherwise looks good: