[PATCH RFC 15/28] ocfs2: keep options that can't change on remount
Christian Brauner
brauner at kernel.org
Mon Oct 12 03:21:00 PDT 2026
ocfs2_check_set_options() insists on exactly one heartbeat mode and
ocfs2_reconfigure() refuses to change the data mode. But
ocfs2_init_fs_context() doesn't inherit the current mount options for a
reconfigure. So every remount that doesn't pass heartbeat= fails with
-EINVAL and on a data=writeback mount so does every remount that doesn't
pass data=writeback. That includes emergency remount (sysrq u) which
passes no options at all. So it WARNs in reconfigure_super() for every
ocfs2 that is mounted read-write:
(kworker/3:1,54,3):ocfs2_check_set_options:1243 ERROR: Invalid heartbeat mount options
forced remount of a ocfs2 fs returned -22
WARNING: fs/super.c:1133 at reconfigure_super+0x498/0xb20, CPU#3: kworker/3:1/54
A remount that does pass heartbeat= has the opposite problem. Every
option it doesn't repeat is reset to its default. So noacl turns into
acl, errors=panic and errors=continue turn into errors=remount-ro, and
barrier=1, nouser_xattr, coherency=buffered, intr, atime_quantum= and
preferred_slot= are dropped. localflocks is always dropped because the
parser ignores it on remount and inode64 is dropped unless it's passed
again.
So start a reconfigure from the current options instead, like exfat and
gfs2_init_fs_context() do. Then a remount only changes what it
specifies. That's the mount option flags, the atime quantum, the
preferred slot and whether a userspace cluster stack is used. Asking for
a different data mode still fails with -EINVAL. Asking for a different
heartbeat mode does too but now as "Invalid heartbeat mount options"
because the current mode is already set.
The next patch stops ocfs2 from setting SB_RDONLY after errors. An
errored ocfs2 then stays read-write as far as the VFS is concerned and
emergency remount would run into this for it as well.
Reproducer: mount any ocfs2, also with data=writeback, then
echo u > /proc/sysrq-trigger # "forced remount of a ocfs2 fs returned -22"
Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
---
fs/ocfs2/super.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index c62e389d4dd6..26041371a666 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1213,6 +1213,20 @@ static int ocfs2_init_fs_context(struct fs_context *fc)
mopt->resv_level = OCFS2_DEFAULT_RESV_LEVEL;
mopt->dir_resv_level = -1;
+ /*
+ * Start out with the current options so that a remount only changes
+ * what it specifies. Emergency remount (sysrq u) passes no options at
+ * all, and the heartbeat and data mode can't change.
+ */
+ if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
+ struct ocfs2_super *osb = OCFS2_SB(fc->root->d_sb);
+
+ mopt->mount_opt = osb->s_mount_opt;
+ mopt->atime_quantum = osb->s_atime_quantum;
+ mopt->slot = osb->preferred_slot;
+ mopt->user_stack = ocfs2_userspace_stack(osb);
+ }
+
fc->fs_private = mopt;
fc->ops = &ocfs2_context_ops;
--
2.53.0
More information about the linux-mtd
mailing list