[RFC/PATCH] mtd: m25p80: set writebufsize

Artem Bityutskiy dedekind1 at gmail.com
Fri Feb 3 01:14:56 EST 2012


On Wed, 2012-02-01 at 11:11 +0200, Shmulik Ladkani wrote:
> On Tue, 31 Jan 2012 09:46:40 -0800 Brian Norris <computersforpeace at gmail.com> wrote:
> > I'm wondering now: how do we guarantee that we're picking the
> > *correct* writebufsize and not just one that *works*? It's only used
> > by UBI, I think, so it depends on UBI's needs.
> > 
> 
> According to mtd.h, 'writebufsize' should be set to the "Size of the
> write buffer used by the MTD".
> 
> m25p->page_size should be set to the size of the device's data buffer
> (used by the Page Program operation).
> 
> Hence for m25p80, 'flash->mtd.writebufsize = flash->page_size' seems
> right.
> 
> BTW 'writebufsize' is propagated to UBI's 'max_write_size' which
> currently affects UBIFS write-buffer size.
> 
> It should be set to "the maximum amount of bytes the underlying flash is
> able to program at a time" (according to ubifs/io.c).
> 
> Hence again, for m25p80, 'flash->page_size' seems adequate.

This parameter was introduced for NOR flashes, and in NAND flashes
context it looks weird. Probably we could document this better. But
basically, it describes how much data the driver is able to write at a
time. All NAND drivers write only one page at a time, so this parameter
should be set to NAND page size.

Imagine if you created a striping layer on top of 2 MTD devices to
speed-up the I/O. In this case you would most probably make
'writebufsize' = 2xNAND pages. UBIFS would then try to do I/O in
'writebufsize' units for optimal performance, unless there is a sync
command for example, in which case UBIFS would write the last chunk of
date in smaller 'min_io_size' (=NAND page size) unit to waste less
space.

UBIFS also needs to know max_write_size for recovery to calculate how
fare a corruption caused by an unclean reboot can span (on the above
example, a normal corruption can only affect 2 NAND pages).

To summarize:

mtd->writesize = UBIFS->min_io_size - normal min. I/O unit
mtd->writebufsize = UBIFS->max_write_size - how much data the driver may
write at a time, defines the max. corruption size, gives fastest I/O.

And there is also mtd->subpage_shft -> sub-page size :-) This exists on
some NANDs. UBI uses it to pack its headers more tightly and waste less
space. We do not make this to be our min_io_size because we assume the
I/O speed in subpage-sized units is slow. Indeed, in case of normal
NANDs the whole page is written anyway, just padded with 0xFFs.

Anyway, pushed to l2-mtd.git, thanks! Added
Cc: stable at kernel.org [2.6.38+] as well.

-- 
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120203/b24d982a/attachment-0001.sig>


More information about the linux-mtd mailing list