<div dir="ltr"><div style="font-size:12.8px"><div style="font-size:12.8px">Hi All,</div><div><br></div><div>Below is the design for &#39;<b style="font-size:12.8px">GlusterFS User and Group Quotas&#39;, </b><span style="font-size:12.8px">please provide your feedback on the same.</span></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b style="font-size:12.8px"><u>Developers:</u></b><br></div><div style="font-size:12.8px">Vijaikumar.M and Manikandan.S</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b><u>Introduction:</u></b></div><div style="font-size:12.8px">User and Group quotas is to limit the amount of disk space for a</div><div style="font-size:12.8px">specified user/group ID.</div><div style="font-size:12.8px">This documents provides some details about how the accounting (marker xlator) can be done</div><div style="font-size:12.8px">for user and group quotas</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b><u>Design:</u></b></div><div style="font-size:12.8px">We have three different approaches, each has pros and cons</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b><u>Approach-1)</u></b></div><div style="font-size:12.8px">T1 - For each file/dir &#39;file_x&#39;, create a contribution extended attribute say &#39;trusted.glusterfs.quota.&lt;uid&gt;-contri&#39;</div><div style="font-size:12.8px">T2 - In a lookup/write operation read the actual size from the stat-buf, add the delta size to the contribution xattr</div><div style="font-size:12.8px">T3 - Create a file .glusterfs/quota/users/&lt;uid&gt;.</div><div style="font-size:12.8px">     Update size extended attribute say &#39;trusted.glusterfs.quota.size&#39; by adding the delta size calculated in T2</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Same for group quotas a size xattr is updated under .glusterfs/quota/groups/&lt;gid&gt;.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">cons:</div><div style="font-size:12.8px">    If the brick crashes after executing T2 and before T3. Now accounting information is in-correct.</div><div style="font-size:12.8px">    To recover and correct the accounting information, entire file-systems needs to be crawled to fix the trusted.glusterfs.quota.size</div><div style="font-size:12.8px">    value by summing up the contribution of all files with UID. But is a slow process.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b><u>Approach-2)</u></b></div><div style="font-size:12.8px">T1 - For each file/dir &#39;file_x&#39;, create a contribution extended attribute say &#39;trusted.glusterfs.quota.&lt;uid&gt;-contri&#39;</div><div style="font-size:12.8px">T2 - create a directory &#39;.glusterfs/quota/users/&lt;uid&gt;&#39;</div><div style="font-size:12.8px">     create a hardlink for file file_x under this directories</div><div style="font-size:12.8px">T3 - In a lookup/write operation, set dirty flag &#39;trusted.glusterfs.quota.dirty&#39; for directory &#39;.glusterfs/quota/users/&lt;uid&gt;&#39;</div><div style="font-size:12.8px">T4 - Read the actual size of a file from the stat-buf, add the delta size to the contribution xattr</div><div style="font-size:12.8px">T5 - update size extended attribute say for directory &#39;.glusterfs/quota/users/&lt;uid&gt;&#39;</div><div style="font-size:12.8px">T6 - unset the dirty flag</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Same for group quotas a size xattr is updated under .glusterfs/quota/groups/&lt;gid&gt;.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Problem of approach 1 of crawling entire brick is solved by only crawling the directory which is set dirty.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">cons:</div><div style="font-size:12.8px">    Need to make sure that the hard-link for a file is consistent when having another hardlinks</div><div style="font-size:12.8px">    under .glusterfs/quota/users/&lt;uid&gt; and .glusterfs/quota/groups/&lt;gid&gt;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b><u>Approach-3)</u></b></div><div style="font-size:12.8px">T1 - For each file/dir &#39;file_x&#39;, update a contribution entry in the SQL-LITE DB (Create a DB file under .glusterfs/quota/<span style="font-size:12.8px">)</span></div><div style="font-size:12.8px">T2 - In a lookup/write operation read the actual size from the statbuf, add the update the size in the USER-QUOTA schema in the DB</div><div style="font-size:12.8px">T3 - In a lookup/write operation, set dirty flag &#39;trusted.glusterfs.quota.dirty&#39; for directory &#39;.glusterfs/quota/users/&lt;uid&gt;&#39;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Atomicity problem found in approach 1 and 2 is solved by using DB transactions.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Note: need to test the consistency of the SQL-LITE DB.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We feel approach-3 is more simpler and efficient way of implementing user/group quotas.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks,</div><div style="font-size:12.8px">Vijay</div></div>