nalika / rpms / grub2

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