From owner-freebsd-current@FreeBSD.ORG Fri Sep 11 06:30:58 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DEAA1065670 for ; Fri, 11 Sep 2009 06:30:58 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 3FAAC8FC0A for ; Fri, 11 Sep 2009 06:30:57 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.0/8.14.0) with ESMTP id n8B6UvGM076043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 11 Sep 2009 01:30:57 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id n8B6UuPw071391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 11 Sep 2009 01:30:56 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id n8B6UuZq071324; Fri, 11 Sep 2009 01:30:56 -0500 (CDT) (envelope-from dan) Date: Fri, 11 Sep 2009 01:30:55 -0500 From: Dan Nelson To: fulan Peng Message-ID: <20090911063055.GC37884@dan.emsphone.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email2.allantgroup.com [199.67.51.78]); Fri, 11 Sep 2009 01:30:57 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-current@freebsd.org Subject: Re: How to make sysctl.conf effect? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2009 06:30:58 -0000 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@dan) / # zfs create -o mountpoint=/tmp/zz local/zz (dan@dan) / # cd /tmp/zz (dan@dan) /tmp/zz/ # for i in {00..99} ; do echo ${i}0000 ; mkdir ${i}{0000..9999} ; done 000000 [..] 990000 (dan@dan) /tmp/zz/ # echo * | wc -w 1000000 -- Dan Nelson dnelson@allantgroup.com