aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_filestream.c
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 /fs/xfs/xfs_filestream.c
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>
Diffstat (limited to 'fs/xfs/xfs_filestream.c')
-rw-r--r--fs/xfs/xfs_filestream.c29
1 files changed, 8 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