From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Hudec Subject: Re: Page cache and write Date: Mon, 19 May 2003 22:27:33 +0200 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20030519202733.GC944@vagabond> References: <20030519201144.4DA04437A@blood.actrix.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from cimice4.lam.cz ([212.71.168.94]:2788 "EHLO vagabond.cybernet.cz") by vger.kernel.org with ESMTP id S262737AbTESUOi (ORCPT ); Mon, 19 May 2003 16:14:38 -0400 Received: from bulb by vagabond.cybernet.cz with local (Exim 3.36 #1 (Debian)) id 19HrEM-0005IS-00 for ; Mon, 19 May 2003 22:27:34 +0200 To: linux-fsdevel@vger.kernel.org Content-Disposition: inline In-Reply-To: <20030519201144.4DA04437A@blood.actrix.co.nz> List-Id: linux-fsdevel.vger.kernel.org On Tue, May 20, 2003 at 08:13:45AM +1200, Charles Manning wrote: > When writing the YAFFS NAND file system, I added an internal caching layer > that caches both short reads and writes. This is used in most situations, but > not in Linux. > > Under Linux, YAFFS uses generic_file_read and generic_file_write and thus any > caching is provided bythe page cache. It was my understanding that the page > cache will cache up writes. However, from the experiences of some YAFFS users > this is not the case and enabling the YAFFS internal caching resulted in > dramatic speedup (eg 15 seconds-> 3 seconds for a certain code sequence). > > I now want to understand whether I should enable internal caching in YAFFS or > whether I should be using the page cache differently. > > Consider the code > > for(i=0; i < 1000; i++) > write(f,b,1); > > On a flash file system this would take a long time if each write goes all the > way to the fs. I assume too that this code does not result in 1000 disk > writes on a regular file system (eg ext2). > > Questions: Does the page cache do anything to help in this case? > > Question: Assuming ext2 does not do 1000 physical writes to disk, where does > the consolidation happen? Writes through page-cache work like this: When a page should be written to, it is first read. Then the modification is made in memory and the page is marked dirty. When something gets to it, it writes the page to disk. The something might be either memory allocator when it desperately needs a page or a bdflush when it decides the page is dirty for too long. (Hope I don't remember it too wrong). ------------------------------------------------------------------------------- Jan 'Bulb' Hudec