linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: Romain Le Disez <romain.le-disez@corp.ovh.com>
Cc: Stefan Ring <stefanrin@gmail.com>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [QUESTION] multiple fsync() vs single sync()
Date: Thu, 18 Oct 2018 13:43:35 +0200	[thread overview]
Message-ID: <20181018114335.vc7cdqpgcv34mnez@odin.usersys.redhat.com> (raw)
In-Reply-To: <2C57B701-747D-4603-9DA7-F4D766858C36@corp.ovh.com>

On Tue, Oct 16, 2018 at 02:09:27PM +0000, Romain Le Disez wrote:
> 
> > Le 16 oct. 2018 à 15:53, Stefan Ring <stefanrin@gmail.com> a écrit :
> > 
> > But in what order? If I understood correctly, with the single sync()
> > call, he might end up with a directory entry referencing an incomplete
> > file. Which should not be possible in the case with the two fsyncs.
> 
> In what order, this is exactly my question :)
> 
> We are creating hundreds or thousands of files in a row. Converting thousands of fsync() to one sync() would be a great performance improvement, but I want to be sure we are not taking any risk with data consistency.

I honestly don't remember on the top of my head, a sync() will cause the whole
XFS log to be flushed, and the flush order, I believe, will be according to how
the metadata got logged in. But, I do not believe it comes to the case. Reality
is, doesn't matter which is flushed first, file or directory metadata. If sync()
fails, you must assume nothing got flushed at all, and not 'guess' if something
got flushed in.
But, as I mentioned before, and also did Dave, unless you want to cause a whole
filesystem flush every time you have a file modified, use fsync() on the
specific files, instead a global sync().

Cheers


> 
> -- 
> Romain
> 

-- 
Carlos

  reply	other threads:[~2018-10-18 19:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 10:22 [QUESTION] multiple fsync() vs single sync() Romain Le Disez
2018-10-16 12:57 ` Carlos Maiolino
2018-10-16 13:53   ` Stefan Ring
2018-10-16 14:09     ` Romain Le Disez
2018-10-18 11:43       ` Carlos Maiolino [this message]
2018-10-17  1:16 ` Dave Chinner
2018-10-19  8:16   ` Romain Le Disez
2018-10-19 12:12     ` Dave Chinner

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=20181018114335.vc7cdqpgcv34mnez@odin.usersys.redhat.com \
    --to=cmaiolino@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=romain.le-disez@corp.ovh.com \
    --cc=stefanrin@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;
as well as URLs for NNTP newsgroup(s).