linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@innominate.de>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: [RFC] Generic deferred file writing
Date: Sat, 30 Dec 2000 19:58:10 +0100	[thread overview]
Message-ID: <00123020452307.00966@gimli> (raw)
In-Reply-To: <Pine.LNX.4.10.10012291913350.1722-100000@penguin.transmeta.com>
In-Reply-To: <Pine.LNX.4.10.10012291913350.1722-100000@penguin.transmeta.com>

When I saw you put in the if (PageDirty) -->writepage and related code
over the last couple of weeks I was wondering if you realize how close
we are to having generic deferred file writing in the VFS.  I took some
time today to code this little hack and it comes awfully close to doing
the job.  However, *** Warning, do not run this on a machine you care
about, it will mess it up ***.

The advantages of deferred file writing are pretty obvious.  Right now
we are deferring just the writeout of data to the disk, but we can also
defer the disk mapping, so that metadata blocks don't have to stay
around in cache waiting for data blocks to get mapped into them one at
a time - a whole group can be done in one flush.  There is more scope
for the filesystem to optimize allocation - we just need some kind of
->get_blocks call that maps n file blocks in one operation.  Sometimes
we'll be able to write files, read them back and erase them without
ever hitting the disk, or even the filesystem.  Sequences of short
writes will cost a lot less cpu and hit less cache.  There are probably
other advantages as well.

For this to work properly there has to be an analog of kflushd for
pages.  We don't have that yet, and it's some distance away - so I'm
not even beginning to suggest this is a 2.4.0 thing.

In the patch below I didn't try to write the error handling exactly
right and the indenting is wrong.  It's just meant to show the idea
clearly.  Instead of mapping each file page to storage as we normally do
in generic_file_write we just mark it dirty and let page_launder or
Marcelo's new flushing code call the filesystem later.

This code worked well enough to copy some files and directories in uml,
and still have them there after a reboot.  Beyond that - patching it
into test13-pre5 on a real machine resulted in a toasted passwd file,
so there's some work to do yet.

Here it is...

--- 2.4.0-test12.clean/mm/filemap.c	Sat Dec  9 09:13:23 2000
+++ 2.4.0-test12/mm/filemap.c		Sat Dec 30 19:56:24 2000
@@ -2449,6 +2449,16 @@
 			PAGE_BUG(page);
 		}
 
+	if (!offset && bytes == PAGE_SIZE)
+	{
+		kaddr = page_address(page);
+		status = copy_from_user(kaddr+offset, buf, bytes);
+		flush_dcache_page(page);
+		SetPageUptodate(page);
+		SetPageDirty(page); /* set_page_dirty in test13 */
+	}
+	else
+	{
 		status = mapping->a_ops->prepare_write(file, page, offset, offset+bytes);
 		if (status)
 			goto unlock;
@@ -2458,6 +2468,7 @@
 		if (status)
 			goto fail_write;
 		status = mapping->a_ops->commit_write(file, page, offset, offset+bytes);
+	}
 		if (!status)
 			status = bytes;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-12-30 20:18 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-30  0:25 test13-pre6 Linus Torvalds
2000-12-30  0:49 ` test13-pre6 Alexander Viro
2000-12-30  1:03   ` test13-pre6 Linus Torvalds
2000-12-30 18:09     ` test13-pre6 Alexander Viro
2000-12-30  2:25 ` test13-pre6 Daniel Phillips
2000-12-30  3:16   ` test13-pre6 Linus Torvalds
2000-12-30 18:58     ` Daniel Phillips [this message]
2000-12-30 20:05       ` [RFC] Generic deferred file writing Linus Torvalds
2000-12-30 20:06       ` Alexander Viro
2000-12-30 20:21         ` Linus Torvalds
2000-12-30 21:10           ` Andreas Dilger
2000-12-30 21:46           ` Alexander Viro
2000-12-30 23:12             ` Daniel Phillips
2000-12-30 22:00           ` Eric W. Biederman
2000-12-30 22:44             ` Linus Torvalds
2000-12-31  0:26               ` Eric W. Biederman
2000-12-31  1:02             ` Andrea Arcangeli
2000-12-31  1:13               ` Chris Wedgwood
2000-12-31  1:50               ` Alexander Viro
2000-12-31  2:34                 ` Andrea Arcangeli
2000-12-31  2:09               ` Roman Zippel
2000-12-31  2:28                 ` Linus Torvalds
2000-12-31 12:58                   ` Roman Zippel
2001-04-21 20:06                     ` Races in affs_unlink(), affs_rmdir() and affs_rename() Alexander Viro
2001-04-21 22:16                       ` Roman Zippel
2001-04-22  5:53                         ` Alexander Viro
2001-04-22 12:57                           ` Roman Zippel
2001-04-22 13:15                             ` Alexander Viro
2000-12-31 14:38                   ` [RFC] Generic deferred file writing Andrea Arcangeli
2000-12-31 16:33                     ` Linus Torvalds
2000-12-31 16:50                       ` Andrea Arcangeli
2000-12-31 16:51                       ` Alexander Viro
2000-12-31 17:12                         ` Linus Torvalds
2000-12-31 18:30                   ` Daniel Phillips
2000-12-31 18:44                     ` Linus Torvalds
2000-12-31 19:10                       ` Daniel Phillips
2000-12-31 19:31                         ` Linus Torvalds
2000-12-31 21:03                       ` Roman Zippel
2000-12-31 21:32                         ` Linus Torvalds
2001-01-02 18:27                   ` Chris Mason
2000-12-30  3:08 ` test13-pre6 (Fork Bug with Athlons? Temporary Fix) Byron Stanoszek
2000-12-30  3:36   ` Linus Torvalds
2000-12-30  5:55     ` Andi Kleen
2000-12-30  5:13   ` Linus Torvalds
2000-12-30  8:13   ` Graham Murray
2000-12-30  4:21 ` test13-pre6 Dan Aloni
2001-01-04 20:23 ` test13-pre6 Stephen C. Tweedie
2001-01-04 22:15   ` test13-pre6 stewart
     [not found] <Pine.LNX.4.10.10012311726230.1671-100000@penguin.transmeta.com>
2001-01-01  2:50 ` [RFC] Generic deferred file writing Roman Zippel
2001-01-01  3:47   ` Alexander Viro
2001-01-01 12:44     ` Roman Zippel
2001-01-01 15:16       ` Alexander Viro
2001-01-02  3:00         ` Roman Zippel
2001-01-02  5:00           ` Alexander Viro
2001-01-02 16:53             ` Roman Zippel
2001-01-01 20:00     ` Daniel Phillips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00123020452307.00966@gimli \
    --to=phillips@innominate.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).