All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: "Clemens Gruber" <clemens.gruber@pqgruber.com>,
	"Lukáš Czerner" <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: Fast ext4 cleanup to avoid data loss after power failure
Date: Fri, 03 Oct 2014 10:44:05 -0500	[thread overview]
Message-ID: <542EC445.5030503@redhat.com> (raw)
In-Reply-To: <542EC343.7090905@pqgruber.com>

On 10/3/14 10:39 AM, Clemens Gruber wrote:
> On 10/03/2014 04:08 PM, Lukáš Czerner wrote:
>> What exactly is the problem you're trying to solve ? Does it concern
>> specific application ?
> 
> It's a software to control and configure dispensing equipment in a bar.
> The problem is that power is lost frequently and the only warning is the
> mentioned GPIO about 1.5 to 2 seconds in advance, then the caps are drained.
> This happens very often and I have to prevent it from damaging the
> filesystem.
> 
> I did not mention it before, because I was not sure if it is relevant,
> but I am running Linux 3.17-rc7 on the board.
> 
>> So what you expect to happen if the power failure happens in the
>> middle of the write to the eMMC ?
> 
> With the 1.5 second delay, I'd like to stop the application, before that
> happens.
> 
>> I'd avoid the need to deal with this at all. File system
>> (journal) itself will protect you from metadata corruption (file
>> system corruption). But the application has to protect it's own
>> important files for data consistency (data=journal will not help
>> you, nor commit=1).
>>
>> The usual and simple way for the application to deal with this is to
>> use temporary file, fsync the changes to make sure that everything
>> hit the disk and then atomically rename the file to replace the
>> original. That way your file will always by in consistent state. It
>> will either have the new content, or the old one, not mix of both.
> 
> Thank you, this approach sounds good! I will change the application
> accordingly.
> So the only necessary step to do when the GPIO triggers, is to quit the
> applications writing to the eMMC. If I use that write, fsync, rename
> strategy, I guess I could even SIGKILL them.

http://lwn.net/Articles/457667/

is a good overview of data persistence best practices, FWIW.

-Eric

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-10-03 15:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 13:09 Fast ext4 cleanup to avoid data loss after power failure Clemens Gruber
2014-10-03 14:08 ` Lukáš Czerner
2014-10-03 15:39   ` Clemens Gruber
2014-10-03 15:44     ` Eric Sandeen [this message]
2014-10-04  3:47       ` Theodore Ts'o
2014-10-06 22:04         ` Clemens Gruber

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=542EC445.5030503@redhat.com \
    --to=sandeen@redhat.com \
    --cc=clemens.gruber@pqgruber.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.