aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/vtbl.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-05-06 09:12:54 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-07-18 09:53:08 -0400
commit92ad8f37509a7d9d5dd6e0092211b092a7ca7fb1 (patch)
tree96c0f9c524b80e8d1d247e3f462c0c0d6fb782a5 /drivers/mtd/ubi/vtbl.c
parent79b510c0f21174f4bd055d1aab156e548ae3a5f2 (diff)
UBI: use vmalloc for large buffers
UBI allocates temporary buffers of PEB size, which may be 256KiB. Use vmalloc instead of kmalloc for such big temporary buffers. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/vtbl.c')
-rw-r--r--drivers/mtd/ubi/vtbl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 9926f1f9aad8..e3557b987efd 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -381,11 +381,12 @@ static struct ubi_vtbl_record *process_lvol(const struct ubi_device *ubi,
381 381
382 /* Read both LEB 0 and LEB 1 into memory */ 382 /* Read both LEB 0 and LEB 1 into memory */
383 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { 383 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
384 leb[seb->lnum] = kzalloc(ubi->vtbl_size, GFP_KERNEL); 384 leb[seb->lnum] = vmalloc(ubi->vtbl_size);
385 if (!leb[seb->lnum]) { 385 if (!leb[seb->lnum]) {
386 err = -ENOMEM; 386 err = -ENOMEM;
387 goto out_free; 387 goto out_free;
388 } 388 }
389 memset(leb[seb->lnum], 0, ubi->vtbl_size);
389 390
390 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, 391 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
391 ubi->vtbl_size); 392 ubi->vtbl_size);
@@ -416,7 +417,7 @@ static struct ubi_vtbl_record *process_lvol(const struct ubi_device *ubi,
416 } 417 }
417 418
418 /* Both LEB 1 and LEB 2 are OK and consistent */ 419 /* Both LEB 1 and LEB 2 are OK and consistent */
419 kfree(leb[1]); 420 vfree(leb[1]);
420 return leb[0]; 421 return leb[0];
421 } else { 422 } else {
422 /* LEB 0 is corrupted or does not exist */ 423 /* LEB 0 is corrupted or does not exist */
@@ -437,13 +438,13 @@ static struct ubi_vtbl_record *process_lvol(const struct ubi_device *ubi,
437 goto out_free; 438 goto out_free;
438 ubi_msg("volume table was restored"); 439 ubi_msg("volume table was restored");
439 440
440 kfree(leb[0]); 441 vfree(leb[0]);
441 return leb[1]; 442 return leb[1];
442 } 443 }
443 444
444out_free: 445out_free:
445 kfree(leb[0]); 446 vfree(leb[0]);
446 kfree(leb[1]); 447 vfree(leb[1]);
447 return ERR_PTR(err); 448 return ERR_PTR(err);
448} 449}
449 450
@@ -461,9 +462,10 @@ static struct ubi_vtbl_record *create_empty_lvol(const struct ubi_device *ubi,
461 int i; 462 int i;
462 struct ubi_vtbl_record *vtbl; 463 struct ubi_vtbl_record *vtbl;
463 464
464 vtbl = kzalloc(ubi->vtbl_size, GFP_KERNEL); 465 vtbl = vmalloc(ubi->vtbl_size);
465 if (!vtbl) 466 if (!vtbl)
466 return ERR_PTR(-ENOMEM); 467 return ERR_PTR(-ENOMEM);
468 memset(vtbl, 0, ubi->vtbl_size);
467 469
468 for (i = 0; i < ubi->vtbl_slots; i++) 470 for (i = 0; i < ubi->vtbl_slots; i++)
469 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE); 471 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);
@@ -473,7 +475,7 @@ static struct ubi_vtbl_record *create_empty_lvol(const struct ubi_device *ubi,
473 475
474 err = create_vtbl(ubi, si, i, vtbl); 476 err = create_vtbl(ubi, si, i, vtbl);
475 if (err) { 477 if (err) {
476 kfree(vtbl); 478 vfree(vtbl);
477 return ERR_PTR(err); 479 return ERR_PTR(err);
478 } 480 }
479 } 481 }
@@ -784,7 +786,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
784 return 0; 786 return 0;
785 787
786out_free: 788out_free:
787 kfree(ubi->vtbl); 789 vfree(ubi->vtbl);
788 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) 790 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++)
789 if (ubi->volumes[i]) { 791 if (ubi->volumes[i]) {
790 kfree(ubi->volumes[i]); 792 kfree(ubi->volumes[i]);