diff options
author | Dipankar Sarma <dipankar@in.ibm.com> | 2006-04-19 17:00:12 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-04-24 09:56:05 -0700 |
commit | 95fb678bf90572414b1c2f239c6a44226049ba8a (patch) | |
tree | b7246d566793a2672111c598a450ba98fdc55b4e /fs/locks.c | |
parent | bd6b6027eacb8e5ef633aa0e1c2576dc5a464675 (diff) |
[PATCH] Fix file lookup without ref
There are places in the kernel where we look up files in fd tables and
access the file structure without holding refereces to the file. So, we
need special care to avoid the race between looking up files in the fd
table and tearing down of the file in another CPU. Otherwise, one might
see a NULL f_dentry or such torn down version of the file. This patch
fixes those special places where such a race may happen.
Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
Acked-by: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/locks.c b/fs/locks.c index 909eab8fb1d..e75ac392a31 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2212,7 +2212,12 @@ void steal_locks(fl_owner_t from) lock_kernel(); j = 0; - rcu_read_lock(); + + /* + * We are not taking a ref to the file structures, so + * we need to acquire ->file_lock. + */ + spin_lock(&files->file_lock); fdt = files_fdtable(files); for (;;) { unsigned long set; @@ -2230,7 +2235,7 @@ void steal_locks(fl_owner_t from) set >>= 1; } } - rcu_read_unlock(); + spin_unlock(&files->file_lock); unlock_kernel(); } EXPORT_SYMBOL(steal_locks); |