From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 16/16] xfs: kill xfs_sb_version_has_v3inode()
Date: Wed, 14 Jul 2021 16:24:44 -0700 [thread overview]
Message-ID: <20210714232444.GJ22402@magnolia> (raw)
In-Reply-To: <20210714041912.2625692-17-david@fromorbit.com>
On Wed, Jul 14, 2021 at 02:19:12PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> All callers to xfs_dinode_good_version() and XFS_DINODE_SIZE() in
> both the kernel and userspace have a xfs_mount structure available
> which means they can use mount features checks instead looking
> directly are the superblock.
>
> Convert these functions to take a mount and use a xfs_has_v3inodes()
> check and move it out of the libxfs/xfs_format.h file as it really
> doesn't have anything to do with the definition of the on-disk
> format.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> fs/xfs/libxfs/xfs_format.h | 18 +++---------------
> fs/xfs/libxfs/xfs_ialloc.c | 3 +--
> fs/xfs/libxfs/xfs_inode_buf.c | 2 +-
> fs/xfs/libxfs/xfs_inode_buf.h | 11 ++++++++++-
> 4 files changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index e1ecb3237075..452ae4114c92 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -399,18 +399,6 @@ xfs_sb_has_incompat_log_feature(
> }
>
>
> -/*
> - * v5 file systems support V3 inodes only, earlier file systems support
> - * v2 and v1 inodes.
> - */
> -static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,
> - uint8_t version)
> -{
> - if (xfs_sb_is_v5(sbp))
> - return version == 3;
> - return version == 1 || version == 2;
> -}
> -
> static inline bool
> xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino)
> {
> @@ -877,12 +865,12 @@ enum xfs_dinode_fmt {
> /*
> * Inode size for given fs.
> */
> -#define XFS_DINODE_SIZE(sbp) \
> - (xfs_sb_is_v5(sbp) ? \
> +#define XFS_DINODE_SIZE(mp) \
> + (xfs_has_crc(mp) ? \
> sizeof(struct xfs_dinode) : \
> offsetof(struct xfs_dinode, di_crc))
> #define XFS_LITINO(mp) \
> - ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(&(mp)->m_sb))
> + ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(mp))
>
> /*
> * Inode data & attribute fork sizes, per inode.
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 51768f8999e5..702d4e11dd7f 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -337,7 +337,6 @@ xfs_ialloc_inode_init(
> xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));
> for (i = 0; i < M_IGEO(mp)->inodes_per_cluster; i++) {
> int ioffset = i << mp->m_sb.sb_inodelog;
> - uint isize = XFS_DINODE_SIZE(&mp->m_sb);
>
> free = xfs_make_iptr(mp, fbuf, i);
> free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
> @@ -354,7 +353,7 @@ xfs_ialloc_inode_init(
> } else if (tp) {
> /* just log the inode core */
> xfs_trans_log_buf(tp, fbuf, ioffset,
> - ioffset + isize - 1);
> + ioffset + XFS_DINODE_SIZE(mp) - 1);
> }
> }
>
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 08b4413d3ac4..327d05300f24 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -58,7 +58,7 @@ xfs_inode_buf_verify(
> dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
> unlinked_ino = be32_to_cpu(dip->di_next_unlinked);
> di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
> - xfs_dinode_good_version(&mp->m_sb, dip->di_version) &&
> + xfs_dinode_good_version(mp, dip->di_version) &&
> xfs_verify_agino_or_null(mp, agno, unlinked_ino);
> if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
> XFS_ERRTAG_ITOBP_INOTOBP))) {
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index 7f865bb4df84..585ed5a110af 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -21,7 +21,7 @@ struct xfs_imap {
>
> int xfs_imap_to_bp(struct xfs_mount *mp, struct xfs_trans *tp,
> struct xfs_imap *imap, struct xfs_buf **bpp);
> -void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *);
> +void xfs_dinode_calc_crc(struct xfs_mount *mp, struct xfs_dinode *dip);
> void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to,
> xfs_lsn_t lsn);
> int xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
> @@ -42,4 +42,13 @@ static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv)
> struct timespec64 xfs_inode_from_disk_ts(struct xfs_dinode *dip,
> const xfs_timestamp_t ts);
>
> +static inline bool
> +xfs_dinode_good_version(struct xfs_mount *mp, uint8_t version)
> +{
> + if (xfs_has_v3inodes(mp))
> + return version == 3;
> + return version == 1 || version == 2;
> +}
> +
> +
> #endif /* __XFS_INODE_BUF_H__ */
> --
> 2.31.1
>
next prev parent reply other threads:[~2021-07-14 23:24 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 4:18 [PATCH 00/16] xfs: rework feature flags Dave Chinner
2021-07-14 4:18 ` [PATCH 01/16] xfs: sb verifier doesn't handle uncached sb buffer Dave Chinner
2021-07-14 6:43 ` Christoph Hellwig
2021-07-14 9:37 ` Dave Chinner
2021-07-14 22:44 ` Darrick J. Wong
2021-07-14 23:00 ` Dave Chinner
2021-07-14 23:03 ` Darrick J. Wong
2021-07-14 4:18 ` [PATCH 02/16] xfs: rename xfs_has_attr() Dave Chinner
2021-07-14 6:49 ` Christoph Hellwig
2021-07-14 22:46 ` Darrick J. Wong
2021-07-14 4:18 ` [PATCH 03/16] xfs: rework attr2 feature and mount options Dave Chinner
2021-07-14 6:58 ` Christoph Hellwig
2021-07-14 9:45 ` Dave Chinner
2021-07-15 5:55 ` Christoph Hellwig
2021-07-15 23:47 ` Dave Chinner
2021-07-16 9:43 ` Christoph Hellwig
2021-07-14 22:51 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 04/16] xfs: reflect sb features in xfs_mount Dave Chinner
2021-07-14 7:01 ` Christoph Hellwig
2021-07-14 22:56 ` Darrick J. Wong
2021-07-14 23:07 ` Dave Chinner
2021-07-14 23:17 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 05/16] xfs: replace xfs_sb_version checks with feature flag checks Dave Chinner
2021-07-14 7:03 ` Christoph Hellwig
2021-07-14 22:57 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 06/16] xfs: consolidate mount option features in m_features Dave Chinner
2021-07-14 7:05 ` Christoph Hellwig
2021-07-14 9:55 ` Dave Chinner
2021-07-15 5:59 ` Christoph Hellwig
2021-07-15 23:43 ` Dave Chinner
2021-07-14 23:02 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 07/16] xfs: convert mount flags to features Dave Chinner
2021-07-14 23:07 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 08/16] xfs: convert remaining mount flags to state flags Dave Chinner
2021-07-14 23:10 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 09/16] xfs: replace XFS_FORCED_SHUTDOWN with xfs_is_shutdown Dave Chinner
2021-07-14 23:11 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 10/16] xfs: convert xfs_fs_geometry to use mount feature checks Dave Chinner
2021-07-14 7:11 ` Christoph Hellwig
2021-07-14 23:15 ` Darrick J. Wong
2021-07-14 23:35 ` Dave Chinner
2021-07-14 23:38 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 11/16] xfs: open code sb verifier " Dave Chinner
2021-07-14 7:19 ` Christoph Hellwig
2021-07-16 0:26 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 12/16] xfs: convert scrub to use mount-based " Dave Chinner
2021-07-14 23:18 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 13/16] xfs: convert xfs_sb_version_has checks to use mount features Dave Chinner
2021-07-14 23:19 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 14/16] xfs: remove unused xfs_sb_version_has wrappers Dave Chinner
2021-07-14 23:21 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 15/16] xfs: introduce xfs_sb_is_v5 helper Dave Chinner
2021-07-14 23:24 ` Darrick J. Wong
2021-07-14 4:19 ` [PATCH 16/16] xfs: kill xfs_sb_version_has_v3inode() Dave Chinner
2021-07-14 23:24 ` Darrick J. Wong [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-08-10 5:24 [PATCH 00/16 v2] xfs: rework feature flags Dave Chinner
2021-08-10 5:24 ` [PATCH 16/16] xfs: kill xfs_sb_version_has_v3inode() Dave Chinner
2021-08-18 23:59 [PATCH 00/16 v3] xfs: rework feature flags Dave Chinner
2021-08-18 23:59 ` [PATCH 16/16] xfs: kill xfs_sb_version_has_v3inode() Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210714232444.GJ22402@magnolia \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).