<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:29:05 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-2889] There&apos;s a race between starting and stopping service threads</title>
                <link>https://jira.whamcloud.com/browse/LU-2889</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;When ptlrpc_start_thread fails to create a new thread, it will finalize and free a struct ptlrpc_thread created and used here. Considering this, it can be problem when ptlrpc_svcpt_stop_thread is driven and handles the struct ptlrpc_thread right after or right before failure of cfs_create_thread. &lt;/p&gt;

&lt;p&gt;This situation let the both of ptlrpc_start_thread and ptlrpc_svcpt_stop_threads access the freed ptlrpc_thread and cause OS panic.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;ptlrpc_thread_start&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; wait)
{
        ...

        spin_lock(&amp;amp;svcpt-&amp;gt;scp_lock);

        ...

        cfs_list_add(&amp;amp;thread-&amp;gt;t_link, &amp;amp;svcpt-&amp;gt;scp_threads);
        spin_unlock(&amp;amp;svcpt-&amp;gt;scp_lock);

        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (svcpt-&amp;gt;scp_cpt &amp;gt;= 0) {
                snprintf(thread-&amp;gt;t_name, PTLRPC_THR_NAME_LEN, &lt;span class=&quot;code-quote&quot;&gt;&quot;%s%02d_%03d&quot;&lt;/span&gt;,
                         svc-&amp;gt;srv_thread_name, svcpt-&amp;gt;scp_cpt, thread-&amp;gt;t_id);
        } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; {
                snprintf(thread-&amp;gt;t_name, PTLRPC_THR_NAME_LEN, &lt;span class=&quot;code-quote&quot;&gt;&quot;%s_%04d&quot;&lt;/span&gt;,
                         svc-&amp;gt;srv_thread_name, thread-&amp;gt;t_id);
        }

        CDEBUG(D_RPCTRACE, &lt;span class=&quot;code-quote&quot;&gt;&quot;starting thread &lt;span class=&quot;code-quote&quot;&gt;&apos;%s&apos;&lt;/span&gt;\n&quot;&lt;/span&gt;, thread-&amp;gt;t_name);
        /*
         * CLONE_VM and CLONE_FILES just avoid a needless copy, because we
         * just drop the VM and FILES in cfs_daemonize_ctxt() right away.
         */
        rc = cfs_create_thread(ptlrpc_main, thread, CFS_DAEMON_FLAGS);
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (rc &amp;lt; 0) {
                CERROR(&lt;span class=&quot;code-quote&quot;&gt;&quot;cannot start thread &lt;span class=&quot;code-quote&quot;&gt;&apos;%s&apos;&lt;/span&gt;: rc %d\n&quot;&lt;/span&gt;,
                       thread-&amp;gt;t_name, rc); 
                                            &lt;span class=&quot;code-comment&quot;&gt;//////////////////////////////////////
&lt;/span&gt;                                            &lt;span class=&quot;code-comment&quot;&gt;// &amp;lt;---- let&apos;s say when
&lt;/span&gt;                                            &lt;span class=&quot;code-comment&quot;&gt;// ptlrpc_svcpt_stop_thread is driven here
&lt;/span&gt;                                            &lt;span class=&quot;code-comment&quot;&gt;//////////////////////////////////////
&lt;/span&gt;                spin_lock(&amp;amp;svcpt-&amp;gt;scp_lock);
                cfs_list_del(&amp;amp;thread-&amp;gt;t_link);
                --svcpt-&amp;gt;scp_nthrs_starting;
                spin_unlock(&amp;amp;svcpt-&amp;gt;scp_lock);

                OBD_FREE(thread, sizeof(*thread));
                RETURN(rc);
        }

&#12288;&#12288;&#12288;&#12288;...

}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;ptlrpc_svcpt_stop_threads&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt)
{
        struct l_wait_info      lwi = { 0 };
        struct ptlrpc_thread    *thread;
        CFS_LIST_HEAD           (zombie);

        ENTRY;

        CDEBUG(D_INFO, &lt;span class=&quot;code-quote&quot;&gt;&quot;Stopping threads &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; service %s\n&quot;&lt;/span&gt;,
               svcpt-&amp;gt;scp_service-&amp;gt;srv_name);

        spin_lock(&amp;amp;svcpt-&amp;gt;scp_lock);
        &lt;span class=&quot;code-comment&quot;&gt;/* let the thread know that we would like it to stop asap */&lt;/span&gt;
        list_for_each_entry(thread, &amp;amp;svcpt-&amp;gt;scp_threads, t_link) {
                CDEBUG(D_INFO, &lt;span class=&quot;code-quote&quot;&gt;&quot;Stopping thread %s #%u\n&quot;&lt;/span&gt;,
                       svcpt-&amp;gt;scp_service-&amp;gt;srv_thread_name, thread-&amp;gt;t_id);
                thread_add_flags(thread, SVC_STOPPING);
        }

        cfs_waitq_broadcast(&amp;amp;svcpt-&amp;gt;scp_waitq);

        &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; (!cfs_list_empty(&amp;amp;svcpt-&amp;gt;scp_threads)) {
                thread = cfs_list_entry(svcpt-&amp;gt;scp_threads.next,
                                        struct ptlrpc_thread, t_link);
                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (thread_is_stopped(thread)) {
                        cfs_list_del(&amp;amp;thread-&amp;gt;t_link);
                        cfs_list_add(&amp;amp;thread-&amp;gt;t_link, &amp;amp;zombie);
                        &lt;span class=&quot;code-keyword&quot;&gt;continue&lt;/span&gt;;
                }
                spin_unlock(&amp;amp;svcpt-&amp;gt;scp_lock);

                CDEBUG(D_INFO, &lt;span class=&quot;code-quote&quot;&gt;&quot;waiting &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; stopping-thread %s #%u\n&quot;&lt;/span&gt;,
                       svcpt-&amp;gt;scp_service-&amp;gt;srv_thread_name, thread-&amp;gt;t_id);
                l_wait_event(thread-&amp;gt;t_ctl_waitq,
                             thread_is_stopped(thread), &amp;amp;lwi);

                spin_lock(&amp;amp;svcpt-&amp;gt;scp_lock);
        }

        spin_unlock(&amp;amp;svcpt-&amp;gt;scp_lock);

        &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; (!cfs_list_empty(&amp;amp;zombie)) {
                thread = cfs_list_entry(zombie.next,
                                        struct ptlrpc_thread, t_link);
                cfs_list_del(&amp;amp;thread-&amp;gt;t_link);
                OBD_FREE_PTR(thread);
        }
        EXIT;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


</description>
                <environment>no specific environment is needed</environment>
        <key id="17734">LU-2889</key>
            <summary>There&apos;s a race between starting and stopping service threads</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.whamcloud.com/images/icons/priorities/critical.svg">Critical</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="keith">Keith Mannthey</assignee>
                                    <reporter username="nozaki">Hiroya Nozaki</reporter>
                        <labels>
                            <label>mn1</label>
                            <label>mn8</label>
                            <label>patch</label>
                    </labels>
                <created>Thu, 28 Feb 2013 01:11:29 +0000</created>
                <updated>Wed, 16 Oct 2013 20:49:10 +0000</updated>
                            <resolved>Wed, 16 Oct 2013 20:49:10 +0000</resolved>
                                    <version>Lustre 2.4.0</version>
                    <version>Lustre 2.1.5</version>
                    <version>Lustre 1.8.9</version>
                                    <fixVersion>Lustre 2.5.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>4</watches>
                                                                            <comments>
                            <comment id="53161" author="nozaki" created="Thu, 28 Feb 2013 01:38:32 +0000"  >&lt;p&gt;The patch for master&lt;br/&gt;
&lt;a href=&quot;http://review.whamcloud.com/#change,5552&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#change,5552&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="53171" author="nozaki" created="Thu, 28 Feb 2013 06:05:22 +0000"  >&lt;p&gt;Here is the patch for b2_1&lt;br/&gt;
&lt;a href=&quot;http://review.whamcloud.com/5557&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/5557&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BTW, I&apos;ll upload the patch for b1_8 after completing the review for b2_1. Because the patch for b1_8 will be almost the same as b2_1&lt;/p&gt;</comment>
                            <comment id="63935" author="keith" created="Fri, 9 Aug 2013 07:29:18 +0000"  >&lt;p&gt;Master patch has been landed. &lt;/p&gt;</comment>
                            <comment id="69163" author="pjones" created="Wed, 16 Oct 2013 20:49:10 +0000"  >&lt;p&gt;Fix landed for 2.5.0. Fix will also be tracked as a candidate for inclusion in any future 1.8.x/2.1.x releases&lt;/p&gt;</comment>
                    </comments>
                    <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|hzvk1j:</customfieldvalue>

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