All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: MTD/NAND user-space ABI: interesting observation
Date: Fri, 14 Feb 2014 18:05:52 -0800	[thread overview]
Message-ID: <20140215020552.GR18440@ld-irv-0074> (raw)

Hi all,

Perhaps it's a non-issue, but I was realizing during some testing today
that there is no sound way to determine (in user-space) if a particular
raw read (i.e., from a /dev/mtdX) resulted in either a correctable bit
error or an uncorrectable ECC error. The current method used by
mtd-utils' nanddump is more or less a sequence of:

  ioctl(fd, ECCGETSTATS, &stat1);
  read(fd, buf, len);
  ioctl(fd, ECCGETSTATS, &stat2);
  if (stat2.corrected > stat1.corrected)
  	correctable bitflip;
  if (stat2.failed > stat1.failed)
  	uncorrectable error;

This is completely unsound if you are performing concurrent reads on the
same MTD device node (e.g., running two concurrent 'nanddump'
processes). The issue is pretty obvious once you study it, but I was
left scratching my head this afternoon when I had two separate nanddump
processes reporting bitflips at exactly the same times, at different
addresses!

I think this issue is probably not that important, since user-space raw
MTD accesses are really only good for testing/debugging, and any sane
solution would utilize a translation layer or special-purpose filesystem
(UBI, UBIFS, JFFS2, etc.) to handle -EUCLEAN and -EBADMSG (which is
presented properly in the MTD in-kernel API).

Just food for thought. Have a nice weekend!

Brian

                 reply	other threads:[~2014-02-15  2:06 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=20140215020552.GR18440@ld-irv-0074 \
    --to=computersforpeace@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 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.