<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:10.5pt;">
<div align="left" style="text-align:justify;">Hi, Dear Expert,</div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;">We have use glusterfs as a network filesystem, and syslog store in there, some clients on different host may write the syslog file via &#8220;glusterfs&#8221; mount point.</div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;">Now we encounter an issue when we &#8220;tail&#8221; the syslog file, it will occasional failed with error &#8220;<font color="red">file truncated</font>&#8221;</div>
<div align="left" style="text-align:justify;">As we study and trace with the &#8220;tail&#8221; source code, it failed with the following code:</div>
<div align="left" style="text-indent:84pt;text-align:justify;"><span style="background-color:silver;">if (</span><span style="background-color:yellow;">S_ISREG (mode) &amp;&amp; stats.st_size &lt; f[i].size</span><span style="background-color:silver;">)</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error (0, 0, _(&quot;%s: file truncated&quot;), quotef (name));</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Assume the file was truncated to 0,</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and therefore output all &quot;new&quot; data.&nbsp; */</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlseek (fd, 0, SEEK_SET, name);</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f[i].size = 0;</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;">When stats.st_size &lt; f[i].size, what mean the size report by fstat is less than &#8220;tail&#8221; had read, it lead to &#8220;file truncated&#8221;, we also use &#8220;strace&#8221; tools to trace the tail application, the related tail strace log
as the below:</div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">nanosleep({1, 0}, NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">fstat(3, {st_mode=S_IFREG|0644, st_size=192543105, ...}) = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">nanosleep({1, 0}, NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">fstat(3, {st_mode=S_IFREG|0644, st_size=192543105, ...}) = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">nanosleep({1, 0}, NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">fstat(3, {st_mode=S_IFREG|0644, st_size=192543105, ...}) = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">nanosleep({1, 0}, NULL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">fstat(3, {st_mode=S_IFREG|0644, st_size=192544549, ...}) = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">read(3, &quot;</span><span style="background-color:yellow;">Data &#8230;</span><span style="background-color:yellow;">-&quot;..., 8192) = 1444</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">read(3, &quot;</span><span style="background-color:yellow;">Data..</span><span style="background-color:yellow;">&quot;..., 8192) = 720</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">read(3, &quot;&quot;, 8192)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">fstat(3, {st_mode=S_IFREG|0644, st_size=192544789, ...}) = 0</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">write(1, </span><span style="background-color:yellow;">&#8220;DATA&#8230;..&#8221;</span><span style="background-color:yellow;">) = 2164</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">write(2, &quot;tail: &quot;, 6tail: )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 6</span></div>
<div align="left" style="text-align:justify;"><span style="background-color:yellow;">write(2, &quot;/mnt/log/master/syslog: file tru&quot;..., 38/mnt/log/master/syslog: file truncated) = 38</span></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;">as the above strace log, tail has read 1444&#43;720=2164 bytes,</div>
<div align="left" style="text-align:justify;">but fstat tell &#8220;tail&#8221; <span style="background-color:yellow;">192544789</span> &#8211; <span style="background-color:yellow;">192543105</span> = 1664 which less than 2164, so it lead to &#8220;tail&#8221; application &#8220;file truncated&#8221;.</div>
<div align="left" style="text-align:justify;">&nbsp;</div>
<div align="left" style="text-align:justify;">And if we turn off &#8220;write-behind&#8221; feature, the issue will not be reproduced any more.</div>
<div align="left" style="text-align:justify;">So we think it may be related to cache consistence issue due to performance consider, but we still have concern that:</div>
<div align="left" style="text-align:justify;">&nbsp;</div>
<div align="left" style="text-align:justify;">The syslog file is used only with &#8220;Append&#8221; mode, so the size of file shouldn&#8217;t be reduced, when a client read the file, why &#8220;fstat&#8221; can&#8217;t return the really size match to the cache?</div>
<div align="left" style="text-align:justify;">From current investigation, we doubt that the current implement of &#8220;glusterfs&#8221; has a bug on &#8220;fstat&#8221; when cache is on.</div>
<div align="left" style="text-align:justify;">&nbsp;</div>
<div align="left" style="text-align:justify;">Your comments is our highly appreciated!</div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;">Thanks &amp; Best Regards</div>
<div align="left" style="text-align:justify;">&nbsp;</div>
<div align="left" style="text-align:justify;">George</div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
<div align="left" style="text-align:justify;"><font face="Times New Roman">&nbsp;</font></div>
</span></font>
</body>
</html>