xfs_defer_ops is a separate data structure from the xfs_trans data structure. The former is typically allocated on the stack and completed/processed before the associated thread returns outside of the scope that defines the structure. While this currently works fine, there are many places where xfs_dfops has to be plumbed through deep callchains and/or subsystem data structures (e.g., struct xfs_da_args) to other contexts. Since deferred operations cannot be processed without a transaction, the scope of xfs_defer_ops is essentially a subset of that of a transaction. Further, an upcoming enhancement to defer AGFL block frees requires to plumb xfs_defer_ops through yet another context (struct xfs_alloc_arg) that already carries a transaction. Rather than continue to pass dfops around independently, support the ability to optionally carry an xfs_defer_ops structure in the transaction itself. This facilitates the addition of deferred AGFL block free behavior from selective contexts and incremental clean up of other callchains to set/use the transaction reference rather than plumb the dfops through explicitly. Note that this patch does not change behavior nor dictate any changes to how dfops structs are allocated (on the stack) and so all existing rules apply. Changes to how dfops are allocated can be considered once all paths are converted and thus would use a consistent allocation pattern. Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx> --- fs/xfs/xfs_trans.c | 7 ++++--- fs/xfs/xfs_trans.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 86f92df32c42..50ee39faf64e 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -94,11 +94,11 @@ xfs_trans_free( * blocks. Locks and log items, however, are no inherited. They must * be added to the new transaction explicitly. */ -STATIC xfs_trans_t * +STATIC struct xfs_trans * xfs_trans_dup( - xfs_trans_t *tp) + struct xfs_trans *tp) { - xfs_trans_t *ntp; + struct xfs_trans *ntp; ntp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP); @@ -124,6 +124,7 @@ xfs_trans_dup( ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; tp->t_rtx_res = tp->t_rtx_res_used; ntp->t_pflags = tp->t_pflags; + ntp->t_dfops = tp->t_dfops; xfs_trans_dup_dqinfo(tp, ntp); diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 815b53d20e26..d3e0599a4ce9 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -111,6 +111,7 @@ typedef struct xfs_trans { struct xlog_ticket *t_ticket; /* log mgr ticket */ struct xfs_mount *t_mountp; /* ptr to fs mount struct */ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ + struct xfs_defer_ops *t_dfops; /* deferred ops reference */ unsigned int t_flags; /* misc flags */ int64_t t_icount_delta; /* superblock icount change */ int64_t t_ifree_delta; /* superblock ifree change */ -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html