Blame SOURCES/0268-xfs-accept-filesystem-with-sparse-inodes.patch

f731ee
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f731ee
From: Eric Sandeen <sandeen@sandeen.net>
f731ee
Date: Tue, 15 May 2018 14:55:55 -0500
f731ee
Subject: [PATCH] xfs: accept filesystem with sparse inodes
f731ee
f731ee
The sparse inode metadata format became a mkfs.xfs default in
f731ee
xfsprogs-4.16.0, and such filesystems are now rejected by grub as
f731ee
containing an incompatible feature.
f731ee
f731ee
In essence, this feature allows xfs to allocate inodes into fragmented
f731ee
freespace.  (Without this feature, if xfs could not allocate contiguous
f731ee
space for 64 new inodes, inode creation would fail.)
f731ee
f731ee
In practice, the disk format change is restricted to the inode btree,
f731ee
which as far as I can tell is not used by grub.  If all you're doing
f731ee
today is parsing a directory, reading an inode number, and converting
f731ee
that inode number to a disk location, then ignoring this feature
f731ee
should be fine, so I've added it to XFS_SB_FEAT_INCOMPAT_SUPPORTED
f731ee
f731ee
I did some brief testing of this patch by hacking up the regression
f731ee
tests to completely fragment freespace on the test xfs filesystem, and
f731ee
then write a large-ish number of inodes to consume any existing
f731ee
contiguous 64-inode chunk.  This way any files the grub tests add and
f731ee
traverse would be in such a fragmented inode allocation.  Tests passed,
f731ee
but I'm not sure how to cleanly integrate that into the test harness.
f731ee
f731ee
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
f731ee
---
f731ee
 grub-core/fs/xfs.c | 16 +++++++++++++++-
f731ee
 1 file changed, 15 insertions(+), 1 deletion(-)
f731ee
f731ee
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
f731ee
index 72492915533..852155b1bf3 100644
f731ee
--- a/grub-core/fs/xfs.c
f731ee
+++ b/grub-core/fs/xfs.c
f731ee
@@ -76,8 +76,22 @@ GRUB_MOD_LICENSE ("GPLv3+");
f731ee
 
f731ee
 /* incompat feature flags */
f731ee
 #define XFS_SB_FEAT_INCOMPAT_FTYPE      (1 << 0)        /* filetype in dirent */
f731ee
+#define XFS_SB_FEAT_INCOMPAT_SPINODES   (1 << 1)        /* sparse inode chunks */
f731ee
+#define XFS_SB_FEAT_INCOMPAT_META_UUID  (1 << 2)        /* metadata UUID */
f731ee
+
f731ee
+/*
f731ee
+ * Directory entries with ftype are explicitly handled by grub code.
f731ee
+ *
f731ee
+ * We do not currently verify metadata UUID, so it is safe to read filesystems
f731ee
+ * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
f731ee
+ *
f731ee
+ * We do not currently read the inode btrees, so it is safe to read filesystems
f731ee
+ * with the XFS_SB_FEAT_INCOMPAT_SPINODES feature.
f731ee
+ */
f731ee
 #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
f731ee
-	(XFS_SB_FEAT_INCOMPAT_FTYPE)
f731ee
+	(XFS_SB_FEAT_INCOMPAT_FTYPE | \
f731ee
+	 XFS_SB_FEAT_INCOMPAT_SPINODES | \
f731ee
+	 XFS_SB_FEAT_INCOMPAT_META_UUID)
f731ee
 
f731ee
 struct grub_xfs_sblock
f731ee
 {