aboutsummaryrefslogtreecommitdiffstats
path: root/fs/coda/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/coda/cache.c')
-rw-r--r--fs/coda/cache.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index a5bf5771a22a..690157876184 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -17,12 +17,12 @@
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_psdev.h> 23#include <linux/coda_psdev.h>
24#include <linux/coda_fs_i.h> 24#include "coda_linux.h"
25#include <linux/coda_cache.h> 25#include "coda_cache.h"
26 26
27static atomic_t permission_epoch = ATOMIC_INIT(0); 27static atomic_t permission_epoch = ATOMIC_INIT(0);
28 28
@@ -31,19 +31,23 @@ void coda_cache_enter(struct inode *inode, int mask)
31{ 31{
32 struct coda_inode_info *cii = ITOC(inode); 32 struct coda_inode_info *cii = ITOC(inode);
33 33
34 spin_lock(&cii->c_lock);
34 cii->c_cached_epoch = atomic_read(&permission_epoch); 35 cii->c_cached_epoch = atomic_read(&permission_epoch);
35 if (cii->c_uid != current_fsuid()) { 36 if (cii->c_uid != current_fsuid()) {
36 cii->c_uid = current_fsuid(); 37 cii->c_uid = current_fsuid();
37 cii->c_cached_perm = mask; 38 cii->c_cached_perm = mask;
38 } else 39 } else
39 cii->c_cached_perm |= mask; 40 cii->c_cached_perm |= mask;
41 spin_unlock(&cii->c_lock);
40} 42}
41 43
42/* remove cached acl from an inode */ 44/* remove cached acl from an inode */
43void coda_cache_clear_inode(struct inode *inode) 45void coda_cache_clear_inode(struct inode *inode)
44{ 46{
45 struct coda_inode_info *cii = ITOC(inode); 47 struct coda_inode_info *cii = ITOC(inode);
48 spin_lock(&cii->c_lock);
46 cii->c_cached_epoch = atomic_read(&permission_epoch) - 1; 49 cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50 spin_unlock(&cii->c_lock);
47} 51}
48 52
49/* remove all acl caches */ 53/* remove all acl caches */
@@ -57,13 +61,15 @@ void coda_cache_clear_all(struct super_block *sb)
57int coda_cache_check(struct inode *inode, int mask) 61int coda_cache_check(struct inode *inode, int mask)
58{ 62{
59 struct coda_inode_info *cii = ITOC(inode); 63 struct coda_inode_info *cii = ITOC(inode);
60 int hit; 64 int hit;
61 65
62 hit = (mask & cii->c_cached_perm) == mask && 66 spin_lock(&cii->c_lock);
63 cii->c_uid == current_fsuid() && 67 hit = (mask & cii->c_cached_perm) == mask &&
64 cii->c_cached_epoch == atomic_read(&permission_epoch); 68 cii->c_uid == current_fsuid() &&
69 cii->c_cached_epoch == atomic_read(&permission_epoch);
70 spin_unlock(&cii->c_lock);
65 71
66 return hit; 72 return hit;
67} 73}
68 74
69 75
@@ -86,7 +92,7 @@ static void coda_flag_children(struct dentry *parent, int flag)
86 struct list_head *child; 92 struct list_head *child;
87 struct dentry *de; 93 struct dentry *de;
88 94
89 spin_lock(&dcache_lock); 95 spin_lock(&parent->d_lock);
90 list_for_each(child, &parent->d_subdirs) 96 list_for_each(child, &parent->d_subdirs)
91 { 97 {
92 de = list_entry(child, struct dentry, d_u.d_child); 98 de = list_entry(child, struct dentry, d_u.d_child);
@@ -95,7 +101,7 @@ static void coda_flag_children(struct dentry *parent, int flag)
95 continue; 101 continue;
96 coda_flag_inode(de->d_inode, flag); 102 coda_flag_inode(de->d_inode, flag);
97 } 103 }
98 spin_unlock(&dcache_lock); 104 spin_unlock(&parent->d_lock);
99 return; 105 return;
100} 106}
101 107