Whamcloud - gitweb
LUDOC-65 bugfix: Added workaround needed for setting quotas.
[doc/manual.git] / ConfiguringQuotas.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="configuringquotas">
3   <title xml:id="configuringquotas.title">Configuring and Managing Quotas</title>
4   <para>This chapter describes how to configure quotas and includes the following sections:</para>
5   <itemizedlist>
6     <listitem>
7       <para><xref linkend="quota_configuring"/></para>
8     </listitem>
9     <listitem>
10       <para><xref linkend="enabling_disk_quotas"/></para>
11     </listitem>
12     <listitem>
13       <para><xref linkend="quota_administration"/></para>
14     </listitem>
15     <listitem>
16       <para><xref linkend="quota_allocation"/></para>
17     </listitem>
18     <listitem>
19       <para><xref linkend="quota_interoperability"/></para>
20     </listitem>
21     <listitem>
22       <para><xref linkend="granted_cache_and_quota_limits"/></para>
23     </listitem>
24     <listitem>
25       <para><xref linkend="lustre_quota_statistics"/></para>
26     </listitem>
27   </itemizedlist>
28   <section xml:id="quota_configuring">
29       <title>
30           <indexterm><primary>Quotas</primary><secondary>configuring</secondary></indexterm>Working with Quotas</title>
31     <para>Quotas allow a system administrator to limit the amount of disk space a user or group can use. Quotas are set by root, and can be specified for individual users and/or groups. Before a file is written to a partition where quotas are set, the quota of the creator&apos;s group is checked. If a quota exists, then the file size counts towards the group&apos;s quota. If no quota exists, then the owner&apos;s user quota is checked before the file is written. Similarly, inode usage for specific functions can be controlled if a user over-uses the allocated space.</para>
32     <para>Lustre quota enforcement differs from standard Linux quota enforcement in several ways:</para>
33     <itemizedlist>
34       <listitem>
35         <para>Quotas are administered via the <literal>lfs</literal> and <literal>lctl</literal> commands (post-mount).</para>
36       </listitem>
37       <listitem>
38         <para>Quotas are distributed (as Lustre is a distributed file system), which has several ramifications.</para>
39       </listitem>
40       <listitem>
41         <para>Quotas are allocated and consumed in a quantized fashion.</para>
42       </listitem>
43       <listitem>
44       <para>Client does not set the <literal>usrquota</literal> or <literal>grpquota</literal> options to mount. As of Lustre 2.4, space accounting is always enabled by default and quota enforcement can be enabled/disabled on a per-filesystem basis with <literal>lctl conf_param</literal>. It is worth noting that both <literal>lfs quotaon</literal> and <literal>quota_type</literal> are deprecated as of Lustre 2.4.0.</para>
45       </listitem>
46     </itemizedlist>
47     <caution>
48       <para>Although quotas are available in Lustre, root quotas are NOT enforced.</para>
49       <para><literal>lfs setquota -u root</literal> (limits are not enforced)</para>
50       <para><literal>lfs quota -u root</literal> (usage includes internal Lustre data that is dynamic in size and does not accurately reflect mount point visible block and inode usage).</para>
51     </caution>
52   </section>
53   <section xml:id="enabling_disk_quotas">
54     <title><indexterm><primary>Quotas</primary><secondary>enabling disk</secondary></indexterm>Enabling Disk Quotas</title>
55     <para>Prior to Lustre 2.4.0, enabling quota involved a full file system scan via <literal>lfs
56         quotacheck</literal>. All file systems formatted with Lustre 2.4.0 or newer no longer
57       require quotacheck to be run since up-to-date accounting information are now always maintained
58       by the OSD layer, regardless of the quota enforcement status. </para>
59     <section remap="h3" condition="l24">
60       <title>Enabling Disk Quotas (Lustre Release 2.4 and later)</title>
61       <para>Although quota enforcement is managed by Lustre itself, each OSD implementation relies
62         on the backend file system to maintain per-user/group block and inode usage:</para>
63       <itemizedlist>
64         <listitem>
65           <para>For ldiskfs backend, mkfs.lustre now creates empty quota files and enables the QUOTA
66             feature flag in the superblock which turns quota accounting on at mount time
67             automatically. e2fsck was also modified to fix the quota files when the QUOTA feature
68             flag is present.</para>
69         </listitem>
70         <listitem>
71           <para>For ZFS backend, accounting ZAPs are created and maintained by the ZFS filesystem
72             itself. While ZFS tracks per-user and group block usage, it does not handle inode
73             accounting. The ZFS OSD implements its own support for inode tracking. Two options are
74             available:</para>
75           <orderedlist>
76             <listitem>
77               <para> The ZFS OSD can estimate the number of inodes in-use based on the number of
78                 blocks used by a given user or group. This mode can be enabled by running the
79                 following command on the server running the target: <literal>lctl set_param
80                   osd-zfs.${FSNAME}-${TARGETNAME}.quota_iused_estimate=1</literal>.</para>
81             </listitem>
82             <listitem>
83               <para> Similarly to block accounting, dedicated ZAPs are also created the ZFS OSD to
84                 maintain per-user and group inode usage. This is the default mode which corresponds
85                 to <literal>quota_iused_estimate</literal> set to 0.</para>
86             </listitem>
87           </orderedlist>
88         </listitem>
89       </itemizedlist>
90       <para>As a result, <literal>lfs quotacheck</literal> is now deprecated and not required any
91         more when running Lustre 2.4 on the servers.</para>
92       <para>Lustre filesystems formatted with a Lustre version prior to 2.4.0 can be still safely
93         upgraded to 2.4.0, but won't have functional space usage report until <literal>tunefs.lustre
94           --quota</literal> is run against all targets. This command sets the QUOTA feature flag in
95         the superblock and runs e2fsck (as a result, the target must be offline) to build the
96         per-UID/GID disk usage database. </para>
97       <caution>
98         <para>Lustre 2.4 and beyond requires a version of e2fsprogs that supports quota (i.e. newer
99           or equal to 1.42.3.wc1) to be installed on the server nodes using ldiskfs backend
100           (e2fsprogs isn't needed with ZFS backend). In general, we recommend to use the latest
101           e2fsprogs version available on http://downloads.whamcloud.com/public/e2fsprogs.</para>
102         <para>The ldiskfs OSD relies on the standard Linux quota to maintain accounting information
103           on disk. As a consequence, the Linux kernel running on the Lustre servers using ldiskfs
104           backend must have <literal>CONFIG_QUOTA</literal>, <literal>CONFIG_QUOTACTL</literal> and
105             <literal>CONFIG_QFMT_V2</literal> enabled.</para>
106       </caution>
107       <para>As of Lustre 2.4.0, quota enforcement is thus turned on/off independently of space
108         accounting which is always enabled. <literal>lfs
109           quota<replaceable>on|off</replaceable></literal> as well as the per-target
110           <literal>quota_type</literal> parameter are deprecated in favor of a single per-filesystem
111         quota parameter controlling inode/block quota enforcement. Like all permanent parameters,
112         this quota parameter can be set via <literal>lctl conf_param</literal> on the MGS via the
113         following syntax:</para>
114       <screen>lctl conf_param <replaceable>fsname</replaceable>.quota.<replaceable>ost|mdt</replaceable>=<replaceable>u|g|ug|none</replaceable></screen>
115       <itemizedlist>
116         <listitem>
117           <para><literal>ost</literal> -- to configure block quota managed by OSTs</para>
118         </listitem>
119         <listitem>
120           <para><literal>mdt</literal> -- to configure inode quota managed by MDTs</para>
121         </listitem>
122         <listitem>
123           <para><literal>u</literal> -- to enable quota enforcement for users only</para>
124         </listitem>
125         <listitem>
126           <para><literal>g</literal> -- to enable quota enforcement for groups only</para>
127         </listitem>
128         <listitem>
129           <para><literal>ug</literal> -- to enable quota enforcement for both users and
130             groups</para>
131         </listitem>
132         <listitem>
133           <para><literal>none</literal> -- to disable quota enforcement for both users and
134             groups</para>
135         </listitem>
136       </itemizedlist>
137       <para>Examples:</para>
138       <para>To turn on user and group quotas for block only on filesystem testfs1, run:</para>
139       <screen>$ lctl conf_param testfs1.quota.ost=ug</screen>
140       <para>To turn on group quotas for inodes on filesystem testfs2, run:</para>
141       <screen>$ lctl conf_param testfs2.quota.mdt=g</screen>
142       <para>To turn off user and group quotas for both inode and block on filesystem testfs3,
143         run:</para>
144       <screen>$ lctl conf_param testfs3.quota.ost=none</screen>
145       <screen>$ lctl conf_param testfs3.quota.mdt=none</screen>
146       <para>Once the quota parameter set on the MGS, all targets which are part of the filesystem
147         will be notified of the new quota settings and enable/disable quota enforcement as needed.
148         The per-target enforcement status can still be verified by running the following command on
149         the Lustre servers:</para>
150       <screen>$ lctl get_param osd-*.*.quota_slave.info
151 osd-zfs.testfs-MDT0000.quota_slave.info=
152 target name:    testfs-MDT0000
153 pool ID:        0
154 type:           md
155 quota enabled:  ug
156 conn to master: setup
157 user uptodate:  glb[1],slv[1],reint[0]
158 group uptodate: glb[1],slv[1],reint[0]</screen>
159       <caution>
160         <para>Lustre 2.4 comes with a new quota protocol and a new on-disk format, be sure to check
161           the Interoperability section below (see <xref linkend="quota_interoperability"/>.) when
162           migrating to 2.4</para>
163       </caution>
164     </section>
165     <section remap="h3">
166       <title>Enabling Disk Quotas (Lustre Releases Previous to Release 2.4 )</title>
167       <para><note>
168           <?oxy_custom_start type="oxy_content_highlight" color="255,64,0"?>
169           <para><?oxy_custom_end?>In Lustre software releases previous to Release 2.4, when new OSTs
170             are added to the file system, quotas are not automatically propagated to the new OSTs.
171             As a workaround, clear and then reset quotas for each user or group using the
172               <literal>lfs setquota</literal> command. In the example below, quotas are cleared and
173             reset for user <literal>bob</literal> on file system <literal>testfs</literal>:
174             <screen>$ lfs setquota -u bob -b 0 -B 0 -i 0 -I 0 /mnt/testfs 
175 $ lfs setquota -u bob -b 307200 -B 309200 -i 10000 -I 11000 /mnt/testfs</screen></para>
176         </note>For Lustre versions older than 2.4, <literal>lfs quotacheck</literal> must be first
177         run from a client node to create quota files on the Lustre targets (i.e. the MDT and OSTs).
178           <literal>lfs quotacheck</literal> requires the filesystem to be quiescent (i.e. no
179         modifying operations like write, truncate, create or delete should run concurrently).
180         Failure to follow this caution may result in inaccurate user/group disk usage. Operations
181         that do not change Lustre files (such as read or mount) are okay to run. <literal>lfs
182           quotacheck</literal> performs a scan on all the Lustre targets to calculates the
183         block/inode usage for each user/group. If the Lustre filesystem has many files,
184           <literal>quotacheck</literal> may take a long time to complete. Several options can be
185         passed to <literal>lfs quotacheck</literal>:</para>
186       <screen># lfs quotacheck -ug /mnt/testfs</screen>
187       <itemizedlist>
188         <listitem>
189           <para><literal>u</literal> -- checks the user disk quota information</para>
190         </listitem>
191         <listitem>
192           <para><literal>g</literal> -- checks the group disk quota information</para>
193         </listitem>
194       </itemizedlist>
195       <para>By default, quota is turned on after <literal>quotacheck</literal> completes. However,
196         this setting isn't persistent and quota will have to be enabled again (via <literal>lfs
197           quotaon</literal>) if one of the Lustre targets is restarted. <literal>lfs
198           quotaoff</literal> is used to turn off quota.</para>
199       <para>To enable quota permanently with a Lustre version older than 2.4, the
200           <literal>quota_type</literal> parameter must be used. This requires setting
201           <literal>mdd.quota_type</literal> and <literal>ost.quota_type</literal>, respectively, on
202         the MDT and OSTs. <literal>quota_type</literal> can be set to the string
203           <literal>u</literal> (user), <literal>g</literal> (group) or <literal>ug</literal> for
204         both users and groups. This parameter can be specified at <literal>mkfs</literal> time
205           (<literal>mkfs.lustre --param mdd.quota_type=ug</literal>) or with
206           <literal>tunefs.lustre</literal>. As an example:</para>
207       <screen>tunefs.lustre --param ost.quota_type=ug $ost_dev</screen>
208       <para>When using <literal>mkfs.lustre --param mdd.quota_type=ug</literal> or
209           <literal>tunefs.lustre --param ost.quota_type=ug</literal>, be sure to run the command on
210         all OSTs and the MDT. Otherwise, abnormal results may occur.</para>
211     </section>
212
213   </section>
214   <section xml:id="quota_administration">
215     <title><indexterm><primary>Quotas</primary><secondary>creating</secondary></indexterm>Quota Administration</title>
216     <para>Once the filesystem is up and running, quota limits on blocks and files can be set for both user and group. This is controlled via three quota parameters:</para>
217     <para><emphasis role="bold">Grace period</emphasis> -- The period of time (in seconds) within which users are allowed to exceed their soft limit. There are four types of grace periods:</para>
218     <itemizedlist>
219       <listitem>
220         <para> user block soft limit</para>
221       </listitem>
222       <listitem>
223         <para> user inode soft limit</para>
224       </listitem>
225       <listitem>
226         <para> group block soft limit</para>
227       </listitem>
228       <listitem>
229         <para> group inode soft limit</para>
230       </listitem>
231     </itemizedlist>
232     <para>The grace period applies to all users. The user block soft limit is for all users who are using a blocks quota.</para>
233     <para><emphasis role="bold">Soft limit</emphasis> -- The grace timer is started once the soft limit is exceeded. At this point, the user/group can still allocate block/inode. When the grace time expires and if the user is still above the soft limit, the soft limit becomes a hard limit and the user/group can't allocate any new block/inode any more. The user/group should then delete files to be under the soft limit. The soft limit MUST be smaller than the hard limit. If the soft limit is not needed, it should be set to zero (0).</para>
234       <para><emphasis role="bold">Hard limit</emphasis> -- Block or inode allocation will fail with <literal>EDQUOT</literal> (i.e. quota exceeded) when the hard limit is reached. The hard limit is the absolute limit. When a grace period is set, one can exceed the soft limit within the grace period if under the hard limit.</para>
235     <para>Due to the distributed nature of Lustre and the need to mainain performance under load, those quota parameters may not be 100% accurate. The quota settings can be manipulated via the <literal>lfs</literal> command which includes several options to work with quotas:</para>
236     <itemizedlist>
237       <listitem>
238         <para><varname>quota</varname>     -- displays general quota information (disk usage and limits)</para>
239       </listitem>
240       <listitem>
241         <para><varname>setquota</varname>  -- specifies quota limits and tunes the grace period. By default, the grace period is one week.</para>
242       </listitem>
243     </itemizedlist>
244     <para> Usage:</para>
245     <screen>lfs quota [-q] [-v] [-o obd_uuid] [-u|-g <replaceable>uname|uid|gname|gid</replaceable>]  <replaceable>/mount_point</replaceable>
246 lfs quota -t <replaceable>-u|-g</replaceable> <replaceable>/mount_point</replaceable>
247 lfs setquota <replaceable>-u|--user|-g|--group</replaceable> <replaceable>username|groupname</replaceable> [-b <replaceable>block-softlimit</replaceable>] \
248              [-B <replaceable>block_hardlimit</replaceable>] [-i <replaceable>inode_softlimit</replaceable>] \
249              [-I <replaceable>inode_hardlimit</replaceable>] <replaceable>/mount_point</replaceable></screen>
250     <para>To display general quota information (disk usage and limits) for the user running the command and his primary group, run:</para>
251     <screen>$ lfs quota /mnt/testfs </screen>
252     <para>To display general quota information for a specific user (&quot;<literal>bob</literal>&quot; in this example), run:</para>
253     <screen>$ lfs quota -u bob /mnt/testfs</screen>
254     <para>To display general quota information for a specific user (&quot;<literal>bob</literal>&quot; in this example) and detailed quota statistics for each MDT and OST, run:</para>
255     <screen>$ lfs quota -u bob -v /mnt/testfs</screen>
256     <para>To display general quota information for a specific group (&quot;<literal>eng</literal>&quot; in this example), run:</para>
257     <screen>$ lfs quota -g eng /mnt/testfs</screen>
258     <para>To display block and inode grace times for user quotas, run:</para>
259     <screen>$ lfs quota -t -u /mnt/testfs</screen>
260     <para>To set user or group quotas for a specific ID (&quot;bob&quot; in this example), run:</para>
261     <screen>$ lfs setquota -u bob -b 307200 -B 309200 -i 10000 -I 11000 /mnt/testfs</screen>
262     <para>In this example, the quota for user &quot;bob&quot; is set to 300 MB (309200*1024) and the hard limit is 11,000 files. Therefore, the inode hard limit should be 11000.</para>
263     <para>The quota command displays the quota allocated and consumed by each Lustre target. Using the previous <literal>setquota</literal> example, running this <literal>lfs</literal> quota command:</para>
264     <screen>$ lfs quota -u bob -v /mnt/testfs </screen>
265     <para>displays this command output:</para>
266     <screen>Disk quotas for user bob (uid 6000):
267 Filesystem          kbytes quota limit grace files quota limit grace
268 /mnt/testfs         0      30720 30920 -     0     10000 11000 -
269 testfs-MDT0000_UUID 0      -     16384 -     0     -     2560  -
270 testfs-OST0000_UUID 0      -     16384 -     0     -     0     -
271 testfs-OST0001_UUID 0      -     16384 -     0     -     0     -</screen>
272   <para>Global quota limits are stored in dedicated index files (there is one such index per quota type) on the quota master target (aka QMT). The QMT runs on MDT0000 and exports the global indexes via /proc. The global indexes can thus be dumped via the following command: <screen># lctl get_param qmt.testfs-QMT0000.*.glb-*</screen> The format of global indexes depends on the OSD type. The ldiskfs OSD uses an IAM files while the ZFS OSD creates dedicated ZAPs.</para>
273   <para>Each slave also stores a copy of this global index locally. When the global index is modified on the master, a glimpse callback is issued on the global quota lock to notify all slaves that the global index has been modified. This glimpse callback includes information about the identifier subject to the change. If the global index on the QMT is modified while a slave is disconnected, the index version is used to determine whether the slave copy of the global index isn't uptodate any more. If so, the slave fetches the whole index again and updates the local copy. The slave copy of the global index is also exported via /proc and can be accessed via the following command: <screen>lctl get_param osd-*.*.quota_slave.limit*</screen></para>
274   <note>
275   <para>Prior to 2.4, global quota limits used to be stored in administrative quota files using the on-disk format of the linux quota file. When upgrading MDT0000 to 2.4, those administrative quota files are converted into IAM indexes automatically, conserving existing quota limits previously set by the administrator.</para>
276   </note>
277   </section>
278   <section xml:id="quota_allocation">
279     <title><indexterm><primary>Quotas</primary><secondary>allocating</secondary></indexterm>Quota Allocation</title>
280     <para>In Lustre, quota must be properly allocated or users may experience unnecessary failures. The file system block quota is divided up among the OSTs within the file system. Each OST requests an allocation which is increased up to the quota limit. The quota allocation is then <emphasis role="italic">quantized</emphasis> to reduce the number of quota-related request traffic.</para>
281     <para>The Lustre quota system distributes quotas from the Quota Master Target (aka QMT). Only one QMT instance is supported for now and only runs on the same node as MDT0000. All OSTs and MDTs set up a Quota Slave Device (aka QSD) which connects to the QMT to allocate/release quota space. The QSD is setup directly from the OSD layer.</para>
282     <para>To reduce quota requests, quota space is initially allocated to QSDs in very large chunks. How much unused quota space can be hold by a target is controlled by the qunit size. When quota space for a given ID is close to exhaustion on the QMT, the qunit size is reduced and QSDs are notified of the new qunit size value via a glimpse callback. Slaves are then responsible for releasing quota space above the new qunit value. The qunit size isn't shrunk indefinitely and there is a minimal value of 1MB for blocks and 1,024 for inodes. This means that the quota space rebalancing process will stop when this mininum value is reached. As a result, quota exceeded can be returned while many slaves still have 1MB or 1,024 inodes of spare quota space.</para>
283     <para>If we look at the <literal>setquota</literal> example again, running this <literal>lfs quota</literal> command:</para>
284     <screen># lfs quota -u bob -v /mnt/testfs
285 </screen>
286     <para>displays this command output:</para>
287     <screen>Disk quotas for user bob (uid 500):
288 Filesystem          kbytes quota limit grace       files  quota limit grace
289 /mnt/testfs         30720* 30720 30920 6d23h56m44s 10101* 10000 11000 6d23h59m50s
290 testfs-MDT0000_UUID 0      -     0     -           10101  -     10240
291 testfs-OST0000_UUID 0      -     1024  -           -      -     -
292 testfs-OST0001_UUID 30720* -     29896 -           -      -     -</screen>
293     <para>The total quota limit of 30,920 is allocated to user bob, which is further distributed to two OSTs.</para>
294     <para>Values appended with &apos;<literal>*</literal>&apos; show that the quota limit has been exceeded, causing the following error when trying to write or create a file:</para>
295     <para><screen>$ cp: writing `/mnt/testfs/foo`: Disk quota exceeded.</screen></para>
296     <note>
297       <para>It is very important to note that the block quota is consumed per OST and the inode quota per MDS. Therefore, when the quota is consumed on one OST (resp. MDT), the client may not be able to create files regardless of the quota available on other OSTs (resp. MDTs).</para>
298       <para>Setting the quota limit below the minimal qunit size may prevent the user/group from all file creation. It is thus recommended to use soft/hard limits which are a multiple of the number of OSTs * the minimal qunit size.</para>
299     </note>
300     <para> To determine the total number of inodes, use <literal>lfs df -i</literal> (and also <literal>lctl get_param *.*.filestotal</literal>). For more information on using the <literal>lfs df -i</literal> command and the command output, see <xref linkend="dbdoclet.50438209_35838"/>.</para>
301     <para>Unfortunately, the <literal>statfs</literal> interface does not report the free inode count directly, but instead reports the total inode and used inode counts. The free inode count is calculated for <literal>df</literal> from (total inodes - used inodes). It is not critical to know a file system&apos;s total inode count. Instead, you should know (accurately), the free inode count and the used inode count for a file system. Lustre manipulates the total inode count in order to accurately report the other two values.</para>
302   </section>
303   <section xml:id="quota_interoperability">
304     <title><indexterm><primary>Quotas</primary><secondary>Interoperability</secondary></indexterm>Interoperability</title>
305     <para>The new quota protocol introduced in Lustre 2.4.0 <emphasis role="bold">isn't compatible</emphasis> with the old one. As a consequence, <emphasis role="bold">all Lustre servers must be upgraded to 2.4.0 for quota to be functional</emphasis>. Quota limits set on the Lustre filesystem prior to the upgrade will be automatically migrated to the new quota index format. As for accounting information with ldiskfs backend, they will be regenerated by running <literal>tunefs.lustre --quota</literal> against all targets. It is worth noting that running <literal>tunefs.lustre --quota</literal> is <emphasis role="bold">mandatory</emphasis> for all targets formatted with a Lustre version older than 2.4.0, otherwise quota enforcement as well as accounting won't be functional.</para>
306     <para>Besides, the 2.4 quota protocol takes for granted that the Lustre client supports the <literal>OBD_CONNECT_EINPROGRESS</literal> connect flag. Clients supporting this flag will retry indefinitely when the server returns <literal>EINPROGRESS</literal> in a reply. Here is the list of Lustre client version which are compatible with 2.4:</para>
307     <itemizedlist>
308       <listitem>
309         <para>2.3-based clients and beyond</para>
310       </listitem>
311       <listitem>
312         <para>1.8 clients newer or equal to 1.8.9-wc1</para>
313       </listitem>
314       <listitem>
315         <para>2.1 clients newer or equal to 2.1.4</para>
316       </listitem>
317   </itemizedlist>
318   </section>
319   <section xml:id="granted_cache_and_quota_limits">
320     <title><indexterm><primary>Quotas</primary><secondary>known issues</secondary></indexterm>Granted Cache and Quota Limits</title>
321     <para>In Lustre, granted cache does not respect quota limits. In this situation, OSTs grant cache to Lustre client to accelerate I/O. Granting cache causes writes to be successful in OSTs, even if they exceed the quota limits, and will overwrite them.</para>
322     <para>The sequence is:</para>
323     <orderedlist>
324       <listitem>
325         <para>A user writes files to Lustre.</para>
326       </listitem>
327       <listitem>
328         <para>If the Lustre client has enough granted cache, then it returns &apos;success&apos; to users and arranges the writes to the OSTs.</para>
329       </listitem>
330       <listitem>
331         <para>Because Lustre clients have delivered success to users, the OSTs cannot fail these writes.</para>
332       </listitem>
333     </orderedlist>
334     <para>Because of granted cache, writes always overwrite quota limitations. For example, if you set a 400 GB quota on user A and use IOR to write for user A from a bundle of clients, you will write much more data than 400 GB, and cause an out-of-quota error (<literal>EDQUOT</literal>).</para>
335     <note>
336       <para>The effect of granted cache on quota limits can be mitigated, but not eradicated. Reduce the maximum amount of dirty data on the clients (minimal value is 1MB):</para>
337       <itemizedlist>
338         <listitem>
339           <para><literal>lctl set_param osc.*.max_dirty_mb=8</literal></para>
340         </listitem>
341       </itemizedlist>
342     </note>
343   </section>
344   <section xml:id="lustre_quota_statistics">
345     <title><indexterm><primary>Quotas</primary><secondary>statistics</secondary></indexterm>Lustre Quota Statistics</title>
346     <para>Lustre includes statistics that monitor quota activity, such as the kinds of quota RPCs sent during a specific period, the average time to complete the RPCs, etc. These statistics are useful to measure performance of a Lustre file system.</para>
347     <para>Each quota statistic consists of a quota event and <literal>min_time</literal>, <literal>max_time</literal> and <literal>sum_time</literal> values for the event.</para>
348     <informaltable frame="all">
349       <tgroup cols="2">
350         <colspec colname="c1" colwidth="50*"/>
351         <colspec colname="c2" colwidth="50*"/>
352         <thead>
353           <row>
354             <entry>
355               <para><emphasis role="bold">Quota Event</emphasis></para>
356             </entry>
357             <entry>
358               <para><emphasis role="bold">Description</emphasis></para>
359             </entry>
360           </row>
361         </thead>
362         <tbody>
363           <row>
364             <entry>
365               <para> <emphasis role="bold">sync_acq_req</emphasis></para>
366             </entry>
367             <entry>
368               <para> Quota slaves send a acquiring_quota request and wait for its return.</para>
369             </entry>
370           </row>
371           <row>
372             <entry>
373               <para> <emphasis role="bold">sync_rel_req</emphasis></para>
374             </entry>
375             <entry>
376               <para> Quota slaves send a releasing_quota request and wait for its return.</para>
377             </entry>
378           </row>
379           <row>
380             <entry>
381               <para> <emphasis role="bold">async_acq_req</emphasis></para>
382             </entry>
383             <entry>
384               <para> Quota slaves send an acquiring_quota request and do not wait for its return.</para>
385             </entry>
386           </row>
387           <row>
388             <entry>
389               <para> <emphasis role="bold">async_rel_req</emphasis></para>
390             </entry>
391             <entry>
392               <para> Quota slaves send a releasing_quota request and do not wait for its return.</para>
393             </entry>
394           </row>
395           <row>
396             <entry>
397               <para> <emphasis role="bold">wait_for_blk_quota (lquota_chkquota)</emphasis></para>
398             </entry>
399             <entry>
400               <para> Before data is written to OSTs, the OSTs check if the remaining block quota is sufficient. This is done in the lquota_chkquota function.</para>
401             </entry>
402           </row>
403           <row>
404             <entry>
405               <para> <emphasis role="bold">wait_for_ino_quota (lquota_chkquota)</emphasis></para>
406             </entry>
407             <entry>
408               <para> Before files are created on the MDS, the MDS checks if the remaining inode quota is sufficient. This is done in the lquota_chkquota function.</para>
409             </entry>
410           </row>
411           <row>
412             <entry>
413               <para> <emphasis role="bold">wait_for_blk_quota (lquota_pending_commit)</emphasis></para>
414             </entry>
415             <entry>
416               <para> After blocks are written to OSTs, relative quota information is updated. This is done in the lquota_pending_commit function.</para>
417             </entry>
418           </row>
419           <row>
420             <entry>
421               <para> <emphasis role="bold">wait_for_ino_quota (lquota_pending_commit)</emphasis></para>
422             </entry>
423             <entry>
424               <para> After files are created, relative quota information is updated. This is done in the lquota_pending_commit function.</para>
425             </entry>
426           </row>
427           <row>
428             <entry>
429               <para> <emphasis role="bold">wait_for_pending_blk_quota_req (qctxt_wait_pending_dqacq)</emphasis></para>
430             </entry>
431             <entry>
432               <para> On the MDS or OSTs, there is one thread sending a quota request for a specific UID/GID for block quota at any time. At that time, if other threads need to do this too, they should wait. This is done in the qctxt_wait_pending_dqacq function.</para>
433             </entry>
434           </row>
435           <row>
436             <entry>
437               <para> <emphasis role="bold">wait_for_pending_ino_quota_req (qctxt_wait_pending_dqacq)</emphasis></para>
438             </entry>
439             <entry>
440               <para> On the MDS, there is one thread sending a quota request for a specific UID/GID for inode quota at any time. If other threads need to do this too, they should wait. This is done in the qctxt_wait_pending_dqacq function.</para>
441             </entry>
442           </row>
443           <row>
444             <entry>
445               <para> <emphasis role="bold">nowait_for_pending_blk_quota_req (qctxt_wait_pending_dqacq)</emphasis></para>
446             </entry>
447             <entry>
448               <para> On the MDS or OSTs, there is one thread sending a quota request for a specific UID/GID for block quota at any time. When threads enter qctxt_wait_pending_dqacq, they do not need to wait. This is done in the qctxt_wait_pending_dqacq function.</para>
449             </entry>
450           </row>
451           <row>
452             <entry>
453               <para> <emphasis role="bold">nowait_for_pending_ino_quota_req (qctxt_wait_pending_dqacq)</emphasis></para>
454             </entry>
455             <entry>
456               <para> On the MDS, there is one thread sending a quota request for a specific UID/GID for inode quota at any time. When threads enter qctxt_wait_pending_dqacq, they do not need to wait. This is done in the qctxt_wait_pending_dqacq function.</para>
457             </entry>
458           </row>
459           <row>
460             <entry>
461               <para> <emphasis role="bold">quota_ctl</emphasis></para>
462             </entry>
463             <entry>
464               <para> The quota_ctl statistic is generated when lfs <literal>setquota</literal>, <literal>lfs quota</literal> and so on, are issued.</para>
465             </entry>
466           </row>
467           <row>
468             <entry>
469               <para> <emphasis role="bold">adjust_qunit</emphasis></para>
470             </entry>
471             <entry>
472               <para> Each time qunit is adjusted, it is counted.</para>
473             </entry>
474           </row>
475         </tbody>
476       </tgroup>
477     </informaltable>
478     <section remap="h3">
479       <title>Interpreting Quota Statistics</title>
480       <para>Quota statistics are an important measure of a Lustre file system&apos;s performance. Interpreting these statistics correctly can help you diagnose problems with quotas, and may indicate adjustments to improve system performance.</para>
481       <para>For example, if you run this command on the OSTs:</para>
482       <screen>lctl get_param lquota.testfs-OST0000.stats</screen>
483       <para>You will get a result similar to this:</para>
484       <screen>snapshot_time                                1219908615.506895 secs.usecs
485 async_acq_req                              1 samples [us]  32 32 32
486 async_rel_req                              1 samples [us]  5 5 5
487 nowait_for_pending_blk_quota_req(qctxt_wait_pending_dqacq) 1 samples [us] 2\
488  2 2
489 quota_ctl                          4 samples [us]  80 3470 4293
490 adjust_qunit                               1 samples [us]  70 70 70
491 ....</screen>
492       <para>In the first line, <literal>snapshot_time</literal> indicates when the statistics were taken. The remaining lines list the quota events and their associated data.</para>
493       <para>In the second line, the <literal>async_acq_req</literal> event occurs one time. The <literal>min_time</literal>, <literal>max_time</literal> and <literal>sum_time</literal> statistics for this event are 32, 32 and 32, respectively. The unit is microseconds (μs).</para>
494       <para>In the fifth line, the quota_ctl event occurs four times. The <literal>min_time</literal>, <literal>max_time</literal> and <literal>sum_time</literal> statistics for this event are 80, 3470 and 4293, respectively. The unit is microseconds (μs).</para>
495     </section>
496   </section>
497 </chapter>