public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Subject: [RFCv2 2/9] xfs: allow attach of dfops to transaction
Date: Wed, 24 Jan 2018 13:44:11 -0500	[thread overview]
Message-ID: <20180124184418.40403-3-bfoster@redhat.com> (raw)
In-Reply-To: <20180124184418.40403-1-bfoster@redhat.com>

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@redhat.com>
---
 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


  parent reply	other threads:[~2018-01-24 18:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 18:44 [RFCv2 0/9] xfs: defer agfl block frees Brian Foster
2018-01-24 18:44 ` [RFCv2 1/9] xfs: create agfl block free helper function Brian Foster
2018-01-24 18:44 ` Brian Foster [this message]
2018-01-24 18:44 ` [RFCv2 3/9] xfs: defer agfl block frees when dfops is available Brian Foster
2018-01-24 18:44 ` [RFCv2 4/9] xfs: defer agfl block frees from deferred ops processing context Brian Foster
2018-01-24 18:44 ` [RFCv2 5/9] xfs: defer agfl frees from inode inactivation Brian Foster
2018-01-24 18:44 ` [RFCv2 6/9] xfs: defer frees from common inode allocation paths Brian Foster
2018-01-24 18:44 ` [RFCv2 7/9] xfs: defer agfl frees from directory op transactions Brian Foster
2018-01-24 18:44 ` [RFCv2 8/9] xfs: add a runtime stat for extra transaction log regrants Brian Foster
2018-01-24 18:44 ` [RFCv2 9/9] xfs: add extra log count for transactions that defer agfl frees Brian Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180124184418.40403-3-bfoster@redhat.com \
    --to=bfoster@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox