From manningc2@actrix.gen.nz Mon Apr 07 23:10:32 2008
Received: from smtp.firstline.co.nz ([203.167.210.162] helo=firstline.co.nz)
	by stoneboat.aleph1.co.uk with smtp (Exim 4.63)
	(envelope-from <manningc2@actrix.gen.nz>) id 1JizXf-0005xt-0S
	for yaffs@lists.aleph1.co.uk; Mon, 07 Apr 2008 23:10:31 +0100
Received: (qmail 31249 invoked by uid 453); 7 Apr 2008 22:10:03 -0000
X-Virus-Checked: Checked by ClamAV on firstline.co.nz
Received: from Unknown (HELO [192.168.0.29]) (10.14.0.253)
	by firstline.co.nz (qpsmtpd/0.40) with ESMTP;
	Tue, 08 Apr 2008 10:10:03 +1200
From: Charles Manning <manningc2@actrix.gen.nz>
To: yaffs@lists.aleph1.co.uk
Date: Tue, 8 Apr 2008 10:10:02 +1200
User-Agent: KMail/1.9.6
References: <47F9C698.5060608@mizi.com>
In-Reply-To: <47F9C698.5060608@mizi.com>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200804081010.02409.manningc2@actrix.gen.nz>
X-SA-Exim-Connect-IP: 203.167.210.162
X-SA-Exim-Mail-From: manningc2@actrix.gen.nz
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.0 required=5.0 tests=AWL,BAYES_00,SPF_NEUTRAL
	autolearn=no 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)
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: Mon, 07 Apr 2008 22:10:32 -0000

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.

>
> Please look at the attached sample code, and the following is its result.
>
> # ./a.out
> # ls -l
> -rwxr-xr-x 1 0 0 1024 Apr 7 14:37 mmap_test
> ...
> # sync
>
> ... power off without unmount, and power-on
>
> # ls -l
> -rwxr-xr-x 1 0 0 0 Apr 7 14:37 mmap_test
>
> I also waited for about 10 seconds before power off, but data was lost
> also.
>
> The above problem is not happened if I read mmap_test file before
> power-off(I used cat). and it's not happened if I unmount before. I also
> have tested the above problem with write api instead of mmap, it was not
> happened in this case.
>
> Regards,
> Louis JANG




