<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:48:18 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-11944] WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes</title>
                <link>https://jira.whamcloud.com/browse/LU-11944</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Tiny writes to a regular file with setuid enabled results in a warning from notify_change() because the inode is not locked. As the write continues through ll_setattr_raw(), it sometimes hangs trying to lock the inode.&lt;/p&gt;

&lt;p&gt;Warning in console log:&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;2019-01-25T19:30:35.591624-06:00 c0-0c1s10n1 ------------[ cut here ]------------
2019-01-25T19:30:35.591630-06:00 c0-0c1s10n1 WARNING: CPU: 11 PID: 15121 at ../fs/attr.c:212 notify_change+0x398/0x408

2019-01-25T19:30:35.591644-06:00 c0-0c1s10n1 CPU: 11 PID: 15121 Comm: memfill2 Tainted: P        W  O     4.12.14-25.22_5.0.64-cray_ari_c #1 SLE15 (unreleased)
2019-01-25T19:30:35.591649-06:00 c0-0c1s10n1 Hardware name: Cavium Inc. Borg/Unknown, BIOS Cavium reference firmware version 6.3 05/01/2018
2019-01-25T19:30:35.591655-06:00 c0-0c1s10n1 task: ffff80be1a1be100 task.stack: ffff00001bd90000
2019-01-25T19:30:35.591660-06:00 c0-0c1s10n1 PC is at notify_change+0x398/0x408
2019-01-25T19:30:35.591665-06:00 c0-0c1s10n1 LR is at file_remove_privs+0xc4/0xf8
2019-01-25T19:30:35.591671-06:00 c0-0c1s10n1 pc : [&amp;lt;ffff000008271088&amp;gt;] lr : [&amp;lt;ffff0000082703cc&amp;gt;] pstate: 20000009
2019-01-25T19:30:35.591676-06:00 c0-0c1s10n1 sp : ffff00001bd93c20
2019-01-25T19:30:35.591676-06:00 c0-0c1s10n1 sp : ffff00001bd93c20
2019-01-25T19:30:35.591759-06:00 c0-0c1s10n1 Call trace:
2019-01-25T19:30:35.591823-06:00 c0-0c1s10n1 [&amp;lt;ffff000008271088&amp;gt;] notify_change+0x398/0x408
2019-01-25T19:30:35.591828-06:00 c0-0c1s10n1 [&amp;lt;ffff0000082703cc&amp;gt;] file_remove_privs+0xc4/0xf8
2019-01-25T19:30:35.591834-06:00 c0-0c1s10n1 [&amp;lt;ffff0000081cbe5c&amp;gt;] __generic_file_write_iter+0x5c/0x1d0
2019-01-25T19:30:35.591840-06:00 c0-0c1s10n1 [&amp;lt;ffff0000013867d0&amp;gt;] ll_file_write_iter+0x2c8/0x5b0 [lustre]
2019-01-25T19:30:35.591845-06:00 c0-0c1s10n1 [&amp;lt;ffff00000824b764&amp;gt;] __vfs_write+0xd4/0x130
2019-01-25T19:30:35.591850-06:00 c0-0c1s10n1 [&amp;lt;ffff00000824cc4c&amp;gt;] vfs_write+0xac/0x1b8
2019-01-25T19:30:35.591855-06:00 c0-0c1s10n1 [&amp;lt;ffff00000824e304&amp;gt;] SyS_write+0x54/0xb0
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The warning code from notify_change is:&lt;br/&gt;
    WARN_ON_ONCE(!inode_is_locked(inode));&lt;/p&gt;

&lt;p&gt;The warning occurs on the ll_tiny_write path through ll_file_write_iter:&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;updates/kernel/fs/lustre &amp;gt; gdb lustre.ko
(gdb) list *(ll_file_write_iter+0x2c8)
0x1e7f8 is in ll_file_write_iter (/home/abuild/rpmbuild/BUILD/cray-lustre-2.11.0.200_cray_79_g4c42971/lustre/llite/file.c:1613).
1608	/home/abuild/rpmbuild/BUILD/cray-lustre-2.11.0.200_cray_79_g4c42971/lustre/llite/file.c: No such file or directory.
(gdb)

Source from lustre/llite/file.c
1597 static ssize_t ll_do_tiny_write(struct kiocb *iocb, struct iov_iter *iter)
1598 {
1599         ssize_t count = iov_iter_count(iter);
1600         struct file *file = iocb-&amp;gt;ki_filp;
1601         struct inode *inode = file_inode(file);
1602         ssize_t result = 0;
1603
1604         ENTRY;
1605
1606         /* Restrict writes to single page and &amp;lt; PAGE_SIZE.  See comment at top
1607          * of function for why.
1608          */
1609         if (count &amp;gt;= PAGE_SIZE ||
1610             (iocb-&amp;gt;ki_pos &amp;amp; (PAGE_SIZE-1)) + count &amp;gt; PAGE_SIZE)
1611                 RETURN(0);
1612
1613         result = __generic_file_write_iter(iocb, iter);   &amp;lt;--- location on stack
....
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that the other Lustre call to __generic_file_write_iter in vvp_io_write_start() is wrapped with lock/unlock calls that are not included in the tiny write case.&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;1023 static int vvp_io_write_start(const struct lu_env *env,
1024                               const struct cl_io_slice *ios)
1025 {
...
1033         bool                     lock_inode = !lli-&amp;gt;lli_inode_locked &amp;amp;&amp;amp;
1034                                               !IS_NOSEC(inode);
...
1092         if (lock_inode)
1093                 inode_lock(inode);
1094         result = __generic_file_write_iter(&amp;amp;io-&amp;gt;u.ci_rw.rw_iocb,
1095                                            &amp;amp;io-&amp;gt;u.ci_rw.rw_iter);
1096         if (lock_inode)
1097                 inode_unlock(inode);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The proposed fix is to add this same logic to ll_do_tiny_write().&lt;/p&gt;

&lt;p&gt;Because the inode is not locked, tiny writes can race in ll_setattr_raw(). The inode rw_semaphore gets corrupted, so the down_write request waits forever.&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;crash_arm64&amp;gt; bt 15121
PID: 15121  TASK: ffff80be1a1be100  CPU: 11  COMMAND: &quot;memfill2&quot;
 #0 [ffff00001bd939e0] __switch_to at ffff000008086500
 #1 [ffff00001bd93a00] __schedule at ffff000008773cbc
 #2 [ffff00001bd93a70] schedule at ffff000008774330
 #3 [ffff00001bd93a80] rwsem_down_write_failed at ffff0000087774a4
 #4 [ffff00001bd93b00] down_write at ffff000008776884
 #5 [ffff00001bd93b40] ll_setattr_raw at ffff0000013af07c [lustre]
 #6 [ffff00001bd93c00] ll_setattr at ffff0000013af6c4 [lustre]
 #7 [ffff00001bd93c20] notify_change at ffff000008270f28
 #8 [ffff00001bd93c70] file_remove_privs at ffff0000082703c8
 #9 [ffff00001bd93cf0] __generic_file_write_iter at ffff0000081cbe58
#10 [ffff00001bd93d40] ll_file_write_iter at ffff0000013867cc [lustre]
#11 [ffff00001bd93db0] __vfs_write at ffff00000824b760
#12 [ffff00001bd93e40] vfs_write at ffff00000824cc48
#13 [ffff00001bd93e80] sys_write at ffff00000824e300
#14 [ffff00001bd93ff0] el0_svc_naked at ffff000008083c7c

crash_arm64&amp;gt; bt -FF | grep inode ==&amp;gt; yields inode and lli pointers:
ll_inode_info ffff809e6d14bb80
inode ffff809e6d14bc08

crash_arm64&amp;gt; struct -o inode | grep i_rwsem
  [160] struct rw_semaphore i_rwsem;
crash_arm64&amp;gt; eval 0xffff809e6d14bc08 + 160 | grep hex
hexadecimal: ffff809e6d14bca8

crash_arm64&amp;gt; rw_semaphore ffff809e6d14bca8
struct rw_semaphore {
  count = {
    counter = -1
  },
  wait_list = {
    next = 0xffff00001bd93ae0,
    prev = 0xffff00001bd93ae0
  },
  wait_lock = {
    raw_lock = {
      owner = 1,
      next = 1
    }
  },
  osq = {
    tail = {
      counter = 0
    }
  },
  owner = 0x0
}
1584 int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
1585 {
....
1646         if (S_ISREG(inode-&amp;gt;i_mode)) {
1647                 if (attr-&amp;gt;ia_valid &amp;amp; ATTR_SIZE)
1648                         inode_dio_write_done(inode);
1649                 inode_unlock(inode);
1650         }
.....
1720         EXIT;
1721 out:
1722         if (op_data != NULL)
1723                 ll_finish_md_op_data(op_data);
1724
1725         if (S_ISREG(inode-&amp;gt;i_mode)) {
1726                 inode_lock(inode);
1727                 if ((attr-&amp;gt;ia_valid &amp;amp; ATTR_SIZE) &amp;amp;&amp;amp; !hsm_import)
1728                         inode_dio_wait(inode);
1729                 /* Once we&apos;ve got the i_mutex, it&apos;s safe to set the S_NOSEC
1730                  * flag.  ll_update_inode (called from ll_md_setattr), clears
1731                  * inode flags, so there is a gap where S_NOSEC is not set.
1732                  * This can cause a writer to take the i_mutex unnecessarily,
1733                  * but this is safe to do and should be rare. */
1734                 inode_has_no_xattr(inode);
1735         }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;I haven&apos;t figured out the exact scenario that causes i_rwsem to end up with the -1 value, but it&apos;s not too important because ll_setattr_raw() should never be called without the semaphore already being locked.&lt;/p&gt;



</description>
                <environment></environment>
        <key id="54820">LU-11944</key>
            <summary>WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes</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="pfarrell">Patrick Farrell</assignee>
                                    <reporter username="amk">Ann Koehler</reporter>
                        <labels>
                    </labels>
                <created>Thu, 7 Feb 2019 21:41:13 +0000</created>
                <updated>Mon, 8 Apr 2019 14:31:29 +0000</updated>
                            <resolved>Sun, 3 Mar 2019 14:50:16 +0000</resolved>
                                    <version>Lustre 2.11.0</version>
                                    <fixVersion>Lustre 2.13.0</fixVersion>
                    <fixVersion>Lustre 2.12.1</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                            <comments>
                            <comment id="241568" author="amk" created="Thu, 7 Feb 2019 21:54:17 +0000"  >&lt;p&gt;Reproducing the notify_change warning is fairly simple. Note however that the message is issued with WARN_ONCE so the node must be rebooted after the message has been issued once (unless you&apos;ve got a newer kernel with the clear_warn_once /proc variable).&lt;/p&gt;

&lt;p&gt;As root:&lt;br/&gt;
&amp;gt; cd &amp;lt;lustrefs&amp;gt;&lt;br/&gt;
&amp;gt; mkdir dir&lt;br/&gt;
&amp;gt; touch dir/tfile&lt;br/&gt;
&amp;gt; chmod u+s dir/tfile&lt;br/&gt;
&amp;gt; chmod a+rwx dir&lt;br/&gt;
&amp;gt; su user0&lt;br/&gt;
&amp;gt; dd conv=notrunc if=/dev/zero of=dir/tfile bs=8 count=10&lt;br/&gt;
&amp;gt; dmesg&lt;/p&gt;</comment>
                            <comment id="241569" author="pfarrell" created="Thu, 7 Feb 2019 22:30:52 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.whamcloud.com/secure/ViewProfile.jspa?name=amk&quot; class=&quot;user-hover&quot; rel=&quot;amk&quot;&gt;amk&lt;/a&gt; and I talked this one over; as author of tiny writes, I&apos;ll review and assist if required.&lt;/p&gt;

&lt;p&gt;I was a little puzzled that the first write - which does not use the tiny writes path, because there&apos;s no dirty page yet - does not clear the setuid bit.&lt;/p&gt;


&lt;p&gt;But after actually looking at this more carefully, I see it now.&#160; One write is sufficient, because:&lt;br/&gt;
The tiny write path is &lt;b&gt;tried&lt;/b&gt;, to see if there&apos;s a dirty page to be found.&#160; This calls __generic_file_write_iter, which tries to do this setuid check.&#160; The actual &lt;b&gt;write&lt;/b&gt; does not complete with tiny writes because no page is found, but we trigger this check before that.&lt;/p&gt;

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


&lt;p&gt;This has no impact on the suggested solution, it&apos;s just a point of confusion I had.&lt;/p&gt;</comment>
                            <comment id="241637" author="gerrit" created="Fri, 8 Feb 2019 22:55:47 +0000"  >&lt;p&gt;Ann Koehler (amk@cray.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/34218&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34218&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-11944&quot; title=&quot;WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-11944&quot;&gt;&lt;del&gt;LU-11944&lt;/del&gt;&lt;/a&gt; llite: Lock inode on tiny write if setuid/setgid set&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: bdce813a7e2f19c3fb2625d20057cc5e49b0ccfe&lt;/p&gt;</comment>
                            <comment id="243248" author="gerrit" created="Sun, 3 Mar 2019 00:21:42 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/34218/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34218/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-11944&quot; title=&quot;WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-11944&quot;&gt;&lt;del&gt;LU-11944&lt;/del&gt;&lt;/a&gt; llite: Lock inode on tiny write if setuid/setgid set&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: f39a552922ca2db0c6974374fa3a917a34a4a747&lt;/p&gt;</comment>
                            <comment id="243265" author="pjones" created="Sun, 3 Mar 2019 14:50:16 +0000"  >&lt;p&gt;Landed for 2.13&lt;/p&gt;</comment>
                            <comment id="244254" author="gerrit" created="Tue, 19 Mar 2019 17:45:07 +0000"  >&lt;p&gt;Minh Diep (mdiep@whamcloud.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/34461&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34461&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-11944&quot; title=&quot;WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-11944&quot;&gt;&lt;del&gt;LU-11944&lt;/del&gt;&lt;/a&gt; llite: Lock inode on tiny write if setuid/setgid set&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_12&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 8a80304db8040c905a9f5ec814b72bc596b1a5b0&lt;/p&gt;</comment>
                            <comment id="245388" author="gerrit" created="Mon, 8 Apr 2019 06:32:51 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/34461/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34461/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-11944&quot; title=&quot;WARNING:  at ../fs/attr.c:212 notify_change doing tiny_writes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-11944&quot;&gt;&lt;del&gt;LU-11944&lt;/del&gt;&lt;/a&gt; llite: Lock inode on tiny write if setuid/setgid set&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_12&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 009ee0ba61e965327ab0f91f151dbb5932e016d4&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|i00b8v:</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>