From: Christoph Hellwig <hch@infradead.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Miklos Szeredi <miklos@szeredi.hu>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org,
Fei Lv <feilv@asrmicro.com>,
Chenglong Tang <chenglongtang@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] ovl: make fsync after metadata copy-up opt-in mount option
Date: Thu, 26 Mar 2026 22:45:38 -0700 [thread overview]
Message-ID: <acYZglh4iyauvDZj@infradead.org> (raw)
In-Reply-To: <CAOQ4uxge9QDMwnLr1+W0xF2GocnFWVrbhRdriaf5Qe+4KkrG4Q@mail.gmail.com>
On Wed, Mar 25, 2026 at 02:11:31PM +0100, Amir Goldstein wrote:
> When an overlayfs file is modified for the first time, copy up will
> create a copy of the lower file and its parent directories in the upper
> layer. Since the Linux filesystem API does not enforce any particular
> ordering on storing changes without explicit fsync(2) calls, in case
> of a system crash, the upper file could end up with no data at all
> (i.e. zeros), which would be an unusual outcome. To avoid this
> experience, overlayfs calls fsync(2) on the upper file before completing
> data copy up with rename(2) to make the copy up "atomic".
Sounds good so far.
> By default, overlayfs does not call fsync(2) on copied up directories,
> so after a crash, a copied up directory could be observed in the upper
> layer without some of its attributes.
This does sound a bit scary. How does a directory copy up work?
mkdir + adding the copies up entries, probably with some chmod or
chown thrown in?
> - "ordered": (default)
> Call fsync(2) on upper file before completion of data copy up.
> No fsync(2) is called on directory or metadata-only copy up.
"ordered" sounds like an odd name here. It's more like lazy or
"nodirfsync". And it might help to explain what this implies, which
is that the fsync on the files in the directory also sync the
directories out, because they are usually modified in the same
transaction, and a traditional simple log model implies that. That
traditional single log model also implies that you get the metadata
file fsync for free in that case. I.e. if you did:
for each file:
sync_file_range(file, .., SYNC_FILE_RANGE_WRITE |
SYNC_FILE_RANGE_WAIT_AFTER);
fsync(dir)
for each file:
fsync(file)
at least for xfs (and probably the others) you should get the
performance of your ordered mode with the durability guarantees
of the strict version.
next prev parent reply other threads:[~2026-03-27 5:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 14:57 [PATCH] ovl: make fsync after metadata copy-up opt-in mount option Amir Goldstein
2026-03-24 18:04 ` Chenglong Tang
2026-03-24 19:09 ` Amir Goldstein
2026-03-25 5:55 ` Christoph Hellwig
2026-03-25 12:03 ` Amir Goldstein
2026-03-25 13:11 ` Amir Goldstein
2026-03-27 5:45 ` Christoph Hellwig [this message]
2026-03-27 11:09 ` Amir Goldstein
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=acYZglh4iyauvDZj@infradead.org \
--to=hch@infradead.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=chenglongtang@google.com \
--cc=feilv@asrmicro.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox