diff options
Diffstat (limited to 'include/linux/fdtable.h')
-rw-r--r-- | include/linux/fdtable.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index a2ec74bc4812..133c0ba25e30 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -11,6 +11,7 @@ #include <linux/rcupdate.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/fs.h> #include <asm/atomic.h> @@ -30,7 +31,7 @@ struct embedded_fd_set { struct fdtable { unsigned int max_fds; - struct file ** fd; /* current fd array */ + struct file __rcu **fd; /* current fd array */ fd_set *close_on_exec; fd_set *open_fds; struct rcu_head rcu; @@ -45,7 +46,7 @@ struct files_struct { * read mostly part */ atomic_t count; - struct fdtable *fdt; + struct fdtable __rcu *fdt; struct fdtable fdtab; /* * written part on a separate cache line in SMP @@ -54,10 +55,18 @@ struct files_struct { int next_fd; struct embedded_fd_set close_on_exec_init; struct embedded_fd_set open_fds_init; - struct file * fd_array[NR_OPEN_DEFAULT]; + struct file __rcu * fd_array[NR_OPEN_DEFAULT]; }; -#define files_fdtable(files) (rcu_dereference((files)->fdt)) +#define rcu_dereference_check_fdtable(files, fdtfd) \ + (rcu_dereference_check((fdtfd), \ + rcu_read_lock_held() || \ + lockdep_is_held(&(files)->file_lock) || \ + atomic_read(&(files)->count) == 1 || \ + rcu_my_thread_group_empty())) + +#define files_fdtable(files) \ + (rcu_dereference_check_fdtable((files), (files)->fdt)) struct file_operations; struct vfsmount; @@ -78,7 +87,7 @@ static inline struct file * fcheck_files(struct files_struct *files, unsigned in struct fdtable *fdt = files_fdtable(files); if (fd < fdt->max_fds) - file = rcu_dereference(fdt->fd[fd]); + file = rcu_dereference_check_fdtable(files, fdt->fd[fd]); return file; } |