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

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