From 630d9c47274aa89bfa77fe6556d7818bdcb12992 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Wed, 16 Nov 2011 23:57:37 -0500 Subject: fs: reduce the use of module.h wherever possible For files only using THIS_MODULE and/or EXPORT_SYMBOL, map them onto including export.h -- or if the file isn't even using those, then just delete the include. Fix up any implicit include dependencies that were being masked by module.h along the way. Signed-off-by: Paul Gortmaker --- fs/fs_struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/fs_struct.c') diff --git a/fs/fs_struct.c b/fs/fs_struct.c index 78b519c1353..a2d1db2ea98 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include -- cgit v1.2.3-70-g09d2 From 3ee05ed0679f29ab19727067ff7c14f0c257fa9a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 15 Mar 2012 14:48:29 -0400 Subject: no need to play with fs->seq in exit_fs() Signed-off-by: Al Viro --- fs/fs_struct.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'fs/fs_struct.c') diff --git a/fs/fs_struct.c b/fs/fs_struct.c index 78b519c1353..27114b41362 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c @@ -107,10 +107,8 @@ void exit_fs(struct task_struct *tsk) int kill; task_lock(tsk); spin_lock(&fs->lock); - write_seqcount_begin(&fs->seq); tsk->fs = NULL; kill = !--fs->users; - write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); task_unlock(tsk); if (kill) -- cgit v1.2.3-70-g09d2 From 82234e61a8fc75599f29026c0805fc0cfe2a6c87 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 15 Mar 2012 14:48:55 -0400 Subject: vfs: take path_get_longterm() out of write_seqcount scope Signed-off-by: Al Viro --- fs/fs_struct.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'fs/fs_struct.c') diff --git a/fs/fs_struct.c b/fs/fs_struct.c index 27114b41362..6324c427495 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c @@ -26,11 +26,11 @@ void set_fs_root(struct fs_struct *fs, struct path *path) { struct path old_root; + path_get_longterm(path); spin_lock(&fs->lock); write_seqcount_begin(&fs->seq); old_root = fs->root; fs->root = *path; - path_get_longterm(path); write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); if (old_root.dentry) @@ -45,11 +45,11 @@ void set_fs_pwd(struct fs_struct *fs, struct path *path) { struct path old_pwd; + path_get_longterm(path); spin_lock(&fs->lock); write_seqcount_begin(&fs->seq); old_pwd = fs->pwd; fs->pwd = *path; - path_get_longterm(path); write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); @@ -57,6 +57,14 @@ void set_fs_pwd(struct fs_struct *fs, struct path *path) path_put_longterm(&old_pwd); } +static inline int replace_path(struct path *p, const struct path *old, const struct path *new) +{ + if (likely(p->dentry != old->dentry || p->mnt != old->mnt)) + return 0; + *p = *new; + return 1; +} + void chroot_fs_refs(struct path *old_root, struct path *new_root) { struct task_struct *g, *p; @@ -68,21 +76,16 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root) task_lock(p); fs = p->fs; if (fs) { + int hits = 0; spin_lock(&fs->lock); write_seqcount_begin(&fs->seq); - if (fs->root.dentry == old_root->dentry - && fs->root.mnt == old_root->mnt) { - path_get_longterm(new_root); - fs->root = *new_root; + hits += replace_path(&fs->root, old_root, new_root); + hits += replace_path(&fs->pwd, old_root, new_root); + write_seqcount_end(&fs->seq); + while (hits--) { count++; - } - if (fs->pwd.dentry == old_root->dentry - && fs->pwd.mnt == old_root->mnt) { path_get_longterm(new_root); - fs->pwd = *new_root; - count++; } - write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); } task_unlock(p); -- cgit v1.2.3-70-g09d2