Whamcloud - gitweb
LUDOC-11 fix assorted minor errors
[doc/manual.git] / LustreDebugging.xml
1 <?xml version='1.0' encoding='UTF-8'?>
2 <!-- This document was created with Syntext Serna Free. --><chapter xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US" xml:id="lustredebugging">
3   <title xml:id="lustredebugging.title">Lustre Debugging</title>
4   <para>This chapter describes tips and information to debug Lustre, and includes the following sections:</para>
5   <itemizedlist>
6     <listitem>
7       <para><xref linkend="dbdoclet.50438274_15874"/></para>
8     </listitem>
9     <listitem>
10       <para><xref linkend="dbdoclet.50438274_23607"/></para>
11     </listitem>
12     <listitem>
13       <para><xref linkend="dbdoclet.50438274_80443"/></para>
14     </listitem>
15   </itemizedlist>
16   <section xml:id="dbdoclet.50438274_15874">
17     <title><indexterm><primary>debugging</primary></indexterm>
18 Diagnostic and Debugging Tools</title>
19     <para>A variety of diagnostic and analysis tools are available to debug issues with the Lustre software. Some of these are provided in Linux distributions, while others have been developed and are made available by the Lustre project.</para>
20     <section remap="h3">
21       <title><indexterm><primary>debugging</primary><secondary>tools</secondary></indexterm>
22 Lustre Debugging Tools</title>
23       <para>The following in-kernel debug mechanisms are incorporated into the Lustre software:</para>
24       <itemizedlist>
25         <listitem>
26           <para><emphasis role="bold">Debug logs</emphasis>  - A circular debug buffer to which Lustre internal debug messages are written (in contrast to error messages, which are printed to the syslog or console). Entries to the Lustre debug log are controlled by the mask set by <literal>/proc/sys/lnet/debug</literal>. The log size defaults to 5 MB per CPU but can be increased as a busy system will quickly overwrite 5 MB. When the buffer fills, the oldest information is discarded.</para>
27         </listitem>
28         <listitem>
29           <para><emphasis role="bold">Debug daemon</emphasis>  - The debug daemon controls logging of debug messages.</para>
30         </listitem>
31         <listitem>
32           <para><emphasis role="bold">
33               <literal>/proc/sys/lnet/debug</literal>
34             </emphasis>  - This file contains a mask that can be used to delimit the debugging information written out to the kernel debug logs.</para>
35         </listitem>
36       </itemizedlist>
37       <para>The following tools are also provided with the Lustre software:</para>
38       <itemizedlist>
39         <listitem>
40           <para><emphasis role="bold">
41               <literal>lctl</literal>
42             </emphasis>  - This tool is used with the debug_kernel option to manually dump the Lustre debugging log or post-process debugging logs that are dumped automatically. For more information about the lctl tool, see <xref linkend="dbdoclet.50438274_62472"/> and <xref linkend="dbdoclet.50438219_38274"/>.</para>
43         </listitem>
44         <listitem>
45           <para><replaceable role="bold">Lustre subsystem asserts</replaceable>  - A panic-style assertion (LBUG) in the kernel causes Lustre to dump the debug log to the file <literal>/tmp/lustre-log.<replaceable>&lt;timestamp&gt;</replaceable></literal> where it can be retrieved after a reboot. For more information, see <xref linkend="dbdoclet.50438198_40669"/>.</para>
46         </listitem>
47         <listitem>
48           <para>
49                   <literal>
50               <replaceable>lfs</replaceable>
51             </literal>
52                   - This utility provides access to the extended attributes (EAs) of a Lustre file (along with other information). For more information about lfs, see <xref linkend="dbdoclet.50438206_94597"/>.</para>
53         </listitem>
54       </itemizedlist>
55     </section>
56     <section remap="h3">
57       <title><indexterm><primary>debugging</primary><secondary>external tools</secondary></indexterm>External Debugging Tools</title>
58       <para>The tools described in this section are provided in the Linux kernel or are available at an external website. For information about using some of these tools for Lustre debugging, see <xref linkend="dbdoclet.50438274_23607"/> and <xref linkend="dbdoclet.50438274_80443"/>.</para>
59       <section remap="h4">
60         <title><indexterm><primary>debugging</primary><secondary>admin tools</secondary></indexterm>Tools for Administrators and Developers</title>
61         <para>Some general debugging tools provided as a part of the standard Linux distro are:</para>
62         <itemizedlist>
63           <listitem>
64             <para><emphasis role="bold">
65                 <literal>strace</literal>
66               </emphasis> . This tool allows a system call to be traced.</para>
67           </listitem>
68           <listitem>
69             <para><emphasis role="bold">
70                 <literal>/var/log/messages</literal>
71               </emphasis> . <literal>syslogd</literal> prints fatal or serious messages at this log.</para>
72           </listitem>
73           <listitem>
74             <para><emphasis role="bold">Crash dumps</emphasis> . On crash-dump enabled kernels, sysrq c produces a crash dump. Lustre enhances this crash dump with a log dump (the last 64 KB of the log) to the console.</para>
75           </listitem>
76           <listitem>
77             <para><emphasis role="bold">
78                 <literal>debugfs</literal>
79               </emphasis>. Interactive file system debugger.</para>
80           </listitem>
81         </itemizedlist>
82         <para>The following logging and data collection tools can be used to collect information for debugging Lustre kernel issues:</para>
83         <itemizedlist>
84           <listitem>
85             <para><emphasis role="bold">
86                 <literal>kdump</literal>
87               </emphasis> . A Linux kernel crash utility useful for debugging a system running Red Hat Enterprise Linux. For more information about <literal>kdump</literal>, see the Red Hat knowledge base article <link xl:href="http://kbase.redhat.com/faq/docs/DOC-6039">How do I configure kexec/kdump on Red Hat Enterprise Linux 5?</link>. To download <literal>kdump</literal>, go to the <link xl:href="http://fedoraproject.org/wiki/SystemConfig/kdump#Download">Fedora Project Download</link> site.</para>
88           </listitem>
89           <listitem>
90             <para><emphasis role="bold">
91                 <literal>netconsole</literal>
92               </emphasis>. Enables kernel-level network logging over UDP. A system requires (SysRq) allows users to collect relevant data through <literal>netconsole</literal>.</para>
93           </listitem>
94           <listitem>
95             <para><emphasis role="bold">
96                 <literal>netdump</literal>
97               </emphasis>. A crash dump utility from Red Hat that allows memory images to be dumped over a network to a central server for analysis. The <literal>netdump</literal> utility was replaced by <literal>kdump</literal> in RHEL 5. For more information about <literal>netdump</literal>, see <link xl:href="http://www.redhat.com/support/wpapers/redhat/netdump/">Red Hat, Inc.&apos;s Network Console and Crash Dump Facility</link>.</para>
98           </listitem>
99         </itemizedlist>
100       </section>
101       <section remap="h4">
102         <title><indexterm><primary>debugging</primary><secondary>developer tools</secondary></indexterm>Tools for Developers</title>
103         <para>The tools described in this section may be useful for debugging Lustre in a development environment.</para>
104         <para>Of general interest is:</para>
105         <itemizedlist>
106           <listitem>
107             <para><literal>
108                 <replaceable role="bold">leak_finder.pl</replaceable>
109               </literal> . This program provided with Lustre is useful for finding memory leaks in the code.</para>
110           </listitem>
111         </itemizedlist>
112         <para>A virtual machine is often used to create an isolated development and test environment. Some commonly-used virtual machines are:</para>
113         <itemizedlist>
114           <listitem>
115             <para><emphasis role="bold">VirtualBox Open Source Edition</emphasis> . Provides enterprise-class virtualization capability for all major platforms and is available free at <link xl:href="http://www.sun.com/software/products/virtualbox/get.jsp?intcmp=2945">Get Sun VirtualBox</link>.</para>
116           </listitem>
117           <listitem>
118             <para><emphasis role="bold">VMware Server</emphasis> . Virtualization platform available as free introductory software at <link xl:href="http://downloads.vmware.com/d/info/datacenter_downloads/vmware_server/2_0">Download VMware Server</link>.</para>
119           </listitem>
120           <listitem>
121             <para><emphasis role="bold">Xen</emphasis> . A para-virtualized environment with virtualization capabilities similar to VMware Server and Virtual Box. However, Xen allows the use of modified kernels to provide near-native performance and the ability to emulate shared storage. For more information, go to <link xl:href="http://xen.org/">xen.org</link>.</para>
122           </listitem>
123         </itemizedlist>
124         <para>A variety of debuggers and analysis tools are available including:</para>
125         <itemizedlist>
126           <listitem>
127             <para><emphasis role="bold">
128                 <literal>kgdb</literal>
129               </emphasis> . The Linux Kernel Source Level Debugger kgdb is used in conjunction with the GNU Debugger <literal>gdb</literal> for debugging the Linux kernel. For more information about using <literal>kgdb</literal> with <literal>gdb</literal>, see <link xl:href="http://www.linuxtopia.org/online_books/redhat_linux_debugging_with_gdb/running.html">Chapter 6. Running Programs Under gdb</link> in the <emphasis>Red Hat Linux 4 Debugging with GDB</emphasis> guide.</para>
130           </listitem>
131           <listitem>
132             <para><emphasis role="bold">
133                 <literal>crash</literal>
134               </emphasis> . Used to analyze saved crash dump data when a system had panicked or locked up or appears unresponsive. For more information about using crash to analyze a crash dump, see:</para>
135             <itemizedlist>
136               <listitem>
137                 <para> Red Hat Magazine article: <link xl:href="http://magazine.redhat.com/2007/08/15/a-quick-overview-of-linux-kernel-crash-dump-analysis/">A quick overview of Linux kernel crash dump analysis</link></para>
138               </listitem>
139               <listitem>
140                 <para><link xl:href="http://people.redhat.com/anderson/crash_whitepaper/#EXAMPLES">Crash Usage: A Case Study</link>  from the white paper <emphasis>Red Hat Crash Utility</emphasis> by David Anderson</para>
141               </listitem>
142               <listitem>
143                 <para> Kernel Trap forum entry: <link xl:href="http://kerneltrap.org/node/5758">Linux: Kernel Crash Dumps</link></para>
144               </listitem>
145               <listitem>
146                 <para> White paper: <link xl:href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=8&amp;ved=0CCUQFjAH&amp;url=http%3A%2F%2Fwww.kernel.sg%2Fpapers%2Fcrash-dump-analysis.pdf&amp;rct=j&amp;q=redhat+crash+dump&amp;ei=6aQBS-ifK4T8tAPcjdiHCw&amp;usg=AFQjCNEk03E3GDtAsawG3gfpwc1gGNELAg">A Quick Overview of Linux Kernel Crash Dump Analysis</link></para>
147               </listitem>
148             </itemizedlist>
149           </listitem>
150         </itemizedlist>
151       </section>
152     </section>
153   </section>
154   <section xml:id="dbdoclet.50438274_23607">
155     <title><indexterm><primary>debugging</primary><secondary>procedure</secondary></indexterm>Lustre Debugging Procedures</title>
156     <para>The procedures below may be useful to administrators or developers debugging a Lustre files system.</para>
157     <section remap="h3">
158       <title><indexterm><primary>debugging</primary><secondary>message format</secondary></indexterm>Understanding the Lustre Debug Messaging Format</title>
159       <para>Lustre debug messages are categorized by originating subsystem, message type, and location in the source code. For a list of subsystems and message types, see <xref linkend="dbdoclet.50438274_57603"/>.</para>
160       <note>
161         <para>For a current list of subsystems and debug message types, see <literal>libcfs/include/libcfs/libcfs_debug.h</literal> in the Lustre tree</para>
162       </note>
163       <para>The elements of a Lustre debug message are described in <xref linkend="dbdoclet.50438274_57177"/> Format of Lustre Debug Messages.</para>
164       <section xml:id="dbdoclet.50438274_57603">
165         <title>Lustre Debug Messages</title>
166         <para>Each Lustre debug message has the tag of the subsystem it originated in, the message type, and the location in the source code. The subsystems and debug types used in Lustre are as follows:</para>
167         <itemizedlist>
168           <listitem>
169             <para>  Standard Subsystems:</para>
170             <para> mdc, mds, osc, ost, obdclass, obdfilter, llite, ptlrpc, portals, lnd, ldlm, lov</para>
171           </listitem>
172         </itemizedlist>
173         <itemizedlist>
174           <listitem>
175             <para>  Debug Types:</para>
176           </listitem>
177           <listitem>
178             <para><informaltable frame="all">
179                 <tgroup cols="2">
180                   <colspec colname="c1" colwidth="50*"/>
181                   <colspec colname="c2" colwidth="50*"/>
182                   <thead>
183                     <row>
184                       <entry>
185                         <para><emphasis role="bold">Types</emphasis></para>
186                       </entry>
187                       <entry>
188                         <para><emphasis role="bold">Description</emphasis></para>
189                       </entry>
190                     </row>
191                   </thead>
192                   <tbody>
193                     <row>
194                       <entry>
195                         <para> <emphasis role="bold">trace</emphasis></para>
196                       </entry>
197                       <entry>
198                         <para> Entry/Exit markers</para>
199                       </entry>
200                     </row>
201                     <row>
202                       <entry>
203                         <para> <emphasis role="bold">dlmtrace</emphasis></para>
204                       </entry>
205                       <entry>
206                         <para> Locking-related information</para>
207                       </entry>
208                     </row>
209                     <row>
210                       <entry>
211                         <para> <emphasis role="bold">inode</emphasis></para>
212                       </entry>
213                       <entry>
214                         <para> &#160;</para>
215                       </entry>
216                     </row>
217                     <row>
218                       <entry>
219                         <para> <emphasis role="bold">super</emphasis></para>
220                       </entry>
221                       <entry>
222                         <para> &#160;</para>
223                       </entry>
224                     </row>
225                     <row>
226                       <entry>
227                         <para> <emphasis role="bold">ext2</emphasis></para>
228                       </entry>
229                       <entry>
230                         <para> Anything from the ext2_debug</para>
231                       </entry>
232                     </row>
233                     <row>
234                       <entry>
235                         <para> <emphasis role="bold">malloc</emphasis></para>
236                       </entry>
237                       <entry>
238                         <para> Print malloc or free information</para>
239                       </entry>
240                     </row>
241                     <row>
242                       <entry>
243                         <para> <emphasis role="bold">cache</emphasis></para>
244                       </entry>
245                       <entry>
246                         <para> Cache-related information</para>
247                       </entry>
248                     </row>
249                     <row>
250                       <entry>
251                         <para> <emphasis role="bold">info</emphasis></para>
252                       </entry>
253                       <entry>
254                         <para> General information</para>
255                       </entry>
256                     </row>
257                     <row>
258                       <entry>
259                         <para> <emphasis role="bold">ioctl</emphasis></para>
260                       </entry>
261                       <entry>
262                         <para> IOCTL-related information</para>
263                       </entry>
264                     </row>
265                     <row>
266                       <entry>
267                         <para> <emphasis role="bold">blocks</emphasis></para>
268                       </entry>
269                       <entry>
270                         <para> Ext2 block allocation information</para>
271                       </entry>
272                     </row>
273                     <row>
274                       <entry>
275                         <para> <emphasis role="bold">net</emphasis></para>
276                       </entry>
277                       <entry>
278                         <para> Networking</para>
279                       </entry>
280                     </row>
281                     <row>
282                       <entry>
283                         <para> <emphasis role="bold">warning</emphasis></para>
284                       </entry>
285                       <entry>
286                         <para> &#160;</para>
287                       </entry>
288                     </row>
289                     <row>
290                       <entry>
291                         <para> <emphasis role="bold">buffs</emphasis></para>
292                       </entry>
293                       <entry>
294                         <para> &#160;</para>
295                       </entry>
296                     </row>
297                     <row>
298                       <entry>
299                         <para> <emphasis role="bold">other</emphasis></para>
300                       </entry>
301                       <entry>
302                         <para> &#160;</para>
303                       </entry>
304                     </row>
305                     <row>
306                       <entry>
307                         <para> <emphasis role="bold">dentry</emphasis></para>
308                       </entry>
309                       <entry>
310                         <para> &#160;</para>
311                       </entry>
312                     </row>
313                     <row>
314                       <entry>
315                         <para> <emphasis role="bold">portals</emphasis></para>
316                       </entry>
317                       <entry>
318                         <para> Entry/Exit markers</para>
319                       </entry>
320                     </row>
321                     <row>
322                       <entry>
323                         <para> <emphasis role="bold">page</emphasis></para>
324                       </entry>
325                       <entry>
326                         <para> Bulk page handling</para>
327                       </entry>
328                     </row>
329                     <row>
330                       <entry>
331                         <para> <emphasis role="bold">error</emphasis></para>
332                       </entry>
333                       <entry>
334                         <para> Error messages</para>
335                       </entry>
336                     </row>
337                     <row>
338                       <entry>
339                         <para> <emphasis role="bold">emerg</emphasis></para>
340                       </entry>
341                       <entry>
342                         <para> &#160;</para>
343                       </entry>
344                     </row>
345                     <row>
346                       <entry>
347                         <para> <emphasis role="bold">rpctrace</emphasis></para>
348                       </entry>
349                       <entry>
350                         <para> For distributed debugging</para>
351                       </entry>
352                     </row>
353                     <row>
354                       <entry>
355                         <para> <emphasis role="bold">ha</emphasis></para>
356                       </entry>
357                       <entry>
358                         <para> Failover and recovery-related information</para>
359                       </entry>
360                     </row>
361                   </tbody>
362                 </tgroup>
363               </informaltable>
364 </para>
365           </listitem>
366         </itemizedlist>
367       </section>
368       <section xml:id="dbdoclet.50438274_57177">
369         <title>Format of Lustre Debug Messages</title>
370         <para>Lustre uses the <literal>CDEBUG()</literal> and <literal>CERROR()</literal> macros to print the debug or error messages. To print the message, the <literal>CDEBUG()</literal> macro uses the function <literal>libcfs_debug_msg()</literal> (<literal>libcfs/libcfs/tracefile.c</literal>). The message format is described below, along with an example.</para>
371         <informaltable frame="all">
372           <tgroup cols="2">
373             <colspec colname="c1" colwidth="50*"/>
374             <colspec colname="c2" colwidth="50*"/>
375             <thead>
376               <row>
377                 <entry>
378                   <para><emphasis role="bold">Description</emphasis></para>
379                 </entry>
380                 <entry>
381                   <para><emphasis role="bold">Parameter</emphasis></para>
382                 </entry>
383               </row>
384             </thead>
385             <tbody>
386               <row>
387                 <entry>
388                   <para> <emphasis role="bold">subsystem</emphasis></para>
389                 </entry>
390                 <entry>
391                   <para> 800000</para>
392                 </entry>
393               </row>
394               <row>
395                 <entry>
396                   <para> <emphasis role="bold">debug mask</emphasis></para>
397                 </entry>
398                 <entry>
399                   <para> 000010</para>
400                 </entry>
401               </row>
402               <row>
403                 <entry>
404                   <para> <emphasis role="bold">smp_processor_id</emphasis></para>
405                 </entry>
406                 <entry>
407                   <para> 0</para>
408                 </entry>
409               </row>
410               <row>
411                 <entry>
412                   <para> <emphasis role="bold">seconds.microseconds</emphasis></para>
413                 </entry>
414                 <entry>
415                   <para> 1081880847.677302</para>
416                 </entry>
417               </row>
418               <row>
419                 <entry>
420                   <para> <emphasis role="bold">stack size</emphasis></para>
421                 </entry>
422                 <entry>
423                   <para> 1204</para>
424                 </entry>
425               </row>
426               <row>
427                 <entry>
428                   <para> <emphasis role="bold">pid</emphasis></para>
429                 </entry>
430                 <entry>
431                   <para> 2973</para>
432                 </entry>
433               </row>
434               <row>
435                 <entry>
436                   <para> <emphasis role="bold">host pid (UML only) or zero</emphasis></para>
437                 </entry>
438                 <entry>
439                   <para> 31070</para>
440                 </entry>
441               </row>
442               <row>
443                 <entry>
444                   <para> <emphasis role="bold">(file:line #:function_name())</emphasis></para>
445                 </entry>
446                 <entry>
447                   <para> (obd_mount.c:2089:lustre_fill_super())</para>
448                 </entry>
449               </row>
450               <row>
451                 <entry>
452                   <para> <emphasis role="bold">debug message</emphasis></para>
453                 </entry>
454                 <entry>
455                   <para> kmalloced &apos;*obj&apos;: 24 at a375571c (tot 17447717)</para>
456                 </entry>
457               </row>
458             </tbody>
459           </tgroup>
460         </informaltable>
461       </section>
462       <section remap="h4">
463         <title>Lustre Debug Messages Buffer</title>
464         <para>Lustre debug messages are maintained in a buffer, with the maximum buffer size specified (in MBs) by the <literal>debug_mb</literal> parameter (<literal>lctl get_param debug_mb</literal>). The buffer is circular, so debug messages are kept until the allocated buffer limit is reached, and then the first messages are overwritten.</para>
465       </section>
466     </section>
467     <section xml:id="dbdoclet.50438274_62472">
468       <title><indexterm><primary>debugging</primary><secondary>using lctl</secondary></indexterm>Using the lctl Tool to View Debug Messages</title>
469       <para>The <literal>lctl</literal> tool allows debug messages to be filtered based on subsystems and message types to extract information useful for troubleshooting from a kernel debug log. For a command reference, see <xref linkend="dbdoclet.50438219_38274"/>.</para>
470       <para>You can use <literal>lctl</literal> to:</para>
471       <itemizedlist>
472         <listitem>
473           <para>Obtain a list of all the types and subsystems:</para>
474           <screen>lctl &gt; debug_list <emphasis>{subs | types}</emphasis></screen>
475         </listitem>
476       </itemizedlist>
477       <itemizedlist>
478         <listitem>
479           <para>Filter the debug log:</para>
480           <screen>lctl &gt; filter <emphasis>{subsystem name | debug type}</emphasis></screen>
481         </listitem>
482       </itemizedlist>
483       <note>
484         <para>When <literal>lctl</literal> filters, it removes unwanted lines from the displayed output. This does not affect the contents of the debug log in the kernel&apos;s memory. As a result, you can print the log many times with different filtering levels without worrying about losing data.</para>
485       </note>
486       <itemizedlist>
487         <listitem>
488           <para>Show debug messages belonging to certain subsystem or type:</para>
489           <screen>lctl &gt; show <emphasis>{subsystem name | debug type}</emphasis></screen>
490           <para><literal>debug_kernel</literal> pulls the data from the kernel logs, filters it appropriately, and displays or saves it as per the specified options</para>
491           <screen>lctl &gt; debug_kernel [<emphasis>output filename</emphasis>]</screen>
492           <para>If the debugging is being done on User Mode Linux (UML), it might be useful to save the logs on the host machine so that they can be used at a later time.</para>
493         </listitem>
494       </itemizedlist>
495       <itemizedlist>
496         <listitem>
497           <para>Filter a log on disk, if you already have a debug log saved to disk (likely from a crash):</para>
498           <screen>lctl &gt; debug_file <emphasis>{input filename}</emphasis> [<emphasis>output filename</emphasis>] </screen>
499           <para>During the debug session, you can add markers or breaks to the log for any reason:</para>
500           <screen>lctl &gt; mark [marker text] </screen>
501           <para>The marker text defaults to the current date and time in the debug log (similar to the example shown below):</para>
502           <screen>DEBUG MARKER: Tue Mar 5 16:06:44 EST 2002 
503 </screen>
504         </listitem>
505       </itemizedlist>
506       <itemizedlist>
507         <listitem>
508           <para>Completely flush the kernel debug buffer:</para>
509           <screen>lctl &gt; clear
510 </screen>
511         </listitem>
512       </itemizedlist>
513       <note>
514         <para>Debug messages displayed with <literal>lctl</literal> are also subject to the kernel debug masks; the filters are additive.</para>
515       </note>
516       <section remap="h4">
517         <title><indexterm><primary>debugging</primary><secondary>lctl example</secondary></indexterm>Sample <literal>lctl</literal> Run</title>
518         <para>Below is a sample run using the <literal>lctl</literal> command.</para>
519         <screen>bash-2.04# ./lctl 
520 lctl &gt; debug_kernel /tmp/lustre_logs/log_all 
521 Debug log: 324 lines, 324 kept, 0 dropped. 
522 lctl &gt; filter trace 
523 Disabling output of type &quot;trace&quot; 
524 lctl &gt; debug_kernel /tmp/lustre_logs/log_notrace 
525 Debug log: 324 lines, 282 kept, 42 dropped. 
526 lctl &gt; show trace 
527 Enabling output of type &quot;trace&quot; 
528 lctl &gt; filter portals 
529 Disabling output from subsystem &quot;portals&quot; 
530 lctl &gt; debug_kernel /tmp/lustre_logs/log_noportals 
531 Debug log: 324 lines, 258 kept, 66 dropped. 
532 </screen>
533       </section>
534     </section>
535     <section remap="h3">
536       <title>Dumping the Buffer to a File (<literal>debug_daemon</literal>)</title>
537       <para>The <literal>lctl debug_daemon</literal> command is used to continuously dump the <literal>debug_kernel</literal> buffer to a user-specified file. This functionality uses a kernel thread to continuously dump the messages from the kernel debug log, so that much larger debug logs can be saved over a longer time than would fit in the kernel ringbuffer.</para>
538       <para>The <literal>debug_daemon</literal> is highly dependent on file system write speed. File system write operations may not be fast enough to flush out all of the <literal>debug_buffer</literal> if the Lustre file system is under heavy system load and continues to log debug messages to the <literal>debug_buffer</literal>. The <literal>debug_daemon</literal> will write the message <literal>DEBUG MARKER: Trace buffer full</literal> into the <literal>debug_buffer</literal> to indicate the <literal>debug_buffer</literal> contents are overlapping before the <literal>debug_daemon</literal> flushes data to a file.</para>
539       <para>Users can use the <literal>lctl debug_daemon</literal> command to start or stop the Lustre daemon from dumping the <literal>debug_buffer</literal> to a file.</para>
540       <section remap="h4">
541         <title><literal>lctl debug_daemon</literal> Commands</title>
542         <para>To initiate the <literal>debug_daemon</literal> to start dumping the <literal>debug_buffer</literal> into a file, run as the root user:</para>
543         <screen>lctl debug_daemon start {filename} [{megabytes}]</screen>
544         <para>The debug log will be written to the specified filename from the kernel.  The file will be limited to the optionally specified number of megabytes.</para>
545         <para>The daemon wraps around and dumps data to the beginning of the file when the output file size is over the limit of the user-specified file size. To decode the dumped file to ASCII and sort the log entries by time, run:</para>
546         <screen>lctl debug_file {filename} &gt; {newfile}</screen>
547         <para>The output is internally sorted by the <literal>lctl</literal> command.</para>
548         <para>To stop the <literal>debug_daemon</literal> operation and flush the file output, run:</para>
549         <screen>lctl debug_daemon stop</screen>
550         <para>Otherwise, <literal>debug_daemon</literal> is shut down as part of the Lustre file system shutdown process. Users can restart <literal>debug_daemon</literal> by using start command after each stop command issued.</para>
551         <para>This is an example using <literal>debug_daemon</literal> with the interactive mode of <literal>lctl</literal> to dump debug logs to a 40 MB file.</para>
552         <screen>lctl</screen>
553         <screen>lctl &gt; debug_daemon start /var/log/lustre.40.bin 40 </screen>
554         <screen>{run filesystem operations to debug}</screen>
555         <screen>lctl &gt; debug_daemon stop </screen>
556         <screen>lctl &gt; debug_file /var/log/lustre.bin /var/log/lustre.log</screen>
557         <para>To start another daemon with an unlimited file size, run:</para>
558         <screen>lctl &gt; debug_daemon start /var/log/lustre.bin </screen>
559         <para>The text message <literal>*** End of debug_daemon trace log ***</literal> appears at the end of each output file.</para>
560       </section>
561     </section>
562     <section remap="h3">
563       <title><indexterm><primary>debugging</primary><secondary>kernel debug log</secondary></indexterm>Controlling Information Written to the Kernel Debug Log</title>
564       <para>The <literal>lctl set_param subsystem_debug={subsystem_mask}</literal> and <literal>lctl set_param debug={debug_mask}</literal> are used to determine which information is written to the debug log. The subsystem_debug mask determines the information written to the log based on the functional area of the code (such as lnet, osc, or ldlm). The debug mask controls information based on the message type (such as info, error, trace, or malloc).</para>
565       <para>To turn off Lustre debugging completely:</para>
566       <screen>lctl set_param debug=0 </screen>
567       <para>To turn on full Lustre debugging:</para>
568       <screen>lctl set_param debug=-1 </screen>
569       <para>To log only messages related to network communications:</para>
570       <screen>lctl set_param debug=net </screen>
571       <para>To turn on logging of messages related to network communications and existing debug flags:</para>
572       <screen>lctl set_param debug=+net </screen>
573       <para>To turn off network logging with changing existing flags:</para>
574       <screen>lctl set_param debug=-net </screen>
575       <para>The various options available to print to kernel debug logs are listed in <literal>libcfs/include/libcfs/libcfs.h</literal></para>
576     </section>
577     <section remap="h3">
578       <title><indexterm><primary>debugging</primary><secondary>using strace</secondary></indexterm>Troubleshooting with <literal>strace</literal></title>
579       <para>The <literal>strace</literal> utility provided with the Linux distribution enables system calls to be traced by intercepting all the system calls made by a process and recording the system call name, arguments, and return values.</para>
580       <para>To invoke <literal>strace</literal> on a program, enter:</para>
581       <screen>$ strace <emphasis>{program} {args}</emphasis> </screen>
582       <para>Sometimes, a system call may fork child processes. In this situation, use the <literal>-f</literal> option of <literal>strace</literal> to trace the child processes:</para>
583       <screen>$ strace -f <emphasis>{program} {args}</emphasis> </screen>
584       <para>To redirect the <literal>strace</literal> output to a file, enter:</para>
585       <screen>$ strace -o <emphasis>{filename} {program} {args}</emphasis> </screen>
586       <para>Use the <literal>-ff</literal> option, along with <literal>-o</literal>, to save the trace output in <literal>filename.pid</literal>, where <literal>pid</literal> is the process ID of the process being traced. Use the <literal>-ttt</literal> option to timestamp all lines in the strace output, so they can be correlated to operations in the lustre kernel debug log.</para>
587     </section>
588     <section remap="h3">
589       <title><indexterm><primary>debugging</primary><secondary>disk contents</secondary></indexterm>Looking at Disk Content</title>
590       <para>In Lustre, the inodes on the metadata server contain extended attributes (EAs) that store information about file striping. EAs contain a list of all object IDs and their locations (that is, the OST that stores them). The <literal>lfs</literal> tool can be used to obtain this information for a given file using the <literal>getstripe</literal> subcommand. Use a corresponding <literal>lfs setstripe</literal> command to specify striping attributes for a new file or directory.</para>
591       <para>The <literal>lfs getstripe</literal> command takes a Lustre filename as input and lists all the objects that form a part of this file. To obtain this information for the file <literal>/mnt/lustre/frog</literal> in Lustre file system, run:</para>
592       <screen>$ lfs getstripe /mnt/lustre/frog
593 lmm_stripe_count:   2
594 lmm_stripe_size:    1048576
595 lmm_stripe_offset:  2
596         obdidx           objid          objid           group
597              2          818855        0xc7ea7               0
598              0          873123        0xd52a3               0
599         </screen>
600       <para>The <literal>debugfs</literal> tool is provided in the <literal>e2fsprogs</literal> package. It can be used for interactive debugging of an <literal>ldiskfs</literal> file system. The <literal>debugfs</literal> tool can either be used to check status or modify information in the file system. In Lustre, all objects that belong to a file are stored in an underlying <literal>ldiskfs</literal> file system on the OSTs. The file system uses the object IDs as the file names. Once the object IDs are known, use the <literal>debugfs</literal> tool to obtain the attributes of all objects from different OSTs.</para>
601       <para>A sample run for the <literal>/mnt/lustre/frog</literal> file used in the above example is shown here:</para>
602       <screen>$ debugfs -c -R "stat O/0/d$((818855 % 32))/818855" /dev/vgmyth/lvmythost2
603
604 debugfs 1.41.90.wc3 (28-May-2011)
605 /dev/vgmyth/lvmythost2: catastrophic mode - not reading inode or group bitmaps
606 Inode: 227649   Type: regular    Mode:  0666   Flags: 0x80000
607 Generation: 1375019198    Version: 0x0000002f:0000728f
608 User:  1000   Group:  1000   Size: 2800
609 File ACL: 0    Directory ACL: 0
610 Links: 1   Blockcount: 8
611 Fragment:  Address: 0    Number: 0    Size: 0
612  ctime: 0x4e177fe5:00000000 -- Fri Jul  8 16:08:37 2011
613  atime: 0x4d2e2397:00000000 -- Wed Jan 12 14:56:39 2011
614  mtime: 0x4e177fe5:00000000 -- Fri Jul  8 16:08:37 2011
615 crtime: 0x4c3b5820:a364117c -- Mon Jul 12 12:00:00 2010
616 Size of extra inode fields: 28
617 Extended attributes stored in inode body: 
618   fid = "08 80 24 00 00 00 00 00 28 8a e7 fc 00 00 00 00 a7 7e 0c 00 00 00 00 00
619  00 00 00 00 00 00 00 00 " (32)
620   fid: objid=818855 seq=0 parent=[0x248008:0xfce78a28:0x0] stripe=0
621 EXTENTS:
622 (0):63331288
623       </screen>
624     </section>
625     <section remap="h3">
626       <title>Finding the Lustre UUID of an OST</title>
627       <para>To determine the Lustre UUID of an OST disk (for example, if you mix up the cables on your OST devices or the SCSI bus numbering suddenly changes and the SCSI devices get new names), it is possible to extract this from the last_rcvd file using debugfs:</para>
628       <screen>debugfs -c -R "dump last_rcvd /tmp/last_rcvd" /dev/sdc
629 strings /tmp/last_rcvd | head -1
630 myth-OST0004_UUID
631       </screen>
632       <para>It is also possible (and easier) to extract this from the filesystem label using the <literal>dumpe2fs</literal> command:</para>
633       <screen>dumpe2fs -h /dev/sdc | grep volume
634 dumpe2fs 1.41.90.wc3 (28-May-2011)
635 Filesystem volume name:   myth-OST0004
636       </screen>
637       <para>The debugfs and dumpe2fs commands are well documented in the <literal>debugfs(8)</literal> and <literal>dumpe2fs(8)</literal> manual pages.</para>
638     </section>
639     <section remap="h3">
640       <title>Printing Debug Messages to the Console</title>
641       <para>To dump debug messages to the console (<literal>/var/log/messages</literal>), set the corresponding debug mask in the <literal>printk</literal> flag:</para>
642       <screen>lctl set_param printk=-1 </screen>
643       <para>This slows down the system dramatically. It is also possible to selectively enable or disable this capability for particular flags using:<literal>lctl set_param printk=+vfstrace</literal> and <literal>lctl set_param printk=-vfstrace </literal>.</para>
644       <para>It is possible to disable warning, error, and console messages, though it is strongly recommended to have something like <literal>lctl debug_daemon</literal> running to capture this data to a local file system for failure detection purposes.</para>
645     </section>
646     <section remap="h3">
647       <title>Tracing Lock Traffic</title>
648       <para>Lustre has a specific debug type category for tracing lock traffic. Use:</para>
649       <screen>lctl&gt; filter all_types 
650 lctl&gt; show dlmtrace 
651 lctl&gt; debug_kernel [filename] </screen>
652     </section>
653   </section>
654   <section xml:id="dbdoclet.50438274_80443">
655     <title><indexterm><primary>debugging</primary><secondary>developers tools</secondary></indexterm>Lustre Debugging for Developers</title>
656     <para>The procedures in this section may be useful to developers debugging Lustre code.</para>
657     <section remap="h3">
658       <title>Adding Debugging to the Lustre Source Code</title>
659       <para>The debugging infrastructure provides a number of macros that can be used in Lustre source code to aid in debugging or reporting serious errors.</para>
660       <para>To use these macros, you will need to set the <literal>DEBUG_SUBSYSTEM</literal> variable at the top of the file as shown below:</para>
661       <screen>#define DEBUG_SUBSYSTEM S_PORTALS</screen>
662       <para>A list of available macros with descriptions is provided in the table below.</para>
663       <informaltable frame="all">
664         <tgroup cols="2">
665           <colspec colname="c1" colwidth="50*"/>
666           <colspec colname="c2" colwidth="50*"/>
667           <thead>
668             <row>
669               <entry>
670                 <para><emphasis role="bold">Macro</emphasis></para>
671               </entry>
672               <entry>
673                 <para><emphasis role="bold">Description</emphasis></para>
674               </entry>
675             </row>
676           </thead>
677           <tbody>
678             <row>
679               <entry>
680                 <para> <emphasis role="bold">
681                     <literal>LBUG()</literal>
682                   </emphasis></para>
683               </entry>
684               <entry>
685                 <para>A panic-style assertion in the kernel which causes Lustre to dump its circular log to the <literal>/tmp/lustre-log</literal> file. This file can be retrieved after a reboot. <literal>LBUG()</literal> freezes the thread to allow capture of the panic stack. A system reboot is needed to clear the thread.</para>
686               </entry>
687             </row>
688             <row>
689               <entry>
690                 <para> <emphasis role="bold">
691                     <literal>LASSERT()</literal>
692                   </emphasis></para>
693               </entry>
694               <entry>
695                 <para>Validates a given expression as true, otherwise calls LBUG(). The failed expression is printed on the console, although the values that make up the expression are not printed.</para>
696               </entry>
697             </row>
698             <row>
699               <entry>
700                 <para> <emphasis role="bold">
701                     <literal>LASSERTF()</literal>
702                   </emphasis></para>
703               </entry>
704               <entry>
705                 <para>Similar to <literal>LASSERT()</literal> but allows a free-format message to be printed, like <literal>printf/printk</literal>.</para>
706               </entry>
707             </row>
708             <row>
709               <entry>
710                 <para> <emphasis role="bold">
711                     <literal>CDEBUG()</literal>
712                   </emphasis></para>
713               </entry>
714               <entry>
715                 <para>The basic, most commonly used debug macro that takes just one more argument than standard <literal>printf()</literal> - the debug type. This message adds to the debug log with the debug mask set accordingly. Later, when a user retrieves the log for troubleshooting, they can filter based on this type.</para>
716                 <para><literal>CDEBUG(D_INFO, &quot;debug message: rc=%d\n&quot;, number);</literal></para>
717               </entry>
718             </row>
719             <row>
720               <entry>
721                 <para> <emphasis role="bold">
722                     <literal>CDEBUG_LIMIT()</literal>
723                   </emphasis></para>
724               </entry>
725               <entry>
726                 <para> Behaves similarly to <literal>CDEBUG()</literal>, but rate limits this message when printing to the console (for <literal>D_WARN</literal>, <literal>D_ERROR</literal>, and <literal>D_CONSOLE</literal> message types. This is useful for messages that use a variable debug mask:</para>
727                 <para><literal>CDEBUG(mask, &quot;maybe bad: rc=%d\n&quot;, rc);</literal></para>
728               </entry>
729             </row>
730             <row>
731               <entry>
732                 <para> <emphasis role="bold">
733                     <literal>CERROR()</literal>
734                   </emphasis></para>
735               </entry>
736               <entry>
737                 <para>Internally using <literal>CDEBUG_LIMIT(D_ERROR, ...)</literal>, which unconditionally prints the message in the debug log and to the console. This is appropriate for serious errors or fatal conditions.  Messages printed to the console are prefixed with <literal>LustreError:</literal>, and are rate-limited, to avoid flooding the console with duplicates.</para>
738                 <para><literal>CERROR(&quot;Something bad happened: rc=%d\n&quot;, rc);</literal></para>
739               </entry>
740             </row>
741             <row>
742               <entry>
743                 <para> <emphasis role="bold">
744                     <literal>CWARN()</literal>
745                   </emphasis></para>
746               </entry>
747               <entry>
748                 <para> Behaves similarly to <literal>CERROR()</literal>, but prefixes the messages with <literal>Lustre:</literal>. This is appropriate for important, but not fatal conditions.  Messages printed to the console are rate-limited.</para>
749               </entry>
750             </row>
751             <row>
752               <entry>
753                 <para> <emphasis role="bold">
754                     <literal>CNETERR()</literal>
755                   </emphasis></para>
756               </entry>
757               <entry>
758                 <para> Behaves similarly to <literal>CERROR()</literal>, but prints error messages for LNET if <literal>D_NETERR</literal> is set in the <literal>debug</literal> mask. This is appropriate for serious networking errors. Messages printed to the console are rate-limited.</para>
759               </entry>
760             </row>
761             <row>
762               <entry>
763                 <para> <emphasis role="bold">
764                     <literal>DEBUG_REQ()</literal>
765                   </emphasis></para>
766               </entry>
767               <entry>
768                 <para>Prints information about the given <literal>ptlrpc_request</literal> structure.</para>
769                 <para><literal>DEBUG_REQ(D_RPCTRACE, req, &quot;"Handled RPC: rc=%d\n&quot;, rc);</literal></para>
770               </entry>
771             </row>
772             <row>
773               <entry>
774                 <para> <emphasis role="bold">
775                     <literal>ENTRY</literal>
776                   </emphasis></para>
777               </entry>
778               <entry>
779                 <para> Add messages to the entry of a function to aid in call tracing (takes no arguments). When using these macros, cover all exit conditions with a single <literal>EXIT</literal>, <literal>GOTO()</literal>, or <literal>RETURN()</literal> macro to avoid confusion when the debug log reports that a function was entered, but never exited.</para>
780               </entry>
781             </row>
782             <row>
783               <entry>
784                 <para> <emphasis role="bold">
785                     <literal>EXIT</literal>
786                   </emphasis></para>
787               </entry>
788               <entry>
789                 <para> Mark the exit of a function, to match <literal>ENTRY</literal> (takes no arguments).</para>
790               </entry>
791             </row>
792             <row>
793               <entry>
794                 <para> <emphasis role="bold">
795                     <literal>GOTO()</literal>
796                   </emphasis></para>
797               </entry>
798               <entry>
799                 <para> Mark when code jumps via <literal>goto</literal> to the end of a function, to match <literal>ENTRY</literal>, and prints out the goto label and function return code in signed and unsigned decimal, and hexadecimal format.</para>
800               </entry>
801             </row>
802             <row>
803               <entry>
804                 <para> <emphasis role="bold">
805                     <literal>RETURN()</literal>
806                   </emphasis></para>
807               </entry>
808               <entry>
809                 <para> Mark the exit of a function, to match <literal>ENTRY</literal>, and prints out the function return code in signed and unsigned decimal, and hexadecimal format.</para>
810               </entry>
811             </row>
812             <row>
813               <entry>
814                 <para> <emphasis role="bold">
815                     <literal>LDLM_DEBUG()</literal>
816                   </emphasis></para>
817                 <para> <emphasis role="bold">
818                     <literal>LDLM_DEBUG_NOLOCK()</literal>
819                   </emphasis></para>
820               </entry>
821               <entry>
822                 <para>Used when tracing LDLM locking operations. These macros build a thin trace that shows the locking requests on a node, and can also be linked across the client and server node using the printed lock handles.</para>
823               </entry>
824             </row>
825             <row>
826               <entry>
827                 <para> <emphasis role="bold">
828                     <literal>OBD_FAIL_CHECK()</literal>
829                   </emphasis></para>
830               </entry>
831               <entry>
832                 <para>Allows insertion of failure points into the Lustre code. This is useful to generate regression tests that can hit a very specific sequence of events. This works in conjunction with &quot;<literal>lctl set_param fail_loc={fail_loc}</literal>&quot; to set a specific failure point for which a given <literal>OBD_FAIL_CHECK()</literal> will test.</para>
833               </entry>
834             </row>
835             <row>
836               <entry>
837                 <para> <emphasis role="bold">
838                     <literal>OBD_FAIL_TIMEOUT()</literal>
839                   </emphasis></para>
840               </entry>
841               <entry>
842                 <para>Similar to <literal>OBD_FAIL_CHECK()</literal>. Useful to simulate hung, blocked or busy processes or network devices. If the given <literal>fail_loc</literal> is hit, <literal>OBD_FAIL_TIMEOUT()</literal> waits for the specified number of seconds.</para>
843               </entry>
844             </row>
845             <row>
846               <entry>
847                 <para> <emphasis role="bold">
848                     <literal>OBD_RACE()</literal>
849                   </emphasis></para>
850               </entry>
851               <entry>
852                 <para>Similar to <literal>OBD_FAIL_CHECK()</literal>. Useful to have multiple processes execute the same code concurrently to provoke locking races. The first process to hit <literal>OBD_RACE()</literal> sleeps until a second process hits <literal>OBD_RACE()</literal>, then both processes continue.</para>
853               </entry>
854             </row>
855             <row>
856               <entry>
857                 <para> <emphasis role="bold">
858                     <literal>OBD_FAIL_ONCE</literal>
859                   </emphasis></para>
860               </entry>
861               <entry>
862                 <para>A flag set on a <literal>fail_loc</literal> breakpoint to cause the <literal>OBD_FAIL_CHECK()</literal> condition to be hit only one time. Otherwise, a <literal>fail_loc</literal> is permanent until it is cleared with &quot;<literal>lctl set_param fail_loc=0</literal>&quot;.</para>
863               </entry>
864             </row>
865             <row>
866               <entry>
867                 <para> <emphasis role="bold">
868                     <literal>OBD_FAIL_RAND</literal>
869                   </emphasis></para>
870               </entry>
871               <entry>
872                 <para>A flag set on a <literal>fail_loc</literal> breakpoint to cause <literal>OBD_FAIL_CHECK()</literal> to fail randomly; on average every (1 / fail_val) times.</para>
873               </entry>
874             </row>
875             <row>
876               <entry>
877                 <para> <emphasis role="bold">
878                     <literal>OBD_FAIL_SKIP</literal>
879                   </emphasis></para>
880               </entry>
881               <entry>
882                 <para>A flag set on a <literal>fail_loc</literal> breakpoint to cause <literal>OBD_FAIL_CHECK()</literal> to succeed <literal>fail_val</literal> times, and then fail permanently or once with <literal>OBD_FAIL_ONCE</literal>.</para>
883               </entry>
884             </row>
885             <row>
886               <entry>
887                 <para> <emphasis role="bold">
888                     <literal>OBD_FAIL_SOME</literal>
889                   </emphasis></para>
890               </entry>
891               <entry>
892                 <para>A flag set on <literal>fail_loc</literal> breakpoint to cause <literal>OBD_FAIL_CHECK</literal> to fail <literal>fail_val</literal> times, and then succeed.</para>
893               </entry>
894             </row>
895           </tbody>
896         </tgroup>
897       </informaltable>
898     </section>
899     <section remap="h3">
900       <title>Accessing the <literal>ptlrpc</literal> Request History</title>
901       <para>Each service maintains a request history, which can be useful for first occurrence troubleshooting.</para>
902       <para><literal>ptlrpc</literal> is an RPC protocol layered on LNET that deals with stateful servers and has semantics and built-in support for recovery.</para>
903       <para>The ptlrpc request history works as follows:</para>
904       <orderedlist>
905         <listitem>
906           <para><literal>request_in_callback()</literal> adds the new request to the service&apos;s request history.</para>
907         </listitem>
908         <listitem>
909           <para>When a request buffer becomes idle, it is added to the service&apos;s request buffer history list.</para>
910         </listitem>
911         <listitem>
912           <para>Buffers are culled from the service request buffer history if it has grown above <literal>req_buffer_history_max</literal> and its reqs are removed from the service request history.</para>
913         </listitem>
914       </orderedlist>
915       <para>Request history is accessed and controlled using the following /proc files under the service directory:</para>
916       <itemizedlist>
917         <listitem>
918           <para><literal>req_buffer_history_len </literal></para>
919           <para>Number of request buffers currently in the history</para>
920         </listitem>
921       </itemizedlist>
922       <itemizedlist>
923         <listitem>
924           <para><literal>req_buffer_history_max </literal></para>
925           <para>Maximum number of request buffers to keep</para>
926         </listitem>
927       </itemizedlist>
928       <itemizedlist>
929         <listitem>
930           <para><literal>req_history </literal> </para>
931           <para>The request history</para>
932         </listitem>
933       </itemizedlist>
934       <para>Requests in the history include &quot;live&quot; requests that are currently being handled. Each line in <literal>req_history</literal> looks like:</para>
935       <screen>&lt;seq&gt;:&lt;target NID&gt;:&lt;client ID&gt;:&lt;xid&gt;:&lt;length&gt;:&lt;phase&gt; &lt;svc specific&gt; </screen>
936       <informaltable frame="all">
937         <tgroup cols="2">
938           <colspec colname="c1" colwidth="50*"/>
939           <colspec colname="c2" colwidth="50*"/>
940           <thead>
941             <row>
942               <entry>
943                 <para><emphasis role="bold">Parameter</emphasis></para>
944               </entry>
945               <entry>
946                 <para><emphasis role="bold">Description</emphasis></para>
947               </entry>
948             </row>
949           </thead>
950           <tbody>
951             <row>
952               <entry>
953                 <para> <emphasis role="bold">
954                     <literal>seq</literal>
955                   </emphasis></para>
956               </entry>
957               <entry>
958                 <para> Request sequence number</para>
959               </entry>
960             </row>
961             <row>
962               <entry>
963                 <para> <literal>
964                     <replaceable role="bold">target NID</replaceable>
965                   </literal></para>
966               </entry>
967               <entry>
968                 <para> Destination <literal>NID</literal> of the incoming request</para>
969               </entry>
970             </row>
971             <row>
972               <entry>
973                 <para> <literal>
974                     <replaceable role="bold">client ID</replaceable>
975                   </literal></para>
976               </entry>
977               <entry>
978                 <para> Client <literal>PID</literal> and <literal>NID</literal></para>
979               </entry>
980             </row>
981             <row>
982               <entry>
983                 <para> 
984                         <literal>
985                     <replaceable>xid</replaceable>
986                   </literal>
987                   </para>
988               </entry>
989               <entry>
990                 <para> <literal>rq_xid</literal></para>
991               </entry>
992             </row>
993             <row>
994               <entry>
995                 <para> <emphasis role="bold">
996                     <literal>length</literal>
997                   </emphasis></para>
998               </entry>
999               <entry>
1000                 <para> Size of the request message</para>
1001               </entry>
1002             </row>
1003             <row>
1004               <entry>
1005                 <para> <emphasis role="bold">
1006                     <literal>phase</literal>
1007                   </emphasis></para>
1008               </entry>
1009               <entry>
1010                 <para><itemizedlist>
1011                     <listitem>
1012                       <para>New (waiting to be handled or could not be unpacked)</para>
1013                     </listitem>
1014                     <listitem>
1015                       <para>Interpret (unpacked or being handled)</para>
1016                     </listitem>
1017                     <listitem>
1018                       <para>Complete (handled)</para>
1019                     </listitem>
1020                   </itemizedlist></para>
1021               </entry>
1022             </row>
1023             <row>
1024               <entry>
1025                 <para> <emphasis role="bold">
1026                     <literal>svc specific</literal>
1027                   </emphasis></para>
1028               </entry>
1029               <entry>
1030                 <para>Service-specific request printout. Currently, the only service that does this is the OST (which prints the opcode if the message has been unpacked successfully</para>
1031               </entry>
1032             </row>
1033           </tbody>
1034         </tgroup>
1035       </informaltable>
1036     </section>
1037     <section remap="h3">
1038       <title><indexterm><primary>debugging</primary><secondary>memory leaks</secondary></indexterm>Finding Memory Leaks Using <literal>leak_finder.pl</literal></title>
1039       <para>Memory leaks can occur in code when memory has been allocated and then not freed once it is no longer required. The <literal>leak_finder.pl</literal> program provides a way to find memory leaks.</para>
1040       <para>Before running this program, you must turn on debugging to collect all <literal>malloc</literal> and free entries. Run:</para>
1041       <screen>lctl set_param debug=+malloc </screen>
1042       <para>Then complete the following steps:</para>
1043       <orderedlist>
1044         <listitem>
1045           <para>Dump the log into a user-specified log file using lctl (see <xref linkend="dbdoclet.50438274_62472"/>).</para>
1046         </listitem>
1047         <listitem>
1048           <para>Run the leak finder on the newly-created log dump:</para>
1049           <screen>perl leak_finder.pl {ascii-logname}</screen>
1050         </listitem>
1051       </orderedlist>
1052       <para>The output is:</para>
1053       <screen>malloced 8bytes at a3116744 (called pathcopy) 
1054 (lprocfs_status.c:lprocfs_add_vars:80) 
1055 freed 8bytes at a3116744 (called pathcopy) 
1056 (lprocfs_status.c:lprocfs_add_vars:80) 
1057 </screen>
1058       <para>The tool displays the following output to show the leaks found:</para>
1059       <screen>Leak:32bytes allocated at a23a8fc(service.c:ptlrpc_init_svc:144,debug file line 241)</screen>
1060     </section>
1061   </section>
1062 </chapter>