summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-04-22 17:11:52 -0400
committerDave Chinner <david@fromorbit.com>2014-04-22 17:11:52 -0400
commitb94acd4786dce4379e986e6d58bdd74f8986af2f (patch)
treeff66aab92805f93946c51e05c39557cfd5768182
parent3b8d90766a85e079fefaee74ca9dde43ce75edea (diff)
xfs: add filestream allocator tracepoints
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_filestream.c29
-rw-r--r--fs/xfs/xfs_filestream.h1
-rw-r--r--fs/xfs/xfs_trace.c1
-rw-r--r--fs/xfs/xfs_trace.h58
4 files changed, 68 insertions, 21 deletions
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index c8a8840e5027..8ec81bed7992 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -33,12 +33,6 @@
33#include "xfs_filestream.h" 33#include "xfs_filestream.h"
34#include "xfs_trace.h" 34#include "xfs_trace.h"
35 35
36#define TRACE_AG_SCAN(mp, ag, ag2)
37#define TRACE_AG_PICK1(mp, max_ag, maxfree)
38#define TRACE_AG_PICK2(mp, ag, ag2, cnt, free, scan, flag)
39#define TRACE_FREE(mp, ip, pip, ag, cnt)
40#define TRACE_LOOKUP(mp, ip, pip, ag, cnt)
41
42struct xfs_fstrm_item { 36struct xfs_fstrm_item {
43 struct xfs_mru_cache_elem mru; 37 struct xfs_mru_cache_elem mru;
44 struct xfs_inode *ip; 38 struct xfs_inode *ip;
@@ -87,7 +81,7 @@ enum xfs_fstrm_alloc {
87 * the cache that reference per-ag array elements that have since been 81 * the cache that reference per-ag array elements that have since been
88 * reallocated. 82 * reallocated.
89 */ 83 */
90static int 84int
91xfs_filestream_peek_ag( 85xfs_filestream_peek_ag(
92 xfs_mount_t *mp, 86 xfs_mount_t *mp,
93 xfs_agnumber_t agno) 87 xfs_agnumber_t agno)
@@ -136,8 +130,7 @@ xfs_fstrm_free_func(
136 130
137 xfs_filestream_put_ag(item->ip->i_mount, item->ag); 131 xfs_filestream_put_ag(item->ip->i_mount, item->ag);
138 132
139 TRACE_FREE(mp, ip, NULL, item->ag, 133 trace_xfs_filestream_free(item->ip, item->ag);
140 xfs_filestream_peek_ag(mp, item->ag));
141 134
142 kmem_free(item); 135 kmem_free(item);
143} 136}
@@ -157,9 +150,8 @@ xfs_filestream_pick_ag(
157 struct xfs_mount *mp = ip->i_mount; 150 struct xfs_mount *mp = ip->i_mount;
158 struct xfs_fstrm_item *item; 151 struct xfs_fstrm_item *item;
159 struct xfs_perag *pag; 152 struct xfs_perag *pag;
160 xfs_extlen_t longest, free, minfree, maxfree = 0; 153 xfs_extlen_t longest, free = 0, minfree, maxfree = 0;
161 xfs_agnumber_t ag, max_ag = NULLAGNUMBER; 154 xfs_agnumber_t ag, max_ag = NULLAGNUMBER;
162 int streams, max_streams;
163 int err, trylock, nscan; 155 int err, trylock, nscan;
164 156
165 ASSERT(S_ISDIR(ip->i_d.di_mode)); 157 ASSERT(S_ISDIR(ip->i_d.di_mode));
@@ -174,8 +166,9 @@ xfs_filestream_pick_ag(
174 trylock = XFS_ALLOC_FLAG_TRYLOCK; 166 trylock = XFS_ALLOC_FLAG_TRYLOCK;
175 167
176 for (nscan = 0; 1; nscan++) { 168 for (nscan = 0; 1; nscan++) {
169 trace_xfs_filestream_scan(ip, ag);
170
177 pag = xfs_perag_get(mp, ag); 171 pag = xfs_perag_get(mp, ag);
178 TRACE_AG_SCAN(mp, ag, atomic_read(&pag->pagf_fstrms));
179 172
180 if (!pag->pagf_init) { 173 if (!pag->pagf_init) {
181 err = xfs_alloc_pagf_init(mp, NULL, ag, trylock); 174 err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);
@@ -192,7 +185,6 @@ xfs_filestream_pick_ag(
192 /* Keep track of the AG with the most free blocks. */ 185 /* Keep track of the AG with the most free blocks. */
193 if (pag->pagf_freeblks > maxfree) { 186 if (pag->pagf_freeblks > maxfree) {
194 maxfree = pag->pagf_freeblks; 187 maxfree = pag->pagf_freeblks;
195 max_streams = atomic_read(&pag->pagf_fstrms);
196 max_ag = ag; 188 max_ag = ag;
197 } 189 }
198 190
@@ -215,7 +207,6 @@ xfs_filestream_pick_ag(
215 207
216 /* Break out, retaining the reference on the AG. */ 208 /* Break out, retaining the reference on the AG. */
217 free = pag->pagf_freeblks; 209 free = pag->pagf_freeblks;
218 streams = atomic_read(&pag->pagf_fstrms);
219 xfs_perag_put(pag); 210 xfs_perag_put(pag);
220 *agp = ag; 211 *agp = ag;
221 break; 212 break;
@@ -251,20 +242,18 @@ next_ag:
251 */ 242 */
252 if (max_ag != NULLAGNUMBER) { 243 if (max_ag != NULLAGNUMBER) {
253 xfs_filestream_get_ag(mp, max_ag); 244 xfs_filestream_get_ag(mp, max_ag);
254 TRACE_AG_PICK1(mp, max_ag, maxfree);
255 streams = max_streams;
256 free = maxfree; 245 free = maxfree;
257 *agp = max_ag; 246 *agp = max_ag;
258 break; 247 break;
259 } 248 }
260 249
261 /* take AG 0 if none matched */ 250 /* take AG 0 if none matched */
262 TRACE_AG_PICK1(mp, max_ag, maxfree); 251 trace_xfs_filestream_pick(ip, *agp, free, nscan);
263 *agp = 0; 252 *agp = 0;
264 return 0; 253 return 0;
265 } 254 }
266 255
267 TRACE_AG_PICK2(mp, startag, *agp, streams, free, nscan, flags); 256 trace_xfs_filestream_pick(ip, *agp, free, nscan);
268 257
269 if (*agp == NULLAGNUMBER) 258 if (*agp == NULLAGNUMBER)
270 return 0; 259 return 0;
@@ -330,7 +319,6 @@ xfs_filestream_lookup_ag(
330 struct xfs_mount *mp = ip->i_mount; 319 struct xfs_mount *mp = ip->i_mount;
331 struct xfs_inode *pip = NULL; 320 struct xfs_inode *pip = NULL;
332 xfs_agnumber_t startag, ag = NULLAGNUMBER; 321 xfs_agnumber_t startag, ag = NULLAGNUMBER;
333 int ref = 0;
334 struct xfs_mru_cache_elem *mru; 322 struct xfs_mru_cache_elem *mru;
335 323
336 ASSERT(S_ISREG(ip->i_d.di_mode)); 324 ASSERT(S_ISREG(ip->i_d.di_mode));
@@ -344,8 +332,7 @@ xfs_filestream_lookup_ag(
344 ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; 332 ag = container_of(mru, struct xfs_fstrm_item, mru)->ag;
345 xfs_mru_cache_done(mp->m_filestream); 333 xfs_mru_cache_done(mp->m_filestream);
346 334
347 ref = xfs_filestream_peek_ag(ip->i_mount, ag); 335 trace_xfs_filestream_lookup(ip, ag);
348 TRACE_LOOKUP(mp, ip, pip, ag, ref);
349 goto out; 336 goto out;
350 } 337 }
351 338
diff --git a/fs/xfs/xfs_filestream.h b/fs/xfs/xfs_filestream.h
index 2de853e03bf1..2ef43406e53b 100644
--- a/fs/xfs/xfs_filestream.h
+++ b/fs/xfs/xfs_filestream.h
@@ -27,6 +27,7 @@ void xfs_filestream_unmount(struct xfs_mount *mp);
27void xfs_filestream_deassociate(struct xfs_inode *ip); 27void xfs_filestream_deassociate(struct xfs_inode *ip);
28xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip); 28xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip);
29int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp); 29int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp);
30int xfs_filestream_peek_ag(struct xfs_mount *mp, xfs_agnumber_t agno);
30 31
31static inline int 32static inline int
32xfs_inode_is_filestream( 33xfs_inode_is_filestream(
diff --git a/fs/xfs/xfs_trace.c b/fs/xfs/xfs_trace.c
index dee3279c095e..1e85bcd0e418 100644
--- a/fs/xfs/xfs_trace.c
+++ b/fs/xfs/xfs_trace.c
@@ -46,6 +46,7 @@
46#include "xfs_log_recover.h" 46#include "xfs_log_recover.h"
47#include "xfs_inode_item.h" 47#include "xfs_inode_item.h"
48#include "xfs_bmap_btree.h" 48#include "xfs_bmap_btree.h"
49#include "xfs_filestream.h"
49 50
50/* 51/*
51 * We include this last to have the helpers above available for the trace 52 * We include this last to have the helpers above available for the trace
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index a4ae41c179a8..a2e18cecfd64 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -538,6 +538,64 @@ DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
538DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); 538DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
539DEFINE_BUF_ITEM_EVENT(xfs_trans_buf_ordered); 539DEFINE_BUF_ITEM_EVENT(xfs_trans_buf_ordered);
540 540
541DECLARE_EVENT_CLASS(xfs_filestream_class,
542 TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno),
543 TP_ARGS(ip, agno),
544 TP_STRUCT__entry(
545 __field(dev_t, dev)
546 __field(xfs_ino_t, ino)
547 __field(xfs_agnumber_t, agno)
548 __field(int, streams)
549 ),
550 TP_fast_assign(
551 __entry->dev = VFS_I(ip)->i_sb->s_dev;
552 __entry->ino = ip->i_ino;
553 __entry->agno = agno;
554 __entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
555 ),
556 TP_printk("dev %d:%d ino 0x%llx agno %u streams %d",
557 MAJOR(__entry->dev), MINOR(__entry->dev),
558 __entry->ino,
559 __entry->agno,
560 __entry->streams)
561)
562#define DEFINE_FILESTREAM_EVENT(name) \
563DEFINE_EVENT(xfs_filestream_class, name, \
564 TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno), \
565 TP_ARGS(ip, agno))
566DEFINE_FILESTREAM_EVENT(xfs_filestream_free);
567DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup);
568DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);
569
570TRACE_EVENT(xfs_filestream_pick,
571 TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno,
572 xfs_extlen_t free, int nscan),
573 TP_ARGS(ip, agno, free, nscan),
574 TP_STRUCT__entry(
575 __field(dev_t, dev)
576 __field(xfs_ino_t, ino)
577 __field(xfs_agnumber_t, agno)
578 __field(int, streams)
579 __field(xfs_extlen_t, free)
580 __field(int, nscan)
581 ),
582 TP_fast_assign(
583 __entry->dev = VFS_I(ip)->i_sb->s_dev;
584 __entry->ino = ip->i_ino;
585 __entry->agno = agno;
586 __entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
587 __entry->free = free;
588 __entry->nscan = nscan;
589 ),
590 TP_printk("dev %d:%d ino 0x%llx agno %u streams %d free %d nscan %d",
591 MAJOR(__entry->dev), MINOR(__entry->dev),
592 __entry->ino,
593 __entry->agno,
594 __entry->streams,
595 __entry->free,
596 __entry->nscan)
597);
598
541DECLARE_EVENT_CLASS(xfs_lock_class, 599DECLARE_EVENT_CLASS(xfs_lock_class,
542 TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, 600 TP_PROTO(struct xfs_inode *ip, unsigned lock_flags,
543 unsigned long caller_ip), 601 unsigned long caller_ip),