Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[safe/jmp/linux-2.6] / include / linux / fdtable.h
index 4aab6f1..013dc52 100644 (file)
@@ -5,12 +5,14 @@
 #ifndef __LINUX_FDTABLE_H
 #define __LINUX_FDTABLE_H
 
-#include <asm/atomic.h>
 #include <linux/posix_types.h>
 #include <linux/compiler.h>
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
 #include <linux/types.h>
+#include <linux/init.h>
+
+#include <asm/atomic.h>
 
 /*
  * The default fd array needs to be at least BITS_PER_LONG,
@@ -55,9 +57,14 @@ struct files_struct {
        struct file * 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))
 
-extern struct kmem_cache *filp_cachep;
+#define files_fdtable(files) \
+               (rcu_dereference_check_fdtable((files), (files)->fdt))
 
 struct file_operations;
 struct vfsmount;
@@ -78,7 +85,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;
 }