From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> This patch converts fabric independent configfs link/unlink to use RCU read path macros for se_node_acl->lun_entry_hlist[] access. Also, update show_write_protect attribute access as well. Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Sagi Grimberg <sagig@xxxxxxxxxxxx> Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/target_core_fabric_configfs.c | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index 0c3f901..86ad50d 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c @@ -111,8 +111,8 @@ static int target_fabric_mappedlun_link( * which be will write protected (READ-ONLY) when * tpg_1/attrib/demo_mode_write_protect=1 */ - spin_lock_irq(&lacl->se_lun_nacl->device_list_lock); - deve = lacl->se_lun_nacl->device_list[lacl->mapped_lun]; + rcu_read_lock(); + deve = rcu_dereference(lacl->se_lun_nacl->lun_entry_hlist[lacl->mapped_lun]); if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) lun_access = deve->lun_flags; else @@ -120,7 +120,7 @@ static int target_fabric_mappedlun_link( (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect( se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY : TRANSPORT_LUNFLAGS_READ_WRITE; - spin_unlock_irq(&lacl->se_lun_nacl->device_list_lock); + rcu_read_unlock(); /* * Determine the actual mapped LUN value user wants.. * @@ -141,14 +141,18 @@ static int target_fabric_mappedlun_unlink( struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), struct se_lun_acl, se_lun_group); struct se_node_acl *nacl = lacl->se_lun_nacl; - struct se_dev_entry *deve = nacl->device_list[lacl->mapped_lun]; + struct se_dev_entry *deve; struct se_portal_group *se_tpg; /* * Determine if the underlying MappedLUN has already been released.. */ - if (!deve->se_lun) + rcu_read_lock(); + deve = rcu_dereference(nacl->lun_entry_hlist[lacl->mapped_lun]); + if (!deve || !deve->se_lun) { + rcu_read_lock(); return 0; - + } + rcu_read_unlock(); lun = container_of(to_config_group(lun_ci), struct se_lun, lun_group); se_tpg = lun->lun_sep->sep_tpg; @@ -171,12 +175,13 @@ static ssize_t target_fabric_mappedlun_show_write_protect( struct se_dev_entry *deve; ssize_t len; - spin_lock_irq(&se_nacl->device_list_lock); - deve = se_nacl->device_list[lacl->mapped_lun]; - len = sprintf(page, "%d\n", - (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? - 1 : 0); - spin_unlock_irq(&se_nacl->device_list_lock); + rcu_read_lock(); + deve = rcu_dereference(se_nacl->lun_entry_hlist[lacl->mapped_lun]); + if (deve) { + len = sprintf(page, "%d\n", + (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? 1 : 0); + } + rcu_read_unlock(); return len; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html