aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_tpg.c
diff options
context:
space:
mode:
authorJörn Engel <joern@logfs.org>2012-03-15 15:05:40 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-03-15 22:15:51 -0400
commitf2083241f23722207676025abbb45a301d412e69 (patch)
treec340376faf2a1eebe0983075adee2a3c8070c064 /drivers/target/target_core_tpg.c
parent4a5a75f32dcbcd0b2685f74fd4ede26edf8765a9 (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/target_core_tpg.c')
-rw-r--r--drivers/target/target_core_tpg.c8
1 files changed, 4 insertions, 4 deletions
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);