Commit 692b6cdd authored by Dave Chinner's avatar Dave Chinner

xfs: t_firstblock is tracking AGs not blocks

The tp->t_firstblock field is now raelly tracking the highest AG we
have locked, not the block number of the highest allocation we've
made. It's purpose is to prevent AGF locking deadlocks, so rename it
to "highest AG" and simplify the implementation to just track the
agno rather than a fsbno.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 36b6ad2d
...@@ -3169,8 +3169,8 @@ xfs_alloc_vextent( ...@@ -3169,8 +3169,8 @@ xfs_alloc_vextent(
mp = args->mp; mp = args->mp;
type = args->otype = args->type; type = args->otype = args->type;
args->agbno = NULLAGBLOCK; args->agbno = NULLAGBLOCK;
if (args->tp->t_firstblock != NULLFSBLOCK) if (args->tp->t_highest_agno != NULLAGNUMBER)
minimum_agno = XFS_FSB_TO_AGNO(mp, args->tp->t_firstblock); minimum_agno = args->tp->t_highest_agno;
/* /*
* Just fix this up, for the case where the last a.g. is shorter * Just fix this up, for the case where the last a.g. is shorter
* (or there's only one a.g.) and the caller couldn't easily figure * (or there's only one a.g.) and the caller couldn't easily figure
...@@ -3375,11 +3375,9 @@ xfs_alloc_vextent( ...@@ -3375,11 +3375,9 @@ xfs_alloc_vextent(
* deadlocks. * deadlocks.
*/ */
if (args->agbp && if (args->agbp &&
(args->tp->t_firstblock == NULLFSBLOCK || (args->tp->t_highest_agno == NULLAGNUMBER ||
args->pag->pag_agno > minimum_agno)) { args->pag->pag_agno > minimum_agno))
args->tp->t_firstblock = XFS_AGB_TO_FSB(mp, args->tp->t_highest_agno = args->pag->pag_agno;
args->pag->pag_agno, 0);
}
xfs_perag_put(args->pag); xfs_perag_put(args->pag);
return 0; return 0;
error0: error0:
......
...@@ -4192,7 +4192,7 @@ xfs_bmapi_minleft( ...@@ -4192,7 +4192,7 @@ xfs_bmapi_minleft(
{ {
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, fork); struct xfs_ifork *ifp = xfs_ifork_ptr(ip, fork);
if (tp && tp->t_firstblock != NULLFSBLOCK) if (tp && tp->t_highest_agno != NULLAGNUMBER)
return 0; return 0;
if (ifp->if_format != XFS_DINODE_FMT_BTREE) if (ifp->if_format != XFS_DINODE_FMT_BTREE)
return 1; return 1;
...@@ -6079,7 +6079,7 @@ xfs_bmap_finish_one( ...@@ -6079,7 +6079,7 @@ xfs_bmap_finish_one(
struct xfs_bmbt_irec *bmap = &bi->bi_bmap; struct xfs_bmbt_irec *bmap = &bi->bi_bmap;
int error = 0; int error = 0;
ASSERT(tp->t_firstblock == NULLFSBLOCK); ASSERT(tp->t_highest_agno == NULLAGNUMBER);
trace_xfs_bmap_deferred(tp->t_mountp, trace_xfs_bmap_deferred(tp->t_mountp,
XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock), XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
......
...@@ -184,11 +184,11 @@ xfs_bmbt_update_cursor( ...@@ -184,11 +184,11 @@ xfs_bmbt_update_cursor(
struct xfs_btree_cur *src, struct xfs_btree_cur *src,
struct xfs_btree_cur *dst) struct xfs_btree_cur *dst)
{ {
ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) || ASSERT((dst->bc_tp->t_highest_agno != NULLAGNUMBER) ||
(dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME)); (dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME));
dst->bc_ino.allocated += src->bc_ino.allocated; dst->bc_ino.allocated += src->bc_ino.allocated;
dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock; dst->bc_tp->t_highest_agno = src->bc_tp->t_highest_agno;
src->bc_ino.allocated = 0; src->bc_ino.allocated = 0;
} }
...@@ -218,7 +218,7 @@ xfs_bmbt_alloc_block( ...@@ -218,7 +218,7 @@ xfs_bmbt_alloc_block(
* we have to ensure that we attempt to locate the entire set of bmbt * we have to ensure that we attempt to locate the entire set of bmbt
* allocations in the same AG, as xfs_bmapi_write() would have reserved. * allocations in the same AG, as xfs_bmapi_write() would have reserved.
*/ */
if (cur->bc_tp->t_firstblock == NULLFSBLOCK) if (cur->bc_tp->t_highest_agno == NULLAGNUMBER)
args.minleft = xfs_bmapi_minleft(cur->bc_tp, cur->bc_ino.ip, args.minleft = xfs_bmapi_minleft(cur->bc_tp, cur->bc_ino.ip,
cur->bc_ino.whichfork); cur->bc_ino.whichfork);
......
...@@ -2943,7 +2943,7 @@ xfs_btree_split( ...@@ -2943,7 +2943,7 @@ xfs_btree_split(
DECLARE_COMPLETION_ONSTACK(done); DECLARE_COMPLETION_ONSTACK(done);
if (cur->bc_btnum != XFS_BTNUM_BMAP || if (cur->bc_btnum != XFS_BTNUM_BMAP ||
cur->bc_tp->t_firstblock == NULLFSBLOCK) cur->bc_tp->t_highest_agno == NULLAGNUMBER)
return __xfs_btree_split(cur, level, ptrp, key, curp, stat); return __xfs_btree_split(cur, level, ptrp, key, curp, stat);
args.cur = cur; args.cur = cur;
......
...@@ -1410,7 +1410,7 @@ xfs_swap_extent_rmap( ...@@ -1410,7 +1410,7 @@ xfs_swap_extent_rmap(
/* Unmap the old blocks in the source file. */ /* Unmap the old blocks in the source file. */
while (tirec.br_blockcount) { while (tirec.br_blockcount) {
ASSERT(tp->t_firstblock == NULLFSBLOCK); ASSERT(tp->t_highest_agno == NULLAGNUMBER);
trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec); trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
/* Read extent from the source file */ /* Read extent from the source file */
......
...@@ -1367,7 +1367,7 @@ xfs_itruncate_extents_flags( ...@@ -1367,7 +1367,7 @@ xfs_itruncate_extents_flags(
unmap_len = XFS_MAX_FILEOFF - first_unmap_block + 1; unmap_len = XFS_MAX_FILEOFF - first_unmap_block + 1;
while (unmap_len > 0) { while (unmap_len > 0) {
ASSERT(tp->t_firstblock == NULLFSBLOCK); ASSERT(tp->t_highest_agno == NULLAGNUMBER);
error = __xfs_bunmapi(tp, ip, first_unmap_block, &unmap_len, error = __xfs_bunmapi(tp, ip, first_unmap_block, &unmap_len,
flags, XFS_ITRUNC_MAX_EXTENTS); flags, XFS_ITRUNC_MAX_EXTENTS);
if (error) if (error)
......
...@@ -610,7 +610,7 @@ xfs_reflink_cancel_cow_blocks( ...@@ -610,7 +610,7 @@ xfs_reflink_cancel_cow_blocks(
if (error) if (error)
break; break;
} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) { } else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
ASSERT((*tpp)->t_firstblock == NULLFSBLOCK); ASSERT((*tpp)->t_highest_agno == NULLAGNUMBER);
/* Free the CoW orphan record. */ /* Free the CoW orphan record. */
xfs_refcount_free_cow_extent(*tpp, del.br_startblock, xfs_refcount_free_cow_extent(*tpp, del.br_startblock,
......
...@@ -1801,7 +1801,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, ...@@ -1801,7 +1801,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class,
__field(char, wasfromfl) __field(char, wasfromfl)
__field(int, resv) __field(int, resv)
__field(int, datatype) __field(int, datatype)
__field(xfs_fsblock_t, firstblock) __field(xfs_agnumber_t, highest_agno)
), ),
TP_fast_assign( TP_fast_assign(
__entry->dev = args->mp->m_super->s_dev; __entry->dev = args->mp->m_super->s_dev;
...@@ -1822,12 +1822,12 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, ...@@ -1822,12 +1822,12 @@ DECLARE_EVENT_CLASS(xfs_alloc_class,
__entry->wasfromfl = args->wasfromfl; __entry->wasfromfl = args->wasfromfl;
__entry->resv = args->resv; __entry->resv = args->resv;
__entry->datatype = args->datatype; __entry->datatype = args->datatype;
__entry->firstblock = args->tp->t_firstblock; __entry->highest_agno = args->tp->t_highest_agno;
), ),
TP_printk("dev %d:%d agno 0x%x agbno 0x%x minlen %u maxlen %u mod %u " TP_printk("dev %d:%d agno 0x%x agbno 0x%x minlen %u maxlen %u mod %u "
"prod %u minleft %u total %u alignment %u minalignslop %u " "prod %u minleft %u total %u alignment %u minalignslop %u "
"len %u type %s otype %s wasdel %d wasfromfl %d resv %d " "len %u type %s otype %s wasdel %d wasfromfl %d resv %d "
"datatype 0x%x firstblock 0x%llx", "datatype 0x%x highest_agno 0x%x",
MAJOR(__entry->dev), MINOR(__entry->dev), MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->agno, __entry->agno,
__entry->agbno, __entry->agbno,
...@@ -1846,7 +1846,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, ...@@ -1846,7 +1846,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class,
__entry->wasfromfl, __entry->wasfromfl,
__entry->resv, __entry->resv,
__entry->datatype, __entry->datatype,
(unsigned long long)__entry->firstblock) __entry->highest_agno)
) )
#define DEFINE_ALLOC_EVENT(name) \ #define DEFINE_ALLOC_EVENT(name) \
......
...@@ -102,7 +102,7 @@ xfs_trans_dup( ...@@ -102,7 +102,7 @@ xfs_trans_dup(
INIT_LIST_HEAD(&ntp->t_items); INIT_LIST_HEAD(&ntp->t_items);
INIT_LIST_HEAD(&ntp->t_busy); INIT_LIST_HEAD(&ntp->t_busy);
INIT_LIST_HEAD(&ntp->t_dfops); INIT_LIST_HEAD(&ntp->t_dfops);
ntp->t_firstblock = NULLFSBLOCK; ntp->t_highest_agno = NULLAGNUMBER;
ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
ASSERT(tp->t_ticket != NULL); ASSERT(tp->t_ticket != NULL);
...@@ -278,7 +278,7 @@ xfs_trans_alloc( ...@@ -278,7 +278,7 @@ xfs_trans_alloc(
INIT_LIST_HEAD(&tp->t_items); INIT_LIST_HEAD(&tp->t_items);
INIT_LIST_HEAD(&tp->t_busy); INIT_LIST_HEAD(&tp->t_busy);
INIT_LIST_HEAD(&tp->t_dfops); INIT_LIST_HEAD(&tp->t_dfops);
tp->t_firstblock = NULLFSBLOCK; tp->t_highest_agno = NULLAGNUMBER;
error = xfs_trans_reserve(tp, resp, blocks, rtextents); error = xfs_trans_reserve(tp, resp, blocks, rtextents);
if (error == -ENOSPC && want_retry) { if (error == -ENOSPC && want_retry) {
......
...@@ -132,7 +132,7 @@ typedef struct xfs_trans { ...@@ -132,7 +132,7 @@ typedef struct xfs_trans {
unsigned int t_rtx_res; /* # of rt extents resvd */ unsigned int t_rtx_res; /* # of rt extents resvd */
unsigned int t_rtx_res_used; /* # of resvd rt extents used */ unsigned int t_rtx_res_used; /* # of resvd rt extents used */
unsigned int t_flags; /* misc flags */ unsigned int t_flags; /* misc flags */
xfs_fsblock_t t_firstblock; /* first block allocated */ xfs_agnumber_t t_highest_agno; /* highest AGF locked */
struct xlog_ticket *t_ticket; /* log mgr ticket */ struct xlog_ticket *t_ticket; /* log mgr ticket */
struct xfs_mount *t_mountp; /* ptr to fs mount struct */ struct xfs_mount *t_mountp; /* ptr to fs mount struct */
struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
......
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