[PATCH] mtd: Add sysfs attribute for mtd OOB available size

Boris Brezillon boris.brezillon at bootlin.com
Tue Apr 3 01:43:54 PDT 2018


On Tue, 3 Apr 2018 10:46:58 +0800
xiaolei li <xiaolei.li at mediatek.com> wrote:

> Hello Boris,
> 
> On Mon, 2018-04-02 at 14:15 +0200, Boris Brezillon wrote:
> > Hi Xiaolei,
> > 
> > On Mon, 2 Apr 2018 16:20:10 +0800
> > Xiaolei Li <xiaolei.li at mediatek.com> wrote:
> >   
> > > Expose mtd OOB available size by sysfs file. Then users can get available
> > > OOB size by accessing /sys/class/mtd/mtdX/oobavail.  
> > 
> > May I ask why you need to expose that? I'm not against exposing new
> > things through sysfs, but since this is part of the ABI, I'd like to be
> > sure we actually need it.
> >   
> That is user-space can write OOB data through ioctl MEMWRITE now.
> If OOB operation mode is MTD_OPS_AUTO_OOB, user should know how many
> OOB available bytes it can use. But I didn't find a way to get it. (If
> there is already a method, please kindly let me know, thanks.)

Nope. We have the ECCGETLAYOUT ioctl, but it's not reliable because of
the MTD_MAX_OOBFREE_ENTRIES limitation.

> 
> One problem I know is to do Jffs2 type flash erase using MTD user-space
> tool flash_erase. flash_erase tool will program "cleanmarker" into OOB
> free area, but it can not get OOB available size.

That's a good reason to expose this property indeed. Do you plan to fix
mtd-utils to use the sysfs value when it's available? Also, do we need
to expose the ECC/free layout as done with the
ECCGETLAYOUT/MEMGETOOBSEL ioctls?




More information about the Linux-mediatek mailing list