All of lore.kernel.org
 help / color / mirror / Atom feed
* UBI fastmap torture script
@ 2012-06-18 16:29 Richard Weinberger
  0 siblings, 0 replies; only message in thread
From: Richard Weinberger @ 2012-06-18 16:29 UTC (permalink / raw)
  To: MTD Maling List; +Cc: Artem Bityutskiy


[-- Attachment #1.1: Type: text/plain, Size: 441 bytes --]

Hi!

If you want to test UBI fastmap you can use my torture.sh script.
Please adjust it to your needs (N, MTD device, UBI device, volume size).
WARNING: It erases the MTD device!

paranoia.diff is also very useful to catch errors.
It turns all ubi_asserts() into BUG() and adds an extra self check to detect
duplicated PEBs.
Also bit flip emulation and all other UBI self-checks are enabled by default.

Have fun!
//richard



[-- Attachment #1.2: torture.sh --]
[-- Type: application/x-shellscript, Size: 1828 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: paranoia.diff --]
[-- Type: text/x-patch; name="paranoia.diff", Size: 3264 bytes --]

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 1ad128d..1acefaf 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -928,6 +928,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
 	if (err)
 		goto out_free;
 
+	ubi->dbg->chk_gen = 1;
+	ubi->dbg->emulate_bitflips = 1;
+
 	err = ubi_attach(ubi);
 	if (err) {
 		ubi_err("failed to attach mtd%d, error %d", mtd->index, err);
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index d5d2645..a4fac6e 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -31,7 +31,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
 	if (unlikely(!(expr))) {                                             \
 		printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
 		       __func__, __LINE__, current->pid);                    \
-		dump_stack();                                                \
+		BUG();                                                \
 	}                                                                    \
 } while (0)
 
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index f4d2c79..7b49665 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1632,7 +1632,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 	int err, i, found_pebs = 0;
 	struct rb_node *rb1, *rb2;
 	struct ubi_ainf_volume *av;
-	struct ubi_ainf_peb *aeb, *tmp;
+	struct ubi_ainf_peb *aeb, *tmp, *x;
 	struct ubi_wl_entry *e;
 
 	ubi->used = ubi->erroneous = ubi->free = ubi->scrub = RB_ROOT;
@@ -1653,6 +1653,28 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 		INIT_LIST_HEAD(&ubi->pq[i]);
 	ubi->pq_head = 0;
 
+	ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) {
+		ubi_rb_for_each_entry(rb2, aeb, &av->root, u.rb) {
+			list_for_each_entry(x, &ai->erase, u.list) {
+				if (x->pnum == aeb->pnum) {
+					ubi_err("PEB: %i is in used/scrub and erase!", x->pnum);
+				}
+			}
+			list_for_each_entry(x, &ai->free, u.list) {
+				if (x->pnum == aeb->pnum) {
+					ubi_err("PEB: %i is in used/scrub and free!", x->pnum);
+				}
+			}
+		}
+	}
+	list_for_each_entry(aeb, &ai->erase, u.list) {
+		list_for_each_entry(x, &ai->free, u.list) {
+			if (x->pnum == aeb->pnum) {
+				ubi_err("PEB: %i is in erase and free!", x->pnum);
+			}
+		}
+	}
+
 	list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
 		cond_resched();
 
@@ -1819,7 +1841,7 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec)
 	if (ec != read_ec && read_ec - ec > 1) {
 		ubi_err("self-check failed for PEB %d", pnum);
 		ubi_err("read EC is %lld, should be %d", read_ec, ec);
-		dump_stack();
+		BUG();
 		err = 1;
 	} else
 		err = 0;
@@ -1849,7 +1871,7 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi,
 
 	ubi_err("self-check failed for PEB %d, EC %d, RB-tree %p ",
 		e->pnum, e->ec, root);
-	dump_stack();
+	BUG();
 	return -EINVAL;
 }
 
@@ -1877,6 +1899,6 @@ static int self_check_in_pq(const struct ubi_device *ubi,
 
 	ubi_err("self-check failed for PEB %d, EC %d, Protect queue",
 		e->pnum, e->ec);
-	dump_stack();
+	BUG();
 	return -EINVAL;
 }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-18 16:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-18 16:29 UBI fastmap torture script Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.