Commit 370c782b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: remove XFS_BUF_TO_AGI

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 4b975108
...@@ -312,7 +312,7 @@ xfs_agiblock_init( ...@@ -312,7 +312,7 @@ xfs_agiblock_init(
struct xfs_buf *bp, struct xfs_buf *bp,
struct aghdr_init_data *id) struct aghdr_init_data *id)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(bp); struct xfs_agi *agi = bp->b_addr;
int bucket; int bucket;
agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
...@@ -502,7 +502,7 @@ xfs_ag_extend_space( ...@@ -502,7 +502,7 @@ xfs_ag_extend_space(
if (error) if (error)
return error; return error;
agi = XFS_BUF_TO_AGI(bp); agi = bp->b_addr;
be32_add_cpu(&agi->agi_length, len); be32_add_cpu(&agi->agi_length, len);
ASSERT(id->agno == mp->m_sb.sb_agcount - 1 || ASSERT(id->agno == mp->m_sb.sb_agcount - 1 ||
be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks); be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks);
...@@ -569,7 +569,7 @@ xfs_ag_get_geometry( ...@@ -569,7 +569,7 @@ xfs_ag_get_geometry(
memset(ageo, 0, sizeof(*ageo)); memset(ageo, 0, sizeof(*ageo));
ageo->ag_number = agno; ageo->ag_number = agno;
agi = XFS_BUF_TO_AGI(agi_bp); agi = agi_bp->b_addr;
ageo->ag_icount = be32_to_cpu(agi->agi_count); ageo->ag_icount = be32_to_cpu(agi->agi_count);
ageo->ag_ifree = be32_to_cpu(agi->agi_freecount); ageo->ag_ifree = be32_to_cpu(agi->agi_freecount);
......
...@@ -775,7 +775,6 @@ typedef struct xfs_agi { ...@@ -775,7 +775,6 @@ typedef struct xfs_agi {
/* disk block (xfs_daddr_t) in the AG */ /* disk block (xfs_daddr_t) in the AG */
#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr))
/* /*
* The third a.g. block contains the a.g. freelist, an array * The third a.g. block contains the a.g. freelist, an array
......
...@@ -177,7 +177,7 @@ xfs_inobt_insert( ...@@ -177,7 +177,7 @@ xfs_inobt_insert(
xfs_btnum_t btnum) xfs_btnum_t btnum)
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
xfs_agino_t thisino; xfs_agino_t thisino;
int i; int i;
...@@ -525,7 +525,7 @@ xfs_inobt_insert_sprec( ...@@ -525,7 +525,7 @@ xfs_inobt_insert_sprec(
bool merge) /* merge or replace */ bool merge) /* merge or replace */
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
int error; int error;
int i; int i;
...@@ -658,7 +658,7 @@ xfs_ialloc_ag_alloc( ...@@ -658,7 +658,7 @@ xfs_ialloc_ag_alloc(
* chunk of inodes. If the filesystem is striped, this will fill * chunk of inodes. If the filesystem is striped, this will fill
* an entire stripe unit with inodes. * an entire stripe unit with inodes.
*/ */
agi = XFS_BUF_TO_AGI(agbp); agi = agbp->b_addr;
newino = be32_to_cpu(agi->agi_newino); newino = be32_to_cpu(agi->agi_newino);
agno = be32_to_cpu(agi->agi_seqno); agno = be32_to_cpu(agi->agi_seqno);
args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
...@@ -1130,7 +1130,7 @@ xfs_dialloc_ag_inobt( ...@@ -1130,7 +1130,7 @@ xfs_dialloc_ag_inobt(
xfs_ino_t *inop) xfs_ino_t *inop)
{ {
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
xfs_agnumber_t pagno = XFS_INO_TO_AGNO(mp, parent); xfs_agnumber_t pagno = XFS_INO_TO_AGNO(mp, parent);
xfs_agino_t pagino = XFS_INO_TO_AGINO(mp, parent); xfs_agino_t pagino = XFS_INO_TO_AGINO(mp, parent);
...@@ -1583,7 +1583,7 @@ xfs_dialloc_ag( ...@@ -1583,7 +1583,7 @@ xfs_dialloc_ag(
xfs_ino_t *inop) xfs_ino_t *inop)
{ {
struct xfs_mount *mp = tp->t_mountp; struct xfs_mount *mp = tp->t_mountp;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
xfs_agnumber_t pagno = XFS_INO_TO_AGNO(mp, parent); xfs_agnumber_t pagno = XFS_INO_TO_AGNO(mp, parent);
xfs_agino_t pagino = XFS_INO_TO_AGINO(mp, parent); xfs_agino_t pagino = XFS_INO_TO_AGINO(mp, parent);
...@@ -1943,7 +1943,7 @@ xfs_difree_inobt( ...@@ -1943,7 +1943,7 @@ xfs_difree_inobt(
struct xfs_icluster *xic, struct xfs_icluster *xic,
struct xfs_inobt_rec_incore *orec) struct xfs_inobt_rec_incore *orec)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
struct xfs_perag *pag; struct xfs_perag *pag;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
...@@ -2079,7 +2079,7 @@ xfs_difree_finobt( ...@@ -2079,7 +2079,7 @@ xfs_difree_finobt(
xfs_agino_t agino, xfs_agino_t agino,
struct xfs_inobt_rec_incore *ibtrec) /* inobt record */ struct xfs_inobt_rec_incore *ibtrec) /* inobt record */
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
struct xfs_inobt_rec_incore rec; struct xfs_inobt_rec_incore rec;
...@@ -2489,9 +2489,8 @@ xfs_ialloc_log_agi( ...@@ -2489,9 +2489,8 @@ xfs_ialloc_log_agi(
sizeof(xfs_agi_t) sizeof(xfs_agi_t)
}; };
#ifdef DEBUG #ifdef DEBUG
xfs_agi_t *agi; /* allocation group header */ struct xfs_agi *agi = bp->b_addr;
agi = XFS_BUF_TO_AGI(bp);
ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
#endif #endif
...@@ -2523,14 +2522,13 @@ xfs_agi_verify( ...@@ -2523,14 +2522,13 @@ xfs_agi_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_mount; struct xfs_mount *mp = bp->b_mount;
struct xfs_agi *agi = XFS_BUF_TO_AGI(bp); struct xfs_agi *agi = bp->b_addr;
int i; int i;
if (xfs_sb_version_hascrc(&mp->m_sb)) { if (xfs_sb_version_hascrc(&mp->m_sb)) {
if (!uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid)) if (!uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid))
return __this_address; return __this_address;
if (!xfs_log_check_lsn(mp, if (!xfs_log_check_lsn(mp, be64_to_cpu(agi->agi_lsn)))
be64_to_cpu(XFS_BUF_TO_AGI(bp)->agi_lsn)))
return __this_address; return __this_address;
} }
...@@ -2593,6 +2591,7 @@ xfs_agi_write_verify( ...@@ -2593,6 +2591,7 @@ xfs_agi_write_verify(
{ {
struct xfs_mount *mp = bp->b_mount; struct xfs_mount *mp = bp->b_mount;
struct xfs_buf_log_item *bip = bp->b_log_item; struct xfs_buf_log_item *bip = bp->b_log_item;
struct xfs_agi *agi = bp->b_addr;
xfs_failaddr_t fa; xfs_failaddr_t fa;
fa = xfs_agi_verify(bp); fa = xfs_agi_verify(bp);
...@@ -2605,7 +2604,7 @@ xfs_agi_write_verify( ...@@ -2605,7 +2604,7 @@ xfs_agi_write_verify(
return; return;
if (bip) if (bip)
XFS_BUF_TO_AGI(bp)->agi_lsn = cpu_to_be64(bip->bli_item.li_lsn); agi->agi_lsn = cpu_to_be64(bip->bli_item.li_lsn);
xfs_buf_update_cksum(bp, XFS_AGI_CRC_OFF); xfs_buf_update_cksum(bp, XFS_AGI_CRC_OFF);
} }
...@@ -2661,7 +2660,7 @@ xfs_ialloc_read_agi( ...@@ -2661,7 +2660,7 @@ xfs_ialloc_read_agi(
if (error) if (error)
return error; return error;
agi = XFS_BUF_TO_AGI(*bpp); agi = (*bpp)->b_addr;
pag = xfs_perag_get(mp, agno); pag = xfs_perag_get(mp, agno);
if (!pag->pagi_init) { if (!pag->pagi_init) {
pag->pagi_freecount = be32_to_cpu(agi->agi_freecount); pag->pagi_freecount = be32_to_cpu(agi->agi_freecount);
......
...@@ -45,7 +45,7 @@ xfs_inobt_set_root( ...@@ -45,7 +45,7 @@ xfs_inobt_set_root(
int inc) /* level change */ int inc) /* level change */
{ {
struct xfs_buf *agbp = cur->bc_private.a.agbp; struct xfs_buf *agbp = cur->bc_private.a.agbp;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
agi->agi_root = nptr->s; agi->agi_root = nptr->s;
be32_add_cpu(&agi->agi_level, inc); be32_add_cpu(&agi->agi_level, inc);
...@@ -59,7 +59,7 @@ xfs_finobt_set_root( ...@@ -59,7 +59,7 @@ xfs_finobt_set_root(
int inc) /* level change */ int inc) /* level change */
{ {
struct xfs_buf *agbp = cur->bc_private.a.agbp; struct xfs_buf *agbp = cur->bc_private.a.agbp;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
agi->agi_free_root = nptr->s; agi->agi_free_root = nptr->s;
be32_add_cpu(&agi->agi_free_level, inc); be32_add_cpu(&agi->agi_free_level, inc);
...@@ -212,7 +212,7 @@ xfs_inobt_init_ptr_from_cur( ...@@ -212,7 +212,7 @@ xfs_inobt_init_ptr_from_cur(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
union xfs_btree_ptr *ptr) union xfs_btree_ptr *ptr)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp); struct xfs_agi *agi = cur->bc_private.a.agbp->b_addr;
ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno)); ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno));
...@@ -224,7 +224,7 @@ xfs_finobt_init_ptr_from_cur( ...@@ -224,7 +224,7 @@ xfs_finobt_init_ptr_from_cur(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
union xfs_btree_ptr *ptr) union xfs_btree_ptr *ptr)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp); struct xfs_agi *agi = cur->bc_private.a.agbp->b_addr;
ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno)); ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno));
ptr->s = agi->agi_free_root; ptr->s = agi->agi_free_root;
...@@ -410,7 +410,7 @@ xfs_inobt_init_cursor( ...@@ -410,7 +410,7 @@ xfs_inobt_init_cursor(
xfs_agnumber_t agno, /* allocation group number */ xfs_agnumber_t agno, /* allocation group number */
xfs_btnum_t btnum) /* ialloc or free ino btree */ xfs_btnum_t btnum) /* ialloc or free ino btree */
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); struct xfs_agi *agi = agbp->b_addr;
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS); cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
......
...@@ -765,7 +765,7 @@ static inline void ...@@ -765,7 +765,7 @@ static inline void
xchk_agi_xref_icounts( xchk_agi_xref_icounts(
struct xfs_scrub *sc) struct xfs_scrub *sc)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(sc->sa.agi_bp); struct xfs_agi *agi = sc->sa.agi_bp->b_addr;
xfs_agino_t icount; xfs_agino_t icount;
xfs_agino_t freecount; xfs_agino_t freecount;
int error; int error;
...@@ -834,7 +834,7 @@ xchk_agi( ...@@ -834,7 +834,7 @@ xchk_agi(
goto out; goto out;
xchk_buffer_recheck(sc, sc->sa.agi_bp); xchk_buffer_recheck(sc, sc->sa.agi_bp);
agi = XFS_BUF_TO_AGI(sc->sa.agi_bp); agi = sc->sa.agi_bp->b_addr;
/* Check the AG length */ /* Check the AG length */
eoag = be32_to_cpu(agi->agi_length); eoag = be32_to_cpu(agi->agi_length);
......
...@@ -761,7 +761,7 @@ xrep_agi_init_header( ...@@ -761,7 +761,7 @@ xrep_agi_init_header(
struct xfs_buf *agi_bp, struct xfs_buf *agi_bp,
struct xfs_agi *old_agi) struct xfs_agi *old_agi)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agi_bp); struct xfs_agi *agi = agi_bp->b_addr;
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
memcpy(old_agi, agi, sizeof(*old_agi)); memcpy(old_agi, agi, sizeof(*old_agi));
...@@ -807,7 +807,7 @@ xrep_agi_calc_from_btrees( ...@@ -807,7 +807,7 @@ xrep_agi_calc_from_btrees(
struct xfs_buf *agi_bp) struct xfs_buf *agi_bp)
{ {
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agi_bp); struct xfs_agi *agi = agi_bp->b_addr;
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
xfs_agino_t count; xfs_agino_t count;
xfs_agino_t freecount; xfs_agino_t freecount;
...@@ -835,7 +835,7 @@ xrep_agi_commit_new( ...@@ -835,7 +835,7 @@ xrep_agi_commit_new(
struct xfs_buf *agi_bp) struct xfs_buf *agi_bp)
{ {
struct xfs_perag *pag; struct xfs_perag *pag;
struct xfs_agi *agi = XFS_BUF_TO_AGI(agi_bp); struct xfs_agi *agi = agi_bp->b_addr;
/* Trigger inode count recalculation */ /* Trigger inode count recalculation */
xfs_force_summary_recalc(sc->mp); xfs_force_summary_recalc(sc->mp);
...@@ -892,7 +892,7 @@ xrep_agi( ...@@ -892,7 +892,7 @@ xrep_agi(
if (error) if (error)
return error; return error;
agi_bp->b_ops = &xfs_agi_buf_ops; agi_bp->b_ops = &xfs_agi_buf_ops;
agi = XFS_BUF_TO_AGI(agi_bp); agi = agi_bp->b_addr;
/* Find the AGI btree roots. */ /* Find the AGI btree roots. */
error = xrep_agi_find_btrees(sc, fab); error = xrep_agi_find_btrees(sc, fab);
......
...@@ -2117,7 +2117,7 @@ xfs_iunlink_update_bucket( ...@@ -2117,7 +2117,7 @@ xfs_iunlink_update_bucket(
unsigned int bucket_index, unsigned int bucket_index,
xfs_agino_t new_agino) xfs_agino_t new_agino)
{ {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agibp); struct xfs_agi *agi = agibp->b_addr;
xfs_agino_t old_value; xfs_agino_t old_value;
int offset; int offset;
...@@ -2257,7 +2257,7 @@ xfs_iunlink( ...@@ -2257,7 +2257,7 @@ xfs_iunlink(
error = xfs_read_agi(mp, tp, agno, &agibp); error = xfs_read_agi(mp, tp, agno, &agibp);
if (error) if (error)
return error; return error;
agi = XFS_BUF_TO_AGI(agibp); agi = agibp->b_addr;
/* /*
* Get the index into the agi hash table for the list this inode will * Get the index into the agi hash table for the list this inode will
...@@ -2441,7 +2441,7 @@ xfs_iunlink_remove( ...@@ -2441,7 +2441,7 @@ xfs_iunlink_remove(
error = xfs_read_agi(mp, tp, agno, &agibp); error = xfs_read_agi(mp, tp, agno, &agibp);
if (error) if (error)
return error; return error;
agi = XFS_BUF_TO_AGI(agibp); agi = agibp->b_addr;
/* /*
* Get the index into the agi hash table for the list this inode will * Get the index into the agi hash table for the list this inode will
......
...@@ -4947,7 +4947,7 @@ xlog_recover_clear_agi_bucket( ...@@ -4947,7 +4947,7 @@ xlog_recover_clear_agi_bucket(
if (error) if (error)
goto out_abort; goto out_abort;
agi = XFS_BUF_TO_AGI(agibp); agi = agibp->b_addr;
agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
offset = offsetof(xfs_agi_t, agi_unlinked) + offset = offsetof(xfs_agi_t, agi_unlinked) +
(sizeof(xfs_agino_t) * bucket); (sizeof(xfs_agino_t) * bucket);
...@@ -5083,7 +5083,7 @@ xlog_recover_process_iunlinks( ...@@ -5083,7 +5083,7 @@ xlog_recover_process_iunlinks(
* buffer reference though, so that it stays pinned in memory * buffer reference though, so that it stays pinned in memory
* while we need the buffer. * while we need the buffer.
*/ */
agi = XFS_BUF_TO_AGI(agibp); agi = agibp->b_addr;
xfs_buf_unlock(agibp); xfs_buf_unlock(agibp);
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
...@@ -5840,7 +5840,7 @@ xlog_recover_check_summary( ...@@ -5840,7 +5840,7 @@ xlog_recover_check_summary(
xfs_alert(mp, "%s agi read failed agno %d error %d", xfs_alert(mp, "%s agi read failed agno %d error %d",
__func__, agno, error); __func__, agno, error);
} else { } else {
struct xfs_agi *agi = XFS_BUF_TO_AGI(agibp); struct xfs_agi *agi = agibp->b_addr;
itotal += be32_to_cpu(agi->agi_count); itotal += be32_to_cpu(agi->agi_count);
ifree += be32_to_cpu(agi->agi_freecount); ifree += be32_to_cpu(agi->agi_freecount);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment