MemFS 2.0 - A Memory-based File System on HP-UX 11iv3

4
Data structures
Directory entries
A directory entry, which converts the file name to an inode, is created for each file/directory.
Directory entries are maintained in the hash table using the unique tuple. As directory entries of a
directory are evenly distributed across the hash table, the lookup of files in the directory is faster
and it scales well for large directories. To support sequential reads (readdir()), each directory
keeps track of all the directory entries in it using a double linked list and associates a unique offset
with each directory entries. The unique directory offsets within a directory are generated using a
per-directory specific counter and a per directory specific freelist of available free offsets for re-
use, to improve the performance of create operation
Inodes
Inodes keeps track of data and information of files. Inodes are created using the kernel memory
and hence the maximum number of inodes on MemFS is restricted by the available kernel
memory. To support remote access of files (using Network file system, NFS), they are maintained
in a hash table. Directory entries will point to these inodes itself. Thus only one copy of inode is
maintained in memory. Vnodes (virtual node) which will provide file system independent access to
outside, is embedded in the inodes. All file types are supported, including symbolic links and
block and character special device files are supported.
File cache
Unified file cache (UFC) maintains all the pages associated with MemFS. During UFC or system
memory pressure, these pages are moved to swap device. It searches the requested data in
memory, and informs MemFS to just initiate the I/O to read the pages from swap incase it is not
present. UFC maintains the position of the data on swap and transparently handles bringing them
to memory.
MemFS Daemon (memfsd)
To improve the performance of some of the operations, a system wide daemon will be running on
the systems with MemFS installed. This will make some of the operations asynchronous. Currently
this is being used to free the memory and blocks used by the purged files. The files being removed
are added to this daemon to free them up asynchronously.
Operations
Mount
A MemFS file system is created using mount operation. It creates an entry in VFS (virtual file
system), directory entries and inodes hash tables and root inode. The root inode will be the root of
the directory tree.
Directory entries operation
All the basic operations which deal with directory entries like create, remove, hard links and
symbolic links are supported on MemFS file system. The directory entries hash table is searched
for the specified name in the directory and corresponding action is performed.
read/write operation
MemFS pass on the read/write requests to UFC similar to other file systems. Using the vnode and
the offset passed in, UFC finds the pages and bring them in to the memory from the swap in case
they are swapped out. Similarly mmap() support is provided.