From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lukas Czerner <lczerner@redhat.com>,
Ritesh Harjani <riteshh@linux.ibm.com>,
Theodore Ts'o <tytso@mit.edu>, Sasha Levin <sashal@kernel.org>,
linux-ext4@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 06/38] ext4: handle option set by mount flags correctly
Date: Mon, 24 Aug 2020 12:37:18 -0400 [thread overview]
Message-ID: <20200824163751.606577-6-sashal@kernel.org> (raw)
In-Reply-To: <20200824163751.606577-1-sashal@kernel.org>
From: Lukas Czerner <lczerner@redhat.com>
[ Upstream commit f25391ebb475d3ffb3aa61bb90e3594c841749ef ]
Currently there is a problem with mount options that can be both set by
vfs using mount flags or by a string parsing in ext4.
i_version/iversion options gets lost after remount, for example
$ mount -o i_version /dev/pmem0 /mnt
$ grep pmem0 /proc/self/mountinfo | grep i_version
310 95 259:0 / /mnt rw,relatime shared:163 - ext4 /dev/pmem0 rw,seclabel,i_version
$ mount -o remount,ro /mnt
$ grep pmem0 /proc/self/mountinfo | grep i_version
nolazytime gets ignored by ext4 on remount, for example
$ mount -o lazytime /dev/pmem0 /mnt
$ grep pmem0 /proc/self/mountinfo | grep lazytime
310 95 259:0 / /mnt rw,relatime shared:163 - ext4 /dev/pmem0 rw,lazytime,seclabel
$ mount -o remount,nolazytime /mnt
$ grep pmem0 /proc/self/mountinfo | grep lazytime
310 95 259:0 / /mnt rw,relatime shared:163 - ext4 /dev/pmem0 rw,lazytime,seclabel
Fix it by applying the SB_LAZYTIME and SB_I_VERSION flags from *flags to
s_flags before we parse the option and use the resulting state of the
same flags in *flags at the end of successful remount.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/20200723150526.19931-1-lczerner@redhat.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ext4/super.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 76c5529394395..92a6741c4bdd9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5342,7 +5342,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
{
struct ext4_super_block *es;
struct ext4_sb_info *sbi = EXT4_SB(sb);
- unsigned long old_sb_flags;
+ unsigned long old_sb_flags, vfs_flags;
struct ext4_mount_options old_opts;
int enable_quota = 0;
ext4_group_t g;
@@ -5385,6 +5385,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
if (sbi->s_journal && sbi->s_journal->j_task->io_context)
journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
+ /*
+ * Some options can be enabled by ext4 and/or by VFS mount flag
+ * either way we need to make sure it matches in both *flags and
+ * s_flags. Copy those selected flags from *flags to s_flags
+ */
+ vfs_flags = SB_LAZYTIME | SB_I_VERSION;
+ sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags);
+
if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) {
err = -EINVAL;
goto restore_opts;
@@ -5438,9 +5446,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
}
- if (*flags & SB_LAZYTIME)
- sb->s_flags |= SB_LAZYTIME;
-
if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) {
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
err = -EROFS;
@@ -5580,7 +5585,13 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
}
#endif
- *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME);
+ /*
+ * Some options can be enabled by ext4 and/or by VFS mount flag
+ * either way we need to make sure it matches in both *flags and
+ * s_flags. Copy those selected flags from s_flags to *flags
+ */
+ *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags);
+
ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
kfree(orig_data);
return 0;
--
2.25.1
next prev parent reply other threads:[~2020-08-24 17:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 16:37 [PATCH AUTOSEL 5.4 01/38] spi: stm32: clear only asserted irq flags on interrupt Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 02/38] jbd2: make sure jh have b_transaction set in refile/unfile_buffer Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 03/38] ext4: don't BUG on inconsistent journal feature Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 04/38] ext4: handle read only external journal device Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 05/38] jbd2: abort journal if free a async write error metadata buffer Sasha Levin
2020-08-24 16:37 ` Sasha Levin [this message]
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 07/38] ext4: handle error of ext4_setup_system_zone() on remount Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 08/38] ext4: correctly restore system zone info when remount fails Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 09/38] fs: prevent BUG_ON in submit_bh_wbc() Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 10/38] spi: stm32h7: fix race condition at end of transfer Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 11/38] spi: stm32: fix fifo threshold level in case of short transfer Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 12/38] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 13/38] spi: stm32: always perform registers configuration prior to transfer Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 14/38] drm/amd/powerplay: correct Vega20 cached smu feature state Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 15/38] drm/amd/powerplay: correct UVD/VCE PG state on custom pptable uploading Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 16/38] drm/amd/display: Switch to immediate mode for updating infopackets Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 17/38] libbpf: Handle GCC built-in types for Arm NEON Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 18/38] netfilter: avoid ipv6 -> nf_defrag_ipv6 module dependency Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 19/38] can: j1939: transport: j1939_xtp_rx_dat_one(): compare own packets to detect corruptions Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 20/38] ALSA: hda/realtek: Add model alc298-samsung-headphone Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 21/38] s390/cio: add cond_resched() in the slow_eval_known_fn() loop Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 22/38] ASoC: wm8994: Avoid attempts to read unreadable registers Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 23/38] selftests: disable rp_filter for icmp_redirect.sh Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 24/38] scsi: fcoe: Fix I/O path allocation Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 25/38] scsi: ufs: Fix possible infinite loop in ufshcd_hold Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 26/38] scsi: ufs: Improve interrupt handling for shared interrupts Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 27/38] scsi: ufs: Clean up completed request without interrupt notification Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 28/38] scsi: qla2xxx: Fix login timeout Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 29/38] scsi: qla2xxx: Check if FW supports MQ before enabling Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 30/38] scsi: qla2xxx: Fix null pointer access during disconnect from subsystem Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 31/38] Revert "scsi: qla2xxx: Fix crash on qla2x00_mailbox_command" Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 32/38] macvlan: validate setting of multiple remote source MAC addresses Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 33/38] net: gianfar: Add of_node_put() before goto statement Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 34/38] drm/amdgpu: disable gfxoff for navy_flounder Sasha Levin
2020-08-24 18:25 ` Alex Deucher
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 35/38] Revert "drm/amdgpu: disable gfxoff for navy_flounder" Sasha Levin
2020-08-24 18:25 ` Alex Deucher
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 36/38] powerpc/perf: Fix soft lockups due to missed interrupt accounting Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 37/38] arm64: Move handling of erratum 1418040 into C code Sasha Levin
2020-08-24 16:37 ` [PATCH AUTOSEL 5.4 38/38] arm64: Allow booting of late CPUs affected by erratum 1418040 Sasha Levin
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=20200824163751.606577-6-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=riteshh@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
/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
Powered by JetHome