[Gluster-devel] Fixing dht rename of directory symlink

Emmanuel Dreyfus manu at netbsd.org
Sun Jul 31 14:51:46 UTC 2011


Anand Avati <anand.avati at gmail.com> wrote:

> 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
> 
> 1. Can you submit this patch in accordance to the development work flow

Just to make sure it is clear: my patch is very broken for now. It has a
deadlock I have to debug, and it tries to rename symlinks without the
link/rename/unlink. That makes a non atomic rename, but it is better
than a non working one. I am just experimenting for now in the search of
the path of least resistance, but it seems I will really need hints
here.

> 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.

See below all the cases, which all work on NetBSD. Note that link(2) on
symlink does link on target, while Linux links on the symlink itself. It
tested MacOS X, it also links on the target. 

There is still a corner case, though: link(2) symlinks resolving on
nonexistent objects will not work on NetBSD (nor on MacOS X), for the
same reason that raise EPERM on link(2) on symlink to directories.

SUSv2 only says link(2) on directory may be unsupported, so I do not
think we will find another problem here.

# ls -l b c f s
brw-r--r--  1 root  wheel  1, 1 Jul 31 16:18 b
crw-r--r--  1 root  wheel  1, 1 Jul 31 16:18 c
prw-r--r--  1 root  wheel     0 Jul 31 16:18 f
srw-rw-rw-  2 root  wheel     0 Jul 27 14:29 s
# for i in  b c f s ; do ln -s ${i} s${i} ; done
# for i in  b c f s ; do ln  ${i} h${i} ; done   
# for i in  b c f s ; do ln  s${i} hs${i} ; done
# ls -li  *b *c *f *s 
 6126885 brw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 b
 6126860 crw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 c
 6126886 prw-r--r--  3 root  wheel     0 Jul 31 16:22 f
 6126885 brw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 hb
 6126860 crw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 hc
 6126886 prw-r--r--  3 root  wheel     0 Jul 31 16:22 hf
58030453 srw-rw-rw-  4 root  wheel     0 Jul 27 14:29 hs
 6126885 brw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 hsb
 6126860 crw-r--r--  3 root  wheel  1, 1 Jul 31 16:22 hsc
 6126886 prw-r--r--  3 root  wheel     0 Jul 31 16:22 hsf
58030453 srw-rw-rw-  4 root  wheel     0 Jul 27 14:29 hss
58030453 srw-rw-rw-  4 root  wheel     0 Jul 27 14:29 s
 6126887 lrwxr-xr-x  1 root  wheel     1 Jul 31 16:23 sb -> b
 6126888 lrwxr-xr-x  1 root  wheel     1 Jul 31 16:23 sc -> c
 6126889 lrwxr-xr-x  1 root  wheel     1 Jul 31 16:23 sf -> f
 6126890 lrwxr-xr-x  1 root  wheel     1 Jul 31 16:23 ss -> s

# ln -s nonexistant l
# ln l hl
ln: l: No such file or directory
# uname
NetBSD
-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu at netbsd.org




More information about the Gluster-devel mailing list