ext2/ext3 32000限制

为什么有32000限制?
ext2/ext3有此限制,xfs无,reiserfs限制数量要大些.

mkdir: cannot create directory `test`: Too many links。

I already talked to Drew, there is a limit of 32,000 links in an inode,
which in turn limits the number of directories in a single place to 31,998

There is no way to increase this  in ext2 without changing the inode format,
which will not happen before a little while

Solutions:
1) use base/d/di/directoryname name splits
2) use another filesystem (note that the default filesystem on freebsd, and
   probably many other FS do also have a limit of 32K directories or
   somesuch, so for portability, you want solution #1)
另外,同一个目录下的文件不要太多,听说超过1000个文件或目录时读取速度就有些影响了。

限制来源于:
./linux/ext2_fs.h:
#define EXT2_LINK_MAX 32000

This limit comes from link count of ext2fs's.
You can change the definition of EXT2_LINK_MAX in
include/linux/ext2fs.h upto 32765 since struct inode.i_nlink is
unsigned short, and recompile your kernel.
But another normal kernel will not operate such too many linked files
and directories.



This is imposed by a number of issues:
- EXT2_LINK_MAX=32000 is checked for new subdirectories
- ext2 bg_used_dirs_count is a __u16
- inode->i_nlink (__kernel_nlink_t) is an unsigned short for some platforms

For stat (old interface) the st_nlinks count is also an unsigned short, so
we _should_ be able to increase EXT2_LINK_MAX to 65500 or so safely.  The
VFS will have problems if you increase the max link count over 65535 because
__kernel_nlink_t is __u16.

I see that reiserfs plays some tricks with the directory i_nlink count.
If you exceed 64536 links in a directory, it reverts to "1" and no longer
tracks the link count.

你可能感兴趣的:(linux,FreeBSD)