Skip to content

Commit

Permalink
xfs: convert xfs_sb_version_has checks to use mount features
Browse files Browse the repository at this point in the history
This is a conversion of the remaining xfs_sb_version_has..(sbp)
checks to use xfs_has_..(mp) feature checks.

This was largely done with a vim replacement macro that did:

:0,$s/xfs_sb_version_has\(.*\)&\(.*\)->m_sb/xfs_has_\1\2/g<CR>

A couple of other variants were also used, and the rest touched up
by hand.

$ size -t fs/xfs/built-in.a
	   text    data     bss     dec     hex filename
before	1127533  311352     484 1439369  15f689 (TOTALS)
after	1125360  311352     484 1437196  15ee0c (TOTALS)

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
  • Loading branch information
Dave Chinner authored and Darrick J. Wong committed Aug 19, 2021
1 parent 55fafb3 commit ebd9027
Show file tree
Hide file tree
Showing 34 changed files with 90 additions and 96 deletions.
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_ag.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ xfs_agiblock_init(
}
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) {
if (xfs_has_inobtcounts(mp)) {
agi->agi_iblocks = cpu_to_be32(1);
if (xfs_sb_version_hasfinobt(&mp->m_sb))
if (xfs_has_finobt(mp))
agi->agi_fblocks = cpu_to_be32(1);
}
}
Expand Down
12 changes: 6 additions & 6 deletions fs/xfs/libxfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ xfs_alloc_min_freelist(
min_free += min_t(unsigned int, levels[XFS_BTNUM_CNTi] + 1,
mp->m_ag_maxlevels);
/* space needed reverse mapping used space btree */
if (xfs_sb_version_hasrmapbt(&mp->m_sb))
if (xfs_has_rmapbt(mp))
min_free += min_t(unsigned int, levels[XFS_BTNUM_RMAPi] + 1,
mp->m_rmap_maxlevels);

Expand Down Expand Up @@ -2912,7 +2912,7 @@ xfs_agf_verify(
be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > mp->m_rmap_maxlevels))
return __this_address;

if (xfs_sb_version_hasrmapbt(&mp->m_sb) &&
if (xfs_has_rmapbt(mp) &&
be32_to_cpu(agf->agf_rmap_blocks) > be32_to_cpu(agf->agf_length))
return __this_address;

Expand All @@ -2925,16 +2925,16 @@ xfs_agf_verify(
if (bp->b_pag && be32_to_cpu(agf->agf_seqno) != bp->b_pag->pag_agno)
return __this_address;

if (xfs_sb_version_haslazysbcount(&mp->m_sb) &&
if (xfs_has_lazysbcount(mp) &&
be32_to_cpu(agf->agf_btreeblks) > be32_to_cpu(agf->agf_length))
return __this_address;

if (xfs_sb_version_hasreflink(&mp->m_sb) &&
if (xfs_has_reflink(mp) &&
be32_to_cpu(agf->agf_refcount_blocks) >
be32_to_cpu(agf->agf_length))
return __this_address;

if (xfs_sb_version_hasreflink(&mp->m_sb) &&
if (xfs_has_reflink(mp) &&
(be32_to_cpu(agf->agf_refcount_level) < 1 ||
be32_to_cpu(agf->agf_refcount_level) > mp->m_refc_maxlevels))
return __this_address;
Expand Down Expand Up @@ -3073,7 +3073,7 @@ xfs_alloc_read_agf(
* counter only tracks non-root blocks.
*/
allocbt_blks = pag->pagf_btreeblks;
if (xfs_sb_version_hasrmapbt(&mp->m_sb))
if (xfs_has_rmapbt(mp))
allocbt_blks -= be32_to_cpu(agf->agf_rmap_blocks) - 1;
if (allocbt_blks > 0)
atomic64_add(allocbt_blks, &mp->m_allocbt_blks);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static inline __be32 *
xfs_buf_to_agfl_bno(
struct xfs_buf *bp)
{
if (xfs_sb_version_hascrc(&bp->b_mount->m_sb))
if (xfs_has_crc(bp->b_mount))
return bp->b_addr + sizeof(struct xfs_agfl);
return bp->b_addr;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_alloc_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ xfs_allocbt_verify(
if (!xfs_verify_magic(bp, block->bb_magic))
return __this_address;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
fa = xfs_btree_sblock_v5hdr_verify(bp);
if (fa)
return fa;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_bmap_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ xfs_bmbt_verify(
if (!xfs_verify_magic(bp, block->bb_magic))
return __this_address;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
/*
* XXX: need a better way of verifying the owner here. Right now
* just make sure there has been one set.
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ xfs_btree_lblock_calc_crc(
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
struct xfs_buf_log_item *bip = bp->b_log_item;

if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb))
if (!xfs_has_crc(bp->b_mount))
return;
if (bip)
block->bb_u.l.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn);
Expand Down Expand Up @@ -311,7 +311,7 @@ xfs_btree_sblock_calc_crc(
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
struct xfs_buf_log_item *bip = bp->b_log_item;

if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb))
if (!xfs_has_crc(bp->b_mount))
return;
if (bip)
block->bb_u.s.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn);
Expand Down Expand Up @@ -1749,7 +1749,7 @@ xfs_btree_lookup_get_block(
return error;

/* Check the inode owner since the verifiers don't. */
if (xfs_sb_version_hascrc(&cur->bc_mp->m_sb) &&
if (xfs_has_crc(cur->bc_mp) &&
!(cur->bc_ino.flags & XFS_BTCUR_BMBT_INVALID_OWNER) &&
(cur->bc_flags & XFS_BTREE_LONG_PTRS) &&
be64_to_cpu((*blkp)->bb_u.l.bb_owner) !=
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_da_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ xfs_da3_node_hdr_from_disk(
struct xfs_da3_icnode_hdr *to,
struct xfs_da_intnode *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_da3_intnode *from3 = (struct xfs_da3_intnode *)from;

to->forw = be32_to_cpu(from3->hdr.info.hdr.forw);
Expand All @@ -156,7 +156,7 @@ xfs_da3_node_hdr_to_disk(
struct xfs_da_intnode *to,
struct xfs_da3_icnode_hdr *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_da3_intnode *to3 = (struct xfs_da3_intnode *)to;

ASSERT(from->magic == XFS_DA3_NODE_MAGIC);
Expand Down Expand Up @@ -191,7 +191,7 @@ xfs_da3_blkinfo_verify(
if (!xfs_verify_magic16(bp, hdr->magic))
return __this_address;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
return __this_address;
if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ xfs_da_mount(
dageo->fsblog = mp->m_sb.sb_blocklog;
dageo->blksize = xfs_dir2_dirblock_bytes(&mp->m_sb);
dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog;
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
dageo->node_hdr_size = sizeof(struct xfs_da3_node_hdr);
dageo->leaf_hdr_size = sizeof(struct xfs_dir3_leaf_hdr);
dageo->free_hdr_size = sizeof(struct xfs_dir3_free_hdr);
Expand Down Expand Up @@ -730,7 +730,7 @@ xfs_dir2_hashname(
struct xfs_mount *mp,
struct xfs_name *name)
{
if (unlikely(xfs_sb_version_hasasciici(&mp->m_sb)))
if (unlikely(xfs_has_asciici(mp)))
return xfs_ascii_ci_hashname(name);
return xfs_da_hashname(name->name, name->len);
}
Expand All @@ -741,7 +741,7 @@ xfs_dir2_compname(
const unsigned char *name,
int len)
{
if (unlikely(xfs_sb_version_hasasciici(&args->dp->i_mount->m_sb)))
if (unlikely(xfs_has_asciici(args->dp->i_mount)))
return xfs_ascii_ci_compname(args, name, len);
return xfs_da_compname(args, name, len);
}
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_dir2_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ xfs_dir3_block_verify(
if (!xfs_verify_magic(bp, hdr3->magic))
return __this_address;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
return __this_address;
if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
Expand Down Expand Up @@ -121,7 +121,7 @@ xfs_dir3_block_header_check(
{
struct xfs_mount *mp = dp->i_mount;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;

if (be64_to_cpu(hdr3->owner) != dp->i_ino)
Expand Down
10 changes: 5 additions & 5 deletions fs/xfs/libxfs/xfs_dir2_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ xfs_dir2_data_bestfree_p(
struct xfs_mount *mp,
struct xfs_dir2_data_hdr *hdr)
{
if (xfs_sb_version_hascrc(&mp->m_sb))
if (xfs_has_crc(mp))
return ((struct xfs_dir3_data_hdr *)hdr)->best_free;
return hdr->bestfree;
}
Expand All @@ -51,7 +51,7 @@ xfs_dir2_data_get_ftype(
struct xfs_mount *mp,
struct xfs_dir2_data_entry *dep)
{
if (xfs_sb_version_hasftype(&mp->m_sb)) {
if (xfs_has_ftype(mp)) {
uint8_t ftype = dep->name[dep->namelen];

if (likely(ftype < XFS_DIR3_FT_MAX))
Expand All @@ -70,7 +70,7 @@ xfs_dir2_data_put_ftype(
ASSERT(ftype < XFS_DIR3_FT_MAX);
ASSERT(dep->namelen != 0);

if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
dep->name[dep->namelen] = ftype;
}

Expand Down Expand Up @@ -297,7 +297,7 @@ xfs_dir3_data_verify(
if (!xfs_verify_magic(bp, hdr3->magic))
return __this_address;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
return __this_address;
if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
Expand Down Expand Up @@ -401,7 +401,7 @@ xfs_dir3_data_header_check(
{
struct xfs_mount *mp = dp->i_mount;

if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_data_hdr *hdr3 = bp->b_addr;

if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino)
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_dir2_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ xfs_dir2_leaf_hdr_from_disk(
struct xfs_dir3_icleaf_hdr *to,
struct xfs_dir2_leaf *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_leaf *from3 = (struct xfs_dir3_leaf *)from;

to->forw = be32_to_cpu(from3->hdr.info.hdr.forw);
Expand Down Expand Up @@ -68,7 +68,7 @@ xfs_dir2_leaf_hdr_to_disk(
struct xfs_dir2_leaf *to,
struct xfs_dir3_icleaf_hdr *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_leaf *to3 = (struct xfs_dir3_leaf *)to;

ASSERT(from->magic == XFS_DIR3_LEAF1_MAGIC ||
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_dir2_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ xfs_dir2_free_hdr_from_disk(
struct xfs_dir3_icfree_hdr *to,
struct xfs_dir2_free *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_free *from3 = (struct xfs_dir3_free *)from;

to->magic = be32_to_cpu(from3->hdr.hdr.magic);
Expand All @@ -274,7 +274,7 @@ xfs_dir2_free_hdr_to_disk(
struct xfs_dir2_free *to,
struct xfs_dir3_icfree_hdr *from)
{
if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (xfs_has_crc(mp)) {
struct xfs_dir3_free *to3 = (struct xfs_dir3_free *)to;

ASSERT(from->magic == XFS_DIR3_FREE_MAGIC);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dir2_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ xfs_dir2_data_entsize(

len = offsetof(struct xfs_dir2_data_entry, name[0]) + namelen +
sizeof(xfs_dir2_data_off_t) /* tag */;
if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
len += sizeof(uint8_t);
return round_up(len, XFS_DIR2_DATA_ALIGN);
}
Expand Down
10 changes: 5 additions & 5 deletions fs/xfs/libxfs/xfs_dir2_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ xfs_dir2_sf_entsize(
count += sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */
count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */

if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
count += sizeof(uint8_t);
return count;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ xfs_dir2_sf_get_ino(
{
uint8_t *from = sfep->name + sfep->namelen;

if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
from++;

if (!hdr->i8count)
Expand All @@ -95,7 +95,7 @@ xfs_dir2_sf_put_ino(

ASSERT(ino <= XFS_MAXINUMBER);

if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
to++;

if (hdr->i8count)
Expand Down Expand Up @@ -135,7 +135,7 @@ xfs_dir2_sf_get_ftype(
struct xfs_mount *mp,
struct xfs_dir2_sf_entry *sfep)
{
if (xfs_sb_version_hasftype(&mp->m_sb)) {
if (xfs_has_ftype(mp)) {
uint8_t ftype = sfep->name[sfep->namelen];

if (ftype < XFS_DIR3_FT_MAX)
Expand All @@ -153,7 +153,7 @@ xfs_dir2_sf_put_ftype(
{
ASSERT(ftype < XFS_DIR3_FT_MAX);

if (xfs_sb_version_hasftype(&mp->m_sb))
if (xfs_has_ftype(mp))
sfep->name[sfep->namelen] = ftype;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dquot_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ xfs_dquot_verify(
return __this_address;

if ((ddq->d_type & XFS_DQTYPE_BIGTIME) &&
!xfs_sb_version_hasbigtime(&mp->m_sb))
!xfs_has_bigtime(mp))
return __this_address;

if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && !ddq->d_id)
Expand Down
Loading

0 comments on commit ebd9027

Please sign in to comment.