<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Bah, of course there is a write of the new data to the file just before the fsync. The fd is also set for auto-flushing (this is a perl script).<div><br><div><div>On Feb 8, 2010, at 3:45 PM, Robert Olson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: monospace; ">I have a locking/fsync question..<br><br>I have an app that keeps job metadata in an XML file that resides on a Lustre filesystem (I actually just discovered my running system has it on NFS, but I'm seeing an anomaly on Lustre so I'll keep writing).<br><br>It uses libxml to read and write the file, and thus has to read the file into memory, make changes, and write back out.<br><br>The approach I'm taking to this is:<br><br><span class="Apple-tab-span" style="white-space: pre; ">    </span>open file => fd<br><span class="Apple-tab-span" style="white-space: pre; ">     </span>lock fd (using fcntl F_SETLKW)<br><span class="Apple-tab-span" style="white-space: pre; "> </span>read from fd<br><span class="Apple-tab-span" style="white-space: pre; ">   </span>ftruncate fd<br><span class="Apple-tab-span" style="white-space: pre; ">   </span><make modifications><br><span class="Apple-tab-span" style="white-space: pre; ">     </span>fsync fd<br><span class="Apple-tab-span" style="white-space: pre; ">       </span>unlock fd<br><span class="Apple-tab-span" style="white-space: pre; ">      </span>close fd<br><br>The lustre system is a 4-OSS system and I'm running the test across 12 compute nodes, all of which have the fs mounted with the flock option (it falls over immediately without flock). I'm at lustre 1.6.6.<br><br>What I'm seeing is that, occasionally, the file reads will pick up an empty or partial file. This doesn't seem like it should be the case, but I'm sure I'm missing something. I don't see any errors showing up on the MDS.<br><br>thanks,<br>--bob</span></div>_______________________________________________<br>Lustre-discuss mailing list<br><a href="mailto:Lustre-discuss@lists.lustre.org">Lustre-discuss@lists.lustre.org</a><br>http://lists.lustre.org/mailman/listinfo/lustre-discuss<br></blockquote></div><br></div></body></html>