MemFS v2 û A Memory-based File System on HP-UX 11i v2
Since the system sees a RAM disk as a device rather than a file system, any access to a file stored on
it results in a second copy of the data being kept in the file system buffer. Some of the
implementations of a RAM disk may provide an improved interface and some of these shortcomings
may not be present.
As attractive as the performance aspects sound, a memory-based file system only works efficiently
under certain circumstances. The biggest disadvantage is that it does not preserve data across
mounts. It cannot be used to replace file systems that store persistent data. Since it uses memory which
is a shared resource, excessive use can adversely affect other memory consumers. A typical use of a
memory file system is for storing temporary files that are created, accessed frequently in a short span
of time and then deleted. The advantage comes from not having to update large amounts of metadata
on file creation – growing the file – and then deletion and cleanup.
The write-to-swap feature of memory-based file systems efficiency has direct correlation with the swap
activity. As the swap activity increases, the file system performance decreases.
The HP-UX Memory-based File System Design
The memory file-based system which is available as a configurable product in HP-UX 11iv2 is based
on the buffer cache approach.
HP-UX uses HFS
1
as the base for MemFS
2
. HFS provides a well-designed and tested file system
implementation. It has all the features needed for a basic file system. Some of the more advanced file
system features (e.g. journaling, un-buffered I/O) that some of the contemporary file systems provide
are neither required nor relevant in the context of a memory file system.
Figure 1. MemFS Design
A MemFS file-system is created from a mount(1M) command. Initially the metadata for the file system
is created in memory, and the necessary VFS
3
and inode structures are initialized. A file system has
the concept of disk layout, which refers to how information such as the superblock, inodes and the
data blocks are organized on the disk. In a MemFS this disk information is simulated, and kept in
1
HFS – Hierarchical File System, the file system traditionally used by Unix based Operating Systems
2
The term MemFS is used to refer to the HP-UX implementation of a Memory File System.
3
VFS- Virtual File System – an abstraction layer on top of a more concrete file system.
MemFS
UFS
VFS
Buffer cache
MemFS
swap pseudo
driver
System swap
device
user process
(per MemFS
mount)