All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Nikhilesh Reddy <reddyn@codeaurora.org>, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] ubifs: Add new mount option to force fdatasync before rename
Date: Fri, 2 Oct 2015 23:38:40 +0200	[thread overview]
Message-ID: <560EF960.50808@nod.at> (raw)
In-Reply-To: <560984B4.7090105@codeaurora.org>

Hi!

Am 28.09.2015 um 20:19 schrieb Nikhilesh Reddy:
> The rename operation in UBIFS is synchronous (or nearly synchronous)
> while the write operation is not. This can result in zero length files when
> renaming of files followed by an abrupt power down or a crash.
> 
> For example:
> 1) Say a file a.txt exists with size 1KB.
> 2) Create a file b.tmp (open)
> 3) Update the data in b.tmp with new values (write and close)
> 4) rename b.tmp to a.txt
> 5) Abrupt power down or crash
> 
> This above scenario can result in a.txt becoming a file of zero length and
> giving the impression of a.txt being truncated.
> This scenario can ofcourse be prevented by calling fsync or fdatasync
> before the rename operation.

I gave this a try and hacked up something to emulate a powercut *exactly* after
rename() in UBIFS.

fd = open("b.tmp", ...)
write(fd, "foo", ...)
close(fd)
rename("b.tmp", "a.txt")
^---- powercut

After remounting UBIFS both a.txt and b.tmp are present
but b.tmp is truncated. Not a.txt as you said.

Can you please double check?
I want to make sure that we're talking about the same things.

Thanks,
//richard

  parent reply	other threads:[~2015-10-02 21:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 18:19 [PATCH] ubifs: Add new mount option to force fdatasync before rename Nikhilesh Reddy
2015-09-28 19:38 ` Richard Weinberger
2015-09-28 20:38   ` Nikhilesh Reddy
2015-09-28 20:49     ` Richard Weinberger
2015-09-29 17:04       ` Nikhilesh Reddy
2015-09-29 17:52         ` Richard Weinberger
2015-10-02 21:38 ` Richard Weinberger [this message]
2015-10-05 18:05   ` Nikhilesh Reddy
2015-10-06  8:09     ` Richard Weinberger
2015-10-13 18:41       ` Nikhilesh Reddy
2015-10-15 19:16         ` Richard Weinberger

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=560EF960.50808@nod.at \
    --to=richard@nod.at \
    --cc=linux-mtd@lists.infradead.org \
    --cc=reddyn@codeaurora.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.