All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 18/18] xfs: add more dquot tracepoints
Date: Tue, 30 Jun 2020 08:43:45 -0700	[thread overview]
Message-ID: <159353182503.2864738.13936001087522113609.stgit@magnolia> (raw)
In-Reply-To: <159353170983.2864738.16885438169173786208.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Add all the xfs_dquot fields to the tracepoint for that type; add a new
tracepoint type for the qtrx structure (dquot transaction deltas); and
use our new tracepoints.  This makes it easier for the author to trace
changes to dquot counters for debugging.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_trace.h       |  140 +++++++++++++++++++++++++++++++++++++++++++++-
 fs/xfs/xfs_trans_dquot.c |   21 +++++++
 2 files changed, 159 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 851f97dfe9e3..35b9dfd3984f 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -36,6 +36,7 @@ struct xfs_owner_info;
 struct xfs_trans_res;
 struct xfs_inobt_rec_incore;
 union xfs_btree_ptr;
+struct xfs_dqtrx;
 
 #define XFS_ATTR_FILTER_FLAGS \
 	{ XFS_ATTR_ROOT,	"ROOT" }, \
@@ -867,37 +868,59 @@ DECLARE_EVENT_CLASS(xfs_dquot_class,
 		__field(unsigned, flags)
 		__field(unsigned, nrefs)
 		__field(unsigned long long, res_bcount)
+		__field(unsigned long long, res_rtbcount)
+		__field(unsigned long long, res_icount)
+
 		__field(unsigned long long, bcount)
+		__field(unsigned long long, rtbcount)
 		__field(unsigned long long, icount)
+
 		__field(unsigned long long, blk_hardlimit)
 		__field(unsigned long long, blk_softlimit)
+		__field(unsigned long long, rtb_hardlimit)
+		__field(unsigned long long, rtb_softlimit)
 		__field(unsigned long long, ino_hardlimit)
 		__field(unsigned long long, ino_softlimit)
-	), \
+	),
 	TP_fast_assign(
 		__entry->dev = dqp->q_mount->m_super->s_dev;
 		__entry->id = dqp->q_id;
 		__entry->flags = dqp->dq_flags;
 		__entry->nrefs = dqp->q_nrefs;
+
 		__entry->res_bcount = dqp->q_blk.reserved;
+		__entry->res_rtbcount = dqp->q_rtb.reserved;
+		__entry->res_icount = dqp->q_ino.reserved;
+
 		__entry->bcount = dqp->q_blk.count;
+		__entry->rtbcount = dqp->q_rtb.count;
 		__entry->icount = dqp->q_ino.count;
+
 		__entry->blk_hardlimit = dqp->q_blk.hardlimit;
 		__entry->blk_softlimit = dqp->q_blk.softlimit;
+		__entry->rtb_hardlimit = dqp->q_rtb.hardlimit;
+		__entry->rtb_softlimit = dqp->q_rtb.softlimit;
 		__entry->ino_hardlimit = dqp->q_ino.hardlimit;
 		__entry->ino_softlimit = dqp->q_ino.softlimit;
 	),
-	TP_printk("dev %d:%d id 0x%x flags %s nrefs %u res_bc 0x%llx "
+	TP_printk("dev %d:%d id 0x%x flags %s nrefs %u "
+		  "res_bc 0x%llx res_rtbc 0x%llx res_ic 0x%llx "
 		  "bcnt 0x%llx bhardlimit 0x%llx bsoftlimit 0x%llx "
+		  "rtbcnt 0x%llx rtbhardlimit 0x%llx rtbsoftlimit 0x%llx "
 		  "icnt 0x%llx ihardlimit 0x%llx isoftlimit 0x%llx]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->id,
 		  __print_flags(__entry->flags, "|", XFS_DQ_FLAGS),
 		  __entry->nrefs,
 		  __entry->res_bcount,
+		  __entry->res_rtbcount,
+		  __entry->res_icount,
 		  __entry->bcount,
 		  __entry->blk_hardlimit,
 		  __entry->blk_softlimit,
+		  __entry->rtbcount,
+		  __entry->rtb_hardlimit,
+		  __entry->rtb_softlimit,
 		  __entry->icount,
 		  __entry->ino_hardlimit,
 		  __entry->ino_softlimit)
@@ -928,6 +951,119 @@ DEFINE_DQUOT_EVENT(xfs_dqrele);
 DEFINE_DQUOT_EVENT(xfs_dqflush);
 DEFINE_DQUOT_EVENT(xfs_dqflush_force);
 DEFINE_DQUOT_EVENT(xfs_dqflush_done);
+DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_before);
+DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_after);
+
+#define XFS_QMOPT_FLAGS \
+	{ XFS_QMOPT_UQUOTA,		"UQUOTA" }, \
+	{ XFS_QMOPT_PQUOTA,		"PQUOTA" }, \
+	{ XFS_QMOPT_FORCE_RES,		"FORCE_RES" }, \
+	{ XFS_QMOPT_SBVERSION,		"SBVERSION" }, \
+	{ XFS_QMOPT_GQUOTA,		"GQUOTA" }, \
+	{ XFS_QMOPT_INHERIT,		"INHERIT" }, \
+	{ XFS_QMOPT_RES_REGBLKS,	"RES_REGBLKS" }, \
+	{ XFS_QMOPT_RES_RTBLKS,		"RES_RTBLKS" }, \
+	{ XFS_QMOPT_BCOUNT,		"BCOUNT" }, \
+	{ XFS_QMOPT_ICOUNT,		"ICOUNT" }, \
+	{ XFS_QMOPT_RTBCOUNT,		"RTBCOUNT" }, \
+	{ XFS_QMOPT_DELBCOUNT,		"DELBCOUNT" }, \
+	{ XFS_QMOPT_DELRTBCOUNT,	"DELRTBCOUNT" }, \
+	{ XFS_QMOPT_RES_INOS,		"RES_INOS" }
+
+TRACE_EVENT(xfs_trans_mod_dquot,
+	TP_PROTO(struct xfs_trans *tp, struct xfs_dquot *dqp,
+		 unsigned int field, int64_t delta),
+	TP_ARGS(tp, dqp, field, delta),
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(unsigned int, dqflags)
+		__field(unsigned int, dqid)
+		__field(unsigned int, field)
+		__field(int64_t, delta)
+	),
+	TP_fast_assign(
+		__entry->dev = tp->t_mountp->m_super->s_dev;
+		__entry->dqflags = dqp->dq_flags;
+		__entry->dqid = dqp->q_id;
+		__entry->field = field;
+		__entry->delta = delta;
+	),
+	TP_printk("dev %d:%d dquot %s id 0x%x %s delta %lld",
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		   __print_flags(__entry->dqflags, "|", XFS_DQ_FLAGS),
+		  __entry->dqid,
+		   __print_flags(__entry->field, "|", XFS_QMOPT_FLAGS),
+		  __entry->delta)
+);
+
+DECLARE_EVENT_CLASS(xfs_dqtrx_class,
+	TP_PROTO(struct xfs_dqtrx *qtrx),
+	TP_ARGS(qtrx),
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(unsigned int, dqflags)
+		__field(u32, dqid)
+
+		__field(uint64_t, blk_res)
+		__field(int64_t,  bcount_delta)
+		__field(int64_t,  delbcnt_delta)
+
+		__field(uint64_t, rtblk_res)
+		__field(uint64_t, rtblk_res_used)
+		__field(int64_t,  rtbcount_delta)
+		__field(int64_t,  delrtb_delta)
+
+		__field(uint64_t, ino_res)
+		__field(uint64_t, ino_res_used)
+		__field(int64_t,  icount_delta)
+	),
+	TP_fast_assign(
+		__entry->dev = qtrx->qt_dquot->q_mount->m_super->s_dev;
+		__entry->dqflags = qtrx->qt_dquot->dq_flags;
+		__entry->dqid = qtrx->qt_dquot->q_id;
+
+		__entry->blk_res = qtrx->qt_blk_res;
+		__entry->bcount_delta = qtrx->qt_bcount_delta;
+		__entry->delbcnt_delta = qtrx->qt_delbcnt_delta;
+
+		__entry->rtblk_res = qtrx->qt_rtblk_res;
+		__entry->rtblk_res_used = qtrx->qt_rtblk_res_used;
+		__entry->rtbcount_delta = qtrx->qt_rtbcount_delta;
+		__entry->delrtb_delta = qtrx->qt_delrtb_delta;
+
+		__entry->ino_res = qtrx->qt_ino_res;
+		__entry->ino_res_used = qtrx->qt_ino_res_used;
+		__entry->icount_delta = qtrx->qt_icount_delta;
+	),
+	TP_printk("dev %d:%d dquot %s id 0x%x "
+		  "blk_res %llu bcount_delta %lld delbcnt_delta %lld "
+		  "rtblk_res %llu rtblk_res_used %llu rtbcount_delta %lld delrtb_delta %lld "
+		  "ino_res %llu ino_res_used %llu icount_delta %lld",
+		MAJOR(__entry->dev), MINOR(__entry->dev),
+		__print_flags(__entry->dqflags, "|", XFS_DQ_FLAGS),
+		__entry->dqid,
+
+		__entry->blk_res,
+		__entry->bcount_delta,
+		__entry->delbcnt_delta,
+
+		__entry->rtblk_res,
+		__entry->rtblk_res_used,
+		__entry->rtbcount_delta,
+		__entry->delrtb_delta,
+
+		__entry->ino_res,
+		__entry->ino_res_used,
+		__entry->icount_delta)
+)
+
+#define DEFINE_DQTRX_EVENT(name) \
+DEFINE_EVENT(xfs_dqtrx_class, name, \
+	TP_PROTO(struct xfs_dqtrx *qtrx), \
+	TP_ARGS(qtrx))
+DEFINE_DQTRX_EVENT(xfs_trans_apply_dquot_deltas);
+DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_before);
+DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_after);
 
 DECLARE_EVENT_CLASS(xfs_loggrant_class,
 	TP_PROTO(struct xlog *log, struct xlog_ticket *tic),
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 701923ea6c04..5689d9f1b748 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -15,6 +15,7 @@
 #include "xfs_trans_priv.h"
 #include "xfs_quota.h"
 #include "xfs_qm.h"
+#include "xfs_trace.h"
 
 STATIC void	xfs_trans_alloc_dqinfo(xfs_trans_t *);
 
@@ -203,6 +204,11 @@ xfs_trans_mod_dquot(
 	if (qtrx->qt_dquot == NULL)
 		qtrx->qt_dquot = dqp;
 
+	if (delta) {
+		trace_xfs_trans_mod_dquot_before(qtrx);
+		trace_xfs_trans_mod_dquot(tp, dqp, field, delta);
+	}
+
 	switch (field) {
 
 		/*
@@ -266,6 +272,10 @@ xfs_trans_mod_dquot(
 	      default:
 		ASSERT(0);
 	}
+
+	if (delta)
+		trace_xfs_trans_mod_dquot_after(qtrx);
+
 	tp->t_flags |= XFS_TRANS_DQ_DIRTY;
 }
 
@@ -391,6 +401,13 @@ xfs_trans_apply_dquot_deltas(
 				qtrx->qt_delbcnt_delta;
 			totalrtbdelta = qtrx->qt_rtbcount_delta +
 				qtrx->qt_delrtb_delta;
+
+			if (totalbdelta != 0 || totalrtbdelta != 0 ||
+			    qtrx->qt_icount_delta != 0) {
+				trace_xfs_trans_apply_dquot_deltas_before(dqp);
+				trace_xfs_trans_apply_dquot_deltas(qtrx);
+			}
+
 #ifdef DEBUG
 			if (totalbdelta < 0)
 				ASSERT(dqp->q_blk.count >= -totalbdelta);
@@ -410,6 +427,10 @@ xfs_trans_apply_dquot_deltas(
 			if (totalrtbdelta)
 				dqp->q_rtb.count += totalrtbdelta;
 
+			if (totalbdelta != 0 || totalrtbdelta != 0 ||
+			    qtrx->qt_icount_delta != 0)
+				trace_xfs_trans_apply_dquot_deltas_after(dqp);
+
 			/*
 			 * Get any default limits in use.
 			 * Start/reset the timer(s) if needed.


  parent reply	other threads:[~2020-06-30 15:44 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 15:41 [PATCH 00/18] xfs: remove xfs_disk_quot from incore dquot Darrick J. Wong
2020-06-30 15:41 ` [PATCH 01/18] xfs: clear XFS_DQ_FREEING if we can't lock the dquot buffer to flush Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:32   ` Chandan Babu R
2020-07-01  8:33   ` Christoph Hellwig
2020-07-01 22:42     ` Dave Chinner
2020-06-30 15:42 ` [PATCH 02/18] xfs: fix inode quota reservation checks Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:34   ` Christoph Hellwig
2020-06-30 15:42 ` [PATCH 03/18] xfs: validate ondisk/incore dquot flags Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:42   ` Christoph Hellwig
2020-07-01 18:25     ` Darrick J. Wong
2020-07-02  6:30       ` Christoph Hellwig
2020-07-02 15:13         ` Darrick J. Wong
2020-07-01 22:41   ` Dave Chinner
2020-07-01 23:16     ` Darrick J. Wong
2020-06-30 15:42 ` [PATCH 04/18] xfs: stop using q_core.d_flags in the quota code Darrick J. Wong
2020-07-01  8:34   ` Chandan Babu R
2020-07-01  8:47   ` Christoph Hellwig
2020-07-01 19:02     ` Darrick J. Wong
2020-07-01 20:15   ` Allison Collins
2020-07-01 22:50   ` Dave Chinner
2020-07-01 23:19     ` Darrick J. Wong
2020-07-01 23:44       ` Dave Chinner
2020-07-01 23:50         ` Darrick J. Wong
2020-07-03  0:58           ` Dave Chinner
2020-07-03 18:01             ` Darrick J. Wong
2020-06-30 15:42 ` [PATCH 05/18] xfs: stop using q_core.d_id " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:48   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-06-30 15:42 ` [PATCH 06/18] xfs: use a per-resource struct for incore dquot data Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:49   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-06-30 15:42 ` [PATCH 07/18] xfs: stop using q_core limits in the quota code Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:50   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-07-01 23:01   ` Dave Chinner
2020-07-01 23:13     ` Darrick J. Wong
2020-07-01 23:33       ` Darrick J. Wong
2020-07-01 23:45         ` Dave Chinner
2020-06-30 15:42 ` [PATCH 08/18] xfs: stop using q_core counters " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:42 ` [PATCH 09/18] xfs: stop using q_core warning " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:42 ` [PATCH 10/18] xfs: stop using q_core timers " Darrick J. Wong
2020-07-01  8:34   ` Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:43 ` [PATCH 11/18] xfs: remove qcore from incore dquots Darrick J. Wong
2020-07-01  8:34   ` Chandan Babu R
2020-07-01  8:52   ` Christoph Hellwig
2020-07-01 23:07   ` Dave Chinner
2020-07-01 23:14     ` Darrick J. Wong
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 12/18] xfs: refactor default quota limits by resource Darrick J. Wong
2020-07-01  8:52   ` Chandan Babu R
2020-07-01  8:53   ` Christoph Hellwig
2020-07-01 23:30   ` Dave Chinner
2020-07-02  0:07     ` Darrick J. Wong
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 13/18] xfs: remove unnecessary arguments from quota adjust functions Darrick J. Wong
2020-07-01  8:53   ` Christoph Hellwig
2020-07-01  8:58   ` Chandan Babu R
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 14/18] xfs: refactor quota exceeded test Darrick J. Wong
2020-07-01  8:56   ` Christoph Hellwig
2020-07-01 17:51     ` Darrick J. Wong
2020-07-01 18:48       ` Eric Sandeen
2020-07-01 23:34       ` Dave Chinner
2020-07-01 10:19   ` Chandan Babu R
2020-07-02 18:57   ` Allison Collins
2020-06-30 15:43 ` [PATCH 15/18] xfs: refactor xfs_qm_scall_setqlim Darrick J. Wong
2020-07-01  8:56   ` Christoph Hellwig
2020-07-03  4:11   ` Allison Collins
2020-07-03 12:39   ` Chandan Babu R
2020-06-30 15:43 ` [PATCH 16/18] xfs: refactor xfs_trans_dqresv Darrick J. Wong
2020-07-03  4:11   ` Allison Collins
2020-07-03 13:00   ` Chandan Babu R
2020-06-30 15:43 ` [PATCH 17/18] xfs: refactor xfs_trans_apply_dquot_deltas Darrick J. Wong
2020-07-04 20:41   ` Allison Collins
2020-07-06 13:40   ` Chandan Babu R
2020-06-30 15:43 ` Darrick J. Wong [this message]
2020-07-04 20:41   ` [PATCH 18/18] xfs: add more dquot tracepoints Allison Collins
2020-07-06 13:42   ` Chandan Babu R

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=159353182503.2864738.13936001087522113609.stgit@magnolia \
    --to=darrick.wong@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.