http://en.wikipedia.org/wiki/Ext3#cite_note-0
The maximum number of inodes (and hence the maximum number of files and directories) is set when the file system is created. If V is the volume size in bytes, then the default number of inodes is given by V/213 (or the number of blocks, whichever is less), and the minimum by V/223. The default was deemed sufficient for most applications. The max number of subdirectories in one directory is fixed to 32000.
http://serverfault.com/questions/43133/filesystem-large-number-of-files-in-a-single-directory
Using tune2fs to enable dir_index might help. To see if it is enabled: sudo tune2fs -l /dev/sda1 | grep dir_index If it is not enabled: sudo umount /dev/sda1 sudo tune2fs -O dir_index /dev/sad1 sudo e2fsck -D /dev/sda1 sudo mount /dev/sda1 But I have a feeling you might be going down the wrong path... why not generate a flat index and use some code to select randomly based on that. You can then use sub directories for a more optimized tree structure.
xfs介绍
http://xfs.org/index.php/XFS_Papers_and_Documentation
----------------------
ext3-handling-large-number-of-files-in-a-directory
http://roopindersingh.com/2008/05/10/ext3-handling-large-number-of-files-in-a-directory/