Skip to contentSkip to conversation

Blockrom: badblock-free RO MTD blockdev access

PATCH In review Thilo Fromm 2 participants 2 messages May 7, 2012 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Blockrom: badblock-free RO MTD blockdev access

The blockrom MTD driver provides bad block free read access to MTDs via /dev/blockromX device files. Bad blocks are automatically skipped upon read, and reading continues with the next good block.

This allows for read-only filesystems to exist in MTDs with bad blocks:
usually the baddies are skipped when writing the filesystem into MTD by the tool performing the write (e.g. nandwrite). To successfully mount these filesystems, however, you will need a translation layer that skips bad blocks upon read as well. blockrom is such a translation layer.

---
 drivers/mtd/Kconfig    |   14 +++
 drivers/mtd/Makefile   |    1 +
 drivers/mtd/blockrom.c |  234 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/blockrom.c
drivers/mtd/Kconfig +14 -0
index 1e2cbf5..bbcbabc 100644
@@ -226,6 +226,20 @@ config MTD_BLOCK_RO
 	  You do not need this option for use with the DiskOnChip devices. For
 	  those, enable NFTL support (CONFIG_NFTL) instead.
 
+config MTD_BLOCK_ROM_BBFREE
+	tristate "Bad-block-skipiping readonly access to MTD devices"
+	depends on MTD_BLOCK!=y && MTD
+	help
+	  The blockrom MTD driver provides bad block free read access to MTDs via
+	  /dev/blockromX device files. Bad blocks are automatically skipped upon read,
+	  and reading continues with the next block.
+
+	  This allows for read-only filesystems to exist in MTDs with bad blocks:
+	  usually the baddies are skipped when writing the filesystem into MTD by
+	  the tool performing the write (e.g. nandwrite). To successfully mount 
+	  these filesystems, however, you will need a translation layer that skips 
+	  bad blocks upon read as well. blockrom is such a translation layer.
+
 config FTL
 	tristate "FTL (Flash Translation Layer) support"
 	depends on BLOCK
drivers/mtd/Makefile +1 -0
index 760abc5..2337097 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_CHAR)		+= mtdchar.o
 obj-$(CONFIG_MTD_BLKDEVS)	+= mtd_blkdevs.o
 obj-$(CONFIG_MTD_BLOCK)		+= mtdblock.o
 obj-$(CONFIG_MTD_BLOCK_RO)	+= mtdblock_ro.o
+obj-$(CONFIG_MTD_BLOCK_ROM_BBFREE)	+= blockrom.o
 obj-$(CONFIG_FTL)		+= ftl.o
 obj-$(CONFIG_NFTL)		+= nftl.o
 obj-$(CONFIG_INFTL)		+= inftl.o
drivers/mtd/blockrom.c new file +234 -0

234 lines not on this page · raw message

Signature · 1 line
1.7.7
#1 lore raw

Hello *.*,

Quoted 10 lines · Thilo Fromm

       The blockrom MTD driver provides bad block free read access to MTDs via /dev/blockromX device files. Bad blocks are automatically skipped upon read, and reading continues with the next good block.

       This allows for read-only filesystems to exist in MTDs with bad blocks:
       usually the baddies are skipped when writing the filesystem into MTD by the tool performing the write (e.g. nandwrite). To successfully mount these filesystems, however, you will need a translation layer that skips bad blocks upon read as well. blockrom is such a translation layer.

Some remarks:
- moved bad block mapping table generation to driver initialisation time. Further optimization opportunities include e.g. doing table generation in the background (work queue or kernel task).
The original driver did lazy block mapping, i.e. mapped when a block was accessed for the first time.
- driver handle already has "spare blocks" and "management blocks" fields which are currently unused but provide for addiition of a very simple scrubbing mechanism later on.

I understand that the main focus of the linux-mtd community is on ubi_blk for generic r/w block access, one layer above MTD. I provide this FTL for simple bad block-free r/o access directly on the MTD level in the hope that it is useful for generic read-only FS. Comments and suggestions are welcome.

I'm willing to put extra effort into blockrom should the linux-mtd community be interested into a merge despite of ubi_blk.

Regards,
Thilo

Signature · 8 lines
Dipl.-Ing (FH) Thilo Fromm, MSc., Embedded Systems Architect
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, D-10319 Berlin, Germany
Tel: +49 (30) 515 932 228   mailto:[email protected]
Fax: +49 (30) 515 932 77    http://www.dresearch.de
Amtsgericht: Berlin Charlottenburg, HRB 130120 B
Ust.-IDNr. DE273952058
Geschäftsführer: Dr. M. Weber, W. Mögle