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>,
	njs@pobox.com, bart@samwel.tk, jens.axboe@oracle.com
Subject: Re: [rfc] Ignore Fsync Calls in Laptop_Mode
Date: Thu, 26 May 2011 12:21:38 -0400	[thread overview]
Message-ID: <20110526162138.GN9520@thunk.org> (raw)
In-Reply-To: <BANLkTinTzNN2P45tgZAQ9FsL43CqyAJR3Q@mail.gmail.com>

On Thu, May 26, 2011 at 06:05:43PM +0200, D. Jansen wrote:
> Problem: any fsync call by any application spins up the hard disk any
> time even in laptop_mode

What you call a problem, I call a feature.  If an application doesn't
participate in the write aggregation protocol, the worst that happens
is that you waste battery power.  This I consider as a lesser evil
than data loss.

Similarly, if an application really _needs_ to write disk, and it
can't contact the coordinating daemon, or the coordinating daemon
doesn't respond in a reasonable amount of time, the application should
feel free to write the data to disk and fsync().  This might waste a
bit of power, but power is cheaper than lost data.

> Because though there is no possibility to destroy data that is on disk
> due to non FIFO flushing of application writes queued in the kernel,
> which seems to be the main kernel level problem, yet new problems come
> up.

I'm not sure what you're talking about here.  Buffered data can always
be reordered in terms of when it is written to disk.  This is
considered good, and normal.  If you want to guarantee that
application writes are pushed out to disk, then either (a) use
O_DIRECT, or (b) use fsync().  Those are your two options.

If we didn't (for example) reorder writes to avoid the hard disk head
from seeking all over the disk, that would actually cause more power
to be consumed!

> Now there is
> 1) special support needed on the application side.

Yep, because this is fundamentally an application-level problem, and
the kernel doesn't have enough semantic information to solve the
database coherency problem.

> 2) need for new out-of-kernel buffers.

Yes.  So?

> 3) need for inter-application write alignment nightmares. This sort of
> structure could cause very uncomfortable bugs that prevent writes from
> happening at all in cases that were not foreseen at all.

Huh?  I think you are talking about order that buffered writes happen,
and there's no problem here.  It's a feature that they can be
reordered.  See above.

> 4) need for resources wasted through yet another daemon.

A daemon doesn't have to take up much space.  If it is linked with all
of the GNOME libraries in the world, yeah, there'll be a problem, but
there's no reason that this daemon should take more than, say a few
tens of kilobytes at most.

> 5) If the _application_, but not the kernel crashes, the data is safe.
> In my experience this is the much more likely case than that the mail
> server on my netbook optimized for battery time receives an email in
> laptop mode, sends the other server "200" and then before the next
> commit window my battery slips out and it's all gone.

Huh?  What's the problem that you're worried about here.

> I think the alternative of ensuring the application writes are
> committed in order would make more sense:
> e..g a _user space library_ disables fsync etc. in laptop_mode if the
> user chooses to do so and kernel support for forced FIFO ordering or
> writes.
> This would fix 1) 2) 3) 4) 5) 6).

And if you do this to a mysql daemon, or to a firefox or chrome
process which uses sqllite, and you crash at a wrong time, the entire
database could be scrambled.  You can't fix this with your solution,
because you want to make fsync() lie to the database code.  And so all
of the extra work (and power) consumed by the database code to try to
make its database writes be safe, will be compromised by making
fsync() unreliable.

> So you've re-thought this "All that is necessary is a kernel patch to
> allow laptop_mode to disable fsync() calls(...)"
> (http://tytso.livejournal.com/2009/03/15/). That post had inspired my
> patch.

I was thinking about things only from a file system perspective.  The
problem is that more and more people are running databases or other
binary files which are updated in place on their laptops, and from a
more holistic perspective, we have to worry about making sure that
application-level databases are coherent in the face of a system
crash.  (For example, you drop your mobile phone, or your tablet, or
your laptop, and the battery slips out.)

						- Ted

  reply	other threads:[~2011-05-26 16:21 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
2011-05-26 16:05                     ` D. Jansen
2011-05-26 16:21                       ` Ted Ts'o [this message]
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=20110526162138.GN9520@thunk.org \
    --to=tytso@mit.edu \
    --cc=akpm@linux-foundation.org \
    --cc=bart@samwel.tk \
    --cc=d.g.jansen@googlemail.com \
    --cc=david@fromorbit.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=njs@pobox.com \
    --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