diff options
Diffstat (limited to 'fs/fs_struct.c')
-rw-r--r-- | fs/fs_struct.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/fs/fs_struct.c b/fs/fs_struct.c index eee059052db5..ed45a9cf5f3d 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c | |||
@@ -13,11 +13,11 @@ void set_fs_root(struct fs_struct *fs, struct path *path) | |||
13 | { | 13 | { |
14 | struct path old_root; | 14 | struct path old_root; |
15 | 15 | ||
16 | write_lock(&fs->lock); | 16 | spin_lock(&fs->lock); |
17 | old_root = fs->root; | 17 | old_root = fs->root; |
18 | fs->root = *path; | 18 | fs->root = *path; |
19 | path_get(path); | 19 | path_get(path); |
20 | write_unlock(&fs->lock); | 20 | spin_unlock(&fs->lock); |
21 | if (old_root.dentry) | 21 | if (old_root.dentry) |
22 | path_put(&old_root); | 22 | path_put(&old_root); |
23 | } | 23 | } |
@@ -30,11 +30,11 @@ void set_fs_pwd(struct fs_struct *fs, struct path *path) | |||
30 | { | 30 | { |
31 | struct path old_pwd; | 31 | struct path old_pwd; |
32 | 32 | ||
33 | write_lock(&fs->lock); | 33 | spin_lock(&fs->lock); |
34 | old_pwd = fs->pwd; | 34 | old_pwd = fs->pwd; |
35 | fs->pwd = *path; | 35 | fs->pwd = *path; |
36 | path_get(path); | 36 | path_get(path); |
37 | write_unlock(&fs->lock); | 37 | spin_unlock(&fs->lock); |
38 | 38 | ||
39 | if (old_pwd.dentry) | 39 | if (old_pwd.dentry) |
40 | path_put(&old_pwd); | 40 | path_put(&old_pwd); |
@@ -51,7 +51,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root) | |||
51 | task_lock(p); | 51 | task_lock(p); |
52 | fs = p->fs; | 52 | fs = p->fs; |
53 | if (fs) { | 53 | if (fs) { |
54 | write_lock(&fs->lock); | 54 | spin_lock(&fs->lock); |
55 | if (fs->root.dentry == old_root->dentry | 55 | if (fs->root.dentry == old_root->dentry |
56 | && fs->root.mnt == old_root->mnt) { | 56 | && fs->root.mnt == old_root->mnt) { |
57 | path_get(new_root); | 57 | path_get(new_root); |
@@ -64,7 +64,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root) | |||
64 | fs->pwd = *new_root; | 64 | fs->pwd = *new_root; |
65 | count++; | 65 | count++; |
66 | } | 66 | } |
67 | write_unlock(&fs->lock); | 67 | spin_unlock(&fs->lock); |
68 | } | 68 | } |
69 | task_unlock(p); | 69 | task_unlock(p); |
70 | } while_each_thread(g, p); | 70 | } while_each_thread(g, p); |
@@ -87,10 +87,10 @@ void exit_fs(struct task_struct *tsk) | |||
87 | if (fs) { | 87 | if (fs) { |
88 | int kill; | 88 | int kill; |
89 | task_lock(tsk); | 89 | task_lock(tsk); |
90 | write_lock(&fs->lock); | 90 | spin_lock(&fs->lock); |
91 | tsk->fs = NULL; | 91 | tsk->fs = NULL; |
92 | kill = !--fs->users; | 92 | kill = !--fs->users; |
93 | write_unlock(&fs->lock); | 93 | spin_unlock(&fs->lock); |
94 | task_unlock(tsk); | 94 | task_unlock(tsk); |
95 | if (kill) | 95 | if (kill) |
96 | free_fs_struct(fs); | 96 | free_fs_struct(fs); |
@@ -104,14 +104,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old) | |||
104 | if (fs) { | 104 | if (fs) { |
105 | fs->users = 1; | 105 | fs->users = 1; |
106 | fs->in_exec = 0; | 106 | fs->in_exec = 0; |
107 | rwlock_init(&fs->lock); | 107 | spin_lock_init(&fs->lock); |
108 | fs->umask = old->umask; | 108 | fs->umask = old->umask; |
109 | read_lock(&old->lock); | 109 | get_fs_root_and_pwd(old, &fs->root, &fs->pwd); |
110 | fs->root = old->root; | ||
111 | path_get(&old->root); | ||
112 | fs->pwd = old->pwd; | ||
113 | path_get(&old->pwd); | ||
114 | read_unlock(&old->lock); | ||
115 | } | 110 | } |
116 | return fs; | 111 | return fs; |
117 | } | 112 | } |
@@ -126,10 +121,10 @@ int unshare_fs_struct(void) | |||
126 | return -ENOMEM; | 121 | return -ENOMEM; |
127 | 122 | ||
128 | task_lock(current); | 123 | task_lock(current); |
129 | write_lock(&fs->lock); | 124 | spin_lock(&fs->lock); |
130 | kill = !--fs->users; | 125 | kill = !--fs->users; |
131 | current->fs = new_fs; | 126 | current->fs = new_fs; |
132 | write_unlock(&fs->lock); | 127 | spin_unlock(&fs->lock); |
133 | task_unlock(current); | 128 | task_unlock(current); |
134 | 129 | ||
135 | if (kill) | 130 | if (kill) |
@@ -148,7 +143,7 @@ EXPORT_SYMBOL(current_umask); | |||
148 | /* to be mentioned only in INIT_TASK */ | 143 | /* to be mentioned only in INIT_TASK */ |
149 | struct fs_struct init_fs = { | 144 | struct fs_struct init_fs = { |
150 | .users = 1, | 145 | .users = 1, |
151 | .lock = __RW_LOCK_UNLOCKED(init_fs.lock), | 146 | .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock), |
152 | .umask = 0022, | 147 | .umask = 0022, |
153 | }; | 148 | }; |
154 | 149 | ||
@@ -161,14 +156,14 @@ void daemonize_fs_struct(void) | |||
161 | 156 | ||
162 | task_lock(current); | 157 | task_lock(current); |
163 | 158 | ||
164 | write_lock(&init_fs.lock); | 159 | spin_lock(&init_fs.lock); |
165 | init_fs.users++; | 160 | init_fs.users++; |
166 | write_unlock(&init_fs.lock); | 161 | spin_unlock(&init_fs.lock); |
167 | 162 | ||
168 | write_lock(&fs->lock); | 163 | spin_lock(&fs->lock); |
169 | current->fs = &init_fs; | 164 | current->fs = &init_fs; |
170 | kill = !--fs->users; | 165 | kill = !--fs->users; |
171 | write_unlock(&fs->lock); | 166 | spin_unlock(&fs->lock); |
172 | 167 | ||
173 | task_unlock(current); | 168 | task_unlock(current); |
174 | if (kill) | 169 | if (kill) |