6 GetOptions("pid=i" => \$pid,
9 "rpctrace!" => \$rpctrace,
11 "dlm_ns=s" => \$dlm_ns,
12 "noclass!" => \$noclass,
14 "extract_start=s" => \$extract_start,
15 "extract_end=s" => \$extract_end);
19 $subsys->{UNDEFINED} = 1 << 0;
20 $subsys->{MDC} = 1 << 1;
21 $subsys->{MDS} = 1 << 2;
22 $subsys->{OSC} = 1 << 3;
23 $subsys->{OST} = 1 << 4;
24 $subsys->{CLASS} = 1 << 5;
25 $subsys->{LOG} = 1 << 6;
26 $subsys->{LLITE} = 1 << 7;
27 $subsys->{RPC} = 1 << 8;
28 $subsys->{MGMT} = 1 << 9;
29 $subsys->{PORTALS} = 1 << 10;
30 $subsys->{SOCKNAL} = 1 << 11;
31 $subsys->{QSWNAL} = 1 << 12;
32 $subsys->{PINGER} = 1 << 13;
33 $subsys->{FILTER} = 1 << 14;
34 $subsys->{PTLBD} = 1 << 15;
35 $subsys->{ECHO} = 1 << 16;
36 $subsys->{LDLM} = 1 << 17;
37 $subsys->{LOV} = 1 << 18;
38 $subsys->{GMNAL} = 1 << 19;
39 $subsys->{PTLROUTER} = 1 << 20;
40 $subsys->{COBD} = 1 << 21;
41 $subsys->{OPENIBNAL} = 1 << 22;
44 $masks->{TRACE} = 1 << 0; # /* ENTRY/EXIT markers */
45 $masks->{INODE} = 1 << 1; #
46 $masks->{SUPER} = 1 << 2; #
47 $masks->{EXT2} = 1 << 3; # /* anything from ext2_debug */
48 $masks->{MALLOC} = 1 << 4; # /* print malloc, free information */
49 $masks->{CACHE} = 1 << 5; # /* cache-related items */
50 $masks->{INFO} = 1 << 6; # /* general information */
51 $masks->{IOCTL} = 1 << 7; # /* ioctl related information */
52 $masks->{BLOCKS} = 1 << 8; # /* ext2 block allocation */
53 $masks->{NET} = 1 << 9; # /* network communications */
54 $masks->{WARNING} = 1 << 10; #
55 $masks->{BUFFS} = 1 << 11; #
56 $masks->{OTHER} = 1 << 12; #
57 $masks->{DENTRY} = 1 << 13; #
58 $masks->{PORTALS} = 1 << 14; # /* ENTRY/EXIT markers */
59 $masks->{PAGE} = 1 << 15; # /* bulk page handling */
60 $masks->{DLMTRACE} = 1 << 16; #
61 $masks->{ERROR} = 1 << 17; # /* CERROR} = ...) == CDEBUG} = D_ERROR, ...) */
62 $masks->{EMERG} = 1 << 18; # /* CEMERG} = ...) == CDEBUG} = D_EMERG, ...) */
63 $masks->{HA} = 1 << 19; # /* recovery and failover */
64 $masks->{RPCTRACE} = 1 << 19; # /* recovery and failover */
70 if ($line =~ /(\d+)\:(\d+)\:(\d+)\:(\d+\.\d+)\:(\d+)\:(\d+)\:.*/) {
79 if ($line =~ /(\d+)\:(\d+)\:(\d+)\:(\d+\.\d+)\:(\d+)\:(\d+)\:(\d+)\:.*/) {
87 $entering_rpc = /Handling RPC/;
90 $pid = extractpid($_);
98 $leaving_rpc = /Handled RPC/;
108 $entering = /Process entered/;
114 $entering = /Process leaving/;
119 my ($subsys, $mask) = split ":";
125 my ($subsys, $mask) = split ":";
131 my $linemask = shift;
133 if ($linemask == $masks->{TRACE}) {
135 print color("yellow on_black");
137 print color("green on_black");
140 if ($linemask == $masks->{DLMTRACE}) {
141 print color("magenta on_black");
143 if ($linemask == $masks->{DLM}) {
144 print color("magenta on_black");
146 if ($linemask == $masks->{DENTRY}) {
147 print color("red on_black");
156 $rc = /completion callback handler START ns: (.*) lock: (.*) lrc: (.*) mode/;
158 $completion_callbacks{$1}->{$2} = $3;
159 # print color("white");
160 # print "---CP CB START: $1 $2 $3\n";
161 # print color("reset");
163 $rc = /callback handler finished.* ns: (.*) lock: (.*) lrc: (.*) mode/;
165 # print color("white");
166 # print "---CP CB END: $1 $2 $3 deleting $completion_callbacks{$1}->{$2}\n";
167 # print color("reset");
168 delete $completion_callbacks{$1}->{$2};
172 $rc = /client blocking AST callback handler START ns: (.*) lock: (.*) lrc: (.*) mode/;
173 $blocking_callbacks{$1}->{$2} = $3;
174 # print color("white");
175 # print "---BL CB START: $1 $2\n";
176 # print color("reset");
178 $rc = /client blocking callback handler END ns: (.*) lock: (.*) lrc: (.*) mode/;
180 # print color("white");
181 # print "---BL CB END: $1 $2 $3 deleting $blocking_callbacks{$1}->{$2}\n";
182 # print color("reset");
183 delete $blocking_callbacks{$1}->{$2};
186 $rc = /ldlm_lock_addref.*ns: (.*) lock: (.*) lrc: (.*) mode/;
187 # print color("white");
188 # print "------>addref ns: $1 lock: $2 lrc: $3\n" if ($rc);
189 # print color("reset");
190 $locks{$1}->{$2} = {$3} if ($rc);
191 $rc = /ldlm_lock_decref.*ns: (.*) lock: (.*) lrc: (.*) mode/;
192 # print color("white");
193 # print "------>decref ns: $1 lock: $2 lrc: $3\n" if ($rc);
194 # print color("reset");
195 $locks{$1}->{$2} = {$3} if ($rc);
203 foreach (keys %completion_callbacks) {
206 foreach (keys %{$completion_callbacks{$ns}}) {
208 print "Unfinished completions in ns $ns: \n";
211 print " lock: $_ lrc: $completion_callbacks{$ns}->{$_}\n";
214 foreach (keys %blocking_callbacks) {
217 foreach (keys %{$blocking_callbacks{$ns}}) {
219 print "Unfinished blocking in ns $ns: \n";
222 printf(" lock: $_ lrc: %s\n", $blocking_callbacks{$ns}->{$_});
233 $rc = /D_IT UP dentry (.*) fsdata/;
234 delete $it{$1} if ($rc);
235 $rc = /D_IT DOWN dentry (.*) fsdata/;
236 $it{$1} = "yes" if ($rc);
239 sub unmatched_intents {
243 print "Unmatched intents: \n";
252 print "Usage : llanalyze LOGFILE\n";
257 if(!open(LOG, "<$ARGV[0]")){
258 print "Cannot open $ARGV[0]\n";
269 print "nodlm $nodlm, nonet $nonet, trace $trace\n";
270 print "pid: $pid, dlm_ns: $dlm_ns\n";
271 print "extract_start: $extract_start\n";
272 print "extract_end: $extract_end\n";
274 if ($extract_start && $extract_start ne "LLANAYZE_FOUND") {
275 next if (index($_, $extract_start, 0) == -1);
276 $extract_start = "LLANAYZE_FOUND";
280 next if ($extract_end eq "LLANAYZE_FOUND");
281 if (index($_, $extract_end, 0) != -1) {
282 $extract_end = "LLANAYZE_FOUND";
286 $linepid = extractpid($_);
287 $linehpid = extracthostpid($_);
288 $linemask = getmask($_);
289 $linesubsys = getsubsys($_);
291 # printf "---> mask %x subsys %x\n", $linemask, $linesubsys;
294 chop $prefix->{$linepid};
295 chop $prefix->{$linepid};
298 if ($linemask == $masks->{DENTRY}) {
301 if ($linemask == $masks->{DLMTRACE}) {
305 if ( !$pid || $linepid == $pid || $linehpid == $pid) {
306 next if (!$entering_rpc && $rpctrace && $linemask != $masks->{RPCTRACE});
307 next if ($trace && $linemask != $masks->{TRACE});
309 ( $linesubsys == $subsys->{LDLM}));
311 ( $linesubsys != $subsys->{LDLM}));
312 next if (($found_dlm_ns = index( $_, $dlm_ns, 0)) == -1);
314 ( $linesubsys == $subsys->{CLASS}));
316 ( $linesubsys == $subsys->{RPC} ||
317 $linesubsys == $subsys->{NET} ||
318 $linesubsys == $subsys->{PORTALS} ||
319 $linesubsys == $subsys->{SOCKNAL} ||
320 $linesubsys == $subsys->{QSWNAL} ||
321 $linesubsys == $subsys->{OPENIBNAL} ||
322 $linesubsys == $subsys->{GMNAL}));
323 if(!$entering_rpc) {entering_rpc($_);}
324 if(!$leaving_rpc) {leaving_rpc($_);}
326 # printf "sub/mask: %s - %s\n", getsubsys($_), getmask($_);
328 setcolor($linemask, $_);
329 my $string = $prefix->{$linepid}.$_;
331 $string = substr($string, 0, $width)."\n";
333 printf("%s", $string);
334 print color("reset");
336 # last if $count++ > 100;
339 $prefix->{$linepid} .= ' ';
346 # printf "argv %s pid %d\n", $ARGV[0], extractpid($ARGV[0]);