On Sun, May 18, 2008 at 05:36:02PM +0200, Bernie Innocenti wrote:> > Some background: I'm moving users' Maildirs to a separate filesystem tuned > for small files to increase performance. One of our users intentionally > collected spam for 5 years in one folder and likes it this way. > We could easily work it around, but first I'd like to understand whether > the particular parameters we used trigger a bug in ext3 or if we're just > hitting a (possibly undocumented) limit.No, not a bug, but a limit. Ext3's hash directores are limited to a depth of 3 blocks, which normally isn't a problem if you are using a 4k blocksize, since each internal node is small; only 8 bytes. So you have a fanout of 508 for each internal node, and two internal nodes gets you to over 250,000 4k directory blocks. But with a 1k blocksize, the internal node fanout is only 124, so that only gets you a bit more than 15,000 1k directory blocks. We could remove this limit at some point; the problem is that Daniel Phillip's original code had this as a limitation, and fixing it would mean replacing the tree implementation. We actually have some code from Lustre that we could use for this purpose, but to date we've been focused on some other higher priority items for ext4. - Ted
On Mon, May 19, 2008 at 01:01:57AM +0200, Stefano Fedrigo wrote:> > So, if I understand correctly, with a 1024 bytes blocksize, dir_index, and > inode size of 128 byte, the maximum number of files in a directory is > 123008. With 4k blocks this limit rises to 8,258,048 files?It depends on the length of the directory entries, and how full the various directory blocks end up getting (which is a function of the directory names used and the per-filesystem hash seed). But in general, the maximum limit goes up as the cube of the blocksize. So a 4k filesystem can store roughly 64 times as many files ; a filesystem using 16k blocks (say, on a Power or IA64 architecture) will be able to store roughly 4,096 as many files in a single directory. (So around 819 million files in a single directory, using the original maildir example). Seriously, though, past a certain point, if you really want to store that many small datums, you should really consider a database.... - Ted