Your summary is accurate. Currently distribute assumes link(2)ability of non-directories to provide POSIX semantics that the destination path should always be accessible if a file already existed at the time of rename(2). I will review this patch in more detail. In the mean time, a couple of points<div>
<br></div><div>1. Can you submit this patch in accordance to the development work flow outlined at <a href="http://www.gluster.com/community/documentation/index.php/Development_Work_Flow">http://www.gluster.com/community/documentation/index.php/Development_Work_Flow</a></div>
<div><br></div><div>2. Can you check if the other file types, like block/char devices, named pipes, named sockets etc are link(2)able? We might have to extend a non-link(2) based solution to the rest of the filetypes.</div>
<div><br></div><div>Avati<br><br><div class="gmail_quote">On Sun, Jul 31, 2011 at 1:44 PM, Emmanuel Dreyfus <span dir="ltr">&lt;<a href="mailto:manu@netbsd.org">manu@netbsd.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This is a followup to my previous messages about dht and rename. Here is a<br>
quick summary for the impatient:<br>
<br>
dht rename works on non directory files by link/rename/unlink. As I understand<br>
this is to make sure the file is accessible during the rename operation.<br>
However this breaks on the standard front when we rename a symlink to a<br>
directory.<br>
<br>
Standards say that link(2) on a directory may not be supported. In is indeed<br>
not supported on Linux ext3fs, nor on NetBSD FFS. Nothing is said in the<br>
standards about link(2) on a symlink to a directory. Linux does it, making two<br>
symlinks with same inode. NetBSD first resolves the symlink, discovers the<br>
link(2) attempt on a directory, and raises EPERM.<br>
<br>
Both approaches to link(2) on symlink to a directory are standared compliant,<br>
but glusterfs relying on a given behavior here is a mistake. I talked to<br>
NetBSD crowd about adding a linux_link(2) system call, but that proposal did<br>
not reach consensus. Therefore I would like to fix this in glusterfs.<br>
<br>
Here is a first try. It works fine when rename operates on the same subvolume.<br>
It works but never gives control back to the calling process when it happens<br>
of different subvolumes.<br>
<br>
Help would be welcome.<br>
<br>
--- dht-rename.c.orig   2011-07-31 09:19:02.000000000 +0200<br>
+++ dht-rename.c        2011-07-31 09:46:09.000000000 +0200<br>
@@ -501,9 +501,10 @@<br>
<br>
         if (local-&gt;call_cnt == 0)<br>
                 goto unwind;<br>
<br>
-        if (src_cached != dst_hashed &amp;&amp; src_cached != dst_cached) {<br>
+        if (!IA_ISLNK(local-&gt;loc.inode-&gt;ia_type) &amp;&amp;<br>
+           src_cached != dst_hashed &amp;&amp; src_cached != dst_cached) {<br>
                 gf_log (this-&gt;name, GF_LOG_TRACE,<br>
                         &quot;deleting old src datafile %s @ %s&quot;,<br>
                         local-&gt;loc.path, src_cached-&gt;name);<br>
<br>
@@ -521,9 +522,9 @@<br>
                             src_hashed, src_hashed-&gt;fops-&gt;unlink,<br>
                             &amp;local-&gt;loc);<br>
         }<br>
<br>
-        if (dst_cached<br>
+        if (!IA_ISLNK(local-&gt;loc.inode-&gt;ia_type) &amp;&amp; dst_cached<br>
             &amp;&amp; (dst_cached != dst_hashed)<br>
             &amp;&amp; (dst_cached != src_cached)) {<br>
                 gf_log (this-&gt;name, GF_LOG_TRACE,<br>
                         &quot;deleting old dst datafile %s @ %s&quot;,<br>
@@ -669,14 +670,25 @@<br>
                                        src_cached, dst_hashed, &amp;local-&gt;loc);<br>
         }<br>
<br>
         if (src_cached != dst_hashed) {<br>
-                gf_log (this-&gt;name, GF_LOG_TRACE,<br>
-                        &quot;link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
-                        local-&gt;loc2.path, src_cached-&gt;name);<br>
-                STACK_WIND (frame, dht_rename_links_cbk,<br>
-                            src_cached, src_cached-&gt;fops-&gt;link,<br>
-                            &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               if (IA_ISLNK(local-&gt;loc.inode-&gt;ia_type)) {<br>
+                       gf_log (this-&gt;name, GF_LOG_TRACE,<br>
+                               &quot;rename link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
+                               local-&gt;loc2.path, src_cached-&gt;name);<br>
+<br>
+                       STACK_WIND (frame, dht_rename_cbk,<br>
+                                   src_cached, src_cached-&gt;fops-&gt;rename,<br>
+                                   &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               } else {<br>
+                       gf_log (this-&gt;name, GF_LOG_TRACE,<br>
+                               &quot;link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
+                               local-&gt;loc2.path, src_cached-&gt;name);<br>
+<br>
+                       STACK_WIND (frame, dht_rename_links_cbk,<br>
+                                   src_cached, src_cached-&gt;fops-&gt;link,<br>
+                                   &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               }<br>
         }<br>
<br>
 nolinks:<br>
         if (!call_cnt) {<br>
bacasable# q<br>
bacasable# diff -U4 dht-rename.c.orig dht-rename.c<br>
--- dht-rename.c.orig   2011-07-31 09:19:02.000000000 +0200<br>
+++ dht-rename.c        2011-07-31 09:46:09.000000000 +0200<br>
@@ -501,9 +501,10 @@<br>
<br>
         if (local-&gt;call_cnt == 0)<br>
                 goto unwind;<br>
<br>
-        if (src_cached != dst_hashed &amp;&amp; src_cached != dst_cached) {<br>
+        if (!IA_ISLNK(local-&gt;loc.inode-&gt;ia_type) &amp;&amp;<br>
+           src_cached != dst_hashed &amp;&amp; src_cached != dst_cached) {<br>
                 gf_log (this-&gt;name, GF_LOG_TRACE,<br>
                         &quot;deleting old src datafile %s @ %s&quot;,<br>
                         local-&gt;loc.path, src_cached-&gt;name);<br>
<br>
@@ -521,9 +522,9 @@<br>
                             src_hashed, src_hashed-&gt;fops-&gt;unlink,<br>
                             &amp;local-&gt;loc);<br>
         }<br>
<br>
-        if (dst_cached<br>
+        if (!IA_ISLNK(local-&gt;loc.inode-&gt;ia_type) &amp;&amp; dst_cached<br>
             &amp;&amp; (dst_cached != dst_hashed)<br>
             &amp;&amp; (dst_cached != src_cached)) {<br>
                 gf_log (this-&gt;name, GF_LOG_TRACE,<br>
                         &quot;deleting old dst datafile %s @ %s&quot;,<br>
@@ -669,14 +670,25 @@<br>
                                        src_cached, dst_hashed, &amp;local-&gt;loc);<br>
         }<br>
<br>
         if (src_cached != dst_hashed) {<br>
-                gf_log (this-&gt;name, GF_LOG_TRACE,<br>
-                        &quot;link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
-                        local-&gt;loc2.path, src_cached-&gt;name);<br>
-                STACK_WIND (frame, dht_rename_links_cbk,<br>
-                            src_cached, src_cached-&gt;fops-&gt;link,<br>
-                            &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               if (IA_ISLNK(local-&gt;loc.inode-&gt;ia_type)) {<br>
+                       gf_log (this-&gt;name, GF_LOG_TRACE,<br>
+                               &quot;rename link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
+                               local-&gt;loc2.path, src_cached-&gt;name);<br>
+<br>
+                       STACK_WIND (frame, dht_rename_cbk,<br>
+                                   src_cached, src_cached-&gt;fops-&gt;rename,<br>
+                                   &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               } else {<br>
+                       gf_log (this-&gt;name, GF_LOG_TRACE,<br>
+                               &quot;link %s =&gt; %s (%s)&quot;, local-&gt;loc.path,<br>
+                               local-&gt;loc2.path, src_cached-&gt;name);<br>
+<br>
+                       STACK_WIND (frame, dht_rename_links_cbk,<br>
+                                   src_cached, src_cached-&gt;fops-&gt;link,<br>
+                                   &amp;local-&gt;loc, &amp;local-&gt;loc2);<br>
+               }<br>
         }<br>
<br>
 nolinks:<br>
         if (!call_cnt) {<br>
<br>
<br>
--<br>
Emmanuel Dreyfus<br>
<a href="http://hcpnet.free.fr/pubz" target="_blank">http://hcpnet.free.fr/pubz</a><br>
<a href="mailto:manu@netbsd.org">manu@netbsd.org</a><br>
<br>
_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a><br>
<a href="https://lists.nongnu.org/mailman/listinfo/gluster-devel" target="_blank">https://lists.nongnu.org/mailman/listinfo/gluster-devel</a><br>
</blockquote></div><br></div>