From: jw schultz <jw@pegasys.ws>
To: linux-kernel@vger.kernel.org
Subject: Re: [reiserfs-dev] Re: [PATCH] sparc32: wrong type of nlink_t
Date: Thu, 5 Sep 2002 15:57:06 -0700 [thread overview]
Message-ID: <20020905225706.GC3942@pegasys.ws> (raw)
In-Reply-To: <20020906000249.A10844@vestdata.no>
On Fri, Sep 06, 2002 at 12:02:49AM +0200, Ragnar Kjørstad wrote:
> On Thu, Sep 05, 2002 at 02:18:49PM -0700, jw schultz wrote:
> > I'm assuming for the moment that the discussion here is
> > about what to report to stat(2) and not how to deal with
> > internal overflow (which should produce an error).
> >
> > So what you are suggesting is that
> > <pseudocode>
> > if (i.i_nlink > ST_NLINK_MAX)
> > st.st_nlink = S_ISDIR(i.i_mode) ? 1 : ST_NLINK_MAX;
> > </pseudocode>
> >
> > I don't know the rationale for st_nlink == 1 on directories
> > but it seems to me the thing to do is st_nlink == 0 on
> > overflow regardless of type. This simplifies the logic and
> > eliminates the use a funky special value that gets in the
> > way of supporting growth.
>
> I believe nlink for directories and files are used differently,
> and thus may have to be handled differently as well.
>
> Amongs other things nlink on directories are used when traversing
> directory-trees. If nlink=4 on a directory there must be 2
> sub-directories, and you can stop looking once you've found the two.
>
> By giving the incorrect nlink-number, applications using this
> optimization will break.
>
> Apperently some operatingsystems/filesystems (VMS?) report the special
> value of nlink=1 when the information is not available, and some
> applications use this information to automaticly disable the
> optimization. This is why reiserfs has returned nlink=1 for directories
> with more than MAX_REISERFS_NLINK subdirectories.
>
> Now, I've just checked the source of GNU find (v4.1.7) and it does _not_
> recognize nlink=1 as a special value. (It works as long as there are
> less than 2^32 subdirectories though, because it is looking for -1
> subdirectories and it wraps)
So a value of 0 would have the same effect.
(0 - 2 == -2 vs 1 - 2 == -1) Yes?
>
>
> I'm not sure exactly what nlink is used for in userspace for regular
> files, so I don't know what value should be used when the real number
> doesn't fit in the interface.
I know it is used for reporting purposes such as ls -l. It
would also used by archiving tools like cpio, tar and rsync
to identify files that may be linked so that not every file
must be checked against every previous file. A smart
archiving tool would track the link count and remove entries
that have all links found so any value that isn't recognized
as an overflow indicator would tend to break things. I see
the value of 0 as indicating "link count unsupported".
> (Of course new directories/hardlinks shouldn't be created at all once
> the limit is exceeded, the above is only a workaround for people that
> need it anyway :) )
It should not fail just because the type specified for
st_nlink has overflowed. It should fail only if the FS or
kernel internals overflow. Internally the kernel is moving
to an unsigned int. I looked it up a recently and each
filesystem has it's own idea of a maximum number of links
and most of them are not just arbitrary but even strange
such as 32000 or 0x7FFF - 1000.
The stat structure has already been left behind on this.
Eventually (3.0?) it should be updated to reflect the
changed internals. This update has to be delayed because it
will break binary compatability of oodles of code. I, at
least, don't think this is worth creating yet another
version of stat(2).
--
________________________________________________________________
J.W. Schultz Pegasystems Technologies
email address: jw@pegasys.ws
Remember Cernan and Schmitt
next prev parent reply other threads:[~2002-09-05 22:54 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-01 8:55 [PATCH] sparc32: wrong type of nlink_t Tomas Szepe
2002-09-01 8:52 ` David S. Miller
2002-09-01 9:44 ` Tomas Szepe
2002-09-04 20:18 ` Dave Kleikamp
2002-09-04 20:29 ` [reiserfs-dev] " Chris Mason
2002-09-04 23:34 ` David S. Miller
2002-09-06 8:52 ` David Woodhouse
2002-09-04 20:31 ` Hans Reiser
2002-09-04 21:18 ` Tomas Szepe
2002-09-04 21:44 ` Thunder from the hill
2002-09-04 21:57 ` Thunder from the hill
2002-09-04 23:35 ` David S. Miller
2002-09-05 0:36 ` Hans Reiser
2002-09-05 0:32 ` David S. Miller
2002-09-05 0:49 ` Chris Mason
2002-09-05 5:40 ` Tomas Szepe
2002-09-05 5:36 ` David S. Miller
2002-09-05 5:48 ` Tomas Szepe
2002-09-05 5:45 ` David S. Miller
2002-09-05 9:46 ` Nikita Danilov
2002-09-05 5:56 ` Oleg Drokin
2002-09-05 5:52 ` David S. Miller
2002-09-05 6:07 ` Oleg Drokin
2002-09-05 5:59 ` Tomas Szepe
2002-09-05 9:54 ` Oleg Drokin
2002-09-05 10:50 ` David S. Miller
2002-09-05 13:49 ` Oleg Drokin
2002-09-05 13:57 ` Oleg Drokin
2002-09-05 14:03 ` Chris Mason
2002-09-05 14:17 ` Oleg Drokin
2002-09-05 16:45 ` Chris Mason
2002-09-05 17:25 ` Oleg Drokin
2002-09-05 21:18 ` jw schultz
2002-09-05 22:02 ` Ragnar Kjørstad
2002-09-05 22:57 ` jw schultz [this message]
2002-09-06 0:01 ` Ragnar Kjørstad
2002-09-06 1:41 ` jw schultz
2002-09-06 2:29 ` Ragnar Kjørstad
2002-09-05 16:09 ` Dave Kleikamp
2002-09-05 16:13 ` Oleg Drokin
2002-09-05 17:58 ` Dave Kleikamp
2002-09-06 13:54 ` Oleg Drokin
2002-09-05 17:24 ` Linus Torvalds
2002-09-04 23:33 ` David S. Miller
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=20020905225706.GC3942@pegasys.ws \
--to=jw@pegasys.ws \
--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