<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:26:40 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-9491] v2.9: silent data corruption with writev() and O_APPEND</title>
                <link>https://jira.whamcloud.com/browse/LU-9491</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Lustre client version 2.9.0 will silently corrupt data if:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;a file is opened with mode O_APPEND, and&lt;/li&gt;
	&lt;li&gt;is written to using the writev() syscall using two or more iovs, and&lt;/li&gt;
	&lt;li&gt;the file offset written to by any but the last iov touches a page boundary.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;If all of the above hold true, the last iov overwrites some or all data from the previous iovs. It can be easily reproduces with eg.&lt;/p&gt;

&lt;p&gt;/usr/lib64/lustre/tests/rwv -w -a -n 2 4096 4096 /lustre/test131.out&lt;/p&gt;

&lt;p&gt;On a Lustre client running v2.9.0, the first chunk is lost, and test.out ends up as a 4k-sized file. Earlier versions create an 8k-sized test.out containing both chunks. In both cases, the writev() syscall returns 8192, indicating that the complete data set had been written.&lt;/p&gt;

&lt;p&gt;Test 131b from sanity.sh already triggers this bug. It only checks return codes, but doesn&apos;t verify the written file, and therefore currently won&apos;t catch the error. (Obvious patch to follow.)&lt;/p&gt;

&lt;p&gt;A git bisect run revealed that commit 1101120d3258509fa74f952cd8664bfdc17bd97d (&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-4257&quot; title=&quot;parallel dds are slower than serial dds&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-4257&quot;&gt;&lt;del&gt;LU-4257&lt;/del&gt;&lt;/a&gt; llite: fix up iov_iter implementation) had introduced the error. So far, I&apos;ve verified that v2.9.0 is affected on both RHEL6 and RHEL7, both of which use the various &lt;tt&gt;iov_iter_&amp;#42;()&lt;/tt&gt; functions from lustre/llite/llite_internal.h introduced by this changeset. There&apos;s a chance that more recent kernel versions that implement &lt;tt&gt;iov_iter_&amp;#42;()&lt;/tt&gt; themselves are unaffected, but I haven&apos;t been able to check.&lt;/p&gt;

&lt;p&gt;I&apos;ll attach a brief vfstrace from running the rwv reproducer mentioned above. Note the second call to ll_write_begin() logs &quot;Writing 0 of 0 to 4096 bytes&quot; just like the first invocation whereas it should have advanced a page, ie. &quot;Writing 1 of 0 to 4096 bytes&quot; would be the expected output. This means that ll_write_begin() may be called with an incorrect pos field for all but the first iov in the list, but I haven&apos;t been able to pinpoint the spot where it goes wrong.&lt;/p&gt;

&lt;p&gt;If O_APPEND is dropped from the open() call (ie. rwv is called without the -a switch), everything works fine, and the second call to ll_write_begin() indeed logs &quot;Writing 1 of 0 to 4096 bytes&quot; as expected.&lt;/p&gt;</description>
                <environment>RHEL6&lt;br/&gt;
RHEL7</environment>
        <key id="46033">LU-9491</key>
            <summary>v2.9: silent data corruption with writev() and O_APPEND</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="jay">Jinshan Xiong</assignee>
                                    <reporter username="kobras">Daniel Kobras</reporter>
                        <labels>
                    </labels>
                <created>Thu, 11 May 2017 16:02:50 +0000</created>
                <updated>Fri, 3 May 2019 17:25:57 +0000</updated>
                            <resolved>Sat, 20 May 2017 19:25:11 +0000</resolved>
                                    <version>Lustre 2.8.0</version>
                    <version>Lustre 2.9.0</version>
                                    <fixVersion>Lustre 2.10.0</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>7</watches>
                                                                            <comments>
                            <comment id="195514" author="kobras" created="Thu, 11 May 2017 17:04:09 +0000"  >&lt;p&gt;Sorry, mistyped the command line for the reproducer. Correct sequence of options is:&lt;/p&gt;

&lt;p&gt;/usr/lib64/lustre/tests/rwv -f /lustre/test131.out -w -a -n 2 4096 4096&lt;/p&gt;</comment>
                            <comment id="195529" author="pjones" created="Thu, 11 May 2017 17:25:18 +0000"  >&lt;p&gt;Jinshan&lt;/p&gt;

&lt;p&gt;Can you please look into this issue?&lt;/p&gt;

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

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="195532" author="kobras" created="Thu, 11 May 2017 17:36:50 +0000"  >&lt;p&gt;Reverting the changes to vvp_io_write_start() in 1101120d3258509fa74f952cd8664bfdc17bd97d fixes the issue for me.&lt;/p&gt;</comment>
                            <comment id="195582" author="gerrit" created="Thu, 11 May 2017 22:59:18 +0000"  >&lt;p&gt;Jinshan Xiong (jinshan.xiong@intel.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/27086&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/27086&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-9491&quot; title=&quot;v2.9: silent data corruption with writev() and O_APPEND&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-9491&quot;&gt;&lt;del&gt;LU-9491&lt;/del&gt;&lt;/a&gt; llite: Handle multi-vec append write correctly&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 9a231894578dcecb1ad7280f235ffaa0b7d18447&lt;/p&gt;</comment>
                            <comment id="195651" author="kobras" created="Fri, 12 May 2017 12:33:43 +0000"  >&lt;p&gt;Thanks! With 9a231894578dcecb1ad7280f235ffaa0b7d18447 on top of 2.9.0, I was unable to reproduce the problem. So this looks good!&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;That said, after staring at __generic_file_aio_write() and descendants for a while, the need for the added complexity in llite_internal&apos;s __generic_file_write_iter() still isn&apos;t clear to me. Just wrapping it like&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;static&lt;/span&gt; inline ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
{
       &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; __generic_file_aio_write(iocb, iter-&amp;gt;iov, iter-&amp;gt;nr_segs, &amp;amp;iocb-&amp;gt;ki_pos);
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;matches the old code prior to 1101120d3258509fa74f952cd8664bfdc17bd97d, and doesn&apos;t look less efficient. Why the need to iterate in __generic_file_write_iter() ourselves in the general (non-O_APPEND) case, rather than relying on common code that already seems to do the right thing?&lt;/p&gt;</comment>
                            <comment id="195708" author="jay" created="Fri, 12 May 2017 17:29:43 +0000"  >&lt;p&gt;The &lt;tt&gt;iov_offset&lt;/tt&gt; of &lt;tt&gt;iov_iter&lt;/tt&gt; could not be zero then your proposal will write wrong data to file. The old way worked because it manipulated &lt;tt&gt;iovec&lt;/tt&gt; in I/O stack.&lt;/p&gt;</comment>
                            <comment id="195918" author="adilger" created="Mon, 15 May 2017 23:50:47 +0000"  >&lt;p&gt;A very good test of this code is &lt;tt&gt;write_append_truncate&lt;/tt&gt;, though it needs MPI to run.  That said, it doesn&apos;t look like it triggered this problem because it isn&apos;t using writev().&lt;/p&gt;</comment>
                            <comment id="196547" author="gerrit" created="Sat, 20 May 2017 18:44:17 +0000"  >&lt;p&gt;Oleg Drokin (oleg.drokin@intel.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/27086/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/27086/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-9491&quot; title=&quot;v2.9: silent data corruption with writev() and O_APPEND&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-9491&quot;&gt;&lt;del&gt;LU-9491&lt;/del&gt;&lt;/a&gt; llite: Handle multi-vec append write correctly&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 6352eb778d032d99e2a87e4d8b3a5562b585e752&lt;/p&gt;</comment>
                            <comment id="196557" author="pjones" created="Sat, 20 May 2017 19:25:11 +0000"  >&lt;p&gt;Landed for 2.10&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="31816">LU-7067</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="22045">LU-4257</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="26664" name="writev_append.debug" size="7717" author="kobras" created="Thu, 11 May 2017 16:02:20 +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_10040" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Epic</customfieldname>
                        <customfieldvalues>
                                        <label>client</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10030" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Epic/Theme</customfieldname>
                        <customfieldvalues>
                                        <label>lustre-2.9</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzzcin:</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>