aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Ehrenberg <dehrenberg@chromium.org>2014-12-19 14:27:18 -0500
committerRichard Weinberger <richard@nod.at>2015-02-12 17:29:25 -0500
commit1440061be128180a3846480d8b8bd24233edcd2f (patch)
tree11eb08dcccd6ac008c935568bf6d32827c3b5122
parent88cff0f0fbcf64cb6c2fbad6cf57e2725475d0ee (diff)
UBI: block: Continue creating ubiblocks after an initialization error
If one ubi volume is corrupted but another is not, it should be possible to initialize that ubiblock from a kernel commandline which includes both of them. This patch changes the error handling behavior in initializing ubiblock to ensure that all parameters are attempted even if one fails. If there is a failure, it is logged on dmesg. It also makes error messages more descriptive by including the name of the UBI volume that failed. Tested: Formatted ubi volume /dev/ubi5_0 in a corrupt way and dev/ubi3_0 properly and included "ubi.block=5,0 ubi.block=3,0" on the kernel command line. At boot, I see the following in the console: [ 21.082420] UBI error: ubiblock_create_from_param: block: can't open volume on ubi5_0, err=-19 [ 21.084268] UBI: ubiblock3_0 created from ubi3:0(rootfs) Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--drivers/mtd/ubi/block.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 995e61c38f24..d82c63ae7c21 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -577,22 +577,28 @@ open_volume_desc(const char *name, int ubi_num, int vol_id)
577 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY); 577 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
578} 578}
579 579
580static int __init ubiblock_create_from_param(void) 580static void __init ubiblock_create_from_param(void)
581{ 581{
582 int i, ret; 582 int i, ret = 0;
583 struct ubiblock_param *p; 583 struct ubiblock_param *p;
584 struct ubi_volume_desc *desc; 584 struct ubi_volume_desc *desc;
585 struct ubi_volume_info vi; 585 struct ubi_volume_info vi;
586 586
587 /*
588 * If there is an error creating one of the ubiblocks, continue on to
589 * create the following ubiblocks. This helps in a circumstance where
590 * the kernel command-line specifies multiple block devices and some
591 * may be broken, but we still want the working ones to come up.
592 */
587 for (i = 0; i < ubiblock_devs; i++) { 593 for (i = 0; i < ubiblock_devs; i++) {
588 p = &ubiblock_param[i]; 594 p = &ubiblock_param[i];
589 595
590 desc = open_volume_desc(p->name, p->ubi_num, p->vol_id); 596 desc = open_volume_desc(p->name, p->ubi_num, p->vol_id);
591 if (IS_ERR(desc)) { 597 if (IS_ERR(desc)) {
592 pr_err("UBI: block: can't open volume, err=%ld\n", 598 pr_err(
593 PTR_ERR(desc)); 599 "UBI: block: can't open volume on ubi%d_%d, err=%ld",
594 ret = PTR_ERR(desc); 600 p->ubi_num, p->vol_id, PTR_ERR(desc));
595 break; 601 continue;
596 } 602 }
597 603
598 ubi_get_volume_info(desc, &vi); 604 ubi_get_volume_info(desc, &vi);
@@ -600,12 +606,12 @@ static int __init ubiblock_create_from_param(void)
600 606
601 ret = ubiblock_create(&vi); 607 ret = ubiblock_create(&vi);
602 if (ret) { 608 if (ret) {
603 pr_err("UBI: block: can't add '%s' volume, err=%d\n", 609 pr_err(
604 vi.name, ret); 610 "UBI: block: can't add '%s' volume on ubi%d_%d, err=%d",
605 break; 611 vi.name, p->ubi_num, p->vol_id, ret);
612 continue;
606 } 613 }
607 } 614 }
608 return ret;
609} 615}
610 616
611static void ubiblock_remove_all(void) 617static void ubiblock_remove_all(void)
@@ -631,10 +637,12 @@ int __init ubiblock_init(void)
631 if (ubiblock_major < 0) 637 if (ubiblock_major < 0)
632 return ubiblock_major; 638 return ubiblock_major;
633 639
634 /* Attach block devices from 'block=' module param */ 640 /*
635 ret = ubiblock_create_from_param(); 641 * Attach block devices from 'block=' module param.
636 if (ret) 642 * Even if one block device in the param list fails to come up,
637 goto err_remove; 643 * still allow the module to load and leave any others up.
644 */
645 ubiblock_create_from_param();
638 646
639 /* 647 /*
640 * Block devices are only created upon user requests, so we ignore 648 * Block devices are only created upon user requests, so we ignore
@@ -647,7 +655,6 @@ int __init ubiblock_init(void)
647 655
648err_unreg: 656err_unreg:
649 unregister_blkdev(ubiblock_major, "ubiblock"); 657 unregister_blkdev(ubiblock_major, "ubiblock");
650err_remove:
651 ubiblock_remove_all(); 658 ubiblock_remove_all();
652 return ret; 659 return ret;
653} 660}