Linux Overlay Filesystem development
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: miklos@szeredi.hu, amir73il@gmail.com
Cc: linux-unionfs@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH] ovl: Allow changing default fsync_mode
Date: Tue, 23 Jun 2026 16:43:37 +0800	[thread overview]
Message-ID: <20260623084337.54344-1-laoar.shao@gmail.com> (raw)

We have enabled "volatile" fsync_mode on our Kubernetes production
environment to prevent container exit from being blocked when there
are many dirty pages to flush. This has worked well without introducing
any issues.

However, on some of our production servers, upgrading the container
runtime to support the "volatile" mount option is not straightforward [0].
To address this, we want to enable it by default within the kernel.

Add a Kconfig option to set the default fsync_mode at build time, and
allow it to be overridden dynamically via a module parameter when
loading overlayfs. This also aligns with how other features are
configured.

Link: https://github.com/containerd/containerd/issues/6406 [0]
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 fs/overlayfs/Kconfig  | 15 +++++++++++++++
 fs/overlayfs/params.c | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index 2ac67e04a6fb..4aeae8232c39 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -134,3 +134,18 @@ config OVERLAY_FS_DEBUG
 	  Say Y here to enable extra debugging checks in overlayfs.
 
 	  If unsure, say N.
+
+config OVERLAY_FS_FSYNC_MODE
+	int "Overlayfs: default fsync mode"
+	depends on OVERLAY_FS
+	range 0 2
+	default 1
+	help
+	  Set the default fsync mode for Overlayfs.
+
+	  0: volatile - Do not sync filesystem on fsync
+	  1: auto     - Automatically detect sync behavior (default)
+	  2: strict   - Always sync filesystem on fsync
+
+	  This can be overridden at runtime via the fsync_mode module
+	  parameter or per-mount with the 'fsync=' mount option.
diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c
index c93fcaa45d4a..e0c88cf19d51 100644
--- a/fs/overlayfs/params.c
+++ b/fs/overlayfs/params.c
@@ -153,11 +153,49 @@ static const char *ovl_fsync_mode(struct ovl_config *config)
 	return ovl_parameter_fsync[config->fsync_mode].name;
 }
 
+static int ovl_default_fsync = CONFIG_OVERLAY_FS_FSYNC_MODE;
 static int ovl_fsync_mode_def(void)
 {
-	return OVL_FSYNC_AUTO;
+	return ovl_default_fsync;
 }
 
+static int ovl_fsync_mode_set(const char *val, const struct kernel_param *kp)
+{
+	int i;
+	int *p = kp->arg;
+
+	if (!val)
+		return -EINVAL;
+
+	for (i = 0; i < ARRAY_SIZE(ovl_parameter_fsync); i++) {
+		if (sysfs_streq(val, ovl_parameter_fsync[i].name)) {
+			*p = ovl_parameter_fsync[i].value;
+			return 0;
+		}
+	}
+	return -EINVAL;
+}
+
+static int ovl_fsync_mode_get(char *buffer, const struct kernel_param *kp)
+{
+	int val = *(int *)kp->arg;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ovl_parameter_fsync); i++) {
+		if (ovl_parameter_fsync[i].value == val)
+			return sysfs_emit(buffer, "%s\n", ovl_parameter_fsync[i].name);
+	}
+	return sysfs_emit(buffer, "unknown\n");
+}
+
+static const struct kernel_param_ops ovl_fsync_mode_ops = {
+	.set = ovl_fsync_mode_set,
+	.get = ovl_fsync_mode_get,
+};
+
+module_param_cb(fsync_mode, &ovl_fsync_mode_ops, &ovl_default_fsync, 0644);
+MODULE_PARM_DESC(fsync_mode, "fsync mode: auto, volatile, strict (default: auto)");
+
 const struct fs_parameter_spec ovl_parameter_spec[] = {
 	fsparam_string_empty("lowerdir",    Opt_lowerdir),
 	fsparam_file_or_string("lowerdir+", Opt_lowerdir_add),
-- 
2.52.0


             reply	other threads:[~2026-06-23  8:43 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23  8:43 Yafang Shao [this message]
2026-06-23  9:00 ` [PATCH] ovl: Allow changing default fsync_mode Gao Xiang
2026-06-23  9:15   ` Yafang Shao
2026-06-23  9:25     ` Gao Xiang
2026-06-23  9:34       ` Yafang Shao
2026-06-23  9:49         ` Gao Xiang
2026-06-23  9:59           ` Yafang Shao
2026-06-23 10:06             ` Gao Xiang
2026-06-23 10:12             ` Gao Xiang
2026-06-23 10:18               ` Yafang Shao
2026-06-23 10:25                 ` Gao Xiang
2026-06-23 11:38                   ` Yafang Shao
2026-06-23 11:59                     ` Gao Xiang
2026-06-23 12:47                       ` Yafang Shao
2026-06-23 13:11                         ` Gao Xiang
2026-06-23 13:19                           ` Yafang Shao
2026-06-23 13:35                             ` Gao Xiang
2026-06-23 13:39                               ` Yafang Shao
2026-06-23 13:42                               ` Christoph Hellwig
2026-06-23 13:46                                 ` Yafang Shao
2026-06-23 13:47                                 ` Gao Xiang
2026-06-23 14:52                                   ` Amir Goldstein
2026-06-24  2:09                                     ` Yafang Shao
2026-06-24  2:28                                       ` Gao Xiang
2026-06-24  2:30                                         ` Yafang Shao
2026-06-24  3:17                                           ` Gao Xiang
2026-06-24  3:28                                             ` Yafang Shao
2026-06-24  3:36                                               ` Gao Xiang
2026-06-24  3:41                                                 ` Yafang Shao
2026-06-23 13:03             ` Gao Xiang

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=20260623084337.54344-1-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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