diff options
author | Dipankar Sarma <dipankar@in.ibm.com> | 2005-09-09 16:04:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 16:57:55 -0400 |
commit | badf16621c1f9d1ac753be056fce11b43d6e0be5 (patch) | |
tree | 3fdf833fdf2e3d3a439090743539680449ec3428 /fs/select.c | |
parent | c0dfb2905126e9e94edebbce8d3e05001301f52d (diff) |
[PATCH] files: break up files struct
In order for the RCU to work, the file table array, sets and their sizes must
be updated atomically. Instead of ensuring this through too many memory
barriers, we put the arrays and their sizes in a separate structure. This
patch takes the first step of putting the file table elements in a separate
structure fdtable that is embedded withing files_struct. It also changes all
the users to refer to the file table using files_fdtable() macro. Subsequent
applciation of RCU becomes easier after this.
Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/select.c')
-rw-r--r-- | fs/select.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/select.c b/fs/select.c index b80e7eb0ac0d..2e56325c73c4 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -132,11 +132,13 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds) | |||
132 | unsigned long *open_fds; | 132 | unsigned long *open_fds; |
133 | unsigned long set; | 133 | unsigned long set; |
134 | int max; | 134 | int max; |
135 | struct fdtable *fdt; | ||
135 | 136 | ||
136 | /* handle last in-complete long-word first */ | 137 | /* handle last in-complete long-word first */ |
137 | set = ~(~0UL << (n & (__NFDBITS-1))); | 138 | set = ~(~0UL << (n & (__NFDBITS-1))); |
138 | n /= __NFDBITS; | 139 | n /= __NFDBITS; |
139 | open_fds = current->files->open_fds->fds_bits+n; | 140 | fdt = files_fdtable(current->files); |
141 | open_fds = fdt->open_fds->fds_bits+n; | ||
140 | max = 0; | 142 | max = 0; |
141 | if (set) { | 143 | if (set) { |
142 | set &= BITS(fds, n); | 144 | set &= BITS(fds, n); |
@@ -299,6 +301,7 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s | |||
299 | char *bits; | 301 | char *bits; |
300 | long timeout; | 302 | long timeout; |
301 | int ret, size, max_fdset; | 303 | int ret, size, max_fdset; |
304 | struct fdtable *fdt; | ||
302 | 305 | ||
303 | timeout = MAX_SCHEDULE_TIMEOUT; | 306 | timeout = MAX_SCHEDULE_TIMEOUT; |
304 | if (tvp) { | 307 | if (tvp) { |
@@ -326,7 +329,8 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s | |||
326 | goto out_nofds; | 329 | goto out_nofds; |
327 | 330 | ||
328 | /* max_fdset can increase, so grab it once to avoid race */ | 331 | /* max_fdset can increase, so grab it once to avoid race */ |
329 | max_fdset = current->files->max_fdset; | 332 | fdt = files_fdtable(current->files); |
333 | max_fdset = fdt->max_fdset; | ||
330 | if (n > max_fdset) | 334 | if (n > max_fdset) |
331 | n = max_fdset; | 335 | n = max_fdset; |
332 | 336 | ||
@@ -464,9 +468,11 @@ asmlinkage long sys_poll(struct pollfd __user * ufds, unsigned int nfds, long ti | |||
464 | unsigned int i; | 468 | unsigned int i; |
465 | struct poll_list *head; | 469 | struct poll_list *head; |
466 | struct poll_list *walk; | 470 | struct poll_list *walk; |
471 | struct fdtable *fdt; | ||
467 | 472 | ||
468 | /* Do a sanity check on nfds ... */ | 473 | /* Do a sanity check on nfds ... */ |
469 | if (nfds > current->files->max_fdset && nfds > OPEN_MAX) | 474 | fdt = files_fdtable(current->files); |
475 | if (nfds > fdt->max_fdset && nfds > OPEN_MAX) | ||
470 | return -EINVAL; | 476 | return -EINVAL; |
471 | 477 | ||
472 | if (timeout) { | 478 | if (timeout) { |