<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:02:04 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-6654] Race condition in osd_thread_info/osd_iobuf freeing causes GPF/null pointers when running obdfilter-survey</title>
                <link>https://jira.whamcloud.com/browse/LU-6654</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Running obdfilter-survey causes GPF/null pointers&lt;/p&gt;

&lt;p&gt;Current master on CentOS 6.5 crashes when obdfilter is run on RAM disks with GPF or null pointers, always in the same spot.  If I&apos;ve diagnosed this correctly, the RAM disk only matters because it makes the race condition more likely, and is not directly related.&lt;/p&gt;

&lt;p&gt;The stack trace of the crash is always like this:&lt;br/&gt;
&amp;lt;4&amp;gt;RIP: 0010:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff81054691&amp;gt;&amp;#93;&lt;/span&gt;  &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff81054691&amp;gt;&amp;#93;&lt;/span&gt; __wake_up_common+0x31/0x90&lt;br/&gt;
&amp;lt;4&amp;gt;RSP: 0018:ffff88082f285d60  EFLAGS: 00010096&lt;br/&gt;
&amp;lt;4&amp;gt;RAX: 5a5a5a5a5a5a5a42 RBX: ffff880780bcb9b8 RCX: 0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;RDX: 5a5a5a5a5a5a5a5a RSI: 0000000000000003 RDI: ffff880780bcb9b8&lt;br/&gt;
&amp;lt;4&amp;gt;RBP: ffff88082f285da0 R08: 0000000000000000 R09: 0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;R10: 0000000000000001 R11: 000000000000000f R12: 0000000000000282&lt;br/&gt;
&amp;lt;4&amp;gt;R13: ffff880780bcb9c0 R14: 0000000000000000 R15: 0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;FS:  0000000000000000(0000) GS:ffff880028380000(0000) knlGS:0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b&lt;br/&gt;
&amp;lt;4&amp;gt;CR2: 00007f4a594a0060 CR3: 0000000784c0d000 CR4: 00000000000407e0&lt;br/&gt;
&amp;lt;4&amp;gt;DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400&lt;br/&gt;
&amp;lt;4&amp;gt;Process loop2 (pid: 1677, threadinfo ffff88082f284000, task ffff880831376080)&lt;br/&gt;
&amp;lt;4&amp;gt;Stack:&lt;br/&gt;
&amp;lt;4&amp;gt; ffff880780bcb9b8 0000000300000001 ffff88082e570f58 ffff880780bcb9b8&lt;br/&gt;
&amp;lt;4&amp;gt;&amp;lt;d&amp;gt; 0000000000000282 0000000000000003 0000000000000001 0000000000000000&lt;br/&gt;
&amp;lt;4&amp;gt;&amp;lt;d&amp;gt; ffff88082f285de0 ffffffff81058bc8 ffff88082d851cc0 ffff880833361800&lt;br/&gt;
&amp;lt;4&amp;gt;Call Trace:&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff81058bc8&amp;gt;&amp;#93;&lt;/span&gt; __wake_up+0x48/0x70&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffffa1390e80&amp;gt;&amp;#93;&lt;/span&gt; dio_complete_routine+0x1a0/0x380 &lt;span class=&quot;error&quot;&gt;&amp;#91;osd_ldiskfs&amp;#93;&lt;/span&gt;&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff811c314d&amp;gt;&amp;#93;&lt;/span&gt; bio_endio+0x1d/0x40&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8137d33f&amp;gt;&amp;#93;&lt;/span&gt; loop_thread+0xdf/0x270&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8109afa0&amp;gt;&amp;#93;&lt;/span&gt; ? autoremove_wake_function+0x0/0x40&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8137d260&amp;gt;&amp;#93;&lt;/span&gt; ? loop_thread+0x0/0x270&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8109abf6&amp;gt;&amp;#93;&lt;/span&gt; kthread+0x96/0xa0&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8100c20a&amp;gt;&amp;#93;&lt;/span&gt; child_rip+0xa/0x20&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8109ab60&amp;gt;&amp;#93;&lt;/span&gt; ? kthread+0x0/0xa0&lt;br/&gt;
&amp;lt;4&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;lt;ffffffff8100c200&amp;gt;&amp;#93;&lt;/span&gt; ? child_rip+0x0/0x20&lt;/p&gt;

&lt;p&gt;Note the freed memory in RAX/RDX.  These are sometimes other invalid pointers, rather than freed memory.&lt;/p&gt;

&lt;p&gt;Here&apos;s the race that&apos;s causing this.&lt;/p&gt;

&lt;p&gt;In dio_complete_routine, which is called in one the &apos;loop&apos; threads, we have this sequence:&lt;br/&gt;
        if (atomic_dec_and_test(&amp;amp;iobuf-&amp;gt;dr_numreqs))&lt;br/&gt;
                wake_up(&amp;amp;iobuf-&amp;gt;dr_wait);&lt;/p&gt;

&lt;p&gt;The corresponding wait (for one of the &apos;lctl&apos; threads) is this:&lt;br/&gt;
        wait_event(iobuf-&amp;gt;dr_wait,&lt;br/&gt;
                       atomic_read(&amp;amp;iobuf-&amp;gt;dr_numreqs) == 0);&lt;/p&gt;

&lt;p&gt;Once this wait has completed, things roll up, and, eventually, the struct &apos;osd_thread_info&apos; containing this &apos;iobuf&apos; is freed.&lt;/p&gt;

&lt;p&gt;The bug (which is easily repeatable) is this:&lt;br/&gt;
&apos;loop&apos;, in dio_complete_routine, arrives at &apos;atomic_dec_and_test&apos; and succesfull reduces numreqs to 0.  The thread is then delayed for some reason or another.&lt;br/&gt;
&apos;lctl&apos;, the other thread, arrives at the &apos;wait_event&apos;, and passes the condition, because dr_numreqs is already 0.&lt;br/&gt;
&apos;lctl&apos; then continues on and, eventually, the osd_thread_info containing the iobuf is freed.&lt;/p&gt;

&lt;p&gt;Then the first thread goes and &apos;wake_up&apos; is called, except that the wait queue has been freed.&lt;br/&gt;
This very quickly leads to a GPF/null pointer exception.&lt;/p&gt;

&lt;p&gt;I&apos;ve given a fair bit of thought to this, and I don&apos;t see a terribly clean way to fix this.  The fundamental problem, I think, is that the osd_thread_info is supposed to be thread specific information &amp;amp; it&apos;s being used to hold a wait queue that&apos;s used by another thread.&lt;/p&gt;

&lt;p&gt;I&apos;ve created a patch which allocates the iobuf separately from the osd_thread_info, and uses a spinlock in the thread info to prevent the race condition.&lt;/p&gt;

&lt;p&gt;We&apos;ve confirmed this fixes the problem in our testing, but I&apos;m not sure I like the approach.  I am very open to suggestions for different fixes.&lt;/p&gt;

&lt;p&gt;I will also attach logs and a dmesg showing the crash (with some extra debug info the logs).  I can provide a dump if requested.&lt;br/&gt;
In the case in the attached logs, the two racing threads are 1677 - loop2 - and 5188, one of the lctl threads.&lt;/p&gt;

&lt;p&gt;In the attached logs, thread 1677 logs &quot;wakeup&quot;, which is printed &lt;b&gt;before&lt;/b&gt; the wakeup call, then for whatever reason it is delayed.  When it starts up again, it is in the actual wakeup call and causes the kernel panic.  (As 5188 has freed the osd_thread_info struct containing the iobuf &amp;amp; wait queue.)&lt;/p&gt;</description>
                <environment>CentOS 6.5, current master or 2.7.0.  Probably earlier versions as well.</environment>
        <key id="30394">LU-6654</key>
            <summary>Race condition in osd_thread_info/osd_iobuf freeing causes GPF/null pointers when running obdfilter-survey</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="hongchao.zhang">Hongchao Zhang</assignee>
                                    <reporter username="paf">Patrick Farrell</reporter>
                        <labels>
                            <label>patch</label>
                    </labels>
                <created>Wed, 27 May 2015 16:01:37 +0000</created>
                <updated>Thu, 12 Oct 2017 07:46:45 +0000</updated>
                                            <version>Lustre 2.7.0</version>
                    <version>Lustre 2.8.0</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>11</watches>
                                                                            <comments>
                            <comment id="116550" author="gerrit" created="Wed, 27 May 2015 16:31:54 +0000"  >&lt;p&gt;Patrick Farrell (paf@cray.com) uploaded a new patch: &lt;a href=&quot;http://review.whamcloud.com/14963&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/14963&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6654&quot; title=&quot;Race condition in osd_thread_info/osd_iobuf freeing causes GPF/null pointers when running obdfilter-survey&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6654&quot;&gt;LU-6654&lt;/a&gt; osd: Add osd_iobuf concurrency control&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 38fea9ef2c27f82ed3aec54843d2367a3847c687&lt;/p&gt;</comment>
                            <comment id="134245" author="cfaber" created="Mon, 23 Nov 2015 16:47:32 +0000"  >&lt;p&gt;Has this patch been abandoned? I see no activity on it for a long time.&lt;/p&gt;</comment>
                            <comment id="138202" author="hongchao.zhang" created="Thu, 7 Jan 2016 14:51:13 +0000"  >&lt;p&gt;The patch &lt;a href=&quot;http://review.whamcloud.com/14963&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/14963&lt;/a&gt; has been updated.&lt;/p&gt;</comment>
                            <comment id="138547" author="jaylan" created="Mon, 11 Jan 2016 19:41:52 +0000"  >&lt;p&gt;Would there be a newer update given Patrick Farrell&apos;s comment on patchset #2 on Jan 7th?&lt;/p&gt;</comment>
                            <comment id="138676" author="paf" created="Tue, 12 Jan 2016 16:03:26 +0000"  >&lt;p&gt;Jay - Hongchao wrote a new patch (and took the time to do it right, unlike me &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>
                            <comment id="138708" author="jaylan" created="Tue, 12 Jan 2016 19:06:12 +0000"  >&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="138762" author="jaylan" created="Wed, 13 Jan 2016 01:26:22 +0000"  >&lt;p&gt;Could you port your patch to b2_5_fe please? The difference are not trivial. Thank!&lt;/p&gt;</comment>
                            <comment id="138862" author="jaylan" created="Wed, 13 Jan 2016 23:43:08 +0000"  >&lt;p&gt;Oops, my bad! I tried to apply to wrong repo. No need back port to b2_5_fe.&lt;/p&gt;

&lt;p&gt;What I need the patch for is b2_7_fe. I noticed that the osd_key_fini() in b2_7_fe missed the codes related to idc. Not sure if your patch depends on earlier patches that added chunk of codes related toe idc. Please advise or provide me a patch for b2_7_fe. &lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="139556" author="bzzz" created="Thu, 21 Jan 2016 13:37:39 +0000"  >&lt;p&gt;I&apos;d think that using RCU (i.e. late deallocation) could make the patch a bit simpler.&lt;/p&gt;</comment>
                            <comment id="140781" author="gerrit" created="Tue, 2 Feb 2016 11:02:43 +0000"  >&lt;p&gt;Hongchao Zhang (hongchao.zhang@intel.com) uploaded a new patch: &lt;a href=&quot;http://review.whamcloud.com/18257&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/18257&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-6654&quot; title=&quot;Race condition in osd_thread_info/osd_iobuf freeing causes GPF/null pointers when running obdfilter-survey&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-6654&quot;&gt;LU-6654&lt;/a&gt; osd: add RCU lock on osd_thread_info&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 280c9392bebb4407bd4c61d0675d62772134c743&lt;/p&gt;</comment>
                            <comment id="154554" author="adilger" created="Fri, 3 Jun 2016 08:48:13 +0000"  >&lt;p&gt;Hongchao, how does your patch relate to  &lt;a href=&quot;http://review.whamcloud.com/14963&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/14963&lt;/a&gt; ?  &lt;/p&gt;</comment>
                            <comment id="174856" author="paf" created="Wed, 23 Nov 2016 16:57:49 +0000"  >&lt;p&gt;I&apos;m just posting to &apos;bump&apos; this and repeat the question from Andreas:&lt;/p&gt;

&lt;p&gt;&quot;Hongchao, how does your patch relate to &lt;a href=&quot;http://review.whamcloud.com/14963&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/14963&lt;/a&gt; ? &quot;&lt;/p&gt;

&lt;p&gt;It would be nice to get one of these patches landed.  They seem to achieve the same thing, though RCU is probably more efficient.&lt;/p&gt;</comment>
                            <comment id="210418" author="spitzcor" created="Thu, 5 Oct 2017 18:48:17 +0000"  >&lt;p&gt;We let this one sit for a year.  Does Patrick need to refresh his original patch or what?&lt;/p&gt;</comment>
                            <comment id="210782" author="adilger" created="Wed, 11 Oct 2017 02:34:15 +0000"  >&lt;p&gt;Patrick&apos;s patch is outdated and no longer applies cleanly.&#160; It would need to be updated to land.&lt;/p&gt;

&lt;p&gt;Hongchao, can you and Patrick please come to a conclusion about your patches, and get at least one of them landed.&lt;/p&gt;</comment>
                            <comment id="210824" author="paf" created="Wed, 11 Oct 2017 16:03:52 +0000"  >&lt;p&gt;Sure.&lt;/p&gt;

&lt;p&gt;I think we should probably just land &lt;a href=&quot;https://review.whamcloud.com/#/c/14963/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/14963/&lt;/a&gt;, which is the first patch from Hongchao.  (Mine definitely shouldn&apos;t land.)  RCU is more efficient, sure, but it&apos;s also more complex.  I&apos;d leave RCU out unless we&apos;re sure we need it.&lt;/p&gt;</comment>
                            <comment id="210918" author="spitzcor" created="Thu, 12 Oct 2017 01:42:55 +0000"  >&lt;p&gt;Patrick, you have me confused.  You contributed PS1 of #14963 and Hongchao Zhang uploaded PS1 of #18257.  You say that yours shouldn&apos;t land and that RCU should stay out of it, but #18257 is the one with RCU.&lt;/p&gt;

&lt;p&gt;I think you want to land #14963, which was your patch originally.  Hongchao, will you take that over and refresh it again?  If we all agree, #18257 should be abandoned.&lt;/p&gt;</comment>
                            <comment id="210924" author="hongchao.zhang" created="Thu, 12 Oct 2017 07:46:45 +0000"  >&lt;p&gt;the patch &lt;a href=&quot;https://review.whamcloud.com/#/c/14963/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/14963/&lt;/a&gt; has been updated.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="17974" name="logs_dmesg.tar.gz" size="1642453" author="paf" created="Wed, 27 May 2015 16:01:37 +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|hzxebr:</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>