1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * Cache operations for Coda. 4 * For Linux 2.1: (C) 1997 Carnegie Mellon Uni 5 * For Linux 2.3: (C) 2000 Carnegie Mellon Uni 6 * 7 * Carnegie Mellon encourages users of this co 8 * to the Coda project http://www.coda.cs.cmu. 9 */ 10 11 #include <linux/types.h> 12 #include <linux/kernel.h> 13 #include <linux/time.h> 14 #include <linux/fs.h> 15 #include <linux/stat.h> 16 #include <linux/errno.h> 17 #include <linux/uaccess.h> 18 #include <linux/string.h> 19 #include <linux/list.h> 20 #include <linux/sched.h> 21 #include <linux/spinlock.h> 22 23 #include <linux/coda.h> 24 #include "coda_psdev.h" 25 #include "coda_linux.h" 26 #include "coda_cache.h" 27 28 static atomic_t permission_epoch = ATOMIC_INIT 29 30 /* replace or extend an acl cache hit */ 31 void coda_cache_enter(struct inode *inode, int 32 { 33 struct coda_inode_info *cii = ITOC(ino 34 35 spin_lock(&cii->c_lock); 36 cii->c_cached_epoch = atomic_read(&per 37 if (!uid_eq(cii->c_uid, current_fsuid( 38 cii->c_uid = current_fsuid(); 39 cii->c_cached_perm = mask; 40 } else 41 cii->c_cached_perm |= mask; 42 spin_unlock(&cii->c_lock); 43 } 44 45 /* remove cached acl from an inode */ 46 void coda_cache_clear_inode(struct inode *inod 47 { 48 struct coda_inode_info *cii = ITOC(ino 49 spin_lock(&cii->c_lock); 50 cii->c_cached_epoch = atomic_read(&per 51 spin_unlock(&cii->c_lock); 52 } 53 54 /* remove all acl caches */ 55 void coda_cache_clear_all(struct super_block * 56 { 57 atomic_inc(&permission_epoch); 58 } 59 60 61 /* check if the mask has been matched against 62 int coda_cache_check(struct inode *inode, int 63 { 64 struct coda_inode_info *cii = ITOC(ino 65 int hit; 66 67 spin_lock(&cii->c_lock); 68 hit = (mask & cii->c_cached_perm) == m 69 uid_eq(cii->c_uid, current_fsuid() 70 cii->c_cached_epoch == atomic_read 71 spin_unlock(&cii->c_lock); 72 73 return hit; 74 } 75 76 77 /* Purging dentries and children */ 78 /* The following routines drop dentries which 79 in use and flag dentries which are in use t 80 zapped later. 81 82 The flags are detected by: 83 - coda_dentry_revalidate (for lookups) if t 84 - coda_dentry_delete: to remove dentry from 85 falls to zero 86 - an inode method coda_revalidate (for attr 87 flag is C_VATTR 88 */ 89 90 /* this won't do any harm: just flag all child 91 static void coda_flag_children(struct dentry * 92 { 93 struct dentry *de; 94 95 spin_lock(&parent->d_lock); 96 hlist_for_each_entry(de, &parent->d_ch 97 struct inode *inode = d_inode_ 98 /* don't know what to do with 99 if (inode) 100 coda_flag_inode(inode, 101 } 102 spin_unlock(&parent->d_lock); 103 } 104 105 void coda_flag_inode_children(struct inode *in 106 { 107 struct dentry *alias_de; 108 109 if ( !inode || !S_ISDIR(inode->i_mode) 110 return; 111 112 alias_de = d_find_alias(inode); 113 if (!alias_de) 114 return; 115 coda_flag_children(alias_de, flag); 116 shrink_dcache_parent(alias_de); 117 dput(alias_de); 118 } 119 120
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.