From e91046d26412ec21bcf6cd69257e27f6467c388a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 3 May 2021 17:23:43 +0200 Subject: [PATCH] Add XFS needsrepair support Signed-off-by: Javier Martinez Canillas --- ...srepair-in-the-supported-incompat-fe.patch | 79 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 7 +- 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 0202-xfs-Include-needsrepair-in-the-supported-incompat-fe.patch diff --git a/0202-xfs-Include-needsrepair-in-the-supported-incompat-fe.patch b/0202-xfs-Include-needsrepair-in-the-supported-incompat-fe.patch new file mode 100644 index 0000000..fbffc3c --- /dev/null +++ b/0202-xfs-Include-needsrepair-in-the-supported-incompat-fe.patch @@ -0,0 +1,79 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 3 May 2021 16:57:17 +0200 +Subject: [PATCH] xfs: Include needsrepair in the supported incompat features + list + +XFS now has an incompat feature flag to indicate that the filesystem needs +to be repaired. The Linux kernel refuses to mount a filesystem that has it +set and only the xfs_repair tool is able to clear that flag. + +The GRUB doesn't have the concept of mounting filesystems and just attempt +to read the files. But it does some sanity checking, before attempting to +read from a filesystem. + +Among the things that are tested, is if the super block only has set the +incompatible features flags that are supported by GRUB. If it contains any +flags that are not listed as supported, reading the XFS filesystem fails. + +Since GRUB doesn't attempt to detect if the filesystem is inconsistent nor +replays the journal, just ignore if a filesystem needs to be repaired too. + +But print a message if grub_xfs_mount() fails, to give more information to +the user about why that could had been the case. + +Suggested-by: Eric Sandeen +Signed-off-by: Javier Martinez Canillas +--- + grub-core/fs/xfs.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index 2ce76ec70f9..c4c1bca39a8 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -84,6 +84,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); + #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ + #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ + #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ ++#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ + + /* + * Directory entries with ftype are explicitly handled by GRUB code. +@@ -98,7 +99,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ + XFS_SB_FEAT_INCOMPAT_SPINODES | \ + XFS_SB_FEAT_INCOMPAT_META_UUID | \ +- XFS_SB_FEAT_INCOMPAT_BIGTIME) ++ XFS_SB_FEAT_INCOMPAT_BIGTIME | \ ++ XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) + + struct grub_xfs_sblock + { +@@ -307,6 +309,16 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data) + return 0; + } + ++static int ++grub_xfs_sb_needs_repair(struct grub_xfs_data *data) ++{ ++ return ((data->sblock.version & ++ grub_cpu_to_be16_compile_time (XFS_SB_VERSION_NUMBITS)) == ++ grub_cpu_to_be16_compile_time (XFS_SB_VERSION_5) && ++ (data->sblock.sb_features_incompat & ++ grub_cpu_to_be32_compile_time (XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR))); ++} ++ + /* Filetype information as used in inodes. */ + #define FILETYPE_INO_MASK 0170000 + #define FILETYPE_INO_REG 0100000 +@@ -949,6 +961,9 @@ grub_xfs_mount (grub_disk_t disk) + return data; + fail: + ++ if (grub_xfs_sb_needs_repair(data)) ++ grub_dprintf("xfs", "Filesystem needs repair\n"); ++ + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem"); + diff --git a/grub.patches b/grub.patches index 6ca168c..cd6807c 100644 --- a/grub.patches +++ b/grub.patches @@ -199,3 +199,4 @@ Patch0198: 0198-fs-Use-64bit-type-for-filesystem-timestamp.patch Patch0199: 0199-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch Patch0200: 0200-ieee1275-claim-more-memory.patch Patch0201: 0201-ieee1275-request-memory-with-ibm-client-architecture.patch +Patch0202: 0202-xfs-Include-needsrepair-in-the-supported-incompat-fe.patch diff --git a/grub2.spec b/grub2.spec index 56c834b..9f8918d 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.06~rc1 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -555,7 +555,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog -* Fri Apr 23 2021 Javier Martinez Canillas - 2.06~rc1-5 +* Mon May 03 2021 Javier Martinez Canillas - 2.06~rc1-7 +- Add XFS needsrepair support + +* Fri Apr 23 2021 Javier Martinez Canillas - 2.06~rc1-6 - Find and claim more memory for ieee1275 (dja) * Wed Apr 14 2021 Javier Martinez Canillas - 2.06~rc1-5