From louis@mizi.com Tue Apr 08 04:03:12 2008
Received: from mail.mizi.com ([61.107.31.33])
	by stoneboat.aleph1.co.uk with esmtps
	(TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.63)
	(envelope-from <louis@mizi.com>) id 1Jj46w-0005Vx-V6
	for yaffs@lists.aleph1.co.uk; Tue, 08 Apr 2008 04:03:12 +0100
Received: from [61.107.31.74] (peach.mizi.com [61.107.31.74])
	by mail.mizi.com (8.12.11/8.12.11) with ESMTP id m3832pU4019010;
	Tue, 8 Apr 2008 12:02:51 +0900
Message-ID: <47FAE05B.3050303@mizi.com>
Date: Tue, 08 Apr 2008 12:02:51 +0900
From: Louis JANG <louis@mizi.com>
Organization: MIZI Research, Inc.
User-Agent: Thunderbird 1.5.0.14pre (X11/20071023)
MIME-Version: 1.0
To: Charles Manning <manningc2@actrix.gen.nz>
References: <47F9C698.5060608@mizi.com>
	<200804081010.02409.manningc2@actrix.gen.nz>
In-Reply-To: <200804081010.02409.manningc2@actrix.gen.nz>
Content-Type: text/plain; charset=EUC-KR
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by mail.mizi.com id
	m3832pU4019010
X-SA-Exim-Connect-IP: 61.107.31.33
X-SA-Exim-Mail-From: louis@mizi.com
X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on
	stoneboat.aleph1.co.uk
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham
	version=3.2.3
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on stoneboat.aleph1.co.uk)
Cc: yaffs@lists.aleph1.co.uk
Subject: Re: [Yaffs] mmap, power-off, and data is lost
X-BeenThere: yaffs@lists.aleph1.co.uk
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion of YAFFS NAND flash filesystem <yaffs.lists.aleph1.co.uk>
List-Unsubscribe: <http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs>, 
	<mailto:yaffs-request@lists.aleph1.co.uk?subject=unsubscribe>
List-Archive: <http://lists.aleph1.co.uk/lurker/list/yaffs.html>
List-Post: <mailto:yaffs@lists.aleph1.co.uk>
List-Help: <mailto:yaffs-request@lists.aleph1.co.uk?subject=help>
List-Subscribe: <http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs>,
	<mailto:yaffs-request@lists.aleph1.co.uk?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2008 03:03:13 -0000

Hi Charles,

Charles Manning =BE=B4 =B1=DB:
> On Monday 07 April 2008 19:00:40 Louis JANG wrote:
>  =20
>> Hi all,
>>
>> I'm using yaffs in several mobile platform, and using mmap interface t=
o
>> read/write contents of file in yaffs. it works well in normal situatio=
n,
>> but it losts data when I turn off its power without unmount.
>>    =20
>
> 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=20
> only happen when the pages are sync'ed back to the fs  by msync() or  w=
hen=20
> the page mapping is invalidated (page pushed out or munmap)
>
> As James says, msync should do what you need.
>  =20
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



