AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
vcache.c File Reference

The vnode cache: a filesystem's vnodes that are in use, by inode number, so that a file opened twice gets the same vnode. More...

#include <core/system.h>
#include <fs/vcache.h>

Go to the source code of this file.

Functions

static int vcache_eq (void *_a, void *_b)
 Says whether a cached vnode has the inode number _b points to.
void vcache_init (struct vcache *vcache)
 Sets up an empty vnode cache.
int vcache_insert (struct vcache *vcache, struct vnode *vnode)
 Adds a vnode to a cache.
int vcache_remove (struct vcache *vcache, struct vnode *vnode)
 Takes a vnode out of a cache.
struct vnode * vcache_find (struct vcache *vcache, ino_t ino)
 Finds the cached vnode of an inode.

Detailed Description

The vnode cache: a filesystem's vnodes that are in use, by inode number, so that a file opened twice gets the same vnode.

Definition in file vcache.c.

Function Documentation

◆ vcache_eq()

int vcache_eq ( void * _a,
void * _b )
static

Says whether a cached vnode has the inode number _b points to.

Definition at line 12 of file vcache.c.

References vnode::ino, and vcache_eq().

Referenced by vcache_eq(), and vcache_init().

◆ vcache_find()

struct vnode * vcache_find ( struct vcache * vcache,
ino_t ino )

Finds the cached vnode of an inode.

Parameters
vcachethe cache
inothe inode number
Returns
the vnode, or NULL if it isn't cached

Definition at line 80 of file vcache.c.

References hashmap_node::entry, hashmap_node::hash, vcache::hashmap, vnode::ino, NULL, and vcache_find().

Referenced by ext2_inode_build(), minix_inode_build(), procfs_close(), procfs_vget(), and vcache_find().

◆ vcache_init()

void vcache_init ( struct vcache * vcache)

Sets up an empty vnode cache.

Parameters
vcachethe cache

Definition at line 25 of file vcache.c.

References vcache::hashmap, vcache_eq(), and vcache_init().

Referenced by ext2_load(), minix_load(), procfs_init(), vcache_init(), and vcache_insert().

◆ vcache_insert()

int vcache_insert ( struct vcache * vcache,
struct vnode * vnode )

Adds a vnode to a cache.

Parameters
vcachethe cache, set up on first use
vnodethe vnode
Returns
0, -EINVAL if vcache is NULL, or -ENOMEM

Definition at line 37 of file vcache.c.

References vcache::hashmap, vnode::ino, vcache_init(), and vcache_insert().

Referenced by ext2_inode_build(), minix_inode_build(), procfs_vget(), and vcache_insert().

◆ vcache_remove()

int vcache_remove ( struct vcache * vcache,
struct vnode * vnode )

Takes a vnode out of a cache.

Parameters
vcachethe cache
vnodethe vnode
Returns
0, or -1 if the vnode wasn't in the cache

Definition at line 56 of file vcache.c.

References hashmap_node::hash, vcache::hashmap, vnode::ino, and vcache_remove().

Referenced by ext2_close(), procfs_close(), and vcache_remove().