Skip to content

Commit be50f53

Browse files
Mike ChristieNicholas Bellinger
authored andcommitted
target: remove g_device_list
g_device_list is no longer needed because we now use the idr code for lookups and seaches. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 6906d00 commit be50f53

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

drivers/target/target_core_device.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#include "target_core_pr.h"
5050
#include "target_core_ua.h"
5151

52-
DEFINE_MUTEX(g_device_mutex);
53-
LIST_HEAD(g_device_list);
52+
DEFINE_MUTEX(device_mutex);
53+
LIST_HEAD(device_list);
5454
static DEFINE_IDR(devices_idr);
5555

5656
static struct se_hba *lun0_hba;
@@ -773,7 +773,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
773773
INIT_LIST_HEAD(&dev->delayed_cmd_list);
774774
INIT_LIST_HEAD(&dev->state_list);
775775
INIT_LIST_HEAD(&dev->qf_cmd_list);
776-
INIT_LIST_HEAD(&dev->g_dev_node);
777776
spin_lock_init(&dev->execute_task_lock);
778777
spin_lock_init(&dev->delayed_cmd_lock);
779778
spin_lock_init(&dev->dev_reservation_lock);
@@ -895,11 +894,11 @@ struct se_device *target_find_device(int id, bool do_depend)
895894
{
896895
struct se_device *dev;
897896

898-
mutex_lock(&g_device_mutex);
897+
mutex_lock(&device_mutex);
899898
dev = idr_find(&devices_idr, id);
900899
if (dev && do_depend && target_depend_item(&dev->dev_group.cg_item))
901900
dev = NULL;
902-
mutex_unlock(&g_device_mutex);
901+
mutex_unlock(&device_mutex);
903902
return dev;
904903
}
905904
EXPORT_SYMBOL(target_find_device);
@@ -943,9 +942,9 @@ int target_for_each_device(int (*fn)(struct se_device *dev, void *data),
943942
iter.fn = fn;
944943
iter.data = data;
945944

946-
mutex_lock(&g_device_mutex);
945+
mutex_lock(&device_mutex);
947946
ret = idr_for_each(&devices_idr, target_devices_idr_iter, &iter);
948-
mutex_unlock(&g_device_mutex);
947+
mutex_unlock(&device_mutex);
949948
return ret;
950949
}
951950

@@ -964,13 +963,13 @@ int target_configure_device(struct se_device *dev)
964963
* Add early so modules like tcmu can use during its
965964
* configuration.
966965
*/
967-
mutex_lock(&g_device_mutex);
966+
mutex_lock(&device_mutex);
968967
/*
969968
* Use cyclic to try and avoid collisions with devices
970969
* that were recently removed.
971970
*/
972971
id = idr_alloc_cyclic(&devices_idr, dev, 0, INT_MAX, GFP_KERNEL);
973-
mutex_unlock(&g_device_mutex);
972+
mutex_unlock(&device_mutex);
974973
if (id < 0) {
975974
ret = -ENOMEM;
976975
goto out;
@@ -1036,20 +1035,16 @@ int target_configure_device(struct se_device *dev)
10361035
hba->dev_count++;
10371036
spin_unlock(&hba->device_lock);
10381037

1039-
mutex_lock(&g_device_mutex);
1040-
list_add_tail(&dev->g_dev_node, &g_device_list);
1041-
mutex_unlock(&g_device_mutex);
1042-
10431038
dev->dev_flags |= DF_CONFIGURED;
10441039

10451040
return 0;
10461041

10471042
out_free_alua:
10481043
core_alua_free_lu_gp_mem(dev);
10491044
out_free_index:
1050-
mutex_lock(&g_device_mutex);
1045+
mutex_lock(&device_mutex);
10511046
idr_remove(&devices_idr, dev->dev_index);
1052-
mutex_unlock(&g_device_mutex);
1047+
mutex_unlock(&device_mutex);
10531048
out:
10541049
se_release_vpd_for_dev(dev);
10551050
return ret;
@@ -1066,10 +1061,9 @@ void target_free_device(struct se_device *dev)
10661061

10671062
dev->transport->destroy_device(dev);
10681063

1069-
mutex_lock(&g_device_mutex);
1064+
mutex_lock(&device_mutex);
10701065
idr_remove(&devices_idr, dev->dev_index);
1071-
list_del(&dev->g_dev_node);
1072-
mutex_unlock(&g_device_mutex);
1066+
mutex_unlock(&device_mutex);
10731067

10741068
spin_lock(&hba->device_lock);
10751069
hba->dev_count--;

drivers/target/target_core_internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ struct target_fabric_configfs {
5656
extern struct t10_alua_lu_gp *default_lu_gp;
5757

5858
/* target_core_device.c */
59-
extern struct mutex g_device_mutex;
60-
extern struct list_head g_device_list;
61-
6259
int core_alloc_rtpi(struct se_lun *lun, struct se_device *dev);
6360
struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
6461
void target_pr_kref_release(struct kref *);

include/target/target_core_base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ struct se_device {
796796
struct list_head delayed_cmd_list;
797797
struct list_head state_list;
798798
struct list_head qf_cmd_list;
799-
struct list_head g_dev_node;
800799
/* Pointer to associated SE HBA */
801800
struct se_hba *se_hba;
802801
/* T10 Inquiry and VPD WWN Information */

0 commit comments

Comments
 (0)