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 /include/linux/file.h | |
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 'include/linux/file.h')
-rw-r--r-- | include/linux/file.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index 5206beb9a80e..db372230848e 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
@@ -16,23 +16,29 @@ | |||
16 | */ | 16 | */ |
17 | #define NR_OPEN_DEFAULT BITS_PER_LONG | 17 | #define NR_OPEN_DEFAULT BITS_PER_LONG |
18 | 18 | ||
19 | struct fdtable { | ||
20 | unsigned int max_fds; | ||
21 | int max_fdset; | ||
22 | int next_fd; | ||
23 | struct file ** fd; /* current fd array */ | ||
24 | fd_set *close_on_exec; | ||
25 | fd_set *open_fds; | ||
26 | }; | ||
27 | |||
19 | /* | 28 | /* |
20 | * Open file table structure | 29 | * Open file table structure |
21 | */ | 30 | */ |
22 | struct files_struct { | 31 | struct files_struct { |
23 | atomic_t count; | 32 | atomic_t count; |
24 | spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ | 33 | spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */ |
25 | int max_fds; | 34 | struct fdtable fdtab; |
26 | int max_fdset; | ||
27 | int next_fd; | ||
28 | struct file ** fd; /* current fd array */ | ||
29 | fd_set *close_on_exec; | ||
30 | fd_set *open_fds; | ||
31 | fd_set close_on_exec_init; | 35 | fd_set close_on_exec_init; |
32 | fd_set open_fds_init; | 36 | fd_set open_fds_init; |
33 | struct file * fd_array[NR_OPEN_DEFAULT]; | 37 | struct file * fd_array[NR_OPEN_DEFAULT]; |
34 | }; | 38 | }; |
35 | 39 | ||
40 | #define files_fdtable(files) (&(files)->fdtab) | ||
41 | |||
36 | extern void FASTCALL(__fput(struct file *)); | 42 | extern void FASTCALL(__fput(struct file *)); |
37 | extern void FASTCALL(fput(struct file *)); | 43 | extern void FASTCALL(fput(struct file *)); |
38 | 44 | ||
@@ -63,9 +69,10 @@ extern int expand_files(struct files_struct *, int nr); | |||
63 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) | 69 | static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) |
64 | { | 70 | { |
65 | struct file * file = NULL; | 71 | struct file * file = NULL; |
72 | struct fdtable *fdt = files_fdtable(files); | ||
66 | 73 | ||
67 | if (fd < files->max_fds) | 74 | if (fd < fdt->max_fds) |
68 | file = files->fd[fd]; | 75 | file = fdt->fd[fd]; |
69 | return file; | 76 | return file; |
70 | } | 77 | } |
71 | 78 | ||