UFS Subdirectory limit.

David Schultz das at FreeBSD.ORG
Fri Mar 25 19:10:22 PST 2005


On Sat, Mar 26, 2005, David Malone wrote:
> There was a discussion on comp.unix.bsd.freebsd.misc about two weeks
> ago, where someone had an application that used about 150K
> subdirectories of a single directory. They wanted to move this
> application to FreeBSD, but discovered that UFS is limited to 32K
> subdirectories, because UFS's link count field is a signed 16 bit
> quantity. Rewriting the application wasn't an option for them.
> 
> I had a look at how hard it would be to fix this. The obvious route
> of increasing the size of the link count field is trickly because
> it means changing the struct stat, which has a 16 bit link count
> field. This would imply ABI breakage, though it might be worth it.

Why not just...

- make a new st_nlink field that's 32 bits and put it in the spare
  32-bit field in struct stat

- rename the old st_nlink to st_onlink and leave it at 16 bits

- the kernel would fill in st_onlink with max(st_nlink,SHORT_MAX)


More information about the freebsd-fs mailing list