<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:15:31 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Whamcloud Community JIRA</title>
    <link>https://jira.whamcloud.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.4.14</version>
        <build-number>940014</build-number>
        <build-date>05-12-2023</build-date>
    </build-info>


<item>
            <title>[LU-1310] setfsuid() and quotas</title>
                <link>https://jira.whamcloud.com/browse/LU-1310</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;The following code as root doesn&apos;t raise &quot;EDQUOT&quot; error on Lustre even if the user &quot;ME&quot; exceeded its data quota:&lt;/p&gt;

&lt;p&gt;    #define SIZE 10240&lt;br/&gt;
    #define ME 500&lt;/p&gt;

&lt;p&gt;    int main( int argc, char * argv[] )&lt;/p&gt;
    {
      char * buff = NULL ;
      int fd =0 ;

      buff = malloc( SIZE ) ;

      setfsuid( ME ) ;
      fd = open( argv[1], O_CREAT|O_RDWR, 0644 ) ;
      printf( &quot;buff=%p, errno=%u\n&quot;, buff, errno ) ;

      printf( &quot;fd = %d\n&quot;, fd ) ;
      printf( &quot;bytes written = %d, errno=%u\n&quot;,
             write( fd, buff, SIZE), errno );

      printf( &quot;fsync:%d errno=%u\n&quot;, fsync( fd ), errno ) ;
      printf( &quot;close:%d errno=%u\n&quot;, close( fd ), errno )  ;
    }

&lt;p&gt;Running it returns no error even if user 500 is out of data quota:&lt;br/&gt;
    buff=0xee8010, errno=0&lt;br/&gt;
    fd = 3&lt;br/&gt;
    bytes written = 10240, errno=0&lt;br/&gt;
    fsync:0 errno=0&lt;br/&gt;
    close:0 errno=0&lt;/p&gt;

&lt;p&gt;The issue is only for data quota. setfsuid() works fine for inode quota.&lt;/p&gt;</description>
                <environment>RedHat 6.0</environment>
        <key id="13964">LU-1310</key>
            <summary>setfsuid() and quotas</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.whamcloud.com/images/icons/priorities/minor.svg">Minor</priority>
                        <status id="5" iconUrl="https://jira.whamcloud.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="2">Won&apos;t Fix</resolution>
                                        <assignee username="niu">Niu Yawei</assignee>
                                    <reporter username="leibovici-cea">Thomas LEIBOVICI - CEA</reporter>
                        <labels>
                    </labels>
                <created>Thu, 12 Apr 2012 10:08:24 +0000</created>
                <updated>Mon, 7 May 2012 05:25:58 +0000</updated>
                            <resolved>Mon, 7 May 2012 05:25:58 +0000</resolved>
                                    <version>Lustre 2.1.0</version>
                                                        <due></due>
                            <votes>1</votes>
                                    <watches>5</watches>
                                                                            <comments>
                            <comment id="34594" author="pjones" created="Thu, 12 Apr 2012 10:11:32 +0000"  >&lt;p&gt;Niu&lt;/p&gt;

&lt;p&gt;Could you please comment on this one?&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="34595" author="leibovici-cea" created="Thu, 12 Apr 2012 10:12:20 +0000"  >&lt;p&gt;reproducer&lt;/p&gt;</comment>
                            <comment id="34685" author="niu" created="Fri, 13 Apr 2012 04:20:33 +0000"  >&lt;p&gt;Hi, Thomas&lt;/p&gt;

&lt;p&gt;Did you test it on any other fs? I ran it on my local ext4 fs, and got the same result.&lt;/p&gt;

&lt;p&gt;Lustre checks CAP_SYS_RESOURCE on client to determine if the process can over data quota on OST. This test program calls setfsuid only, but leave the CAP_SYS_RESOURCE capability preserved, so this process should still be able to over quota.&lt;/p&gt;

&lt;p&gt;To make the process not over-run quota, I think the application should both setfsuid and clear the corresponding superior capabilities, what&apos;s your opinion? Thanks.&lt;/p&gt;</comment>
                            <comment id="34927" author="leibovici-cea" created="Tue, 17 Apr 2012 10:32:37 +0000"  >&lt;p&gt;Thanks, I have to check this with the CEA developper who reported me this issue.&lt;/p&gt;</comment>
                            <comment id="38078" author="deniel-cea" created="Thu, 3 May 2012 08:01:06 +0000"  >&lt;p&gt;Hi Niu,&lt;/p&gt;

&lt;p&gt;I do confirm that CAP_SYS_RESOURCE is ON for the process. I&apos;ll try to remove it by using prctl() or capset() or capng_update() (the one which will be the most portable and effective). Then, I&apos;ll update this thread. &lt;/p&gt;

&lt;p&gt;  regards&lt;/p&gt;

&lt;p&gt;    Philippe&lt;/p&gt;</comment>
                            <comment id="38087" author="deniel-cea" created="Thu, 3 May 2012 10:56:02 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I have attached to this mail a new reproducer (reproducer_v2.c) which is the same as the former one, but does call to capget and capset.&lt;br/&gt;
Those calls are use to remove the CAP_SYS_RESOURCE capability. The behavior does not change (write operation is allowed as errno=EDQUOT should be returned).&lt;/p&gt;</comment>
                            <comment id="38090" author="niu" created="Thu, 3 May 2012 11:34:48 +0000"  >&lt;p&gt;Could you run &apos;lfs quota -v -u $USR $MNT&apos; to see if the user is really alreay over quota first? If the user do run out of quota, could you run the reproducer 2 times to see if the second run will get EDQUOT? (for instance, ./reproducer_v2 /mnt/lustre/a; ./reproducer_v2 /mnt/lustre/b) The -EDQUOT on second run is expected behavior, otherwise, we have to collect more information to see what&apos;s wrong here.&lt;/p&gt;

&lt;p&gt;Let me explain why the first write will success even if the user is running out of quota:&lt;br/&gt;
The write in reproducer is asynchronous, that first write will be written into cache, and the cache flush always ignore quota in lustre (otherwise, the cached data will be lost), when the cache flush return from server, client will know that the user is out of quota, and the second write will be turned into sync write internally in lustre, and fail for -EDQUOT at the end.  &lt;/p&gt;</comment>
                            <comment id="38096" author="deniel-cea" created="Thu, 3 May 2012 12:35:14 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;lfs quota shows this (/gl is the mounted LUSTRE fs)&lt;/p&gt;

&lt;p&gt;lfs quota -v -u 3051  /gl&lt;br/&gt;
Disk quotas for user 3051 (uid 3051):&lt;br/&gt;
     Filesystem  kbytes   quota   limit   grace   files   quota   limit   grace&lt;br/&gt;
            /gl 2876856* 1048576 2097152       -      78     100     150       -&lt;br/&gt;
gl-MDT0000_UUID       4       -    1024       -      78       -      80       -&lt;br/&gt;
gl-OST0000_UUID  698284*      -  551936       -       -       -       -       -&lt;br/&gt;
gl-OST0001_UUID 1033972*      -  770048       -       -       -       -       -&lt;br/&gt;
gl-OST0002_UUID  772192*      -  699392       -       -       -       -       -&lt;br/&gt;
gl-OST0003_UUID  372404*      -   74752       -       -       -       -       -&lt;/p&gt;

&lt;p&gt;There are &quot;*&quot; after every OST information, I guess they all have &quot;exceeded quotas&quot;. Do you confirm this ?&lt;/p&gt;

&lt;p&gt;I ran the reproducer (as root), with two different files as parameter. No -EDQUOT is returned and two new files of file 10240 are created. But the call will always increase the counter in lfs quota. Now lfs quota shows that :&lt;/p&gt;

&lt;p&gt;lfs quota -u deniel /gl&lt;br/&gt;
Disk quotas for user deniel (uid 3051):&lt;br/&gt;
     Filesystem  kbytes   quota   limit   grace   files   quota   limit   grace&lt;br/&gt;
            /gl 2876880* 1048576 2097152       -      80     100     150       -&lt;/p&gt;

&lt;p&gt;The &quot;used&quot; space has increased from 2876856 to 2876880, much more than the 2097152 hard limit. &lt;/p&gt;

&lt;p&gt;What can I do to provide you with more information ?&lt;/p&gt;

&lt;p&gt; Regards&lt;/p&gt;

&lt;p&gt;   Philippe &lt;/p&gt;</comment>
                            <comment id="38143" author="niu" created="Fri, 4 May 2012 00:29:04 +0000"  >&lt;blockquote&gt;
&lt;p&gt;There are &quot;*&quot; after every OST information, I guess they all have &quot;exceeded quotas&quot;. Do you confirm this ?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Yes, all OSTs have exceeded quotas.&lt;/p&gt;

&lt;p&gt;Seems there is a defect in your reproducer:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;  capdata.effective &amp;amp;= ~CAP_SYS_RESOURCE;
  capdata.permitted &amp;amp;= ~CAP_SYS_RESOURCE;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;should be changed to:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;  capdata.effective &amp;amp;= ~CAP_TO_MASK(CAP_SYS_RESOURCE);
  capdata.permitted &amp;amp;= ~CAP_TO_MASK(CAP_SYS_RESOURCE);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And I&apos;m not sure what&apos;s your default stripe count, if the stripe count is 1, you might need to repeat the reproducer 4 times. (there are 4 OSTs, you need to write each OST once to retrieve the out of quota informaiton to client for each of them)&lt;/p&gt;</comment>
                            <comment id="38145" author="deniel-cea" created="Fri, 4 May 2012 04:21:43 +0000"  >&lt;p&gt;Hi Niu,&lt;/p&gt;

&lt;p&gt;you are perfectly right, CAP_TO_MASK is what was missing in my reproducer. Things look much better now and I finally could have the EDQUOT error that I expected. I will backport the logic inside the fixed reproducer to my program. &lt;br/&gt;
Thanks a lot for your help.&lt;/p&gt;

&lt;p&gt;  Regards&lt;/p&gt;

&lt;p&gt;    Philippe &lt;/p&gt;</comment>
                            <comment id="38211" author="niu" created="Mon, 7 May 2012 03:22:18 +0000"  >&lt;p&gt;Hi, Philippe/Thomas, can we close this ticket?&lt;/p&gt;</comment>
                            <comment id="38212" author="deniel-cea" created="Mon, 7 May 2012 03:48:54 +0000"  >&lt;p&gt;Yes, you can &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.whamcloud.com/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;
</comment>
                    </comments>
                    <attachments>
                            <attachment id="11283" name="reproducer_v2.c" size="2140" author="deniel-cea" created="Thu, 3 May 2012 10:54:27 +0000"/>
                            <attachment id="11140" name="setfsuid.c" size="626" author="leibovici-cea" created="Thu, 12 Apr 2012 10:12:20 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_10890" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzvh2v:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6416</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10060" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Severity</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10022"><![CDATA[3]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>