O_EXCL should work fine on FUSE+GlusterFS.<div><br></div><div>Avati<br><br><div class="gmail_quote">On Wed, Jul 11, 2012 at 1:16 PM, Stephen Pierce <span dir="ltr">&lt;<a href="mailto:spierce@verifyle.com" target="_blank">spierce@verifyle.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Short question: Does gluster and the FUSE client support the O_EXCL flag to open()?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Long question:<u></u><u></u></p>
<p class="MsoNormal">So I have several hosts, all using the FUSE client. I mount the same gluster filesystem using the FUSE client on each host. Then, two processes (on separate hosts), try to open() the same file with O_CREAT|O_EXCL. Does the FUSE client and
 gluster guarantee that only one will be successful (ie: no race condition exists)? Or do I need to implement the suggested work-around for NFS in the man page for open()?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Next question: Is anyone actually relying on O_EXCL? :-)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Steve<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Open() manpage:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">       O_EXCL Ensure that this call creates the file: if this flag is  specified  in  conjunction  with<u></u><u></u></p>
<p class="MsoNormal">              O_CREAT,  and  pathname already exists, then open() will fail.  The behavior of O_EXCL is<u></u><u></u></p>
<p class="MsoNormal">              undefined if O_CREAT is not specified.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">              When these two flags are specified, symbolic links are not followed:  if  pathname  is  a<u></u><u></u></p>
<p class="MsoNormal">              symbolic link, then open() fails regardless of where the symbolic link points to.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">              O_EXCL  is  only  supported  on NFS when using NFSv3 or later on kernel 2.6 or later.  In<u></u><u></u></p>
<p class="MsoNormal">              environments where NFS O_EXCL support is not provided, programs that rely on it for  per-<u></u><u></u></p>
<p class="MsoNormal">              forming locking tasks will contain a race condition.  Portable programs that want to per-<u></u><u></u></p>
<p class="MsoNormal">              form atomic file locking using a lockfile, and need to avoid reliance on NFS support  for<u></u><u></u></p>
<p class="MsoNormal">              O_EXCL,  can  create  a unique file on the same file system (e.g., incorporating hostname<u></u><u></u></p>
<p class="MsoNormal">              and PID), and use link(2) to make a link to the lockfile.  If link(2) returns 0, the lock<u></u><u></u></p>
<p class="MsoNormal">              is  successful.  Otherwise, use stat(2) on the unique file to check if its link count has<u></u><u></u></p>
<p class="MsoNormal">              increased to 2, in which case the lock is also successful.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

<br>_______________________________________________<br>
Gluster-users mailing list<br>
<a href="mailto:Gluster-users@gluster.org">Gluster-users@gluster.org</a><br>
<a href="http://gluster.org/cgi-bin/mailman/listinfo/gluster-users" target="_blank">http://gluster.org/cgi-bin/mailman/listinfo/gluster-users</a><br>
<br></blockquote></div><br></div>