linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu
To: Joshua Hudson <joshudson@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: what is necessary for directory hard links
Date: Mon, 24 Jul 2006 14:22:19 -0400	[thread overview]
Message-ID: <200607241822.k6OIMJcY014229@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Mon, 24 Jul 2006 09:21:04 PDT." <bda6d13a0607240921x78049eefraae775e4c6c0ba5c@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2122 bytes --]

On Mon, 24 Jul 2006 09:21:04 PDT, Joshua Hudson said:
> On 7/24/06, Valdis.Kletnieks@vt.edu <Valdis.Kletnieks@vt.edu> wrote:

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

The problem is that the "target inode" may not be the one obviously causing the
loop - you may be trying to link a directory into a/b/c, while the loop
is caused by a link from a/b/c/d/e/f/g back up to someplace.

Consider:

function mkdir_tree(foo) {
for i=1,3 do
  for j=1,3 do
   for k=1,3 do
	mkdir ${foo}/a${i}/b${j}/c${k}
}

mkdir_tree(x)
mkdir_tree(y)
mkdir_tree(z)

ln x/a2/b3/c3/d1 y
ln x/a1/b3/c3/d2 y
ln y/a1/b1/c3/d1 z
ln y/a1/b1/c2/d2 z
ln y/a1/b2/c1/d3 z

Now - ln z/a3/b1/c3/d1 x - how many directories do you need to
examine to tell if this is a loop?  Is it still a loop if I rm z/d1 first?
or z/d2? or do I need to remove z/d1 through z/d3 to prevent a loop?
Can I leave z/d1 there but remove y/a1/b2/c3/d1 instead?
Does your answer change if somebody did 'ln y/a1/b2/c4 z/a1/b3/d7'?

How many places would you have to look if I didn't give you a cheat sheet
of the ln commands I had done?  Yes, you have to search *every* directory
under x, y, and z.  All 120 of them.  And this is an artificially small
directory tree.  Think about a /usr/src/ that has 4 or 5 linux-kernel
trees in it, with some 1,650 directories per tree...

> Should be obvious that the average case is much less than the
> whole tree.

"The average case" is the one where the feature isn't used.  When you
actually *use* it, you get "not average case" behavior - not a good sign.

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

Even if that's sufficient (which it isn't), it's going to be painful to lock
the filesystem for 20 or 30 seconds while you walk everything to make sure
there's no problem.  


[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

  parent reply	other threads:[~2006-07-24 18:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6ARGK-19L-5@gated-at.bofh.it>
     [not found] ` <6B8og-1iB-17@gated-at.bofh.it>
2006-07-22 16:59   ` what is necessary for directory hard links Bodo Eggert
2006-07-22 18:13     ` Joshua Hudson
2006-07-24  6:45       ` Nikita Danilov
2006-07-24  7:25         ` Valdis.Kletnieks
2006-07-24 16:21           ` Joshua Hudson
2006-07-24 17:55             ` Horst H. von Brand
2006-07-24 18:22             ` Valdis.Kletnieks [this message]
2006-07-25  4:49               ` Joshua Hudson
2006-07-25 12:43                 ` Valdis.Kletnieks
2006-07-25 14:47                 ` Horst H. von Brand
2006-07-23  2:19     ` Horst H. von Brand
2006-07-23 22:27       ` Vernon Mauery
2006-07-25 23:43       ` Peter Chubb
     [not found] <6CcT1-1lH-39@gated-at.bofh.it>
     [not found] ` <6Cwov-5xl-5@gated-at.bofh.it>
2006-07-25 21:28   ` Bodo Eggert
2006-07-26  1:00     ` Horst H. von Brand
2006-07-26  9:13       ` Bodo Eggert
2006-07-21  1:04 Joshua Hudson
2006-07-21 18:49 ` Horst H. von Brand
2006-07-21 20:28 ` Rob Sims
2006-07-21 21:57   ` Joshua Hudson
2006-07-24  6:42     ` Nikita Danilov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200607241822.k6OIMJcY014229@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=joshudson@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).