xfs
[Top] [All Lists]

Re: [PATCH] v3 inodes are only valid on crc-enabled filesystems.

To: Roger Willcocks <roger@xxxxxxxxxxxxxxxx>
Subject: Re: [PATCH] v3 inodes are only valid on crc-enabled filesystems.
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Sun, 16 Aug 2015 10:42:42 +1000
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <C69467E1-642A-422A-8ECF-FDED92550B1B@xxxxxxxxxxxxxxxx>
References: <C69467E1-642A-422A-8ECF-FDED92550B1B@xxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Sun, Aug 16, 2015 at 01:14:55AM +0100, Roger Willcocks wrote:
> Fix an xfs_repair regression reported by Leslie Rhorer where a bad
> (v3) inode version number was not reset.
> 
> Signed-off-by: Roger Willcocks <roger@xxxxxxxxxxxxxxxx>
> ---
> db/check.c             | 2 +-
> include/xfs_dinode.h   | 3 ++-
> libxfs/xfs_inode_buf.c | 2 +-
> repair/dinode.c        | 7 +++----
> repair/prefetch.c      | 2 +-
> 5 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/db/check.c b/db/check.c
> index c4c972f..810fa55 100644
> --- a/db/check.c
> +++ b/db/check.c
> @@ -2637,7 +2637,7 @@ process_inode(
>               error++;
>               return;
>       }
> -     if (!XFS_DINODE_GOOD_VERSION(idic.di_version)) {
> +     if (!XFS_DINODE_GOOD_VERSION(&mp->m_sb, idic.di_version)) {
>               if (isfree || v)
>                       dbprintf(_("bad version number %#x for inode %lld\n"),
>                               idic.di_version, ino);
> diff --git a/include/xfs_dinode.h b/include/xfs_dinode.h
> index 623bbe8..40700e6 100644
> --- a/include/xfs_dinode.h
> +++ b/include/xfs_dinode.h
> @@ -19,7 +19,8 @@
> #define       __XFS_DINODE_H__
> 
> #define       XFS_DINODE_MAGIC                0x494e  /* 'IN' */
> -#define XFS_DINODE_GOOD_VERSION(v)   ((v) >= 1 && (v) <= 3)
> +#define XFS_DINODE_GOOD_VERSION(sb, v) \
> +     (xfs_sb_version_hascrc(sb) ? ((v) == 3) : ((v) == 1 || (v) == 2))

I'd make this a static inline function so it gets type checking and
it is easier to understand the logic at a glance. i.e. something
like:

static inline bool
xfs_dinode_good_version(struct xfs_mount *mp, __uint8_t version)
{
        if (version < 1 || version > 3)
                return false;
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                if (version != 3)
                        return false;
        } else if (version > 2)
                return false;

        return true;
}

Otherwise looks fine.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>