[lkml]   [2006]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: what is necessary for directory hard links
On 7/24/06, <> wrote:
> On Mon, 24 Jul 2006 10:45:45 +0400, Nikita Danilov said:
> > Joshua Hudson writes:
> > > In my filesystem, any attempt to create a loop of hard links
> > > is detected and cancelled.
> >
> > Can you elaborate a bit on this exciting mechanism? Obviously an ability
> > to efficiently detect loops would be a break-through in a
> > reference-counted garbage collection, somehow missed for last 40
> It's actually pretty trivial to do if it's a toy filesystem and all the
> relevant inodes are in-memory already. The hard-to-solve part is getting
> around the (apparent) need to walk across essentially the entire tree
> structure making sure that you aren't creating a loop. This can get
> rather performance piggy - even /home on my laptop has some 400K
> inodes on it, and a 'find /home -type d' takes 28 seconds. That's a *long*
> time to lock and freeze a filesystem.

Actually, I walk from the source inode down to try to find the
target inode. If not found, this is not attempting to create a loop.
Should be obvious that the average case is much less than the
whole tree.

> Where it gets *really* messy is that it isn't just mkdir that's the problem -
> once you let there be more than one path from the fs root to a given directory,
> it gets *really* hard to make sure that any given 'mv' command isn't going to
> to screw things up (is 'mv a/b/c/d ../../w/z/b' safe? How do you know, without
> examining a *lot* of stuff under a/ and ../../w/?

mv /a/b/c/d ../../w/z/b is implemented as this in the filesystem:
ln /a/b/c/d ../../w/z/b && rm /a/b/c/d

So what it's going to do is try to find z under /a/b/c/d.

Oh, and Nakita's right about the NFS server stuff. Actually, I think
the current filesystem I use for this is totally incompatible with
NFS (cannot call d_splice_alias on directory dnodes) so that
doesn't concern me.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-07-24 18:23    [W:0.051 / U:0.100 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site