From owner-freebsd-questions Thu Feb 27 16:39: 8 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1CAE037B401 for ; Thu, 27 Feb 2003 16:39:06 -0800 (PST) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id 9D8D443F85 for ; Thu, 27 Feb 2003 16:39:03 -0800 (PST) (envelope-from ertr1013@student.uu.se) Received: (qmail 1930 invoked by uid 1001); 28 Feb 2003 00:39:01 -0000 Date: Fri, 28 Feb 2003 01:39:00 +0100 From: Erik Trulsson To: How Can ThisBe Cc: freebsd-questions@FreeBSD.ORG Subject: Re: File system limits Message-ID: <20030228003859.GA1846@falcon.midgard.homeip.net> Mail-Followup-To: How Can ThisBe , freebsd-questions@FreeBSD.ORG References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.3i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Feb 28, 2003 at 12:11:14AM +0000, How Can ThisBe wrote: > I'm working on a little experimental script and I'm wondering if there > is any kind of limit as to how many files or subdirectories a directory > can have. Yes, there is a limit on how many subdirectories a directory can have. This is because there is a limit on how many hardlinks there can be to a given file/directory and each directory has a link ("..") to its parent. The count for how many hardlinks there are to a given inode is kept as a signed 16-bit integer which means that you can have a bit over 32000 subdirectories in a given directory. (Each of those can of course have some 32000 subdirectories and so on.) There is no limit on how many files you can have in a directory, but if you have too many entries in a directory it can be slow to open/list/create files there. This is because a directory is essentially just a file containing a list of all files/subdirectories in it and to find a particular file a linear search is needed. This means that it can sometimes be faster to have a few extra levels of subdirectories rather than just a few levels with a lot of files at each level. As for how many is too many, I am not sure but I think you might start to see a slowdown after a couple of thousand entries. (The UFS_DIRHASH kernel option reduces the impact of large number of directory entries, at least after the first access, so then you should be able to have several thousand entries without any noticable slowdown.) > > I'm in the planing stages at the moment and I'm think that I may have > upto 4096 directories in a single directory, each of these 4096 > directories could have upto 4096 sub directories... That should not be a problem. Depending on how you access these directories you *might* see some of the slowdown for large directories that I mentioned above, so it might be a good idea to reduce these numbers somewhat (to 2048 or 1024 maybe), but functionally it won't be a problem. (And if you use the UFS_DIRHASH option, which I believe is used by default in the GENERIC kernel, there should not be any noticable slowdown either.) (It won't be a problem for the computer anyway, but for a human trying to look through directories it quickly becomes unwieldy once the number of entries in a directory start exceeding a couple of hundred.) > > The other option I have (if this is too many) is to have 256 > subdirectories (I'm guessing this on will not be a problem) -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message