target: don't add lun0 to tpg_lun_hlist

From: Christoph Hellwig
Date: Thu May 21 2015 - 12:58:21 EST


We never want to find the virtual lun0 when looking up a lun on the TPG,
otherwise the core code gets really confused.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
drivers/target/target_core_tpg.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index b8c2a32..ced1dd6 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -647,7 +647,8 @@ int core_tpg_add_lun(

lun->lun_access = lun_access;
lun->lun_status = TRANSPORT_LUN_STATUS_ACTIVE;
- hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist);
+ if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
+ hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist);

mutex_unlock(&tpg->tpg_lun_mutex);

@@ -687,7 +688,8 @@ void core_tpg_remove_lun(
}

lun->lun_status = TRANSPORT_LUN_STATUS_FREE;
- hlist_del_rcu(&lun->link);
+ if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
+ hlist_del_rcu(&lun->link);
mutex_unlock(&tpg->tpg_lun_mutex);

percpu_ref_exit(&lun->lun_ref);
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/