All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Hill <brian@houston-radar.com>
To: linux-mtd@lists.infradead.org
Subject: Re: ubifs_scan: corrupt empty space
Date: Sat, 27 Jun 2015 09:09:08 -0600	[thread overview]
Message-ID: <558EBC94.1090102@houston-radar.com> (raw)
In-Reply-To: <558E6CD5.70201@huawei.com>


On 6/27/2015 3:28 AM, Sheng Yong wrote:
> On 6/26/2015 10:31 PM, Brian Hill wrote:
>> I thought I might try and answer "what would happen?" myself with the nandsim kernel module, but I find it can't provide bitflips in erased data - they are always simulated as "perfect".
> Nandsim can generate bitflips by setting bitflips=n. Then read will set a random
> bitflip in the read buffer. But this does not always happen. You can read do_bit_flips()
> in drivers/mtd/nand/nandsim.c and you will see that only if (bitflips && prandom_u32() < (1<<22)),
> (but "prandom_u32() < (1 << 22)" seems unlikely happen) bitflip is generated. So if you
> would like to make bitflip likely happen, you could change the condition.
>
> thanks,
> Sheng

Sheng,
Bit flips are never simulated on erased pages, they are always 0xFFs.

static void read_page(struct nandsim *ns, int num)
{
	union ns_mem *mypage;

	if (ns->cfile) {
		if (!test_bit(ns->regs.row, ns->pages_written)) {
			NS_DBG("read_page: page %d not written\n", ns->regs.row);
			memset(ns->buf.byte, 0xFF, num);           <----- perfect 0xFFs
		} else {
			loff_t pos;
			ssize_t tx;

			NS_DBG("read_page: page %d written, reading from %d\n",
				ns->regs.row, ns->regs.column + ns->regs.off);
			if (do_read_error(ns, num))
				return;
			pos = (loff_t)NS_RAW_OFFSET(ns) + ns->regs.off;
			tx = read_file(ns, ns->cfile, ns->buf.byte, num, pos);
			if (tx != num) {
				NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx);
				return;
			}
			do_bit_flips(ns, num);        <----- not reached for erased pages
		}
		return;
	}


Thanks,
-Brian Hill

  reply	other threads:[~2015-06-27 15:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 14:31 ubifs_scan: corrupt empty space Brian Hill
2015-06-27  9:28 ` Sheng Yong
2015-06-27 15:09   ` Brian Hill [this message]
2015-06-27 20:11 ` Richard Weinberger
2015-06-27 20:34   ` nick

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=558EBC94.1090102@houston-radar.com \
    --to=brian@houston-radar.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 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.