<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 01:17:32 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-1540] e2fsck remove too many symlinks</title>
                <link>https://jira.whamcloud.com/browse/LU-1540</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;Each time we run fsck on a MDS, we lose thousand of symlinks (which is a kind of corruption).&lt;br/&gt;
To figure out a little what was wrong with those inodes, I did a small instrumentation of e2fsck_pass1_check_symlink and started to print various information about the inode (modification are attached).&lt;/p&gt;

&lt;p&gt;Here is what I got :&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;[root@gaia14 ~]# ./e2fsck -n -f -v -d /dev/mapper/vg_mdt_work1-mdt_work1 | grep -B2 -A1 &quot;at pass1.c:246&quot;
e2fsck 1.41.90.wc4 (01-Sep-2011)
blocks != 0 &amp;amp;&amp;amp; fs-&amp;gt;blocksize = 4096, buf = %/home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_oldaux.py%
len = 84, inode-&amp;gt;i_size = 78
at pass1.c:246 : offending inode 16819164 found !
e2fsck_pass1:1416: increase inode 16819164 badness 0 to 1
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;note the content of buf (result of io_channel_read_blk64), and specially the latest characters &apos;aux.py&apos; (% was in the printf format).&lt;/p&gt;

&lt;p&gt;Looking at this inode using debugfs return &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;debugfs: stat &amp;lt;16819164&amp;gt;
Inode: 16819164 Type: symlink Mode: 0777 Flag
Generation: 1029089099 Version: 0x0000004e:1a78c70
User: 11876 Group: 1850 Size: 78
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
 ctime: 0x4fd1a998:00000000 -- Fri Jun 8 09:28:24 20
 atime: 0x4fd1a998:00000000 -- Fri Jun 8 09:28:24 20
 mtime: 0x4fd1a998:00000000 -- Fri Jun 8 09:28:24 20
crtime: 0x4fd1a998:e6373924 -- Fri Jun 8 09:28:24 20
Size of extra inode fields: 28
Extended attributes stored in inode body:
  lma = &quot;00 00 00 00 00 00 00 00 56 fa 1b 0d 02 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  link = &quot;df f1 ea 11 01 00 00 00 36 00 00 00 00 00 0
 5c 00 00 00 00 42 6c 6f 63 6b 2e 70 79 5f 6f 6c 64 &quot;
BLOCKS:
(0):17832933
TOTAL: 1

debugfs: cat &amp;lt;16819164&amp;gt;
/home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_old
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The string is the same except that it doesn&apos;t display the &apos;aux.py&apos;, and the targeted file is what was expected.&lt;/p&gt;

&lt;p&gt;Accessing the filesystem through mount doesn&apos;t display any issue. Accessing the symlink works and the content is valid (the expected link has a length of inode-&amp;gt;i_size).&lt;br/&gt;
The buffer retrieved in e2fsck looks wrong and the end of the string (starting inode-&amp;gt;i_size) always contain garbage.&lt;/p&gt;

&lt;p&gt;So who is wrong ? Is it correct for e2fsprog to guess that a symlink is always terminated by a &apos;\0&apos;, giving strnlen a chance to return the right length ? Or is ldiskfs wrong in not enforcing the &apos;\0&apos; at inode-&amp;gt;i_size position ? ... or something else ...&lt;/p&gt;</description>
                <environment></environment>
        <key id="14969">LU-1540</key>
            <summary>e2fsck remove too many symlinks</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.whamcloud.com/images/icons/priorities/major.svg">Major</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="bobijam">Zhenyu Xu</assignee>
                                    <reporter username="louveta">Alexandre Louvet</reporter>
                        <labels>
                    </labels>
                <created>Tue, 19 Jun 2012 06:39:26 +0000</created>
                <updated>Wed, 3 Aug 2022 07:45:37 +0000</updated>
                            <resolved>Fri, 24 Aug 2012 04:18:06 +0000</resolved>
                                    <version>Lustre 2.2.0</version>
                    <version>Lustre 2.3.0</version>
                    <version>Lustre 2.1.1</version>
                    <version>Lustre 2.1.2</version>
                    <version>Lustre 2.1.3</version>
                                    <fixVersion>Lustre 2.3.0</fixVersion>
                    <fixVersion>Lustre 2.4.0</fixVersion>
                    <fixVersion>Lustre 2.1.3</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>7</watches>
                                                                            <comments>
                            <comment id="40845" author="pjones" created="Tue, 19 Jun 2012 08:57:29 +0000"  >&lt;p&gt;Bobijam&lt;/p&gt;

&lt;p&gt;Could you please look into this one?&lt;/p&gt;

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

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="40901" author="adilger" created="Wed, 20 Jun 2012 01:25:54 +0000"  >&lt;p&gt;I believe this symlink problem is caused by the MDS being formatted with the &quot;extents&quot; option, which is not the default (see discussion in &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1366&quot; title=&quot;getting &amp;quot;dirdata length set incorrectly&amp;quot; running e2fsck&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1366&quot;&gt;&lt;del&gt;LU-1366&lt;/del&gt;&lt;/a&gt; for a similar issue).&lt;/p&gt;

&lt;p&gt;The removal of symlinks should be fixed in the recently-released e2fsprogs-1.42.3.wc1 version of e2fsck.  Please see &lt;a href=&quot;http://downloads.whamlcoud.com/public/e2fsprogs/latest/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://downloads.whamlcoud.com/public/e2fsprogs/latest/&lt;/a&gt; for packages.&lt;/p&gt;</comment>
                            <comment id="40906" author="louveta" created="Wed, 20 Jun 2012 02:20:49 +0000"  >&lt;p&gt;Unfortunately not, it isn&apos;t &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.whamcloud.com/images/icons/emoticons/sad.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; (unless it&apos;s not the good way to check).&lt;/p&gt;

&lt;p&gt;debugfs:  params&lt;br/&gt;
Open mode: read-only&lt;br/&gt;
Filesystem in use: /dev/mapper/vg_mdt_store1-mdt_store1&lt;br/&gt;
debugfs:  features&lt;br/&gt;
Filesystem features: has_journal ext_attr resize_inode dir_index filetype&lt;br/&gt;
needs_recovery mmp flex_bg dirdata sparse_super large_file uninit_bg&lt;/p&gt;

&lt;p&gt;I&apos;ll double check, but we also give a try to e2fsprogs-1.42.3.wc1 yesterday and it didn&apos;t change anything.&lt;/p&gt;

&lt;p&gt;Alex.&lt;/p&gt;</comment>
                            <comment id="40912" author="louveta" created="Wed, 20 Jun 2012 04:21:14 +0000"  >&lt;p&gt;Checked that e2fsprogs-1.42.3.wc1 doesn&apos;t change the unexpected behaviour.&lt;/p&gt;

&lt;p&gt;Alex.&lt;/p&gt;</comment>
                            <comment id="40924" author="adilger" created="Wed, 20 Jun 2012 10:31:47 +0000"  >&lt;p&gt;I wonder if the Lustre osd-ldiskfs code is not NUL terminating the long symlinks?  I&apos;m not sure if that is required, or if the fault is in e2fsck for assuming that they will be NUL terminated?&lt;/p&gt;</comment>
                            <comment id="40925" author="adilger" created="Wed, 20 Jun 2012 10:33:00 +0000"  >&lt;p&gt;In either case, it seems we will also need to make a patch for e2fsck so that it doesn&apos;t consider such symlinks as corrupt, but instead fixes them up, since this will be the case for all 2.x Lustre MDTs.&lt;/p&gt;</comment>
                            <comment id="40977" author="bobijam" created="Thu, 21 Jun 2012 04:27:02 +0000"  >&lt;p&gt;I tried b1_2 branch, lustre doesn&apos;t create size-mismatched long symbolic link file.&lt;/p&gt;

&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;create a long symlink&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;&amp;#35; ls -l /mnt/lustre&lt;br/&gt;
lrwxrwxrwx 1 root root 84 Jun 21 16:13 long-symlink -&amp;gt; /home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_oldaux.py&lt;br/&gt;
&lt;font color=&quot;red&quot;&gt;its size is 84 == length of the string&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;umount MDT, and check the long symlink file.&lt;/p&gt;

&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;e2fsck MDT device&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;&amp;#35; e2fsck -fnvd /dev/sdb&lt;br/&gt;
e2fsck 1.41.90.wc4 (01-Sep-2011)&lt;br/&gt;
Pass 1: Checking inodes, blocks, and sizes&lt;br/&gt;
Pass 2: Checking directory structure&lt;br/&gt;
Pass 3: Checking directory connectivity&lt;br/&gt;
Pass 4: Checking reference counts&lt;br/&gt;
Pass 5: Checking group summary information&lt;/p&gt;

&lt;p&gt;	  39 inodes used (0.04%)&lt;br/&gt;
	   3 non-contiguous files (7.7%)&lt;br/&gt;
	   0 non-contiguous directories (0.0%)&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;of inodes with ind/dind/tind blocks: 0/0/0&lt;br/&gt;
   16734 blocks used (33.47%)&lt;br/&gt;
	   0 bad blocks&lt;br/&gt;
	   1 large file&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;	  21 regular files&lt;br/&gt;
	   8 directories&lt;br/&gt;
	   0 character device files&lt;br/&gt;
	   0 block device files&lt;br/&gt;
	   0 fifos&lt;br/&gt;
	   0 links&lt;br/&gt;
	   1 symbolic link (0 fast symbolic links) &lt;font color=&quot;red&quot;&gt;===&amp;gt; this long symlink file&lt;/font&gt;&lt;br/&gt;
	   0 sockets&lt;br/&gt;
--------&lt;br/&gt;
	  30 files&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;stat the file&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;&amp;#35; debugfs -R &quot;stat /ROOT/long-symlink&quot; /dev/sdb&lt;br/&gt;
debugfs 1.41.90.wc4 (01-Sep-2011)&lt;br/&gt;
Inode: 34   Type: symlink    Mode:  0777   Flags: 0x0&lt;br/&gt;
Generation: 759704194    Version: 0x00000001:00000002&lt;br/&gt;
User:     0   Group:     0   Size: 84 &lt;font color=&quot;red&quot;&gt;  =====&amp;gt; size matched&lt;/font&gt;&lt;br/&gt;
File ACL: 0    Directory ACL: 0&lt;br/&gt;
Links: 1   Blockcount: 8&lt;br/&gt;
Fragment:  Address: 0    Number: 0    Size: 0&lt;br/&gt;
 ctime: 0x4fe2d7c2:00000000 &amp;#8211; Thu Jun 21 16:13:54 2012&lt;br/&gt;
 atime: 0x4fe2d7c2:00000000 &amp;#8211; Thu Jun 21 16:13:54 2012&lt;br/&gt;
 mtime: 0x4fe2d7c2:00000000 &amp;#8211; Thu Jun 21 16:13:54 2012&lt;br/&gt;
crtime: 0x4fe2d7c2:b3456314 &amp;#8211; Thu Jun 21 16:13:54 2012&lt;br/&gt;
Size of extra inode fields: 28&lt;br/&gt;
Extended attributes stored in inode body:&lt;br/&gt;
  lma = &quot;00 00 00 00 00 00 00 00 00 04 00 00 02 00 00 00 01 00 00 00 00 00 00 00&lt;br/&gt;
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0&lt;br/&gt;
0 00 00 00 00 00 00 00 00 00 00 00 00 00 &quot; (64)&lt;br/&gt;
  link = &quot;df f1 ea 11 01 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0&lt;br/&gt;
0 00 1e 00 00 00 00 00 00 61 ab 2d 48 2a 75 00 00 00 00 6c 6f 6e 67 2d 73 79 6d&lt;br/&gt;
6c 69 6e 6b &quot; (54)&lt;br/&gt;
BLOCKS:&lt;br/&gt;
(0):57&lt;br/&gt;
TOTAL: 1&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;cat it&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;panelContent&quot;&gt;
&lt;p&gt;&amp;#35; debugfs -R &quot;cat &amp;lt;34&amp;gt;&quot; /dev/sdb&lt;br/&gt;
debugfs 1.41.90.wc4 (01-Sep-2011)&lt;br/&gt;
/home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_oldaux.py&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="40978" author="louveta" created="Thu, 21 Jun 2012 04:37:07 +0000"  >&lt;p&gt;This is not that simple as all symlinks are not in this case. We have a huge number of symlinks that remain untouched during fsck. Only a subset are affected.&lt;/p&gt;</comment>
                            <comment id="40991" author="louveta" created="Thu, 21 Jun 2012 11:01:03 +0000"  >&lt;p&gt;Ok, so I&apos;m now able to provide a (more or less) simple reproducer. It was run on a cluster running lustre 2.1.2 on a freshly created filesystem (mounted in /scratch on the client).&lt;br/&gt;
On the client, after the new filesystem has been mounted, simply run &apos;gen.sh&apos;. When the script did complete, umount the filesystem and run fsck on the MDT.&lt;/p&gt;

&lt;p&gt;Attached gen.sh (the reproducer) &amp;amp; log.txt (output of e2fsck -v -n /dev/sdb2 in my case).&lt;/p&gt;</comment>
                            <comment id="41002" author="bobijam" created="Thu, 21 Jun 2012 14:01:28 +0000"  >&lt;p&gt;found the lustre code corresponding to the issue, osd_write does not write the end NULL symlink string to its data block area.&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;osd_write()&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;        /* Write small symlink to inode body as we need to maintain correct
         * on-disk symlinks &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; ldiskfs.
         */
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt;(S_ISLNK(obj-&amp;gt;oo_dt.do_lu.lo_header-&amp;gt;loh_attr) &amp;amp;&amp;amp;
           (buf-&amp;gt;lb_len &amp;lt; sizeof (LDISKFS_I(inode)-&amp;gt;i_data)))
                result = osd_ldiskfs_writelink(inode, buf-&amp;gt;lb_buf, buf-&amp;gt;lb_len);
        &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;
                result = osd_ldiskfs_write_record(inode, buf-&amp;gt;lb_buf,
                                                  buf-&amp;gt;lb_len, pos,
                                                  oh-&amp;gt;ot_handle);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I did a hack to verify it, with following patch, fsck passed the MDT device filled with gen.sh reproducer.&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/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c
index 9a052be..457090c 100644
--- a/lustre/osd-ldiskfs/osd_handler.c
+++ b/lustre/osd-ldiskfs/osd_handler.c
@@ -2555,6 +2555,8 @@ &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; osd_ldiskfs_write_record(struct inode *inode, v
         &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; boffs;
         &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; dirty_inode = 0;

+        *((&lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; *)buf + bufsize) = &lt;span class=&quot;code-quote&quot;&gt;&apos;\0&apos;&lt;/span&gt;;
+        ++bufsize;
         &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; (bufsize &amp;gt; 0) {
                 &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (bh != NULL)
                         brelse(bh);
@@ -2593,6 +2595,7 @@ &lt;span class=&quot;code-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; osd_ldiskfs_write_record(struct inode *inode, v

         &lt;span class=&quot;code-comment&quot;&gt;/* correct in-core and on-disk sizes */&lt;/span&gt;
         &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (new_size &amp;gt; i_size_read(inode)) {
+                --new_size;
                 spin_lock(&amp;amp;inode-&amp;gt;i_lock);
                 &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (new_size &amp;gt; i_size_read(inode))
                         i_size_write(inode, new_size);
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="41004" author="bobijam" created="Thu, 21 Jun 2012 14:14:52 +0000"  >&lt;p&gt;I think we need change 2 parts:&lt;/p&gt;

&lt;p&gt;1. include the &apos;\0&apos; in mdd_create() when writing symlink data (passing buflen + 1), thus inode-&amp;gt;i_size also include this NULL string terminator.&lt;br/&gt;
2. in e2fsck_pass1_check_symlink(),  change the long symlink check to make sure the string length of its data block is one less than the inode&apos;s i_size. &lt;/p&gt;</comment>
                            <comment id="41007" author="adilger" created="Thu, 21 Jun 2012 15:09:34 +0000"  >&lt;p&gt;Bobijam,&lt;br/&gt;
it appears that the NUL terminator for the symlink is at buf&lt;span class=&quot;error&quot;&gt;&amp;#91;inode-&amp;gt;i_size&amp;#93;&lt;/span&gt;, so for your example i_size = 84, which is also the number of characters in the string.  That means e2fsck shouldn&apos;t check that the strlen(symlink) is (i_size - 1), but rather that it should add a NUL terminator at buf&lt;span class=&quot;error&quot;&gt;&amp;#91;i_size&amp;#93;&lt;/span&gt; (assuming this fits within the blocksize).&lt;/p&gt;</comment>
                            <comment id="41009" author="bobijam" created="Thu, 21 Jun 2012 15:44:14 +0000"  >&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;mdd_create&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;if&lt;/span&gt; (S_ISLNK(attr-&amp;gt;la_mode)) {
                struct md_ucred  *uc = md_ucred(env);
                struct dt_object *dt = mdd_object_child(son);
                &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;code-object&quot;&gt;char&lt;/span&gt; *target_name = spec-&amp;gt;u.sp_symname;
                &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; sym_len = strlen(target_name);
                &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; struct lu_buf *buf;
                loff_t pos = 0;

                buf = mdd_buf_get_const(env, target_name, sym_len);
                rc = dt-&amp;gt;do_body_ops-&amp;gt;dbo_write(env, dt, buf, &amp;amp;pos, handle,
                                                mdd_object_capa(env, son),
                                                uc-&amp;gt;mu_cap &amp;amp;
                                                CFS_CAP_SYS_RESOURCE_MASK);

                &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (rc == sym_len)
                        rc = 0;
                &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;
                        GOTO(cleanup, rc = -EFAULT);
        }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;spec-&amp;gt;u.sp_symname contains the NUL terminator, while sym_len does not count it, so osd_write does not write the NUL terminator to the inode&apos;s data block and also set i_size to sym_len. So the string length e2fsck_pass1_check_symlink() reads from the inode&apos;s data block cannot gurantee to match with the inode&apos;s i_size.&lt;/p&gt;</comment>
                            <comment id="41017" author="bobijam" created="Fri, 22 Jun 2012 01:03:59 +0000"  >&lt;p&gt;As the original case shows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;debugfs: cat &amp;lt;16819164&amp;gt;&lt;br/&gt;
/home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_old&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;this is what the symlink&apos;s target string, and e2fsck read more than that&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;root@gaia14 ~&amp;#93;&lt;/span&gt;# ./e2fsck -n -f -v -d /dev/mapper/vg_mdt_work1-mdt_work1 | grep -B2 -A1 &quot;at pass1.c:246&quot;&lt;br/&gt;
e2fsck 1.41.90.wc4 (01-Sep-2011)&lt;br/&gt;
blocks != 0 &amp;amp;&amp;amp; fs-&amp;gt;blocksize = 4096, buf = %/home/cont001/segura/BIN/ELSA/CHAINE_V2/MODULES_PYTHON/GENERIQUES/Block.py_oldaux.py%&lt;br/&gt;
len = 84, inode-&amp;gt;i_size = 78&lt;/p&gt;&lt;/blockquote&gt;
</comment>
                            <comment id="41019" author="bobijam" created="Fri, 22 Jun 2012 02:56:50 +0000"  >&lt;p&gt;&lt;a href=&quot;http://review.whamcloud.com/3171&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/3171&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; e2fsprogs: symlink check handle string length properly&lt;/p&gt;

&lt;p&gt;The symbolic link target string is written into inode data block&lt;br/&gt;
without NUL terminator, its length is decided by the inode&apos;s size,&lt;br/&gt;
so this fix makes symlink check take heed of it.&lt;/p&gt;</comment>
                            <comment id="41036" author="adilger" created="Fri, 22 Jun 2012 11:33:48 +0000"  >&lt;p&gt;There must be some way to write a block with NULs beyond i_size. When writing a normal data file, it has to fill in zeroes after i_size fit the rest of the block to ensure that sparse writes work properly. Why can&apos;t we do the same for symlinks?  One bad way I can think to do this are to write the full block, then truncate to i_size, but I suspect there is a better way to do this. &lt;/p&gt;

&lt;p&gt;Alex, could you please comment?&lt;/p&gt;</comment>
                            <comment id="41209" author="adilger" created="Wed, 27 Jun 2012 13:54:43 +0000"  >&lt;p&gt;The patch to e2fsck in &lt;a href=&quot;http://review.whamcloud.com/3171&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/3171&lt;/a&gt; can be used as a temporary workaround to the removal of corrupt symlinks, but it doesn&apos;t actually fix the problem on disk, only prevents e2fsck from deleting the symlinks.  This is why I want an updated version of that patch landed to e2fsck.&lt;/p&gt;

&lt;p&gt;There is also as yet no patch to fix the osd-ldiskfs code to prevent further bad symlinks from being created in the future.&lt;/p&gt;

&lt;p&gt;Both of these issues need to be addressed before this bug can be closed.&lt;/p&gt;</comment>
                            <comment id="41210" author="adilger" created="Wed, 27 Jun 2012 13:56:17 +0000"  >&lt;p&gt;Since this is now known to be a bug in osd-ldiskfs and not e2fsck, I&apos;m elevating this to be a 2.1.3 and 2.3 blocker.&lt;/p&gt;</comment>
                            <comment id="41273" author="adilger" created="Thu, 28 Jun 2012 13:12:04 +0000"  >&lt;p&gt;Alex, can you please comment on the osd-ldiskfs issues here.  What is the best way to write out a NUL-terminated symlink without changing the file size?  This shouldn&apos;t be any different than writing out a partial-page buffer (which should be zero-filled at the end).&lt;/p&gt;</comment>
                            <comment id="41275" author="bzzz" created="Thu, 28 Jun 2012 13:24:45 +0000"  >&lt;p&gt;I think osd-ldiskfs can check the object&apos;s type (=symlink), then either append a zero and decrement i_size or just use trivial copy of osd_ldiskfs_write_record() ?&lt;/p&gt;</comment>
                            <comment id="41342" author="adilger" created="Sat, 30 Jun 2012 02:43:50 +0000"  >&lt;p&gt;How does osd-ldiskfs handle the case of a normal 80-byte write to a new file?  The rest of the disk block beyond 80 bytes needs to be zero-filled, but I don&apos;t think any tricks are played with the file size. Can we not just hook into the ldiskfs symlink code? &lt;/p&gt;

&lt;p&gt;Cheers, Andreas&lt;/p&gt;

</comment>
                            <comment id="41867" author="hudson" created="Mon, 16 Jul 2012 01:10:34 +0000"  >&lt;p&gt;Integrated in &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;http://iu-build.whamcloud.com/images/16x16/blue.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt; &lt;a href=&quot;http://iu-build.whamcloud.com/job/e2fsprogs-master/./arch=x86_64,distro=el6/226/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;e2fsprogs-master &#187; x86_64,el6 #226&lt;/a&gt;&lt;br/&gt;
     &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; e2fsck: add missing symlink NUL terminator (Revision 311939a654b4085aef9559f21e91d7205150950f)&lt;/p&gt;

&lt;p&gt;     Result = SUCCESS&lt;br/&gt;
Andreas Dilger : &lt;a href=&quot;http://git.whamcloud.com/gitweb/?p=tools/e2fsprogs.git;a=commit;h=refs/heads/master-lustre&amp;amp;a=commit&amp;amp;h=311939a654b4085aef9559f21e91d7205150950f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;311939a654b4085aef9559f21e91d7205150950f&lt;/a&gt;&lt;br/&gt;
Files : &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.2&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.1&lt;/li&gt;
	&lt;li&gt;e2fsck/e2fsck.h&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.c&lt;/li&gt;
	&lt;li&gt;e2fsck/pass1.c&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.h&lt;/li&gt;
	&lt;li&gt;e2fsck/pass2.c&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="41869" author="hudson" created="Mon, 16 Jul 2012 01:10:39 +0000"  >&lt;p&gt;Integrated in &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;http://iu-build.whamcloud.com/images/16x16/blue.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt; &lt;a href=&quot;http://iu-build.whamcloud.com/job/e2fsprogs-master/./arch=i686,distro=el6/226/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;e2fsprogs-master &#187; i686,el6 #226&lt;/a&gt;&lt;br/&gt;
     &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; e2fsck: add missing symlink NUL terminator (Revision 311939a654b4085aef9559f21e91d7205150950f)&lt;/p&gt;

&lt;p&gt;     Result = SUCCESS&lt;br/&gt;
Andreas Dilger : &lt;a href=&quot;http://git.whamcloud.com/gitweb/?p=tools/e2fsprogs.git;a=commit;h=refs/heads/master-lustre&amp;amp;a=commit&amp;amp;h=311939a654b4085aef9559f21e91d7205150950f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;311939a654b4085aef9559f21e91d7205150950f&lt;/a&gt;&lt;br/&gt;
Files : &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;e2fsck/problem.c&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.1&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.h&lt;/li&gt;
	&lt;li&gt;e2fsck/pass1.c&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.2&lt;/li&gt;
	&lt;li&gt;e2fsck/pass2.c&lt;/li&gt;
	&lt;li&gt;e2fsck/e2fsck.h&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="41871" author="hudson" created="Mon, 16 Jul 2012 01:11:39 +0000"  >&lt;p&gt;Integrated in &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;http://iu-build.whamcloud.com/images/16x16/blue.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt; &lt;a href=&quot;http://iu-build.whamcloud.com/job/e2fsprogs-master/./arch=x86_64,distro=el5/226/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;e2fsprogs-master &#187; x86_64,el5 #226&lt;/a&gt;&lt;br/&gt;
     &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; e2fsck: add missing symlink NUL terminator (Revision 311939a654b4085aef9559f21e91d7205150950f)&lt;/p&gt;

&lt;p&gt;     Result = SUCCESS&lt;br/&gt;
Andreas Dilger : &lt;a href=&quot;http://git.whamcloud.com/gitweb/?p=tools/e2fsprogs.git;a=commit;h=refs/heads/master-lustre&amp;amp;a=commit&amp;amp;h=311939a654b4085aef9559f21e91d7205150950f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;311939a654b4085aef9559f21e91d7205150950f&lt;/a&gt;&lt;br/&gt;
Files : &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;e2fsck/pass2.c&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.2&lt;/li&gt;
	&lt;li&gt;e2fsck/pass1.c&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.1&lt;/li&gt;
	&lt;li&gt;e2fsck/e2fsck.h&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.h&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.c&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="41873" author="hudson" created="Mon, 16 Jul 2012 01:11:59 +0000"  >&lt;p&gt;Integrated in &lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;http://iu-build.whamcloud.com/images/16x16/blue.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt; &lt;a href=&quot;http://iu-build.whamcloud.com/job/e2fsprogs-master/./arch=i686,distro=el5/226/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;e2fsprogs-master &#187; i686,el5 #226&lt;/a&gt;&lt;br/&gt;
     &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; e2fsck: add missing symlink NUL terminator (Revision 311939a654b4085aef9559f21e91d7205150950f)&lt;/p&gt;

&lt;p&gt;     Result = SUCCESS&lt;br/&gt;
Andreas Dilger : &lt;a href=&quot;http://git.whamcloud.com/gitweb/?p=tools/e2fsprogs.git;a=commit;h=refs/heads/master-lustre&amp;amp;a=commit&amp;amp;h=311939a654b4085aef9559f21e91d7205150950f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;311939a654b4085aef9559f21e91d7205150950f&lt;/a&gt;&lt;br/&gt;
Files : &lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.2&lt;/li&gt;
	&lt;li&gt;e2fsck/e2fsck.h&lt;/li&gt;
	&lt;li&gt;e2fsck/pass2.c&lt;/li&gt;
	&lt;li&gt;e2fsck/pass1.c&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.c&lt;/li&gt;
	&lt;li&gt;tests/f_badsymlinks/expect.1&lt;/li&gt;
	&lt;li&gt;e2fsck/problem.h&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="42825" author="pjones" created="Tue, 7 Aug 2012 14:40:03 +0000"  >&lt;p&gt;Bobijam&lt;/p&gt;

&lt;p&gt;I spoke with Andreas about this issue and he thinks that it makes sense for you to talk directly with Alex Z about ways of approaching this problem and that we should aim to get this fixed for 2.3&lt;/p&gt;

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

&lt;p&gt;Peter&lt;/p&gt;</comment>
                            <comment id="42880" author="pjones" created="Wed, 8 Aug 2012 12:08:25 +0000"  >&lt;p&gt;&lt;a href=&quot;http://review.whamcloud.com/#change,3560&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/#change,3560&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="42930" author="adilger" created="Thu, 9 Aug 2012 05:38:36 +0000"  >&lt;p&gt;The e2fsck part of this change is included into the e2fsprogs-1.42.3.wc3 release.&lt;/p&gt;</comment>
                            <comment id="43558" author="pjones" created="Tue, 21 Aug 2012 10:48:29 +0000"  >&lt;p&gt;Fix landed for 2.3&lt;/p&gt;</comment>
                            <comment id="43690" author="dmoreno" created="Thu, 23 Aug 2012 10:29:27 +0000"  >&lt;p&gt;Could it be possible to have the ldiskfs patch (&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-1540&quot; title=&quot;e2fsck remove too many symlinks&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-1540&quot;&gt;&lt;del&gt;LU-1540&lt;/del&gt;&lt;/a&gt; osd: add NUL terminator for long symlink) ported to b2_1?&lt;/p&gt;

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

&lt;p&gt;Diego&lt;/p&gt;</comment>
                            <comment id="43705" author="bobijam" created="Thu, 23 Aug 2012 14:06:16 +0000"  >&lt;p&gt;b2_1 port of ldiskfs patch tracking at &lt;a href=&quot;http://review.whamcloud.com/3765&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://review.whamcloud.com/3765&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;&quot;&gt;&lt;b&gt;patch description&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;LU-1540 osd: add NUL terminator for long symlink

Add NUL terminator for long symlink to ldiskfs inode on-disk data.

Signed-off-by: Bobi Jam &amp;lt;bobijam@whamcloud.com&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="43729" author="dmoreno" created="Fri, 24 Aug 2012 07:42:31 +0000"  >&lt;p&gt;That&apos;s great, we&apos;ll try the patch.&lt;/p&gt;

&lt;p&gt;Thanks guys,&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="14249">LU-1366</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="15535">LU-1774</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="71558">LU-16060</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="11643" name="gen.sh" size="1127" author="louveta" created="Thu, 21 Jun 2012 11:01:35 +0000"/>
                            <attachment id="11644" name="log.txt.gz" size="6185" author="louveta" created="Thu, 21 Jun 2012 11:01:35 +0000"/>
                            <attachment id="11624" name="src.txt" size="3224" author="louveta" created="Tue, 19 Jun 2012 06:39:26 +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|hzv5gf:</customfieldvalue>

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