[PATCH v2 3/3] xfs: inobt record insert/delete tracepoints

Brian Foster
2016-06-20T17:12:11Z

Add tracepoints for inobt record insert and delete. Be sure to
distinguish between the inobt and finobt in the tracepoints as the
record lifecycles differ between the trees.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/libxfs/xfs_ialloc.c | 16 +++++++++++++---
fs/xfs/xfs_trace.h | 32 ++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index fdaeee8..114b020 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -186,6 +186,8 @@ xfs_inobt_insert(
}
ASSERT(i == 0);

+ trace_xfs_irec_insert(mp, btnum, agno, thisino,
+ XFS_INODES_PER_CHUNK);
error = xfs_inobt_insert_rec(cur, XFS_INOBT_HOLEMASK_FULL,
XFS_INODES_PER_CHUNK,
XFS_INODES_PER_CHUNK,
@@ -234,6 +236,8 @@ xfs_inobt_delete(
XFS_WANT_CORRUPTED_GOTO(mp, rec.ir_startino == agino,
out_error);

+ trace_xfs_irec_delete(mp, cur->bc_btnum, agno, rec.ir_startino,
+ rec.ir_count);
error = xfs_btree_delete(cur, &i);
if (error)
goto out_error;
@@ -729,6 +733,8 @@ xfs_inobt_insert_sprec(
goto error;
/* if nothing there, insert a new record and return */
if (i == 0) {
+ trace_xfs_irec_insert(mp, btnum, agno, nrec->ir_startino,
+ nrec->ir_count);
error = xfs_inobt_insert_rec(cur, nrec->ir_holemask,
nrec->ir_count, nrec->ir_freecount,
nrec->ir_free, &i);
@@ -1789,10 +1795,13 @@ xfs_dialloc_ag(
*/
rec.ir_free &= ~XFS_INOBT_MASK(offset);
rec.ir_freecount--;
- if (rec.ir_freecount)
+ if (rec.ir_freecount) {
error = xfs_inobt_update(cur, &rec);
- else
+ } else {
+ trace_xfs_irec_delete(mp, cur->bc_btnum, agno, rec.ir_startino,
+ rec.ir_count);
error = xfs_btree_delete(cur, &i);
+ }
if (error)
goto error_cur;

@@ -2261,7 +2270,8 @@ xfs_difree_finobt(
* something is out of sync.
*/
XFS_WANT_CORRUPTED_GOTO(mp, ibtrec->ir_freecount == 1, error);
-
+ trace_xfs_irec_insert(mp, cur->bc_btnum, agno,
+ ibtrec->ir_startino, ibtrec->ir_count);
error = xfs_inobt_insert_rec(cur, ibtrec->ir_holemask,
ibtrec->ir_count,
ibtrec->ir_freecount,
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index ea94ee0..3e27cdc 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -786,6 +786,38 @@ TRACE_EVENT(xfs_irec_merge_post,
__entry->holemask)
)

+DECLARE_EVENT_CLASS(xfs_irec_class,
+ TP_PROTO(struct xfs_mount *mp, xfs_btnum_t btnum, xfs_agnumber_t agno,
+ xfs_agino_t agino, int count),
+ TP_ARGS(mp, btnum, agno, agino, count),
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(xfs_btnum_t, btnum)
+ __field(xfs_agnumber_t, agno)
+ __field(xfs_agino_t, agino)
+ __field(int, count)
+ ),
+ TP_fast_assign(
+ __entry->dev = mp->m_super->s_dev;
+ __entry->btnum = btnum;
+ __entry->agno = agno;
+ __entry->agino = agino;
+ __entry->count = count;
+ ),
+ TP_printk("dev %d:%d %s agno %d agino 0x%x count %d",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ __entry->btnum == XFS_BTNUM_INOi ? "ibt" : "fibt",
+ __entry->agno, __entry->agino, __entry->count)
+)
+
+#define DEFINE_IREC_EVENT(name) \
+DEFINE_EVENT(xfs_irec_class, name, \
+ TP_PROTO(struct xfs_mount *mp, xfs_btnum_t btnum, xfs_agnumber_t agno, \
+ xfs_agino_t agino, int count), \
+ TP_ARGS(mp, btnum, agno, agino, count))
+DEFINE_IREC_EVENT(xfs_irec_insert);
+DEFINE_IREC_EVENT(xfs_irec_delete);
+
#define DEFINE_IREF_EVENT(name) \
DEFINE_EVENT(xfs_iref_class, name, \
TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \