]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
xfs: add filestream allocator tracepoints
authorChristoph Hellwig <hch@lst.de>
Tue, 22 Apr 2014 21:11:52 +0000 (07:11 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 22 Apr 2014 21:11:52 +0000 (07:11 +1000)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_filestream.c
fs/xfs/xfs_filestream.h
fs/xfs/xfs_trace.c
fs/xfs/xfs_trace.h

index c8a8840e5027ee8fc0f8e60032b8ee392cf4191b..8ec81bed7992149420efd5781cfb12c9596633f5 100644 (file)
 #include "xfs_filestream.h"
 #include "xfs_trace.h"
 
-#define TRACE_AG_SCAN(mp, ag, ag2)
-#define TRACE_AG_PICK1(mp, max_ag, maxfree)
-#define TRACE_AG_PICK2(mp, ag, ag2, cnt, free, scan, flag)
-#define TRACE_FREE(mp, ip, pip, ag, cnt)
-#define TRACE_LOOKUP(mp, ip, pip, ag, cnt)
-
 struct xfs_fstrm_item {
        struct xfs_mru_cache_elem       mru;
        struct xfs_inode                *ip;
@@ -87,7 +81,7 @@ enum xfs_fstrm_alloc {
  * the cache that reference per-ag array elements that have since been
  * reallocated.
  */
-static int
+int
 xfs_filestream_peek_ag(
        xfs_mount_t     *mp,
        xfs_agnumber_t  agno)
@@ -136,8 +130,7 @@ xfs_fstrm_free_func(
 
        xfs_filestream_put_ag(item->ip->i_mount, item->ag);
 
-       TRACE_FREE(mp, ip, NULL, item->ag,
-                  xfs_filestream_peek_ag(mp, item->ag));
+       trace_xfs_filestream_free(item->ip, item->ag);
 
        kmem_free(item);
 }
@@ -157,9 +150,8 @@ xfs_filestream_pick_ag(
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_fstrm_item   *item;
        struct xfs_perag        *pag;
-       xfs_extlen_t            longest, free, minfree, maxfree = 0;
+       xfs_extlen_t            longest, free = 0, minfree, maxfree = 0;
        xfs_agnumber_t          ag, max_ag = NULLAGNUMBER;
-       int                     streams, max_streams;
        int                     err, trylock, nscan;
 
        ASSERT(S_ISDIR(ip->i_d.di_mode));
@@ -174,8 +166,9 @@ xfs_filestream_pick_ag(
        trylock = XFS_ALLOC_FLAG_TRYLOCK;
 
        for (nscan = 0; 1; nscan++) {
+               trace_xfs_filestream_scan(ip, ag);
+
                pag = xfs_perag_get(mp, ag);
-               TRACE_AG_SCAN(mp, ag, atomic_read(&pag->pagf_fstrms));
 
                if (!pag->pagf_init) {
                        err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);
@@ -192,7 +185,6 @@ xfs_filestream_pick_ag(
                /* Keep track of the AG with the most free blocks. */
                if (pag->pagf_freeblks > maxfree) {
                        maxfree = pag->pagf_freeblks;
-                       max_streams = atomic_read(&pag->pagf_fstrms);
                        max_ag = ag;
                }
 
@@ -215,7 +207,6 @@ xfs_filestream_pick_ag(
 
                        /* Break out, retaining the reference on the AG. */
                        free = pag->pagf_freeblks;
-                       streams = atomic_read(&pag->pagf_fstrms);
                        xfs_perag_put(pag);
                        *agp = ag;
                        break;
@@ -251,20 +242,18 @@ next_ag:
                 */
                if (max_ag != NULLAGNUMBER) {
                        xfs_filestream_get_ag(mp, max_ag);
-                       TRACE_AG_PICK1(mp, max_ag, maxfree);
-                       streams = max_streams;
                        free = maxfree;
                        *agp = max_ag;
                        break;
                }
 
                /* take AG 0 if none matched */
-               TRACE_AG_PICK1(mp, max_ag, maxfree);
+               trace_xfs_filestream_pick(ip, *agp, free, nscan);
                *agp = 0;
                return 0;
        }
 
-       TRACE_AG_PICK2(mp, startag, *agp, streams, free, nscan, flags);
+       trace_xfs_filestream_pick(ip, *agp, free, nscan);
 
        if (*agp == NULLAGNUMBER)
                return 0;
@@ -330,7 +319,6 @@ xfs_filestream_lookup_ag(
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_inode        *pip = NULL;
        xfs_agnumber_t          startag, ag = NULLAGNUMBER;
-       int                     ref = 0;
        struct xfs_mru_cache_elem *mru;
 
        ASSERT(S_ISREG(ip->i_d.di_mode));
@@ -344,8 +332,7 @@ xfs_filestream_lookup_ag(
                ag = container_of(mru, struct xfs_fstrm_item, mru)->ag;
                xfs_mru_cache_done(mp->m_filestream);
 
-               ref = xfs_filestream_peek_ag(ip->i_mount, ag);
-               TRACE_LOOKUP(mp, ip, pip, ag, ref);
+               trace_xfs_filestream_lookup(ip, ag);
                goto out;
        }
 
index 2de853e03bf196d8e3883ceec1053a799d13cabf..2ef43406e53bd91cba503fb73527d2604136386a 100644 (file)
@@ -27,6 +27,7 @@ void xfs_filestream_unmount(struct xfs_mount *mp);
 void xfs_filestream_deassociate(struct xfs_inode *ip);
 xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip);
 int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp);
+int xfs_filestream_peek_ag(struct xfs_mount *mp, xfs_agnumber_t agno);
 
 static inline int
 xfs_inode_is_filestream(
index dee3279c095e6a32dcf460ca58acda0aa924bb2d..1e85bcd0e418629871bb2bd37d869447212c7dbf 100644 (file)
@@ -46,6 +46,7 @@
 #include "xfs_log_recover.h"
 #include "xfs_inode_item.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_filestream.h"
 
 /*
  * We include this last to have the helpers above available for the trace
index a4ae41c179a8a66a5772914a61642b8a53be1c4b..a2e18cecfd645b4ad34dd0cd2446ea48e35debce 100644 (file)
@@ -538,6 +538,64 @@ DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
 DEFINE_BUF_ITEM_EVENT(xfs_trans_buf_ordered);
 
+DECLARE_EVENT_CLASS(xfs_filestream_class,
+       TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno),
+       TP_ARGS(ip, agno),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_agnumber_t, agno)
+               __field(int, streams)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->agno = agno;
+               __entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
+       ),
+       TP_printk("dev %d:%d ino 0x%llx agno %u streams %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __entry->agno,
+                 __entry->streams)
+)
+#define DEFINE_FILESTREAM_EVENT(name) \
+DEFINE_EVENT(xfs_filestream_class, name, \
+       TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno), \
+       TP_ARGS(ip, agno))
+DEFINE_FILESTREAM_EVENT(xfs_filestream_free);
+DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup);
+DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);
+
+TRACE_EVENT(xfs_filestream_pick,
+       TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno,
+                xfs_extlen_t free, int nscan),
+       TP_ARGS(ip, agno, free, nscan),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_agnumber_t, agno)
+               __field(int, streams)
+               __field(xfs_extlen_t, free)
+               __field(int, nscan)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->agno = agno;
+               __entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
+               __entry->free = free;
+               __entry->nscan = nscan;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx agno %u streams %d free %d nscan %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __entry->agno,
+                 __entry->streams,
+                 __entry->free,
+                 __entry->nscan)
+);
+
 DECLARE_EVENT_CLASS(xfs_lock_class,
        TP_PROTO(struct xfs_inode *ip, unsigned lock_flags,
                 unsigned long caller_ip),