public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: MTD Maling List <linux-mtd@lists.infradead.org>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Subject: UBI fastmap torture script
Date: Mon, 18 Jun 2012 18:29:24 +0200	[thread overview]
Message-ID: <4FDF5764.6090404@nod.at> (raw)


[-- 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 --]

                 reply	other threads:[~2012-06-18 16:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FDF5764.6090404@nod.at \
    --to=richard@nod.at \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox