diff options
| author | Yoshihisa Abe <yoshiabe@cs.cmu.edu> | 2010-10-25 02:03:44 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-25 11:02:40 -0400 |
| commit | b5ce1d83a62fc109d8e815b1fc71dcdb0d26bc49 (patch) | |
| tree | ea537c1b6436c36bee3b33d8b4f750124fd7d661 /fs/coda/cache.c | |
| parent | 3a99c6319064af3f2e18eb929f638d555dbf7a62 (diff) | |
Coda: add spin lock to protect accesses to struct coda_inode_info.
We mostly need it to protect cached user permissions. The c_flags field
is advisory, reading the wrong value is harmless and in the worst case
we hit a slow path where we have to make an extra upcall to the
userspace cache manager when revalidating a dentry or inode.
Signed-off-by: Yoshihisa Abe <yoshiabe@cs.cmu.edu>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coda/cache.c')
| -rw-r--r-- | fs/coda/cache.c | 17 |
1 files changed, 12 insertions, 5 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 | ||
