[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] xfs: Print a warning if the filesystem needs to be repaired
From: |
Carlos Maiolino |
Subject: |
Re: [PATCH] xfs: Print a warning if the filesystem needs to be repaired |
Date: |
Tue, 20 Apr 2021 09:59:45 +0200 |
> Suggested-by: Eric Sandeen <esandeen@redhat.com>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
>
> grub-core/fs/xfs.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
> index 43023e03fb3..22e7e61d574 100644
> --- a/grub-core/fs/xfs.c
> +++ b/grub-core/fs/xfs.c
> @@ -79,6 +79,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
> #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in
> dirent */
> #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_NEEDSREPAIR (1 << 4) /* needs xfs_repair
> */
>
> /*
> * Directory entries with ftype are explicitly handled by GRUB code.
> @@ -300,6 +301,16 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data)
> return 0;
> }
>
> +static int
> +grub_xfs_sb_needsrepair(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
> @@ -915,6 +926,11 @@ grub_xfs_mount (grub_disk_t disk)
> if (!grub_xfs_sb_valid(data))
> goto fail;
>
> + if (grub_xfs_sb_needsrepair(data))
> + {
> + grub_printf (N_("Filesystem needs repair. Please run a XFS repair
> tool"));
> + }
> +
I'm not a grub developer, but from the XFS point of view, this looks fine.
Feel free to add my reviewed tag if it makes sense to you:
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
--
Carlos