508 root node entries (root_limit)
510 internal node entries (node_limit)
For a filename with 40 bytes, its sizeof(ext4_dir_entry_2) = 48, a linear directory can contain at most floor(4096/48)=85 of them.
The real per-directory entry limit should be 508*510*85 = 22021800
The limit varies with the average length of filenames.
However, the Linux ext4 code does not try rebalancing the htree, so we will not be able to create filenames in a full leaf node. This is demonstrated with the following example, certain filenames cannot be used while others can:
% touch d/0000000000000000000000000000000000816a6f touch: cannot touch 'd/0000000000000000000000000000000000816a6f': No space left on device % touch d/0000000000000000000000000000000000816a70 # succeeded
Remove sentence as it is duplicated below.