diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-12-14 18:14:59 -0500 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2009-12-15 00:08:16 -0500 |
commit | 0b1b213fcf3a8486ada99a2bab84ab8c6f51b264 (patch) | |
tree | 661fd8da7487231224c77b95c33986cb7d7b41ef /fs/xfs/xfs_alloc.c | |
parent | 6ef3554422e2c7e7aa424ba63737da498881dff4 (diff) |
xfs: event tracing support
Convert the old xfs tracing support that could only be used with the
out of tree kdb and xfsidbg patches to use the generic event tracer.
To use it make sure CONFIG_EVENT_TRACING is enabled and then enable
all xfs trace channels by:
echo 1 > /sys/kernel/debug/tracing/events/xfs/enable
or alternatively enable single events by just doing the same in one
event subdirectory, e.g.
echo 1 > /sys/kernel/debug/tracing/events/xfs/xfs_ihold/enable
or set more complex filters, etc. In Documentation/trace/events.txt
all this is desctribed in more detail. To reads the events do a
cat /sys/kernel/debug/tracing/trace
Compared to the last posting this patch converts the tracing mostly to
the one tracepoint per callsite model that other users of the new
tracing facility also employ. This allows a very fine-grained control
of the tracing, a cleaner output of the traces and also enables the
perf tool to use each tracepoint as a virtual performance counter,
allowing us to e.g. count how often certain workloads git various
spots in XFS. Take a look at
http://lwn.net/Articles/346470/
for some examples.
Also the btree tracing isn't included at all yet, as it will require
additional core tracing features not in mainline yet, I plan to
deliver it later.
And the really nice thing about this patch is that it actually removes
many lines of code while adding this nice functionality:
fs/xfs/Makefile | 8
fs/xfs/linux-2.6/xfs_acl.c | 1
fs/xfs/linux-2.6/xfs_aops.c | 52 -
fs/xfs/linux-2.6/xfs_aops.h | 2
fs/xfs/linux-2.6/xfs_buf.c | 117 +--
fs/xfs/linux-2.6/xfs_buf.h | 33
fs/xfs/linux-2.6/xfs_fs_subr.c | 3
fs/xfs/linux-2.6/xfs_ioctl.c | 1
fs/xfs/linux-2.6/xfs_ioctl32.c | 1
fs/xfs/linux-2.6/xfs_iops.c | 1
fs/xfs/linux-2.6/xfs_linux.h | 1
fs/xfs/linux-2.6/xfs_lrw.c | 87 --
fs/xfs/linux-2.6/xfs_lrw.h | 45 -
fs/xfs/linux-2.6/xfs_super.c | 104 ---
fs/xfs/linux-2.6/xfs_super.h | 7
fs/xfs/linux-2.6/xfs_sync.c | 1
fs/xfs/linux-2.6/xfs_trace.c | 75 ++
fs/xfs/linux-2.6/xfs_trace.h | 1369 +++++++++++++++++++++++++++++++++++++++++
fs/xfs/linux-2.6/xfs_vnode.h | 4
fs/xfs/quota/xfs_dquot.c | 110 ---
fs/xfs/quota/xfs_dquot.h | 21
fs/xfs/quota/xfs_qm.c | 40 -
fs/xfs/quota/xfs_qm_syscalls.c | 4
fs/xfs/support/ktrace.c | 323 ---------
fs/xfs/support/ktrace.h | 85 --
fs/xfs/xfs.h | 16
fs/xfs/xfs_ag.h | 14
fs/xfs/xfs_alloc.c | 230 +-----
fs/xfs/xfs_alloc.h | 27
fs/xfs/xfs_alloc_btree.c | 1
fs/xfs/xfs_attr.c | 107 ---
fs/xfs/xfs_attr.h | 10
fs/xfs/xfs_attr_leaf.c | 14
fs/xfs/xfs_attr_sf.h | 40 -
fs/xfs/xfs_bmap.c | 507 +++------------
fs/xfs/xfs_bmap.h | 49 -
fs/xfs/xfs_bmap_btree.c | 6
fs/xfs/xfs_btree.c | 5
fs/xfs/xfs_btree_trace.h | 17
fs/xfs/xfs_buf_item.c | 87 --
fs/xfs/xfs_buf_item.h | 20
fs/xfs/xfs_da_btree.c | 3
fs/xfs/xfs_da_btree.h | 7
fs/xfs/xfs_dfrag.c | 2
fs/xfs/xfs_dir2.c | 8
fs/xfs/xfs_dir2_block.c | 20
fs/xfs/xfs_dir2_leaf.c | 21
fs/xfs/xfs_dir2_node.c | 27
fs/xfs/xfs_dir2_sf.c | 26
fs/xfs/xfs_dir2_trace.c | 216 ------
fs/xfs/xfs_dir2_trace.h | 72 --
fs/xfs/xfs_filestream.c | 8
fs/xfs/xfs_fsops.c | 2
fs/xfs/xfs_iget.c | 111 ---
fs/xfs/xfs_inode.c | 67 --
fs/xfs/xfs_inode.h | 76 --
fs/xfs/xfs_inode_item.c | 5
fs/xfs/xfs_iomap.c | 85 --
fs/xfs/xfs_iomap.h | 8
fs/xfs/xfs_log.c | 181 +----
fs/xfs/xfs_log_priv.h | 20
fs/xfs/xfs_log_recover.c | 1
fs/xfs/xfs_mount.c | 2
fs/xfs/xfs_quota.h | 8
fs/xfs/xfs_rename.c | 1
fs/xfs/xfs_rtalloc.c | 1
fs/xfs/xfs_rw.c | 3
fs/xfs/xfs_trans.h | 47 +
fs/xfs/xfs_trans_buf.c | 62 -
fs/xfs/xfs_vnodeops.c | 8
70 files changed, 2151 insertions(+), 2592 deletions(-)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/xfs_alloc.c | 230 |
1 files changed, 44 insertions, 186 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 2cf944eb796d..a1c65fc6d9c4 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "xfs_ialloc.h" | 38 | #include "xfs_ialloc.h" |
39 | #include "xfs_alloc.h" | 39 | #include "xfs_alloc.h" |
40 | #include "xfs_error.h" | 40 | #include "xfs_error.h" |
41 | #include "xfs_trace.h" | ||
41 | 42 | ||
42 | 43 | ||
43 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) | 44 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) |
@@ -51,30 +52,6 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
51 | xfs_agblock_t bno, | 52 | xfs_agblock_t bno, |
52 | xfs_extlen_t len); | 53 | xfs_extlen_t len); |
53 | 54 | ||
54 | #if defined(XFS_ALLOC_TRACE) | ||
55 | ktrace_t *xfs_alloc_trace_buf; | ||
56 | |||
57 | #define TRACE_ALLOC(s,a) \ | ||
58 | xfs_alloc_trace_alloc(__func__, s, a, __LINE__) | ||
59 | #define TRACE_FREE(s,a,b,x,f) \ | ||
60 | xfs_alloc_trace_free(__func__, s, mp, a, b, x, f, __LINE__) | ||
61 | #define TRACE_MODAGF(s,a,f) \ | ||
62 | xfs_alloc_trace_modagf(__func__, s, mp, a, f, __LINE__) | ||
63 | #define TRACE_BUSY(__func__,s,ag,agb,l,sl,tp) \ | ||
64 | xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSY, __LINE__) | ||
65 | #define TRACE_UNBUSY(__func__,s,ag,sl,tp) \ | ||
66 | xfs_alloc_trace_busy(__func__, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__) | ||
67 | #define TRACE_BUSYSEARCH(__func__,s,ag,agb,l,tp) \ | ||
68 | xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, 0, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__) | ||
69 | #else | ||
70 | #define TRACE_ALLOC(s,a) | ||
71 | #define TRACE_FREE(s,a,b,x,f) | ||
72 | #define TRACE_MODAGF(s,a,f) | ||
73 | #define TRACE_BUSY(s,a,ag,agb,l,sl,tp) | ||
74 | #define TRACE_UNBUSY(fname,s,ag,sl,tp) | ||
75 | #define TRACE_BUSYSEARCH(fname,s,ag,agb,l,tp) | ||
76 | #endif /* XFS_ALLOC_TRACE */ | ||
77 | |||
78 | /* | 55 | /* |
79 | * Prototypes for per-ag allocation routines | 56 | * Prototypes for per-ag allocation routines |
80 | */ | 57 | */ |
@@ -498,124 +475,6 @@ xfs_alloc_read_agfl( | |||
498 | return 0; | 475 | return 0; |
499 | } | 476 | } |
500 | 477 | ||
501 | #if defined(XFS_ALLOC_TRACE) | ||
502 | /* | ||
503 | * Add an allocation trace entry for an alloc call. | ||
504 | */ | ||
505 | STATIC void | ||
506 | xfs_alloc_trace_alloc( | ||
507 | const char *name, /* function tag string */ | ||
508 | char *str, /* additional string */ | ||
509 | xfs_alloc_arg_t *args, /* allocation argument structure */ | ||
510 | int line) /* source line number */ | ||
511 | { | ||
512 | ktrace_enter(xfs_alloc_trace_buf, | ||
513 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_ALLOC | (line << 16)), | ||
514 | (void *)name, | ||
515 | (void *)str, | ||
516 | (void *)args->mp, | ||
517 | (void *)(__psunsigned_t)args->agno, | ||
518 | (void *)(__psunsigned_t)args->agbno, | ||
519 | (void *)(__psunsigned_t)args->minlen, | ||
520 | (void *)(__psunsigned_t)args->maxlen, | ||
521 | (void *)(__psunsigned_t)args->mod, | ||
522 | (void *)(__psunsigned_t)args->prod, | ||
523 | (void *)(__psunsigned_t)args->minleft, | ||
524 | (void *)(__psunsigned_t)args->total, | ||
525 | (void *)(__psunsigned_t)args->alignment, | ||
526 | (void *)(__psunsigned_t)args->len, | ||
527 | (void *)((((__psint_t)args->type) << 16) | | ||
528 | (__psint_t)args->otype), | ||
529 | (void *)(__psint_t)((args->wasdel << 3) | | ||
530 | (args->wasfromfl << 2) | | ||
531 | (args->isfl << 1) | | ||
532 | (args->userdata << 0))); | ||
533 | } | ||
534 | |||
535 | /* | ||
536 | * Add an allocation trace entry for a free call. | ||
537 | */ | ||
538 | STATIC void | ||
539 | xfs_alloc_trace_free( | ||
540 | const char *name, /* function tag string */ | ||
541 | char *str, /* additional string */ | ||
542 | xfs_mount_t *mp, /* file system mount point */ | ||
543 | xfs_agnumber_t agno, /* allocation group number */ | ||
544 | xfs_agblock_t agbno, /* a.g. relative block number */ | ||
545 | xfs_extlen_t len, /* length of extent */ | ||
546 | int isfl, /* set if is freelist allocation/free */ | ||
547 | int line) /* source line number */ | ||
548 | { | ||
549 | ktrace_enter(xfs_alloc_trace_buf, | ||
550 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_FREE | (line << 16)), | ||
551 | (void *)name, | ||
552 | (void *)str, | ||
553 | (void *)mp, | ||
554 | (void *)(__psunsigned_t)agno, | ||
555 | (void *)(__psunsigned_t)agbno, | ||
556 | (void *)(__psunsigned_t)len, | ||
557 | (void *)(__psint_t)isfl, | ||
558 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
559 | } | ||
560 | |||
561 | /* | ||
562 | * Add an allocation trace entry for modifying an agf. | ||
563 | */ | ||
564 | STATIC void | ||
565 | xfs_alloc_trace_modagf( | ||
566 | const char *name, /* function tag string */ | ||
567 | char *str, /* additional string */ | ||
568 | xfs_mount_t *mp, /* file system mount point */ | ||
569 | xfs_agf_t *agf, /* new agf value */ | ||
570 | int flags, /* logging flags for agf */ | ||
571 | int line) /* source line number */ | ||
572 | { | ||
573 | ktrace_enter(xfs_alloc_trace_buf, | ||
574 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_MODAGF | (line << 16)), | ||
575 | (void *)name, | ||
576 | (void *)str, | ||
577 | (void *)mp, | ||
578 | (void *)(__psint_t)flags, | ||
579 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno), | ||
580 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length), | ||
581 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]), | ||
582 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]), | ||
583 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), | ||
584 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), | ||
585 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst), | ||
586 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast), | ||
587 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount), | ||
588 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks), | ||
589 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest)); | ||
590 | } | ||
591 | |||
592 | STATIC void | ||
593 | xfs_alloc_trace_busy( | ||
594 | const char *name, /* function tag string */ | ||
595 | char *str, /* additional string */ | ||
596 | xfs_mount_t *mp, /* file system mount point */ | ||
597 | xfs_agnumber_t agno, /* allocation group number */ | ||
598 | xfs_agblock_t agbno, /* a.g. relative block number */ | ||
599 | xfs_extlen_t len, /* length of extent */ | ||
600 | int slot, /* perag Busy slot */ | ||
601 | xfs_trans_t *tp, | ||
602 | int trtype, /* type: add, delete, search */ | ||
603 | int line) /* source line number */ | ||
604 | { | ||
605 | ktrace_enter(xfs_alloc_trace_buf, | ||
606 | (void *)(__psint_t)(trtype | (line << 16)), | ||
607 | (void *)name, | ||
608 | (void *)str, | ||
609 | (void *)mp, | ||
610 | (void *)(__psunsigned_t)agno, | ||
611 | (void *)(__psunsigned_t)agbno, | ||
612 | (void *)(__psunsigned_t)len, | ||
613 | (void *)(__psint_t)slot, | ||
614 | (void *)tp, | ||
615 | NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
616 | } | ||
617 | #endif /* XFS_ALLOC_TRACE */ | ||
618 | |||
619 | /* | 478 | /* |
620 | * Allocation group level functions. | 479 | * Allocation group level functions. |
621 | */ | 480 | */ |
@@ -665,9 +524,6 @@ xfs_alloc_ag_vextent( | |||
665 | */ | 524 | */ |
666 | if (args->agbno != NULLAGBLOCK) { | 525 | if (args->agbno != NULLAGBLOCK) { |
667 | xfs_agf_t *agf; /* allocation group freelist header */ | 526 | xfs_agf_t *agf; /* allocation group freelist header */ |
668 | #ifdef XFS_ALLOC_TRACE | ||
669 | xfs_mount_t *mp = args->mp; | ||
670 | #endif | ||
671 | long slen = (long)args->len; | 527 | long slen = (long)args->len; |
672 | 528 | ||
673 | ASSERT(args->len >= args->minlen && args->len <= args->maxlen); | 529 | ASSERT(args->len >= args->minlen && args->len <= args->maxlen); |
@@ -682,7 +538,6 @@ xfs_alloc_ag_vextent( | |||
682 | args->pag->pagf_freeblks -= args->len; | 538 | args->pag->pagf_freeblks -= args->len; |
683 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= | 539 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= |
684 | be32_to_cpu(agf->agf_length)); | 540 | be32_to_cpu(agf->agf_length)); |
685 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | ||
686 | xfs_alloc_log_agf(args->tp, args->agbp, | 541 | xfs_alloc_log_agf(args->tp, args->agbp, |
687 | XFS_AGF_FREEBLKS); | 542 | XFS_AGF_FREEBLKS); |
688 | /* search the busylist for these blocks */ | 543 | /* search the busylist for these blocks */ |
@@ -792,13 +647,14 @@ xfs_alloc_ag_vextent_exact( | |||
792 | } | 647 | } |
793 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR); | 648 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR); |
794 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 649 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
795 | TRACE_ALLOC("normal", args); | 650 | |
651 | trace_xfs_alloc_exact_done(args); | ||
796 | args->wasfromfl = 0; | 652 | args->wasfromfl = 0; |
797 | return 0; | 653 | return 0; |
798 | 654 | ||
799 | error0: | 655 | error0: |
800 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); | 656 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); |
801 | TRACE_ALLOC("error", args); | 657 | trace_xfs_alloc_exact_error(args); |
802 | return error; | 658 | return error; |
803 | } | 659 | } |
804 | 660 | ||
@@ -958,7 +814,7 @@ xfs_alloc_ag_vextent_near( | |||
958 | args->len = blen; | 814 | args->len = blen; |
959 | if (!xfs_alloc_fix_minleft(args)) { | 815 | if (!xfs_alloc_fix_minleft(args)) { |
960 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 816 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
961 | TRACE_ALLOC("nominleft", args); | 817 | trace_xfs_alloc_near_nominleft(args); |
962 | return 0; | 818 | return 0; |
963 | } | 819 | } |
964 | blen = args->len; | 820 | blen = args->len; |
@@ -981,7 +837,8 @@ xfs_alloc_ag_vextent_near( | |||
981 | goto error0; | 837 | goto error0; |
982 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 838 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
983 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 839 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
984 | TRACE_ALLOC("first", args); | 840 | |
841 | trace_xfs_alloc_near_first(args); | ||
985 | return 0; | 842 | return 0; |
986 | } | 843 | } |
987 | /* | 844 | /* |
@@ -1272,7 +1129,7 @@ xfs_alloc_ag_vextent_near( | |||
1272 | * If we couldn't get anything, give up. | 1129 | * If we couldn't get anything, give up. |
1273 | */ | 1130 | */ |
1274 | if (bno_cur_lt == NULL && bno_cur_gt == NULL) { | 1131 | if (bno_cur_lt == NULL && bno_cur_gt == NULL) { |
1275 | TRACE_ALLOC("neither", args); | 1132 | trace_xfs_alloc_size_neither(args); |
1276 | args->agbno = NULLAGBLOCK; | 1133 | args->agbno = NULLAGBLOCK; |
1277 | return 0; | 1134 | return 0; |
1278 | } | 1135 | } |
@@ -1299,7 +1156,7 @@ xfs_alloc_ag_vextent_near( | |||
1299 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); | 1156 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); |
1300 | xfs_alloc_fix_len(args); | 1157 | xfs_alloc_fix_len(args); |
1301 | if (!xfs_alloc_fix_minleft(args)) { | 1158 | if (!xfs_alloc_fix_minleft(args)) { |
1302 | TRACE_ALLOC("nominleft", args); | 1159 | trace_xfs_alloc_near_nominleft(args); |
1303 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 1160 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
1304 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1161 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
1305 | return 0; | 1162 | return 0; |
@@ -1314,13 +1171,18 @@ xfs_alloc_ag_vextent_near( | |||
1314 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, | 1171 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, |
1315 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) | 1172 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) |
1316 | goto error0; | 1173 | goto error0; |
1317 | TRACE_ALLOC(j ? "gt" : "lt", args); | 1174 | |
1175 | if (j) | ||
1176 | trace_xfs_alloc_near_greater(args); | ||
1177 | else | ||
1178 | trace_xfs_alloc_near_lesser(args); | ||
1179 | |||
1318 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1180 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
1319 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 1181 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
1320 | return 0; | 1182 | return 0; |
1321 | 1183 | ||
1322 | error0: | 1184 | error0: |
1323 | TRACE_ALLOC("error", args); | 1185 | trace_xfs_alloc_near_error(args); |
1324 | if (cnt_cur != NULL) | 1186 | if (cnt_cur != NULL) |
1325 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 1187 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
1326 | if (bno_cur_lt != NULL) | 1188 | if (bno_cur_lt != NULL) |
@@ -1371,7 +1233,7 @@ xfs_alloc_ag_vextent_size( | |||
1371 | goto error0; | 1233 | goto error0; |
1372 | if (i == 0 || flen == 0) { | 1234 | if (i == 0 || flen == 0) { |
1373 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1235 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
1374 | TRACE_ALLOC("noentry", args); | 1236 | trace_xfs_alloc_size_noentry(args); |
1375 | return 0; | 1237 | return 0; |
1376 | } | 1238 | } |
1377 | ASSERT(i == 1); | 1239 | ASSERT(i == 1); |
@@ -1448,7 +1310,7 @@ xfs_alloc_ag_vextent_size( | |||
1448 | xfs_alloc_fix_len(args); | 1310 | xfs_alloc_fix_len(args); |
1449 | if (rlen < args->minlen || !xfs_alloc_fix_minleft(args)) { | 1311 | if (rlen < args->minlen || !xfs_alloc_fix_minleft(args)) { |
1450 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1312 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
1451 | TRACE_ALLOC("nominleft", args); | 1313 | trace_xfs_alloc_size_nominleft(args); |
1452 | args->agbno = NULLAGBLOCK; | 1314 | args->agbno = NULLAGBLOCK; |
1453 | return 0; | 1315 | return 0; |
1454 | } | 1316 | } |
@@ -1471,11 +1333,11 @@ xfs_alloc_ag_vextent_size( | |||
1471 | args->agbno + args->len <= | 1333 | args->agbno + args->len <= |
1472 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), | 1334 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1473 | error0); | 1335 | error0); |
1474 | TRACE_ALLOC("normal", args); | 1336 | trace_xfs_alloc_size_done(args); |
1475 | return 0; | 1337 | return 0; |
1476 | 1338 | ||
1477 | error0: | 1339 | error0: |
1478 | TRACE_ALLOC("error", args); | 1340 | trace_xfs_alloc_size_error(args); |
1479 | if (cnt_cur) | 1341 | if (cnt_cur) |
1480 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 1342 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
1481 | if (bno_cur) | 1343 | if (bno_cur) |
@@ -1534,7 +1396,7 @@ xfs_alloc_ag_vextent_small( | |||
1534 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), | 1396 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1535 | error0); | 1397 | error0); |
1536 | args->wasfromfl = 1; | 1398 | args->wasfromfl = 1; |
1537 | TRACE_ALLOC("freelist", args); | 1399 | trace_xfs_alloc_small_freelist(args); |
1538 | *stat = 0; | 1400 | *stat = 0; |
1539 | return 0; | 1401 | return 0; |
1540 | } | 1402 | } |
@@ -1556,17 +1418,17 @@ xfs_alloc_ag_vextent_small( | |||
1556 | */ | 1418 | */ |
1557 | if (flen < args->minlen) { | 1419 | if (flen < args->minlen) { |
1558 | args->agbno = NULLAGBLOCK; | 1420 | args->agbno = NULLAGBLOCK; |
1559 | TRACE_ALLOC("notenough", args); | 1421 | trace_xfs_alloc_small_notenough(args); |
1560 | flen = 0; | 1422 | flen = 0; |
1561 | } | 1423 | } |
1562 | *fbnop = fbno; | 1424 | *fbnop = fbno; |
1563 | *flenp = flen; | 1425 | *flenp = flen; |
1564 | *stat = 1; | 1426 | *stat = 1; |
1565 | TRACE_ALLOC("normal", args); | 1427 | trace_xfs_alloc_small_done(args); |
1566 | return 0; | 1428 | return 0; |
1567 | 1429 | ||
1568 | error0: | 1430 | error0: |
1569 | TRACE_ALLOC("error", args); | 1431 | trace_xfs_alloc_small_error(args); |
1570 | return error; | 1432 | return error; |
1571 | } | 1433 | } |
1572 | 1434 | ||
@@ -1809,17 +1671,14 @@ xfs_free_ag_extent( | |||
1809 | be32_to_cpu(agf->agf_freeblks) <= | 1671 | be32_to_cpu(agf->agf_freeblks) <= |
1810 | be32_to_cpu(agf->agf_length), | 1672 | be32_to_cpu(agf->agf_length), |
1811 | error0); | 1673 | error0); |
1812 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | ||
1813 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | 1674 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); |
1814 | if (!isfl) | 1675 | if (!isfl) |
1815 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); | 1676 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); |
1816 | XFS_STATS_INC(xs_freex); | 1677 | XFS_STATS_INC(xs_freex); |
1817 | XFS_STATS_ADD(xs_freeb, len); | 1678 | XFS_STATS_ADD(xs_freeb, len); |
1818 | } | 1679 | } |
1819 | TRACE_FREE(haveleft ? | 1680 | |
1820 | (haveright ? "both" : "left") : | 1681 | trace_xfs_free_extent(mp, agno, bno, len, isfl, haveleft, haveright); |
1821 | (haveright ? "right" : "none"), | ||
1822 | agno, bno, len, isfl); | ||
1823 | 1682 | ||
1824 | /* | 1683 | /* |
1825 | * Since blocks move to the free list without the coordination | 1684 | * Since blocks move to the free list without the coordination |
@@ -1836,7 +1695,7 @@ xfs_free_ag_extent( | |||
1836 | return 0; | 1695 | return 0; |
1837 | 1696 | ||
1838 | error0: | 1697 | error0: |
1839 | TRACE_FREE("error", agno, bno, len, isfl); | 1698 | trace_xfs_free_extent(mp, agno, bno, len, isfl, -1, -1); |
1840 | if (bno_cur) | 1699 | if (bno_cur) |
1841 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); | 1700 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); |
1842 | if (cnt_cur) | 1701 | if (cnt_cur) |
@@ -2122,7 +1981,6 @@ xfs_alloc_get_freelist( | |||
2122 | logflags |= XFS_AGF_BTREEBLKS; | 1981 | logflags |= XFS_AGF_BTREEBLKS; |
2123 | } | 1982 | } |
2124 | 1983 | ||
2125 | TRACE_MODAGF(NULL, agf, logflags); | ||
2126 | xfs_alloc_log_agf(tp, agbp, logflags); | 1984 | xfs_alloc_log_agf(tp, agbp, logflags); |
2127 | *bnop = bno; | 1985 | *bnop = bno; |
2128 | 1986 | ||
@@ -2165,6 +2023,8 @@ xfs_alloc_log_agf( | |||
2165 | sizeof(xfs_agf_t) | 2023 | sizeof(xfs_agf_t) |
2166 | }; | 2024 | }; |
2167 | 2025 | ||
2026 | trace_xfs_agf(tp->t_mountp, XFS_BUF_TO_AGF(bp), fields, _RET_IP_); | ||
2027 | |||
2168 | xfs_btree_offsets(fields, offsets, XFS_AGF_NUM_BITS, &first, &last); | 2028 | xfs_btree_offsets(fields, offsets, XFS_AGF_NUM_BITS, &first, &last); |
2169 | xfs_trans_log_buf(tp, bp, (uint)first, (uint)last); | 2029 | xfs_trans_log_buf(tp, bp, (uint)first, (uint)last); |
2170 | } | 2030 | } |
@@ -2230,13 +2090,11 @@ xfs_alloc_put_freelist( | |||
2230 | logflags |= XFS_AGF_BTREEBLKS; | 2090 | logflags |= XFS_AGF_BTREEBLKS; |
2231 | } | 2091 | } |
2232 | 2092 | ||
2233 | TRACE_MODAGF(NULL, agf, logflags); | ||
2234 | xfs_alloc_log_agf(tp, agbp, logflags); | 2093 | xfs_alloc_log_agf(tp, agbp, logflags); |
2235 | 2094 | ||
2236 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); | 2095 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); |
2237 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; | 2096 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; |
2238 | *blockp = cpu_to_be32(bno); | 2097 | *blockp = cpu_to_be32(bno); |
2239 | TRACE_MODAGF(NULL, agf, logflags); | ||
2240 | xfs_alloc_log_agf(tp, agbp, logflags); | 2098 | xfs_alloc_log_agf(tp, agbp, logflags); |
2241 | xfs_trans_log_buf(tp, agflbp, | 2099 | xfs_trans_log_buf(tp, agflbp, |
2242 | (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl), | 2100 | (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl), |
@@ -2399,7 +2257,7 @@ xfs_alloc_vextent( | |||
2399 | args->minlen > args->maxlen || args->minlen > agsize || | 2257 | args->minlen > args->maxlen || args->minlen > agsize || |
2400 | args->mod >= args->prod) { | 2258 | args->mod >= args->prod) { |
2401 | args->fsbno = NULLFSBLOCK; | 2259 | args->fsbno = NULLFSBLOCK; |
2402 | TRACE_ALLOC("badargs", args); | 2260 | trace_xfs_alloc_vextent_badargs(args); |
2403 | return 0; | 2261 | return 0; |
2404 | } | 2262 | } |
2405 | minleft = args->minleft; | 2263 | minleft = args->minleft; |
@@ -2418,12 +2276,12 @@ xfs_alloc_vextent( | |||
2418 | error = xfs_alloc_fix_freelist(args, 0); | 2276 | error = xfs_alloc_fix_freelist(args, 0); |
2419 | args->minleft = minleft; | 2277 | args->minleft = minleft; |
2420 | if (error) { | 2278 | if (error) { |
2421 | TRACE_ALLOC("nofix", args); | 2279 | trace_xfs_alloc_vextent_nofix(args); |
2422 | goto error0; | 2280 | goto error0; |
2423 | } | 2281 | } |
2424 | if (!args->agbp) { | 2282 | if (!args->agbp) { |
2425 | up_read(&mp->m_peraglock); | 2283 | up_read(&mp->m_peraglock); |
2426 | TRACE_ALLOC("noagbp", args); | 2284 | trace_xfs_alloc_vextent_noagbp(args); |
2427 | break; | 2285 | break; |
2428 | } | 2286 | } |
2429 | args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno); | 2287 | args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno); |
@@ -2488,7 +2346,7 @@ xfs_alloc_vextent( | |||
2488 | error = xfs_alloc_fix_freelist(args, flags); | 2346 | error = xfs_alloc_fix_freelist(args, flags); |
2489 | args->minleft = minleft; | 2347 | args->minleft = minleft; |
2490 | if (error) { | 2348 | if (error) { |
2491 | TRACE_ALLOC("nofix", args); | 2349 | trace_xfs_alloc_vextent_nofix(args); |
2492 | goto error0; | 2350 | goto error0; |
2493 | } | 2351 | } |
2494 | /* | 2352 | /* |
@@ -2499,7 +2357,9 @@ xfs_alloc_vextent( | |||
2499 | goto error0; | 2357 | goto error0; |
2500 | break; | 2358 | break; |
2501 | } | 2359 | } |
2502 | TRACE_ALLOC("loopfailed", args); | 2360 | |
2361 | trace_xfs_alloc_vextent_loopfailed(args); | ||
2362 | |||
2503 | /* | 2363 | /* |
2504 | * Didn't work, figure out the next iteration. | 2364 | * Didn't work, figure out the next iteration. |
2505 | */ | 2365 | */ |
@@ -2526,7 +2386,7 @@ xfs_alloc_vextent( | |||
2526 | if (args->agno == sagno) { | 2386 | if (args->agno == sagno) { |
2527 | if (no_min == 1) { | 2387 | if (no_min == 1) { |
2528 | args->agbno = NULLAGBLOCK; | 2388 | args->agbno = NULLAGBLOCK; |
2529 | TRACE_ALLOC("allfailed", args); | 2389 | trace_xfs_alloc_vextent_allfailed(args); |
2530 | break; | 2390 | break; |
2531 | } | 2391 | } |
2532 | if (flags == 0) { | 2392 | if (flags == 0) { |
@@ -2642,16 +2502,16 @@ xfs_alloc_mark_busy(xfs_trans_t *tp, | |||
2642 | } | 2502 | } |
2643 | } | 2503 | } |
2644 | 2504 | ||
2505 | trace_xfs_alloc_busy(mp, agno, bno, len, n); | ||
2506 | |||
2645 | if (n < XFS_PAGB_NUM_SLOTS) { | 2507 | if (n < XFS_PAGB_NUM_SLOTS) { |
2646 | bsy = &mp->m_perag[agno].pagb_list[n]; | 2508 | bsy = &mp->m_perag[agno].pagb_list[n]; |
2647 | mp->m_perag[agno].pagb_count++; | 2509 | mp->m_perag[agno].pagb_count++; |
2648 | TRACE_BUSY("xfs_alloc_mark_busy", "got", agno, bno, len, n, tp); | ||
2649 | bsy->busy_start = bno; | 2510 | bsy->busy_start = bno; |
2650 | bsy->busy_length = len; | 2511 | bsy->busy_length = len; |
2651 | bsy->busy_tp = tp; | 2512 | bsy->busy_tp = tp; |
2652 | xfs_trans_add_busy(tp, agno, n); | 2513 | xfs_trans_add_busy(tp, agno, n); |
2653 | } else { | 2514 | } else { |
2654 | TRACE_BUSY("xfs_alloc_mark_busy", "FULL", agno, bno, len, -1, tp); | ||
2655 | /* | 2515 | /* |
2656 | * The busy list is full! Since it is now not possible to | 2516 | * The busy list is full! Since it is now not possible to |
2657 | * track the free block, make this a synchronous transaction | 2517 | * track the free block, make this a synchronous transaction |
@@ -2678,12 +2538,12 @@ xfs_alloc_clear_busy(xfs_trans_t *tp, | |||
2678 | list = mp->m_perag[agno].pagb_list; | 2538 | list = mp->m_perag[agno].pagb_list; |
2679 | 2539 | ||
2680 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); | 2540 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); |
2541 | |||
2542 | trace_xfs_alloc_unbusy(mp, agno, idx, list[idx].busy_tp == tp); | ||
2543 | |||
2681 | if (list[idx].busy_tp == tp) { | 2544 | if (list[idx].busy_tp == tp) { |
2682 | TRACE_UNBUSY("xfs_alloc_clear_busy", "found", agno, idx, tp); | ||
2683 | list[idx].busy_tp = NULL; | 2545 | list[idx].busy_tp = NULL; |
2684 | mp->m_perag[agno].pagb_count--; | 2546 | mp->m_perag[agno].pagb_count--; |
2685 | } else { | ||
2686 | TRACE_UNBUSY("xfs_alloc_clear_busy", "missing", agno, idx, tp); | ||
2687 | } | 2547 | } |
2688 | 2548 | ||
2689 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2549 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
@@ -2724,24 +2584,22 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
2724 | if ((bno > bend) || (uend < bsy->busy_start)) { | 2584 | if ((bno > bend) || (uend < bsy->busy_start)) { |
2725 | cnt--; | 2585 | cnt--; |
2726 | } else { | 2586 | } else { |
2727 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", | ||
2728 | "found1", agno, bno, len, tp); | ||
2729 | break; | 2587 | break; |
2730 | } | 2588 | } |
2731 | } | 2589 | } |
2732 | } | 2590 | } |
2733 | 2591 | ||
2592 | trace_xfs_alloc_busysearch(mp, agno, bno, len, !!cnt); | ||
2593 | |||
2734 | /* | 2594 | /* |
2735 | * If a block was found, force the log through the LSN of the | 2595 | * If a block was found, force the log through the LSN of the |
2736 | * transaction that freed the block | 2596 | * transaction that freed the block |
2737 | */ | 2597 | */ |
2738 | if (cnt) { | 2598 | if (cnt) { |
2739 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "found", agno, bno, len, tp); | ||
2740 | lsn = bsy->busy_tp->t_commit_lsn; | 2599 | lsn = bsy->busy_tp->t_commit_lsn; |
2741 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2600 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2742 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); | 2601 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); |
2743 | } else { | 2602 | } else { |
2744 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "not-found", agno, bno, len, tp); | ||
2745 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2603 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2746 | } | 2604 | } |
2747 | } | 2605 | } |