~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/coda/cache.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/coda/cache.c (Version linux-6.11.5) and /fs/coda/cache.c (Version linux-2.6.0)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php