mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Miklos Szeredi <miklos@szeredi.hu>,
	Amir Goldstein <amir73il@gmail.com>,
	 Christian Brauner <brauner@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	 Christoph Hellwig <hch@infradead.org>,
	Chris Mason <mason@kernel.org>,
	 Chengguang Xu <cgxu519@mykernel.net>,
	linux-unionfs@vger.kernel.org,  linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH v7 2/7] ovl: no fsync=relaxed without data integrity
Date: Wed, 18 Nov 2026 17:03:25 +0000	[thread overview]
Message-ID: <20261118-b4-ovl-containerized-sync-v7-2-54f45743fe55@toxicpanda.com> (raw)
In-Reply-To: <20261118-b4-ovl-containerized-sync-v7-0-54f45743fe55@toxicpanda.com>

A sync does not wait for a filesystem with SB_I_NO_DATA_INTEGRITY, which is
fuse, so that a server that does not answer cannot block it.

With fsync=relaxed, syncfs() and unmount of the overlay are going to write
the upper inodes one by one and wait for each.  fuse_write_inode() waits
for the server whatever the sync mode is, so they would wait for the
server once for every inode.

Do not resolve fsync=auto to fsync=relaxed on such an upper filesystem, and
fall back to fsync=on if fsync=relaxed was asked for.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 Documentation/filesystems/overlayfs.rst |  4 ++++
 fs/overlayfs/super.c                    | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/overlayfs.rst b/Documentation/filesystems/overlayfs.rst
index 1a59500834a1..8a007fbc5257 100644
--- a/Documentation/filesystems/overlayfs.rst
+++ b/Documentation/filesystems/overlayfs.rst
@@ -870,6 +870,10 @@ The default is "fsync=on" instead of "fsync=auto" with the module option
 "fsync_auto=N" or with the kernel config option
 CONFIG_OVERLAY_FS_FSYNC_AUTO=n.
 
+An upper filesystem that cannot guarantee data persistence on sync (fuse)
+does not get "fsync=relaxed".  "fsync=auto" means "fsync=on" there, and
+"fsync=relaxed" falls back to it.
+
 If the upper filesystem has no writeback (e.g. tmpfs), a non-default mode
 falls back to "fsync=off".
 
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5960974c5af2..31a58e28968c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -765,7 +765,8 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
 
 	/* fsync=auto that is not resolved to fsync=relaxed means fsync=on */
 	if (ofs->config.fsync_mode == OVL_FSYNC_AUTO && rename_whiteout &&
-	    mnt->mnt_sb->s_bdi != &noop_backing_dev_info)
+	    mnt->mnt_sb->s_bdi != &noop_backing_dev_info &&
+	    !(mnt->mnt_sb->s_iflags & SB_I_NO_DATA_INTEGRITY))
 		ofs->config.fsync_mode = OVL_FSYNC_RELAXED;
 
 	/*
@@ -1499,6 +1500,16 @@ static int ovl_fill_super_creds(struct fs_context *fc, struct super_block *sb)
 			ofs->config.fsync_mode = OVL_FSYNC_OFF;
 		}
 
+		/*
+		 * A sync does not wait for such an upper fs, whose server may
+		 * not answer.  A relaxed overlay waits for each upper inode.
+		 */
+		if ((upper_sb->s_iflags & SB_I_NO_DATA_INTEGRITY) &&
+		    ofs->config.fsync_mode == OVL_FSYNC_RELAXED) {
+			pr_warn("upper fs does not guarantee data integrity, falling back to fsync=on.\n");
+			ofs->config.fsync_mode = OVL_FSYNC_ON;
+		}
+
 		if (!ovl_should_sync(ofs)) {
 			ofs->errseq = errseq_sample(&upper_sb->s_wb_err);
 			if (errseq_check(&upper_sb->s_wb_err, ofs->errseq)) {

-- 
2.55.0


  parent reply	other threads:[~2026-11-18 17:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 17:03 [PATCH v7 0/7] ovl: only sync what was written through the overlay Josef Bacik
2026-11-18 17:03 ` [PATCH v7 1/7] ovl: expand fsync mount options Josef Bacik
2026-11-18 17:03 ` Josef Bacik [this message]
2026-11-18 18:00   ` [PATCH v7 2/7] ovl: no fsync=relaxed without data integrity Amir Goldstein
2026-11-18 17:03 ` [PATCH v7 3/7] fs: add sync_fs_and_bdev() Josef Bacik
2026-11-19  8:55   ` Jan Kara
2026-11-18 17:03 ` [PATCH v7 4/7] fs: add write_inode_for_sync() Josef Bacik
2026-11-19  9:14   ` Jan Kara
2026-11-19  9:47     ` OGAWA Hirofumi
2026-11-18 17:03 ` [PATCH v7 5/7] ovl: add a set of the inodes that a sync has to write Josef Bacik
2026-11-18 17:03 ` [PATCH v7 6/7] ovl: track an inode when it is modified Josef Bacik
2026-11-18 17:03 ` [PATCH v7 7/7] ovl: implement containerized syncfs for overlayfs Josef Bacik
2026-11-18 18:09   ` Amir Goldstein
2026-11-18 18:14 ` [PATCH v7 0/7] ovl: only sync what was written through the overlay 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=20261118-b4-ovl-containerized-sync-v7-2-54f45743fe55@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cgxu519@mykernel.net \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mason@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®