aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@daterainc.com>2013-08-22 14:33:37 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-09-10 19:48:40 -0400
commitd9ea32bff2c55d4cd4654f1e98d269a758f34534 (patch)
tree64d8c15126232442cd574312b567511f2bfac74a /drivers/target
parentc5ff8d6bc3ebc363d77d71791080fefb07ae9017 (diff)
target: Add global device list for EXTENDED_COPY
EXTENDED_COPY needs to be able to search a global list of devices based on NAA WWN device identifiers, so add a simple g_device_list protected by g_device_mutex. Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Cc: Martin Petersen <martin.petersen@oracle.com> Cc: Chris Mason <chris.mason@fusionio.com> Cc: Roland Dreier <roland@purestorage.com> Cc: Zach Brown <zab@redhat.com> Cc: James Bottomley <JBottomley@Parallels.com> Cc: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_device.c13
1 files changed, 13 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);