diff options
Diffstat (limited to 'fs/coda')
-rw-r--r-- | fs/coda/cache.c | 17 | ||||
-rw-r--r-- | fs/coda/cnode.c | 19 | ||||
-rw-r--r-- | fs/coda/dir.c | 157 | ||||
-rw-r--r-- | fs/coda/file.c | 31 | ||||
-rw-r--r-- | fs/coda/inode.c | 65 | ||||
-rw-r--r-- | fs/coda/pioctl.c | 23 | ||||
-rw-r--r-- | fs/coda/psdev.c | 42 | ||||
-rw-r--r-- | fs/coda/symlink.c | 3 | ||||
-rw-r--r-- | fs/coda/upcall.c | 89 |
9 files changed, 205 insertions, 241 deletions
diff --git a/fs/coda/cache.c b/fs/coda/cache.c index a5bf5771a22a..9060f08e70cf 100644 --- a/fs/coda/cache.c +++ b/fs/coda/cache.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/list.h> | 18 | #include <linux/list.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/spinlock.h> | ||
20 | 21 | ||
21 | #include <linux/coda.h> | 22 | #include <linux/coda.h> |
22 | #include <linux/coda_linux.h> | 23 | #include <linux/coda_linux.h> |
@@ -31,19 +32,23 @@ void coda_cache_enter(struct inode *inode, int mask) | |||
31 | { | 32 | { |
32 | struct coda_inode_info *cii = ITOC(inode); | 33 | struct coda_inode_info *cii = ITOC(inode); |
33 | 34 | ||
35 | spin_lock(&cii->c_lock); | ||
34 | cii->c_cached_epoch = atomic_read(&permission_epoch); | 36 | cii->c_cached_epoch = atomic_read(&permission_epoch); |
35 | if (cii->c_uid != current_fsuid()) { | 37 | if (cii->c_uid != current_fsuid()) { |
36 | cii->c_uid = current_fsuid(); | 38 | cii->c_uid = current_fsuid(); |
37 | cii->c_cached_perm = mask; | 39 | cii->c_cached_perm = mask; |
38 | } else | 40 | } else |
39 | cii->c_cached_perm |= mask; | 41 | cii->c_cached_perm |= mask; |
42 | spin_unlock(&cii->c_lock); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | /* remove cached acl from an inode */ | 45 | /* remove cached acl from an inode */ |
43 | void coda_cache_clear_inode(struct inode *inode) | 46 | void coda_cache_clear_inode(struct inode *inode) |
44 | { | 47 | { |
45 | struct coda_inode_info *cii = ITOC(inode); | 48 | struct coda_inode_info *cii = ITOC(inode); |
49 | spin_lock(&cii->c_lock); | ||
46 | cii->c_cached_epoch = atomic_read(&permission_epoch) - 1; | 50 | cii->c_cached_epoch = atomic_read(&permission_epoch) - 1; |
51 | spin_unlock(&cii->c_lock); | ||
47 | } | 52 | } |
48 | 53 | ||
49 | /* remove all acl caches */ | 54 | /* remove all acl caches */ |
@@ -57,13 +62,15 @@ void coda_cache_clear_all(struct super_block *sb) | |||
57 | int coda_cache_check(struct inode *inode, int mask) | 62 | int coda_cache_check(struct inode *inode, int mask) |
58 | { | 63 | { |
59 | struct coda_inode_info *cii = ITOC(inode); | 64 | struct coda_inode_info *cii = ITOC(inode); |
60 | int hit; | 65 | int hit; |
61 | 66 | ||
62 | hit = (mask & cii->c_cached_perm) == mask && | 67 | spin_lock(&cii->c_lock); |
63 | cii->c_uid == current_fsuid() && | 68 | hit = (mask & cii->c_cached_perm) == mask && |
64 | cii->c_cached_epoch == atomic_read(&permission_epoch); | 69 | cii->c_uid == current_fsuid() && |
70 | cii->c_cached_epoch == atomic_read(&permission_epoch); | ||
71 | spin_unlock(&cii->c_lock); | ||
65 | 72 | ||
66 | return hit; | 73 | return hit; |
67 | } | 74 | } |
68 | 75 | ||
69 | 76 | ||
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index a7a780929eec..602240569c89 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c | |||
@@ -45,13 +45,15 @@ static void coda_fill_inode(struct inode *inode, struct coda_vattr *attr) | |||
45 | static int coda_test_inode(struct inode *inode, void *data) | 45 | static int coda_test_inode(struct inode *inode, void *data) |
46 | { | 46 | { |
47 | struct CodaFid *fid = (struct CodaFid *)data; | 47 | struct CodaFid *fid = (struct CodaFid *)data; |
48 | return coda_fideq(&(ITOC(inode)->c_fid), fid); | 48 | struct coda_inode_info *cii = ITOC(inode); |
49 | return coda_fideq(&cii->c_fid, fid); | ||
49 | } | 50 | } |
50 | 51 | ||
51 | static int coda_set_inode(struct inode *inode, void *data) | 52 | static int coda_set_inode(struct inode *inode, void *data) |
52 | { | 53 | { |
53 | struct CodaFid *fid = (struct CodaFid *)data; | 54 | struct CodaFid *fid = (struct CodaFid *)data; |
54 | ITOC(inode)->c_fid = *fid; | 55 | struct coda_inode_info *cii = ITOC(inode); |
56 | cii->c_fid = *fid; | ||
55 | return 0; | 57 | return 0; |
56 | } | 58 | } |
57 | 59 | ||
@@ -71,6 +73,7 @@ struct inode * coda_iget(struct super_block * sb, struct CodaFid * fid, | |||
71 | cii = ITOC(inode); | 73 | cii = ITOC(inode); |
72 | /* we still need to set i_ino for things like stat(2) */ | 74 | /* we still need to set i_ino for things like stat(2) */ |
73 | inode->i_ino = hash; | 75 | inode->i_ino = hash; |
76 | /* inode is locked and unique, no need to grab cii->c_lock */ | ||
74 | cii->c_mapcount = 0; | 77 | cii->c_mapcount = 0; |
75 | unlock_new_inode(inode); | 78 | unlock_new_inode(inode); |
76 | } | 79 | } |
@@ -107,14 +110,20 @@ int coda_cnode_make(struct inode **inode, struct CodaFid *fid, struct super_bloc | |||
107 | } | 110 | } |
108 | 111 | ||
109 | 112 | ||
113 | /* Although we treat Coda file identifiers as immutable, there is one | ||
114 | * special case for files created during a disconnection where they may | ||
115 | * not be globally unique. When an identifier collision is detected we | ||
116 | * first try to flush the cached inode from the kernel and finally | ||
117 | * resort to renaming/rehashing in-place. Userspace remembers both old | ||
118 | * and new values of the identifier to handle any in-flight upcalls. | ||
119 | * The real solution is to use globally unique UUIDs as identifiers, but | ||
120 | * retrofitting the existing userspace code for this is non-trivial. */ | ||
110 | void coda_replace_fid(struct inode *inode, struct CodaFid *oldfid, | 121 | void coda_replace_fid(struct inode *inode, struct CodaFid *oldfid, |
111 | struct CodaFid *newfid) | 122 | struct CodaFid *newfid) |
112 | { | 123 | { |
113 | struct coda_inode_info *cii; | 124 | struct coda_inode_info *cii = ITOC(inode); |
114 | unsigned long hash = coda_f2i(newfid); | 125 | unsigned long hash = coda_f2i(newfid); |
115 | 126 | ||
116 | cii = ITOC(inode); | ||
117 | |||
118 | BUG_ON(!coda_fideq(&cii->c_fid, oldfid)); | 127 | BUG_ON(!coda_fideq(&cii->c_fid, oldfid)); |
119 | 128 | ||
120 | /* replace fid and rehash inode */ | 129 | /* replace fid and rehash inode */ |
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index ccd98b0f2b0b..5d8b35539601 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/stat.h> | 17 | #include <linux/stat.h> |
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/smp_lock.h> | 20 | #include <linux/spinlock.h> |
21 | 21 | ||
22 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
23 | 23 | ||
@@ -116,15 +116,11 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc | |||
116 | goto exit; | 116 | goto exit; |
117 | } | 117 | } |
118 | 118 | ||
119 | lock_kernel(); | ||
120 | |||
121 | error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length, | 119 | error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length, |
122 | &type, &resfid); | 120 | &type, &resfid); |
123 | if (!error) | 121 | if (!error) |
124 | error = coda_cnode_make(&inode, &resfid, dir->i_sb); | 122 | error = coda_cnode_make(&inode, &resfid, dir->i_sb); |
125 | 123 | ||
126 | unlock_kernel(); | ||
127 | |||
128 | if (error && error != -ENOENT) | 124 | if (error && error != -ENOENT) |
129 | return ERR_PTR(error); | 125 | return ERR_PTR(error); |
130 | 126 | ||
@@ -140,28 +136,24 @@ exit: | |||
140 | 136 | ||
141 | int coda_permission(struct inode *inode, int mask) | 137 | int coda_permission(struct inode *inode, int mask) |
142 | { | 138 | { |
143 | int error = 0; | 139 | int error; |
144 | 140 | ||
145 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; | 141 | mask &= MAY_READ | MAY_WRITE | MAY_EXEC; |
146 | 142 | ||
147 | if (!mask) | 143 | if (!mask) |
148 | return 0; | 144 | return 0; |
149 | 145 | ||
150 | if ((mask & MAY_EXEC) && !execute_ok(inode)) | 146 | if ((mask & MAY_EXEC) && !execute_ok(inode)) |
151 | return -EACCES; | 147 | return -EACCES; |
152 | 148 | ||
153 | lock_kernel(); | ||
154 | |||
155 | if (coda_cache_check(inode, mask)) | 149 | if (coda_cache_check(inode, mask)) |
156 | goto out; | 150 | return 0; |
157 | 151 | ||
158 | error = venus_access(inode->i_sb, coda_i2f(inode), mask); | 152 | error = venus_access(inode->i_sb, coda_i2f(inode), mask); |
159 | 153 | ||
160 | if (!error) | 154 | if (!error) |
161 | coda_cache_enter(inode, mask); | 155 | coda_cache_enter(inode, mask); |
162 | 156 | ||
163 | out: | ||
164 | unlock_kernel(); | ||
165 | return error; | 157 | return error; |
166 | } | 158 | } |
167 | 159 | ||
@@ -200,41 +192,34 @@ static inline void coda_dir_drop_nlink(struct inode *dir) | |||
200 | /* creation routines: create, mknod, mkdir, link, symlink */ | 192 | /* creation routines: create, mknod, mkdir, link, symlink */ |
201 | static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd) | 193 | static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd) |
202 | { | 194 | { |
203 | int error=0; | 195 | int error; |
204 | const char *name=de->d_name.name; | 196 | const char *name=de->d_name.name; |
205 | int length=de->d_name.len; | 197 | int length=de->d_name.len; |
206 | struct inode *inode; | 198 | struct inode *inode; |
207 | struct CodaFid newfid; | 199 | struct CodaFid newfid; |
208 | struct coda_vattr attrs; | 200 | struct coda_vattr attrs; |
209 | 201 | ||
210 | lock_kernel(); | 202 | if (coda_isroot(dir) && coda_iscontrol(name, length)) |
211 | |||
212 | if (coda_isroot(dir) && coda_iscontrol(name, length)) { | ||
213 | unlock_kernel(); | ||
214 | return -EPERM; | 203 | return -EPERM; |
215 | } | ||
216 | 204 | ||
217 | error = venus_create(dir->i_sb, coda_i2f(dir), name, length, | 205 | error = venus_create(dir->i_sb, coda_i2f(dir), name, length, |
218 | 0, mode, &newfid, &attrs); | 206 | 0, mode, &newfid, &attrs); |
219 | 207 | if (error) | |
220 | if ( error ) { | 208 | goto err_out; |
221 | unlock_kernel(); | ||
222 | d_drop(de); | ||
223 | return error; | ||
224 | } | ||
225 | 209 | ||
226 | inode = coda_iget(dir->i_sb, &newfid, &attrs); | 210 | inode = coda_iget(dir->i_sb, &newfid, &attrs); |
227 | if ( IS_ERR(inode) ) { | 211 | if (IS_ERR(inode)) { |
228 | unlock_kernel(); | 212 | error = PTR_ERR(inode); |
229 | d_drop(de); | 213 | goto err_out; |
230 | return PTR_ERR(inode); | ||
231 | } | 214 | } |
232 | 215 | ||
233 | /* invalidate the directory cnode's attributes */ | 216 | /* invalidate the directory cnode's attributes */ |
234 | coda_dir_update_mtime(dir); | 217 | coda_dir_update_mtime(dir); |
235 | unlock_kernel(); | ||
236 | d_instantiate(de, inode); | 218 | d_instantiate(de, inode); |
237 | return 0; | 219 | return 0; |
220 | err_out: | ||
221 | d_drop(de); | ||
222 | return error; | ||
238 | } | 223 | } |
239 | 224 | ||
240 | static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) | 225 | static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) |
@@ -246,36 +231,29 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) | |||
246 | int error; | 231 | int error; |
247 | struct CodaFid newfid; | 232 | struct CodaFid newfid; |
248 | 233 | ||
249 | lock_kernel(); | 234 | if (coda_isroot(dir) && coda_iscontrol(name, len)) |
250 | |||
251 | if (coda_isroot(dir) && coda_iscontrol(name, len)) { | ||
252 | unlock_kernel(); | ||
253 | return -EPERM; | 235 | return -EPERM; |
254 | } | ||
255 | 236 | ||
256 | attrs.va_mode = mode; | 237 | attrs.va_mode = mode; |
257 | error = venus_mkdir(dir->i_sb, coda_i2f(dir), | 238 | error = venus_mkdir(dir->i_sb, coda_i2f(dir), |
258 | name, len, &newfid, &attrs); | 239 | name, len, &newfid, &attrs); |
259 | 240 | if (error) | |
260 | if ( error ) { | 241 | goto err_out; |
261 | unlock_kernel(); | ||
262 | d_drop(de); | ||
263 | return error; | ||
264 | } | ||
265 | 242 | ||
266 | inode = coda_iget(dir->i_sb, &newfid, &attrs); | 243 | inode = coda_iget(dir->i_sb, &newfid, &attrs); |
267 | if ( IS_ERR(inode) ) { | 244 | if (IS_ERR(inode)) { |
268 | unlock_kernel(); | 245 | error = PTR_ERR(inode); |
269 | d_drop(de); | 246 | goto err_out; |
270 | return PTR_ERR(inode); | ||
271 | } | 247 | } |
272 | 248 | ||
273 | /* invalidate the directory cnode's attributes */ | 249 | /* invalidate the directory cnode's attributes */ |
274 | coda_dir_inc_nlink(dir); | 250 | coda_dir_inc_nlink(dir); |
275 | coda_dir_update_mtime(dir); | 251 | coda_dir_update_mtime(dir); |
276 | unlock_kernel(); | ||
277 | d_instantiate(de, inode); | 252 | d_instantiate(de, inode); |
278 | return 0; | 253 | return 0; |
254 | err_out: | ||
255 | d_drop(de); | ||
256 | return error; | ||
279 | } | 257 | } |
280 | 258 | ||
281 | /* try to make de an entry in dir_inodde linked to source_de */ | 259 | /* try to make de an entry in dir_inodde linked to source_de */ |
@@ -287,52 +265,38 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode, | |||
287 | int len = de->d_name.len; | 265 | int len = de->d_name.len; |
288 | int error; | 266 | int error; |
289 | 267 | ||
290 | lock_kernel(); | 268 | if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) |
291 | |||
292 | if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) { | ||
293 | unlock_kernel(); | ||
294 | return -EPERM; | 269 | return -EPERM; |
295 | } | ||
296 | 270 | ||
297 | error = venus_link(dir_inode->i_sb, coda_i2f(inode), | 271 | error = venus_link(dir_inode->i_sb, coda_i2f(inode), |
298 | coda_i2f(dir_inode), (const char *)name, len); | 272 | coda_i2f(dir_inode), (const char *)name, len); |
299 | |||
300 | if (error) { | 273 | if (error) { |
301 | d_drop(de); | 274 | d_drop(de); |
302 | goto out; | 275 | return error; |
303 | } | 276 | } |
304 | 277 | ||
305 | coda_dir_update_mtime(dir_inode); | 278 | coda_dir_update_mtime(dir_inode); |
306 | atomic_inc(&inode->i_count); | 279 | ihold(inode); |
307 | d_instantiate(de, inode); | 280 | d_instantiate(de, inode); |
308 | inc_nlink(inode); | 281 | inc_nlink(inode); |
309 | 282 | return 0; | |
310 | out: | ||
311 | unlock_kernel(); | ||
312 | return(error); | ||
313 | } | 283 | } |
314 | 284 | ||
315 | 285 | ||
316 | static int coda_symlink(struct inode *dir_inode, struct dentry *de, | 286 | static int coda_symlink(struct inode *dir_inode, struct dentry *de, |
317 | const char *symname) | 287 | const char *symname) |
318 | { | 288 | { |
319 | const char *name = de->d_name.name; | 289 | const char *name = de->d_name.name; |
320 | int len = de->d_name.len; | 290 | int len = de->d_name.len; |
321 | int symlen; | 291 | int symlen; |
322 | int error = 0; | 292 | int error; |
323 | |||
324 | lock_kernel(); | ||
325 | 293 | ||
326 | if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) { | 294 | if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) |
327 | unlock_kernel(); | ||
328 | return -EPERM; | 295 | return -EPERM; |
329 | } | ||
330 | 296 | ||
331 | symlen = strlen(symname); | 297 | symlen = strlen(symname); |
332 | if ( symlen > CODA_MAXPATHLEN ) { | 298 | if (symlen > CODA_MAXPATHLEN) |
333 | unlock_kernel(); | ||
334 | return -ENAMETOOLONG; | 299 | return -ENAMETOOLONG; |
335 | } | ||
336 | 300 | ||
337 | /* | 301 | /* |
338 | * This entry is now negative. Since we do not create | 302 | * This entry is now negative. Since we do not create |
@@ -343,10 +307,9 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de, | |||
343 | symname, symlen); | 307 | symname, symlen); |
344 | 308 | ||
345 | /* mtime is no good anymore */ | 309 | /* mtime is no good anymore */ |
346 | if ( !error ) | 310 | if (!error) |
347 | coda_dir_update_mtime(dir_inode); | 311 | coda_dir_update_mtime(dir_inode); |
348 | 312 | ||
349 | unlock_kernel(); | ||
350 | return error; | 313 | return error; |
351 | } | 314 | } |
352 | 315 | ||
@@ -357,17 +320,12 @@ static int coda_unlink(struct inode *dir, struct dentry *de) | |||
357 | const char *name = de->d_name.name; | 320 | const char *name = de->d_name.name; |
358 | int len = de->d_name.len; | 321 | int len = de->d_name.len; |
359 | 322 | ||
360 | lock_kernel(); | ||
361 | |||
362 | error = venus_remove(dir->i_sb, coda_i2f(dir), name, len); | 323 | error = venus_remove(dir->i_sb, coda_i2f(dir), name, len); |
363 | if ( error ) { | 324 | if (error) |
364 | unlock_kernel(); | ||
365 | return error; | 325 | return error; |
366 | } | ||
367 | 326 | ||
368 | coda_dir_update_mtime(dir); | 327 | coda_dir_update_mtime(dir); |
369 | drop_nlink(de->d_inode); | 328 | drop_nlink(de->d_inode); |
370 | unlock_kernel(); | ||
371 | return 0; | 329 | return 0; |
372 | } | 330 | } |
373 | 331 | ||
@@ -377,8 +335,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) | |||
377 | int len = de->d_name.len; | 335 | int len = de->d_name.len; |
378 | int error; | 336 | int error; |
379 | 337 | ||
380 | lock_kernel(); | ||
381 | |||
382 | error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len); | 338 | error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len); |
383 | if (!error) { | 339 | if (!error) { |
384 | /* VFS may delete the child */ | 340 | /* VFS may delete the child */ |
@@ -389,7 +345,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) | |||
389 | coda_dir_drop_nlink(dir); | 345 | coda_dir_drop_nlink(dir); |
390 | coda_dir_update_mtime(dir); | 346 | coda_dir_update_mtime(dir); |
391 | } | 347 | } |
392 | unlock_kernel(); | ||
393 | return error; | 348 | return error; |
394 | } | 349 | } |
395 | 350 | ||
@@ -403,15 +358,12 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
403 | int new_length = new_dentry->d_name.len; | 358 | int new_length = new_dentry->d_name.len; |
404 | int error; | 359 | int error; |
405 | 360 | ||
406 | lock_kernel(); | ||
407 | |||
408 | error = venus_rename(old_dir->i_sb, coda_i2f(old_dir), | 361 | error = venus_rename(old_dir->i_sb, coda_i2f(old_dir), |
409 | coda_i2f(new_dir), old_length, new_length, | 362 | coda_i2f(new_dir), old_length, new_length, |
410 | (const char *) old_name, (const char *)new_name); | 363 | (const char *) old_name, (const char *)new_name); |
411 | 364 | if (!error) { | |
412 | if ( !error ) { | 365 | if (new_dentry->d_inode) { |
413 | if ( new_dentry->d_inode ) { | 366 | if (S_ISDIR(new_dentry->d_inode->i_mode)) { |
414 | if ( S_ISDIR(new_dentry->d_inode->i_mode) ) { | ||
415 | coda_dir_drop_nlink(old_dir); | 367 | coda_dir_drop_nlink(old_dir); |
416 | coda_dir_inc_nlink(new_dir); | 368 | coda_dir_inc_nlink(new_dir); |
417 | } | 369 | } |
@@ -423,8 +375,6 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
423 | coda_flag_inode(new_dir, C_VATTR); | 375 | coda_flag_inode(new_dir, C_VATTR); |
424 | } | 376 | } |
425 | } | 377 | } |
426 | unlock_kernel(); | ||
427 | |||
428 | return error; | 378 | return error; |
429 | } | 379 | } |
430 | 380 | ||
@@ -594,10 +544,7 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd) | |||
594 | struct inode *inode = de->d_inode; | 544 | struct inode *inode = de->d_inode; |
595 | struct coda_inode_info *cii; | 545 | struct coda_inode_info *cii; |
596 | 546 | ||
597 | if (!inode) | 547 | if (!inode || coda_isroot(inode)) |
598 | return 1; | ||
599 | lock_kernel(); | ||
600 | if (coda_isroot(inode)) | ||
601 | goto out; | 548 | goto out; |
602 | if (is_bad_inode(inode)) | 549 | if (is_bad_inode(inode)) |
603 | goto bad; | 550 | goto bad; |
@@ -617,13 +564,12 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd) | |||
617 | goto out; | 564 | goto out; |
618 | 565 | ||
619 | /* clear the flags. */ | 566 | /* clear the flags. */ |
567 | spin_lock(&cii->c_lock); | ||
620 | cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); | 568 | cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); |
621 | 569 | spin_unlock(&cii->c_lock); | |
622 | bad: | 570 | bad: |
623 | unlock_kernel(); | ||
624 | return 0; | 571 | return 0; |
625 | out: | 572 | out: |
626 | unlock_kernel(); | ||
627 | return 1; | 573 | return 1; |
628 | } | 574 | } |
629 | 575 | ||
@@ -656,20 +602,19 @@ static int coda_dentry_delete(struct dentry * dentry) | |||
656 | int coda_revalidate_inode(struct dentry *dentry) | 602 | int coda_revalidate_inode(struct dentry *dentry) |
657 | { | 603 | { |
658 | struct coda_vattr attr; | 604 | struct coda_vattr attr; |
659 | int error = 0; | 605 | int error; |
660 | int old_mode; | 606 | int old_mode; |
661 | ino_t old_ino; | 607 | ino_t old_ino; |
662 | struct inode *inode = dentry->d_inode; | 608 | struct inode *inode = dentry->d_inode; |
663 | struct coda_inode_info *cii = ITOC(inode); | 609 | struct coda_inode_info *cii = ITOC(inode); |
664 | 610 | ||
665 | lock_kernel(); | 611 | if (!cii->c_flags) |
666 | if ( !cii->c_flags ) | 612 | return 0; |
667 | goto ok; | ||
668 | 613 | ||
669 | if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) { | 614 | if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) { |
670 | error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr); | 615 | error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr); |
671 | if ( error ) | 616 | if (error) |
672 | goto return_bad; | 617 | return -EIO; |
673 | 618 | ||
674 | /* this inode may be lost if: | 619 | /* this inode may be lost if: |
675 | - it's ino changed | 620 | - it's ino changed |
@@ -688,17 +633,13 @@ int coda_revalidate_inode(struct dentry *dentry) | |||
688 | /* the following can happen when a local fid is replaced | 633 | /* the following can happen when a local fid is replaced |
689 | with a global one, here we lose and declare the inode bad */ | 634 | with a global one, here we lose and declare the inode bad */ |
690 | if (inode->i_ino != old_ino) | 635 | if (inode->i_ino != old_ino) |
691 | goto return_bad; | 636 | return -EIO; |
692 | 637 | ||
693 | coda_flag_inode_children(inode, C_FLUSH); | 638 | coda_flag_inode_children(inode, C_FLUSH); |
639 | |||
640 | spin_lock(&cii->c_lock); | ||
694 | cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); | 641 | cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); |
642 | spin_unlock(&cii->c_lock); | ||
695 | } | 643 | } |
696 | |||
697 | ok: | ||
698 | unlock_kernel(); | ||
699 | return 0; | 644 | return 0; |
700 | |||
701 | return_bad: | ||
702 | unlock_kernel(); | ||
703 | return -EIO; | ||
704 | } | 645 | } |
diff --git a/fs/coda/file.c b/fs/coda/file.c index ad3cd2abeeb4..c8b50ba4366a 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/stat.h> | 15 | #include <linux/stat.h> |
16 | #include <linux/cred.h> | 16 | #include <linux/cred.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
@@ -109,19 +109,24 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) | |||
109 | 109 | ||
110 | coda_inode = coda_file->f_path.dentry->d_inode; | 110 | coda_inode = coda_file->f_path.dentry->d_inode; |
111 | host_inode = host_file->f_path.dentry->d_inode; | 111 | host_inode = host_file->f_path.dentry->d_inode; |
112 | |||
113 | cii = ITOC(coda_inode); | ||
114 | spin_lock(&cii->c_lock); | ||
112 | coda_file->f_mapping = host_file->f_mapping; | 115 | coda_file->f_mapping = host_file->f_mapping; |
113 | if (coda_inode->i_mapping == &coda_inode->i_data) | 116 | if (coda_inode->i_mapping == &coda_inode->i_data) |
114 | coda_inode->i_mapping = host_inode->i_mapping; | 117 | coda_inode->i_mapping = host_inode->i_mapping; |
115 | 118 | ||
116 | /* only allow additional mmaps as long as userspace isn't changing | 119 | /* only allow additional mmaps as long as userspace isn't changing |
117 | * the container file on us! */ | 120 | * the container file on us! */ |
118 | else if (coda_inode->i_mapping != host_inode->i_mapping) | 121 | else if (coda_inode->i_mapping != host_inode->i_mapping) { |
122 | spin_unlock(&cii->c_lock); | ||
119 | return -EBUSY; | 123 | return -EBUSY; |
124 | } | ||
120 | 125 | ||
121 | /* keep track of how often the coda_inode/host_file has been mmapped */ | 126 | /* keep track of how often the coda_inode/host_file has been mmapped */ |
122 | cii = ITOC(coda_inode); | ||
123 | cii->c_mapcount++; | 127 | cii->c_mapcount++; |
124 | cfi->cfi_mapcount++; | 128 | cfi->cfi_mapcount++; |
129 | spin_unlock(&cii->c_lock); | ||
125 | 130 | ||
126 | return host_file->f_op->mmap(host_file, vma); | 131 | return host_file->f_op->mmap(host_file, vma); |
127 | } | 132 | } |
@@ -138,8 +143,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
138 | if (!cfi) | 143 | if (!cfi) |
139 | return -ENOMEM; | 144 | return -ENOMEM; |
140 | 145 | ||
141 | lock_kernel(); | ||
142 | |||
143 | error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, | 146 | error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, |
144 | &host_file); | 147 | &host_file); |
145 | if (!host_file) | 148 | if (!host_file) |
@@ -147,7 +150,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
147 | 150 | ||
148 | if (error) { | 151 | if (error) { |
149 | kfree(cfi); | 152 | kfree(cfi); |
150 | unlock_kernel(); | ||
151 | return error; | 153 | return error; |
152 | } | 154 | } |
153 | 155 | ||
@@ -159,8 +161,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
159 | 161 | ||
160 | BUG_ON(coda_file->private_data != NULL); | 162 | BUG_ON(coda_file->private_data != NULL); |
161 | coda_file->private_data = cfi; | 163 | coda_file->private_data = cfi; |
162 | |||
163 | unlock_kernel(); | ||
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
166 | 166 | ||
@@ -171,9 +171,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) | |||
171 | struct coda_file_info *cfi; | 171 | struct coda_file_info *cfi; |
172 | struct coda_inode_info *cii; | 172 | struct coda_inode_info *cii; |
173 | struct inode *host_inode; | 173 | struct inode *host_inode; |
174 | int err = 0; | 174 | int err; |
175 | |||
176 | lock_kernel(); | ||
177 | 175 | ||
178 | cfi = CODA_FTOC(coda_file); | 176 | cfi = CODA_FTOC(coda_file); |
179 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); | 177 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); |
@@ -185,18 +183,18 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) | |||
185 | cii = ITOC(coda_inode); | 183 | cii = ITOC(coda_inode); |
186 | 184 | ||
187 | /* did we mmap this file? */ | 185 | /* did we mmap this file? */ |
186 | spin_lock(&cii->c_lock); | ||
188 | if (coda_inode->i_mapping == &host_inode->i_data) { | 187 | if (coda_inode->i_mapping == &host_inode->i_data) { |
189 | cii->c_mapcount -= cfi->cfi_mapcount; | 188 | cii->c_mapcount -= cfi->cfi_mapcount; |
190 | if (!cii->c_mapcount) | 189 | if (!cii->c_mapcount) |
191 | coda_inode->i_mapping = &coda_inode->i_data; | 190 | coda_inode->i_mapping = &coda_inode->i_data; |
192 | } | 191 | } |
192 | spin_unlock(&cii->c_lock); | ||
193 | 193 | ||
194 | fput(cfi->cfi_container); | 194 | fput(cfi->cfi_container); |
195 | kfree(coda_file->private_data); | 195 | kfree(coda_file->private_data); |
196 | coda_file->private_data = NULL; | 196 | coda_file->private_data = NULL; |
197 | 197 | ||
198 | unlock_kernel(); | ||
199 | |||
200 | /* VFS fput ignores the return value from file_operations->release, so | 198 | /* VFS fput ignores the return value from file_operations->release, so |
201 | * there is no use returning an error here */ | 199 | * there is no use returning an error here */ |
202 | return 0; | 200 | return 0; |
@@ -207,7 +205,7 @@ int coda_fsync(struct file *coda_file, int datasync) | |||
207 | struct file *host_file; | 205 | struct file *host_file; |
208 | struct inode *coda_inode = coda_file->f_path.dentry->d_inode; | 206 | struct inode *coda_inode = coda_file->f_path.dentry->d_inode; |
209 | struct coda_file_info *cfi; | 207 | struct coda_file_info *cfi; |
210 | int err = 0; | 208 | int err; |
211 | 209 | ||
212 | if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || | 210 | if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || |
213 | S_ISLNK(coda_inode->i_mode))) | 211 | S_ISLNK(coda_inode->i_mode))) |
@@ -218,11 +216,8 @@ int coda_fsync(struct file *coda_file, int datasync) | |||
218 | host_file = cfi->cfi_container; | 216 | host_file = cfi->cfi_container; |
219 | 217 | ||
220 | err = vfs_fsync(host_file, datasync); | 218 | err = vfs_fsync(host_file, datasync); |
221 | if ( !err && !datasync ) { | 219 | if (!err && !datasync) |
222 | lock_kernel(); | ||
223 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); | 220 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); |
224 | unlock_kernel(); | ||
225 | } | ||
226 | 221 | ||
227 | return err; | 222 | return err; |
228 | } | 223 | } |
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 6526e6f21ecf..5ea57c8c7f97 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -15,7 +15,8 @@ | |||
15 | #include <linux/stat.h> | 15 | #include <linux/stat.h> |
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/unistd.h> | 17 | #include <linux/unistd.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/mutex.h> |
19 | #include <linux/spinlock.h> | ||
19 | #include <linux/file.h> | 20 | #include <linux/file.h> |
20 | #include <linux/vfs.h> | 21 | #include <linux/vfs.h> |
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
@@ -51,6 +52,7 @@ static struct inode *coda_alloc_inode(struct super_block *sb) | |||
51 | ei->c_flags = 0; | 52 | ei->c_flags = 0; |
52 | ei->c_uid = 0; | 53 | ei->c_uid = 0; |
53 | ei->c_cached_perm = 0; | 54 | ei->c_cached_perm = 0; |
55 | spin_lock_init(&ei->c_lock); | ||
54 | return &ei->vfs_inode; | 56 | return &ei->vfs_inode; |
55 | } | 57 | } |
56 | 58 | ||
@@ -143,7 +145,7 @@ static int get_device_index(struct coda_mount_data *data) | |||
143 | static int coda_fill_super(struct super_block *sb, void *data, int silent) | 145 | static int coda_fill_super(struct super_block *sb, void *data, int silent) |
144 | { | 146 | { |
145 | struct inode *root = NULL; | 147 | struct inode *root = NULL; |
146 | struct venus_comm *vc = NULL; | 148 | struct venus_comm *vc; |
147 | struct CodaFid fid; | 149 | struct CodaFid fid; |
148 | int error; | 150 | int error; |
149 | int idx; | 151 | int idx; |
@@ -157,21 +159,26 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
157 | printk(KERN_INFO "coda_read_super: device index: %i\n", idx); | 159 | printk(KERN_INFO "coda_read_super: device index: %i\n", idx); |
158 | 160 | ||
159 | vc = &coda_comms[idx]; | 161 | vc = &coda_comms[idx]; |
162 | mutex_lock(&vc->vc_mutex); | ||
163 | |||
160 | if (!vc->vc_inuse) { | 164 | if (!vc->vc_inuse) { |
161 | printk("coda_read_super: No pseudo device\n"); | 165 | printk("coda_read_super: No pseudo device\n"); |
162 | return -EINVAL; | 166 | error = -EINVAL; |
167 | goto unlock_out; | ||
163 | } | 168 | } |
164 | 169 | ||
165 | if ( vc->vc_sb ) { | 170 | if (vc->vc_sb) { |
166 | printk("coda_read_super: Device already mounted\n"); | 171 | printk("coda_read_super: Device already mounted\n"); |
167 | return -EBUSY; | 172 | error = -EBUSY; |
173 | goto unlock_out; | ||
168 | } | 174 | } |
169 | 175 | ||
170 | error = bdi_setup_and_register(&vc->bdi, "coda", BDI_CAP_MAP_COPY); | 176 | error = bdi_setup_and_register(&vc->bdi, "coda", BDI_CAP_MAP_COPY); |
171 | if (error) | 177 | if (error) |
172 | goto bdi_err; | 178 | goto unlock_out; |
173 | 179 | ||
174 | vc->vc_sb = sb; | 180 | vc->vc_sb = sb; |
181 | mutex_unlock(&vc->vc_mutex); | ||
175 | 182 | ||
176 | sb->s_fs_info = vc; | 183 | sb->s_fs_info = vc; |
177 | sb->s_flags |= MS_NOATIME; | 184 | sb->s_flags |= MS_NOATIME; |
@@ -200,26 +207,33 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
200 | printk("coda_read_super: rootinode is %ld dev %s\n", | 207 | printk("coda_read_super: rootinode is %ld dev %s\n", |
201 | root->i_ino, root->i_sb->s_id); | 208 | root->i_ino, root->i_sb->s_id); |
202 | sb->s_root = d_alloc_root(root); | 209 | sb->s_root = d_alloc_root(root); |
203 | if (!sb->s_root) | 210 | if (!sb->s_root) { |
211 | error = -EINVAL; | ||
204 | goto error; | 212 | goto error; |
205 | return 0; | 213 | } |
214 | return 0; | ||
206 | 215 | ||
207 | error: | 216 | error: |
208 | bdi_destroy(&vc->bdi); | ||
209 | bdi_err: | ||
210 | if (root) | 217 | if (root) |
211 | iput(root); | 218 | iput(root); |
212 | if (vc) | ||
213 | vc->vc_sb = NULL; | ||
214 | 219 | ||
215 | return -EINVAL; | 220 | mutex_lock(&vc->vc_mutex); |
221 | bdi_destroy(&vc->bdi); | ||
222 | vc->vc_sb = NULL; | ||
223 | sb->s_fs_info = NULL; | ||
224 | unlock_out: | ||
225 | mutex_unlock(&vc->vc_mutex); | ||
226 | return error; | ||
216 | } | 227 | } |
217 | 228 | ||
218 | static void coda_put_super(struct super_block *sb) | 229 | static void coda_put_super(struct super_block *sb) |
219 | { | 230 | { |
220 | bdi_destroy(&coda_vcp(sb)->bdi); | 231 | struct venus_comm *vcp = coda_vcp(sb); |
221 | coda_vcp(sb)->vc_sb = NULL; | 232 | mutex_lock(&vcp->vc_mutex); |
233 | bdi_destroy(&vcp->bdi); | ||
234 | vcp->vc_sb = NULL; | ||
222 | sb->s_fs_info = NULL; | 235 | sb->s_fs_info = NULL; |
236 | mutex_unlock(&vcp->vc_mutex); | ||
223 | 237 | ||
224 | printk("Coda: Bye bye.\n"); | 238 | printk("Coda: Bye bye.\n"); |
225 | } | 239 | } |
@@ -245,8 +259,6 @@ int coda_setattr(struct dentry *de, struct iattr *iattr) | |||
245 | struct coda_vattr vattr; | 259 | struct coda_vattr vattr; |
246 | int error; | 260 | int error; |
247 | 261 | ||
248 | lock_kernel(); | ||
249 | |||
250 | memset(&vattr, 0, sizeof(vattr)); | 262 | memset(&vattr, 0, sizeof(vattr)); |
251 | 263 | ||
252 | inode->i_ctime = CURRENT_TIME_SEC; | 264 | inode->i_ctime = CURRENT_TIME_SEC; |
@@ -256,13 +268,10 @@ int coda_setattr(struct dentry *de, struct iattr *iattr) | |||
256 | /* Venus is responsible for truncating the container-file!!! */ | 268 | /* Venus is responsible for truncating the container-file!!! */ |
257 | error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr); | 269 | error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr); |
258 | 270 | ||
259 | if ( !error ) { | 271 | if (!error) { |
260 | coda_vattr_to_iattr(inode, &vattr); | 272 | coda_vattr_to_iattr(inode, &vattr); |
261 | coda_cache_clear_inode(inode); | 273 | coda_cache_clear_inode(inode); |
262 | } | 274 | } |
263 | |||
264 | unlock_kernel(); | ||
265 | |||
266 | return error; | 275 | return error; |
267 | } | 276 | } |
268 | 277 | ||
@@ -276,12 +285,8 @@ static int coda_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
276 | { | 285 | { |
277 | int error; | 286 | int error; |
278 | 287 | ||
279 | lock_kernel(); | ||
280 | |||
281 | error = venus_statfs(dentry, buf); | 288 | error = venus_statfs(dentry, buf); |
282 | 289 | ||
283 | unlock_kernel(); | ||
284 | |||
285 | if (error) { | 290 | if (error) { |
286 | /* fake something like AFS does */ | 291 | /* fake something like AFS does */ |
287 | buf->f_blocks = 9000000; | 292 | buf->f_blocks = 9000000; |
@@ -301,16 +306,16 @@ static int coda_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
301 | 306 | ||
302 | /* init_coda: used by filesystems.c to register coda */ | 307 | /* init_coda: used by filesystems.c to register coda */ |
303 | 308 | ||
304 | static int coda_get_sb(struct file_system_type *fs_type, | 309 | static struct dentry *coda_mount(struct file_system_type *fs_type, |
305 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 310 | int flags, const char *dev_name, void *data) |
306 | { | 311 | { |
307 | return get_sb_nodev(fs_type, flags, data, coda_fill_super, mnt); | 312 | return mount_nodev(fs_type, flags, data, coda_fill_super); |
308 | } | 313 | } |
309 | 314 | ||
310 | struct file_system_type coda_fs_type = { | 315 | struct file_system_type coda_fs_type = { |
311 | .owner = THIS_MODULE, | 316 | .owner = THIS_MODULE, |
312 | .name = "coda", | 317 | .name = "coda", |
313 | .get_sb = coda_get_sb, | 318 | .mount = coda_mount, |
314 | .kill_sb = kill_anon_super, | 319 | .kill_sb = kill_anon_super, |
315 | .fs_flags = FS_BINARY_MOUNTDATA, | 320 | .fs_flags = FS_BINARY_MOUNTDATA, |
316 | }; | 321 | }; |
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c index ca25d96d45c9..2fd89b5c5c7b 100644 --- a/fs/coda/pioctl.c +++ b/fs/coda/pioctl.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include <linux/coda_fs_i.h> | 23 | #include <linux/coda_fs_i.h> |
24 | #include <linux/coda_psdev.h> | 24 | #include <linux/coda_psdev.h> |
25 | 25 | ||
26 | #include <linux/smp_lock.h> | ||
27 | |||
28 | /* pioctl ops */ | 26 | /* pioctl ops */ |
29 | static int coda_ioctl_permission(struct inode *inode, int mask); | 27 | static int coda_ioctl_permission(struct inode *inode, int mask); |
30 | static long coda_pioctl(struct file *filp, unsigned int cmd, | 28 | static long coda_pioctl(struct file *filp, unsigned int cmd, |
@@ -39,6 +37,7 @@ const struct inode_operations coda_ioctl_inode_operations = { | |||
39 | const struct file_operations coda_ioctl_operations = { | 37 | const struct file_operations coda_ioctl_operations = { |
40 | .owner = THIS_MODULE, | 38 | .owner = THIS_MODULE, |
41 | .unlocked_ioctl = coda_pioctl, | 39 | .unlocked_ioctl = coda_pioctl, |
40 | .llseek = noop_llseek, | ||
42 | }; | 41 | }; |
43 | 42 | ||
44 | /* the coda pioctl inode ops */ | 43 | /* the coda pioctl inode ops */ |
@@ -57,13 +56,9 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, | |||
57 | struct inode *target_inode = NULL; | 56 | struct inode *target_inode = NULL; |
58 | struct coda_inode_info *cnp; | 57 | struct coda_inode_info *cnp; |
59 | 58 | ||
60 | lock_kernel(); | ||
61 | |||
62 | /* get the Pioctl data arguments from user space */ | 59 | /* get the Pioctl data arguments from user space */ |
63 | if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) { | 60 | if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) |
64 | error = -EINVAL; | 61 | return -EINVAL; |
65 | goto out; | ||
66 | } | ||
67 | 62 | ||
68 | /* | 63 | /* |
69 | * Look up the pathname. Note that the pathname is in | 64 | * Look up the pathname. Note that the pathname is in |
@@ -75,13 +70,12 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, | |||
75 | error = user_lpath(data.path, &path); | 70 | error = user_lpath(data.path, &path); |
76 | 71 | ||
77 | if (error) | 72 | if (error) |
78 | goto out; | 73 | return error; |
79 | else | 74 | |
80 | target_inode = path.dentry->d_inode; | 75 | target_inode = path.dentry->d_inode; |
81 | 76 | ||
82 | /* return if it is not a Coda inode */ | 77 | /* return if it is not a Coda inode */ |
83 | if (target_inode->i_sb != inode->i_sb) { | 78 | if (target_inode->i_sb != inode->i_sb) { |
84 | path_put(&path); | ||
85 | error = -EINVAL; | 79 | error = -EINVAL; |
86 | goto out; | 80 | goto out; |
87 | } | 81 | } |
@@ -90,10 +84,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, | |||
90 | cnp = ITOC(target_inode); | 84 | cnp = ITOC(target_inode); |
91 | 85 | ||
92 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); | 86 | error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); |
93 | |||
94 | path_put(&path); | ||
95 | |||
96 | out: | 87 | out: |
97 | unlock_kernel(); | 88 | path_put(&path); |
98 | return error; | 89 | return error; |
99 | } | 90 | } |
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 116af7546cf0..62647a8595e4 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/poll.h> | 35 | #include <linux/poll.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/list.h> | 37 | #include <linux/list.h> |
38 | #include <linux/smp_lock.h> | 38 | #include <linux/mutex.h> |
39 | #include <linux/device.h> | 39 | #include <linux/device.h> |
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | #include <asm/system.h> | 41 | #include <asm/system.h> |
@@ -67,8 +67,10 @@ static unsigned int coda_psdev_poll(struct file *file, poll_table * wait) | |||
67 | unsigned int mask = POLLOUT | POLLWRNORM; | 67 | unsigned int mask = POLLOUT | POLLWRNORM; |
68 | 68 | ||
69 | poll_wait(file, &vcp->vc_waitq, wait); | 69 | poll_wait(file, &vcp->vc_waitq, wait); |
70 | mutex_lock(&vcp->vc_mutex); | ||
70 | if (!list_empty(&vcp->vc_pending)) | 71 | if (!list_empty(&vcp->vc_pending)) |
71 | mask |= POLLIN | POLLRDNORM; | 72 | mask |= POLLIN | POLLRDNORM; |
73 | mutex_unlock(&vcp->vc_mutex); | ||
72 | 74 | ||
73 | return mask; | 75 | return mask; |
74 | } | 76 | } |
@@ -108,16 +110,9 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
108 | return -EFAULT; | 110 | return -EFAULT; |
109 | 111 | ||
110 | if (DOWNCALL(hdr.opcode)) { | 112 | if (DOWNCALL(hdr.opcode)) { |
111 | struct super_block *sb = NULL; | 113 | union outputArgs *dcbuf; |
112 | union outputArgs *dcbuf; | ||
113 | int size = sizeof(*dcbuf); | 114 | int size = sizeof(*dcbuf); |
114 | 115 | ||
115 | sb = vcp->vc_sb; | ||
116 | if ( !sb ) { | ||
117 | count = nbytes; | ||
118 | goto out; | ||
119 | } | ||
120 | |||
121 | if ( nbytes < sizeof(struct coda_out_hdr) ) { | 116 | if ( nbytes < sizeof(struct coda_out_hdr) ) { |
122 | printk("coda_downcall opc %d uniq %d, not enough!\n", | 117 | printk("coda_downcall opc %d uniq %d, not enough!\n", |
123 | hdr.opcode, hdr.unique); | 118 | hdr.opcode, hdr.unique); |
@@ -137,9 +132,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
137 | } | 132 | } |
138 | 133 | ||
139 | /* what downcall errors does Venus handle ? */ | 134 | /* what downcall errors does Venus handle ? */ |
140 | lock_kernel(); | 135 | error = coda_downcall(vcp, hdr.opcode, dcbuf); |
141 | error = coda_downcall(hdr.opcode, dcbuf, sb); | ||
142 | unlock_kernel(); | ||
143 | 136 | ||
144 | CODA_FREE(dcbuf, nbytes); | 137 | CODA_FREE(dcbuf, nbytes); |
145 | if (error) { | 138 | if (error) { |
@@ -152,7 +145,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
152 | } | 145 | } |
153 | 146 | ||
154 | /* Look for the message on the processing queue. */ | 147 | /* Look for the message on the processing queue. */ |
155 | lock_kernel(); | 148 | mutex_lock(&vcp->vc_mutex); |
156 | list_for_each(lh, &vcp->vc_processing) { | 149 | list_for_each(lh, &vcp->vc_processing) { |
157 | tmp = list_entry(lh, struct upc_req , uc_chain); | 150 | tmp = list_entry(lh, struct upc_req , uc_chain); |
158 | if (tmp->uc_unique == hdr.unique) { | 151 | if (tmp->uc_unique == hdr.unique) { |
@@ -161,7 +154,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, | |||
161 | break; | 154 | break; |
162 | } | 155 | } |
163 | } | 156 | } |
164 | unlock_kernel(); | 157 | mutex_unlock(&vcp->vc_mutex); |
165 | 158 | ||
166 | if (!req) { | 159 | if (!req) { |
167 | printk("psdev_write: msg (%d, %d) not found\n", | 160 | printk("psdev_write: msg (%d, %d) not found\n", |
@@ -216,7 +209,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, | |||
216 | if (nbytes == 0) | 209 | if (nbytes == 0) |
217 | return 0; | 210 | return 0; |
218 | 211 | ||
219 | lock_kernel(); | 212 | mutex_lock(&vcp->vc_mutex); |
220 | 213 | ||
221 | add_wait_queue(&vcp->vc_waitq, &wait); | 214 | add_wait_queue(&vcp->vc_waitq, &wait); |
222 | set_current_state(TASK_INTERRUPTIBLE); | 215 | set_current_state(TASK_INTERRUPTIBLE); |
@@ -230,7 +223,9 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, | |||
230 | retval = -ERESTARTSYS; | 223 | retval = -ERESTARTSYS; |
231 | break; | 224 | break; |
232 | } | 225 | } |
226 | mutex_unlock(&vcp->vc_mutex); | ||
233 | schedule(); | 227 | schedule(); |
228 | mutex_lock(&vcp->vc_mutex); | ||
234 | } | 229 | } |
235 | 230 | ||
236 | set_current_state(TASK_RUNNING); | 231 | set_current_state(TASK_RUNNING); |
@@ -263,7 +258,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, | |||
263 | CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); | 258 | CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); |
264 | kfree(req); | 259 | kfree(req); |
265 | out: | 260 | out: |
266 | unlock_kernel(); | 261 | mutex_unlock(&vcp->vc_mutex); |
267 | return (count ? count : retval); | 262 | return (count ? count : retval); |
268 | } | 263 | } |
269 | 264 | ||
@@ -276,10 +271,10 @@ static int coda_psdev_open(struct inode * inode, struct file * file) | |||
276 | if (idx < 0 || idx >= MAX_CODADEVS) | 271 | if (idx < 0 || idx >= MAX_CODADEVS) |
277 | return -ENODEV; | 272 | return -ENODEV; |
278 | 273 | ||
279 | lock_kernel(); | ||
280 | |||
281 | err = -EBUSY; | 274 | err = -EBUSY; |
282 | vcp = &coda_comms[idx]; | 275 | vcp = &coda_comms[idx]; |
276 | mutex_lock(&vcp->vc_mutex); | ||
277 | |||
283 | if (!vcp->vc_inuse) { | 278 | if (!vcp->vc_inuse) { |
284 | vcp->vc_inuse++; | 279 | vcp->vc_inuse++; |
285 | 280 | ||
@@ -293,7 +288,7 @@ static int coda_psdev_open(struct inode * inode, struct file * file) | |||
293 | err = 0; | 288 | err = 0; |
294 | } | 289 | } |
295 | 290 | ||
296 | unlock_kernel(); | 291 | mutex_unlock(&vcp->vc_mutex); |
297 | return err; | 292 | return err; |
298 | } | 293 | } |
299 | 294 | ||
@@ -308,7 +303,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file) | |||
308 | return -1; | 303 | return -1; |
309 | } | 304 | } |
310 | 305 | ||
311 | lock_kernel(); | 306 | mutex_lock(&vcp->vc_mutex); |
312 | 307 | ||
313 | /* Wakeup clients so they can return. */ | 308 | /* Wakeup clients so they can return. */ |
314 | list_for_each_entry_safe(req, tmp, &vcp->vc_pending, uc_chain) { | 309 | list_for_each_entry_safe(req, tmp, &vcp->vc_pending, uc_chain) { |
@@ -333,7 +328,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file) | |||
333 | 328 | ||
334 | file->private_data = NULL; | 329 | file->private_data = NULL; |
335 | vcp->vc_inuse--; | 330 | vcp->vc_inuse--; |
336 | unlock_kernel(); | 331 | mutex_unlock(&vcp->vc_mutex); |
337 | return 0; | 332 | return 0; |
338 | } | 333 | } |
339 | 334 | ||
@@ -346,6 +341,7 @@ static const struct file_operations coda_psdev_fops = { | |||
346 | .unlocked_ioctl = coda_psdev_ioctl, | 341 | .unlocked_ioctl = coda_psdev_ioctl, |
347 | .open = coda_psdev_open, | 342 | .open = coda_psdev_open, |
348 | .release = coda_psdev_release, | 343 | .release = coda_psdev_release, |
344 | .llseek = noop_llseek, | ||
349 | }; | 345 | }; |
350 | 346 | ||
351 | static int init_coda_psdev(void) | 347 | static int init_coda_psdev(void) |
@@ -361,9 +357,11 @@ static int init_coda_psdev(void) | |||
361 | err = PTR_ERR(coda_psdev_class); | 357 | err = PTR_ERR(coda_psdev_class); |
362 | goto out_chrdev; | 358 | goto out_chrdev; |
363 | } | 359 | } |
364 | for (i = 0; i < MAX_CODADEVS; i++) | 360 | for (i = 0; i < MAX_CODADEVS; i++) { |
361 | mutex_init(&(&coda_comms[i])->vc_mutex); | ||
365 | device_create(coda_psdev_class, NULL, | 362 | device_create(coda_psdev_class, NULL, |
366 | MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i); | 363 | MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i); |
364 | } | ||
367 | coda_sysctl_init(); | 365 | coda_sysctl_init(); |
368 | goto out; | 366 | goto out; |
369 | 367 | ||
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c index 4513b7258458..af78f007a2b0 100644 --- a/fs/coda/symlink.c +++ b/fs/coda/symlink.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/stat.h> | 14 | #include <linux/stat.h> |
15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/pagemap.h> | 16 | #include <linux/pagemap.h> |
17 | #include <linux/smp_lock.h> | ||
18 | 17 | ||
19 | #include <linux/coda.h> | 18 | #include <linux/coda.h> |
20 | #include <linux/coda_linux.h> | 19 | #include <linux/coda_linux.h> |
@@ -29,11 +28,9 @@ static int coda_symlink_filler(struct file *file, struct page *page) | |||
29 | unsigned int len = PAGE_SIZE; | 28 | unsigned int len = PAGE_SIZE; |
30 | char *p = kmap(page); | 29 | char *p = kmap(page); |
31 | 30 | ||
32 | lock_kernel(); | ||
33 | cii = ITOC(inode); | 31 | cii = ITOC(inode); |
34 | 32 | ||
35 | error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len); | 33 | error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len); |
36 | unlock_kernel(); | ||
37 | if (error) | 34 | if (error) |
38 | goto fail; | 35 | goto fail; |
39 | SetPageUptodate(page); | 36 | SetPageUptodate(page); |
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index b8893ab6f9e6..c3563cab9758 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/string.h> | 28 | #include <linux/string.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
32 | #include <linux/vfs.h> | 33 | #include <linux/vfs.h> |
@@ -606,7 +607,8 @@ static void coda_unblock_signals(sigset_t *old) | |||
606 | (r)->uc_opcode != CODA_RELEASE) || \ | 607 | (r)->uc_opcode != CODA_RELEASE) || \ |
607 | (r)->uc_flags & CODA_REQ_READ)) | 608 | (r)->uc_flags & CODA_REQ_READ)) |
608 | 609 | ||
609 | static inline void coda_waitfor_upcall(struct upc_req *req) | 610 | static inline void coda_waitfor_upcall(struct venus_comm *vcp, |
611 | struct upc_req *req) | ||
610 | { | 612 | { |
611 | DECLARE_WAITQUEUE(wait, current); | 613 | DECLARE_WAITQUEUE(wait, current); |
612 | unsigned long timeout = jiffies + coda_timeout * HZ; | 614 | unsigned long timeout = jiffies + coda_timeout * HZ; |
@@ -639,10 +641,12 @@ static inline void coda_waitfor_upcall(struct upc_req *req) | |||
639 | break; | 641 | break; |
640 | } | 642 | } |
641 | 643 | ||
644 | mutex_unlock(&vcp->vc_mutex); | ||
642 | if (blocked) | 645 | if (blocked) |
643 | schedule_timeout(HZ); | 646 | schedule_timeout(HZ); |
644 | else | 647 | else |
645 | schedule(); | 648 | schedule(); |
649 | mutex_lock(&vcp->vc_mutex); | ||
646 | } | 650 | } |
647 | if (blocked) | 651 | if (blocked) |
648 | coda_unblock_signals(&old); | 652 | coda_unblock_signals(&old); |
@@ -667,18 +671,23 @@ static int coda_upcall(struct venus_comm *vcp, | |||
667 | { | 671 | { |
668 | union outputArgs *out; | 672 | union outputArgs *out; |
669 | union inputArgs *sig_inputArgs; | 673 | union inputArgs *sig_inputArgs; |
670 | struct upc_req *req, *sig_req; | 674 | struct upc_req *req = NULL, *sig_req; |
671 | int error = 0; | 675 | int error; |
676 | |||
677 | mutex_lock(&vcp->vc_mutex); | ||
672 | 678 | ||
673 | if (!vcp->vc_inuse) { | 679 | if (!vcp->vc_inuse) { |
674 | printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); | 680 | printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); |
675 | return -ENXIO; | 681 | error = -ENXIO; |
682 | goto exit; | ||
676 | } | 683 | } |
677 | 684 | ||
678 | /* Format the request message. */ | 685 | /* Format the request message. */ |
679 | req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); | 686 | req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); |
680 | if (!req) | 687 | if (!req) { |
681 | return -ENOMEM; | 688 | error = -ENOMEM; |
689 | goto exit; | ||
690 | } | ||
682 | 691 | ||
683 | req->uc_data = (void *)buffer; | 692 | req->uc_data = (void *)buffer; |
684 | req->uc_flags = 0; | 693 | req->uc_flags = 0; |
@@ -705,7 +714,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
705 | * ENODEV. */ | 714 | * ENODEV. */ |
706 | 715 | ||
707 | /* Go to sleep. Wake up on signals only after the timeout. */ | 716 | /* Go to sleep. Wake up on signals only after the timeout. */ |
708 | coda_waitfor_upcall(req); | 717 | coda_waitfor_upcall(vcp, req); |
709 | 718 | ||
710 | /* Op went through, interrupt or not... */ | 719 | /* Op went through, interrupt or not... */ |
711 | if (req->uc_flags & CODA_REQ_WRITE) { | 720 | if (req->uc_flags & CODA_REQ_WRITE) { |
@@ -759,6 +768,7 @@ static int coda_upcall(struct venus_comm *vcp, | |||
759 | 768 | ||
760 | exit: | 769 | exit: |
761 | kfree(req); | 770 | kfree(req); |
771 | mutex_unlock(&vcp->vc_mutex); | ||
762 | return error; | 772 | return error; |
763 | } | 773 | } |
764 | 774 | ||
@@ -796,21 +806,24 @@ exit: | |||
796 | * | 806 | * |
797 | * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */ | 807 | * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */ |
798 | 808 | ||
799 | int coda_downcall(int opcode, union outputArgs * out, struct super_block *sb) | 809 | int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out) |
800 | { | 810 | { |
801 | struct inode *inode = NULL; | 811 | struct inode *inode = NULL; |
802 | struct CodaFid *fid, *newfid; | 812 | struct CodaFid *fid = NULL, *newfid; |
813 | struct super_block *sb; | ||
803 | 814 | ||
804 | /* Handle invalidation requests. */ | 815 | /* Handle invalidation requests. */ |
805 | if ( !sb || !sb->s_root) | 816 | mutex_lock(&vcp->vc_mutex); |
806 | return 0; | 817 | sb = vcp->vc_sb; |
818 | if (!sb || !sb->s_root) | ||
819 | goto unlock_out; | ||
807 | 820 | ||
808 | switch (opcode) { | 821 | switch (opcode) { |
809 | case CODA_FLUSH: | 822 | case CODA_FLUSH: |
810 | coda_cache_clear_all(sb); | 823 | coda_cache_clear_all(sb); |
811 | shrink_dcache_sb(sb); | 824 | shrink_dcache_sb(sb); |
812 | if (sb->s_root->d_inode) | 825 | if (sb->s_root->d_inode) |
813 | coda_flag_inode(sb->s_root->d_inode, C_FLUSH); | 826 | coda_flag_inode(sb->s_root->d_inode, C_FLUSH); |
814 | break; | 827 | break; |
815 | 828 | ||
816 | case CODA_PURGEUSER: | 829 | case CODA_PURGEUSER: |
@@ -819,45 +832,53 @@ int coda_downcall(int opcode, union outputArgs * out, struct super_block *sb) | |||
819 | 832 | ||
820 | case CODA_ZAPDIR: | 833 | case CODA_ZAPDIR: |
821 | fid = &out->coda_zapdir.CodaFid; | 834 | fid = &out->coda_zapdir.CodaFid; |
822 | inode = coda_fid_to_inode(fid, sb); | ||
823 | if (inode) { | ||
824 | coda_flag_inode_children(inode, C_PURGE); | ||
825 | coda_flag_inode(inode, C_VATTR); | ||
826 | } | ||
827 | break; | 835 | break; |
828 | 836 | ||
829 | case CODA_ZAPFILE: | 837 | case CODA_ZAPFILE: |
830 | fid = &out->coda_zapfile.CodaFid; | 838 | fid = &out->coda_zapfile.CodaFid; |
831 | inode = coda_fid_to_inode(fid, sb); | ||
832 | if (inode) | ||
833 | coda_flag_inode(inode, C_VATTR); | ||
834 | break; | 839 | break; |
835 | 840 | ||
836 | case CODA_PURGEFID: | 841 | case CODA_PURGEFID: |
837 | fid = &out->coda_purgefid.CodaFid; | 842 | fid = &out->coda_purgefid.CodaFid; |
843 | break; | ||
844 | |||
845 | case CODA_REPLACE: | ||
846 | fid = &out->coda_replace.OldFid; | ||
847 | break; | ||
848 | } | ||
849 | if (fid) | ||
838 | inode = coda_fid_to_inode(fid, sb); | 850 | inode = coda_fid_to_inode(fid, sb); |
839 | if (inode) { | ||
840 | coda_flag_inode_children(inode, C_PURGE); | ||
841 | 851 | ||
842 | /* catch the dentries later if some are still busy */ | 852 | unlock_out: |
843 | coda_flag_inode(inode, C_PURGE); | 853 | mutex_unlock(&vcp->vc_mutex); |
844 | d_prune_aliases(inode); | ||
845 | 854 | ||
846 | } | 855 | if (!inode) |
856 | return 0; | ||
857 | |||
858 | switch (opcode) { | ||
859 | case CODA_ZAPDIR: | ||
860 | coda_flag_inode_children(inode, C_PURGE); | ||
861 | coda_flag_inode(inode, C_VATTR); | ||
862 | break; | ||
863 | |||
864 | case CODA_ZAPFILE: | ||
865 | coda_flag_inode(inode, C_VATTR); | ||
866 | break; | ||
867 | |||
868 | case CODA_PURGEFID: | ||
869 | coda_flag_inode_children(inode, C_PURGE); | ||
870 | |||
871 | /* catch the dentries later if some are still busy */ | ||
872 | coda_flag_inode(inode, C_PURGE); | ||
873 | d_prune_aliases(inode); | ||
847 | break; | 874 | break; |
848 | 875 | ||
849 | case CODA_REPLACE: | 876 | case CODA_REPLACE: |
850 | fid = &out->coda_replace.OldFid; | ||
851 | newfid = &out->coda_replace.NewFid; | 877 | newfid = &out->coda_replace.NewFid; |
852 | inode = coda_fid_to_inode(fid, sb); | 878 | coda_replace_fid(inode, fid, newfid); |
853 | if (inode) | ||
854 | coda_replace_fid(inode, fid, newfid); | ||
855 | break; | 879 | break; |
856 | } | 880 | } |
857 | 881 | iput(inode); | |
858 | if (inode) | ||
859 | iput(inode); | ||
860 | |||
861 | return 0; | 882 | return 0; |
862 | } | 883 | } |
863 | 884 | ||