From: Urs Thuermann <urs@isnogud.escape.de>
To: <linux-btrfs@vger.kernel.org>
Subject: Re: Link count for directories
Date: 26 Aug 2020 09:04:21 +0200 [thread overview]
Message-ID: <ygfd03dkhvu.fsf@tehran.isnogud.escape.de> (raw)
In-Reply-To: <A61FAA28-DE0C-42BD-8074-756765C5557E@fb.com>; from "Chris Mason" on Tue, 25 Aug 2020 09:46:02 -0400
Chris Mason <clm@fb.com> writes:
> > Wrong, ext4 and xfs do maintain the count.
>
> Correct, at least until they hit 65536.
For ext4 the limit is actually 65000 links. For directories, nlink is
set to 1 if an additional sub-directory is created (and stays at 1
even if you remove directories), while for other file you get EMLNK.
In xfs there seems to be no limit (dirs and other files, I have seen
more than 200000 for both) and btrfs has a limit of 65535 links on
non-directories.
> Find certainly paid attention, but from an optimization point of
> view, dtype in directory entries is dramatically more helpful.
1. dtype is not in POSIX. OTOH, I seem to remember that POSIX states
st_link == 1 for directories or otherwise it has the traditional
value of 2 + sub-directory count. However, I cannot find this
anymore. Is that correct and can anyone give me a pointer?
2. If you just want to find all directories you only need stat(2) on a
directory and if it has st_nlink == 2 you don't need to read all
directory entries (with or without dtype). So this optimization is
possible with the traditional link count of directories but not
with dtype.
> I'd want to see big wins from applications before adding this
> into btrfs.
I would expect noticable but not big wins. However, I'd like adding
this to btrfs just because it looks nicer. Since ls (and readdir)
gives you the . and .. links they should be counted in the usual way.
urs
next prev parent reply other threads:[~2020-08-26 7:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 17:40 Link count for directories Steve Keller
2020-08-24 12:44 ` Nikolay Borisov
2020-08-24 21:50 ` Steve Keller
2020-08-24 22:23 ` Adam Borowski
2020-08-25 12:24 ` Urs Thuermann
2020-08-25 12:38 ` Nikolay Borisov
2020-08-25 12:37 ` Nikolay Borisov
2020-08-25 13:46 ` Chris Mason
2020-08-26 7:04 ` Urs Thuermann [this message]
2020-08-31 13:03 ` David Sterba
2020-08-25 12:39 ` Nikolay Borisov
2020-08-31 13:18 ` David Sterba
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=ygfd03dkhvu.fsf@tehran.isnogud.escape.de \
--to=urs@isnogud.escape.de \
--cc=linux-btrfs@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