From: Linus Torvalds (torvalds@klaava.Helsinki.FI)
Date: 12/18/92


From: torvalds@klaava.Helsinki.FI (Linus Torvalds)
Subject: Re: [Q] Does Linux fs hate large Directories?
Date: 18 Dec 1992 10:44:29 GMT

In article <1992Dec14.124205.417@camaro> tfoley@camaro (Tim Foley) writes:
>
> Does Linux 0.98p1 have a problem with large directories?

I already replied to Tim, but I thought I'd mention it publicly as well:
yes, linux 0.99 (as well as all earlier versions) have problems with
directories that contain many subdirectories. The reason is simple: the
minix filesystem uses only a unsigned char for the nlinks field, so if
you create a lot of directories, nlinks will overflow, as it's not
checked for. The solution is either to use the extended filesystem
(which uses unsigned shorts) or to live with the limitation that you
can't have more than about 250 subdirectories in the same directory.

Here is a patche to make the kernel check it (easy enough..): apply by
hand to linux/fs/minix/namei.c, beginning of the minix_mkdir() function.

===== pseudo=patch =====
                iput(dir);
                return -EEXIST;
        }
+ if (dir->i_nlink > 250) {
+ iput(dir);
+ return -EMLINK;
+ }
        inode = minix_new_inode(dir);
        if (!inode) {
===== pseudo=patch =====

Alternatively, wait until Sunday, when I'll make 0.99.1 available for
final testing before 1.0.

                Linus