<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 03:03:22 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-13689] Replace cdt_state_lock with cdt_llog_lock</title>
                <link>https://jira.whamcloud.com/browse/LU-13689</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Merge cdt_llog_lock and cdt_state_lock and check cdt_state against CDT_STOPPED and CDT_INIT in mdt_agent_record_add(); this should allow for race-free checking of cdt_state with respect to cdt_state transitions and ensure that cdt_last_cookie has been properly set at CDT startup time, before it is used for new requests.&lt;/p&gt;</description>
                <environment></environment>
        <key id="59606">LU-13689</key>
            <summary>Replace cdt_state_lock with cdt_llog_lock</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="nangelinas">Nikitas Angelinas</assignee>
                                    <reporter username="nangelinas">Nikitas Angelinas</reporter>
                        <labels>
                    </labels>
                <created>Wed, 17 Jun 2020 11:47:57 +0000</created>
                <updated>Wed, 12 Oct 2022 19:25:42 +0000</updated>
                                                                                <due></due>
                            <votes>0</votes>
                                    <watches>4</watches>
                                                                            <comments>
                            <comment id="273081" author="gerrit" created="Wed, 17 Jun 2020 11:51:48 +0000"  >&lt;p&gt;Nikitas Angelinas (nikitas.angelinas@hpe.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/38963&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/38963&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-13689&quot; title=&quot;Replace cdt_state_lock with cdt_llog_lock&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-13689&quot;&gt;LU-13689&lt;/a&gt; hsm: replace cdt_state_lock with cdt_llog_lock&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 3123d6498c1310ab5472d44ea255b49aa62bda41&lt;/p&gt;</comment>
                            <comment id="277312" author="nangelinas" created="Wed, 12 Aug 2020 13:56:43 +0000"  >&lt;p&gt;The following shows a reproducer and that the fix addresses the issue:&lt;/p&gt;

&lt;p&gt;Reproducer:&lt;/p&gt;

&lt;p&gt;The reproducer depends on artificially-inserted delays in the relevant code paths to simulate the race condition between the threads. A 10 second delay is inserted in mdt_hsm_cdt_start() after the HSM coordinator is set to CDT_INIT and cdt_last_cookie is reset using ktime_get_real_seconds(), but before mdt_hsm_pending_restore() is called; this allows us to enlarge the race window artificially when restarting the HSM coordinator. A 5 second delay is added in mdt_hsm_add_actions(), after cdt_state is checked against CDT_STOPPED and CDT_INIT, but only after 1000 HSM requests have been handled; this allows the reproducer to enter the race window where cdt_state is checked and gives a small delay during which we can restart the HSM coordinator. Because the request-adding delay is smaller than the coordinator-restarting delay, the request-adding thread in mdt_hsm_add_actions() will check cdt_state and proceed since it is set to CDT_RUNNING. Once 1000 HSM requests have been handled by the HSM coordinator, we try to archive the 1001th request. The 5-second delay allows us to restart the coordinator quickly; this resets cdt_last_cookie. The request-adding thread wakes up quicker than the coordinator-restarting thread since it has a smaller delay and since cdt_last_cookie has not yet been incremented to an unused value by the coordinator-starting thread, it proceeds to add the HSM request to the llog using an already-used cookie value. This leads to the following assertions being hit in cdt_agent_record_hash_add():&lt;/p&gt;

&lt;p&gt;LASSERT(carl0-&amp;gt;carl_cat_idx == carl1-&amp;gt;carl_cat_idx);&lt;br/&gt;
LASSERT(carl0-&amp;gt;carl_rec_idx == carl1-&amp;gt;carl_rec_idx);&lt;/p&gt;

&lt;p&gt;Applying the fix from &lt;a href=&quot;https://review.whamcloud.com/#/c/38963/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/38963/&lt;/a&gt; allows the HSM coordinator to return -EAGAIN, instead of hitting the assertions.&lt;/p&gt;

&lt;p&gt;Steps to reproduce:&lt;/p&gt;

&lt;p&gt;1. Set up a minimal Lustre cluster, one with llmount.sh and cfg/local.sh is sufficient; a copytool is not needed, but lhsmtool_posix can be used&lt;br/&gt;
2. Start the HSM coordinator&lt;br/&gt;
3. Set grace_delay to a large value, e.g. 1200; this allows HSM requests to remain in the llog long enough for the reproducer to take place and cause the assertions to be hit&lt;br/&gt;
4. Create 1001 files&lt;br/&gt;
5. Archive 1000 of the files&lt;br/&gt;
6. Archive the last file; notice that a small delay is incurred. During this delay window, shut down and enable the coordinator&lt;br/&gt;
With a branch derived from somewhat recent master, the following output is observed:&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;# lfs hsm_archive /mnt/lustre/testfile1001
# dmesg -c
...
 kernel:LustreError: 30362:0:(mdt_hsm_cdt_actions.c:139:cdt_agent_record_hash_add()) ASSERTION( carl0-&amp;gt;carl_rec_idx == carl1-&amp;gt;carl_rec_idx ) failed:
 ...
  kernel:LustreError: 30362:0:(mdt_hsm_cdt_actions.c:139:cdt_agent_record_hash_add()) LBUG
  [root@c02sxfm0gtfm-mds1 tests]# dmesg -c
  [19605.583099] LustreError: 30362:0:(mdt_hsm_cdt_actions.c:139:cdt_agent_record_hash_add()) ASSERTION( carl0-&amp;gt;carl_rec_idx == carl1-&amp;gt;carl_rec_idx ) failed:
  [19605.583105] LustreError: 30362:0:(mdt_hsm_cdt_actions.c:139:cdt_agent_record_hash_add()) LBUG
  [19605.583107] Pid: 30362, comm: hsm_cdtr 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019
  [19605.583108] Call Trace:
  [19605.583121]  [&amp;lt;ffffffffc06557cc&amp;gt;] libcfs_call_trace+0x8c/0xc0 [libcfs]
  [19605.583131]  [&amp;lt;ffffffffc065587c&amp;gt;] lbug_with_loc+0x4c/0xa0 [libcfs]
  [19605.583136]  [&amp;lt;ffffffffc11a64f5&amp;gt;] cdt_agent_record_hash_add+0x355/0x3c0 [mdt]
  [19605.583154]  [&amp;lt;ffffffffc11b2969&amp;gt;] mdt_cdt_waiting_cb.isra.26+0x729/0xcc0 [mdt]
  [19605.583167]  [&amp;lt;ffffffffc11b4772&amp;gt;] mdt_coordinator_cb+0x162/0x290 [mdt]
  [19605.583180]  [&amp;lt;ffffffffc07d37ff&amp;gt;] llog_process_thread+0x85f/0x1a20 [obdclass]
  [19605.583199]  [&amp;lt;ffffffffc07d4a8f&amp;gt;] llog_process_or_fork+0xcf/0x520 [obdclass]
  [19605.583210]  [&amp;lt;ffffffffc07da1b9&amp;gt;] llog_cat_process_cb+0x239/0x250 [obdclass]
  [19605.583222]  [&amp;lt;ffffffffc07d37ff&amp;gt;] llog_process_thread+0x85f/0x1a20 [obdclass]
  [19605.583234]  [&amp;lt;ffffffffc07d4a8f&amp;gt;] llog_process_or_fork+0xcf/0x520 [obdclass]
  [19605.583245]  [&amp;lt;ffffffffc07d6911&amp;gt;] llog_cat_process_or_fork+0x1f1/0x370 [obdclass]
  [19605.583256]  [&amp;lt;ffffffffc07d6abe&amp;gt;] llog_cat_process+0x2e/0x30 [obdclass]
  [19605.583268]  [&amp;lt;ffffffffc11a6a26&amp;gt;] cdt_llog_process+0xc6/0x3a0 [mdt]
  [19605.583280]  [&amp;lt;ffffffffc11b06d1&amp;gt;] mdt_coordinator+0x541/0x19f0 [mdt]
  [19605.583291]  [&amp;lt;ffffffff8ccc61f1&amp;gt;] kthread+0xd1/0xe0
  [19605.583296]  [&amp;lt;ffffffff8d38dd37&amp;gt;] ret_from_fork_nospec_end+0x0/0x39
  [19605.583300]  [&amp;lt;ffffffffffffffff&amp;gt;] 0xffffffffffffffff
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;An LBUG can be triggered due to this issue in cdt_agent_record_hash_add() on either carl_cat_idx or carl_rec_idx (as shown in the example above) depending on whether the two llog entries are in the same catalog entry or not. With the fix from &lt;a href=&quot;https://review.whamcloud.com/#/c/38963/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/38963/&lt;/a&gt; applied, this same code allows the MDT to return -EAGAIN, instead of triggering one of the two LBUGs:&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;# lfs hsm_archive /mnt/lustre/testfile1000
Cannot send HSM request (use of /mnt/lustre/testfile1000): Resource temporarily unavailable
# dmesg -c
[  385.347189] Lustre: lustre-OST0000-osc-ffff97ad8ac4a800: reconnect after 16s idle
[  385.347324] Lustre: lustre-OST0000: Connection restored to b3fb17d8-3cf4-5172-6801-684ff0fc684a (at 192.168.42.90@tcp)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-EAGAIN is returned from the following change that the fix introduces in mdt_agent_record_add():&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;if ((cdt-&amp;gt;cdt_state == CDT_STOPPED || cdt-&amp;gt;cdt_state == CDT_INIT) &amp;amp;&amp;amp;
	    !(flags &amp;amp; HAL_CDT_FORCE))
		GOTO(unavail, rc = -EAGAIN);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="72775">LU-16235</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="54046">LU-11675</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="64861">LU-14793</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|i012yn:</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>