diff options
author | Roland Dreier <roland@purestorage.com> | 2011-07-20 05:09:10 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-07-22 05:37:45 -0400 |
commit | 78faae37897dc2a9ccc7c19155294a4bfdcae077 (patch) | |
tree | 36db87c44506bd34da1d21633dbfe1e59de40910 | |
parent | 07bde79a5c355dbca66ca4318645aa17b4c0d859 (diff) |
target: Make transport_lookup_cmd_lun() locking IRQ-safe
transport_lookup_cmd_lun() may be called from interrupt context (eg
tcm_loop_allocate_core_cmd() calls it, and it has a comment that says,
"Can be called from interrupt context"), so it needs to use
spin_lock_irqsave() instead of spin_lock_irq() to avoid enabling
interrupts at the wrong time.
(And indeed the last set of lock operations, on lun_cmd_lock, were
already using spin_lock_irqsave(), so we just need to fix the other
two locks we take)
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_device.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index c674a5d74218..e25df3b813e5 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -72,7 +72,7 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
72 | return -ENODEV; | 72 | return -ENODEV; |
73 | } | 73 | } |
74 | 74 | ||
75 | spin_lock_irq(&se_sess->se_node_acl->device_list_lock); | 75 | spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags); |
76 | se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun]; | 76 | se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun]; |
77 | if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { | 77 | if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { |
78 | struct se_dev_entry *deve = se_cmd->se_deve; | 78 | struct se_dev_entry *deve = se_cmd->se_deve; |
@@ -88,7 +88,7 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
88 | " Access for 0x%08x\n", | 88 | " Access for 0x%08x\n", |
89 | se_cmd->se_tfo->get_fabric_name(), | 89 | se_cmd->se_tfo->get_fabric_name(), |
90 | unpacked_lun); | 90 | unpacked_lun); |
91 | spin_unlock_irq(&se_sess->se_node_acl->device_list_lock); | 91 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); |
92 | return -EACCES; | 92 | return -EACCES; |
93 | } | 93 | } |
94 | 94 | ||
@@ -106,7 +106,7 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
106 | se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev; | 106 | se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev; |
107 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; | 107 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; |
108 | } | 108 | } |
109 | spin_unlock_irq(&se_sess->se_node_acl->device_list_lock); | 109 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); |
110 | 110 | ||
111 | if (!se_lun) { | 111 | if (!se_lun) { |
112 | /* | 112 | /* |
@@ -154,13 +154,13 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
154 | 154 | ||
155 | /* TODO: get rid of this and use atomics for stats */ | 155 | /* TODO: get rid of this and use atomics for stats */ |
156 | dev = se_lun->lun_se_dev; | 156 | dev = se_lun->lun_se_dev; |
157 | spin_lock_irq(&dev->stats_lock); | 157 | spin_lock_irqsave(&dev->stats_lock, flags); |
158 | dev->num_cmds++; | 158 | dev->num_cmds++; |
159 | if (se_cmd->data_direction == DMA_TO_DEVICE) | 159 | if (se_cmd->data_direction == DMA_TO_DEVICE) |
160 | dev->write_bytes += se_cmd->data_length; | 160 | dev->write_bytes += se_cmd->data_length; |
161 | else if (se_cmd->data_direction == DMA_FROM_DEVICE) | 161 | else if (se_cmd->data_direction == DMA_FROM_DEVICE) |
162 | dev->read_bytes += se_cmd->data_length; | 162 | dev->read_bytes += se_cmd->data_length; |
163 | spin_unlock_irq(&dev->stats_lock); | 163 | spin_unlock_irqrestore(&dev->stats_lock, flags); |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * Add the iscsi_cmd_t to the struct se_lun's cmd list. This list is used | 166 | * Add the iscsi_cmd_t to the struct se_lun's cmd list. This list is used |