Commit 549d3c9a authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: pass xfs_buf lookup flags to xfs_*read_agi

Allow callers to pass buffer lookup flags to xfs_read_agi and
xfs_ialloc_read_agi.  This will be used in the next patch to fix a
deadlock in the online fsck inode scanner.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 0bbac3fa
...@@ -194,7 +194,7 @@ xfs_initialize_perag_data( ...@@ -194,7 +194,7 @@ xfs_initialize_perag_data(
pag = xfs_perag_get(mp, index); pag = xfs_perag_get(mp, index);
error = xfs_alloc_read_agf(pag, NULL, 0, NULL); error = xfs_alloc_read_agf(pag, NULL, 0, NULL);
if (!error) if (!error)
error = xfs_ialloc_read_agi(pag, NULL, NULL); error = xfs_ialloc_read_agi(pag, NULL, 0, NULL);
if (error) { if (error) {
xfs_perag_put(pag); xfs_perag_put(pag);
return error; return error;
...@@ -931,7 +931,7 @@ xfs_ag_shrink_space( ...@@ -931,7 +931,7 @@ xfs_ag_shrink_space(
int error, err2; int error, err2;
ASSERT(pag->pag_agno == mp->m_sb.sb_agcount - 1); ASSERT(pag->pag_agno == mp->m_sb.sb_agcount - 1);
error = xfs_ialloc_read_agi(pag, *tpp, &agibp); error = xfs_ialloc_read_agi(pag, *tpp, 0, &agibp);
if (error) if (error)
return error; return error;
...@@ -1062,7 +1062,7 @@ xfs_ag_extend_space( ...@@ -1062,7 +1062,7 @@ xfs_ag_extend_space(
ASSERT(pag->pag_agno == pag->pag_mount->m_sb.sb_agcount - 1); ASSERT(pag->pag_agno == pag->pag_mount->m_sb.sb_agcount - 1);
error = xfs_ialloc_read_agi(pag, tp, &bp); error = xfs_ialloc_read_agi(pag, tp, 0, &bp);
if (error) if (error)
return error; return error;
...@@ -1119,7 +1119,7 @@ xfs_ag_get_geometry( ...@@ -1119,7 +1119,7 @@ xfs_ag_get_geometry(
int error; int error;
/* Lock the AG headers. */ /* Lock the AG headers. */
error = xfs_ialloc_read_agi(pag, NULL, &agi_bp); error = xfs_ialloc_read_agi(pag, NULL, 0, &agi_bp);
if (error) if (error)
return error; return error;
error = xfs_alloc_read_agf(pag, NULL, 0, &agf_bp); error = xfs_alloc_read_agf(pag, NULL, 0, &agf_bp);
......
...@@ -1699,7 +1699,7 @@ xfs_dialloc_good_ag( ...@@ -1699,7 +1699,7 @@ xfs_dialloc_good_ag(
return false; return false;
if (!xfs_perag_initialised_agi(pag)) { if (!xfs_perag_initialised_agi(pag)) {
error = xfs_ialloc_read_agi(pag, tp, NULL); error = xfs_ialloc_read_agi(pag, tp, 0, NULL);
if (error) if (error)
return false; return false;
} }
...@@ -1768,7 +1768,7 @@ xfs_dialloc_try_ag( ...@@ -1768,7 +1768,7 @@ xfs_dialloc_try_ag(
* Then read in the AGI buffer and recheck with the AGI buffer * Then read in the AGI buffer and recheck with the AGI buffer
* lock held. * lock held.
*/ */
error = xfs_ialloc_read_agi(pag, *tpp, &agbp); error = xfs_ialloc_read_agi(pag, *tpp, 0, &agbp);
if (error) if (error)
return error; return error;
...@@ -2286,7 +2286,7 @@ xfs_difree( ...@@ -2286,7 +2286,7 @@ xfs_difree(
/* /*
* Get the allocation group header. * Get the allocation group header.
*/ */
error = xfs_ialloc_read_agi(pag, tp, &agbp); error = xfs_ialloc_read_agi(pag, tp, 0, &agbp);
if (error) { if (error) {
xfs_warn(mp, "%s: xfs_ialloc_read_agi() returned error %d.", xfs_warn(mp, "%s: xfs_ialloc_read_agi() returned error %d.",
__func__, error); __func__, error);
...@@ -2332,7 +2332,7 @@ xfs_imap_lookup( ...@@ -2332,7 +2332,7 @@ xfs_imap_lookup(
int error; int error;
int i; int i;
error = xfs_ialloc_read_agi(pag, tp, &agbp); error = xfs_ialloc_read_agi(pag, tp, 0, &agbp);
if (error) { if (error) {
xfs_alert(mp, xfs_alert(mp,
"%s: xfs_ialloc_read_agi() returned error %d, agno %d", "%s: xfs_ialloc_read_agi() returned error %d, agno %d",
...@@ -2675,6 +2675,7 @@ int ...@@ -2675,6 +2675,7 @@ int
xfs_read_agi( xfs_read_agi(
struct xfs_perag *pag, struct xfs_perag *pag,
struct xfs_trans *tp, struct xfs_trans *tp,
xfs_buf_flags_t flags,
struct xfs_buf **agibpp) struct xfs_buf **agibpp)
{ {
struct xfs_mount *mp = pag->pag_mount; struct xfs_mount *mp = pag->pag_mount;
...@@ -2684,7 +2685,7 @@ xfs_read_agi( ...@@ -2684,7 +2685,7 @@ xfs_read_agi(
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, pag->pag_agno, XFS_AGI_DADDR(mp)), XFS_AG_DADDR(mp, pag->pag_agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, agibpp, &xfs_agi_buf_ops); XFS_FSS_TO_BB(mp, 1), flags, agibpp, &xfs_agi_buf_ops);
if (xfs_metadata_is_sick(error)) if (xfs_metadata_is_sick(error))
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGI); xfs_ag_mark_sick(pag, XFS_SICK_AG_AGI);
if (error) if (error)
...@@ -2704,6 +2705,7 @@ int ...@@ -2704,6 +2705,7 @@ int
xfs_ialloc_read_agi( xfs_ialloc_read_agi(
struct xfs_perag *pag, struct xfs_perag *pag,
struct xfs_trans *tp, struct xfs_trans *tp,
int flags,
struct xfs_buf **agibpp) struct xfs_buf **agibpp)
{ {
struct xfs_buf *agibp; struct xfs_buf *agibp;
...@@ -2712,7 +2714,9 @@ xfs_ialloc_read_agi( ...@@ -2712,7 +2714,9 @@ 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, tp, &agibp); error = xfs_read_agi(pag, tp,
(flags & XFS_IALLOC_FLAG_TRYLOCK) ? XBF_TRYLOCK : 0,
&agibp);
if (error) if (error)
return error; return error;
......
...@@ -63,10 +63,11 @@ xfs_ialloc_log_agi( ...@@ -63,10 +63,11 @@ 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, int xfs_read_agi(struct xfs_perag *pag, struct xfs_trans *tp, xfs_buf_flags_t flags,
struct xfs_buf **agibpp); struct xfs_buf **agibpp);
int xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp, int xfs_ialloc_read_agi(struct xfs_perag *pag, struct xfs_trans *tp,
struct xfs_buf **agibpp); int flags, struct xfs_buf **agibpp);
#define XFS_IALLOC_FLAG_TRYLOCK (1U << 0) /* use trylock for buffer locking */
/* /*
* Lookup a record by ino in the btree given by cur. * Lookup a record by ino in the btree given by cur.
......
...@@ -745,7 +745,7 @@ xfs_finobt_count_blocks( ...@@ -745,7 +745,7 @@ xfs_finobt_count_blocks(
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
int error; int error;
error = xfs_ialloc_read_agi(pag, tp, &agbp); error = xfs_ialloc_read_agi(pag, tp, 0, &agbp);
if (error) if (error)
return error; return error;
...@@ -768,7 +768,7 @@ xfs_finobt_read_blocks( ...@@ -768,7 +768,7 @@ xfs_finobt_read_blocks(
struct xfs_agi *agi; struct xfs_agi *agi;
int error; int error;
error = xfs_ialloc_read_agi(pag, tp, &agbp); error = xfs_ialloc_read_agi(pag, tp, 0, &agbp);
if (error) if (error)
return error; return error;
......
...@@ -445,7 +445,7 @@ xchk_perag_read_headers( ...@@ -445,7 +445,7 @@ xchk_perag_read_headers(
{ {
int error; int error;
error = xfs_ialloc_read_agi(sa->pag, sc->tp, &sa->agi_bp); error = xfs_ialloc_read_agi(sa->pag, sc->tp, 0, &sa->agi_bp);
if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGI)) if (error && want_ag_read_header_failure(sc, XFS_SCRUB_TYPE_AGI))
return error; return error;
...@@ -827,7 +827,7 @@ xchk_iget_agi( ...@@ -827,7 +827,7 @@ xchk_iget_agi(
* in the iget cache miss path. * in the iget cache miss path.
*/ */
pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum)); pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum));
error = xfs_ialloc_read_agi(pag, tp, agi_bpp); error = xfs_ialloc_read_agi(pag, tp, 0, agi_bpp);
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) if (error)
return error; return error;
......
...@@ -85,7 +85,7 @@ xchk_fscount_warmup( ...@@ -85,7 +85,7 @@ xchk_fscount_warmup(
continue; continue;
/* Lock both AG headers. */ /* Lock both AG headers. */
error = xfs_ialloc_read_agi(pag, sc->tp, &agi_bp); error = xfs_ialloc_read_agi(pag, sc->tp, 0, &agi_bp);
if (error) if (error)
break; break;
error = xfs_alloc_read_agf(pag, sc->tp, 0, &agf_bp); error = xfs_alloc_read_agf(pag, sc->tp, 0, &agf_bp);
......
...@@ -281,7 +281,7 @@ xchk_iscan_advance( ...@@ -281,7 +281,7 @@ xchk_iscan_advance(
if (!pag) if (!pag)
return -ECANCELED; return -ECANCELED;
ret = xfs_ialloc_read_agi(pag, sc->tp, &agi_bp); ret = xfs_ialloc_read_agi(pag, sc->tp, 0, &agi_bp);
if (ret) if (ret)
goto out_pag; goto out_pag;
......
...@@ -290,7 +290,7 @@ xrep_calc_ag_resblks( ...@@ -290,7 +290,7 @@ xrep_calc_ag_resblks(
icount = pag->pagi_count; icount = pag->pagi_count;
} else { } else {
/* Try to get the actual counters from disk. */ /* Try to get the actual counters from disk. */
error = xfs_ialloc_read_agi(pag, NULL, &bp); error = xfs_ialloc_read_agi(pag, NULL, 0, &bp);
if (!error) { if (!error) {
icount = pag->pagi_count; icount = pag->pagi_count;
xfs_buf_relse(bp); xfs_buf_relse(bp);
...@@ -908,7 +908,7 @@ xrep_reinit_pagi( ...@@ -908,7 +908,7 @@ xrep_reinit_pagi(
ASSERT(xfs_perag_initialised_agi(pag)); ASSERT(xfs_perag_initialised_agi(pag));
clear_bit(XFS_AGSTATE_AGI_INIT, &pag->pag_opstate); clear_bit(XFS_AGSTATE_AGI_INIT, &pag->pag_opstate);
error = xfs_ialloc_read_agi(pag, sc->tp, &bp); error = xfs_ialloc_read_agi(pag, sc->tp, 0, &bp);
if (error) if (error)
return error; return error;
...@@ -934,7 +934,7 @@ xrep_ag_init( ...@@ -934,7 +934,7 @@ xrep_ag_init(
ASSERT(!sa->pag); ASSERT(!sa->pag);
error = xfs_ialloc_read_agi(pag, sc->tp, &sa->agi_bp); error = xfs_ialloc_read_agi(pag, sc->tp, 0, &sa->agi_bp);
if (error) if (error)
return error; return error;
......
...@@ -2167,7 +2167,7 @@ xfs_iunlink( ...@@ -2167,7 +2167,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(pag, tp, &agibp); error = xfs_read_agi(pag, tp, 0, &agibp);
if (error) if (error)
goto out; goto out;
...@@ -2264,7 +2264,7 @@ xfs_iunlink_remove( ...@@ -2264,7 +2264,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(pag, tp, &agibp); error = xfs_read_agi(pag, tp, 0, &agibp);
if (error) if (error)
return error; return error;
...@@ -3142,7 +3142,7 @@ xfs_rename( ...@@ -3142,7 +3142,7 @@ xfs_rename(
pag = xfs_perag_get(mp, pag = xfs_perag_get(mp,
XFS_INO_TO_AGNO(mp, inodes[i]->i_ino)); XFS_INO_TO_AGNO(mp, inodes[i]->i_ino));
error = xfs_read_agi(pag, tp, &bp); error = xfs_read_agi(pag, tp, 0, &bp);
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
...@@ -3814,7 +3814,7 @@ xfs_inode_reload_unlinked_bucket( ...@@ -3814,7 +3814,7 @@ xfs_inode_reload_unlinked_bucket(
/* Grab the first inode in the list */ /* Grab the first inode in the list */
pag = xfs_perag_get(mp, agno); pag = xfs_perag_get(mp, agno);
error = xfs_ialloc_read_agi(pag, tp, &agibp); error = xfs_ialloc_read_agi(pag, tp, 0, &agibp);
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) if (error)
return error; return error;
......
...@@ -268,7 +268,7 @@ xfs_iwalk_ag_start( ...@@ -268,7 +268,7 @@ xfs_iwalk_ag_start(
/* Set up a fresh cursor and empty the inobt cache. */ /* Set up a fresh cursor and empty the inobt cache. */
iwag->nr_recs = 0; iwag->nr_recs = 0;
error = xfs_ialloc_read_agi(pag, tp, agi_bpp); error = xfs_ialloc_read_agi(pag, tp, 0, agi_bpp);
if (error) if (error)
return error; return error;
*curpp = xfs_inobt_init_cursor(pag, tp, *agi_bpp); *curpp = xfs_inobt_init_cursor(pag, tp, *agi_bpp);
...@@ -386,7 +386,7 @@ xfs_iwalk_run_callbacks( ...@@ -386,7 +386,7 @@ xfs_iwalk_run_callbacks(
} }
/* ...and recreate the cursor just past where we left off. */ /* ...and recreate the cursor just past where we left off. */
error = xfs_ialloc_read_agi(iwag->pag, iwag->tp, agi_bpp); error = xfs_ialloc_read_agi(iwag->pag, iwag->tp, 0, agi_bpp);
if (error) if (error)
return error; return error;
*curpp = xfs_inobt_init_cursor(iwag->pag, iwag->tp, *agi_bpp); *curpp = xfs_inobt_init_cursor(iwag->pag, iwag->tp, *agi_bpp);
......
...@@ -2656,7 +2656,7 @@ xlog_recover_clear_agi_bucket( ...@@ -2656,7 +2656,7 @@ xlog_recover_clear_agi_bucket(
if (error) if (error)
goto out_error; goto out_error;
error = xfs_read_agi(pag, tp, &agibp); error = xfs_read_agi(pag, tp, 0, &agibp);
if (error) if (error)
goto out_abort; goto out_abort;
...@@ -2772,7 +2772,7 @@ xlog_recover_iunlink_ag( ...@@ -2772,7 +2772,7 @@ xlog_recover_iunlink_ag(
int bucket; int bucket;
int error; int error;
error = xfs_read_agi(pag, NULL, &agibp); error = xfs_read_agi(pag, NULL, 0, &agibp);
if (error) { if (error) {
/* /*
* AGI is b0rked. Don't process it. * AGI is b0rked. Don't process it.
......
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