<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 03:06: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-14062] Setting project ID inheritance on directories can break hardlinking</title>
                <link>https://jira.whamcloud.com/browse/LU-14062</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;A colleague of mine mentioned that &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-11872&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;LU-11872&lt;/a&gt; and how it relates to hardlinks was brought up on the Robinhood mailing list, so we tested some various cases and debugged as much as we could. We were interested in the reported problems, as we were looking to enable project quotas on one of our file systems within the month, but the users of said file system rely fairly heavily on hardlinks. Here&apos;s what we came up with.&lt;/p&gt;

&lt;p&gt;There are two main issues:&lt;br/&gt;
Issue 1: All hardlink project IDs get set to the most recent update to the inode. This is somewhat expected behavior.&lt;br/&gt;
Issue 2: You cannot create hardlinks across multiple &lt;b&gt;existing&lt;/b&gt; project directories when inheritance is set.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br/&gt;
Issue 1:&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;
# mkdir hardlink_dir1
# mkdir hardlink_dir2
# touch hardlink_dir1/foo
# cd hardlink_dir2
# ln ../hardlink_dir1/foo ./hardlink_to_fo
# cd ..
# lfs project -srp 1111 hardlink_dir1
# lfs project -d ./hardlink_dir1/foo
 1111 P ./hardlink_dir1/foo
# lfs project -srp 2222 hardlink_dir2
# lfs project -d ./hardlink_dir1/foo
 2222 P ./hardlink_dir1/foo
#
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Issue 2:&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;
# mkdir hardlink_dir1
# mkdir hardlink_dir2
# lfs project -srp 1111 hardlink_dir1
# lfs project -srp 2222 hardlink_dir2
# touch hardlink_dir/foo
touch: cannot touch &lt;span class=&quot;code-quote&quot;&gt;&apos;hardlink_dir/foo&apos;&lt;/span&gt;: No such file or directory
# touch hardlink_dir1/foo
# cd hardlink_dir2
# ln ../hardlink_dir1/foo ./hardlink_to_foo
ln: failed to create hard link &lt;span class=&quot;code-quote&quot;&gt;&apos;./hardlink_to_foo&apos;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;code-quote&quot;&gt;&apos;../hardlink_dir1/foo&apos;&lt;/span&gt;: Invalid cross-device link

# cd ..
# lfs project -C -k hardlink_dir2
# lfs project -d hardlink_dir2
 2222 - hardlink_dir2
# cd hardlink_dir2
# ln ../hardlink_dir1/foo ./hardlink_to_foo
# ls -l
total 1
-rw-r--r-- 2 root root 0 Oct 21 14:49 hardlink_to_foo
#
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Looking at `lfs_project.c`, it seems that `project_get_xattr()` is using `sys/stat.h`&apos;s `st_mode` to determine if a file meets the `S_ISREG` or `S_ISDIR` test. If it does, it&apos;s then processed. This works for symlinks, but the issue is that hardlinks match the `S_ISREG` condition. We thought over some possible ways to resolve this and you could theoretically use something like `st_nlink &amp;gt; 1` to determine if the file is a hardlink, but that seemingly leads to a ton of edge cases. For one, a project ID could be set on the original file, and then if a hardlink were created, you&apos;d no longer be able to update or change the existing project ID. If you decided to programmatically clear the project ID once a hardlink was identified, you&apos;d end up not accounting for any of the data represented by the various hardlinks.&lt;/p&gt;

&lt;p&gt;I&apos;m not sure there&apos;s a great permanent solution to this, but as of right now if you enable project quotas, hardlinks break in certain circumstances.&lt;/p&gt;</description>
                <environment></environment>
        <key id="61301">LU-14062</key>
            <summary>Setting project ID inheritance on directories can break hardlinking</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="1" iconUrl="https://jira.whamcloud.com/images/icons/statuses/open.png" description="The issue is open and ready for the assignee to start work on it.">Open</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="wshilong">Wang Shilong</assignee>
                                    <reporter username="nilesj">Jeff Niles</reporter>
                        <labels>
                    </labels>
                <created>Wed, 21 Oct 2020 19:38:57 +0000</created>
                <updated>Sat, 23 Jan 2021 00:02:16 +0000</updated>
                                            <version>Lustre 2.12.5</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>6</watches>
                                                                            <comments>
                            <comment id="282915" author="sthiell" created="Wed, 21 Oct 2020 20:47:30 +0000"  >&lt;p&gt;Hi Jeff,&lt;/p&gt;

&lt;p&gt;We migrated to project quotas a while back on our scratch and we think &apos;Issue 2&apos; is the expected behavior (and we like it). Users should NOT be able to create hardlinks between different projects. This is the same on Isilon when you use directory quotas, so our users understand it (they got &quot;Invalid cross-device link&quot; when using ln between projects).&lt;/p&gt;

&lt;p&gt;Of course, if you have many hardlinks already on your filesystem and want to migrate to project quotas, that can be a real problem indeed...&lt;/p&gt;</comment>
                            <comment id="282918" author="nilesj" created="Wed, 21 Oct 2020 21:09:33 +0000"  >&lt;p&gt;Stephane,&lt;/p&gt;

&lt;p&gt;While I think most people associate projects (and thus project IDs) with specific directories, in the current implementation it&apos;s much more arbitrary. I can have a directory and half of its files associated with one project ID, while the other half of the files within the directory are associated with another project ID. Generally not how people use it, but as an example.&lt;/p&gt;

&lt;p&gt;We are intending to use project ID mostly as an accounting feature and not an enforcement feature. I don&apos;t necessarily think that project ID should be used to gate access to files. If I have permissions on a given file, I think I should be able to link to it from anywhere else that I have permissions. The example breakdown in our users&apos; use case would be:&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;
/lustre/example_fs/shared_input_data - project ID: 999 - input directory &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; large input files that are used across various projects
/lustre/example_fs/project1 - project ID: 1 - working area &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; users of the &lt;span class=&quot;code-quote&quot;&gt;&quot;project 1&quot;&lt;/span&gt; project
/lustre/example_fs/project2 - project ID: 2 - working area &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; users of the &lt;span class=&quot;code-quote&quot;&gt;&quot;project 2&quot;&lt;/span&gt; project&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;In the layout above, project ID 999 would be used to account for the space consumed by &quot;shared&quot; input files for all of the various projects. Users would hardlink (which for the record, I don&apos;t like, but user workflows...) data from the &quot;shared_input_data&quot; area into the &quot;project 1&quot; working area to use in their workflow. &quot;project 2&quot; would do the same, as would &quot;project 3&quot;, etc. In the above scenario, it doesn&apos;t make sense to attribute the data to any one of the projects for accounting or quota enforcement, but we&apos;d still like to give it a project ID so that we can account for it in quota reports. I&apos;m not sure if this use case is considered odd, but it seems like an intended use of the feature as it exists now. Maybe I&apos;m off base?&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Jeff&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="283002" author="pjones" created="Thu, 22 Oct 2020 14:34:40 +0000"  >&lt;p&gt;Shilong&lt;/p&gt;

&lt;p&gt;Could you please advise&lt;/p&gt;

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

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="285838" author="wshilong" created="Tue, 24 Nov 2020 01:24:47 +0000"  >&lt;p&gt;Firstly, this is expected behavior with project quota, allowing hardlinks across different projid could be tricky. So what should be new projectID with newly&lt;br/&gt;
created hardlink? hardlink did not create new inode, so its projectID points to target inode projectID, is that fine? or we should re-setting project ID with source parent&apos;s project ID, and as &lt;a href=&quot;https://jira.whamcloud.com/secure/ViewProfile.jspa?name=sthiell&quot; class=&quot;user-hover&quot; rel=&quot;sthiell&quot;&gt;sthiell&lt;/a&gt; mentioned for directory quota, denying. the behavior looks sane.&lt;/p&gt;

&lt;p&gt;We might introduce extra interface from MDS, eg allow hardlink from different project ID, but that should be only used for specific usage and need define &lt;br/&gt;
behavior explictly, what do you think Andreas? &lt;a href=&quot;https://jira.whamcloud.com/secure/ViewProfile.jspa?name=adilger&quot; class=&quot;user-hover&quot; rel=&quot;adilger&quot;&gt;adilger&lt;/a&gt;&lt;/p&gt;




</comment>
                            <comment id="285917" author="adilger" created="Tue, 24 Nov 2020 18:29:26 +0000"  >&lt;p&gt;The first thing I would ask is whether the workflow can change from using hard links to using symlinks?&#160; That would allow the &quot;&lt;tt&gt;shared_input_data&lt;/tt&gt;&quot; directory to hold the quota for those files, and not require the ability to create hard links across project IDs (which is also the disallowed for ext4 and XFS, and AFAIK ZFS).  &lt;/p&gt;

&lt;p&gt;IMHO, it doesn&apos;t make sense to &quot;charge&quot; the users of the hard links for the use of space in &lt;tt&gt;shared_input_data&lt;/tt&gt;, so &lt;b&gt;if&lt;/b&gt; this is allowed (as a non-default tunable paramter on the MDS) it should be that the second hardlink would not change the projid of the inode, and running &quot;&lt;tt&gt;lfs project&lt;/tt&gt;&quot; on a directory to repair the projid should not affect files with multiple links.  I think that would give the correct, and reasonably sane, semantics for this kind of usage.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="54597">LU-11872</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </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|i01cxr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</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>