<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:22:35 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-2127] Confusing messages from osc_announce_cached() caused by unchecked signed/unsigned comparison</title>
                <link>https://jira.whamcloud.com/browse/LU-2127</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Some examples, taken for convenience from &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1153&quot; title=&quot;Client Unresponsive&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1153&quot;&gt;&lt;del&gt;LU-1153&lt;/del&gt;&lt;/a&gt; logs but which are very frequent on T100 site :&lt;br/&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;Feb 28 09:37:28 compute-01-32 kernel: LustreError: 2567:0:(osc_request.c:797:osc_announce_cached()) dirty 2028 - 2028 &amp;gt; system dirty_max 647168
Feb 28 09:37:40 compute-01-32 kernel: LustreError: 2568:0:(osc_request.c:797:osc_announce_cached()) dirty 2040 - 2040 &amp;gt; system dirty_max 647168
Feb 28 09:37:46 compute-01-32 kernel: LustreError: 2565:0:(osc_request.c:797:osc_announce_cached()) dirty 1954 - 1954 &amp;gt; system dirty_max 647168
Feb 28 09:37:47 compute-01-32 kernel: LustreError: 2561:0:(osc_request.c:797:osc_announce_cached()) dirty 1975 - 1976 &amp;gt; system dirty_max 647168
Feb 28 09:37:50 compute-01-32 kernel: LustreError: 2566:0:(osc_request.c:797:osc_announce_cached()) dirty 2001 - 2002 &amp;gt; system dirty_max 647168
Feb 28 09:38:09 compute-01-32 kernel: LustreError: 2567:0:(osc_request.c:797:osc_announce_cached()) dirty 1946 - 1946 &amp;gt; system dirty_max 647168
Feb 28 09:39:20 compute-01-32 kernel: LustreError: 2615:0:(osc_request.c:797:osc_announce_cached()) dirty 2017 - 2017 &amp;gt; system dirty_max 647168
Feb 28 09:39:47 compute-01-32 kernel: LustreError: 2615:0:(osc_request.c:797:osc_announce_cached()) dirty 1847 - 1848 &amp;gt; system dirty_max 647168
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;=================================================================================================&lt;/p&gt;

&lt;p&gt;this comes from the following piece of code :&lt;br/&gt;
=============================================&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;.       } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (cfs_atomic_read(&amp;amp;obd_dirty_pages) -
                   cfs_atomic_read(&amp;amp;obd_dirty_transit_pages) &amp;gt;
                   obd_max_dirty_pages + 1){
                /* The cfs_atomic_read() allowing the cfs_atomic_inc() are
                 * not covered by a lock thus they may safely race and trip
                 * &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; CERROR() unless we add in a small fudge factor (+1). */
                CERROR(&lt;span class=&quot;code-quote&quot;&gt;&quot;dirty %d - %d &amp;gt; system dirty_max %d\n&quot;&lt;/span&gt;,
                       cfs_atomic_read(&amp;amp;obd_dirty_pages),
                       cfs_atomic_read(&amp;amp;obd_dirty_transit_pages),
                       obd_max_dirty_pages);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;=============================================&lt;/p&gt;

&lt;p&gt;where both obd_dirty_pages/obd_dirty_transit_pages are &quot;likely to change&quot; signed ints and obd_max_dirty_pages unsigned which an easily explain the wrong error msgs ...&lt;/p&gt;

&lt;p&gt;This is still true in current master and, if I am right and there is no tricky stuff I may have missed there ..., the following patch should fix :&lt;br/&gt;
==================================================================================================================================================&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;diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index af60e4b..5f75329 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -788,6 +788,7 @@ &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
                                 &lt;span class=&quot;code-object&quot;&gt;long&lt;/span&gt; writing_bytes)
 {
         obd_flag bits = OBD_MD_FLBLOCKS|OBD_MD_FLGRANT;
+        &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; diff;
 
         LASSERT(!(oa-&amp;gt;o_valid &amp;amp; bits));
 
@@ -798,9 +799,9 @@ &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
                 CERROR(&lt;span class=&quot;code-quote&quot;&gt;&quot;dirty %lu - %lu &amp;gt; dirty_max %lu\n&quot;&lt;/span&gt;,
                        cli-&amp;gt;cl_dirty, cli-&amp;gt;cl_dirty_transit, cli-&amp;gt;cl_dirty_max);
                 oa-&amp;gt;o_undirty = 0;
-        } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (cfs_atomic_read(&amp;amp;obd_dirty_pages) -
-                   cfs_atomic_read(&amp;amp;obd_dirty_transit_pages) &amp;gt;
-                   obd_max_dirty_pages + 1){
+        } &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (((diff = (cfs_atomic_read(&amp;amp;obd_dirty_pages) -
+                   cfs_atomic_read(&amp;amp;obd_dirty_transit_pages))) &amp;gt;
+                   obd_max_dirty_pages + 1) &amp;amp;&amp;amp; (diff &amp;gt; 0)){
                 /* The cfs_atomic_read() allowing the cfs_atomic_inc() are
                  * not covered by a lock thus they may safely race and trip
                  * &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; CERROR() unless we add in a small fudge factor (+1). */
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;==================================================================================================================================================&lt;/p&gt;
</description>
                <environment></environment>
        <key id="16300">LU-2127</key>
            <summary>Confusing messages from osc_announce_cached() caused by unchecked signed/unsigned comparison</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="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="louveta">Alexandre Louvet</reporter>
                        <labels>
                            <label>mq213</label>
                    </labels>
                <created>Tue, 9 Oct 2012 12:40:51 +0000</created>
                <updated>Mon, 25 Feb 2013 11:10:54 +0000</updated>
                            <resolved>Mon, 25 Feb 2013 11:10:54 +0000</resolved>
                                                    <fixVersion>Lustre 2.4.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>7</watches>
                                                                            <comments>
                            <comment id="46261" author="bfaccini" created="Tue, 9 Oct 2012 13:29:31 +0000"  >&lt;p&gt;Oops, sorry for the wrong formating, don&apos;t know what happen exactly but seems the starting +/- characters of each patch line did put the tool/inputs into some trouble ...&lt;/p&gt;

&lt;p&gt;Anyway, I can push my patch to master but I just want to get some feedback before ...&lt;/p&gt;</comment>
                            <comment id="46270" author="adilger" created="Tue, 9 Oct 2012 15:19:40 +0000"  >&lt;p&gt;Bruno,&lt;br/&gt;
thanks for the bug report and proposed fix.&lt;/p&gt;

&lt;p&gt;The Lustre coding style discourages the use of assignments inside conditionals, because it can lead to hard-to-find bugs in the code.  Since we always expect the &quot;diff&quot; calculation to be needed, except in the very rare case that the first &quot;if&quot; condition is true, then it would be fine to compute &quot;diff&quot; before all of the checks.&lt;/p&gt;

&lt;p&gt;I think it would also be possible to avoid this error my casting &lt;tt&gt;(long)obd_max_dirty_pages&lt;/tt&gt; so that it is doing a signed comparison.  This avoids adding a second check into the code and an extra variable on the stack and I think makes it more clear.&lt;/p&gt;

&lt;p&gt;Also, I think while this code is being changed that a few more cleanups could be done here:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;add space between &apos;){&apos; at the end of the &quot;else if&quot; line in question&lt;/li&gt;
	&lt;li&gt;the first 3 cases should be annotated with unlikely(), since they are error cases that shouldn&apos;t happen&lt;/li&gt;
	&lt;li&gt;use tabs instead of spaces for indentation for modified lines and neighboring lines&lt;/li&gt;
	&lt;li&gt;wrap long line (max_in_flight) at 80 characters&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="46284" author="pjones" created="Tue, 9 Oct 2012 18:07:06 +0000"  >&lt;p&gt;Bruno&lt;/p&gt;

&lt;p&gt;Thanks again for the suggested change. Could you please submit the next version of the code into gerrit so we can test and land it?&lt;/p&gt;

&lt;p&gt;Keith&lt;/p&gt;

&lt;p&gt;Could you please help see this through to landing?&lt;/p&gt;

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

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="46349" author="bfaccini" created="Wed, 10 Oct 2012 19:20:17 +0000"  >&lt;p&gt;Thank&apos;s for these hints Andreas !!&lt;/p&gt;

&lt;p&gt;My 1st patch version was definitelly to request feedback on the best/preferred way to fix &lt;br/&gt;
and BTW later running the &quot;build/checkpatch.pl&quot; script was scheduled in order to ensure &lt;br/&gt;
beautifying the patch. But seems that the osc_request.c module, at least the original &lt;br/&gt;
osc_announce_cached() routine lines, did not follow the space/tab rules already...&lt;/p&gt;


&lt;p&gt;In fact, the real question I had in mind was use the (cast) for obd_max_dirty_pages or &lt;br/&gt;
check that the difference did not become negative, because I personnaly don&apos;t like to use &lt;br/&gt;
sign/size-casts because they always look tricky for me and that&apos;s why I proposed the 2nd way.&lt;/p&gt;

&lt;p&gt;But anyway, patch has been pushed to master as &lt;a href=&quot;http://review.whamcloud.com/4246&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/4246&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I asked Andreas to review my patch for sure, but since it seems I need 2 reviewers, Keith can I ask you to review ??&lt;/p&gt;</comment>
                            <comment id="52965" author="paf" created="Mon, 25 Feb 2013 10:47:27 +0000"  >&lt;p&gt;I see this is in 2.4.&lt;/p&gt;

&lt;p&gt;This also applies to earlier 2.x versions - It might be worth pushing the patch to those as well.&lt;/p&gt;</comment>
                            <comment id="52968" author="pjones" created="Mon, 25 Feb 2013 11:10:54 +0000"  >&lt;p&gt;Landed for 2.4 and yes this is a candidate for inclusion in an upcoming 2.1.x release&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|hzv9uf:</customfieldvalue>

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