Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Dave Chinner
b94acd47 3b8d9076

+68 -21
+8 -21
fs/xfs/xfs_filestream.c
··· 33 33 #include "xfs_filestream.h" 34 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 - 42 36 struct xfs_fstrm_item { 43 37 struct xfs_mru_cache_elem mru; 44 38 struct xfs_inode *ip; ··· 81 87 * the cache that reference per-ag array elements that have since been 82 88 * reallocated. 83 89 */ 84 - static int 90 + int 85 91 xfs_filestream_peek_ag( 86 92 xfs_mount_t *mp, 87 93 xfs_agnumber_t agno) ··· 130 136 131 137 xfs_filestream_put_ag(item->ip->i_mount, item->ag); 132 138 133 - TRACE_FREE(mp, ip, NULL, item->ag, 134 - xfs_filestream_peek_ag(mp, item->ag)); 139 + trace_xfs_filestream_free(item->ip, item->ag); 135 140 136 141 kmem_free(item); 137 142 } ··· 150 157 struct xfs_mount *mp = ip->i_mount; 151 158 struct xfs_fstrm_item *item; 152 159 struct xfs_perag *pag; 153 - xfs_extlen_t longest, free, minfree, maxfree = 0; 160 + xfs_extlen_t longest, free = 0, minfree, maxfree = 0; 154 161 xfs_agnumber_t ag, max_ag = NULLAGNUMBER; 155 - int streams, max_streams; 156 162 int err, trylock, nscan; 157 163 158 164 ASSERT(S_ISDIR(ip->i_d.di_mode)); ··· 166 174 trylock = XFS_ALLOC_FLAG_TRYLOCK; 167 175 168 176 for (nscan = 0; 1; nscan++) { 177 + trace_xfs_filestream_scan(ip, ag); 178 + 169 179 pag = xfs_perag_get(mp, ag); 170 - TRACE_AG_SCAN(mp, ag, atomic_read(&pag->pagf_fstrms)); 171 180 172 181 if (!pag->pagf_init) { 173 182 err = xfs_alloc_pagf_init(mp, NULL, ag, trylock); ··· 185 192 /* Keep track of the AG with the most free blocks. */ 186 193 if (pag->pagf_freeblks > maxfree) { 187 194 maxfree = pag->pagf_freeblks; 188 - max_streams = atomic_read(&pag->pagf_fstrms); 189 195 max_ag = ag; 190 196 } 191 197 ··· 207 215 208 216 /* Break out, retaining the reference on the AG. */ 209 217 free = pag->pagf_freeblks; 210 - streams = atomic_read(&pag->pagf_fstrms); 211 218 xfs_perag_put(pag); 212 219 *agp = ag; 213 220 break; ··· 242 251 */ 243 252 if (max_ag != NULLAGNUMBER) { 244 253 xfs_filestream_get_ag(mp, max_ag); 245 - TRACE_AG_PICK1(mp, max_ag, maxfree); 246 - streams = max_streams; 247 254 free = maxfree; 248 255 *agp = max_ag; 249 256 break; 250 257 } 251 258 252 259 /* take AG 0 if none matched */ 253 - TRACE_AG_PICK1(mp, max_ag, maxfree); 260 + trace_xfs_filestream_pick(ip, *agp, free, nscan); 254 261 *agp = 0; 255 262 return 0; 256 263 } 257 264 258 - TRACE_AG_PICK2(mp, startag, *agp, streams, free, nscan, flags); 265 + trace_xfs_filestream_pick(ip, *agp, free, nscan); 259 266 260 267 if (*agp == NULLAGNUMBER) 261 268 return 0; ··· 319 330 struct xfs_mount *mp = ip->i_mount; 320 331 struct xfs_inode *pip = NULL; 321 332 xfs_agnumber_t startag, ag = NULLAGNUMBER; 322 - int ref = 0; 323 333 struct xfs_mru_cache_elem *mru; 324 334 325 335 ASSERT(S_ISREG(ip->i_d.di_mode)); ··· 332 344 ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; 333 345 xfs_mru_cache_done(mp->m_filestream); 334 346 335 - ref = xfs_filestream_peek_ag(ip->i_mount, ag); 336 - TRACE_LOOKUP(mp, ip, pip, ag, ref); 347 + trace_xfs_filestream_lookup(ip, ag); 337 348 goto out; 338 349 } 339 350
+1
fs/xfs/xfs_filestream.h
··· 27 27 void xfs_filestream_deassociate(struct xfs_inode *ip); 28 28 xfs_agnumber_t xfs_filestream_lookup_ag(struct xfs_inode *ip); 29 29 int xfs_filestream_new_ag(struct xfs_bmalloca *ap, xfs_agnumber_t *agp); 30 + int xfs_filestream_peek_ag(struct xfs_mount *mp, xfs_agnumber_t agno); 30 31 31 32 static inline int 32 33 xfs_inode_is_filestream(
+1
fs/xfs/xfs_trace.c
··· 46 46 #include "xfs_log_recover.h" 47 47 #include "xfs_inode_item.h" 48 48 #include "xfs_bmap_btree.h" 49 + #include "xfs_filestream.h" 49 50 50 51 /* 51 52 * We include this last to have the helpers above available for the trace
+58
fs/xfs/xfs_trace.h
··· 538 538 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); 539 539 DEFINE_BUF_ITEM_EVENT(xfs_trans_buf_ordered); 540 540 541 + DECLARE_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) \ 563 + DEFINE_EVENT(xfs_filestream_class, name, \ 564 + TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno), \ 565 + TP_ARGS(ip, agno)) 566 + DEFINE_FILESTREAM_EVENT(xfs_filestream_free); 567 + DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup); 568 + DEFINE_FILESTREAM_EVENT(xfs_filestream_scan); 569 + 570 + TRACE_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 + 541 599 DECLARE_EVENT_CLASS(xfs_lock_class, 542 600 TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, 543 601 unsigned long caller_ip),