您的位置:首页 > 其它

一封有趣的邮件列表

2010-04-25 11:19 211 查看



昨天debian user邮件列表里有一封很有意思的邮件。

Hi,
ext3 can have only 32000 files/folders under a folder and I hit that limit.
Which file system can I use to over come it?
I am planning for JFS
Does anybody has any recommendations?
Thanks
--Siju


我的第一反应是使用ext4文档系统。 正如Siju George <sgeorge.ml@gmail.com
> :(该问题的提出者)一样, 我也没有考虑这个问题是否正确。

可能他也是看了某些书, 然后提了这个问题:目录里面最多能建立32000 个文件/文件夹(直译)。

然后, 邮件列表里面的讨论很热闹。

比如:

ext4 is unlimited. http://en.wikipedia.org/wiki/Ext4 is wrong in the section "Break 32,000
subdirectory limit". SOmeone should correct it, because https://ext4.wiki.kernel.org/ind ... rectory_scalability
clearly tells " Ext4 breaks that limit and allows unlimited number of
sub directories".
There is also an ext3 -> ext4 howto in the same page I gave above.


还有一个人使用用perl和bash测试了一下, 以显示 一个目录(文件夹)下面可以有无**的文件,

There is no such limit.  ext3 can handle as many files per folder
as you've got space for.
$ mkdir /tmp/foo
$ cd /tmp/foo
$ perl -e 'for ($i=0; $i<50000; ++$i) { open(F, ">$i"); close(F); }'
$ ls | wc -l
50000
$ mount | grep md1
/dev/md1 on / type ext3 (rw,errors=remount-ro)
$ mount | grep /tmp
$ cd
$ rm -rf /tmp/foo


我不懂perl


,于是就用bash写了一个小脚本测试一下:

1 #/bin/bash
2 i=0; j=0
3 while [ $i -le 50000 ]
4 do
5         mkdir dir$i
6         i=$[$i + 1]
7
8 done
9
10 while [ $j -le 50000 ]
11 do
12         touch file$j
13         j=$[$j + 1]
14
15 done
~


chmod 711 test.sh
./test.sh


标准输出上是(slice):

mkdir: 无法创建目录 “dir49991”: 过多的连接

.

.

.

mkdir: 无法创建目录 “dir50000”: 过多的连接

wolf@debian:/tmp/tmp$ ls dir* | wc
63995   31998  340867
wolf@debian:/tmp/tmp$ ls file* | wc
50001   50001  488900


注意到, 第二个数值

时间比较的长,众所周知, bash脚本的执行速度是很慢,更何况是50000(达不到,呵呵) + 50000个操作。

事实证明了, 一个目录下面可以建立无穷个file(s), 但是目录不会超过32000(包含本目录, 和对父目录的链接,可建立的只有31998)

至于ext4,可以参考**上面的资料
:摘取片段如下:

Break 32,000 subdirectory limit
In ext3 the number of subdirectories that a directory can contain is limited to 32,000. This limit has been raised to 64,000 in ext4, and with the "dir_nlink" feature it can go beyond this (although it will stop increasing the link count on the parent). To allow for continued performance given the possibility of much larger directories, Htree indexes (a specialized version of a B-tree) are turned on by default in ext4. This feature is implemented in Linux kernel 2.6.23. Htree is also available in ext3 when the dir_index feature is enabled.


http://en.wikipedia.org/wiki/Ext4

#参考wikipedia, debian用户组邮件列表
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: