xfs: pass perag to xfs_read_agi

We have the perag in most palces we call xfs_read_agi, so pass the
perag instead of a mount/agno pair.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
Dave Chinner 2022-07-07 19:07:47 +10:00 committed by Dave Chinner
parent 08d3e84fee
commit 61021deb1f
4 changed files with 40 additions and 43 deletions

View File

@ -2571,25 +2571,24 @@ const struct xfs_buf_ops xfs_agi_buf_ops = {
*/ */
int int
xfs_read_agi( xfs_read_agi(
struct xfs_mount *mp, /* file system mount structure */ struct xfs_perag *pag,
struct xfs_trans *tp, /* transaction pointer */ struct xfs_trans *tp,
xfs_agnumber_t agno, /* allocation group number */ struct xfs_buf **agibpp)
struct xfs_buf **bpp) /* allocation group hdr buf */
{ {
struct xfs_mount *mp = pag->pag_mount;
int error; int error;
trace_xfs_read_agi(mp, agno); trace_xfs_read_agi(pag->pag_mount, pag->pag_agno);
ASSERT(agno != NULLAGNUMBER);
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, bpp, &xfs_agi_buf_ops); XFS_FSS_TO_BB(mp, 1), 0, agibpp, &xfs_agi_buf_ops);
if (error) if (error)
return error; return error;
if (tp) if (tp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_AGI_BUF); xfs_trans_buf_set_type(tp, *agibpp, XFS_BLFT_AGI_BUF);
xfs_buf_set_ref(*bpp, XFS_AGI_REF); xfs_buf_set_ref(*agibpp, XFS_AGI_REF);
return 0; return 0;
} }
@ -2609,7 +2608,7 @@ xfs_ialloc_read_agi(
trace_xfs_ialloc_read_agi(pag->pag_mount, pag->pag_agno); trace_xfs_ialloc_read_agi(pag->pag_mount, pag->pag_agno);
error = xfs_read_agi(pag->pag_mount, tp, pag->pag_agno, &agibp); error = xfs_read_agi(pag, tp, &agibp);
if (error) if (error)
return error; return error;

View File

@ -62,11 +62,9 @@ xfs_ialloc_log_agi(
struct xfs_buf *bp, /* allocation group header buffer */ struct xfs_buf *bp, /* allocation group header buffer */
uint32_t fields); /* bitmask of fields to log */ uint32_t fields); /* bitmask of fields to log */
/* int xfs_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
* Read in the allocation group header (inode allocation section) struct xfs_buf **agibpp);
*/ int xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
int /* error */
xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
struct xfs_buf **agibpp); struct xfs_buf **agibpp);
/* /*
@ -89,8 +87,6 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_agnumber_t agno, xfs_agblock_t agbno,
xfs_agblock_t length, unsigned int gen); xfs_agblock_t length, unsigned int gen);
int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, struct xfs_buf **bpp);
union xfs_btree_rec; union xfs_btree_rec;
void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, void xfs_inobt_btrec_to_irec(struct xfs_mount *mp,

View File

@ -2143,7 +2143,7 @@ xfs_iunlink(
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
/* Get the agi buffer first. It ensures lock ordering on the list. */ /* Get the agi buffer first. It ensures lock ordering on the list. */
error = xfs_read_agi(mp, tp, pag->pag_agno, &agibp); error = xfs_read_agi(pag, tp, &agibp);
if (error) if (error)
goto out; goto out;
agi = agibp->b_addr; agi = agibp->b_addr;
@ -2328,7 +2328,7 @@ xfs_iunlink_remove(
trace_xfs_iunlink_remove(ip); trace_xfs_iunlink_remove(ip);
/* Get the agi buffer first. It ensures lock ordering on the list. */ /* Get the agi buffer first. It ensures lock ordering on the list. */
error = xfs_read_agi(mp, tp, pag->pag_agno, &agibp); error = xfs_read_agi(pag, tp, &agibp);
if (error) if (error)
return error; return error;
agi = agibp->b_addr; agi = agibp->b_addr;
@ -3229,11 +3229,13 @@ retry:
if (inodes[i] == wip || if (inodes[i] == wip ||
(inodes[i] == target_ip && (inodes[i] == target_ip &&
(VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) { (VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) {
struct xfs_buf *bp; struct xfs_perag *pag;
xfs_agnumber_t agno; struct xfs_buf *bp;
agno = XFS_INO_TO_AGNO(mp, inodes[i]->i_ino); pag = xfs_perag_get(mp,
error = xfs_read_agi(mp, tp, agno, &bp); XFS_INO_TO_AGNO(mp, inodes[i]->i_ino));
error = xfs_read_agi(pag, tp, &bp);
xfs_perag_put(pag);
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
} }

View File

@ -2629,21 +2629,21 @@ xlog_recover_cancel_intents(
*/ */
STATIC void STATIC void
xlog_recover_clear_agi_bucket( xlog_recover_clear_agi_bucket(
xfs_mount_t *mp, struct xfs_perag *pag,
xfs_agnumber_t agno, int bucket)
int bucket)
{ {
xfs_trans_t *tp; struct xfs_mount *mp = pag->pag_mount;
xfs_agi_t *agi; struct xfs_trans *tp;
struct xfs_buf *agibp; struct xfs_agi *agi;
int offset; struct xfs_buf *agibp;
int error; int offset;
int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_clearagi, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_clearagi, 0, 0, 0, &tp);
if (error) if (error)
goto out_error; goto out_error;
error = xfs_read_agi(mp, tp, agno, &agibp); error = xfs_read_agi(pag, tp, &agibp);
if (error) if (error)
goto out_abort; goto out_abort;
@ -2662,14 +2662,14 @@ xlog_recover_clear_agi_bucket(
out_abort: out_abort:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_error: out_error:
xfs_warn(mp, "%s: failed to clear agi %d. Continuing.", __func__, agno); xfs_warn(mp, "%s: failed to clear agi %d. Continuing.", __func__,
pag->pag_agno);
return; return;
} }
STATIC xfs_agino_t STATIC xfs_agino_t
xlog_recover_process_one_iunlink( xlog_recover_process_one_iunlink(
struct xfs_mount *mp, struct xfs_perag *pag,
xfs_agnumber_t agno,
xfs_agino_t agino, xfs_agino_t agino,
int bucket) int bucket)
{ {
@ -2679,15 +2679,15 @@ xlog_recover_process_one_iunlink(
xfs_ino_t ino; xfs_ino_t ino;
int error; int error;
ino = XFS_AGINO_TO_INO(mp, agno, agino); ino = XFS_AGINO_TO_INO(pag->pag_mount, pag->pag_agno, agino);
error = xfs_iget(mp, NULL, ino, 0, 0, &ip); error = xfs_iget(pag->pag_mount, NULL, ino, 0, 0, &ip);
if (error) if (error)
goto fail; goto fail;
/* /*
* Get the on disk inode to find the next inode in the bucket. * Get the on disk inode to find the next inode in the bucket.
*/ */
error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &ibp); error = xfs_imap_to_bp(pag->pag_mount, NULL, &ip->i_imap, &ibp);
if (error) if (error)
goto fail_iput; goto fail_iput;
dip = xfs_buf_offset(ibp, ip->i_imap.im_boffset); dip = xfs_buf_offset(ibp, ip->i_imap.im_boffset);
@ -2714,7 +2714,7 @@ xlog_recover_process_one_iunlink(
* Call xlog_recover_clear_agi_bucket() to perform a transaction to * Call xlog_recover_clear_agi_bucket() to perform a transaction to
* clear the inode pointer in the bucket. * clear the inode pointer in the bucket.
*/ */
xlog_recover_clear_agi_bucket(mp, agno, bucket); xlog_recover_clear_agi_bucket(pag, bucket);
return NULLAGINO; return NULLAGINO;
} }
@ -2755,7 +2755,7 @@ xlog_recover_process_iunlinks(
int error; int error;
for_each_perag(mp, agno, pag) { for_each_perag(mp, agno, pag) {
error = xfs_read_agi(mp, NULL, pag->pag_agno, &agibp); error = xfs_read_agi(pag, NULL, &agibp);
if (error) { if (error) {
/* /*
* AGI is b0rked. Don't process it. * AGI is b0rked. Don't process it.
@ -2780,8 +2780,8 @@ xlog_recover_process_iunlinks(
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
agino = be32_to_cpu(agi->agi_unlinked[bucket]); agino = be32_to_cpu(agi->agi_unlinked[bucket]);
while (agino != NULLAGINO) { while (agino != NULLAGINO) {
agino = xlog_recover_process_one_iunlink(mp, agino = xlog_recover_process_one_iunlink(pag,
pag->pag_agno, agino, bucket); agino, bucket);
cond_resched(); cond_resched();
} }
} }