Whamcloud - gitweb
LUDOC-382 Tag lfsck_query as lustre 2.9
[doc/manual.git] / ManagingFileSystemIO.xml
1 <?xml version='1.0' encoding='utf-8'?>
2 <chapter xmlns="http://docbook.org/ns/docbook"
3 xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US"
4 xml:id="managingfilesystemio">
5   <title xml:id="managingfilesystemio.title">Managing the File System and
6   I/O</title>
7   <section xml:id="dbdoclet.50438211_17536">
8     <title>
9     <indexterm>
10       <primary>I/O</primary>
11     </indexterm>
12     <indexterm>
13       <primary>I/O</primary>
14       <secondary>full OSTs</secondary>
15     </indexterm>Handling Full OSTs</title>
16     <para>Sometimes a Lustre file system becomes unbalanced, often due to
17     incorrectly-specified stripe settings, or when very large files are created
18     that are not striped over all of the OSTs. Lustre will automatically avoid
19     allocating new files on OSTs that are full. If an OST is completely full and
20     more data is written to files already located on that OST, an error occurs.
21     The procedures below describe how to handle a full OST.</para>
22     <para>The MDS will normally handle space balancing automatically at file
23     creation time, and this procedure is normally not needed, but manual data
24     migration may be desirable in some cases (e.g. creating very large files
25     that would consume more than the total free space of the full OSTs).</para>
26     <section remap="h3">
27       <title>
28       <indexterm>
29         <primary>I/O</primary>
30         <secondary>OST space usage</secondary>
31       </indexterm>Checking OST Space Usage</title>
32       <para>The example below shows an unbalanced file system:</para>
33       <screen>
34 client# lfs df -h
35 UUID                       bytes           Used            Available       \
36 Use%            Mounted on
37 testfs-MDT0000_UUID        4.4G            214.5M          3.9G            \
38 4%              /mnt/testfs[MDT:0]
39 testfs-OST0000_UUID        2.0G            751.3M          1.1G            \
40 37%             /mnt/testfs[OST:0]
41 testfs-OST0001_UUID        2.0G            755.3M          1.1G            \
42 37%             /mnt/testfs[OST:1]
43 testfs-OST0002_UUID        2.0G            1.7G            155.1M          \
44 86%             /mnt/testfs[OST:2] ****
45 testfs-OST0003_UUID        2.0G            751.3M          1.1G            \
46 37%             /mnt/testfs[OST:3]
47 testfs-OST0004_UUID        2.0G            747.3M          1.1G            \
48 37%             /mnt/testfs[OST:4]
49 testfs-OST0005_UUID        2.0G            743.3M          1.1G            \
50 36%             /mnt/testfs[OST:5]
51  
52 filesystem summary:        11.8G           5.4G            5.8G            \
53 45%             /mnt/testfs
54 </screen>
55       <para>In this case, OST0002 is almost full and when an attempt is made to
56       write additional information to the file system (even with uniform
57       striping over all the OSTs), the write command fails as follows:</para>
58       <screen>
59 client# lfs setstripe /mnt/testfs 4M 0 -1
60 client# dd if=/dev/zero of=/mnt/testfs/test_3 bs=10M count=100
61 dd: writing '/mnt/testfs/test_3': No space left on device
62 98+0 records in
63 97+0 records out
64 1017192448 bytes (1.0 GB) copied, 23.2411 seconds, 43.8 MB/s
65 </screen>
66     </section>
67     <section remap="h3">
68       <title>
69       <indexterm>
70         <primary>I/O</primary>
71         <secondary>disabling OST creates</secondary>
72       </indexterm>Disabling creates on a Full OST</title>
73       <para>To avoid running out of space in the file system, if the OST usage
74       is imbalanced and one or more OSTs are close to being full while there
75       are others that have a lot of space, the MDS will typically avoid file
76       creation on the full OST(s) automatically.  The full OSTs may optionally
77       be deactivated manually on the MDS to ensure the MDS will not allocate
78       new objects there.</para>
79       <orderedlist>
80         <listitem>
81           <para>Log into the MDS server and use the <literal>lctl</literal>
82           command to stop new object creation on the full OST(s):
83           </para>
84           <screen>
85 mds# lctl set_param osp.<replaceable>fsname</replaceable>-OST<replaceable>nnnn</replaceable>*.max_create_count=0
86 </screen>
87         </listitem>
88       </orderedlist>
89       <para>When new files are created in the file system, they will only use
90       the remaining OSTs. Either manual space rebalancing can be done by
91       migrating data to other OSTs, as shown in the next section, or normal
92       file deletion and creation can passively rebalance the space usage.</para>
93     </section>
94     <section remap="h3">
95       <title>
96       <indexterm>
97         <primary>I/O</primary>
98         <secondary>migrating data</secondary>
99       </indexterm>
100       <indexterm>
101         <primary>maintenance</primary>
102         <secondary>full OSTs</secondary>
103       </indexterm>Migrating Data within a File System</title>
104
105       <para>If there is a need to move the file data from the current
106       OST(s) to new OST(s), the data must be migrated (copied)
107       to the new location.  The simplest way to do this is to use the
108       <literal>lfs_migrate</literal> command, as described in
109       <xref linkend="dbdoclet.adding_new_ost" />.</para>
110     </section>
111     <section remap="h3">
112       <title>
113       <indexterm>
114         <primary>I/O</primary>
115         <secondary>bringing OST online</secondary>
116       </indexterm>
117       <indexterm>
118         <primary>maintenance</primary>
119         <secondary>bringing OST online</secondary>
120       </indexterm>Returning an Inactive OST Back Online</title>
121       <para>Once the full OST(s) no longer are severely imbalanced, due
122       to either active or passive data redistribution, they should be
123       reactivated so they will again have new files allocated on them.</para>
124       <screen>
125 [mds]# lctl set_param osp.testfs-OST0002.max_create_count=20000
126 </screen>
127     </section>
128     <section remap="h3">
129       <title><indexterm>
130         <primary>migrating metadata</primary>
131       </indexterm>Migrating Metadata within a Filesystem</title>
132       <section remap="h3" condition='l28'>
133         <title><indexterm>
134           <primary>migrating metadata</primary>
135         </indexterm>Whole Directory Migration</title>
136         <para>Lustre software version 2.8 includes a feature
137           to migrate metadata (directories and inodes therein) between MDTs.
138           This migration can only be performed on whole directories. Striped
139           directories are not supported until Lustre 2.12. For example, to
140           migrate the contents of the <literal>/testfs/remotedir</literal>
141           directory from the MDT where it currently is located to MDT0000 to
142           allow that MDT to be removed, the sequence of commands is as follows:
143         </para>
144         <screen>$ cd /testfs
145 $ lfs getdirstripe -m ./remotedir <lineannotation>which MDT is dir on?</lineannotation>
146 1
147 $ touch ./remotedir/file.{1,2,3}.txt<lineannotation>create test files</lineannotation>
148 $ lfs getstripe -m ./remotedir/file.*.txt<lineannotation>check files are on MDT0001</lineannotation>
149 1
150 1
151 1
152 $ lfs migrate -m 0 ./remotedir <lineannotation>migrate testremote to MDT0000</lineannotation>
153 $ lfs getdirstripe -m ./remotedir <lineannotation>which MDT is dir on now?</lineannotation>
154 0
155 $ lfs getstripe -m ./remotedir/file.*.txt<lineannotation>check files are on MDT0000</lineannotation>
156 0
157 0
158 0</screen>
159         <para>For more information, see <literal>man lfs-migrate</literal>.
160         </para>
161          <warning><para>During migration each file receives a new identifier
162            (FID). As a consequence, the file will report a new inode number to
163            userspace applications. Some system tools (for example, backup and
164            archiving tools, NFS, Samba) that identify files by inode number may
165            consider the migrated files to be new, even though the contents are
166            unchanged.  If a Lustre system is re-exporting to NFS, the migrated
167            files may become inaccessible during and after migration if the
168            client or server are caching a stale file handle with the old FID.
169            Restarting the NFS service will flush the local file handle cache,
170            but clients may also need to be restarted as they may cache stale
171            file handles as well.
172         </para></warning>
173       </section>
174       <section remap="h3" condition='l2C'>
175         <title><indexterm>
176           <primary>migrating metadata</primary>
177         </indexterm>Striped Directory Migration</title>
178         <para>Lustre 2.8 included a feature to migrate metadata (directories
179           and inodes therein) between MDTs, however it did not support migration
180           of striped directories, or changing the stripe count of an existing
181           directory. Lustre 2.12 adds support for migrating and restriping
182           directories. The <literal>lfs migrate -m</literal> command can only
183           only be performed on whole directories, though it will migrate both
184           the specified directory and its sub-entries recursively.
185           For example, to migrate the contents of a large directory
186           <literal>/testfs/largedir</literal> from its current location on
187           MDT0000 to MDT0001 and MDT0003, run the following command:</para>
188           <screen>$ lfs migrate -m 1,3 /testfs/largedir</screen>
189         <para>Metadata migration will migrate file dirent and inode to other
190           MDTs, but it won't touch file data.  During migration, directory and
191           its sub-files can be accessed like normal ones, though the same
192           warning above applies to tools that depend on the file inode number.
193           Migration may fail for various reasons such as MDS restart, or disk
194           full.  In those cases, some of the sub-files may have been migrated to
195           the new MDTs, while others are still on the original MDT.  The files
196           can be accessed normally. The same <literal>lfs migrate -m</literal>
197           command should be executed again when these issues are fixed to finish
198           this migration.  However, you cannot abort a failed migration, or
199           migrate to different MDTs from previous migration command.</para>
200       </section>
201     </section>
202   </section>
203   <section xml:id="dbdoclet.50438211_75549">
204     <title>
205     <indexterm>
206       <primary>I/O</primary>
207       <secondary>pools</secondary>
208     </indexterm>
209     <indexterm>
210       <primary>maintenance</primary>
211       <secondary>pools</secondary>
212     </indexterm>
213     <indexterm>
214       <primary>pools</primary>
215     </indexterm>Creating and Managing OST Pools</title>
216     <para>The OST pools feature enables users to group OSTs together to make
217     object placement more flexible. A 'pool' is the name associated with an
218     arbitrary subset of OSTs in a Lustre cluster.</para>
219     <para>OST pools follow these rules:</para>
220     <itemizedlist>
221       <listitem>
222         <para>An OST can be a member of multiple pools.</para>
223       </listitem>
224       <listitem>
225         <para>No ordering of OSTs in a pool is defined or implied.</para>
226       </listitem>
227       <listitem>
228         <para>Stripe allocation within a pool follows the same rules as the
229         normal stripe allocator.</para>
230       </listitem>
231       <listitem>
232         <para>OST membership in a pool is flexible, and can change over
233         time.</para>
234       </listitem>
235     </itemizedlist>
236     <para>When an OST pool is defined, it can be used to allocate files. When
237     file or directory striping is set to a pool, only OSTs in the pool are
238     candidates for striping. If a stripe_index is specified which refers to an
239     OST that is not a member of the pool, an error is returned.</para>
240     <para>OST pools are used only at file creation. If the definition of a pool
241     changes (an OST is added or removed or the pool is destroyed),
242     already-created files are not affected.</para>
243     <note>
244       <para>An error (
245       <literal>EINVAL</literal>) results if you create a file using an empty
246       pool.</para>
247     </note>
248     <note>
249       <para>If a directory has pool striping set and the pool is subsequently
250       removed, the new files created in this directory have the (non-pool)
251       default striping pattern for that directory applied and no error is
252       returned.</para>
253     </note>
254     <section remap="h3">
255       <title>Working with OST Pools</title>
256       <para>OST pools are defined in the configuration log on the MGS. Use the
257       lctl command to:</para>
258       <itemizedlist>
259         <listitem>
260           <para>Create/destroy a pool</para>
261         </listitem>
262         <listitem>
263           <para>Add/remove OSTs in a pool</para>
264         </listitem>
265         <listitem>
266           <para>List pools and OSTs in a specific pool</para>
267         </listitem>
268       </itemizedlist>
269       <para>The lctl command MUST be run on the MGS. Another requirement for
270       managing OST pools is to either have the MDT and MGS on the same node or
271       have a Lustre client mounted on the MGS node, if it is separate from the
272       MDS. This is needed to validate the pool commands being run are
273       correct.</para>
274       <caution>
275         <para>Running the 
276         <literal>writeconf</literal> command on the MDS erases all pools
277         information (as well as any other parameters set using 
278         <literal>lctl conf_param</literal>). We recommend that the pools
279         definitions (and 
280         <literal>conf_param</literal> settings) be executed using a script, so
281         they can be reproduced easily after a 
282         <literal>writeconf</literal> is performed.</para>
283       </caution>
284       <para>To create a new pool, run:</para>
285       <screen>
286 mgs# lctl pool_new 
287 <replaceable>fsname</replaceable>.
288 <replaceable>poolname</replaceable>
289 </screen>
290       <note>
291         <para>The pool name is an ASCII string up to 15 characters.</para>
292       </note>
293       <para>To add the named OST to a pool, run:</para>
294       <screen>
295 mgs# lctl pool_add 
296 <replaceable>fsname</replaceable>.
297 <replaceable>poolname</replaceable> 
298 <replaceable>ost_list</replaceable>
299 </screen>
300       <para>Where:</para>
301       <itemizedlist>
302         <listitem>
303           <para>
304             <literal>
305             <replaceable>ost_list</replaceable>is 
306             <replaceable>fsname</replaceable>-OST
307             <replaceable>index_range</replaceable></literal>
308           </para>
309         </listitem>
310         <listitem>
311           <para>
312           <literal>
313           <replaceable>index_range</replaceable>is 
314           <replaceable>ost_index_start</replaceable>-
315           <replaceable>ost_index_end[,index_range]</replaceable></literal> or 
316           <literal>
317           <replaceable>ost_index_start</replaceable>-
318           <replaceable>ost_index_end/step</replaceable></literal></para>
319         </listitem>
320       </itemizedlist>
321       <para>If the leading 
322       <literal>
323         <replaceable>fsname</replaceable>
324       </literal> and/or ending 
325       <literal>_UUID</literal> are missing, they are automatically added.</para>
326       <para>For example, to add even-numbered OSTs to 
327       <literal>pool1</literal> on file system 
328       <literal>testfs</literal>, run a single command (
329       <literal>pool_add</literal>) to add many OSTs to the pool at one
330       time:</para>
331       <para>
332         <screen>
333 lctl pool_add testfs.pool1 OST[0-10/2]
334 </screen>
335       </para>
336       <note>
337         <para>Each time an OST is added to a pool, a new 
338         <literal>llog</literal> configuration record is created. For
339         convenience, you can run a single command.</para>
340       </note>
341       <para>To remove a named OST from a pool, run:</para>
342       <screen>
343 mgs# lctl pool_remove 
344 <replaceable>fsname</replaceable>.
345 <replaceable>poolname</replaceable> 
346 <replaceable>ost_list</replaceable>
347 </screen>
348       <para>To destroy a pool, run:</para>
349       <screen>
350 mgs# lctl pool_destroy 
351 <replaceable>fsname</replaceable>.
352 <replaceable>poolname</replaceable>
353 </screen>
354       <note>
355         <para>All OSTs must be removed from a pool before it can be
356         destroyed.</para>
357       </note>
358       <para>To list pools in the named file system, run:</para>
359       <screen>
360 mgs# lctl pool_list 
361 <replaceable>fsname|pathname</replaceable>
362 </screen>
363       <para>To list OSTs in a named pool, run:</para>
364       <screen>
365 lctl pool_list 
366 <replaceable>fsname</replaceable>.
367 <replaceable>poolname</replaceable>
368 </screen>
369       <section remap="h4">
370         <title>Using the lfs Command with OST Pools</title>
371         <para>Several lfs commands can be run with OST pools. Use the 
372         <literal>lfs setstripe</literal> command to associate a directory with
373         an OST pool. This causes all new regular files and directories in the
374         directory to be created in the pool. The lfs command can be used to
375         list pools in a file system and OSTs in a named pool.</para>
376         <para>To associate a directory with a pool, so all new files and
377         directories will be created in the pool, run:</para>
378         <screen>
379 client# lfs setstripe --pool|-p pool_name 
380 <replaceable>filename|dirname</replaceable> 
381 </screen>
382         <para>To set striping patterns, run:</para>
383         <screen>
384 client# lfs setstripe [--size|-s stripe_size] [--offset|-o start_ost]
385            [--count|-c stripe_count] [--pool|-p pool_name]
386            
387 <replaceable>dir|filename</replaceable>
388 </screen>
389         <note>
390           <para>If you specify striping with an invalid pool name, because the
391           pool does not exist or the pool name was mistyped, 
392           <literal>lfs setstripe</literal> returns an error. Run 
393           <literal>lfs pool_list</literal> to make sure the pool exists and the
394           pool name is entered correctly.</para>
395         </note>
396         <note>
397           <para>The 
398           <literal>--pool</literal> option for lfs setstripe is compatible with
399           other modifiers. For example, you can set striping on a directory to
400           use an explicit starting index.</para>
401         </note>
402       </section>
403     </section>
404     <section remap="h3">
405       <title>
406       <indexterm>
407         <primary>pools</primary>
408         <secondary>usage tips</secondary>
409       </indexterm>Tips for Using OST Pools</title>
410       <para>Here are several suggestions for using OST pools.</para>
411       <itemizedlist>
412         <listitem>
413           <para>A directory or file can be given an extended attribute (EA),
414           that restricts striping to a pool.</para>
415         </listitem>
416         <listitem>
417           <para>Pools can be used to group OSTs with the same technology or
418           performance (slower or faster), or that are preferred for certain
419           jobs. Examples are SATA OSTs versus SAS OSTs or remote OSTs versus
420           local OSTs.</para>
421         </listitem>
422         <listitem>
423           <para>A file created in an OST pool tracks the pool by keeping the
424           pool name in the file LOV EA.</para>
425         </listitem>
426       </itemizedlist>
427     </section>
428   </section>
429   <section xml:id="dbdoclet.50438211_11204">
430     <title>
431     <indexterm>
432       <primary>I/O</primary>
433       <secondary>adding an OST</secondary>
434     </indexterm>Adding an OST to a Lustre File System</title>
435     <para>To add an OST to existing Lustre file system:</para>
436     <orderedlist>
437       <listitem>
438         <para>Add a new OST by passing on the following commands, run:</para>
439         <screen>
440 oss# mkfs.lustre --fsname=testfs --mgsnode=mds16@tcp0 --ost --index=12 /dev/sda
441 oss# mkdir -p /mnt/testfs/ost12
442 oss# mount -t lustre /dev/sda /mnt/testfs/ost12
443 </screen>
444       </listitem>
445       <listitem>
446         <para>Migrate the data (possibly).</para>
447         <para>The file system is quite unbalanced when new empty OSTs are
448         added. New file creations are automatically balanced. If this is a
449         scratch file system or files are pruned at a regular interval, then no
450         further work may be needed. Files existing prior to the expansion can
451         be rebalanced with an in-place copy, which can be done with a simple
452         script.</para>
453         <para>The basic method is to copy existing files to a temporary file,
454         then move the temp file over the old one. This should not be attempted
455         with files which are currently being written to by users or
456         applications. This operation redistributes the stripes over the entire
457         set of OSTs.</para>
458         <para>A very clever migration script would do the following:</para>
459         <itemizedlist>
460           <listitem>
461             <para>Examine the current distribution of data.</para>
462           </listitem>
463           <listitem>
464             <para>Calculate how much data should move from each full OST to the
465             empty ones.</para>
466           </listitem>
467           <listitem>
468             <para>Search for files on a given full OST (using 
469             <literal>lfs getstripe</literal>).</para>
470           </listitem>
471           <listitem>
472             <para>Force the new destination OST (using 
473             <literal>lfs setstripe</literal>).</para>
474           </listitem>
475           <listitem>
476             <para>Copy only enough files to address the imbalance.</para>
477           </listitem>
478         </itemizedlist>
479       </listitem>
480     </orderedlist>
481     <para>If a Lustre file system administrator wants to explore this approach
482     further, per-OST disk-usage statistics can be found under 
483     <literal>/proc/fs/lustre/osc/*/rpc_stats</literal></para>
484   </section>
485   <section xml:id="dbdoclet.50438211_80295">
486     <title>
487     <indexterm>
488       <primary>I/O</primary>
489       <secondary>direct</secondary>
490     </indexterm>Performing Direct I/O</title>
491     <para>The Lustre software supports the 
492     <literal>O_DIRECT</literal> flag to open.</para>
493     <para>Applications using the 
494     <literal>read()</literal> and 
495     <literal>write()</literal> calls must supply buffers aligned on a page
496     boundary (usually 4 K). If the alignment is not correct, the call returns 
497     <literal>-EINVAL</literal>. Direct I/O may help performance in cases where
498     the client is doing a large amount of I/O and is CPU-bound (CPU utilization
499     100%).</para>
500     <section remap="h3">
501       <title>Making File System Objects Immutable</title>
502       <para>An immutable file or directory is one that cannot be modified,
503       renamed or removed. To do this:</para>
504       <screen>
505 chattr +i 
506 <replaceable>file</replaceable>
507 </screen>
508       <para>To remove this flag, use 
509       <literal>chattr -i</literal></para>
510     </section>
511   </section>
512   <section xml:id="dbdoclet.50438211_61024">
513     <title>Other I/O Options</title>
514     <para>This section describes other I/O options, including checksums, and
515     the ptlrpcd thread pool.</para>
516     <section remap="h3">
517       <title>Lustre Checksums</title>
518       <para>To guard against network data corruption, a Lustre client can
519       perform two types of data checksums: in-memory (for data in client
520       memory) and wire (for data sent over the network). For each checksum
521       type, a 32-bit checksum of the data read or written on both the client
522       and server is computed, to ensure that the data has not been corrupted in
523       transit over the network. The 
524       <literal>ldiskfs</literal> backing file system does NOT do any persistent
525       checksumming, so it does not detect corruption of data in the OST file
526       system.</para>
527       <para>The checksumming feature is enabled, by default, on individual
528       client nodes. If the client or OST detects a checksum mismatch, then an
529       error is logged in the syslog of the form:</para>
530       <screen>
531 LustreError: BAD WRITE CHECKSUM: changed in transit before arrival at OST: \
532 from 192.168.1.1@tcp inum 8991479/2386814769 object 1127239/0 extent [10240\
533 0-106495]
534 </screen>
535       <para>If this happens, the client will re-read or re-write the affected
536       data up to five times to get a good copy of the data over the network. If
537       it is still not possible, then an I/O error is returned to the
538       application.</para>
539       <para>To enable both types of checksums (in-memory and wire), run:</para>
540       <screen>
541 lctl set_param llite.*.checksum_pages=1
542 </screen>
543       <para>To disable both types of checksums (in-memory and wire),
544       run:</para>
545       <screen>
546 lctl set_param llite.*.checksum_pages=0
547 </screen>
548       <para>To check the status of a wire checksum, run:</para>
549       <screen>
550 lctl get_param osc.*.checksums
551 </screen>
552       <section remap="h4">
553         <title>Changing Checksum Algorithms</title>
554         <para>By default, the Lustre software uses the adler32 checksum
555         algorithm, because it is robust and has a lower impact on performance
556         than crc32. The Lustre file system administrator can change the
557         checksum algorithm via 
558         <literal>lctl get_param</literal>, depending on what is supported in
559         the kernel.</para>
560         <para>To check which checksum algorithm is being used by the Lustre
561         software, run:</para>
562         <screen>
563 $ lctl get_param osc.*.checksum_type
564 </screen>
565         <para>To change the wire checksum algorithm, run:</para>
566         <screen>
567 $ lctl set_param osc.*.checksum_type=
568 <replaceable>algorithm</replaceable>
569 </screen>
570         <note>
571           <para>The in-memory checksum always uses the adler32 algorithm, if
572           available, and only falls back to crc32 if adler32 cannot be
573           used.</para>
574         </note>
575         <para>In the following example, the 
576         <literal>lctl get_param</literal> command is used to determine that the
577         Lustre software is using the adler32 checksum algorithm. Then the 
578         <literal>lctl set_param</literal> command is used to change the checksum
579         algorithm to crc32. A second 
580         <literal>lctl get_param</literal> command confirms that the crc32
581         checksum algorithm is now in use.</para>
582         <screen>
583 $ lctl get_param osc.*.checksum_type
584 osc.testfs-OST0000-osc-ffff81012b2c48e0.checksum_type=crc32 [adler]
585 $ lctl set_param osc.*.checksum_type=crc32
586 osc.testfs-OST0000-osc-ffff81012b2c48e0.checksum_type=crc32
587 $ lctl get_param osc.*.checksum_type
588 osc.testfs-OST0000-osc-ffff81012b2c48e0.checksum_type=[crc32] adler
589 </screen>
590       </section>
591     </section>
592     <section remap="h3">
593       <title>Ptlrpc Thread Pool</title>
594       <para>Releases prior to Lustre software release 2.2 used two portal RPC
595       daemons for each client/server pair. One daemon handled all synchronous
596       IO requests, and the second daemon handled all asynchronous (non-IO)
597       RPCs. The increasing use of large SMP nodes for Lustre servers exposed
598       some scaling issues. The lack of threads for large SMP nodes resulted in
599       cases where a single CPU would be 100% utilized and other CPUs would be
600       relativity idle. This is especially noticeable when a single client
601       traverses a large directory.</para>
602       <para>Lustre software release 2.2.x implements a ptlrpc thread pool, so
603       that multiple threads can be created to serve asynchronous RPC requests.
604       The number of threads spawned is controlled at module load time using
605       module options. By default one thread is spawned per CPU, with a minimum
606       of 2 threads spawned irrespective of module options.</para>
607       <para>One of the issues with thread operations is the cost of moving a
608       thread context from one CPU to another with the resulting loss of CPU
609       cache warmth. To reduce this cost, ptlrpc threads can be bound to a CPU.
610       However, if the CPUs are busy, a bound thread may not be able to respond
611       quickly, as the bound CPU may be busy with other tasks and the thread
612       must wait to schedule.</para>
613       <para>Because of these considerations, the pool of ptlrpc threads can be
614       a mixture of bound and unbound threads. The system operator can balance
615       the thread mixture based on system size and workload.</para>
616       <section>
617         <title>ptlrpcd parameters</title>
618         <para>These parameters should be set in 
619         <literal>/etc/modprobe.conf</literal> or in the 
620         <literal>etc/modprobe.d</literal> directory, as options for the ptlrpc
621         module. 
622         <screen>
623 options ptlrpcd max_ptlrpcds=XXX
624 </screen></para>
625         <para>Sets the number of ptlrpcd threads created at module load time.
626         The default if not specified is one thread per CPU, including
627         hyper-threaded CPUs. The lower bound is 2 (old prlrpcd behaviour) 
628         <screen>
629 options ptlrpcd ptlrpcd_bind_policy=[1-4]
630 </screen></para>
631         <para>Controls the binding of threads to CPUs. There are four policy
632         options.</para>
633         <itemizedlist>
634           <listitem>
635             <para>
636             <literal role="bold">
637             PDB_POLICY_NONE</literal>(ptlrpcd_bind_policy=1) All threads are
638             unbound.</para>
639           </listitem>
640           <listitem>
641             <para>
642             <literal role="bold">
643             PDB_POLICY_FULL</literal>(ptlrpcd_bind_policy=2) All threads
644             attempt to bind to a CPU.</para>
645           </listitem>
646           <listitem>
647             <para>
648             <literal role="bold">
649             PDB_POLICY_PAIR</literal>(ptlrpcd_bind_policy=3) This is the
650             default policy. Threads are allocated as a bound/unbound pair. Each
651             thread (bound or free) has a partner thread. The partnering is used
652             by the ptlrpcd load policy, which determines how threads are
653             allocated to CPUs.</para>
654           </listitem>
655           <listitem>
656             <para>
657             <literal role="bold">
658             PDB_POLICY_NEIGHBOR</literal>(ptlrpcd_bind_policy=4) Threads are
659             allocated as a bound/unbound pair. Each thread (bound or free) has
660             two partner threads.</para>
661           </listitem>
662         </itemizedlist>
663       </section>
664     </section>
665   </section>
666 </chapter>