From: Andreas Dilger Date: Mon, 11 Jul 2011 16:30:14 +0000 (-0600) Subject: LUDOC-11 Minor improvements to debugging chapter X-Git-Tag: 2.1.0~5 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4e40f433821df679d28470efdd23d51b1485d511;p=doc%2Fmanual.git LUDOC-11 Minor improvements to debugging chapter Fix formatting consistency of the debugging chapter. Add a number of debug macros that were not being listed, and improve the description and formatting of some others. Update sample output to be consistent with what is generated by modern Lustre tools. Change-Id: Ie1276e49c784ccc6ee23c5609b996baa4ad57173 Signed-off-by: Andreas Dilger --- diff --git a/LustreDebugging.xml b/LustreDebugging.xml index d6eaf75..0a66e57 100644 --- a/LustreDebugging.xml +++ b/LustreDebugging.xml @@ -367,7 +367,7 @@ Lustre Debugging Tools
Format of Lustre Debug Messages - Lustre uses the CDEBUG and CERROR macros to print the debug or error messages. To print the message, the CDEBUG macro uses portals_debug_msg (portals/linux/oslib/debug.c). The message format is described below, along with an example. + Lustre uses the CDEBUG() and CERROR() macros to print the debug or error messages. To print the message, the CDEBUG() macro uses the function libcfs_debug_msg() (libcfs/libcfs/tracefile.c). The message format is described below, along with an example. @@ -375,10 +375,10 @@ Lustre Debugging Tools - Parameter + Description - Description + Parameter @@ -409,11 +409,10 @@ Lustre Debugging Tools - sec.used + seconds.microseconds - 10818808 - 47.677302 + 1081880847.677302 @@ -421,7 +420,7 @@ Lustre Debugging Tools stack size - 1204: + 1204 @@ -429,23 +428,23 @@ Lustre Debugging Tools pid - 2973: + 2973 - host pid (if uml) or zero + host pid (UML only) or zero - 31070: + 31070 - (file:line #:functional()) + (file:line #:function_name()) - (as_dev.c:144:create_write_buffers()) + (obd_mount.c:2089:lustre_fill_super()) @@ -462,7 +461,7 @@ Lustre Debugging Tools
Lustre Debug Messages Buffer - Lustre debug messages are maintained in a buffer, with the maximum buffer size specified (in MBs) by the debug_mb parameter (/proc/sys/lnet/debug_mb). The buffer is circular, so debug messages are kept until the allocated buffer limit is reached, and then the first messages are overwritten. + Lustre debug messages are maintained in a buffer, with the maximum buffer size specified (in MBs) by the debug_mb parameter (lctl get_param debug_mb). The buffer is circular, so debug messages are kept until the allocated buffer limit is reached, and then the first messages are overwritten.
@@ -472,13 +471,13 @@ Lustre Debugging Tools Obtain a list of all the types and subsystems: - lctl > debug_list <subs | types> + lctl > debug_list {subs | types} Filter the debug log: - lctl > filter <subsystem name | debug type> + lctl > filter {subsystem name | debug type} @@ -487,7 +486,7 @@ Lustre Debugging Tools Show debug messages belonging to certain subsystem or type: - lctl > show <subsystem name | debug type> + lctl > show {subsystem name | debug type} debug_kernel pulls the data from the kernel logs, filters it appropriately, and displays or saves it as per the specified options lctl > debug_kernel [output filename] 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. @@ -496,7 +495,7 @@ Lustre Debugging Tools Filter a log on disk, if you already have a debug log saved to disk (likely from a crash): - lctl > debug_file <input filename> [output filename] + lctl > debug_file {input filename} [output filename] During the debug session, you can add markers or breaks to the log for any reason: lctl > mark [marker text] The marker text defaults to the current date and time in the debug log (similar to the example shown below): @@ -535,99 +534,114 @@ Debug log: 324 lines, 258 kept, 66 dropped.
Dumping the Buffer to a File (<literal>debug_daemon</literal>) - The debug_daemon option is used by lctl to control the dumping of the debug_kernel buffer to a user-specified file. This functionality uses a kernel thread on top of debug_kernel, which works in parallel with the debug_daemon command. - The debug_daemon is highly dependent on file system write speed. File system write operations may not be fast enough to flush out all of the debug_buffer if the Lustre file system is under heavy system load and continues to CDEBUG to the debug_buffer. The debug_daemon will write the message DEBUG MARKER: Trace buffer full into the debug_buffer to indicate the debug_buffer contents are overlapping before the debug_daemon flushes data to a file. - Users can use lctl control to start or stop the Lustre daemon from dumping the debug_buffer to a file. Users can also temporarily hold daemon from dumping the file. Use of the debug_daemon sub-command to lctl can provide the same function. + The lctl debug_daemon command is used to continuously dump the debug_kernel 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. + The debug_daemon is highly dependent on file system write speed. File system write operations may not be fast enough to flush out all of the debug_buffer if the Lustre file system is under heavy system load and continues to log debug messages to the debug_buffer. The debug_daemon will write the message DEBUG MARKER: Trace buffer full into the debug_buffer to indicate the debug_buffer contents are overlapping before the debug_daemon flushes data to a file. + Users can use the lctl debug_daemon command to start or stop the Lustre daemon from dumping the debug_buffer to a file.
<literal>lctl debug_daemon</literal> Commands - This section describes lctl debug_daemon commands. - To initiate the debug_daemon to start dumping debug_buffer into a file., enter - $ lctl debug_daemon start [{file} {megabytes}] - The file can be a system default file, as shown in /proc/sys/lnet/debug_path. After Lustre starts, the default path is /tmp/lustre-log-$HOSTNAME. Users can specify a new filename for debug_daemon to output debug_buffer. The new file name shows up in /proc/sys/lnet/debug_path. Megabytes is the limitation of the file size in MBs. - 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 order the log entries by time, run: - lctl debug_file {file} > {newfile} - The output is internally sorted by the lctl command using quicksort. - To completely shut down the debug_daemon operation and flush the file output, enter: - debug_daemon stop + To initiate the debug_daemon to start dumping the debug_buffer into a file, run as the root user: + lctl debug_daemon start {filename} [{megabytes}] + 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. + 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: + lctl debug_file {filename} > {newfile} + The output is internally sorted by the lctl command. + To stop the debug_daemon operation and flush the file output, run: + lctl debug_daemon stop Otherwise, debug_daemon is shut down as part of the Lustre file system shutdown process. Users can restart debug_daemon by using start command after each stop command issued. - This is an example using debug_daemon with the interactive mode of lctl to dump debug logs to a 10 MB file. - #~/utils/lctl - To start the daemon to dump debug_buffer into a 40 MB /tmp/dump file, enter: - lctl > debug_daemon start /trace/log 40 - To completely shut down the daemon, enter: + This is an example using debug_daemon with the interactive mode of lctl to dump debug logs to a 40 MB file. + lctl + lctl > debug_daemon start /var/log/lustre.40.bin 40 + {run filesystem operations to debug} lctl > debug_daemon stop - To start another daemon with an unlimited file size, enter: - lctl > debug_daemon start /tmp/unlimited + lctl > debug_file /var/log/lustre.bin /var/log/lustre.log + To start another daemon with an unlimited file size, run: + lctl > debug_daemon start /var/log/lustre.bin The text message *** End of debug_daemon trace log *** appears at the end of each output file.
<indexterm><primary>debugging</primary><secondary>kernel debug log</secondary></indexterm>Controlling Information Written to the Kernel Debug Log - Masks are provided in /proc/sys/lnet/subsystem_debug and /proc/sys/lnet/debug to be used with the systctl command to determine what information is to be written to the debug log. The subsystem_debug mask determines the information written to the log based on the subsystem (such as iobdfilter, net, portals, or OSC). The debug mask controls information based on debug type (such as info, error, trace, or alloc). + Running lctl set_param subsystem_debug={subsystem_mask} and lcdebug to be used with the systctl command to determine what information is to be written to the debug log. The subsystem_debug mask determines the information written to the log based on the subsystem (such as iobdfilter, net, portals, or OSC). The debug mask controls information based on debug type (such as info, error, trace, or alloc). To turn off Lustre debugging completely: - sysctl -w lnet.debug=0 + lctl set_param debug=0 To turn on full Lustre debugging: - sysctl -w lnet.debug=-1 - To turn on logging of messages related to network communications: - sysctl -w lnet.debug=net + lctl set_param debug=-1 + To log only messages related to network communications: + lctl set_param debug=net To turn on logging of messages related to network communications and existing debug flags: - sysctl -w lnet.debug=+net + lctl set_param debug=+net To turn off network logging with changing existing flags: - sysctl -w lnet.debug=-net - The various options available to print to kernel debug logs are listed in lnet/include/libcfs/libcfs.h + lctl set_param debug=-net + The various options available to print to kernel debug logs are listed in libcfs/include/libcfs/libcfs.h
<indexterm><primary>debugging</primary><secondary>using strace</secondary></indexterm>Troubleshooting with <literal>strace</literal> The strace 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. To invoke strace on a program, enter: - $ strace <program> <args> + $ strace {program} {args} Sometimes, a system call may fork child processes. In this situation, use the -f option of strace to trace the child processes: - $ strace -f <program> <args> + $ strace -f {program} {args} To redirect the strace output to a file, enter: - $ strace -o <filename> <program> <args> + $ strace -o {filename} {program} {args} Use the -ff option, along with -o, to save the trace output in filename.pid, where pid is the process ID of the process being traced. Use the -ttt option to timestamp all lines in the strace output, so they can be correlated to operations in the lustre kernel debug log. - If the debugging is done in UML, save the traces on the host machine. In this example, hostfs is mounted on /r: - $ strace -o /r/tmp/vi.strace
<indexterm><primary>debugging</primary><secondary>disk contents</secondary></indexterm>Looking at Disk Content 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 lfs tool can be used to obtain this information for a given file using the getstripe subcommand. Use a corresponding lfs setstripe command to specify striping attributes for a new file or directory. - The lfs getstripe utility is written in C; it 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 /mnt/lustre/frog in Lustre file system, run: + The lfs getstripe 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 /mnt/lustre/frog in Lustre file system, run: $ lfs getstripe /mnt/lustre/frog -$ - obdix objid - 0 17 - 1 4 - +lmm_stripe_count: 2 +lmm_stripe_size: 1048576 +lmm_stripe_offset: 2 + obdidx objid objid group + 2 818855 0xc7ea7 0 + 0 873123 0xd52a3 0 + The debugfs tool is provided in the e2fsprogs package. It can be used for interactive debugging of an ldiskfs file system. The debugfs 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 ldiskfs file system on the OSTs. The file system uses the object IDs as the file names. Once the object IDs are known, use the debugfs tool to obtain the attributes of all objects from different OSTs. A sample run for the /mnt/lustre/frog file used in the above example is shown here: - $ debugfs -c /tmp/ost1 - debugfs: cd O - debugfs: cd 0 /* for files in group 0 */ - debugfs: cd d<objid % 32> - debugfs: stat <objid> /* for getattr on object */ - debugfs: quit -## Suppose object id is 36, then follow the steps below: - $ debugfs /tmp/ost1 - debugfs: cd O - debugfs: cd 0 - debugfs: cd d4 /* objid % 32 */ - debugfs: stat 36 /* for getattr on obj 4*/ - debugfs: dump 36 /tmp/obj.36 /* dump contents of obj 4 */ - debugfs: quit + $ debugfs -c -R "stat O/0/d$((818855 % 32))/818855" /dev/vgmyth/lvmythost2 + +debugfs 1.41.90.wc3 (28-May-2011) +/dev/vgmyth/lvmythost2: catastrophic mode - not reading inode or group bitmaps +Inode: 227649 Type: regular Mode: 0666 Flags: 0x80000 +Generation: 1375019198 Version: 0x0000002f:0000728f +User: 1000 Group: 1000 Size: 2800 +File ACL: 0 Directory ACL: 0 +Links: 1 Blockcount: 8 +Fragment: Address: 0 Number: 0 Size: 0 + ctime: 0x4e177fe5:00000000 -- Fri Jul 8 16:08:37 2011 + atime: 0x4d2e2397:00000000 -- Wed Jan 12 14:56:39 2011 + mtime: 0x4e177fe5:00000000 -- Fri Jul 8 16:08:37 2011 +crtime: 0x4c3b5820:a364117c -- Mon Jul 12 12:00:00 2010 +Size of extra inode fields: 28 +Extended attributes stored in inode body: + 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 + 00 00 00 00 00 00 00 00 " (32) + fid: objid=818855 seq=0 parent=[0x248008:0xfce78a28:0x0] stripe=0 +EXTENTS: +(0):63331288 +
Finding the Lustre UUID of an OST - To determine the Lustre UUID of an obdfilter 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), use debugfs to get the last_rcvd file. + 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: + debugfs -c -R "dump last_rcvd /tmp/last_rcvd" /dev/sdc +strings /tmp/last_rcvd | head -1 +myth-OST0004_UUID + + It is also possible (and easier) to extract this from the filesystem label using the dumpe2fs command: + dumpe2fs -h /dev/sdc | grep volume +dumpe2fs 1.41.90.wc3 (28-May-2011) +Filesystem volume name: myth-OST0004 + + The debugfs and dumpe2fs commands are well documented in the debugfs(8) and dumpe2fs(8) manual pages.
Printing Debug Messages to the Console To dump debug messages to the console (/var/log/messages), set the corresponding debug mask in the printk flag: - sysctl -w lnet.printk=-1 - This slows down the system dramatically. It is also possible to selectively enable or disable this capability for particular flags using: - sysctl -w lnet.printk=+vfstrace -sysctl -w lnet.printk=-vfstrace - It is possible to disable warning, error, and console messages, though it is strongly recommended to have something like lctl debug_daemon running to capture this data to a local file system for debugging purposes. + lctl set_param printk=-1 + This slows down the system dramatically. It is also possible to selectively enable or disable this capability for particular flags using:lctl set_param printk=+vfstrace and lctl set_param printk=-vfstrace . + It is possible to disable warning, error, and console messages, though it is strongly recommended to have something like lctl debug_daemon running to capture this data to a local file system for failure detection purposes.
Tracing Lock Traffic @@ -664,129 +678,198 @@ lctl> debug_kernel [filename] - LBUG + LBUG() - A panic-style assertion in the kernel which causes Lustre to dump its circular log to the /tmp/lustre-log file. This file can be retrieved after a reboot. LBUG freezes the thread to allow capture of the panic stack. A system reboot is needed to clear the thread. + A panic-style assertion in the kernel which causes Lustre to dump its circular log to the /tmp/lustre-log file. This file can be retrieved after a reboot. LBUG() freezes the thread to allow capture of the panic stack. A system reboot is needed to clear the thread. - LASSERT + LASSERT() - 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. + 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. - LASSERTF + LASSERTF() - Similar to LASSERT but allows a free-format message to be printed, like printf/printk. + Similar to LASSERT() but allows a free-format message to be printed, like printf/printk. - CDEBUG + CDEBUG() - The basic, most commonly used debug macro that takes just one more argument than standard printf - 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. - CDEBUG(D_INFO, "This is my debug message: the number is %d\n", number). + The basic, most commonly used debug macro that takes just one more argument than standard printf() - 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. + CDEBUG(D_INFO, "debug message: rc=%d\n", number); - CERROR + CDEBUG_LIMIT() - Behaves similarly to CDEBUG, but unconditionally prints the message in the debug log and to the console. This is appropriate for serious errors or fatal conditions: - CERROR("Something very bad has happened, and the return code is %d.\n", rc); + Behaves similarly to CDEBUG(), but rate limits this message when printing to the console (for D_WARN, D_ERROR, and D_CONSOLE message types. This is useful for messages that use a variable debug mask: + CDEBUG(mask, "maybe bad: rc=%d\n", rc); - ENTRY and EXIT + + CERROR() + - Add messages to aid in call tracing (takes no arguments). When using these macros, cover all exit conditions to avoid confusion when the debug log reports that a function was entered, but never exited. + Internally using CDEBUG_LIMIT(D_ERROR, ...), 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 LustreError:, and are rate-limited, to avoid flooding the console with duplicates. + CERROR("Something bad happened: rc=%d\n", rc); - LDLM_DEBUG and LDLM_DEBUG_NOLOCK + + CWARN() + - Used when tracing MDS and VFS operations for locking. These macros build a thin trace that shows the protocol exchanges between nodes. + Behaves similarly to CERROR(), but prefixes the messages with Lustre:. This is appropriate for important, but not fatal conditions. Messages printed to the console are rate-limited. - - DEBUG_REQ - + + CNETERR() + + + + Behaves similarly to CERROR(), but prints error messages for LNET if D_NETERR is set in the debug mask. This is appropriate for serious networking errors. Messages printed to the console are rate-limited. + + + + + + DEBUG_REQ() + Prints information about the given ptlrpc_request structure. + DEBUG_REQ(D_RPCTRACE, req, ""Handled RPC: rc=%d\n", rc); - - OBD_FAIL_CHECK - + + ENTRY + - 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 "sysctl -w lustre.fail_loc={fail_loc}" to set a specific failure point for which a given OBD_FAIL_CHECK will test. + 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 EXIT, GOTO(), or RETURN() macro to avoid confusion when the debug log reports that a function was entered, but never exited. - - OBD_FAIL_TIMEOUT - + + EXIT + - Similar to OBD_FAIL_CHECK. Useful to simulate hung, blocked or busy processes or network devices. If the given fail_loc is hit, OBD_FAIL_TIMEOUT waits for the specified number of seconds. + Mark the exit of a function, to match ENTRY (takes no arguments). - - OBD_RACE - + + GOTO() + - Similar to OBD_FAIL_CHECK. Useful to have multiple processes execute the same code concurrently to provoke locking races. The first process to hit OBD_RACE sleeps until a second process hits OBD_RACE, then both processes continue. + Mark when code jumps via goto to the end of a function, to match ENTRY, and prints out the goto label and function return code in signed and unsigned decimal, and hexadecimal format. - - OBD_FAIL_ONCE - + + RETURN() + - A flag set on a lustre.fail_loc breakpoint to cause the OBD_FAIL_CHECK condition to be hit only one time. Otherwise, a fail_loc is permanent until it is cleared with "sysctl -w lustre.fail_loc=0". + Mark the exit of a function, to match ENTRY, and prints out the function return code in signed and unsigned decimal, and hexadecimal format. - - OBD_FAIL_RAND - + + LDLM_DEBUG() + + + LDLM_DEBUG_NOLOCK() + + + + 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. + + + + + + OBD_FAIL_CHECK() + + + + 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 "lctl set_param fail_loc={fail_loc}" to set a specific failure point for which a given OBD_FAIL_CHECK() will test. + + + + + + OBD_FAIL_TIMEOUT() + - Has OBD_FAIL_CHECK fail randomly; on average every (1 / lustre.fail_val) times. + Similar to OBD_FAIL_CHECK(). Useful to simulate hung, blocked or busy processes or network devices. If the given fail_loc is hit, OBD_FAIL_TIMEOUT() waits for the specified number of seconds. + + + + + + OBD_RACE() + + + + Similar to OBD_FAIL_CHECK(). Useful to have multiple processes execute the same code concurrently to provoke locking races. The first process to hit OBD_RACE() sleeps until a second process hits OBD_RACE(), then both processes continue. + + + + + + OBD_FAIL_ONCE + + + + A flag set on a fail_loc breakpoint to cause the OBD_FAIL_CHECK() condition to be hit only one time. Otherwise, a fail_loc is permanent until it is cleared with "lctl set_param fail_loc=0". + + + + + + OBD_FAIL_RAND + + + + A flag set on a fail_loc breakpoint to cause OBD_FAIL_CHECK() to fail randomly; on average every (1 / fail_val) times. @@ -796,17 +879,17 @@ lctl> debug_kernel [filename] - Has OBD_FAIL_CHECK succeed lustre.fail_val times, and then fail permanently or once with OBD_FAIL_ONCE. + A flag set on a fail_loc breakpoint to cause OBD_FAIL_CHECK() to succeed fail_val times, and then fail permanently or once with OBD_FAIL_ONCE. - - OBD_FAIL_SOME - + + OBD_FAIL_SOME + - Has OBD_FAIL_CHECK fail lustre.fail_val times, and then succeed. + A flag set on fail_loc breakpoint to cause OBD_FAIL_CHECK to fail fail_val times, and then succeed. @@ -814,10 +897,10 @@ lctl> debug_kernel [filename]
- Accessing a <literal>ptlrpc</literal> Request History + Accessing the <literal>ptlrpc</literal> Request History Each service maintains a request history, which can be useful for first occurrence troubleshooting. ptlrpc is an RPC protocol layered on LNET that deals with stateful servers and has semantics and built-in support for recovery. - A prlrpc request history works as follows: + The ptlrpc request history works as follows: request_in_callback() adds the new request to the service's request history. @@ -826,29 +909,25 @@ lctl> debug_kernel [filename] When a request buffer becomes idle, it is added to the service's request buffer history list. - Buffers are culled from the service's request buffer history if it has grown above - req_buffer_history_max and its reqs are removed from the service's request history. + Buffers are culled from the service request buffer history if it has grown above req_buffer_history_max and its reqs are removed from the service request history. Request history is accessed and controlled using the following /proc files under the service directory: - req_buffer_history_len - + req_buffer_history_len Number of request buffers currently in the history - req_buffer_history_max - + req_buffer_history_max Maximum number of request buffers to keep - req_history - + req_history The request history @@ -959,7 +1038,7 @@ lctl> debug_kernel [filename] <indexterm><primary>debugging</primary><secondary>memory leaks</secondary></indexterm>Finding Memory Leaks Using <literal>leak_finder.pl</literal> Memory leaks can occur in code when memory has been allocated and then not freed once it is no longer required. The leak_finder.pl program provides a way to find memory leaks. Before running this program, you must turn on debugging to collect all malloc and free entries. Run: - sysctl -w lnet.debug=+malloc + lctl set_param debug=+malloc Then complete the following steps: @@ -967,7 +1046,7 @@ lctl> debug_kernel [filename] Run the leak finder on the newly-created log dump: - perl leak_finder.pl <ascii-logname> + perl leak_finder.pl {ascii-logname} The output is: