[stgt] [PATCH V2 2/8] For each lld save the list of targets using it

Roi Dayan roid at mellanox.com
Wed Jul 18 11:36:09 CEST 2012


Signed-off-by: Roi Dayan <roid at mellanox.com>
---
 usr/driver.h |    2 ++
 usr/target.c |    4 ++++
 usr/target.h |    2 ++
 usr/tgtd.c   |    2 ++
 4 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/usr/driver.h b/usr/driver.h
index d643fac..5c0463a 100644
--- a/usr/driver.h
+++ b/usr/driver.h
@@ -37,6 +37,8 @@ struct tgt_driver {
 	int (*transportid)(int, uint64_t, char *, int);
 
 	const char *default_bst;
+
+	struct list_head target_list;
 };
 
 extern struct tgt_driver *tgt_drivers[];
diff --git a/usr/target.c b/usr/target.c
index a4e7b77..a54106e 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -2124,6 +2124,8 @@ tgtadm_err tgt_target_create(int lld, int tid, char *args)
 	if (tgt_drivers[lld]->target_create)
 		tgt_drivers[lld]->target_create(target);
 
+	list_add_tail(&target->lld_siblings, &tgt_drivers[lld]->target_list);
+
 	dprintf("Succeed to create a new target %d\n", tid);
 
 	return TGTADM_SUCCESS;
@@ -2172,6 +2174,8 @@ tgtadm_err tgt_target_destroy(int lld_no, int tid, int force)
 		free(iqn_acl);
 	}
 
+	list_del(&target->lld_siblings);
+
 	free(target->account.in_aids);
 	free(target->name);
 	free(target);
diff --git a/usr/target.h b/usr/target.h
index da4f675..1750d4c 100644
--- a/usr/target.h
+++ b/usr/target.h
@@ -41,6 +41,8 @@ struct target {
 	struct list_head iqn_acl_list;
 
 	struct tgt_account account;
+
+	struct list_head lld_siblings;
 };
 
 struct it_nexus {
diff --git a/usr/tgtd.c b/usr/tgtd.c
index f152715..67cd2e9 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -427,6 +427,8 @@ static int lld_init(char *args)
 				tgt_drivers[i]->drv_state = DRIVER_ERR;
 				continue;
 			}
+
+			INIT_LIST_HEAD(&tgt_drivers[i]->target_list);
 			tgt_drivers[i]->drv_state = DRIVER_INIT;
 		}
 		nr++;
-- 
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list