Re: How to make sysctl.conf effect?

From: Dan Nelson <dnelson_at_allantgroup.com>
Date: Fri, 11 Sep 2009 01:30:55 -0500
In the last episode (Sep 11), fulan Peng said:
> I am sorry if this is not the right place to ask this question.
> I am using freebsd amd64 7.2.
> I cannot make more than 32768 directories in a folder. So I edited
> /etc/sysctl.conf and added a line
> vfs_ufs_dirhash_maxmem=67108864
> when I do sysctl -a |grep mem, I saw the setting was correct.
> But when I went into a directory and try to make more than 32768
> subdirectories, it always was told me too many links. I have rebooted
> many, many times. I even powered of the computer several times. I have
> 6G memory in the computer. And I even recompiled the kernel once. All
> failed.

dirhash is simply a speed optimization for large directories.  It doesn't
set a hard limit of any sort.  

Your problem is that you are using the UFS filesystem, which does not allow
more than 32768 subdirectories.  The "number of links" counter in UFS
filesystems is a signed short type, and each subdirectory has to create a
".." link back to the parent directory, so if you try to create more than
32768 subdirectories, it fails because the parent directory would exceed the
maximum link count.

You'll need to either create multiple levels of directories (i.e.  make
directories called 345/678/ instead of 345678/ ), or switch to the zfs
filesystem, which has a much higher limit.  I was able to create 1 million
subdirs as a test, using zsh's brace expansion syntax to generate the
directory names:

(dan_at_dan) / # zfs create -o mountpoint=/tmp/zz local/zz
(dan_at_dan) / # cd /tmp/zz
(dan_at_dan) /tmp/zz/ # for i in {00..99} ; do echo ${i}0000 ; mkdir ${i}{0000..9999} ; done
000000
[..]
990000
(dan_at_dan) /tmp/zz/ # echo * | wc -w
1000000


-- 
	Dan Nelson
	dnelson_at_allantgroup.com
Received on Fri Sep 11 2009 - 04:30:58 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:55 UTC