Re: [Yaffs] mmap, power-off, and data is lost

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
Subject: Re: [Yaffs] mmap, power-off, and data is lost
On Tuesday 08 April 2008 15:02:51 Louis JANG wrote:
> Hi Charles,
>
> Charles Manning 쓴 글:
> > On Monday 07 April 2008 19:00:40 Louis JANG wrote:
> >> Hi all,
> >>
> >> I'm using yaffs in several mobile platform, and using mmap interface to
> >> read/write contents of file in yaffs. it works well in normal situation,
> >> but it losts data when I turn off its power without unmount.
> >
> > With mmapping, the data lives in the page cache until it is flushed to
> > the fs.
> >
> > YAFFS will not see the data until the mmapping is flushed through. This
> > will only happen when the pages are sync'ed back to the fs by msync() or
> > when the page mapping is invalidated (page pushed out or munmap)
> >
> > As James says, msync should do what you need.
>
> I added msync before munmap, and data wasn't lost when I use MS_SYNC
> flag. I also tried with MS_ASYNC and wait about more than 10 seconds,
> but data was lost in this case.


The thing to do here is to inspect the kernel code (VFS and mmap code) and
determine what is actually happening during the MS_ASYNC case and munmap.

It could be that yaffs needs to do something on munmap, but I would have
expected the kernel mmap code to flush pahes on the unmap.

>
> However, the sample code invalidated mmap area by munmap already, and
> cached data should be flushed, but it wasn't. and I called sync command
> in shell also.
>
> Regards,
> Louis JANG
>
>
>
> _______________________________________________
> yaffs mailing list
>
> http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs