public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <clm@fb.com>
To: <madthanu@gmail.com>, linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Ordering of directory operations maintained across system crashes in Btrfs?
Date: Mon, 3 Mar 2014 12:43:04 -0500	[thread overview]
Message-ID: <5314BF28.5040209@fb.com> (raw)
In-Reply-To: <CAJ6LpRpbKyETTOicfXjTXe15u0pqwe7rMkLcAUKrH1xyHOB1Vw@mail.gmail.com>

On 02/25/2014 09:01 PM, thanumalayan mad wrote:
> Hi all,
>
> Slightly complicated question.
>
> Assume I do two directory operations in a Btrfs partition (such as an
> unlink() and a rename()), one after the other, and a crash happens
> after the rename(). Can Btrfs (the current version) send the second
> operation to the disk first, so that after the crash, I observe the
> effects of rename() but not the effects of the unlink()?
>
> I think I am observing Btrfs re-ordering an unlink() and a rename(),
> and I just want to confirm that my observation is true. Also, if Btrfs
> does send directory operations to disk out of order, is there some
> limitation on this? Like, is this restricted to only unlink() and
> rename()?
>
> I am looking at some (buggy) applications that use Btrfs, and this
> behavior seems to affect them.

There isn't a single answer for this one.

You might have

Thread A:

ulink(foo);
rename(somefile, somefile2);
<crash>

This should always have the rename happen before or in the same 
transaction as the rename.

Thread A:

ulink(dirA/foo);
rename(dirB/somefile, dirB/somefile2);

Here you're at the mercy of what is happening in dirB.  If someone 
fsyncs that directory, it may hit the disk before the unlink.

Thread A:

ulink(foo);
rename(somefile, somefile2);
fsync(somefile);

This one is even fuzzier.  Backrefs allow us to do some file fsyncs 
without touching the directory, making it possible the unlink will hit 
disk after the fsync.

-chris





  parent reply	other threads:[~2014-03-03 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26  2:01 Ordering of directory operations maintained across system crashes in Btrfs? thanumalayan mad
2014-03-03 17:30 ` thanumalayan mad
2014-03-03 17:43 ` Chris Mason [this message]
2014-03-03 17:56   ` thanumalayan mad
2014-03-13 10:01     ` Goswin von Brederlow

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=5314BF28.5040209@fb.com \
    --to=clm@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=madthanu@gmail.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