Skip to contentSkip to conversation

xfs: preserve inode versioning across remounts

PATCH In review Eric Sandeen 4 participants 4 messages Jul 14, 2020 – Jul 15, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: preserve inode versioning across remounts

The MS_I_VERSION mount flag is exposed via the VFS, as documented in the mount manpages etc; see the iversion and noiversion mount options in mount(8).

As a result, mount -o remount looks for this option in /proc/mounts and will only send the I_VERSION flag back in during remount it it is present. Since it's not there, a remount will /remove/ the I_VERSION flag at the vfs level, and iversion functionality is lost.

xfs v5 superblocks intend to always have i_version enabled; it is set as a default at mount time, but is lost during remount for the reasons above.

The generic fix would be to expose this documented option in /proc/mounts, but since that was rejected, fix it up again in the xfs remount path instead, so that at least xfs won't suffer from this misbehavior.

--

fs/xfs/xfs_super.c +4 -0
index 379cbff438bc..9239985571af 100644
@@ -1714,6 +1714,10 @@ xfs_fc_reconfigure(
 	int			flags = fc->sb_flags;
 	int			error;
 
+	/* version 5 superblocks always support version counters. */
+	if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
+		fc->sb_flags |= SB_I_VERSION;
+
 	error = xfs_fc_validate_params(new_mp);
 	if (error)
 		return error;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Eric Sandeen

The MS_I_VERSION mount flag is exposed via the VFS, as documented in the mount manpages etc; see the iversion and noiversion mount options in mount(8).

As a result, mount -o remount looks for this option in /proc/mounts and will only send the I_VERSION flag back in during remount it it is present. Since it's not there, a remount will /remove/ the I_VERSION flag at the vfs level, and iversion functionality is lost.

xfs v5 superblocks intend to always have i_version enabled; it is set as a default at mount time, but is lost during remount for the reasons above.

The generic fix would be to expose this documented option in /proc/mounts, but since that was rejected, fix it up again in the xfs remount path instead, so that at least xfs won't suffer from this misbehavior.

--

fs/xfs/xfs_super.c +0 -0
index 379cbff438bc..9239985571af 100644

fs/xfs/xfs_super.c xfs_fc_reconfigure( · line 1723

Quoted 10 lines
fs/xfs/xfs_super.c +4 -0
@@ -1714,6 +1714,10 @@ xfs_fc_reconfigure(
 	int			flags = fc->sb_flags;
 	int			error;
 
+	/* version 5 superblocks always support version counters. */
+	if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
+		fc->sb_flags |= SB_I_VERSION;
+
 	error = xfs_fc_validate_params(new_mp);
 	if (error)
 		return error;

Looks fine.

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

The MS_I_VERSION mount flag is exposed via the VFS, as documented in the mount manpages etc; see the iversion and noiversion mount options in mount(8).

Quoted 8 lines

As a result, mount -o remount looks for this option in /proc/mounts and will only send the I_VERSION flag back in during remount it it is present. Since it's not there, a remount will /remove/ the I_VERSION flag at the vfs level, and iversion functionality is lost.

xfs v5 superblocks intend to always have i_version enabled; it is set as a default at mount time, but is lost during remount for the reasons above.

Looks good, this fixes the new mount API conversion, as the old code automatically added it. Maybe this wants a Fixes tag.

#3 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Eric Sandeen

The MS_I_VERSION mount flag is exposed via the VFS, as documented in the mount manpages etc; see the iversion and noiversion mount options in mount(8).

As a result, mount -o remount looks for this option in /proc/mounts and will only send the I_VERSION flag back in during remount it it is present. Since it's not there, a remount will /remove/ the I_VERSION flag at the vfs level, and iversion functionality is lost.

Quoted 8 lines
Quoted 3 lines

xfs v5 superblocks intend to always have i_version enabled; it is set as a default at mount time, but is lost during remount for the reasons above.

Looks good, this fixes the new mount API conversion, as the old code automatically added it. Maybe this wants a Fixes tag.

AFAICT (and from testing) this behavior predates the mount API conversion.

Thanks,
-Eric