Skip to contentSkip to conversation

xfs: check v5 superblock features early

PATCH Applied Christoph Hellwig 3 participants 3 messages Jul 29 – Aug 3 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: check v5 superblock features early

When working on a new features that reuses the existing pad in the superblock, I noticed that mounting such a file system on an old kernel logs a rather confusing warning:

XFS (vdc): Metadir superblock padding fields must be zero.

This is because we only validate the various feature fields in v5 superblocks after the common superblock validation helper is called.

Fix this by calling the feature validation first.

Fixes eca383fcd63b ("xfs: refactor superblock verifiers")

---

Changes since v1:
- minimize the fix, and implement all the good ideas later

 fs/xfs/libxfs/xfs_sb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_sb.c +2 -2
index 47322adb7690..75f2a021ee6d 100644
@@ -1118,10 +1118,10 @@ xfs_sb_read_verify(
 	 * because _verify_common checks the on-disk values.
 	 */
 	__xfs_sb_from_disk(&sb, dsb, false);
-	error = xfs_validate_sb_common(mp, bp, &sb);
+	error = xfs_validate_sb_read(mp, &sb);
 	if (error)
 		goto out_error;
-	error = xfs_validate_sb_read(mp, &sb);
+	error = xfs_validate_sb_common(mp, bp, &sb);
 
 out_error:
 	if (error == -EFSCORRUPTED || error == -EFSBADCRC)
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Christoph Hellwig

When working on a new features that reuses the existing pad in the superblock, I noticed that mounting such a file system on an old kernel logs a rather confusing warning:

XFS (vdc): Metadir superblock padding fields must be zero.

Quoted 7 lines

This is because we only validate the various feature fields in v5 superblocks after the common superblock validation helper is called.

Fix this by calling the feature validation first.

Fixes eca383fcd63b ("xfs: refactor superblock verifiers")

Makes sense, and should probably get backported for the improved error message. Not sure if we care about pre-6.18 kernels though, since none of them really support metadir.

--D

Quoted 29 lines

---

Changes since v1:
- minimize the fix, and implement all the good ideas later

 fs/xfs/libxfs/xfs_sb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_sb.c +2 -2
index 47322adb7690..75f2a021ee6d 100644
@@ -1118,10 +1118,10 @@ xfs_sb_read_verify(
 	 * because _verify_common checks the on-disk values.
 	 */
 	__xfs_sb_from_disk(&sb, dsb, false);
-	error = xfs_validate_sb_common(mp, bp, &sb);
+	error = xfs_validate_sb_read(mp, &sb);
 	if (error)
 		goto out_error;
-	error = xfs_validate_sb_read(mp, &sb);
+	error = xfs_validate_sb_common(mp, bp, &sb);
 
 out_error:
 	if (error == -EFSCORRUPTED || error == -EFSBADCRC)
Signature · 1 line
2.53.0
maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

When working on a new features that reuses the existing pad in the superblock, I noticed that mounting such a file system on an old kernel logs a rather confusing warning:

XFS (vdc): Metadir superblock padding fields must be zero.

This is because we only validate the various feature fields in v5 superblocks after the common superblock validation helper is called.

[...]

Applied to for-next, thanks!

[1/1] xfs: check v5 superblock features early

      commit: eb6b2cc1fc8ad566d746d128a559989ff0bba5cc

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>