• Eric Dumazet's avatar
    fs: allow for more than 2^31 files · 518de9b3
    Eric Dumazet authored
    Robin Holt tried to boot a 16TB system and found af_unix was overflowing
    a 32bit value :
    
    <quote>
    
    We were seeing a failure which prevented boot.  The kernel was incapable
    of creating either a named pipe or unix domain socket.  This comes down
    to a common kernel function called unix_create1() which does:
    
            atomic_inc(&unix_nr_socks);
            if (atomic_read(&unix_nr_socks) > 2 * get_max_files())
                    goto out;
    
    The function get_max_files() is a simple return of files_stat.max_files.
    files_stat.max_files is a signed integer and is computed in
    fs/file_table.c's files_init().
    
            n = (mempages * (PAGE_SIZE / 1024)) / 10;
            files_stat.max_files = n;
    
    In our case, mempages (total_ram_pages) is approx 3,758,096,384
    (0xe0000000).  That leaves max_files at approximately 1,503,238,553.
    This causes 2 * get_max_files() to integer overflow.
    
    </quote>
    
    Fix is to let /proc/sys/fs/file-nr & /proc/sys/fs/file-max use long
    integers, and change af_unix to use ...
    518de9b3
sysctl.c 68.4 KB