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: Louis JANG
Date:  
To: Charles Manning
CC: yaffs
Subject: Re: [Yaffs] mmap, power-off, and data is lost
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.

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