Whamcloud - gitweb
FIX: validation, ulink -> link
[doc/manual.git] / LustreProc.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="lustreproc">
3   <info>
4     <title xml:id="lustreproc.title">LustreProc</title>
5   </info>
6   <para>The <literal>/proc</literal> file system acts as an interface to internal data structures in the kernel. The <literal>/proc</literal> variables can be used to control aspects of Lustre performance and provide information.</para>
7   <para>This chapter describes Lustre /proc entries and includes the following sections:</para>
8   <itemizedlist>
9     <listitem>
10       <para><xref linkend="dbdoclet.50438271_90999"/></para>
11     </listitem>
12     <listitem>
13       <para><xref linkend="dbdoclet.50438271_78950"/></para>
14     </listitem>
15     <listitem>
16       <para><xref linkend="dbdoclet.50438271_83523"/></para>
17     </listitem>
18   </itemizedlist>
19   <section xml:id="dbdoclet.50438271_90999">
20     <title>31.1 Proc Entries for Lustre</title>
21     <para>This section describes <literal>/proc</literal> entries for Lustre.</para>
22     <section remap="h3">
23       <title>31.1.1 Locating Lustre File Systems and Servers</title>
24       <para>Use the proc files on the MGS to locate the following:</para>
25       <itemizedlist>
26         <listitem>
27           <para> All known file systems</para>
28           <screen># cat /proc/fs/lustre/mgs/MGS/filesystems
29 spfs
30 lustre</screen>
31         </listitem>
32       </itemizedlist>
33       <itemizedlist>
34         <listitem>
35           <para> The server names participating in a file system (for each file system that has at least one server running)</para>
36           <screen># cat /proc/fs/lustre/mgs/MGS/live/spfs
37 fsname: spfs
38 flags: 0x0         gen: 7
39 spfs-MDT0000
40 spfs-OST0000</screen>
41         </listitem>
42       </itemizedlist>
43       <para>All servers are named according to this convention: <literal>&lt;fsname&gt;-&lt;MDT|OST&gt;&lt;XXXX&gt;</literal>. This can be shown for live servers under <literal>/proc/fs/lustre/devices</literal>:</para>
44       <screen># cat /proc/fs/lustre/devices 
45 0 UP mgs MGS MGS 11
46 1 UP mgc MGC192.168.10.34@tcp 1f45bb57-d9be-2ddb-c0b0-5431a49226705
47 2 UP mdt MDS MDS_uuid 3
48 3 UP lov lustre-mdtlov lustre-mdtlov_UUID 4
49 4 UP mds lustre-MDT0000 lustre-MDT0000_UUID 7
50 5 UP osc lustre-OST0000-osc lustre-mdtlov_UUID 5
51 6 UP osc lustre-OST0001-osc lustre-mdtlov_UUID 5
52 7 UP lov lustre-clilov-ce63ca00 08ac6584-6c4a-3536-2c6d-b36cf9cbdaa04
53 8 UP mdc lustre-MDT0000-mdc-ce63ca00 08ac6584-6c4a-3536-2c6d-b36cf9cbdaa05
54 9 UP osc lustre-OST0000-osc-ce63ca00 08ac6584-6c4a-3536-2c6d-b36cf9cbdaa05
55 10 UP osc lustre-OST0001-osc-ce63ca00 08ac6584-6c4a-3536-2c6d-b36cf9cbdaa05</screen>
56       <para>Or from the device label at any time:</para>
57       <screen># e2label /dev/sda
58 lustre-MDT0000</screen>
59     </section>
60     <section remap="h3">
61       <title>31.1.2 Lustre Timeouts</title>
62       <para>Lustre uses two types of timeouts.</para>
63       <itemizedlist>
64         <listitem>
65           <para>LND timeouts that ensure point-to-point communications complete in finite time in the presence of failures. These timeouts are logged with the <literal>S_LND</literal> flag set. They may <emphasis>not</emphasis> be printed as console messages, so you should check the Lustre log for <literal>D_NETERROR</literal> messages, or enable printing of <literal>D_NETERROR</literal> messages to the console (<literal>echo + neterror &gt; /proc/sys/lnet/printk</literal>).</para>
66         </listitem>
67       </itemizedlist>
68       <para>Congested routers can be a source of spurious LND timeouts. To avoid this, increase the number of LNET router buffers to reduce back-pressure and/or increase LND timeouts on all nodes on all connected networks. You should also consider increasing the total number of LNET router nodes in the system so that the aggregate router bandwidth matches the aggregate server bandwidth.</para>
69       <itemizedlist>
70         <listitem>
71           <para>Lustre timeouts that ensure Lustre RPCs complete in finite time in the presence of failures. These timeouts should <emphasis>always</emphasis> be printed as console messages. If Lustre timeouts are not accompanied by LNET timeouts, then you need to increase the lustre timeout on both servers and clients.</para>
72         </listitem>
73       </itemizedlist>
74       <para>Specific Lustre timeouts are described below.</para>
75       <para><literal>
76           <replaceable role="bold">/proc/sys/lustre/timeout</replaceable>
77         </literal></para>
78       <para>This is the time period that a client waits for a server to complete an RPC (default is 100s). Servers wait half of this time for a normal client RPC to complete and a quarter of this time for a single bulk request (read or write of up to 1 MB) to complete. The client pings recoverable targets (MDS and OSTs) at one quarter of the timeout, and the server waits one and a half times the timeout before evicting a client for being &quot;stale.&quot;</para>
79       <note>
80         <para>Lustre sends periodic &apos;PING&apos; messages to servers with which it had no communication for a specified period of time. Any network activity on the file system that triggers network traffic toward servers also works as a health check.</para>
81       </note>
82       <para><literal>
83           <replaceable role="bold">/proc/sys/lustre/ldlm_timeout</replaceable>
84         </literal></para>
85       <para>This is the time period for which a server will wait for a client to reply to an initial AST (lock cancellation request) where default is 20s for an OST and 6s for an MDS. If the client replies to the AST, the server will give it a normal timeout (half of the client timeout) to flush any dirty data and release the lock.</para>
86       <para><literal>
87           <replaceable role="bold">/proc/sys/lustre/fail_loc</replaceable>
88         </literal></para>
89       <para>This is the internal debugging failure hook.</para>
90       <para>See <literal>lustre/include/linux/obd_support.h</literal> for the definitions of individual failure locations. The default value is 0 (zero).</para>
91       <screen>sysctl -w lustre.fail_loc=0x80000122 # drop a single reply</screen>
92       <para><literal>
93           <replaceable role="bold">/proc/sys/lustre/dump_on_timeout</replaceable>
94         </literal></para>
95       <para>This triggers dumps of the Lustre debug log when timeouts occur. The default value is 0 (zero).</para>
96       <para><literal>
97           <replaceable role="bold">/proc/sys/lustre/dump_on_eviction</replaceable>
98         </literal></para>
99       <para>This triggers dumps of the Lustre debug log when an eviction occurs. The default value is 0 (zero). By default, debug logs are dumped to the /tmp folder; this location can be changed via /proc.</para>
100     </section>
101     <section remap="h3">
102       <title>31.1.3 Adaptive Timeouts</title>
103       <para>Lustre offers an adaptive mechanism to set RPC timeouts. The adaptive timeouts feature (enabled, by default) causes servers to track actual RPC completion times, and to report estimated completion times for future RPCs back to clients. The clients use these estimates to set their future RPC timeout values. If server request processing slows down for any reason, the RPC completion estimates increase, and the clients allow more time for RPC completion.</para>
104       <para>If RPCs queued on the server approach their timeouts, then the server sends an early reply to the client, telling the client to allow more time. In this manner, clients avoid RPC timeouts and disconnect/reconnect cycles. Conversely, as a server speeds up, RPC timeout values decrease, allowing faster detection of non-responsive servers and faster attempts to reconnect to a server&apos;s failover partner.</para>
105       <para>In previous Lustre versions, the static obd_timeout (<literal>/proc/sys/lustre/timeout</literal>) value was used as the maximum completion time for all RPCs; this value also affected the client-server ping interval and initial recovery timer. Now, with adaptive timeouts, obd_timeout is only used for the ping interval and initial recovery estimate. When a client reconnects during recovery, the server uses the client&apos;s timeout value to reset the recovery wait period; i.e., the server learns how long the client had been willing to wait, and takes this into account when adjusting the recovery period.</para>
106       <section remap="h4">
107         <title>31.1.3.1 Configuring Adaptive Timeouts</title>
108         <para>One of the goals of adaptive timeouts is to relieve users from having to tune the <literal>obd_timeout</literal> value. In general, <literal>obd_timeout</literal> should no longer need to be changed. However, there are several parameters related to adaptive timeouts that users can set. In most situations, the default values should be used.</para>
109         <para>The following parameters can be set persistently system-wide using <literal>lctl conf_param</literal> on the MGS. For example, <literal>lctl conf_param work1.sys.at_max=1500</literal> sets the at_max value for all servers and clients using the work1 file system.</para>
110         <note>
111           <para>Nodes using multiple Lustre file systems must use the same <literal>at_*</literal> values for all file systems.)</para>
112         </note>
113         <informaltable frame="all">
114           <tgroup cols="2">
115             <colspec colname="c1" colwidth="50*"/>
116             <colspec colname="c2" colwidth="50*"/>
117             <thead>
118               <row>
119                 <entry>
120                   <para><emphasis role="bold">Parameter</emphasis></para>
121                 </entry>
122                 <entry>
123                   <para><emphasis role="bold">Description</emphasis></para>
124                 </entry>
125               </row>
126             </thead>
127             <tbody>
128               <row>
129                 <entry>
130                   <para> <literal>
131                       <replaceable role="bold">at_min</replaceable>
132                     </literal></para>
133                 </entry>
134                 <entry>
135                   <para>Sets the minimum adaptive timeout (in seconds). Default value is 0. The at_min parameter is the minimum processing time that a server will report. Clients base their timeouts on this value, but they do not use this value directly. If you experience cases in which, for unknown reasons, the adaptive timeout value is too short and clients time out their RPCs (usually due to temporary network outages), then you can increase the at_min value to compensate for this. Ideally, users should leave at_min set to its default.</para>
136                 </entry>
137               </row>
138               <row>
139                 <entry>
140                   <para> <literal>
141                       <replaceable role="bold">at_max</replaceable>
142                     </literal></para>
143                 </entry>
144                 <entry>
145                   <para>Sets the maximum adaptive timeout (in seconds). The <literal>at_max</literal> parameter is an upper-limit on the service time estimate, and is used as a &apos;failsafe&apos; in case of rogue/bad/buggy code that would lead to never-ending estimate increases. If at_max is reached, an RPC request is considered &apos;broken&apos; and should time out.</para>
146                   <para>Setting at_max to 0 causes adaptive timeouts to be disabled and the old fixed-timeout method (<literal>obd_timeout</literal>) to be used. This is the default value in Lustre 1.6.5.</para>
147                   <note>
148                     <para>It is possible that slow hardware might validly cause the service estimate to increase beyond the default value of at_max. In this case, you should increase at_max to the maximum time you are willing to wait for an RPC completion.</para>
149                   </note>
150                 </entry>
151               </row>
152               <row>
153                 <entry>
154                   <para> <literal>
155                       <replaceable role="bold">at_history</replaceable>
156                     </literal></para>
157                 </entry>
158                 <entry>
159                   <para>Sets a time period (in seconds) within which adaptive timeouts remember the slowest event that occurred. Default value is 600.</para>
160                 </entry>
161               </row>
162               <row>
163                 <entry>
164                   <para> <literal>
165                       <replaceable role="bold">at_early_margin</replaceable>
166                     </literal></para>
167                 </entry>
168                 <entry>
169                   <para>Sets how far before the deadline Lustre sends an early reply. Default value is 5<footnote>
170                       <para>This default was chosen as a reasonable time in which to send a reply from the point at which it was sent.</para>
171                     </footnote>.</para>
172                 </entry>
173               </row>
174               <row>
175                 <entry>
176                   <para> <literal>
177                       <replaceable role="bold">at_extra</replaceable>
178                     </literal></para>
179                 </entry>
180                 <entry>
181                   <para>Sets the incremental amount of time that a server asks for, with each early reply. The server does not know how much time the RPC will take, so it asks for a fixed value. Default value is 30<footnote>
182                       <para>This default was chosen as a balance between sending too many early replies for the same RPC and overestimating the actual completion time</para>
183                     </footnote>. When a server finds a queued request about to time out (and needs to send an early reply out), the server adds the at_extra value. If the time expires, the Lustre client enters recovery status and reconnects to restore it to normal status.</para>
184                   <para>If you see multiple early replies for the same RPC asking for multiple 30-second increases, change the at_extra value to a larger number to cut down on early replies sent and, therefore, network load.</para>
185                 </entry>
186               </row>
187               <row>
188                 <entry>
189                   <para> <literal>
190                       <replaceable role="bold">ldlm_enqueue_min</replaceable>
191                     </literal></para>
192                 </entry>
193                 <entry>
194                   <para> Sets the minimum lock enqueue time. Default value is 100. The <literal>ldlm_enqueue</literal> time is the maximum of the measured enqueue estimate (influenced by at_min and at_max parameters), multiplied by a weighting factor, and the <literal>ldlm_enqueue_min</literal> setting. LDLM lock enqueues were based on the <literal>obd_timeout</literal> value; now they have a dedicated minimum value. Lock enqueues increase as the measured enqueue times increase (similar to adaptive timeouts).</para>
195                 </entry>
196               </row>
197             </tbody>
198           </tgroup>
199         </informaltable>
200         <para>Adaptive timeouts are enabled, by default. To disable adaptive timeouts, at run time, set <literal>at_max</literal> to 0. On the MGS, run:</para>
201         <screen>$ lctl conf_param &lt;fsname&gt;.sys.at_max=0</screen>
202         <note>
203           <para>Changing adaptive timeouts status at runtime may cause transient timeout, reconnect, recovery, etc.</para>
204         </note>
205       </section>
206       <section remap="h4">
207         <title>31.1.3.2 Interpreting Adaptive Timeouts Information</title>
208         <para>Adaptive timeouts information can be read from <literal>/proc/fs/lustre/*/timeouts</literal> files (for each service and client) or with the lctl command.</para>
209         <para>This is an example from the <literal>/proc/fs/lustre/*/timeouts</literal> files:</para>
210         <screen>cfs21:~# cat /proc/fs/lustre/ost/OSS/ost_io/timeouts</screen>
211         <para>This is an example using the <literal>lctl</literal> command:</para>
212         <screen>$ lctl get_param -n ost.*.ost_io.timeouts</screen>
213         <para>This is the sample output:</para>
214         <screen>service : cur 33  worst 34 (at 1193427052, 0d0h26m40s ago) 1 1 33 2</screen>
215         <para>The <literal>ost_io</literal> service on this node is currently reporting an estimate of 33 seconds. The worst RPC service time was 34 seconds, and it happened 26 minutes ago.</para>
216         <para>The output also provides a history of service times. In the example, there are 4 &quot;bins&quot; of <literal>adaptive_timeout_history</literal>, with the maximum RPC time in each bin reported. In 0-150 seconds, the maximum RPC time was 1, with the same result in 150-300 seconds. From 300-450 seconds, the worst (maximum) RPC time was 33 seconds, and from 450-600s the worst time was 2 seconds. The current estimated service time is the maximum value of the 4 bins (33 seconds in this example).</para>
217         <para>Service times (as reported by the servers) are also tracked in the client OBDs:</para>
218         <screen>cfs21:# lctl get_param osc.*.timeouts
219 last reply : 1193428639, 0d0h00m00s ago
220 network    : cur   1  worst   2 (at 1193427053, 0d0h26m26s ago)   1   1   1   1
221 portal 6   : cur  33  worst  34 (at 1193427052, 0d0h26m27s ago)  33  33  33   2
222 portal 28  : cur   1  worst   1 (at 1193426141, 0d0h41m38s ago)   1   1   1   1
223 portal 7   : cur   1  worst   1 (at 1193426141, 0d0h41m38s ago)   1   0   1   1
224 portal 17  : cur   1  worst   1 (at 1193426177, 0d0h41m02s ago)   1   0   0   1
225 </screen>
226         <para>In this case, RPCs to portal 6, the <literal>OST_IO_PORTAL</literal> (see <literal>lustre/include/lustre/lustre_idl.h</literal>), shows the history of what the <literal>ost_io</literal> portal has reported as the service estimate.</para>
227         <para>Server statistic files also show the range of estimates in the normal min/max/sum/sumsq manner.</para>
228         <screen>cfs21:~# lctl get_param mdt.*.mdt.stats
229 ...
230 req_timeout               6 samples [sec] 1 10 15 105
231 ...
232 </screen>
233       </section>
234     </section>
235     <section remap="h3">
236       <title>31.1.4 LNET Information</title>
237       <para>This section describes<literal> /proc</literal> entries for LNET information.</para>
238       <para><literal>
239           <replaceable role="bold">/proc/sys/lnet/peers</replaceable>
240         </literal></para>
241       <para>Shows all NIDs known to this node and also gives information on the queue state.</para>
242       <screen># cat /proc/sys/lnet/peers
243 nid                        refs            state           max             rtr             min             tx              min             queue
244 0@lo                       1               ~rtr            0               0               0               0               0               0
245 192.168.10.35@tcp  1               ~rtr            8               8               8               8               6               0
246 192.168.10.36@tcp  1               ~rtr            8               8               8               8               6               0
247 192.168.10.37@tcp  1               ~rtr            8               8               8               8               6               0</screen>
248       <para>The fields are explained below:</para>
249       <informaltable frame="all">
250         <tgroup cols="2">
251           <colspec colname="c1" colwidth="50*"/>
252           <colspec colname="c2" colwidth="50*"/>
253           <thead>
254             <row>
255               <entry>
256                 <para><emphasis role="bold">Field</emphasis></para>
257               </entry>
258               <entry>
259                 <para><emphasis role="bold">Description</emphasis></para>
260               </entry>
261             </row>
262           </thead>
263           <tbody>
264             <row>
265               <entry>
266                 <para> 
267                         <literal><replaceable>refs</replaceable></literal>
268                   </para>
269               </entry>
270               <entry>
271                 <para>A reference count (principally used for debugging)</para>
272               </entry>
273             </row>
274             <row>
275               <entry>
276                 <para> 
277                         <literal><replaceable>state</replaceable></literal>
278                   </para>
279               </entry>
280               <entry>
281                 <para>Only valid to refer to routers. Possible values:</para>
282                 <itemizedlist>
283                   <listitem>
284                     <para>~ rtr (indicates this node is not a router)</para>
285                   </listitem>
286                   <listitem>
287                     <para>up/down (indicates this node is a router)</para>
288                   </listitem>
289                   <listitem>
290                     <para>auto_fail must be enabled</para>
291                   </listitem>
292                 </itemizedlist>
293               </entry>
294             </row>
295             <row>
296               <entry>
297                 <para> <literal>
298                     <replaceable role="bold">max</replaceable>
299                   </literal></para>
300               </entry>
301               <entry>
302                 <para>Maximum number of concurrent sends from this peer</para>
303               </entry>
304             </row>
305             <row>
306               <entry>
307                 <para> <literal>
308                     <replaceable role="bold">rtr</replaceable>
309                   </literal></para>
310               </entry>
311               <entry>
312                 <para>Routing buffer credits.</para>
313               </entry>
314             </row>
315             <row>
316               <entry>
317                 <para> <literal>
318                     <replaceable role="bold">min</replaceable>
319                   </literal></para>
320               </entry>
321               <entry>
322                 <para>Minimum routing buffer credits seen.</para>
323               </entry>
324             </row>
325             <row>
326               <entry>
327                 <para> <literal>
328                     <replaceable role="bold">tx</replaceable>
329                   </literal></para>
330               </entry>
331               <entry>
332                 <para>Send credits.</para>
333               </entry>
334             </row>
335             <row>
336               <entry>
337                 <para> <literal>
338                     <replaceable role="bold">min</replaceable>
339                   </literal></para>
340               </entry>
341               <entry>
342                 <para>Minimum send credits seen.</para>
343               </entry>
344             </row>
345             <row>
346               <entry>
347                 <para> <literal>
348                     <replaceable role="bold">queue</replaceable>
349                   </literal></para>
350               </entry>
351               <entry>
352                 <para>Total bytes in active/queued sends.</para>
353               </entry>
354             </row>
355           </tbody>
356         </tgroup>
357       </informaltable>
358       <para>Credits work like a semaphore. At start they are initialized to allow a certain number of operations (8 in this example). LNET keeps a track of the minimum value so that you can see how congested a resource was.</para>
359       <para>If <literal>rtr/tx</literal> is less than max, there are operations in progress. The number of operations is equal to <literal>rtr</literal> or <literal>tx</literal> subtracted from max.</para>
360       <para>If <literal>rtr/tx</literal> is greater that max, there are operations blocking.</para>
361       <para>LNET also limits concurrent sends and router buffers allocated to a single peer so that no peer can occupy all these resources.</para>
362       <para><literal>
363           <replaceable role="bold">/proc/sys/lnet/nis</replaceable>
364         </literal></para>
365       <screen># cat /proc/sys/lnet/nis
366 nid                                refs            peer            max             tx              min
367 0@lo                               3               0               0               0               0
368 192.168.10.34@tcp          4               8               256             256             252
369 </screen>
370       <para>Shows the current queue health on this node. The fields are explained below:</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">Field</emphasis></para>
379               </entry>
380               <entry>
381                 <para><emphasis role="bold">Description</emphasis></para>
382               </entry>
383             </row>
384           </thead>
385           <tbody>
386             <row>
387               <entry>
388                 <para> <literal>
389                     <replaceable role="bold">nid</replaceable>
390                   </literal></para>
391               </entry>
392               <entry>
393                 <para>Network interface</para>
394               </entry>
395             </row>
396             <row>
397               <entry>
398                 <para> <literal>
399                     <replaceable role="bold">refs</replaceable>
400                   </literal></para>
401               </entry>
402               <entry>
403                 <para>Internal reference counter</para>
404               </entry>
405             </row>
406             <row>
407               <entry>
408                 <para> <literal>
409                     <replaceable role="bold">peer</replaceable>
410                   </literal></para>
411               </entry>
412               <entry>
413                 <para>Number of peer-to-peer send credits on this NID. Credits are used to size buffer pools</para>
414               </entry>
415             </row>
416             <row>
417               <entry>
418                 <para> <literal>
419                     <replaceable role="bold">max</replaceable>
420                   </literal></para>
421               </entry>
422               <entry>
423                 <para>Total number of send credits on this NID.</para>
424               </entry>
425             </row>
426             <row>
427               <entry>
428                 <para> <literal>
429                     <replaceable role="bold">tx</replaceable>
430                   </literal></para>
431               </entry>
432               <entry>
433                 <para>Current number of send credits available on this NID.</para>
434               </entry>
435             </row>
436             <row>
437               <entry>
438                 <para> <literal>
439                     <replaceable role="bold">min</replaceable>
440                   </literal></para>
441               </entry>
442               <entry>
443                 <para>Lowest number of send credits available on this NID.</para>
444               </entry>
445             </row>
446             <row>
447               <entry>
448                 <para> <literal>
449                     <replaceable role="bold">queue</replaceable>
450                   </literal></para>
451               </entry>
452               <entry>
453                 <para>Total bytes in active/queued sends.</para>
454               </entry>
455             </row>
456           </tbody>
457         </tgroup>
458       </informaltable>
459       <para>Subtracting <literal>max</literal> - <literal>tx</literal> yields the number of sends currently active. A large or increasing number of active sends may indicate a problem.</para>
460       <screen># cat /proc/sys/lnet/nis
461 nid                                refs            peer            max             tx              min
462 0@lo                               2               0               0               0               0
463 10.67.73.173@tcp           4               8               256             256             253
464 </screen>
465     </section>
466     <section remap="h3">
467       <title>31.1.5 Free Space Distribution</title>
468       <para>Free-space stripe weighting, as set, gives a priority of &quot;0&quot; to free space (versus trying to place the stripes &quot;widely&quot; -- nicely distributed across OSSs and OSTs to maximize network balancing). To adjust this priority (as a percentage), use the <literal>qos_prio_free</literal> proc tunable:</para>
469       <screen>$ cat /proc/fs/lustre/lov/&lt;fsname&gt;-mdtlov/qos_prio_free</screen>
470       <para>Currently, the default is 90%. You can permanently set this value by running this command on the MGS:</para>
471       <screen>$ lctl conf_param &lt;fsname&gt;-MDT0000.lov.qos_prio_free=90</screen>
472       <para>Setting the priority to 100% means that OSS distribution does not count in the weighting, but the stripe assignment is still done via weighting. If OST 2 has twice as much free space as OST 1, it is twice as likely to be used, but it is NOT guaranteed to be used.</para>
473       <para>Also note that free-space stripe weighting does not activate until two OSTs are imbalanced by more than 20%. Until then, a faster round-robin stripe allocator is used. (The new round-robin order also maximizes network balancing.)</para>
474       <section remap="h4">
475         <title>31.1.5.1 Managing Stripe Allocation</title>
476         <para>The MDS uses two methods to manage stripe allocation and determine which OSTs to use for file object storage:</para>
477         <itemizedlist>
478           <listitem>
479             <para><emphasis role="bold">QOS</emphasis></para>
480             <para>Quality of Service (QOS) considers an OST&apos;s available blocks, speed, and the number of existing objects, etc. Using these criteria, the MDS selects OSTs with more free space more often than OSTs with less free space.</para>
481           </listitem>
482         </itemizedlist>
483         <itemizedlist>
484           <listitem>
485             <para><emphasis role="bold">RR</emphasis></para>
486             <para>Round-Robin (RR) allocates objects evenly across all OSTs. The RR stripe allocator is faster than QOS, and used often because it distributes space usage/load best in most situations, maximizing network balancing and improving performance.</para>
487           </listitem>
488         </itemizedlist>
489         <para>Whether QOS or RR is used depends on the setting of the <literal>qos_threshold_rr</literal> proc tunable. The <literal>qos_threshold_rr</literal> variable specifies a percentage threshold where the use of QOS or RR becomes more/less likely. The <literal>qos_threshold_rr</literal> tunable can be set as an integer, from 0 to 100, and results in this stripe allocation behavior:</para>
490         <itemizedlist>
491           <listitem>
492             <para> If <literal>qos_threshold_rr</literal> is set to 0, then QOS is always used</para>
493           </listitem>
494           <listitem>
495             <para> If <literal>qos_threshold_rr</literal> is set to 100, then RR is always used</para>
496           </listitem>
497           <listitem>
498             <para> The larger the <literal>qos_threshold_rr</literal> setting, the greater the possibility that RR is used instead of QOS</para>
499           </listitem>
500         </itemizedlist>
501       </section>
502     </section>
503   </section>
504   <section xml:id="dbdoclet.50438271_78950">
505     <title>31.2 Lustre I/O Tunables</title>
506     <para>The section describes I/O tunables.</para>
507     <para><literal>
508         <replaceable role="bold">/proc/fs/lustre/llite/&lt;fsname&gt;-&lt;uid&gt;/max_cache_mb</replaceable>
509       </literal></para>
510     <screen># cat /proc/fs/lustre/llite/lustre-ce63ca00/max_cached_mb 128</screen>
511     <para>This tunable is the maximum amount of inactive data cached by the client (default is 3/4 of RAM).</para>
512     <section remap="h3">
513       <title>31.2.1 Client I/O RPC Stream Tunables</title>
514       <para>The Lustre engine always attempts to pack an optimal amount of data into each I/O RPC and attempts to keep a consistent number of issued RPCs in progress at a time. Lustre exposes several tuning variables to adjust behavior according to network conditions and cluster size. Each OSC has its own tree of these tunables. For example:</para>
515       <screen>$ ls -d /proc/fs/lustre/osc/OSC_client_ost1_MNT_client_2 /localhost
516 /proc/fs/lustre/osc/OSC_uml0_ost1_MNT_localhost
517 /proc/fs/lustre/osc/OSC_uml0_ost2_MNT_localhost
518 /proc/fs/lustre/osc/OSC_uml0_ost3_MNT_localhost
519 $ ls /proc/fs/lustre/osc/OSC_uml0_ost1_MNT_localhost
520 blocksizefilesfree max_dirty_mb ost_server_uuid stats</screen>
521       <para>... and so on.</para>
522       <para>RPC stream tunables are described below.</para>
523       <para><literal>
524           <replaceable role="bold">/proc/fs/lustre/osc/&lt;object name&gt;/max_dirty_mb</replaceable>
525         </literal></para>
526       <para>This tunable controls how many MBs of dirty data can be written and queued up in the OSC. POSIX file writes that are cached contribute to this count. When the limit is reached, additional writes stall until previously-cached writes are written to the server. This may be changed by writing a single ASCII integer to the file. Only values between 0 and 512 are allowable. If 0 is given, no writes are cached. Performance suffers noticeably unless you use large writes (1 MB or more).</para>
527       <para><literal>
528           <replaceable role="bold">/proc/fs/lustre/osc/&lt;object name&gt;/cur_dirty_bytes</replaceable>
529         </literal></para>
530       <para>This tunable is a read-only value that returns the current amount of bytes written and cached on this OSC.</para>
531       <para><literal>
532           <replaceable role="bold">/proc/fs/lustre/osc/&lt;object name&gt;/max_pages_per_rpc</replaceable>
533         </literal></para>
534       <para>This tunable is the maximum number of pages that will undergo I/O in a single RPC to the OST. The minimum is a single page and the maximum for this setting is platform dependent (256 for i386/x86_64, possibly less for ia64/PPC with larger <literal>PAGE_SIZE</literal>), though generally amounts to a total of 1 MB in the RPC.</para>
535       <para><literal>
536           <replaceable role="bold">/proc/fs/lustre/osc/&lt;object name&gt;/max_rpcs_in_flight</replaceable>
537         </literal></para>
538       <para>This tunable is the maximum number of concurrent RPCs in flight from an OSC to its OST. If the OSC tries to initiate an RPC but finds that it already has the same number of RPCs outstanding, it will wait to issue further RPCs until some complete. The minimum setting is 1 and maximum setting is 32. If you are looking to improve small file I/O performance, increase the <literal>max_rpcs_in_flight</literal> value.</para>
539       <para>To maximize performance, the value for <literal>max_dirty_mb</literal> is recommended to be 4 * <literal>max_pages_per_rpc</literal> * <literal>max_rpcs_in_flight</literal>.</para>
540       <note>
541         <para>The 
542             <literal><replaceable>&lt;object name&gt;</replaceable></literal>
543            varies depending on the specific Lustre configuration. For <literal>&lt;object name&gt;</literal> examples, refer to the sample command output.</para>
544       </note>
545     </section>
546     <section remap="h3">
547       <title>31.2.2 Watching the Client RPC Stream</title>
548       <para>The same directory contains a <literal>rpc_stats</literal> file with a histogram showing the composition of previous RPCs. The histogram can be cleared by writing any value into the <literal>rpc_stats</literal> file.</para>
549       <screen># cat /proc/fs/lustre/osc/spfs-OST0000-osc-c45f9c00/rpc_stats
550 snapshot_time:                                     1174867307.156604 (secs.usecs)
551 read RPCs in flight:                               0
552 write RPCs in flight:                              0
553 pending write pages:                               0
554 pending read pages:                                0
555                    read                                    write
556 pages per rpc              rpcs    %       cum     %       |       rpcs    %       cum     %
557 1:                 0       0       0               |       0               0       0
558  
559                    read                                    write
560 rpcs in flight             rpcs    %       cum     %       |       rpcs    %       cum     %
561 0:                 0       0       0               |       0               0       0
562  
563                    read                                    write
564 offset                     rpcs    %       cum     %       |       rpcs    %       cum     %
565 0:                 0       0       0               |       0               0       0
566 </screen>
567       <para>Where:</para>
568       <informaltable frame="all">
569         <tgroup cols="2">
570           <colspec colname="c1" colwidth="50*"/>
571           <colspec colname="c2" colwidth="50*"/>
572           <thead>
573             <row>
574               <entry>
575                 <para><emphasis role="bold">Field</emphasis></para>
576               </entry>
577               <entry>
578                 <para><emphasis role="bold">Description</emphasis></para>
579               </entry>
580             </row>
581           </thead>
582           <tbody>
583             <row>
584               <entry>
585                 <para> <emphasis role="bold">{read,write} RPCs in flight</emphasis></para>
586               </entry>
587               <entry>
588                 <para>Number of read/write RPCs issued by the OSC, but not complete at the time of the snapshot. This value should always be less than or equal to max_rpcs_in_flight.</para>
589               </entry>
590             </row>
591             <row>
592               <entry>
593                 <para> <emphasis role="bold">pending {read,write} pages</emphasis></para>
594               </entry>
595               <entry>
596                 <para>Number of pending read/write pages that have been queued for I/O in the OSC.</para>
597               </entry>
598             </row>
599             <row>
600               <entry>
601                 <para> <emphasis role="bold">pages per RPC</emphasis></para>
602               </entry>
603               <entry>
604                 <para>When an RPC is sent, the number of pages it consists of is recorded (in order). A single page RPC increments the 0: row.</para>
605               </entry>
606             </row>
607             <row>
608               <entry>
609                 <para> <emphasis role="bold">RPCs in flight</emphasis></para>
610               </entry>
611               <entry>
612                 <para>When an RPC is sent, the number of other RPCs that are pending is recorded. When the first RPC is sent, the 0: row is incremented. If the first RPC is sent while another is pending, the 1: row is incremented and so on. As each RPC *completes*, the number of pending RPCs is not tabulated.</para>
613                 <para>This table is a good way to visualize the concurrency of the RPC stream. Ideally, you will see a large clump around the max_rpcs_in_flight value, which shows that the network is being kept busy.</para>
614               </entry>
615             </row>
616             <row>
617               <entry>
618                 <para> <emphasis role="bold">offset</emphasis></para>
619               </entry>
620               <entry>
621                 <para> </para>
622               </entry>
623             </row>
624           </tbody>
625         </tgroup>
626       </informaltable>
627     </section>
628     <section remap="h3">
629       <title>31.2.3 Client Read-Write Offset Survey</title>
630       <para>The offset_stats parameter maintains statistics for occurrences where a series of read or write calls from a process did not access the next sequential location. The offset field is reset to 0 (zero) whenever a different file is read/written.</para>
631       <para>Read/write offset statistics are off, by default. The statistics can be activated by writing anything into the <literal>offset_stats</literal> file.</para>
632       <para>Example:</para>
633       <screen># cat /proc/fs/lustre/llite/lustre-f57dee00/rw_offset_stats
634 snapshot_time: 1155748884.591028 (secs.usecs)
635 R/W                PID             RANGE START             RANGE END               SMALLEST EXTENT         LARGEST EXTENT                          OFFSET
636 R          8385            0                       128                     128                     128                             0
637 R          8385            0                       224                     224                     224                             -128
638 W          8385            0                       250                     50                      100                             0
639 W          8385            100                     1110                    10                      500                             -150
640 W          8384            0                       5233                    5233                    5233                            0
641 R          8385            500                     600                     100                     100                             -610</screen>
642       <para>Where:</para>
643       <informaltable frame="all">
644         <tgroup cols="2">
645           <colspec colname="c1" colwidth="50*"/>
646           <colspec colname="c2" colwidth="50*"/>
647           <thead>
648             <row>
649               <entry>
650                 <para><emphasis role="bold">Field</emphasis></para>
651               </entry>
652               <entry>
653                 <para><emphasis role="bold">Description</emphasis></para>
654               </entry>
655             </row>
656           </thead>
657           <tbody>
658             <row>
659               <entry>
660                 <para> <literal>
661                     <replaceable role="bold">R/W</replaceable>
662                   </literal></para>
663               </entry>
664               <entry>
665                 <para>Whether the non-sequential call was a read or write</para>
666               </entry>
667             </row>
668             <row>
669               <entry>
670                 <para> <literal>
671                     <replaceable role="bold">PID</replaceable>
672                   </literal></para>
673               </entry>
674               <entry>
675                 <para>Process ID which made the read/write call.</para>
676               </entry>
677             </row>
678             <row>
679               <entry>
680                 <para> <literal>
681                     <replaceable role="bold">Range Start/Range End</replaceable>
682                   </literal></para>
683               </entry>
684               <entry>
685                 <para>Range in which the read/write calls were sequential.</para>
686               </entry>
687             </row>
688             <row>
689               <entry>
690                 <para> <literal>
691                     <replaceable role="bold">Smallest Extent</replaceable>
692                   </literal></para>
693               </entry>
694               <entry>
695                 <para>Smallest extent (single read/write) in the corresponding range.</para>
696               </entry>
697             </row>
698             <row>
699               <entry>
700                 <para> <literal>
701                     <replaceable role="bold">Largest Extent</replaceable>
702                   </literal></para>
703               </entry>
704               <entry>
705                 <para>Largest extent (single read/write) in the corresponding range.</para>
706               </entry>
707             </row>
708             <row>
709               <entry>
710                 <para> <literal>
711                     <replaceable role="bold">Offset</replaceable>
712                   </literal></para>
713               </entry>
714               <entry>
715                 <para>Difference from the previous range end to the current range start.</para>
716                 <para>For example, Smallest-Extent indicates that the writes in the range 100 to 1110 were sequential, with a minimum write of 10 and a maximum write of 500. This range was started with an offset of -150. That means this is the difference between the last entry&apos;s range-end and this entry&apos;s range-start for the same file.</para>
717                 <para>The <literal>rw_offset_stats</literal> file can be cleared by writing to it:</para>
718                 <screen>echo &gt; /proc/fs/lustre/llite/lustre-f57dee00/rw_offset_stats</screen>
719               </entry>
720             </row>
721           </tbody>
722         </tgroup>
723       </informaltable>
724     </section>
725     <section remap="h3">
726       <title>31.2.4 Client Read-Write Extents Survey</title>
727       <para><emphasis role="bold">Client-Based I/O Extent Size Survey</emphasis></para>
728       <para>The <literal>rw_extent_stats</literal> histogram in the <literal>llite</literal> directory shows you the statistics for the sizes of the read-write I/O extents. This file does not maintain the per-process statistics.</para>
729       <para>Example:</para>
730       <screen>$ cat /proc/fs/lustre/llite/lustre-ee5af200/extents_stats
731 snapshot_time:                     1213828728.348516 (secs.usecs)
732                            read            |               write
733 extents                    calls   %       cum%    |       calls   %       cum%
734  
735 0K - 4K :          0       0       0       |       2       2       2
736 4K - 8K :          0       0       0       |       0       0       2
737 8K - 16K :         0       0       0       |       0       0       2
738 16K - 32K :                0       0       0       |       20      23      26
739 32K - 64K :                0       0       0       |       0       0       26
740 64K - 128K :               0       0       0       |       51      60      86
741 128K - 256K :              0       0       0       |       0       0       86
742 256K - 512K :              0       0       0       |       0       0       86
743 512K - 1024K :             0       0       0       |       0       0       86
744 1M - 2M :          0       0       0       |       11      13      100</screen>
745       <para>The file can be cleared by issuing the following command:</para>
746       <screen>$ echo &gt; cat /proc/fs/lustre/llite/lustre-ee5af200/extents_stats</screen>
747       <para><emphasis role="bold">Per-Process Client I/O Statistics</emphasis></para>
748       <para>The <literal>extents_stats_per_process</literal> file maintains the I/O extent size statistics on a per-process basis. So you can track the per-process statistics for the last <literal>MAX_PER_PROCESS_HIST</literal> processes.</para>
749       <para>Example:</para>
750       <screen>$ cat /proc/fs/lustre/llite/lustre-ee5af200/extents_stats_per_process
751 snapshot_time:                     1213828762.204440 (secs.usecs)
752                            read            |               write
753 extents                    calls   %       cum%    |       calls   %       cum%
754  
755 PID: 11488
756    0K - 4K :       0       0        0      |       0       0       0
757    4K - 8K :       0       0        0      |       0       0       0
758    8K - 16K :      0       0        0      |       0       0       0
759    16K - 32K :     0       0        0      |       0       0       0
760    32K - 64K :     0       0        0      |       0       0       0
761    64K - 128K :    0       0        0      |       0       0       0
762    128K - 256K :   0       0        0      |       0       0       0
763    256K - 512K :   0       0        0      |       0       0       0
764    512K - 1024K :  0       0        0      |       0       0       0
765    1M - 2M :       0       0        0      |       10      100     100
766  
767 PID: 11491
768    0K - 4K :       0       0        0      |       0       0       0
769    4K - 8K :       0       0        0      |       0       0       0
770    8K - 16K :      0       0        0      |       0       0       0
771    16K - 32K :     0       0        0      |       20      100     100
772    
773 PID: 11424
774    0K - 4K :       0       0        0      |       0       0       0
775    4K - 8K :       0       0        0      |       0       0       0
776    8K - 16K :      0       0        0      |       0       0       0
777    16K - 32K :     0       0        0      |       0       0       0
778    32K - 64K :     0       0        0      |       0       0       0
779    64K - 128K :    0       0        0      |       16      100     100
780  
781 PID: 11426
782    0K - 4K :       0       0        0      |       1       100     100
783  
784 PID: 11429
785    0K - 4K :       0       0        0      |       1       100     100
786  
787 </screen>
788     </section>
789     <section xml:id="dbdoclet.50438271_55057">
790       <title>31.2.5 Watching the OST Block I/O Stream</title>
791       <para>Similarly, there is a <literal>brw_stats</literal> histogram in the obdfilter directory which shows you the statistics for number of I/O requests sent to the disk, their size and whether they are contiguous on the disk or not.</para>
792       <screen>cat /proc/fs/lustre/obdfilter/lustre-OST0000/brw_stats 
793 snapshot_time:                     1174875636.764630 (secs:usecs)
794                            read                            write
795 pages per brw              brws    %       cum %   |       rpcs    %       cum %
796 1:                 0       0       0       |       0       0       0
797                            read                                    write
798 discont pages              rpcs    %       cum %   |       rpcs    %       cum %
799 1:                 0       0       0       |       0       0       0
800                            read                                    write
801 discont blocks             rpcs    %       cum %   |       rpcs    %       cum %
802 1:                 0       0       0       |       0       0       0
803                            read                                    write
804 dio frags          rpcs    %       cum %   |       rpcs    %       cum %
805 1:                 0       0       0       |       0       0       0
806                            read                                    write
807 disk ios in flight rpcs    %       cum %   |       rpcs    %       cum %
808 1:                 0       0       0       |       0       0       0
809                            read                                    write
810 io time (1/1000s)  rpcs    %       cum %   |       rpcs    %       cum %
811 1:                 0       0       0       |       0       0       0
812                            read                                    write
813 disk io size               rpcs    %       cum %   |       rpcs    %       cum %
814 1:                 0       0       0       |       0       0       0
815                            read                                    write
816 </screen>
817       <para>The fields are explained below:</para>
818       <informaltable frame="all">
819         <tgroup cols="2">
820           <colspec colname="c1" colwidth="50*"/>
821           <colspec colname="c2" colwidth="50*"/>
822           <thead>
823             <row>
824               <entry>
825                 <para><emphasis role="bold">Field</emphasis></para>
826               </entry>
827               <entry>
828                 <para><emphasis role="bold">Description</emphasis></para>
829               </entry>
830             </row>
831           </thead>
832           <tbody>
833             <row>
834               <entry>
835                 <para> <literal>
836                     <replaceable role="bold">pages per brw</replaceable>
837                   </literal></para>
838               </entry>
839               <entry>
840                 <para>Number of pages per RPC request, which should match aggregate client <literal>rpc_stats</literal>.</para>
841               </entry>
842             </row>
843             <row>
844               <entry>
845                 <para> <literal>
846                     <replaceable role="bold">discont pages</replaceable>
847                   </literal></para>
848               </entry>
849               <entry>
850                 <para>Number of discontinuities in the logical file offset of each page in a single RPC.</para>
851               </entry>
852             </row>
853             <row>
854               <entry>
855                 <para> <literal>
856                     <replaceable role="bold">discont blocks</replaceable>
857                   </literal></para>
858               </entry>
859               <entry>
860                 <para>Number of discontinuities in the physical block allocation in the file system for a single RPC.</para>
861               </entry>
862             </row>
863           </tbody>
864         </tgroup>
865       </informaltable>
866       <para>For each Lustre service, the following information is provided:</para>
867       <itemizedlist>
868         <listitem>
869           <para>Number of requests</para>
870         </listitem>
871         <listitem>
872           <para>Request wait time (avg, min, max and std dev)</para>
873         </listitem>
874         <listitem>
875           <para>Service idle time (% of elapsed time)</para>
876         </listitem>
877       </itemizedlist>
878       <para>Additionally, data on each Lustre service is provided by service type:</para>
879       <itemizedlist>
880         <listitem>
881           <para>Number of requests of this type</para>
882         </listitem>
883         <listitem>
884           <para>Request service time (avg, min, max and std dev)</para>
885         </listitem>
886       </itemizedlist>
887     </section>
888     <section remap="h3">
889       <title>31.2.6 Using File Readahead and Directory Statahead</title>
890       <para>Lustre 1.6.5.1 introduced file readahead and directory statahead functionality that read data into memory in anticipation of a process actually requesting the data. File readahead functionality reads file content data into memory. Directory statahead functionality reads metadata into memory. When readahead and/or statahead work well, a data-consuming process finds that the information it needs is available when requested, and it is unnecessary to wait for network I/O.</para>
891       <section remap="h4">
892         <title>31.2.6.1 Tuning File Readahead</title>
893         <para>File readahead is triggered when two or more sequential reads by an application fail to be satisfied by the Linux buffer cache. The size of the initial readahead is 1 MB. Additional readaheads grow linearly, and increment until the readahead cache on the client is full at 40 MB.</para>
894         <para><literal>
895             <replaceable role="bold">/proc/fs/lustre/llite/&lt;fsname&gt;-&lt;uid&gt;/max_read_ahead_mb</replaceable>
896           </literal></para>
897         <para>This tunable controls the maximum amount of data readahead on a file. Files are read ahead in RPC-sized chunks (1 MB or the size of read() call, if larger) after the second sequential read on a file descriptor. Random reads are done at the size of the read() call only (no readahead). Reads to non-contiguous regions of the file reset the readahead algorithm, and readahead is not triggered again until there are sequential reads again. To disable readahead, set this tunable to 0. The default value is 40 MB.</para>
898         <para><literal>
899             <replaceable role="bold">/proc/fs/lustre/llite/&lt;fsname&gt;-&lt;uid&gt;/max_read_ahead_whole_mb</replaceable>
900           </literal></para>
901         <para>This tunable controls the maximum size of a file that is read in its entirety, regardless of the size of the <literal>read()</literal>.</para>
902       </section>
903       <section remap="h4">
904         <title>31.2.6.2 Tuning Directory Statahead</title>
905         <para>When the <literal>ls -l</literal> process opens a directory, its process ID is recorded. When the first directory entry is &apos;&apos;stated&apos;&apos; with this recorded process ID, a statahead thread is triggered which stats ahead all of the directory entries, in order. The <literal>ls -l</literal> process can use the stated directory entries directly, improving performance.</para>
906         <para><literal>
907             <replaceable role="bold">/proc/fs/lustre/llite/*/statahead_max</replaceable>
908           </literal></para>
909         <para>This tunable controls whether directory <literal>statahead</literal> is enabled and the maximum statahead count. By default, statahead is active.</para>
910         <para>To disable statahead, set this tunable to:</para>
911         <screen>echo 0 &gt; /proc/fs/lustre/llite/*/statahead_max</screen>
912         <para>To set the maximum statahead count (n), set this tunable to:</para>
913         <screen>echo n &gt; /proc/fs/lustre/llite/*/statahead_max</screen>
914         <para>The maximum value of n is 8192.</para>
915         <para>
916           <literal>
917         <replaceable role="bold">
918             /proc/fs/lustre/llite/*/statahead_status
919         </replaceable>
920           </literal>
921       </para>
922         <para>This is a read-only interface that indicates the current statahead status.</para>
923       </section>
924     </section>
925     <section remap="h3">
926       <title>31.2.7 OSS Read Cache</title>
927       <para>The OSS read cache feature provides read-only caching of data on an OSS. This functionality uses the regular Linux page cache to store the data. Just like caching from a regular filesytem in Linux, OSS read cache uses as much physical memory as is allocated.</para>
928       <para>OSS read cache improves Lustre performance in these situations:</para>
929       <itemizedlist>
930         <listitem>
931           <para>Many clients are accessing the same data set (as in HPC applications and when diskless clients boot from Lustre)</para>
932         </listitem>
933         <listitem>
934           <para>One client is storing data while another client is reading it (essentially exchanging data via the OST)</para>
935         </listitem>
936         <listitem>
937           <para>A client has very limited caching of its own</para>
938         </listitem>
939       </itemizedlist>
940       <para>OSS read cache offers these benefits:</para>
941       <itemizedlist>
942         <listitem>
943           <para>Allows OSTs to cache read data more frequently</para>
944         </listitem>
945         <listitem>
946           <para>Improves repeated reads to match network speeds instead of disk speeds</para>
947         </listitem>
948         <listitem>
949           <para>Provides the building blocks for OST write cache (small-write aggregation)</para>
950         </listitem>
951       </itemizedlist>
952       <section remap="h4">
953         <title>31.2.7.1 Using OSS Read Cache</title>
954         <para>OSS read cache is implemented on the OSS, and does not require any special support on the client side. Since OSS read cache uses the memory available in the Linux page cache, you should use I/O patterns to determine the appropriate amount of memory for the cache; if the data is mostly reads, then more cache is required than for writes.</para>
955         <para>OSS read cache is enabled, by default, and managed by the following tunables:</para>
956         <itemizedlist>
957           <listitem>
958             <para><literal>read_cache_enable</literal>  controls whether data read from disk during a read request is kept in memory and available for later read requests for the same data, without having to re-read it from disk. By default, read cache is enabled (<literal>read_cache_enable = 1</literal>).</para>
959           </listitem>
960         </itemizedlist>
961         <para>When the OSS receives a read request from a client, it reads data from disk into its memory and sends the data as a reply to the requests. If read cache is enabled, this data stays in memory after the client&apos;s request is finished, and the OSS skips reading data from disk when subsequent read requests for the same are received. The read cache is managed by the Linux kernel globally across all OSTs on that OSS, and the least recently used cache pages will be dropped from memory when the amount of free memory is running low.</para>
962         <para>If read cache is disabled (<literal>read_cache_enable = 0</literal>), then the OSS will discard the data after the client&apos;s read requests are serviced and, for subsequent read requests, the OSS must read the data from disk.</para>
963         <para>To disable read cache on all OSTs of an OSS, run:</para>
964         <screen>root@oss1# lctl set_param obdfilter.*.read_cache_enable=0</screen>
965         <para>To re-enable read cache on one OST, run:</para>
966         <screen>root@oss1# lctl set_param obdfilter.{OST_name}.read_cache_enable=1</screen>
967         <para>To check if read cache is enabled on all OSTs on an OSS, run:</para>
968         <screen>root@oss1# lctl get_param obdfilter.*.read_cache_enable</screen>
969         <itemizedlist>
970           <listitem>
971             <para><literal>writethrough_cache_enable</literal>  controls whether data sent to the OSS as a write request is kept in the read cache and available for later reads, or if it is discarded from cache when the write is completed. By default, writethrough cache is enabled (<literal>writethrough_cache_enable = 1</literal>).</para>
972           </listitem>
973         </itemizedlist>
974         <para>When the OSS receives write requests from a client, it receives data from the client into its memory and writes the data to disk. If writethrough cache is enabled, this data stays in memory after the write request is completed, allowing the OSS to skip reading this data from disk if a later read request, or partial-page write request, for the same data is received.</para>
975         <para>If writethrough cache is disabled (<literal>writethrough_cache_enabled = 0</literal>), then the OSS discards the data after the client&apos;s write request is completed, and for subsequent read request, or partial-page write request, the OSS must re-read the data from disk.</para>
976         <para>Enabling writethrough cache is advisable if clients are doing small or unaligned writes that would cause partial-page updates, or if the files written by one node are immediately being accessed by other nodes. Some examples where this might be useful include producer-consumer I/O models or shared-file writes with a different node doing I/O not aligned on 4096-byte boundaries. Disabling writethrough cache is advisable in the case where files are mostly written to the file system but are not re-read within a short time period, or files are only written and re-read by the same node, regardless of whether the I/O is aligned or not.</para>
977         <para>To disable writethrough cache on all OSTs of an OSS, run:</para>
978         <screen>root@oss1# lctl set_param obdfilter.*.writethrough_cache_enable=0</screen>
979         <para>To re-enable writethrough cache on one OST, run:</para>
980         <screen>root@oss1# lctl set_param \
981 obdfilter.{OST_name}.writethrough_cache_enable=1</screen>
982         <para>To check if writethrough cache is</para>
983         <screen>root@oss1# lctl set_param obdfilter.*.writethrough_cache_enable=1</screen>
984         <itemizedlist>
985           <listitem>
986             <para><literal>readcache_max_filesize</literal>  controls the maximum size of a file that both the read cache and writethrough cache will try to keep in memory. Files larger than <literal>readcache_max_filesize</literal> will not be kept in cache for either reads or writes.</para>
987           </listitem>
988         </itemizedlist>
989         <para>This can be very useful for workloads where relatively small files are repeatedly accessed by many clients, such as job startup files, executables, log files, etc., but large files are read or written only once. By not putting the larger files into the cache, it is much more likely that more of the smaller files will remain in cache for a longer time.</para>
990         <para>When setting <literal>readcache_max_filesize</literal>, the input value can be specified in bytes, or can have a suffix to indicate other binary units such as <emphasis role="bold">K</emphasis>ilobytes, <emphasis role="bold">M</emphasis>egabytes, <emphasis role="bold">G</emphasis>igabytes, <emphasis role="bold">T</emphasis>erabytes, or <emphasis role="bold">P</emphasis>etabytes.</para>
991         <para>To limit the maximum cached file size to 32MB on all OSTs of an OSS, run:</para>
992         <screen>root@oss1# lctl set_param obdfilter.*.readcache_max_filesize=32M</screen>
993         <para>To disable the maximum cached file size on an OST, run:</para>
994         <screen>root@oss1# lctl set_param \
995 obdfilter.{OST_name}.readcache_max_filesize=-1</screen>
996         <para>To check the current maximum cached file size on all OSTs of an OSS, run:</para>
997         <screen>root@oss1# lctl get_param obdfilter.*.readcache_max_filesize</screen>
998       </section>
999     </section>
1000     <section remap="h3">
1001       <title>31.2.8 OSS Asynchronous Journal Commit</title>
1002       <para>The OSS asynchronous journal commit feature synchronously writes data to disk without forcing a journal flush. This reduces the number of seeks and significantly improves performance on some hardware.</para>
1003       <note>
1004         <para>Asynchronous journal commit cannot work with O_DIRECT writes, a journal flush is still forced.</para>
1005       </note>
1006       <para>When asynchronous journal commit is enabled, client nodes keep data in the page cache (a page reference). Lustre clients monitor the last committed transaction number (transno) in messages sent from the OSS to the clients. When a client sees that the last committed transno reported by the OSS is &gt;=bulk write transno, it releases the reference on the corresponding pages. To avoid page references being held for too long on clients after a bulk write, a 7 second ping request is scheduled (jbd commit time is 5 seconds) after the bulk write reply is received, so the OSS has an opportunity to report the last committed transno.</para>
1007       <para>If the OSS crashes before the journal commit occurs, then the intermediate data is lost. However, new OSS recovery functionality (introduced in the asynchronous journal commit feature), causes clients to replay their write requests and compensate for the missing disk updates by restoring the state of the file system.</para>
1008       <para>To enable asynchronous journal commit, set the <literal>sync_journal parameter</literal> to zero (<literal>sync_journal=0</literal>):</para>
1009       <screen>$ lctl set_param obdfilter.*.sync_journal=0 
1010 obdfilter.lol-OST0001.sync_journal=0</screen>
1011       <para>By default, <literal>sync_journal</literal> is disabled (<literal>sync_journal=1</literal>), which forces a journal flush after every bulk write.</para>
1012       <para>When asynchronous journal commit is used, clients keep a page reference until the journal transaction commits. This can cause problems when a client receives a blocking callback, because pages need to be removed from the page cache, but they cannot be removed because of the extra page reference.</para>
1013       <para>This problem is solved by forcing a journal flush on lock cancellation. When this happens, the client is granted the metadata blocks that have hit the disk, and it can safely release the page reference before processing the blocking callback. The parameter which controls this action is <literal>sync_on_lock_cancel</literal>, which can be set to the following values:</para>
1014       <itemizedlist>
1015         <listitem>
1016           <para><literal>always</literal>: Always force a journal flush on lock cancellation</para>
1017         </listitem>
1018         <listitem>
1019           <para><literal>blocking</literal>: Force a journal flush only when the local cancellation is due to a blocking callback</para>
1020         </listitem>
1021         <listitem>
1022           <para><literal>never</literal>: Do not force any journal flush</para>
1023         </listitem>
1024       </itemizedlist>
1025       <para>Here is an example of <literal>sync_on_lock_cancel</literal> being set not to force a journal flush:</para>
1026       <screen>$ lctl get_param obdfilter.*.sync_on_lock_cancel
1027 obdfilter.lol-OST0001.sync_on_lock_cancel=never</screen>
1028       <para>By default, <literal>sync_on_lock_cancel</literal> is set to never, because asynchronous journal commit is disabled by default.</para>
1029       <para>When asynchronous journal commit is enabled (<literal>sync_journal=0</literal>), <literal>sync_on_lock_cancel</literal> is automatically set to always, if it was previously set to never.</para>
1030       <para>Similarly, when asynchronous journal commit is disabled, (<literal>sync_journal=1</literal>), <literal>sync_on_lock_cancel</literal> is enforced to never.</para>
1031     </section>
1032     <section remap="h3">
1033       <title>31.2.9 <literal>mballoc</literal> History</title>
1034       <para><literal>
1035           <replaceable role="bold">/proc/fs/ldiskfs/sda/mb_history</replaceable>
1036         </literal></para>
1037       <para>Multi-Block-Allocate (<literal>mballoc</literal>), enables Lustre to ask <literal>ldiskfs</literal> to allocate multiple blocks with a single request to the block allocator. Typically, an <literal>ldiskfs</literal> file system allocates only one block per time. Each <literal>mballoc</literal>-enabled partition has this file. This is sample output:</para>
1038       <screen>pid  inode   goal            result          found   grps    cr      \   merge   tail    broken
1039 2838       139267  17/12288/1      17/12288/1      1       0       0       \   M       1       8192
1040 2838       139267  17/12289/1      17/12289/1      1       0       0       \   M       0       0
1041 2838       139267  17/12290/1      17/12290/1      1       0       0       \   M       1       2
1042 2838       24577   3/12288/1       3/12288/1       1       0       0       \   M       1       8192
1043 2838       24578   3/12288/1       3/771/1         1       1       1       \           0       0
1044 2838       32769   4/12288/1       4/12288/1       1       0       0       \   M       1       8192
1045 2838       32770   4/12288/1       4/12289/1       13      1       1       \           0       0
1046 2838       32771   4/12288/1       5/771/1         26      2       1       \           0       0
1047 2838       32772   4/12288/1       5/896/1         31      2       1       \           1       128
1048 2838       32773   4/12288/1       5/897/1         31      2       1       \           0       0
1049 2828       32774   4/12288/1       5/898/1         31      2       1       \           1       2
1050 2838       32775   4/12288/1       5/899/1         31      2       1       \           0       0
1051 2838       32776   4/12288/1       5/900/1         31      2       1       \           1       4
1052 2838       32777   4/12288/1       5/901/1         31      2       1       \           0       0
1053 2838       32778   4/12288/1       5/902/1         31      2       1       \           1       2</screen>
1054       <para>The parameters are described below:</para>
1055       <informaltable frame="all">
1056         <tgroup cols="2">
1057           <colspec colname="c1" colwidth="50*"/>
1058           <colspec colname="c2" colwidth="50*"/>
1059           <thead>
1060             <row>
1061               <entry>
1062                 <para><emphasis role="bold">Parameter</emphasis></para>
1063               </entry>
1064               <entry>
1065                 <para><emphasis role="bold">Description</emphasis></para>
1066               </entry>
1067             </row>
1068           </thead>
1069           <tbody>
1070             <row>
1071               <entry>
1072                 <para> <emphasis role="bold">
1073                     <literal>pid</literal>
1074                   </emphasis></para>
1075               </entry>
1076               <entry>
1077                 <para>Process that made the allocation.</para>
1078               </entry>
1079             </row>
1080             <row>
1081               <entry>
1082                 <para> <emphasis role="bold">
1083                     <literal>inode</literal>
1084                   </emphasis></para>
1085               </entry>
1086               <entry>
1087                 <para>inode number allocated blocks</para>
1088               </entry>
1089             </row>
1090             <row>
1091               <entry>
1092                 <para> <emphasis role="bold">
1093                     <literal>goal</literal>
1094                   </emphasis></para>
1095               </entry>
1096               <entry>
1097                 <para>Initial request that came to <literal>mballoc</literal> (group/block-in-group/number-of-blocks)</para>
1098               </entry>
1099             </row>
1100             <row>
1101               <entry>
1102                 <para> <emphasis role="bold">
1103                     <literal>result</literal>
1104                   </emphasis></para>
1105               </entry>
1106               <entry>
1107                 <para>What <literal>mballoc</literal> actually found for this request.</para>
1108               </entry>
1109             </row>
1110             <row>
1111               <entry>
1112                 <para> <emphasis role="bold">
1113                     <literal>found</literal>
1114                   </emphasis></para>
1115               </entry>
1116               <entry>
1117                 <para>Number of free chunks <literal>mballoc</literal> found and measured before the final decision.</para>
1118               </entry>
1119             </row>
1120             <row>
1121               <entry>
1122                 <para> <emphasis role="bold">
1123                     <literal>grps</literal>
1124                   </emphasis></para>
1125               </entry>
1126               <entry>
1127                 <para>Number of groups <literal>mballoc</literal> scanned to satisfy the request.</para>
1128               </entry>
1129             </row>
1130             <row>
1131               <entry>
1132                 <para> <emphasis role="bold">
1133                     <literal>cr</literal>
1134                   </emphasis></para>
1135               </entry>
1136               <entry>
1137                 <para>Stage at which <literal>mballoc</literal> found the result:</para>
1138                 <para><emphasis role="bold">0</emphasis> - best in terms of resource allocation. The request was 1MB or larger and was satisfied directly via the kernel buddy allocator.</para>
1139                 <para><emphasis role="bold">1</emphasis> - regular stage (good at resource consumption)</para>
1140                 <para><emphasis role="bold">2</emphasis> - fs is quite fragmented (not that bad at resource consumption)</para>
1141                 <para><emphasis role="bold">3</emphasis> - fs is very fragmented (worst at resource consumption)</para>
1142               </entry>
1143             </row>
1144             <row>
1145               <entry>
1146                 <para> <emphasis role="bold">
1147                     <literal>queue</literal>
1148                   </emphasis></para>
1149               </entry>
1150               <entry>
1151                 <para>Total bytes in active/queued sends.</para>
1152               </entry>
1153             </row>
1154             <row>
1155               <entry>
1156                 <para> <emphasis role="bold">
1157                     <literal>merge</literal>
1158                   </emphasis></para>
1159               </entry>
1160               <entry>
1161                 <para>Whether the request hit the goal. This is good as extents code can now merge new blocks to existing extent, eliminating the need for extents tree growth.</para>
1162               </entry>
1163             </row>
1164             <row>
1165               <entry>
1166                 <para> <emphasis role="bold">
1167                     <literal>tail</literal>
1168                   </emphasis></para>
1169               </entry>
1170               <entry>
1171                 <para>Number of blocks left free after the allocation breaks large free chunks.</para>
1172               </entry>
1173             </row>
1174             <row>
1175               <entry>
1176                 <para> <emphasis role="bold">
1177                     <literal>broken</literal>
1178                   </emphasis></para>
1179               </entry>
1180               <entry>
1181                 <para>How large the broken chunk was.</para>
1182               </entry>
1183             </row>
1184           </tbody>
1185         </tgroup>
1186       </informaltable>
1187       <para>Most customers are probably interested in found/cr. If cr is 0 1 and found is less than 100, then <literal>mballoc</literal> is doing quite well.</para>
1188       <para>Also, number-of-blocks-in-request (third number in the goal triple) can tell the number of blocks requested by the <literal>obdfilter</literal>. If the <literal>obdfilter</literal> is doing a lot of small requests (just few blocks), then either the client is processing input/output to a lot of small files, or something may be wrong with the client (because it is better if client sends large input/output requests). This can be investigated with the OSC <literal>rpc_stats</literal> or OST <literal>brw_stats</literal> mentioned above.</para>
1189       <para>Number of groups scanned (<literal>grps</literal> column) should be small. If it reaches a few dozen often, then either your disk file system is pretty fragmented or <literal>mballoc</literal> is doing something wrong in the group selection part.</para>
1190     </section>
1191     <section remap="h3">
1192       <title>31.2.10 <literal>mballoc3</literal> Tunables</title>
1193       <para>Lustre version 1.6.1 and later includes <literal>mballoc3</literal>, which was built on top of <literal>mballoc2</literal>. By default, mballoc3 is enabled, and adds these features:</para>
1194       <itemizedlist>
1195         <listitem>
1196           <para> Pre-allocation for single files (helps to resist fragmentation)</para>
1197         </listitem>
1198         <listitem>
1199           <para> Pre-allocation for a group of files (helps to pack small files into large, contiguous chunks)</para>
1200         </listitem>
1201         <listitem>
1202           <para> Stream allocation (helps to decrease the seek rate)</para>
1203         </listitem>
1204       </itemizedlist>
1205       <para>The following <literal>mballoc3</literal> tunables are available:</para>
1206       <informaltable frame="all">
1207         <tgroup cols="2">
1208           <colspec colname="c1" colwidth="50*"/>
1209           <colspec colname="c2" colwidth="50*"/>
1210           <thead>
1211             <row>
1212               <entry>
1213                 <para><emphasis role="bold">Field</emphasis></para>
1214               </entry>
1215               <entry>
1216                 <para><emphasis role="bold">Description</emphasis></para>
1217               </entry>
1218             </row>
1219           </thead>
1220           <tbody>
1221             <row>
1222               <entry>
1223                 <para> <emphasis role="bold">
1224                     <literal>stats</literal>
1225                   </emphasis></para>
1226               </entry>
1227               <entry>
1228                 <para>Enables/disables the collection of statistics. Collected statistics can be found</para>
1229                 <para>in <literal>/proc/fs/ldiskfs2/&lt;dev&gt;/mb_history</literal>.</para>
1230               </entry>
1231             </row>
1232             <row>
1233               <entry>
1234                 <para> <literal>
1235                     <replaceable role="bold">max_to_scan</replaceable>
1236                   </literal></para>
1237               </entry>
1238               <entry>
1239                 <para>Maximum number of free chunks that <literal>mballoc</literal> finds before a final decision to avoid livelock.</para>
1240               </entry>
1241             </row>
1242             <row>
1243               <entry>
1244                 <para> <literal>
1245                     <replaceable role="bold">min_to_scan</replaceable>
1246                   </literal></para>
1247               </entry>
1248               <entry>
1249                 <para>Minimum number of free chunks that <literal>mballoc</literal> finds before a final decision. This is useful for a very small request, to resist fragmentation of big free chunks.</para>
1250               </entry>
1251             </row>
1252             <row>
1253               <entry>
1254                 <para> <literal>
1255                     <replaceable role="bold">order2_req</replaceable>
1256                   </literal></para>
1257               </entry>
1258               <entry>
1259                 <para>For requests equal to 2^N (where N &gt;= <literal>order2_req</literal>), a very fast search via buddy structures is used.</para>
1260               </entry>
1261             </row>
1262             <row>
1263               <entry>
1264                 <para> <literal>
1265                     <replaceable role="bold">stream_req</replaceable>
1266                   </literal></para>
1267               </entry>
1268               <entry>
1269                 <para>Requests smaller or equal to this value are packed together to form large write I/Os.</para>
1270               </entry>
1271             </row>
1272           </tbody>
1273         </tgroup>
1274       </informaltable>
1275       <para>The following tunables, providing more control over allocation policy, will be available in the next version:</para>
1276       <informaltable frame="all">
1277         <tgroup cols="2">
1278           <colspec colname="c1" colwidth="50*"/>
1279           <colspec colname="c2" colwidth="50*"/>
1280           <thead>
1281             <row>
1282               <entry>
1283                 <para><emphasis role="bold">Field</emphasis></para>
1284               </entry>
1285               <entry>
1286                 <para><emphasis role="bold">Description</emphasis></para>
1287               </entry>
1288             </row>
1289           </thead>
1290           <tbody>
1291             <row>
1292               <entry>
1293                 <para> <literal>
1294                     <replaceable role="bold">stats</replaceable>
1295                   </literal></para>
1296               </entry>
1297               <entry>
1298                 <para>Enables/disables the collection of statistics. Collected statistics can be found in <literal>/proc/fs/ldiskfs2/&lt;dev&gt;/mb_history</literal>.</para>
1299               </entry>
1300             </row>
1301             <row>
1302               <entry>
1303                 <para> <literal>
1304                     <replaceable role="bold">max_to_scan</replaceable>
1305                   </literal></para>
1306               </entry>
1307               <entry>
1308                 <para>Maximum number of free chunks that <literal>mballoc</literal> finds before a final decision to avoid livelock.</para>
1309               </entry>
1310             </row>
1311             <row>
1312               <entry>
1313                 <para> <literal>
1314                     <replaceable role="bold">min_to_scan</replaceable>
1315                   </literal></para>
1316               </entry>
1317               <entry>
1318                 <para>Minimum number of free chunks that <literal>mballoc</literal> finds before a final decision. This is useful for a very small request, to resist fragmentation of big free chunks.</para>
1319               </entry>
1320             </row>
1321             <row>
1322               <entry>
1323                 <para> <literal>
1324                     <replaceable role="bold">order2_req</replaceable>
1325                   </literal></para>
1326               </entry>
1327               <entry>
1328                 <para>For requests equal to 2^N (where N &gt;= <literal>order2_req</literal>), a very fast search via buddy structures is used.</para>
1329               </entry>
1330             </row>
1331             <row>
1332               <entry>
1333                 <para> <literal>
1334                     <replaceable role="bold">small_req</replaceable>
1335                   </literal></para>
1336               </entry>
1337               <entry morerows="1">
1338                 <para>All requests are divided into 3 categories:</para>
1339                 <para>&lt; small_req (packed together to form large, aggregated requests)</para>
1340                 <para>&lt; large_req (allocated mostly in linearly)</para>
1341                 <para>&gt; large_req (very large requests so the arm seek does not matter)</para>
1342                 <para>The idea is that we try to pack small requests to form large requests, and then place all large requests (including compound from the small ones) close to one another, causing as few arm seeks as possible.</para>
1343               </entry>
1344             </row>
1345             <row>
1346               <entry>
1347                 <para> <literal>
1348                     <replaceable role="bold">large_req</replaceable>
1349                   </literal></para>
1350               </entry>
1351             </row>
1352             <row>
1353               <entry>
1354                 <para> <literal>
1355                     <replaceable role="bold">prealloc_table</replaceable>
1356                   </literal></para>
1357               </entry>
1358               <entry>
1359                 <para>The amount of space to preallocate depends on the current file size. The idea is that for small files we do not need 1 MB preallocations and for large files, 1 MB preallocations are not large enough; it is better to preallocate 4 MB.</para>
1360               </entry>
1361             </row>
1362             <row>
1363               <entry>
1364                 <para> <literal>
1365                     <replaceable role="bold">group_prealloc</replaceable>
1366                   </literal></para>
1367               </entry>
1368               <entry>
1369                 <para>The amount of space preallocated for small requests to be grouped.</para>
1370               </entry>
1371             </row>
1372           </tbody>
1373         </tgroup>
1374       </informaltable>
1375     </section>
1376     <section remap="h3">
1377       <title>31.2.11 Locking</title>
1378       <para><literal>
1379           <replaceable role="bold">/proc/fs/lustre/ldlm/ldlm/namespaces/&lt;OSC name|MDC name&gt;/lru_size</replaceable>
1380         </literal></para>
1381       <para>The <literal>lru_size</literal> parameter is used to control the number of client-side locks in an LRU queue. LRU size is dynamic, based on load. This optimizes the number of locks available to nodes that have different workloads (e.g., login/build nodes vs. compute nodes vs. backup nodes).</para>
1382       <para>The total number of locks available is a function of the server&apos;s RAM. The default limit is 50 locks/1 MB of RAM. If there is too much memory pressure, then the LRU size is shrunk. The number of locks on the server is limited to {number of OST/MDT on node} * {number of clients} * {client lru_size}.</para>
1383       <itemizedlist>
1384         <listitem>
1385           <para>To enable automatic LRU sizing, set the <literal>lru_size</literal> parameter to 0. In this case, the <literal>lru_size</literal> parameter shows the current number of locks being used on the export. (In Lustre 1.6.5.1 and later, LRU sizing is enabled, by default.)</para>
1386         </listitem>
1387         <listitem>
1388           <para>To specify a maximum number of locks, set the lru_size parameter to a value &gt; 0 (former numbers are okay, 100 * CPU_NR). We recommend that you only increase the LRU size on a few login nodes where users access the file system interactively.</para>
1389         </listitem>
1390       </itemizedlist>
1391       <para>To clear the LRU on a single client, and as a result flush client cache, without changing the <literal>lru_size</literal> value:</para>
1392       <screen>$ lctl set_param ldlm.namespaces.&lt;osc_name|mdc_name&gt;.lru_size=clear</screen>
1393       <para>If you shrink the LRU size below the number of existing unused locks, then the unused locks are canceled immediately. Use echo clear to cancel all locks without changing the value.</para>
1394       <note>
1395         <para>Currently, the lru_size parameter can only be set temporarily with <literal>lctl set_param</literal>; it cannot be set permanently.</para>
1396       </note>
1397       <para>To disable LRU sizing, run this command on the Lustre clients:</para>
1398       <screen>$ lctl set_param ldlm.namespaces.*osc*.lru_size=$((NR_CPU*100))</screen>
1399       <para>Replace <literal>NR_CPU</literal> value with the number of CPUs on the node.</para>
1400       <para>To determine the number of locks being granted:</para>
1401       <screen>$ lctl get_param ldlm.namespaces.*.pool.limit</screen>
1402     </section>
1403     <section xml:id="dbdoclet.50438271_87260">
1404       <title>31.2.12 Setting MDS and OSS Thread Counts</title>
1405       <para>MDS and OSS thread counts (minimum and maximum) can be set via the <literal>{min,max}_thread_count tunable</literal>. For each service, a new <literal>/proc/fs/lustre/{service}/*/thread_{min,max,started}</literal> entry is created. The tunable, <literal>{service}.thread_{min,max,started}</literal>, can be used to set the minimum and maximum thread counts or get the current number of running threads for the following services.</para>
1406       <informaltable frame="all">
1407         <tgroup cols="2">
1408           <colspec colname="c1" colwidth="50*"/>
1409           <colspec colname="c2" colwidth="50*"/>
1410           <tbody>
1411             <row>
1412               <entry>
1413                 <para> <emphasis role="bold">Service</emphasis></para>
1414               </entry>
1415               <entry>
1416                 <para> <emphasis role="bold">Description</emphasis></para>
1417               </entry>
1418             </row>
1419             <row>
1420               <entry>
1421                 <literal>
1422                    mdt.MDS.mds
1423                 </literal>
1424               </entry>
1425               <entry>
1426                 <para>normal metadata ops</para>
1427               </entry>
1428             </row>
1429             <row>
1430               <entry>
1431                 <literal>
1432                    mdt.MDS.mds_readpage
1433                 </literal>
1434               </entry>
1435               <entry>
1436                 <para>metadata readdir</para>
1437               </entry>
1438             </row>
1439             <row>
1440               <entry>
1441                 <literal>
1442                    mdt.MDS.mds_setattr
1443                 </literal>
1444               </entry>
1445               <entry>
1446                 <para>metadata setattr</para>
1447               </entry>
1448             </row>
1449             <row>
1450               <entry>
1451                 <literal>
1452                    ost.OSS.ost
1453                 </literal>
1454               </entry>
1455               <entry>
1456                 <para>normal data</para>
1457               </entry>
1458             </row>
1459             <row>
1460               <entry>
1461                 <literal>
1462                    ost.OSS.ost_io
1463                 </literal>
1464               </entry>
1465               <entry>
1466                 <para>bulk data IO</para>
1467               </entry>
1468             </row>
1469             <row>
1470               <entry>
1471                 <literal>
1472                    ost.OSS.ost_create
1473                 </literal>
1474               </entry>
1475               <entry>
1476                 <para>OST object pre-creation service</para>
1477               </entry>
1478             </row>
1479             <row>
1480               <entry>
1481                 <literal>
1482                    ldlm.services.ldlm_canceld
1483                 </literal>
1484               </entry>
1485               <entry>
1486                 <para>DLM lock cancel</para>
1487               </entry>
1488             </row>
1489             <row>
1490               <entry>
1491                 <literal>
1492                    ldlm.services.ldlm_cbd
1493                 </literal>
1494               </entry>
1495               <entry>
1496                 <para>DLM lock grant</para>
1497               </entry>
1498             </row>
1499           </tbody>
1500         </tgroup>
1501       </informaltable>
1502       <itemizedlist>
1503         <listitem>
1504           <para>To temporarily set this tunable, run:</para>
1505           <screen># lctl {get,set}_param {service}.thread_{min,max,started} </screen>
1506         </listitem>
1507       </itemizedlist>
1508       <itemizedlist>
1509         <listitem>
1510           <para>To permanently set this tunable, run:</para>
1511           <screen># lctl conf_param {service}.thread_{min,max,started} </screen>
1512           <para>The following examples show how to set thread counts and get the number of running threads for the ost_io service.</para>
1513         </listitem>
1514       </itemizedlist>
1515       <itemizedlist>
1516         <listitem>
1517           <para>To get the number of running threads, run:</para>
1518           <screen># lctl get_param ost.OSS.ost_io.threads_started</screen>
1519           <para>The command output will be similar to this:</para>
1520           <screen>ost.OSS.ost_io.threads_started=128</screen>
1521         </listitem>
1522       </itemizedlist>
1523       <itemizedlist>
1524         <listitem>
1525           <para>To set the maximum number of threads (512), run:</para>
1526           <screen># lctl get_param ost.OSS.ost_io.threads_max</screen>
1527           <para>The command output will be:</para>
1528           <screen>ost.OSS.ost_io.threads_max=512</screen>
1529         </listitem>
1530       </itemizedlist>
1531       <itemizedlist>
1532         <listitem>
1533           <para> To set the maximum thread count to 256 instead of 512 (to avoid overloading the storage or for an array with requests), run:</para>
1534           <screen># lctl set_param ost.OSS.ost_io.threads_max=256</screen>
1535           <para>The command output will be:</para>
1536           <screen>ost.OSS.ost_io.threads_max=256</screen>
1537         </listitem>
1538       </itemizedlist>
1539       <itemizedlist>
1540         <listitem>
1541           <para> To check if the new <literal>threads_max</literal> setting is active, run:</para>
1542           <screen># lctl get_param ost.OSS.ost_io.threads_max</screen>
1543           <para>The command output will be similar to this:</para>
1544           <screen>ost.OSS.ost_io.threads_max=256</screen>
1545         </listitem>
1546       </itemizedlist>
1547       <note>
1548         <para>Currently, the maximum thread count setting is advisory because Lustre does not reduce the number of service threads in use, even if that number exceeds the <literal>threads_max</literal> value. Lustre does not stop service threads once they are started.</para>
1549       </note>
1550     </section>
1551   </section>
1552   <section xml:id="dbdoclet.50438271_83523">
1553     <title>31.3 Debug</title>
1554     <para><literal>
1555         <replaceable role="bold">/proc/sys/lnet/debug</replaceable>
1556       </literal></para>
1557     <para>By default, Lustre generates a detailed log of all operations to aid in debugging. The level of debugging can affect the performance or speed you achieve with Lustre. Therefore, it is useful to reduce this overhead by turning down the debug level<footnote>
1558         <para>This controls the level of Lustre debugging kept in the internal log buffer. It does not alter the level of debugging that goes to syslog.</para>
1559       </footnote> to improve performance. Raise the debug level when you need to collect the logs for debugging problems. The debugging mask can be set with &quot;symbolic names&quot; instead of the numerical values that were used in prior releases. The new symbolic format is shown in the examples below.</para>
1560     <note>
1561       <para>All of the commands below must be run as root; note the <literal>#</literal> nomenclature.</para>
1562     </note>
1563     <para>To verify the debug level used by examining the <literal>sysctl</literal> that controls debugging, run:</para>
1564     <screen># sysctl lnet.debug 
1565 lnet.debug = ioctl neterror warning error emerg ha config console</screen>
1566     <para>To turn off debugging (except for network error debugging), run this command on all concerned nodes:</para>
1567     <screen># sysctl -w lnet.debug=&quot;neterror&quot; 
1568 lnet.debug = neterror</screen>
1569     <para>To turn off debugging completely, run this command on all concerned nodes:</para>
1570     <screen># sysctl -w lnet.debug=0 
1571 lnet.debug = 0</screen>
1572     <para>To set an appropriate debug level for a production environment, run:</para>
1573     <screen># sysctl -w lnet.debug=&quot;warning dlmtrace error emerg ha rpctrace vfstrace&quot; 
1574 lnet.debug = warning dlmtrace error emerg ha rpctrace vfstrace</screen>
1575     <para>The flags above collect enough high-level information to aid debugging, but they do not cause any serious performance impact.</para>
1576     <para>To clear all flags and set new ones, run:</para>
1577     <screen># sysctl -w lnet.debug=&quot;warning&quot; 
1578 lnet.debug = warning</screen>
1579     <para>To add new flags to existing ones, prefix them with a &quot;<literal>+</literal>&quot;:</para>
1580     <screen># sysctl -w lnet.debug=&quot;+neterror +ha&quot; 
1581 lnet.debug = +neterror +ha
1582 # sysctl lnet.debug 
1583 lnet.debug = neterror warning ha</screen>
1584     <para>To remove flags, prefix them with a &quot;<literal>-</literal>&quot;:</para>
1585     <screen># sysctl -w lnet.debug=&quot;-ha&quot; 
1586 lnet.debug = -ha
1587 # sysctl lnet.debug 
1588 lnet.debug = neterror warning</screen>
1589     <para>You can verify and change the debug level using the <literal>/proc</literal> interface in Lustre. To use the flags with <literal>/proc</literal>, run:</para>
1590     <screen># cat /proc/sys/lnet/debug 
1591 neterror warning
1592 # echo &quot;+ha&quot; &gt; /proc/sys/lnet/debug 
1593 # cat /proc/sys/lnet/debug 
1594 neterror warning ha
1595 # echo &quot;-warning&quot; &gt; /proc/sys/lnet/debug
1596 # cat /proc/sys/lnet/debug 
1597 neterror ha</screen>
1598     <para><literal>
1599         <replaceable role="bold">/proc/sys/lnet/subsystem_debug</replaceable>
1600       </literal></para>
1601     <para>This controls the debug logs for subsystems (see <literal>S_*</literal> definitions).</para>
1602     <para><literal>
1603         <replaceable role="bold">/proc/sys/lnet/debug_path</replaceable>
1604       </literal></para>
1605     <para>This indicates the location where debugging symbols should be stored for <literal>gdb</literal>. The default is set to <literal>/r/tmp/lustre-log-localhost.localdomain</literal>.</para>
1606     <para>These values can also be set via <literal>sysctl -w lnet.debug={value}</literal></para>
1607     <note>
1608       <para>The above entries only exist when Lustre has already been loaded.</para>
1609     </note>
1610     <para><literal>
1611         <replaceable role="bold">/proc/sys/lnet/panic_on_lbug</replaceable>
1612       </literal></para>
1613     <para>This causes Lustre to call &apos;&apos;panic&apos;&apos; when it detects an internal problem (an <literal>LBUG</literal>); panic crashes the node. This is particularly useful when a kernel crash dump utility is configured. The crash dump is triggered when the internal inconsistency is detected by Lustre.</para>
1614     <para><literal>
1615         <replaceable role="bold">/proc/sys/lnet/upcall</replaceable>
1616       </literal></para>
1617     <para>This allows you to specify the path to the binary which will be invoked when an <literal>LBUG</literal> is encountered. This binary is called with four parameters. The first one is the string &apos;&apos;<literal>LBUG</literal>&apos;&apos;. The second one is the file where the <literal>LBUG</literal> occurred. The third one is the function name. The fourth one is the line number in the file.</para>
1618     <section remap="h3">
1619       <title>31.3.1 RPC Information for Other OBD Devices</title>
1620       <para>Some OBD devices maintain a count of the number of RPC events that they process. Sometimes these events are more specific to operations of the device, like llite, than actual raw RPC counts.</para>
1621       <screen>$ find /proc/fs/lustre/ -name stats
1622 /proc/fs/lustre/osc/lustre-OST0001-osc-ce63ca00/stats
1623 /proc/fs/lustre/osc/lustre-OST0000-osc-ce63ca00/stats
1624 /proc/fs/lustre/osc/lustre-OST0001-osc/stats
1625 /proc/fs/lustre/osc/lustre-OST0000-osc/stats
1626 /proc/fs/lustre/mdt/MDS/mds_readpage/stats
1627 /proc/fs/lustre/mdt/MDS/mds_setattr/stats
1628 /proc/fs/lustre/mdt/MDS/mds/stats
1629 /proc/fs/lustre/mds/lustre-MDT0000/exports/ab206805-0630-6647-8543-d24265c91a3d/stats
1630 /proc/fs/lustre/mds/lustre-MDT0000/exports/08ac6584-6c4a-3536-2c6d-b36cf9cbdaa0/stats
1631 /proc/fs/lustre/mds/lustre-MDT0000/stats
1632 /proc/fs/lustre/ldlm/services/ldlm_canceld/stats
1633 /proc/fs/lustre/ldlm/services/ldlm_cbd/stats
1634 /proc/fs/lustre/llite/lustre-ce63ca00/stats
1635 </screen>
1636       <section remap="h4">
1637         <title>31.3.1.1 Interpreting OST Statistics</title>
1638         <note>
1639           <para>See also <xref linkend="dbdoclet.50438219_84890"/> (llobdstat) and <xref linkend="dbdoclet.50438273_80593"/> (CollectL).</para>
1640         </note>
1641         <para>The OST .../stats files can be used to track client statistics (client activity) for each OST. It is possible to get a periodic dump of values from these file (for example, every 10 seconds), that show the RPC rates (similar to iostat) by using the <literal>llstat.pl</literal> tool:</para>
1642         <screen># llstat /proc/fs/lustre/osc/lustre-OST0000-osc/stats 
1643 /usr/bin/llstat: STATS on 09/14/07 /proc/fs/lustre/osc/lustre-OST0000-osc/stats on 192.168.10.34@tcp
1644 snapshot_time                      1189732762.835363
1645 ost_create                 1
1646 ost_get_info                       1
1647 ost_connect                        1
1648 ost_set_info                       1
1649 obd_ping                   212</screen>
1650         <para>To clear the statistics, give the <literal>-c</literal> option to <literal>llstat.pl</literal>. To specify how frequently the statistics should be cleared (in seconds), use an integer for the <literal>-i</literal> option. This is sample output with <literal>-c</literal> and <literal>-i10</literal> options used, providing statistics every 10s):</para>
1651         <screen>$ llstat -c -i10 /proc/fs/lustre/ost/OSS/ost_io/stats
1652  
1653 /usr/bin/llstat: STATS on 06/06/07 /proc/fs/lustre/ost/OSS/ost_io/ stats on 192.168.16.35@tcp
1654 snapshot_time                              1181074093.276072
1655  
1656 /proc/fs/lustre/ost/OSS/ost_io/stats @ 1181074103.284895
1657 Name               Cur.Count       Cur.Rate        #Events Unit            \last               min             avg             max             stddev
1658 req_waittime       8               0               8       [usec]          2078\               34              259.75          868             317.49
1659 req_qdepth 8               0               8       [reqs]          1\          0               0.12            1               0.35
1660 req_active 8               0               8       [reqs]          11\                 1               1.38            2               0.52
1661 reqbuf_avail       8               0               8       [bufs]          511\                63              63.88           64              0.35
1662 ost_write  8               0               8       [bytes]         1697677\    72914           212209.62       387579          91874.29
1663  
1664 /proc/fs/lustre/ost/OSS/ost_io/stats @ 1181074113.290180
1665 Name               Cur.Count       Cur.Rate        #Events Unit            \last               min             avg             max             stddev
1666 req_waittime       31              3               39      [usec]          30011\              34              822.79          12245           2047.71
1667 req_qdepth 31              3               39      [reqs]          0\          0               0.03            1               0.16
1668 req_active 31              3               39      [reqs]          58\         1               1.77            3               0.74
1669 reqbuf_avail       31              3               39      [bufs]          1977\               63              63.79           64              0.41
1670 ost_write  30              3               38      [bytes]         10284679\   15019           315325.16       910694          197776.51
1671  
1672 /proc/fs/lustre/ost/OSS/ost_io/stats @ 1181074123.325560
1673 Name               Cur.Count       Cur.Rate        #Events Unit            \last               min             avg             max             stddev
1674 req_waittime       21              2               60      [usec]          14970\              34              784.32          12245           1878.66
1675 req_qdepth 21              2               60      [reqs]          0\          0               0.02            1               0.13
1676 req_active 21              2               60      [reqs]          33\                 1               1.70            3               0.70
1677 reqbuf_avail       21              2               60      [bufs]          1341\               63              63.82           64              0.39
1678 ost_write  21              2               59      [bytes]         7648424\    15019           332725.08       910694          180397.87
1679 </screen>
1680         <para>Where:</para>
1681         <informaltable frame="all">
1682           <tgroup cols="2">
1683             <colspec colname="c1" colwidth="50*"/>
1684             <colspec colname="c2" colwidth="50*"/>
1685             <thead>
1686               <row>
1687                 <entry>
1688                   <para><emphasis role="bold">Parameter</emphasis></para>
1689                 </entry>
1690                 <entry>
1691                   <para><emphasis role="bold">Description</emphasis></para>
1692                 </entry>
1693               </row>
1694             </thead>
1695             <tbody>
1696               <row>
1697                 <entry>
1698                   <para> <literal>
1699                       <replaceable role="bold">Cur. Count</replaceable>
1700                     </literal></para>
1701                 </entry>
1702                 <entry>
1703                   <para>Number of events of each type sent in the last interval (in this example, 10s)</para>
1704                 </entry>
1705               </row>
1706               <row>
1707                 <entry>
1708                   <para> <literal>
1709                       <replaceable role="bold">Cur. Rate</replaceable>
1710                     </literal></para>
1711                 </entry>
1712                 <entry>
1713                   <para>Number of events per second in the last interval</para>
1714                 </entry>
1715               </row>
1716               <row>
1717                 <entry>
1718                   <para> <literal>
1719                       <replaceable role="bold">#Events</replaceable>
1720                     </literal></para>
1721                 </entry>
1722                 <entry>
1723                   <para>Total number of such events since the system started</para>
1724                 </entry>
1725               </row>
1726               <row>
1727                 <entry>
1728                   <para> <literal>
1729                       <replaceable role="bold">Unit</replaceable>
1730                     </literal></para>
1731                 </entry>
1732                 <entry>
1733                   <para>Unit of measurement for that statistic (microseconds, requests, buffers)</para>
1734                 </entry>
1735               </row>
1736               <row>
1737                 <entry>
1738                   <para> <literal>
1739                       <replaceable role="bold">last</replaceable>
1740                     </literal></para>
1741                 </entry>
1742                 <entry>
1743                   <para>Average rate of these events (in units/event) for the last interval during which they arrived. For instance, in the above mentioned case of <literal>ost_destroy</literal> it took an average of 736 microseconds per destroy for the 400 object destroys in the previous 10 seconds.</para>
1744                 </entry>
1745               </row>
1746               <row>
1747                 <entry>
1748                   <para> <literal>
1749                       <replaceable role="bold">min</replaceable>
1750                     </literal></para>
1751                 </entry>
1752                 <entry>
1753                   <para>Minimum rate (in units/events) since the service started</para>
1754                 </entry>
1755               </row>
1756               <row>
1757                 <entry>
1758                   <para> <literal>
1759                       <replaceable role="bold">avg</replaceable>
1760                     </literal></para>
1761                 </entry>
1762                 <entry>
1763                   <para>Average rate</para>
1764                 </entry>
1765               </row>
1766               <row>
1767                 <entry>
1768                   <para> <literal>
1769                       <replaceable role="bold">max</replaceable>
1770                     </literal></para>
1771                 </entry>
1772                 <entry>
1773                   <para>Maximum rate</para>
1774                 </entry>
1775               </row>
1776               <row>
1777                 <entry>
1778                   <para> <literal>
1779                       <replaceable role="bold">stddev</replaceable>
1780                     </literal></para>
1781                 </entry>
1782                 <entry>
1783                   <para>Standard deviation (not measured in all cases)</para>
1784                 </entry>
1785               </row>
1786             </tbody>
1787           </tgroup>
1788         </informaltable>
1789         <para>The events common to all services are:</para>
1790         <informaltable frame="all">
1791           <tgroup cols="2">
1792             <colspec colname="c1" colwidth="50*"/>
1793             <colspec colname="c2" colwidth="50*"/>
1794             <thead>
1795               <row>
1796                 <entry>
1797                   <para><emphasis role="bold">Parameter</emphasis></para>
1798                 </entry>
1799                 <entry>
1800                   <para><emphasis role="bold">Description</emphasis></para>
1801                 </entry>
1802               </row>
1803             </thead>
1804             <tbody>
1805               <row>
1806                 <entry>
1807                   <para> <literal>
1808                       <replaceable role="bold">req_waittime</replaceable>
1809                     </literal></para>
1810                 </entry>
1811                 <entry>
1812                   <para>Amount of time a request waited in the queue before being handled by an available server thread.</para>
1813                 </entry>
1814               </row>
1815               <row>
1816                 <entry>
1817                   <para> <literal>
1818                       <replaceable role="bold">req_qdepth</replaceable>
1819                     </literal></para>
1820                 </entry>
1821                 <entry>
1822                   <para>Number of requests waiting to be handled in the queue for this service.</para>
1823                 </entry>
1824               </row>
1825               <row>
1826                 <entry>
1827                   <para> <literal>
1828                       <replaceable role="bold">req_active</replaceable>
1829                     </literal></para>
1830                 </entry>
1831                 <entry>
1832                   <para>Number of requests currently being handled.</para>
1833                 </entry>
1834               </row>
1835               <row>
1836                 <entry>
1837                   <para> <literal>
1838                       <replaceable role="bold">reqbuf_avail</replaceable>
1839                     </literal></para>
1840                 </entry>
1841                 <entry>
1842                   <para>Number of unsolicited lnet request buffers for this service.</para>
1843                 </entry>
1844               </row>
1845             </tbody>
1846           </tgroup>
1847         </informaltable>
1848         <para>Some service-specific events of interest are:</para>
1849         <informaltable frame="all">
1850           <tgroup cols="2">
1851             <colspec colname="c1" colwidth="50*"/>
1852             <colspec colname="c2" colwidth="50*"/>
1853             <thead>
1854               <row>
1855                 <entry>
1856                   <para><emphasis role="bold">Parameter</emphasis></para>
1857                 </entry>
1858                 <entry>
1859                   <para><emphasis role="bold">Description</emphasis></para>
1860                 </entry>
1861               </row>
1862             </thead>
1863             <tbody>
1864               <row>
1865                 <entry>
1866                   <para> <literal>
1867                       <replaceable role="bold">ldlm_enqueue</replaceable>
1868                     </literal></para>
1869                 </entry>
1870                 <entry>
1871                   <para>Time it takes to enqueue a lock (this includes file open on the MDS)</para>
1872                 </entry>
1873               </row>
1874               <row>
1875                 <entry>
1876                   <para> <literal>
1877                       <replaceable role="bold">mds_reint</replaceable>
1878                     </literal></para>
1879                 </entry>
1880                 <entry>
1881                   <para>Time it takes to process an MDS modification record (includes create, <literal>mkdir</literal>, <literal>unlink</literal>, <literal>rename</literal> and <literal>setattr</literal>)</para>
1882                 </entry>
1883               </row>
1884             </tbody>
1885           </tgroup>
1886         </informaltable>
1887       </section>
1888       <section remap="h4">
1889         <title>31.3.1.2 Interpreting MDT Statistics</title>
1890         <note>
1891           <para>See also <xref linkend="dbdoclet.50438219_84890"/> (llobdstat) and <xref linkend="dbdoclet.50438273_80593"/> (CollectL).</para>
1892         </note>
1893         <para>The MDT .../stats files can be used to track MDT statistics for the MDS. Here is sample output for an MDT stats file:</para>
1894         <screen># cat /proc/fs/lustre/mds/*-MDT0000/stats 
1895 snapshot_time                              1244832003.676892 secs.usecs 
1896 open                                       2 samples [reqs] 
1897 close                                      1 samples [reqs] 
1898 getxattr                           3 samples [reqs] 
1899 process_config                             1 samples [reqs] 
1900 connect                                    2 samples [reqs] 
1901 disconnect                         2 samples [reqs] 
1902 statfs                                     3 samples [reqs] 
1903 setattr                                    1 samples [reqs] 
1904 getattr                                    3 samples [reqs] 
1905 llog_init                          6 samples [reqs] 
1906 notify                                     16 samples [reqs]
1907 </screen>
1908       </section>
1909     </section>
1910   </section>
1911 </chapter>