Files
kernel-tenderloin-3.0/include/linux
Eric Dumazet 7e360c38ab fs: allow for more than 2^31 files
Andrew,

Could you please review this patch, you probably are the right guy to
take it, because it crosses fs and net trees.

Note : /proc/sys/fs/file-nr is a read-only file, so this patch doesnt
depend on previous patch (sysctl: fix min/max handling in
__do_proc_doulongvec_minmax())

Thanks !

[PATCH V4] fs: allow for more than 2^31 files

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 an atomic_long_t instead of
atomic_t.

get_max_files() is changed to return an unsigned long.
get_nr_files() is changed to return a long.

unix_nr_socks is changed from atomic_t to atomic_long_t, while not
strictly needed to address Robin problem.

Before patch (on a 64bit kernel) :
# echo 2147483648 >/proc/sys/fs/file-max
# cat /proc/sys/fs/file-max
-18446744071562067968

After patch:
# echo 2147483648 >/proc/sys/fs/file-max
# cat /proc/sys/fs/file-max
2147483648
# cat /proc/sys/fs/file-nr
704     0       2147483648

Reported-by: Robin Holt <holt@sgi.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: David Miller <davem@davemloft.net>
Reviewed-by: Robin Holt <holt@sgi.com>
Tested-by: Robin Holt <holt@sgi.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-10-25 21:18:20 -04:00
..
2010-08-24 14:57:09 -07:00
2010-08-12 06:38:24 +10:00
2010-10-15 21:18:59 +02:00
2010-09-23 14:33:39 -07:00
2010-08-12 08:43:30 -07:00
2010-10-25 21:18:20 -04:00
2010-10-25 08:02:40 -07:00
2010-08-19 17:18:00 -07:00
2010-08-12 04:14:05 +01:00
2010-10-21 14:47:59 +02:00
2010-09-23 14:33:39 -07:00
2010-08-19 17:18:03 -07:00
2010-08-18 08:35:46 -04:00
2010-10-25 21:18:20 -04:00
2010-09-09 20:46:30 +02:00
2010-10-23 22:49:32 +02:00
2010-10-12 16:53:37 +02:00
2010-08-11 09:23:22 +02:00
2010-09-21 18:04:47 -07:00
2010-08-29 21:57:55 -07:00
2010-08-19 17:16:23 -07:00
2010-09-30 21:16:05 -07:00
2010-08-20 08:55:00 -07:00
2010-08-19 17:18:03 -07:00
2010-08-09 20:45:05 -07:00
2010-10-12 16:53:44 +02:00
2010-10-07 14:08:55 +01:00
2010-10-12 16:39:07 +02:00
2010-08-10 11:49:21 -07:00
2010-08-18 10:19:52 +02:00
2010-08-12 11:27:58 +02:00
2010-10-22 15:34:12 -05:00
2010-08-19 17:18:00 -07:00
2010-09-09 18:57:24 -07:00
2010-10-21 21:18:54 -04:00
2010-08-09 16:48:45 -04:00
2010-08-11 00:29:47 -04:00
2010-10-12 16:53:34 +02:00
2010-10-04 21:10:52 +02:00
2010-10-04 21:10:52 +02:00
2010-10-21 04:26:38 -07:00
2010-08-19 17:18:00 -07:00
2010-08-19 17:18:02 -07:00
2010-10-15 12:45:44 +02:00
2010-08-21 23:40:14 -07:00
2010-08-19 17:18:03 -07:00
2010-09-08 18:16:55 -07:00
2010-08-09 16:47:27 -04:00
2010-10-25 21:18:20 -04:00
2010-10-05 00:29:48 -07:00
2010-09-08 15:04:10 +02:00
2010-10-05 22:10:30 +09:00
2010-10-20 03:02:23 -07:00
2010-10-21 15:44:13 +02:00
2010-10-21 03:09:42 -07:00
2010-10-07 14:08:55 +01:00
2010-08-09 16:48:44 -04:00
2010-09-24 21:27:41 -07:00
2010-08-30 13:23:33 -07:00
2010-10-21 04:11:07 -07:00
2010-09-09 20:41:20 +02:00
2010-10-22 10:20:04 -07:00
2010-10-22 10:16:43 -07:00
2010-08-11 08:59:02 -07:00