aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/target/target_core_device.c13
-rw-r--r--include/target/target_core_base.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index f3dc1f5fc41c..b2b081236abb 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -47,6 +47,9 @@
47#include "target_core_pr.h" 47#include "target_core_pr.h"
48#include "target_core_ua.h" 48#include "target_core_ua.h"
49 49
50DEFINE_MUTEX(g_device_mutex);
51LIST_HEAD(g_device_list);
52
50static struct se_hba *lun0_hba; 53static struct se_hba *lun0_hba;
51/* not static, needed by tpg.c */ 54/* not static, needed by tpg.c */
52struct se_device *g_lun0_dev; 55struct se_device *g_lun0_dev;
@@ -1406,6 +1409,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
1406 INIT_LIST_HEAD(&dev->delayed_cmd_list); 1409 INIT_LIST_HEAD(&dev->delayed_cmd_list);
1407 INIT_LIST_HEAD(&dev->state_list); 1410 INIT_LIST_HEAD(&dev->state_list);
1408 INIT_LIST_HEAD(&dev->qf_cmd_list); 1411 INIT_LIST_HEAD(&dev->qf_cmd_list);
1412 INIT_LIST_HEAD(&dev->g_dev_node);
1409 spin_lock_init(&dev->stats_lock); 1413 spin_lock_init(&dev->stats_lock);
1410 spin_lock_init(&dev->execute_task_lock); 1414 spin_lock_init(&dev->execute_task_lock);
1411 spin_lock_init(&dev->delayed_cmd_lock); 1415 spin_lock_init(&dev->delayed_cmd_lock);
@@ -1525,6 +1529,11 @@ int target_configure_device(struct se_device *dev)
1525 spin_lock(&hba->device_lock); 1529 spin_lock(&hba->device_lock);
1526 hba->dev_count++; 1530 hba->dev_count++;
1527 spin_unlock(&hba->device_lock); 1531 spin_unlock(&hba->device_lock);
1532
1533 mutex_lock(&g_device_mutex);
1534 list_add_tail(&dev->g_dev_node, &g_device_list);
1535 mutex_unlock(&g_device_mutex);
1536
1528 return 0; 1537 return 0;
1529 1538
1530out_free_alua: 1539out_free_alua:
@@ -1543,6 +1552,10 @@ void target_free_device(struct se_device *dev)
1543 if (dev->dev_flags & DF_CONFIGURED) { 1552 if (dev->dev_flags & DF_CONFIGURED) {
1544 destroy_workqueue(dev->tmr_wq); 1553 destroy_workqueue(dev->tmr_wq);
1545 1554
1555 mutex_lock(&g_device_mutex);
1556 list_del(&dev->g_dev_node);
1557 mutex_unlock(&g_device_mutex);
1558
1546 spin_lock(&hba->device_lock); 1559 spin_lock(&hba->device_lock);
1547 hba->dev_count--; 1560 hba->dev_count--;
1548 spin_unlock(&hba->device_lock); 1561 spin_unlock(&hba->device_lock);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index b5d0c2496c7e..732ce804020c 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -686,6 +686,7 @@ struct se_device {
686 struct list_head delayed_cmd_list; 686 struct list_head delayed_cmd_list;
687 struct list_head state_list; 687 struct list_head state_list;
688 struct list_head qf_cmd_list; 688 struct list_head qf_cmd_list;
689 struct list_head g_dev_node;
689 /* Pointer to associated SE HBA */ 690 /* Pointer to associated SE HBA */
690 struct se_hba *se_hba; 691 struct se_hba *se_hba;
691 /* T10 Inquiry and VPD WWN Information */ 692 /* T10 Inquiry and VPD WWN Information */