Linux NILFS development
 help / color / mirror / Atom feed
From: Yifan Feng <evanfengff@gmail.com>
To: Ryusuke Konishi <konishi.ryusuke@gmail.com>,
	Viacheslav Dubeyko <slava@dubeyko.com>
Cc: Eric Sandeen <sandeen@redhat.com>,
	linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yifan Feng <evanfengff@gmail.com>
Subject: [PATCH] nilfs2: keep the current mount options on remount
Date: Fri,  4 Dec 2026 19:28:40 -0800	[thread overview]
Message-ID: <20261205032840.96219-1-evanfengff@gmail.com> (raw)

nilfs_init_fs_context() fills every new context with the default
options, and nilfs_reconfigure() installs them as they are.  So a
remount that does not repeat nobarrier, errors=, order=strict and
discard resets them:

  # mount -t nilfs2 -o nobarrier,discard /dev/vda /mnt
  # findmnt -no OPTIONS /mnt
  rw,relatime,nobarrier,discard
  # mount -o remount,noatime /dev/vda /mnt
  # findmnt -no OPTIONS /mnt
  rw,noatime

mount(8) hides this when it is given the mount point only, because it
then passes the current options again.  Before the conversion to the
mount API a remount changed only the options that it named.

For a remount, start from the options in use.

Fixes: 36defdd9d7c6 ("nilfs2: convert to use the new mount API")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
On the for-next branch of nilfs2.git. Tested in QEMU with mount(2), mount(8) and fspick()/fsconfig(); with nobarrier the flush requests were counted before and after each remount.
Found and written with the help of an AI coding assistant.

 fs/nilfs2/super.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index ddad1e4f55ce..a4e17d6ee8d7 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1286,12 +1286,18 @@ static const struct fs_context_operations nilfs_context_ops = {
 static int nilfs_init_fs_context(struct fs_context *fc)
 {
 	struct nilfs_fs_context *ctx;
+	struct the_nilfs *nilfs;
 
 	ctx = kzalloc_obj(*ctx);
 	if (!ctx)
 		return -ENOMEM;
 
-	ctx->ns_mount_opt = NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER;
+	if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
+		nilfs = fc->root->d_sb->s_fs_info;
+		ctx->ns_mount_opt = nilfs->ns_mount_opt;
+	} else {
+		ctx->ns_mount_opt = NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER;
+	}
 	fc->fs_private = ctx;
 	fc->ops = &nilfs_context_ops;
 

base-commit: 499a46e4a0f0ff642d5fe2a53bb04a0de64cfe74
-- 
2.39.3 (Apple Git-146)


                 reply	other threads:[~2026-12-05  3:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261205032840.96219-1-evanfengff@gmail.com \
    --to=evanfengff@gmail.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=slava@dubeyko.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