Directories with 2million files

Dan Nelson dnelson at allantgroup.com
Wed Apr 21 14:06:16 PDT 2004


In the last episode (Apr 21), Garance A Drosihn said:
> At 3:09 PM -0500 4/21/04, Eric Anderson wrote:
> >$ du -s
> >du: fts_read: Cannot allocate memory
> 
> Huh.  Well, that seems pretty broken...

The only allocation du does is for its hardlink cache, and it only
stores inodes with a link count >1 in it, so no amount of regular files
should make a difference.  I think it's the fts code that's at fault. 
See the fts_build function in src/lib/libc/gen/fts.c:

/*
 * This is the tricky part -- do not casually change *anything* in
 * here.  The idea is to build the linked list of entries that are used
 * by fts_children and fts_read.  There are lots of special cases.

I know building the list is required for fts_children(), but I don't
know how feasible it would be to rewrite it so a plain
fts_open()/fts_read() loop doesn't create the list internally.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-current mailing list