diff options
author | Jörn Engel <joern@logfs.org> | 2012-03-15 15:05:40 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-03-15 22:15:51 -0400 |
commit | f2083241f23722207676025abbb45a301d412e69 (patch) | |
tree | c340376faf2a1eebe0983075adee2a3c8070c064 /drivers/target | |
parent | 4a5a75f32dcbcd0b2685f74fd4ede26edf8765a9 (diff) |
target: Use array_zalloc for device_list
Turns an order-8 allocation into slab-sized ones, thereby preventing
allocation failures with memory fragmentation.
This likely saves memory as well, as the slab allocator can pack objects
more tightly than the buddy allocator.
(nab: Fix lio-core patch fuzz)
Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_device.c | 20 | ||||
-rw-r--r-- | drivers/target/target_core_fabric_configfs.c | 6 | ||||
-rw-r--r-- | drivers/target/target_core_pr.c | 14 | ||||
-rw-r--r-- | drivers/target/target_core_stat.c | 36 | ||||
-rw-r--r-- | drivers/target/target_core_tpg.c | 8 | ||||
-rw-r--r-- | drivers/target/target_core_ua.c | 8 |
6 files changed, 46 insertions, 46 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index fd7f17c303a7..3be7279865b1 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 | } | 72 | } |
73 | 73 | ||
74 | spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags); | 74 | spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags); |
75 | se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun]; | 75 | se_cmd->se_deve = se_sess->se_node_acl->device_list[unpacked_lun]; |
76 | if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { | 76 | if (se_cmd->se_deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { |
77 | struct se_dev_entry *deve = se_cmd->se_deve; | 77 | struct se_dev_entry *deve = se_cmd->se_deve; |
78 | 78 | ||
@@ -182,7 +182,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
182 | } | 182 | } |
183 | 183 | ||
184 | spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags); | 184 | spin_lock_irqsave(&se_sess->se_node_acl->device_list_lock, flags); |
185 | se_cmd->se_deve = &se_sess->se_node_acl->device_list[unpacked_lun]; | 185 | se_cmd->se_deve = se_sess->se_node_acl->device_list[unpacked_lun]; |
186 | deve = se_cmd->se_deve; | 186 | deve = se_cmd->se_deve; |
187 | 187 | ||
188 | if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { | 188 | if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { |
@@ -240,7 +240,7 @@ struct se_dev_entry *core_get_se_deve_from_rtpi( | |||
240 | 240 | ||
241 | spin_lock_irq(&nacl->device_list_lock); | 241 | spin_lock_irq(&nacl->device_list_lock); |
242 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 242 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
243 | deve = &nacl->device_list[i]; | 243 | deve = nacl->device_list[i]; |
244 | 244 | ||
245 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) | 245 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) |
246 | continue; | 246 | continue; |
@@ -286,7 +286,7 @@ int core_free_device_list_for_node( | |||
286 | 286 | ||
287 | spin_lock_irq(&nacl->device_list_lock); | 287 | spin_lock_irq(&nacl->device_list_lock); |
288 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 288 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
289 | deve = &nacl->device_list[i]; | 289 | deve = nacl->device_list[i]; |
290 | 290 | ||
291 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) | 291 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) |
292 | continue; | 292 | continue; |
@@ -306,7 +306,7 @@ int core_free_device_list_for_node( | |||
306 | } | 306 | } |
307 | spin_unlock_irq(&nacl->device_list_lock); | 307 | spin_unlock_irq(&nacl->device_list_lock); |
308 | 308 | ||
309 | kfree(nacl->device_list); | 309 | array_free(nacl->device_list, TRANSPORT_MAX_LUNS_PER_TPG); |
310 | nacl->device_list = NULL; | 310 | nacl->device_list = NULL; |
311 | 311 | ||
312 | return 0; | 312 | return 0; |
@@ -318,7 +318,7 @@ void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) | |||
318 | unsigned long flags; | 318 | unsigned long flags; |
319 | 319 | ||
320 | spin_lock_irqsave(&se_nacl->device_list_lock, flags); | 320 | spin_lock_irqsave(&se_nacl->device_list_lock, flags); |
321 | deve = &se_nacl->device_list[se_cmd->orig_fe_lun]; | 321 | deve = se_nacl->device_list[se_cmd->orig_fe_lun]; |
322 | deve->deve_cmds--; | 322 | deve->deve_cmds--; |
323 | spin_unlock_irqrestore(&se_nacl->device_list_lock, flags); | 323 | spin_unlock_irqrestore(&se_nacl->device_list_lock, flags); |
324 | } | 324 | } |
@@ -331,7 +331,7 @@ void core_update_device_list_access( | |||
331 | struct se_dev_entry *deve; | 331 | struct se_dev_entry *deve; |
332 | 332 | ||
333 | spin_lock_irq(&nacl->device_list_lock); | 333 | spin_lock_irq(&nacl->device_list_lock); |
334 | deve = &nacl->device_list[mapped_lun]; | 334 | deve = nacl->device_list[mapped_lun]; |
335 | if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) { | 335 | if (lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) { |
336 | deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY; | 336 | deve->lun_flags &= ~TRANSPORT_LUNFLAGS_READ_ONLY; |
337 | deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE; | 337 | deve->lun_flags |= TRANSPORT_LUNFLAGS_READ_WRITE; |
@@ -356,7 +356,7 @@ int core_update_device_list_for_node( | |||
356 | int enable) | 356 | int enable) |
357 | { | 357 | { |
358 | struct se_port *port = lun->lun_sep; | 358 | struct se_port *port = lun->lun_sep; |
359 | struct se_dev_entry *deve = &nacl->device_list[mapped_lun]; | 359 | struct se_dev_entry *deve = nacl->device_list[mapped_lun]; |
360 | int trans = 0; | 360 | int trans = 0; |
361 | /* | 361 | /* |
362 | * If the MappedLUN entry is being disabled, the entry in | 362 | * If the MappedLUN entry is being disabled, the entry in |
@@ -470,7 +470,7 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg) | |||
470 | 470 | ||
471 | spin_lock_irq(&nacl->device_list_lock); | 471 | spin_lock_irq(&nacl->device_list_lock); |
472 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 472 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
473 | deve = &nacl->device_list[i]; | 473 | deve = nacl->device_list[i]; |
474 | if (lun != deve->se_lun) | 474 | if (lun != deve->se_lun) |
475 | continue; | 475 | continue; |
476 | spin_unlock_irq(&nacl->device_list_lock); | 476 | spin_unlock_irq(&nacl->device_list_lock); |
@@ -669,7 +669,7 @@ int target_report_luns(struct se_task *se_task) | |||
669 | 669 | ||
670 | spin_lock_irq(&se_sess->se_node_acl->device_list_lock); | 670 | spin_lock_irq(&se_sess->se_node_acl->device_list_lock); |
671 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 671 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
672 | deve = &se_sess->se_node_acl->device_list[i]; | 672 | deve = se_sess->se_node_acl->device_list[i]; |
673 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) | 673 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) |
674 | continue; | 674 | continue; |
675 | se_lun = deve->se_lun; | 675 | se_lun = deve->se_lun; |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index 9a2ce11e1a6e..405cc98eaed6 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -108,7 +108,7 @@ static int target_fabric_mappedlun_link( | |||
108 | * tpg_1/attrib/demo_mode_write_protect=1 | 108 | * tpg_1/attrib/demo_mode_write_protect=1 |
109 | */ | 109 | */ |
110 | spin_lock_irq(&lacl->se_lun_nacl->device_list_lock); | 110 | spin_lock_irq(&lacl->se_lun_nacl->device_list_lock); |
111 | deve = &lacl->se_lun_nacl->device_list[lacl->mapped_lun]; | 111 | deve = lacl->se_lun_nacl->device_list[lacl->mapped_lun]; |
112 | if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) | 112 | if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) |
113 | lun_access = deve->lun_flags; | 113 | lun_access = deve->lun_flags; |
114 | else | 114 | else |
@@ -137,7 +137,7 @@ static int target_fabric_mappedlun_unlink( | |||
137 | struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), | 137 | struct se_lun_acl *lacl = container_of(to_config_group(lun_acl_ci), |
138 | struct se_lun_acl, se_lun_group); | 138 | struct se_lun_acl, se_lun_group); |
139 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 139 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
140 | struct se_dev_entry *deve = &nacl->device_list[lacl->mapped_lun]; | 140 | struct se_dev_entry *deve = nacl->device_list[lacl->mapped_lun]; |
141 | struct se_portal_group *se_tpg; | 141 | struct se_portal_group *se_tpg; |
142 | /* | 142 | /* |
143 | * Determine if the underlying MappedLUN has already been released.. | 143 | * Determine if the underlying MappedLUN has already been released.. |
@@ -168,7 +168,7 @@ static ssize_t target_fabric_mappedlun_show_write_protect( | |||
168 | ssize_t len; | 168 | ssize_t len; |
169 | 169 | ||
170 | spin_lock_irq(&se_nacl->device_list_lock); | 170 | spin_lock_irq(&se_nacl->device_list_lock); |
171 | deve = &se_nacl->device_list[lacl->mapped_lun]; | 171 | deve = se_nacl->device_list[lacl->mapped_lun]; |
172 | len = sprintf(page, "%d\n", | 172 | len = sprintf(page, "%d\n", |
173 | (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? | 173 | (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? |
174 | 1 : 0); | 174 | 1 : 0); |
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 6beada820165..de3e4f2f60bd 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -328,7 +328,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
328 | return core_scsi2_reservation_seq_non_holder(cmd, | 328 | return core_scsi2_reservation_seq_non_holder(cmd, |
329 | cdb, pr_reg_type); | 329 | cdb, pr_reg_type); |
330 | 330 | ||
331 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 331 | se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
332 | /* | 332 | /* |
333 | * Determine if the registration should be ignored due to | 333 | * Determine if the registration should be ignored due to |
334 | * non-matching ISIDs in core_scsi3_pr_reservation_check(). | 334 | * non-matching ISIDs in core_scsi3_pr_reservation_check(). |
@@ -990,7 +990,7 @@ int core_scsi3_check_aptpl_registration( | |||
990 | { | 990 | { |
991 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | 991 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
992 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; | 992 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; |
993 | struct se_dev_entry *deve = &nacl->device_list[lun_acl->mapped_lun]; | 993 | struct se_dev_entry *deve = nacl->device_list[lun_acl->mapped_lun]; |
994 | 994 | ||
995 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) | 995 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
996 | return 0; | 996 | return 0; |
@@ -1499,7 +1499,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1499 | 1499 | ||
1500 | memset(dest_iport, 0, 64); | 1500 | memset(dest_iport, 0, 64); |
1501 | 1501 | ||
1502 | local_se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 1502 | local_se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
1503 | /* | 1503 | /* |
1504 | * Allocate a struct pr_transport_id_holder and setup the | 1504 | * Allocate a struct pr_transport_id_holder and setup the |
1505 | * local_node_acl and local_se_deve pointers and add to | 1505 | * local_node_acl and local_se_deve pointers and add to |
@@ -2116,7 +2116,7 @@ static int core_scsi3_emulate_pro_register( | |||
2116 | return -EINVAL; | 2116 | return -EINVAL; |
2117 | } | 2117 | } |
2118 | se_tpg = se_sess->se_tpg; | 2118 | se_tpg = se_sess->se_tpg; |
2119 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2119 | se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
2120 | 2120 | ||
2121 | if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) { | 2121 | if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) { |
2122 | memset(&isid_buf[0], 0, PR_REG_ISID_LEN); | 2122 | memset(&isid_buf[0], 0, PR_REG_ISID_LEN); |
@@ -2432,7 +2432,7 @@ static int core_scsi3_pro_reserve( | |||
2432 | return -EINVAL; | 2432 | return -EINVAL; |
2433 | } | 2433 | } |
2434 | se_tpg = se_sess->se_tpg; | 2434 | se_tpg = se_sess->se_tpg; |
2435 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2435 | se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
2436 | /* | 2436 | /* |
2437 | * Locate the existing *pr_reg via struct se_node_acl pointers | 2437 | * Locate the existing *pr_reg via struct se_node_acl pointers |
2438 | */ | 2438 | */ |
@@ -3005,7 +3005,7 @@ static int core_scsi3_pro_preempt( | |||
3005 | return -EINVAL; | 3005 | return -EINVAL; |
3006 | } | 3006 | } |
3007 | 3007 | ||
3008 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 3008 | se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
3009 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, | 3009 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, |
3010 | se_sess); | 3010 | se_sess); |
3011 | if (!pr_reg_n) { | 3011 | if (!pr_reg_n) { |
@@ -3366,7 +3366,7 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3366 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); | 3366 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
3367 | se_tpg = se_sess->se_tpg; | 3367 | se_tpg = se_sess->se_tpg; |
3368 | tf_ops = se_tpg->se_tpg_tfo; | 3368 | tf_ops = se_tpg->se_tpg_tfo; |
3369 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 3369 | se_deve = se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
3370 | /* | 3370 | /* |
3371 | * Follow logic from spc4r17 Section 5.7.8, Table 50 -- | 3371 | * Follow logic from spc4r17 Section 5.7.8, Table 50 -- |
3372 | * Register behaviors for a REGISTER AND MOVE service action | 3372 | * Register behaviors for a REGISTER AND MOVE service action |
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index f8c2d2cc3431..7ce1bfa5c542 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -1253,7 +1253,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_inst( | |||
1253 | ssize_t ret; | 1253 | ssize_t ret; |
1254 | 1254 | ||
1255 | spin_lock_irq(&nacl->device_list_lock); | 1255 | spin_lock_irq(&nacl->device_list_lock); |
1256 | deve = &nacl->device_list[lacl->mapped_lun]; | 1256 | deve = nacl->device_list[lacl->mapped_lun]; |
1257 | if (!deve->se_lun || !deve->se_lun_acl) { | 1257 | if (!deve->se_lun || !deve->se_lun_acl) { |
1258 | spin_unlock_irq(&nacl->device_list_lock); | 1258 | spin_unlock_irq(&nacl->device_list_lock); |
1259 | return -ENODEV; | 1259 | return -ENODEV; |
@@ -1279,7 +1279,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev( | |||
1279 | ssize_t ret; | 1279 | ssize_t ret; |
1280 | 1280 | ||
1281 | spin_lock_irq(&nacl->device_list_lock); | 1281 | spin_lock_irq(&nacl->device_list_lock); |
1282 | deve = &nacl->device_list[lacl->mapped_lun]; | 1282 | deve = nacl->device_list[lacl->mapped_lun]; |
1283 | if (!deve->se_lun || !deve->se_lun_acl) { | 1283 | if (!deve->se_lun || !deve->se_lun_acl) { |
1284 | spin_unlock_irq(&nacl->device_list_lock); | 1284 | spin_unlock_irq(&nacl->device_list_lock); |
1285 | return -ENODEV; | 1285 | return -ENODEV; |
@@ -1304,7 +1304,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_port( | |||
1304 | ssize_t ret; | 1304 | ssize_t ret; |
1305 | 1305 | ||
1306 | spin_lock_irq(&nacl->device_list_lock); | 1306 | spin_lock_irq(&nacl->device_list_lock); |
1307 | deve = &nacl->device_list[lacl->mapped_lun]; | 1307 | deve = nacl->device_list[lacl->mapped_lun]; |
1308 | if (!deve->se_lun || !deve->se_lun_acl) { | 1308 | if (!deve->se_lun || !deve->se_lun_acl) { |
1309 | spin_unlock_irq(&nacl->device_list_lock); | 1309 | spin_unlock_irq(&nacl->device_list_lock); |
1310 | return -ENODEV; | 1310 | return -ENODEV; |
@@ -1327,7 +1327,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_indx( | |||
1327 | ssize_t ret; | 1327 | ssize_t ret; |
1328 | 1328 | ||
1329 | spin_lock_irq(&nacl->device_list_lock); | 1329 | spin_lock_irq(&nacl->device_list_lock); |
1330 | deve = &nacl->device_list[lacl->mapped_lun]; | 1330 | deve = nacl->device_list[lacl->mapped_lun]; |
1331 | if (!deve->se_lun || !deve->se_lun_acl) { | 1331 | if (!deve->se_lun || !deve->se_lun_acl) { |
1332 | spin_unlock_irq(&nacl->device_list_lock); | 1332 | spin_unlock_irq(&nacl->device_list_lock); |
1333 | return -ENODEV; | 1333 | return -ENODEV; |
@@ -1349,7 +1349,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port( | |||
1349 | ssize_t ret; | 1349 | ssize_t ret; |
1350 | 1350 | ||
1351 | spin_lock_irq(&nacl->device_list_lock); | 1351 | spin_lock_irq(&nacl->device_list_lock); |
1352 | deve = &nacl->device_list[lacl->mapped_lun]; | 1352 | deve = nacl->device_list[lacl->mapped_lun]; |
1353 | if (!deve->se_lun || !deve->se_lun_acl) { | 1353 | if (!deve->se_lun || !deve->se_lun_acl) { |
1354 | spin_unlock_irq(&nacl->device_list_lock); | 1354 | spin_unlock_irq(&nacl->device_list_lock); |
1355 | return -ENODEV; | 1355 | return -ENODEV; |
@@ -1371,7 +1371,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name( | |||
1371 | ssize_t ret; | 1371 | ssize_t ret; |
1372 | 1372 | ||
1373 | spin_lock_irq(&nacl->device_list_lock); | 1373 | spin_lock_irq(&nacl->device_list_lock); |
1374 | deve = &nacl->device_list[lacl->mapped_lun]; | 1374 | deve = nacl->device_list[lacl->mapped_lun]; |
1375 | if (!deve->se_lun || !deve->se_lun_acl) { | 1375 | if (!deve->se_lun || !deve->se_lun_acl) { |
1376 | spin_unlock_irq(&nacl->device_list_lock); | 1376 | spin_unlock_irq(&nacl->device_list_lock); |
1377 | return -ENODEV; | 1377 | return -ENODEV; |
@@ -1393,7 +1393,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx( | |||
1393 | ssize_t ret; | 1393 | ssize_t ret; |
1394 | 1394 | ||
1395 | spin_lock_irq(&nacl->device_list_lock); | 1395 | spin_lock_irq(&nacl->device_list_lock); |
1396 | deve = &nacl->device_list[lacl->mapped_lun]; | 1396 | deve = nacl->device_list[lacl->mapped_lun]; |
1397 | if (!deve->se_lun || !deve->se_lun_acl) { | 1397 | if (!deve->se_lun || !deve->se_lun_acl) { |
1398 | spin_unlock_irq(&nacl->device_list_lock); | 1398 | spin_unlock_irq(&nacl->device_list_lock); |
1399 | return -ENODEV; | 1399 | return -ENODEV; |
@@ -1415,7 +1415,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_att_count( | |||
1415 | ssize_t ret; | 1415 | ssize_t ret; |
1416 | 1416 | ||
1417 | spin_lock_irq(&nacl->device_list_lock); | 1417 | spin_lock_irq(&nacl->device_list_lock); |
1418 | deve = &nacl->device_list[lacl->mapped_lun]; | 1418 | deve = nacl->device_list[lacl->mapped_lun]; |
1419 | if (!deve->se_lun || !deve->se_lun_acl) { | 1419 | if (!deve->se_lun || !deve->se_lun_acl) { |
1420 | spin_unlock_irq(&nacl->device_list_lock); | 1420 | spin_unlock_irq(&nacl->device_list_lock); |
1421 | return -ENODEV; | 1421 | return -ENODEV; |
@@ -1437,7 +1437,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds( | |||
1437 | ssize_t ret; | 1437 | ssize_t ret; |
1438 | 1438 | ||
1439 | spin_lock_irq(&nacl->device_list_lock); | 1439 | spin_lock_irq(&nacl->device_list_lock); |
1440 | deve = &nacl->device_list[lacl->mapped_lun]; | 1440 | deve = nacl->device_list[lacl->mapped_lun]; |
1441 | if (!deve->se_lun || !deve->se_lun_acl) { | 1441 | if (!deve->se_lun || !deve->se_lun_acl) { |
1442 | spin_unlock_irq(&nacl->device_list_lock); | 1442 | spin_unlock_irq(&nacl->device_list_lock); |
1443 | return -ENODEV; | 1443 | return -ENODEV; |
@@ -1459,7 +1459,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes( | |||
1459 | ssize_t ret; | 1459 | ssize_t ret; |
1460 | 1460 | ||
1461 | spin_lock_irq(&nacl->device_list_lock); | 1461 | spin_lock_irq(&nacl->device_list_lock); |
1462 | deve = &nacl->device_list[lacl->mapped_lun]; | 1462 | deve = nacl->device_list[lacl->mapped_lun]; |
1463 | if (!deve->se_lun || !deve->se_lun_acl) { | 1463 | if (!deve->se_lun || !deve->se_lun_acl) { |
1464 | spin_unlock_irq(&nacl->device_list_lock); | 1464 | spin_unlock_irq(&nacl->device_list_lock); |
1465 | return -ENODEV; | 1465 | return -ENODEV; |
@@ -1481,7 +1481,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes( | |||
1481 | ssize_t ret; | 1481 | ssize_t ret; |
1482 | 1482 | ||
1483 | spin_lock_irq(&nacl->device_list_lock); | 1483 | spin_lock_irq(&nacl->device_list_lock); |
1484 | deve = &nacl->device_list[lacl->mapped_lun]; | 1484 | deve = nacl->device_list[lacl->mapped_lun]; |
1485 | if (!deve->se_lun || !deve->se_lun_acl) { | 1485 | if (!deve->se_lun || !deve->se_lun_acl) { |
1486 | spin_unlock_irq(&nacl->device_list_lock); | 1486 | spin_unlock_irq(&nacl->device_list_lock); |
1487 | return -ENODEV; | 1487 | return -ENODEV; |
@@ -1503,7 +1503,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds( | |||
1503 | ssize_t ret; | 1503 | ssize_t ret; |
1504 | 1504 | ||
1505 | spin_lock_irq(&nacl->device_list_lock); | 1505 | spin_lock_irq(&nacl->device_list_lock); |
1506 | deve = &nacl->device_list[lacl->mapped_lun]; | 1506 | deve = nacl->device_list[lacl->mapped_lun]; |
1507 | if (!deve->se_lun || !deve->se_lun_acl) { | 1507 | if (!deve->se_lun || !deve->se_lun_acl) { |
1508 | spin_unlock_irq(&nacl->device_list_lock); | 1508 | spin_unlock_irq(&nacl->device_list_lock); |
1509 | return -ENODEV; | 1509 | return -ENODEV; |
@@ -1525,7 +1525,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time( | |||
1525 | ssize_t ret; | 1525 | ssize_t ret; |
1526 | 1526 | ||
1527 | spin_lock_irq(&nacl->device_list_lock); | 1527 | spin_lock_irq(&nacl->device_list_lock); |
1528 | deve = &nacl->device_list[lacl->mapped_lun]; | 1528 | deve = nacl->device_list[lacl->mapped_lun]; |
1529 | if (!deve->se_lun || !deve->se_lun_acl) { | 1529 | if (!deve->se_lun || !deve->se_lun_acl) { |
1530 | spin_unlock_irq(&nacl->device_list_lock); | 1530 | spin_unlock_irq(&nacl->device_list_lock); |
1531 | return -ENODEV; | 1531 | return -ENODEV; |
@@ -1548,7 +1548,7 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_row_status( | |||
1548 | ssize_t ret; | 1548 | ssize_t ret; |
1549 | 1549 | ||
1550 | spin_lock_irq(&nacl->device_list_lock); | 1550 | spin_lock_irq(&nacl->device_list_lock); |
1551 | deve = &nacl->device_list[lacl->mapped_lun]; | 1551 | deve = nacl->device_list[lacl->mapped_lun]; |
1552 | if (!deve->se_lun || !deve->se_lun_acl) { | 1552 | if (!deve->se_lun || !deve->se_lun_acl) { |
1553 | spin_unlock_irq(&nacl->device_list_lock); | 1553 | spin_unlock_irq(&nacl->device_list_lock); |
1554 | return -ENODEV; | 1554 | return -ENODEV; |
@@ -1621,7 +1621,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_inst( | |||
1621 | ssize_t ret; | 1621 | ssize_t ret; |
1622 | 1622 | ||
1623 | spin_lock_irq(&nacl->device_list_lock); | 1623 | spin_lock_irq(&nacl->device_list_lock); |
1624 | deve = &nacl->device_list[lacl->mapped_lun]; | 1624 | deve = nacl->device_list[lacl->mapped_lun]; |
1625 | if (!deve->se_lun || !deve->se_lun_acl) { | 1625 | if (!deve->se_lun || !deve->se_lun_acl) { |
1626 | spin_unlock_irq(&nacl->device_list_lock); | 1626 | spin_unlock_irq(&nacl->device_list_lock); |
1627 | return -ENODEV; | 1627 | return -ENODEV; |
@@ -1647,7 +1647,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( | |||
1647 | ssize_t ret; | 1647 | ssize_t ret; |
1648 | 1648 | ||
1649 | spin_lock_irq(&nacl->device_list_lock); | 1649 | spin_lock_irq(&nacl->device_list_lock); |
1650 | deve = &nacl->device_list[lacl->mapped_lun]; | 1650 | deve = nacl->device_list[lacl->mapped_lun]; |
1651 | if (!deve->se_lun || !deve->se_lun_acl) { | 1651 | if (!deve->se_lun || !deve->se_lun_acl) { |
1652 | spin_unlock_irq(&nacl->device_list_lock); | 1652 | spin_unlock_irq(&nacl->device_list_lock); |
1653 | return -ENODEV; | 1653 | return -ENODEV; |
@@ -1672,7 +1672,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port( | |||
1672 | ssize_t ret; | 1672 | ssize_t ret; |
1673 | 1673 | ||
1674 | spin_lock_irq(&nacl->device_list_lock); | 1674 | spin_lock_irq(&nacl->device_list_lock); |
1675 | deve = &nacl->device_list[lacl->mapped_lun]; | 1675 | deve = nacl->device_list[lacl->mapped_lun]; |
1676 | if (!deve->se_lun || !deve->se_lun_acl) { | 1676 | if (!deve->se_lun || !deve->se_lun_acl) { |
1677 | spin_unlock_irq(&nacl->device_list_lock); | 1677 | spin_unlock_irq(&nacl->device_list_lock); |
1678 | return -ENODEV; | 1678 | return -ENODEV; |
@@ -1721,7 +1721,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx( | |||
1721 | ssize_t ret; | 1721 | ssize_t ret; |
1722 | 1722 | ||
1723 | spin_lock_irq(&nacl->device_list_lock); | 1723 | spin_lock_irq(&nacl->device_list_lock); |
1724 | deve = &nacl->device_list[lacl->mapped_lun]; | 1724 | deve = nacl->device_list[lacl->mapped_lun]; |
1725 | if (!deve->se_lun || !deve->se_lun_acl) { | 1725 | if (!deve->se_lun || !deve->se_lun_acl) { |
1726 | spin_unlock_irq(&nacl->device_list_lock); | 1726 | spin_unlock_irq(&nacl->device_list_lock); |
1727 | return -ENODEV; | 1727 | return -ENODEV; |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 146fe47f11c1..c0fecde02fd0 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -64,7 +64,7 @@ static void core_clear_initiator_node_from_tpg( | |||
64 | 64 | ||
65 | spin_lock_irq(&nacl->device_list_lock); | 65 | spin_lock_irq(&nacl->device_list_lock); |
66 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 66 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
67 | deve = &nacl->device_list[i]; | 67 | deve = nacl->device_list[i]; |
68 | 68 | ||
69 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) | 69 | if (!(deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS)) |
70 | continue; | 70 | continue; |
@@ -259,15 +259,15 @@ static int core_create_device_list_for_node(struct se_node_acl *nacl) | |||
259 | struct se_dev_entry *deve; | 259 | struct se_dev_entry *deve; |
260 | int i; | 260 | int i; |
261 | 261 | ||
262 | nacl->device_list = kzalloc(sizeof(struct se_dev_entry) * | 262 | nacl->device_list = array_zalloc(TRANSPORT_MAX_LUNS_PER_TPG, |
263 | TRANSPORT_MAX_LUNS_PER_TPG, GFP_KERNEL); | 263 | sizeof(struct se_dev_entry), GFP_KERNEL); |
264 | if (!nacl->device_list) { | 264 | if (!nacl->device_list) { |
265 | pr_err("Unable to allocate memory for" | 265 | pr_err("Unable to allocate memory for" |
266 | " struct se_node_acl->device_list\n"); | 266 | " struct se_node_acl->device_list\n"); |
267 | return -ENOMEM; | 267 | return -ENOMEM; |
268 | } | 268 | } |
269 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { | 269 | for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) { |
270 | deve = &nacl->device_list[i]; | 270 | deve = nacl->device_list[i]; |
271 | 271 | ||
272 | atomic_set(&deve->ua_count, 0); | 272 | atomic_set(&deve->ua_count, 0); |
273 | atomic_set(&deve->pr_ref_count, 0); | 273 | atomic_set(&deve->pr_ref_count, 0); |
diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c index 3e12f6bcfa10..6666a0c74f60 100644 --- a/drivers/target/target_core_ua.c +++ b/drivers/target/target_core_ua.c | |||
@@ -53,7 +53,7 @@ int core_scsi3_ua_check( | |||
53 | if (!nacl) | 53 | if (!nacl) |
54 | return 0; | 54 | return 0; |
55 | 55 | ||
56 | deve = &nacl->device_list[cmd->orig_fe_lun]; | 56 | deve = nacl->device_list[cmd->orig_fe_lun]; |
57 | if (!atomic_read(&deve->ua_count)) | 57 | if (!atomic_read(&deve->ua_count)) |
58 | return 0; | 58 | return 0; |
59 | /* | 59 | /* |
@@ -110,7 +110,7 @@ int core_scsi3_ua_allocate( | |||
110 | ua->ua_ascq = ascq; | 110 | ua->ua_ascq = ascq; |
111 | 111 | ||
112 | spin_lock_irq(&nacl->device_list_lock); | 112 | spin_lock_irq(&nacl->device_list_lock); |
113 | deve = &nacl->device_list[unpacked_lun]; | 113 | deve = nacl->device_list[unpacked_lun]; |
114 | 114 | ||
115 | spin_lock(&deve->ua_lock); | 115 | spin_lock(&deve->ua_lock); |
116 | list_for_each_entry_safe(ua_p, ua_tmp, &deve->ua_list, ua_nacl_list) { | 116 | list_for_each_entry_safe(ua_p, ua_tmp, &deve->ua_list, ua_nacl_list) { |
@@ -220,7 +220,7 @@ void core_scsi3_ua_for_check_condition( | |||
220 | return; | 220 | return; |
221 | 221 | ||
222 | spin_lock_irq(&nacl->device_list_lock); | 222 | spin_lock_irq(&nacl->device_list_lock); |
223 | deve = &nacl->device_list[cmd->orig_fe_lun]; | 223 | deve = nacl->device_list[cmd->orig_fe_lun]; |
224 | if (!atomic_read(&deve->ua_count)) { | 224 | if (!atomic_read(&deve->ua_count)) { |
225 | spin_unlock_irq(&nacl->device_list_lock); | 225 | spin_unlock_irq(&nacl->device_list_lock); |
226 | return; | 226 | return; |
@@ -289,7 +289,7 @@ int core_scsi3_ua_clear_for_request_sense( | |||
289 | return -EINVAL; | 289 | return -EINVAL; |
290 | 290 | ||
291 | spin_lock_irq(&nacl->device_list_lock); | 291 | spin_lock_irq(&nacl->device_list_lock); |
292 | deve = &nacl->device_list[cmd->orig_fe_lun]; | 292 | deve = nacl->device_list[cmd->orig_fe_lun]; |
293 | if (!atomic_read(&deve->ua_count)) { | 293 | if (!atomic_read(&deve->ua_count)) { |
294 | spin_unlock_irq(&nacl->device_list_lock); | 294 | spin_unlock_irq(&nacl->device_list_lock); |
295 | return -EPERM; | 295 | return -EPERM; |