<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 03:34:21 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-17307] osd_dirent_count() keeps multiple threads busy</title>
                <link>https://jira.whamcloud.com/browse/LU-17307</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;When &lt;tt&gt;osd_attr_get()&lt;/tt&gt; is accessing a directory for the first time, it calls &lt;tt&gt;osd_dirent_count()&lt;/tt&gt; to iterate over the directory and fill in &lt;tt&gt;obj-&amp;gt;oo_dirent_count&lt;/tt&gt;:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; iterate_dir+0x70/0x140
 osd_ldiskfs_it_fill+0xbd/0x290 [osd_ldiskfs]
 osd_it_ea_next+0xc2/0x150 [osd_ldiskfs]
 osd_attr_get+0x4bc/0x730 [osd_ldiskfs]
 lod_attr_get+0x8b/0x170 [lod]
 mdd_la_get+0x70/0x200 [mdd]
 mdd_attr_get+0x38/0x100 [mdd]
 mdt_attr_get_complex+0x4dd/0x800 [mdt]
 mdt_getattr_internal+0x445/0x1590 [mdt]
 mdt_getattr_name_lock+0x74d/0x2640 [mdt]
 mdt_intent_getattr+0x2a5/0x470 [mdt]
 mdt_intent_opc+0x1ba/0xb40 [mdt]
 mdt_intent_policy+0x1a9/0x370 [mdt]
 ldlm_lock_enqueue+0x3d4/0xb00 [ptlrpc]
 ldlm_handle_enqueue0+0x8b6/0x16d0 [ptlrpc]
 tgt_enqueue+0x62/0x220 [ptlrpc]
 tgt_request_handle+0x8bf/0x18c0 [ptlrpc]
 ptlrpc_server_handle_request+0x253/0xc40 [ptlrpc]
 ptlrpc_main+0xc88/0x26c0 [ptlrpc]
 kthread+0xd1/0xe0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, there are several issues with this:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;if the directory is very large (e.g. millions of entries), then this iteration can take a considerable time and blocks the MDS service thread until it is finished.&lt;/li&gt;
	&lt;li&gt;if multiple MDS threads are accessing the same directory, then all of the threads will try to count the number of entries in the directory, blocking all of the threads.&lt;/li&gt;
	&lt;li&gt;the &lt;tt&gt;oo_dirent_count&lt;/tt&gt; value is only needed for auto directory split, which is not enabled today.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The entry counting should only be done if directory auto-split is enabled, avoiding overhead under normal cases.  Since &lt;tt&gt;mdt_enable_dir_auto_split&lt;/tt&gt; is controlled at the MDT level, the need for the count should be passed down to the OSD via an &lt;tt&gt;LA_DIRENT_COUNT&lt;/tt&gt; valid flag.  For &lt;tt&gt;osd-ldiskfs&lt;/tt&gt; if this flag is not set then the count would be skipped.  For &lt;tt&gt;osd-zfs&lt;/tt&gt; it can optionally return the count since it is available for free.&lt;/p&gt;

&lt;p&gt;If directory auto-split is enabled, it would be much more efficient to only have one thread do the directory iteration.  This should be controlled by a flag in the object, and the other threads can ignore &lt;tt&gt;oo_dirent_count&lt;/tt&gt; (return &quot;&lt;tt&gt;0&lt;/tt&gt;&quot; or &quot;&lt;tt&gt;LU_DIRENT_COUNT_UNSET&lt;/tt&gt;&quot; or the current number of entries found).  At worst this would defer the auto split by a few entries, but that doesn&apos;t matter in the end since the thread doing the counting will always perform the check itself.&lt;/p&gt;
</description>
                <environment></environment>
        <key id="79115">LU-17307</key>
            <summary>osd_dirent_count() keeps multiple threads busy</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.whamcloud.com/images/icons/priorities/major.svg">Major</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="1">Fixed</resolution>
                                        <assignee username="laisiyao">Lai Siyao</assignee>
                                    <reporter username="adilger">Andreas Dilger</reporter>
                        <labels>
                    </labels>
                <created>Tue, 21 Nov 2023 16:44:31 +0000</created>
                <updated>Fri, 15 Dec 2023 19:17:27 +0000</updated>
                            <resolved>Fri, 15 Dec 2023 19:17:27 +0000</resolved>
                                    <version>Lustre 2.14.0</version>
                    <version>Lustre 2.15.0</version>
                                    <fixVersion>Lustre 2.16.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>6</watches>
                                                                            <comments>
                            <comment id="394158" author="gerrit" created="Fri, 24 Nov 2023 10:01:11 +0000"  >&lt;p&gt;&quot;Lai Siyao &amp;lt;lai.siyao@whamcloud.com&amp;gt;&quot; uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/c/fs/lustre-release/+/53229&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/c/fs/lustre-release/+/53229&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-17307&quot; title=&quot;osd_dirent_count() keeps multiple threads busy&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-17307&quot;&gt;&lt;del&gt;LU-17307&lt;/del&gt;&lt;/a&gt; mdt: get dirent count by request&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 06aec8f6c410dcb053bc87d61ce334c23e58e1fd&lt;/p&gt;</comment>
                            <comment id="395820" author="JIRAUSER17900" created="Thu, 7 Dec 2023 10:16:20 +0000"  >&lt;p&gt;2023-12-07: The fix patch is ready to land to master(temporarily not on master-next branch).&lt;/p&gt;</comment>
                            <comment id="396384" author="gerrit" created="Tue, 12 Dec 2023 05:42:01 +0000"  >&lt;p&gt;&quot;Andreas Dilger &amp;lt;adilger@whamcloud.com&amp;gt;&quot; merged in patch &lt;a href=&quot;https://review.whamcloud.com/c/fs/lustre-release/+/53229/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/c/fs/lustre-release/+/53229/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-17307&quot; title=&quot;osd_dirent_count() keeps multiple threads busy&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-17307&quot;&gt;&lt;del&gt;LU-17307&lt;/del&gt;&lt;/a&gt; mdt: get dirent count by request&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: d0babe6bd8b38cb86875c5e3d92aee4c69986ce9&lt;/p&gt;</comment>
                            <comment id="396543" author="JIRAUSER17900" created="Wed, 13 Dec 2023 03:41:49 +0000"  >&lt;p&gt;2023-12-13: The fix patch landed to master branch.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="78116">LU-17148</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="52253">LU-11025</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </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|i042en:</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>