aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-13 19:42:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-13 19:42:11 -0400
commit89838b80bbbf9774cf010905851db7913c9331f0 (patch)
tree4d47f408fc90c2f575f5741093fdf34dc9f74b1e /drivers/mtd
parentf6f993328b2abcab86a3c99d7bd9f2066ab03d36 (diff)
parent25601a3c9737fed554169759582c690b98ead5d4 (diff)
Merge tag 'upstream-3.17-rc1' of git://git.infradead.org/linux-ubifs
Pull UBI/UBIFS changes from Artem Bityutskiy: "No significant changes, mostly small fixes here and there. The more important fixes are: - UBI deleted list items while iterating the list with 'list_for_each_entry' - The UBI block driver did not work properly with very large UBI volumes" * tag 'upstream-3.17-rc1' of git://git.infradead.org/linux-ubifs: (21 commits) UBIFS: Add log overlap assertions Revert "UBIFS: add a log overlap assertion" UBI: bugfix in ubi_wl_flush() UBI: block: Avoid disk size integer overflow UBI: block: Set disk_capacity out of the mutex UBI: block: Make ubiblock_resize return something UBIFS: add a log overlap assertion UBIFS: remove unnecessary check UBIFS: remove mst_mutex UBIFS: kernel-doc warning fix UBI: init_volumes: Ignore volumes with no LEBs UBIFS: replace seq_printf by seq_puts UBIFS: replace count*size kzalloc by kcalloc UBIFS: kernel-doc warning fix UBIFS: fix error path in create_default_filesystem() UBIFS: fix spelling of "scanned" UBIFS: fix some comments UBIFS: remove useless @ecc in struct ubifs_scan_leb UBIFS: remove useless statements UBIFS: Add missing break statements in dbg_chk_pnode() ...
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/block.c18
-rw-r--r--drivers/mtd/ubi/vtbl.c2
-rw-r--r--drivers/mtd/ubi/wl.c4
3 files changed, 15 insertions, 9 deletions
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 8457df7ec5af..33c64955d4d7 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -378,9 +378,11 @@ int ubiblock_create(struct ubi_volume_info *vi)
378{ 378{
379 struct ubiblock *dev; 379 struct ubiblock *dev;
380 struct gendisk *gd; 380 struct gendisk *gd;
381 int disk_capacity; 381 u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
382 int ret; 382 int ret;
383 383
384 if ((sector_t)disk_capacity != disk_capacity)
385 return -EFBIG;
384 /* Check that the volume isn't already handled */ 386 /* Check that the volume isn't already handled */
385 mutex_lock(&devices_mutex); 387 mutex_lock(&devices_mutex);
386 if (find_dev_nolock(vi->ubi_num, vi->vol_id)) { 388 if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
@@ -412,7 +414,6 @@ int ubiblock_create(struct ubi_volume_info *vi)
412 gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id; 414 gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id;
413 gd->private_data = dev; 415 gd->private_data = dev;
414 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); 416 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
415 disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
416 set_capacity(gd, disk_capacity); 417 set_capacity(gd, disk_capacity);
417 dev->gd = gd; 418 dev->gd = gd;
418 419
@@ -498,11 +499,16 @@ int ubiblock_remove(struct ubi_volume_info *vi)
498 return 0; 499 return 0;
499} 500}
500 501
501static void ubiblock_resize(struct ubi_volume_info *vi) 502static int ubiblock_resize(struct ubi_volume_info *vi)
502{ 503{
503 struct ubiblock *dev; 504 struct ubiblock *dev;
504 int disk_capacity; 505 u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
505 506
507 if ((sector_t)disk_capacity != disk_capacity) {
508 ubi_warn("%s: the volume is too big, cannot resize (%d LEBs)",
509 dev->gd->disk_name, vi->size);
510 return -EFBIG;
511 }
506 /* 512 /*
507 * Need to lock the device list until we stop using the device, 513 * Need to lock the device list until we stop using the device,
508 * otherwise the device struct might get released in 514 * otherwise the device struct might get released in
@@ -512,15 +518,15 @@ static void ubiblock_resize(struct ubi_volume_info *vi)
512 dev = find_dev_nolock(vi->ubi_num, vi->vol_id); 518 dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
513 if (!dev) { 519 if (!dev) {
514 mutex_unlock(&devices_mutex); 520 mutex_unlock(&devices_mutex);
515 return; 521 return -ENODEV;
516 } 522 }
517 523
518 mutex_lock(&dev->dev_mutex); 524 mutex_lock(&dev->dev_mutex);
519 disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
520 set_capacity(dev->gd, disk_capacity); 525 set_capacity(dev->gd, disk_capacity);
521 ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size); 526 ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size);
522 mutex_unlock(&dev->dev_mutex); 527 mutex_unlock(&dev->dev_mutex);
523 mutex_unlock(&devices_mutex); 528 mutex_unlock(&devices_mutex);
529 return 0;
524} 530}
525 531
526static int ubiblock_notify(struct notifier_block *nb, 532static int ubiblock_notify(struct notifier_block *nb,
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index d77b1c1d7c72..07cac5f9ffb8 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -591,7 +591,7 @@ static int init_volumes(struct ubi_device *ubi,
591 591
592 /* Static volumes only */ 592 /* Static volumes only */
593 av = ubi_find_av(ai, i); 593 av = ubi_find_av(ai, i);
594 if (!av) { 594 if (!av || !av->leb_count) {
595 /* 595 /*
596 * No eraseblocks belonging to this volume found. We 596 * No eraseblocks belonging to this volume found. We
597 * don't actually know whether this static volume is 597 * don't actually know whether this static volume is
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 0f3425dac910..20f491713145 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1718,12 +1718,12 @@ int ubi_wl_flush(struct ubi_device *ubi, int vol_id, int lnum)
1718 vol_id, lnum, ubi->works_count); 1718 vol_id, lnum, ubi->works_count);
1719 1719
1720 while (found) { 1720 while (found) {
1721 struct ubi_work *wrk; 1721 struct ubi_work *wrk, *tmp;
1722 found = 0; 1722 found = 0;
1723 1723
1724 down_read(&ubi->work_sem); 1724 down_read(&ubi->work_sem);
1725 spin_lock(&ubi->wl_lock); 1725 spin_lock(&ubi->wl_lock);
1726 list_for_each_entry(wrk, &ubi->works, list) { 1726 list_for_each_entry_safe(wrk, tmp, &ubi->works, list) {
1727 if ((vol_id == UBI_ALL || wrk->vol_id == vol_id) && 1727 if ((vol_id == UBI_ALL || wrk->vol_id == vol_id) &&
1728 (lnum == UBI_ALL || wrk->lnum == lnum)) { 1728 (lnum == UBI_ALL || wrk->lnum == lnum)) {
1729 list_del(&wrk->list); 1729 list_del(&wrk->list);