aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_ua.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-07-04 17:13:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-04 17:13:43 -0400
commit5c755fe142b421d295e7dd64a9833c12abbfd28e (patch)
tree768b637e9f7b72def5780c99d2368bc462fdaff4 /drivers/target/target_core_ua.c
parent6d7c8e1b3a1fae91daaf1bec4df694239c7a430b (diff)
parent2ec1e9e20701f37a06562966dbd37e7dd072fcb8 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "It's been a busy development cycle for target-core in a number of different areas. The fabric API usage for se_node_acl allocation is now within target-core code, dropping the external API callers for all fabric drivers tree-wide. There is a new conversion to RCU hlists for se_node_acl and se_portal_group LUN mappings, that turns fast-past LUN lookup into a completely lockless code-path. It also removes the original hard-coded limitation of 256 LUNs per fabric endpoint. The configfs attributes for backends can now be shared between core and driver code, allowing existing drivers to use common code while still allowing flexibility for new backend provided attributes. The highlights include: - Merge sbc_verify_dif_* into common code (sagi) - Remove iscsi-target support for obsolete IFMarker/OFMarker (Christophe Vu-Brugier) - Add bidi support in target/user backend (ilias + vangelis + agover) - Move se_node_acl allocation into target-core code (hch) - Add crc_t10dif_update common helper (akinobu + mkp) - Handle target-core odd SGL mapping for data transfer memory (akinobu) - Move transport ID handling into target-core (hch) - Move task tag into struct se_cmd + support 64-bit tags (bart) - Convert se_node_acl->device_list[] to RCU hlist (nab + hch + paulmck) - Convert se_portal_group->tpg_lun_list[] to RCU hlist (nab + hch + paulmck) - Simplify target backend driver registration (hch) - Consolidate + simplify target backend attribute implementations (hch + nab) - Subsume se_port + t10_alua_tg_pt_gp_member into se_lun (hch) - Drop lun_sep_lock for se_lun->lun_se_dev RCU usage (hch + nab) - Drop unnecessary core_tpg_register TFO parameter (nab) - Use 64-bit LUNs tree-wide (hannes) - Drop left-over TARGET_MAX_LUNS_PER_TRANSPORT limit (hannes)" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (76 commits) target: Bump core version to v5.0 target: remove target_core_configfs.h target: remove unused TARGET_CORE_CONFIG_ROOT define target: consolidate version defines target: implement WRITE_SAME with UNMAP bit using ->execute_unmap target: simplify UNMAP handling target: replace se_cmd->execute_rw with a protocol_data field target/user: Fix inconsistent kmap_atomic/kunmap_atomic target: Send UA when changing LUN inventory target: Send UA upon LUN RESET tmr completion target: Send UA on ALUA target port group change target: Convert se_lun->lun_deve_lock to normal spinlock target: use 'se_dev_entry' when allocating UAs target: Remove 'ua_nacl' pointer from se_ua structure target_core_alua: Correct UA handling when switching states xen-scsiback: Fix compile warning for 64-bit LUN target: Remove TARGET_MAX_LUNS_PER_TRANSPORT target: use 64-bit LUNs target: Drop duplicate + unused se_dev_check_wce target: Drop unnecessary core_tpg_register TFO parameter ...
Diffstat (limited to 'drivers/target/target_core_ua.c')
-rw-r--r--drivers/target/target_core_ua.c81
1 files changed, 50 insertions, 31 deletions
diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c
index e44cc94b12cb..be25eb807a5f 100644
--- a/drivers/target/target_core_ua.c
+++ b/drivers/target/target_core_ua.c
@@ -29,7 +29,6 @@
29 29
30#include <target/target_core_base.h> 30#include <target/target_core_base.h>
31#include <target/target_core_fabric.h> 31#include <target/target_core_fabric.h>
32#include <target/target_core_configfs.h>
33 32
34#include "target_core_internal.h" 33#include "target_core_internal.h"
35#include "target_core_alua.h" 34#include "target_core_alua.h"
@@ -50,9 +49,17 @@ target_scsi3_ua_check(struct se_cmd *cmd)
50 if (!nacl) 49 if (!nacl)
51 return 0; 50 return 0;
52 51
53 deve = nacl->device_list[cmd->orig_fe_lun]; 52 rcu_read_lock();
54 if (!atomic_read(&deve->ua_count)) 53 deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
54 if (!deve) {
55 rcu_read_unlock();
55 return 0; 56 return 0;
57 }
58 if (!atomic_read(&deve->ua_count)) {
59 rcu_read_unlock();
60 return 0;
61 }
62 rcu_read_unlock();
56 /* 63 /*
57 * From sam4r14, section 5.14 Unit attention condition: 64 * From sam4r14, section 5.14 Unit attention condition:
58 * 65 *
@@ -79,18 +86,11 @@ target_scsi3_ua_check(struct se_cmd *cmd)
79} 86}
80 87
81int core_scsi3_ua_allocate( 88int core_scsi3_ua_allocate(
82 struct se_node_acl *nacl, 89 struct se_dev_entry *deve,
83 u32 unpacked_lun,
84 u8 asc, 90 u8 asc,
85 u8 ascq) 91 u8 ascq)
86{ 92{
87 struct se_dev_entry *deve;
88 struct se_ua *ua, *ua_p, *ua_tmp; 93 struct se_ua *ua, *ua_p, *ua_tmp;
89 /*
90 * PASSTHROUGH OPS
91 */
92 if (!nacl)
93 return -EINVAL;
94 94
95 ua = kmem_cache_zalloc(se_ua_cache, GFP_ATOMIC); 95 ua = kmem_cache_zalloc(se_ua_cache, GFP_ATOMIC);
96 if (!ua) { 96 if (!ua) {
@@ -99,13 +99,9 @@ int core_scsi3_ua_allocate(
99 } 99 }
100 INIT_LIST_HEAD(&ua->ua_nacl_list); 100 INIT_LIST_HEAD(&ua->ua_nacl_list);
101 101
102 ua->ua_nacl = nacl;
103 ua->ua_asc = asc; 102 ua->ua_asc = asc;
104 ua->ua_ascq = ascq; 103 ua->ua_ascq = ascq;
105 104
106 spin_lock_irq(&nacl->device_list_lock);
107 deve = nacl->device_list[unpacked_lun];
108
109 spin_lock(&deve->ua_lock); 105 spin_lock(&deve->ua_lock);
110 list_for_each_entry_safe(ua_p, ua_tmp, &deve->ua_list, ua_nacl_list) { 106 list_for_each_entry_safe(ua_p, ua_tmp, &deve->ua_list, ua_nacl_list) {
111 /* 107 /*
@@ -113,7 +109,6 @@ int core_scsi3_ua_allocate(
113 */ 109 */
114 if ((ua_p->ua_asc == asc) && (ua_p->ua_ascq == ascq)) { 110 if ((ua_p->ua_asc == asc) && (ua_p->ua_ascq == ascq)) {
115 spin_unlock(&deve->ua_lock); 111 spin_unlock(&deve->ua_lock);
116 spin_unlock_irq(&nacl->device_list_lock);
117 kmem_cache_free(se_ua_cache, ua); 112 kmem_cache_free(se_ua_cache, ua);
118 return 0; 113 return 0;
119 } 114 }
@@ -158,24 +153,40 @@ int core_scsi3_ua_allocate(
158 list_add_tail(&ua->ua_nacl_list, 153 list_add_tail(&ua->ua_nacl_list,
159 &deve->ua_list); 154 &deve->ua_list);
160 spin_unlock(&deve->ua_lock); 155 spin_unlock(&deve->ua_lock);
161 spin_unlock_irq(&nacl->device_list_lock);
162 156
163 atomic_inc_mb(&deve->ua_count); 157 atomic_inc_mb(&deve->ua_count);
164 return 0; 158 return 0;
165 } 159 }
166 list_add_tail(&ua->ua_nacl_list, &deve->ua_list); 160 list_add_tail(&ua->ua_nacl_list, &deve->ua_list);
167 spin_unlock(&deve->ua_lock); 161 spin_unlock(&deve->ua_lock);
168 spin_unlock_irq(&nacl->device_list_lock);
169 162
170 pr_debug("[%s]: Allocated UNIT ATTENTION, mapped LUN: %u, ASC:" 163 pr_debug("Allocated UNIT ATTENTION, mapped LUN: %llu, ASC:"
171 " 0x%02x, ASCQ: 0x%02x\n", 164 " 0x%02x, ASCQ: 0x%02x\n", deve->mapped_lun,
172 nacl->se_tpg->se_tpg_tfo->get_fabric_name(), unpacked_lun,
173 asc, ascq); 165 asc, ascq);
174 166
175 atomic_inc_mb(&deve->ua_count); 167 atomic_inc_mb(&deve->ua_count);
176 return 0; 168 return 0;
177} 169}
178 170
171void target_ua_allocate_lun(struct se_node_acl *nacl,
172 u32 unpacked_lun, u8 asc, u8 ascq)
173{
174 struct se_dev_entry *deve;
175
176 if (!nacl)
177 return;
178
179 rcu_read_lock();
180 deve = target_nacl_find_deve(nacl, unpacked_lun);
181 if (!deve) {
182 rcu_read_unlock();
183 return;
184 }
185
186 core_scsi3_ua_allocate(deve, asc, ascq);
187 rcu_read_unlock();
188}
189
179void core_scsi3_ua_release_all( 190void core_scsi3_ua_release_all(
180 struct se_dev_entry *deve) 191 struct se_dev_entry *deve)
181{ 192{
@@ -210,10 +221,14 @@ void core_scsi3_ua_for_check_condition(
210 if (!nacl) 221 if (!nacl)
211 return; 222 return;
212 223
213 spin_lock_irq(&nacl->device_list_lock); 224 rcu_read_lock();
214 deve = nacl->device_list[cmd->orig_fe_lun]; 225 deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
226 if (!deve) {
227 rcu_read_unlock();
228 return;
229 }
215 if (!atomic_read(&deve->ua_count)) { 230 if (!atomic_read(&deve->ua_count)) {
216 spin_unlock_irq(&nacl->device_list_lock); 231 rcu_read_unlock();
217 return; 232 return;
218 } 233 }
219 /* 234 /*
@@ -249,10 +264,10 @@ void core_scsi3_ua_for_check_condition(
249 atomic_dec_mb(&deve->ua_count); 264 atomic_dec_mb(&deve->ua_count);
250 } 265 }
251 spin_unlock(&deve->ua_lock); 266 spin_unlock(&deve->ua_lock);
252 spin_unlock_irq(&nacl->device_list_lock); 267 rcu_read_unlock();
253 268
254 pr_debug("[%s]: %s UNIT ATTENTION condition with" 269 pr_debug("[%s]: %s UNIT ATTENTION condition with"
255 " INTLCK_CTRL: %d, mapped LUN: %u, got CDB: 0x%02x" 270 " INTLCK_CTRL: %d, mapped LUN: %llu, got CDB: 0x%02x"
256 " reported ASC: 0x%02x, ASCQ: 0x%02x\n", 271 " reported ASC: 0x%02x, ASCQ: 0x%02x\n",
257 nacl->se_tpg->se_tpg_tfo->get_fabric_name(), 272 nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
258 (dev->dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" : 273 (dev->dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
@@ -278,10 +293,14 @@ int core_scsi3_ua_clear_for_request_sense(
278 if (!nacl) 293 if (!nacl)
279 return -EINVAL; 294 return -EINVAL;
280 295
281 spin_lock_irq(&nacl->device_list_lock); 296 rcu_read_lock();
282 deve = nacl->device_list[cmd->orig_fe_lun]; 297 deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
298 if (!deve) {
299 rcu_read_unlock();
300 return -EINVAL;
301 }
283 if (!atomic_read(&deve->ua_count)) { 302 if (!atomic_read(&deve->ua_count)) {
284 spin_unlock_irq(&nacl->device_list_lock); 303 rcu_read_unlock();
285 return -EPERM; 304 return -EPERM;
286 } 305 }
287 /* 306 /*
@@ -307,10 +326,10 @@ int core_scsi3_ua_clear_for_request_sense(
307 atomic_dec_mb(&deve->ua_count); 326 atomic_dec_mb(&deve->ua_count);
308 } 327 }
309 spin_unlock(&deve->ua_lock); 328 spin_unlock(&deve->ua_lock);
310 spin_unlock_irq(&nacl->device_list_lock); 329 rcu_read_unlock();
311 330
312 pr_debug("[%s]: Released UNIT ATTENTION condition, mapped" 331 pr_debug("[%s]: Released UNIT ATTENTION condition, mapped"
313 " LUN: %u, got REQUEST_SENSE reported ASC: 0x%02x," 332 " LUN: %llu, got REQUEST_SENSE reported ASC: 0x%02x,"
314 " ASCQ: 0x%02x\n", nacl->se_tpg->se_tpg_tfo->get_fabric_name(), 333 " ASCQ: 0x%02x\n", nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
315 cmd->orig_fe_lun, *asc, *ascq); 334 cmd->orig_fe_lun, *asc, *ascq);
316 335