diff mbox

[RFC,9/9] target: remove g_device_list

Message ID 1497262209-5635-10-git-send-email-mchristi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Christie June 12, 2017, 10:10 a.m. UTC
g_device_list is no longer needed because we now use the idr code
for lookups and seaches.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 drivers/target/target_core_device.c   | 32 +++++++++++---------------------
 drivers/target/target_core_internal.h |  3 ---
 include/target/target_core_base.h     |  1 -
 3 files changed, 11 insertions(+), 25 deletions(-)
diff mbox

Patch

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index eea52732..97364fe 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -49,8 +49,7 @@ 
 #include "target_core_pr.h"
 #include "target_core_ua.h"
 
-DEFINE_MUTEX(g_device_mutex);
-LIST_HEAD(g_device_list);
+static DEFINE_MUTEX(device_mutex);
 static struct idr devices_idr;
 
 static struct se_hba *lun0_hba;
@@ -773,7 +772,6 @@  struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
 	INIT_LIST_HEAD(&dev->delayed_cmd_list);
 	INIT_LIST_HEAD(&dev->state_list);
 	INIT_LIST_HEAD(&dev->qf_cmd_list);
-	INIT_LIST_HEAD(&dev->g_dev_node);
 	spin_lock_init(&dev->execute_task_lock);
 	spin_lock_init(&dev->delayed_cmd_lock);
 	spin_lock_init(&dev->dev_reservation_lock);
@@ -884,9 +882,9 @@  struct se_device *target_find_device(int id)
 {
 	struct se_device *dev;
 
-	mutex_lock(&g_device_mutex);
+	mutex_lock(&device_mutex);
 	dev = idr_find(&devices_idr, id);
-	mutex_unlock(&g_device_mutex);
+	mutex_unlock(&device_mutex);
 	return dev;
 }
 EXPORT_SYMBOL(target_find_device);
@@ -895,9 +893,9 @@  int target_for_each_device(int (*fn)(int id, void *p, void *data), void *data)
 {
 	int ret;
 
-	mutex_lock(&g_device_mutex);
+	mutex_lock(&device_mutex);
 	ret = idr_for_each(&devices_idr, fn, data);
-	mutex_unlock(&g_device_mutex);
+	mutex_unlock(&device_mutex);
 	return ret;
 }
 
@@ -927,13 +925,13 @@  int target_configure_device(struct se_device *dev)
 	 * configuration.
 	 */
 	idr_preload(GFP_KERNEL);
-	mutex_lock(&g_device_mutex);
+	mutex_lock(&device_mutex);
 	/*
 	 * Use cyclic to try and avoid collisions with devices
 	 * that were recently removed.
 	 */
 	id = idr_alloc_cyclic(&devices_idr, dev, 0, INT_MAX, GFP_KERNEL);
-	mutex_unlock(&g_device_mutex);
+	mutex_unlock(&device_mutex);
 	idr_preload_end();
 	if (id < 0) {
 		ret = -ENOMEM;
@@ -1000,10 +998,6 @@  int target_configure_device(struct se_device *dev)
 	hba->dev_count++;
 	spin_unlock(&hba->device_lock);
 
-	mutex_lock(&g_device_mutex);
-	list_add_tail(&dev->g_dev_node, &g_device_list);
-	mutex_unlock(&g_device_mutex);
-
 	dev->dev_flags |= DF_CONFIGURED;
 
 	return 0;
@@ -1011,9 +1005,9 @@  int target_configure_device(struct se_device *dev)
 out_free_alua:
 	core_alua_free_lu_gp_mem(dev);
 out_free_index:
-	mutex_lock(&g_device_mutex);
+	mutex_lock(&device_mutex);
 	idr_remove(&devices_idr, dev->dev_index);
-	mutex_unlock(&g_device_mutex);
+	mutex_unlock(&device_mutex);
 out:
 	se_release_vpd_for_dev(dev);
 	return ret;
@@ -1030,10 +1024,6 @@  void target_free_device(struct se_device *dev)
 		dev_index = dev->dev_index;
 		destroy_workqueue(dev->tmr_wq);
 
-		mutex_lock(&g_device_mutex);
-		list_del(&dev->g_dev_node);
-		mutex_unlock(&g_device_mutex);
-
 		spin_lock(&hba->device_lock);
 		hba->dev_count--;
 		spin_unlock(&hba->device_lock);
@@ -1054,9 +1044,9 @@  void target_free_device(struct se_device *dev)
 	 * to use it.
 	 */
 	if (dev_index >= 0) {
-		mutex_lock(&g_device_mutex);
+		mutex_lock(&device_mutex);
 		idr_remove(&devices_idr, dev_index);
-		mutex_unlock(&g_device_mutex);
+		mutex_unlock(&device_mutex);
 	}
 }
 
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 605e25b..cc68aa8 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -56,9 +56,6 @@  struct target_fabric_configfs {
 extern struct t10_alua_lu_gp *default_lu_gp;
 
 /* target_core_device.c */
-extern struct mutex g_device_mutex;
-extern struct list_head g_device_list;
-
 int	core_alloc_rtpi(struct se_lun *lun, struct se_device *dev);
 struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
 void	target_pr_kref_release(struct kref *);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 51a92f1..516764f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -796,7 +796,6 @@  struct se_device {
 	struct list_head	delayed_cmd_list;
 	struct list_head	state_list;
 	struct list_head	qf_cmd_list;
-	struct list_head	g_dev_node;
 	/* Pointer to associated SE HBA */
 	struct se_hba		*se_hba;
 	/* T10 Inquiry and VPD WWN Information */