Blame view
fs/coda/cache.c
3.03 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/* * Cache operations for Coda. * For Linux 2.1: (C) 1997 Carnegie Mellon University * For Linux 2.3: (C) 2000 Carnegie Mellon University * * Carnegie Mellon encourages users of this code to contribute improvements * to the Coda project http://www.coda.cs.cmu.edu/ <coda@cs.cmu.edu>. */ #include <linux/types.h> #include <linux/kernel.h> #include <linux/time.h> #include <linux/fs.h> #include <linux/stat.h> #include <linux/errno.h> #include <asm/uaccess.h> #include <linux/string.h> #include <linux/list.h> |
e8edc6e03 Detach sched.h fr... |
19 |
#include <linux/sched.h> |
b5ce1d83a Coda: add spin lo... |
20 |
#include <linux/spinlock.h> |
1da177e4c Linux-2.6.12-rc2 |
21 22 |
#include <linux/coda.h> |
1da177e4c Linux-2.6.12-rc2 |
23 |
#include <linux/coda_psdev.h> |
31a203df9 take coda-private... |
24 25 |
#include "coda_linux.h" #include "coda_cache.h" |
1da177e4c Linux-2.6.12-rc2 |
26 27 28 29 30 31 32 |
static atomic_t permission_epoch = ATOMIC_INIT(0); /* replace or extend an acl cache hit */ void coda_cache_enter(struct inode *inode, int mask) { struct coda_inode_info *cii = ITOC(inode); |
b5ce1d83a Coda: add spin lo... |
33 |
spin_lock(&cii->c_lock); |
1da177e4c Linux-2.6.12-rc2 |
34 |
cii->c_cached_epoch = atomic_read(&permission_epoch); |
97b7702cd CRED: Wrap task c... |
35 36 |
if (cii->c_uid != current_fsuid()) { cii->c_uid = current_fsuid(); |
1da177e4c Linux-2.6.12-rc2 |
37 38 39 |
cii->c_cached_perm = mask; } else cii->c_cached_perm |= mask; |
b5ce1d83a Coda: add spin lo... |
40 |
spin_unlock(&cii->c_lock); |
1da177e4c Linux-2.6.12-rc2 |
41 42 43 44 45 46 |
} /* remove cached acl from an inode */ void coda_cache_clear_inode(struct inode *inode) { struct coda_inode_info *cii = ITOC(inode); |
b5ce1d83a Coda: add spin lo... |
47 |
spin_lock(&cii->c_lock); |
56ee35479 coda: correctly i... |
48 |
cii->c_cached_epoch = atomic_read(&permission_epoch) - 1; |
b5ce1d83a Coda: add spin lo... |
49 |
spin_unlock(&cii->c_lock); |
1da177e4c Linux-2.6.12-rc2 |
50 51 52 53 54 |
} /* remove all acl caches */ void coda_cache_clear_all(struct super_block *sb) { |
1da177e4c Linux-2.6.12-rc2 |
55 56 57 58 59 60 61 62 |
atomic_inc(&permission_epoch); } /* check if the mask has been matched against the acl already */ int coda_cache_check(struct inode *inode, int mask) { struct coda_inode_info *cii = ITOC(inode); |
b5ce1d83a Coda: add spin lo... |
63 |
int hit; |
1da177e4c Linux-2.6.12-rc2 |
64 |
|
b5ce1d83a Coda: add spin lo... |
65 66 67 68 69 |
spin_lock(&cii->c_lock); hit = (mask & cii->c_cached_perm) == mask && cii->c_uid == current_fsuid() && cii->c_cached_epoch == atomic_read(&permission_epoch); spin_unlock(&cii->c_lock); |
1da177e4c Linux-2.6.12-rc2 |
70 |
|
b5ce1d83a Coda: add spin lo... |
71 |
return hit; |
1da177e4c Linux-2.6.12-rc2 |
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
} /* Purging dentries and children */ /* The following routines drop dentries which are not in use and flag dentries which are in use to be zapped later. The flags are detected by: - coda_dentry_revalidate (for lookups) if the flag is C_PURGE - coda_dentry_delete: to remove dentry from the cache when d_count falls to zero - an inode method coda_revalidate (for attributes) if the flag is C_VATTR */ /* this won't do any harm: just flag all children */ static void coda_flag_children(struct dentry *parent, int flag) { struct list_head *child; struct dentry *de; |
2fd6b7f50 fs: dcache scale ... |
93 |
spin_lock(&parent->d_lock); |
1da177e4c Linux-2.6.12-rc2 |
94 95 |
list_for_each(child, &parent->d_subdirs) { |
5160ee6fc [PATCH] shrink de... |
96 |
de = list_entry(child, struct dentry, d_u.d_child); |
1da177e4c Linux-2.6.12-rc2 |
97 98 99 100 101 |
/* don't know what to do with negative dentries */ if ( ! de->d_inode ) continue; coda_flag_inode(de->d_inode, flag); } |
2fd6b7f50 fs: dcache scale ... |
102 |
spin_unlock(&parent->d_lock); |
1da177e4c Linux-2.6.12-rc2 |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
return; } void coda_flag_inode_children(struct inode *inode, int flag) { struct dentry *alias_de; if ( !inode || !S_ISDIR(inode->i_mode)) return; alias_de = d_find_alias(inode); if (!alias_de) return; coda_flag_children(alias_de, flag); shrink_dcache_parent(alias_de); dput(alias_de); } |