fs/coda/cache.c
Source file repositories/reference/linux-study-clean/fs/coda/cache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/coda/cache.c- Extension
.c- Size
- 3115 bytes
- Lines
- 122
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/kernel.hlinux/time.hlinux/fs.hlinux/stat.hlinux/errno.hlinux/uaccess.hlinux/string.hlinux/list.hlinux/sched.hlinux/spinlock.hlinux/coda.hcoda_psdev.hcoda_linux.hcoda_cache.h
Detected Declarations
function coda_cache_enterfunction coda_cache_clear_inodefunction coda_cache_clear_allfunction coda_cache_checkfunction coda_flag_childrenfunction coda_flag_inode_children
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* 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 <linux/uaccess.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/coda.h>
#include "coda_psdev.h"
#include "coda_linux.h"
#include "coda_cache.h"
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);
spin_lock(&cii->c_lock);
cii->c_cached_epoch = atomic_read(&permission_epoch);
if (!uid_eq(cii->c_uid, current_fsuid())) {
cii->c_uid = current_fsuid();
cii->c_cached_perm = mask;
} else
cii->c_cached_perm |= mask;
spin_unlock(&cii->c_lock);
}
/* remove cached acl from an inode */
void coda_cache_clear_inode(struct inode *inode)
{
struct coda_inode_info *cii = ITOC(inode);
spin_lock(&cii->c_lock);
cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
spin_unlock(&cii->c_lock);
}
/* remove all acl caches */
void coda_cache_clear_all(struct super_block *sb)
{
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);
int hit;
spin_lock(&cii->c_lock);
hit = (mask & cii->c_cached_perm) == mask &&
uid_eq(cii->c_uid, current_fsuid()) &&
cii->c_cached_epoch == atomic_read(&permission_epoch);
spin_unlock(&cii->c_lock);
return hit;
}
/* 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 */
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/time.h`, `linux/fs.h`, `linux/stat.h`, `linux/errno.h`, `linux/uaccess.h`, `linux/string.h`.
- Detected declarations: `function coda_cache_enter`, `function coda_cache_clear_inode`, `function coda_cache_clear_all`, `function coda_cache_check`, `function coda_flag_children`, `function coda_flag_inode_children`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.