public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ted Ts'o" <tytso@mit.edu>
To: "D. Jansen" <d.g.jansen@googlemail.com>
Cc: Oliver Neukum <oneukum@suse.de>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	Dave Chinner <david@fromorbit.com>
Subject: Re: [rfc] Ignore Fsync Calls in Laptop_Mode
Date: Thu, 26 May 2011 09:31:55 -0400	[thread overview]
Message-ID: <20110526133155.GH9520@thunk.org> (raw)
In-Reply-To: <BANLkTimNjt4=9v33Z9Nr12xa6GmyJ-Ue5A@mail.gmail.com>

On Thu, May 26, 2011 at 01:16:45PM +0200, D. Jansen wrote:
> 
> exactly. so what now?

This needs to be solved at the application level.  So what we need is
a coordinating daemon which sends a message to all applications
saying, "ok, here's an opportunity to flush data to the disk; if you
have dirty files, or databases that has data that needs to be flushed,
send it now", and then a little while later, it sends a message to all
applications, "ok, we're going to let the disk spin down now, hold
your horses and don't send any data to the disk".

If an application has too much data buffered in memory, and either
because (a) it's getting nervous that it doesn't want to lose a huge
amount of critical user data, or (b) it's about to exit, so it really
needs to save its state to disk, or (c) the buffered data is taking up
too much space, so it needs to flush its in-memory buffers, then the
application sends a message to the coordinating daemon, saying,
"please give me permission to write", and then waits for the "ok, you
can write to the disk" message.

That way, if you have multiple database-using applications active on
the system at the same time, they can coordinate their access to the
disk, and in a way such that when they stop writing, the data left in
the application-level database is in a coherent state.

The kernel can't do this by arbitrarily stopping writes from going to
the disk because the kernel doesn't know --- and can't possibly know
--- when it is a safe time to cut off write access to the disk.  It
can try and guess, by stopping write access after an fsync(), but it
has to honor the fsync().  Consider what happens when an SMTP server
sends back a 200 OK message --- that gives permission for its opposite
number at the other end of the connection to delete the e-mail
message, since the local SMTP server has promised that the e-mail has
been saved to stable storage.  It can't make that promise if fsync()
has been rigged to lie.  

That's why at the end of the day, in order for application level data
coherency, the application has to be in control.  If you want to save
power by coordinating access to the disk, that coordination has to
happen at the application level.

						- Ted

  parent reply	other threads:[~2011-05-26 13:32 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 13:34 [rfc] Ignore Fsync Calls in Laptop_Mode Dennis Jansen
2011-05-19 13:43 ` Alan Cox
     [not found]   ` <BANLkTikFRwPY_qOQpPmCmNUJbBUsGcuGUw@mail.gmail.com>
     [not found]     ` <20110519153928.40521b93@lxorguk.ukuu.org.uk>
2011-05-19 15:01       ` D. Jansen
2011-05-19 15:02   ` D. Jansen
2011-05-20 15:34     ` Valdis.Kletnieks
2011-05-20  3:39 ` Dave Chinner
2011-05-20  6:01   ` D. Jansen
2011-05-22  0:48     ` Dave Chinner
2011-05-23  8:12       ` Oliver Neukum
2011-05-23 13:05         ` D. Jansen
2011-05-25  0:00         ` Dave Chinner
2011-05-25  6:50           ` Oliver Neukum
2011-05-26  7:01             ` D. Jansen
2011-05-26 10:49               ` Theodore Tso
     [not found]                 ` <BANLkTimNjt4=9v33Z9Nr12xa6GmyJ-Ue5A@mail.gmail.com>
2011-05-26 13:31                   ` Ted Ts'o [this message]
2011-05-26 16:05                     ` D. Jansen
2011-05-26 16:21                       ` Ted Ts'o
2011-05-27  7:12                         ` D. Jansen
2011-05-27 14:17                           ` Theodore Tso
2011-05-27 17:51                             ` david
2011-05-29 10:45                             ` D. Jansen
2011-05-30  1:53                               ` david
2011-05-30  7:13                                 ` Oliver Neukum
2011-05-30 12:55                                   ` Valdis.Kletnieks
2011-05-30 18:03                                     ` david
2011-05-30 13:55                                 ` D. Jansen
2011-05-30 18:02                                   ` david
2011-05-30 18:28                                     ` D. Jansen
2011-05-30 18:43                                       ` Valdis.Kletnieks
2011-05-30 19:54                                         ` D. Jansen
2011-05-30 18:45                                       ` david
2011-05-30 19:49                                         ` D. Jansen
2011-05-30 20:53                                           ` david
2011-05-30 21:24                                             ` D. Jansen
2011-05-30 22:41                                               ` david
2011-05-31  2:03                                               ` Ted Ts'o
2011-05-31  2:26                                                 ` david
2011-05-31 13:47                                                 ` D. Jansen
2011-05-31 18:23                                                   ` david
2011-05-31 18:37                                                     ` D. Jansen
2011-05-31 18:54                                                       ` david
2011-05-31 19:04                                                         ` D. Jansen
2011-06-02  7:42                                                 ` D. Jansen
2011-05-31  8:22                                               ` Valdis.Kletnieks
2011-05-30 22:10                                           ` Jesper Juhl
2011-05-31  6:48                                         ` Oliver Neukum
2011-05-26 19:31               ` Matthew Garrett
2011-05-27  7:22                 ` D. Jansen
2011-05-20 15:28 ` Valdis.Kletnieks
2011-05-20 16:40   ` D. Jansen
2011-05-20 22:03     ` torbenh
2011-05-21  8:23       ` D. Jansen
2011-05-23  8:22     ` Jesper Juhl

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=20110526133155.GH9520@thunk.org \
    --to=tytso@mit.edu \
    --cc=akpm@linux-foundation.org \
    --cc=d.g.jansen@googlemail.com \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oneukum@suse.de \
    /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