SquirrelFS is a file system for persistent memory (PM) written in Rust that uses soft updates for crash consistency. It uses Rust support for the typestate pattern to check that persistent updates adhere to the soft updates rules. It relies on the Rust for Linux build system to compile Rust code in the Linux kernel.
If you use SquirrelFS, please cite the following paper:
@inproceedings {osdi24-squirrelfs,
author = {Hayley LeBlanc and Nathan Taylor and James Bornholt and Vijay Chidambaram},
title = {{SquirrelFS}: using the Rust compiler to check file-system crash consistency},
booktitle = {18th USENIX Symposium on Operating Systems Design and Implementation (OSDI 24)},
year = {2024},
url = {https://www.usenix.org/conference/osdi24/presentation/leblanc},
publisher = {USENIX Association},
month = jul,
}
- Repository contents
- System requirements
- Quickstart guide
- Detailed setup
- Artifact evaluation
- Setting up PM
- Kernel configuration
- Using rust-analyzer
dependencies/: contains scripts to install SquirrelFS, kernel compilation, and Alloy model dependencies.evaluation/: contains benchmark code and helper scripts to run all experiments presented in the SquirrelFS paper. artifact_evaluation.md contains detailed information on how to run these experiments.linux/: contains a slightly modified v6.3.0 Linux kernel and the SquirrelFS file system.model_checking: contains the SquirrelFS Alloy model, plus utilities and scripts to check the model and examine the output of such checks.
- Ubuntu 22.04 or Debian Bookworm
- 128MB persistent memory (emulated or real)
- 16GB DRAM
- 20GB free disk space
Note: These are minimum general requirements for SquirrelFS. The recommended artifact evaluation requirements are listed in artifact_evaluation.md.
SquirrelFS can be run in a VM or on a baremetal machine.
This section describes how to download and run SquirrelFS on a pre-made VM with emulated PM. For more detailed instructions on running SquirrelFS on baremetal or a custom-made VM, see below.
- Download the pre-made VM image:
curl -o rustfs.img.tar.gz https://www.cs.utexas.edu/~hleblanc/rustfs.img.tar.gz(13GB) - Untar the VM image:
tar -xf rustfs.img.tar.gz(expands to about 30GB; may take up to 50GB) - The VM can now be booted using
qemu-system-x86_64 -boot c -m 30G -hda rustfs.img -enable-kvm -net nic -net user,hostfwd=tcp::2222-:22 -cpu host -nographic -smp <# cores>. We suggest providing QEMU at minimum 8 cores, and ideally more if possible.- After running the boot command, the VM will appear to hang with a
Booting from Hard Disk...message. Leave this terminal running.
- After running the boot command, the VM will appear to hang with a
- Open another terminal window and SSH in using
ssh rustfs@localhost -p 2222; it may take a few seconds following VM startup before you can connect to the VM. The username and password are bothrustfs. - To gracefully shut down the VM, in your SSH session, run
sudo shutdown -h now. You will be disconnected from the VM and your QEMU console, opened in step 3, will close as well.
cd squirrelfsand pull to ensure the local version is up to date.- You will need to create a GitHub SSH key in the VM and add it to your GitHub account to pull from the repository.
- Run
dependencies/dependencies.shto ensure all dependencies are up to date. - Build and install the most up-to-date version of the kernel (on a VM with 16GB RAM and 8 cores: ~45 min to compile, ~5 min to install):
cd linux
cp SQUIRRELFS_CONFIG .config
make LLVM=-14 -j <# cores>
sudo make modules_install install
- Reboot the VM via
sudo shutdown -r now. - On reboot, check that the correct kernel is running;
uname -rshould output6.3.0-squirrelfs+or similar.- If the output is different, check that the kernel built and installed without errors and ensure GRUB options are set to boot into the correct kernel.
- Load the file system module and initialize and mount SquirrelFS:
cd squirrelfs
sudo insmod linux/fs/squirrelfs/squirrelfs.ko
sudo mount -o init -t squirrelfs /dev/pmem0 /mnt/pmem
- Run
dfto confirm that SquirrelFS is mounted. If SquirrelFS is mounted, the output will include something like:
/dev/pmem0 1048576 11276 1037300 2% /mnt/pmem
This section describes how to set up your own VM to run SquirrelFS and how to install it on either the VM or a baremetal machine.
- Install QEMU:
sudo apt-get install qemu-system - Create a VM image:
qemu-img create -f qcow2 <image name> <size>- Your VM disk size should be at least 50GB
- Download Ubuntu 22.04 and boot the VM:
qemu-system-x86_64 -boot d -cdrom <path to ubuntu ISO> -m 8G -hda <image name> -enable-kvm. - Follow the instructions to install Ubuntu on the VM. Defaults for the minimal installation are fine.
- Quit the VM and boot it again using
qemu-system-x86_64 -boot c -m 8G -hda <image name> -enable-kvm. - Open a terminal in the graphical VM and run
sudo apt-get git openssh-server - The VM can now be booted using
qemu-system-x86_64 -boot c -m 8G -hda <image name> -enable-kvm -net nic -net user,hostfwd=tcp::2222-:22 -cpu host -nographic -smp <cores>and accessed via ssh over port 2222.- After running the boot command, the VM will appear to hang with a
Booting from Hard Disk...message. Open another terminal window and SSH in; it may take a few seconds before you can connect to the VM.
- After running the boot command, the VM will appear to hang with a
If using a VM, run these steps on the VM.
- Clone this repo and
cdtosquirrelfs/ - Install Rust by following the instructions at the following link: https://www.rust-lang.org/tools/install
- Run
dependencies/dependencies.shto install packages required to build the kernel.- Note: this script overrides the Rust toolchain for the
squirrelfsdirectory to use the version required by the kernel and installsrust-fmt,rust-src, andbindgen. - Note: this script installs
default-jdkanddefault-jreso that the Alloy model can be checked.
- Note: this script overrides the Rust toolchain for the
- Copy
SQUIRRELFS_CONFIGto.config. - Build and install the kernel (on a VM with 16GB RAM and 8 cores: ~45 min to compile, ~5 min to install):
cd linux
make LLVM=-14 -j <# cores>
sudo make modules_install install
While building the kernel, it may prompt you to select some configuration options interactively. Select the default option by hitting Enter on each prompt.
If using a VM, run these steps on the VM.
cdtosquirrelfs/- Copy
SQUIRRELFS_CONFIGto.config.- Note: this step should only be done after installing Rust dependencies with
dependencies/rust_dependencies.sh. If Rust is not properly set up before copying the configuration file, one required option (CONFIG_RUST) will be set incorrectly.
- Note: this step should only be done after installing Rust dependencies with
- Build the kernel with
make LLVM=-14 -j <number of cores>.LLVM=14is necessary to build Rust components. (45 minutes on a QEMU/KVM VM with 16GB RAM and 8 cores)- Note: while building the kernel, it may prompt you to select some configuration options interactively.
- Select the first option (i.e. 1,2,3 => choose 1 OR N/y => choose N)
- Install the kernel with
sudo make modules_install install(5 minutes on VM) - Reboot the machine or VM
- Check that everything was set up properly.
uname -rshould return a kernel version number starting with6.3.0. - Run
sudo mkdir /mnt/pmem/to create a mount point for the persistent memory device.
The above steps only need to be followed the first time after cloning the kernel. The steps for subsequent builds of the entire kernel are:
make LLVM=-14 -j <number of cores>sudo make modules_install install- Reboot
- Building just the file system:
make LLVM=-14 fs/squirrelfs/squirrelfs.ko - To load the file system module:
sudo insmod fs/squirrelfs/squirrelfs.ko - To mount the file system:
- To initialize following a recompilation,
sudo mount -o init -t squirrelfs /dev/pmem0 /mnt/pmem - For all subsequent mounts:
sudo mount -t squirrelfs /dev/pmem0 /mnt/pmem
- To initialize following a recompilation,
- To unmount the file system:
sudo umount /dev/pmem0 - To remove the file system module:
sudo rmmod squirrelfs
Detailed instructions to run experiments and reproduce the results in the paper can be found in artifact_evaluation.md.
If real PM is not available, SquirrelFS can be run with emulated PM. Note that the following emulation technique is not persistent; the emulated PM device will be wiped on reboot.
- Edit the
/etc/default/grubfile: update theGRUB_CMDLINE_LINUXline toGRUB_CMDLINE_LINUX="memmap=XG!YG"- This will reserve X GB of DRAM as an emulated persistent memory starting at Y GB.
- We suggest using
GRUB_CMDLINE_LINUX="memmap=1G!4G"
- Run
sudo update-grub - Reboot
- After rebooting, confirm that the PM is emulated correctly by checking if
/dev/pmem0is present.
For more information on PM emulation, see https://docs.pmem.io/persistent-memory/getting-started-guide/creating-development-environments/linux-environments/linux-memmap
PM devices are managed by the NDCTL utility and are partitioned in to namespaces.
SquirrelFS requires a PM device with a corresponding namespace set to the fsdax mode.
- To show active namespaces, run
ndctl list -N. - If there is not currently a namespace in
fsdaxmode, create a new namespace in this mode by runningsudo ndctl create-namespace -f -e namespace0.0 --mode=fsdax- NOTE: this will overwrite
namespace0.0if it already exists.
- NOTE: this will overwrite
For more information on NDCTL, see the NDCTL user guide: https://docs.pmem.io/ndctl-user-guide/
SQUIRRELFS_CONFIG contains the required configurations for SquirrelFS plus drivers required to run on a QEMU VM or baremetal machine.
If you want to start from a different configuration file, make sure the following options are set:
- Make sure that
CONFIG_RUST(underGeneral Setup -> Rust Support) is set to Y. If this option isn't available, make sure thatmake LLVM=14 rustavailablereturns success andCONFIG_MODVERSIONSandCONFIG_DEBUG_INFO_BTFare set to N.- Be sure to install Rust and run
dependencies/dependencies.shfirst; this option will not be available otherwise.
- Be sure to install Rust and run
- Set the following config options. These should be done in the listed order, as some later options depend on earlier ones.
- Set
CONFIG_SYSTEM_TRUSTED_KEYSto an empty string - Set
CONFIG_SYSTEM_REVOCATION_KEYSto N - Set
CONFIG_MODULESto Y - Set
CONFIG_MEMORY_HOTPLUGandCONFIG_MEMORY_HOTREMOVEto Y - Set
CONFIG_ZONE_DEVICEto Y - Set
CONFIG_LIBNVDIMM,CONFIG_BTT,CONFIG_NVDIMM_PFN, andCONFIG_NVDIMM_DAXto Y - Set
CONFIG_BLK_DEV_PMEMto M - Set
CONFIG_DAXto Y - Set
CONFIG_X86_PMEM_LEGACYto Y - Set
CONFIG_FS_DAXto Y - Set
CONFIG_SQUIRRELFSto M - Set
CONFIG_DEBUG_PREEMPTIONto N - Set
CONFIG_LOCALVERSION_AUTOto N - Set
CONFIG_TRANSPARENT_HUGEPAGEto Y
- Set
If you'd like to run rust-analyzer, do the following:
cdtolinux/fs/squirrelfs- Retrieve your
sysrootby typingrustc --print sysrootinto the terminal - Open
rust-project.jsonand replacesysrootwith the output of step 2. Additionally, replaceroot_modulewith the absolute path to thesuper.rsfile inlinux/fs/squirrelfs
To use rust-analyzer with a text editor like VSCode, open your settings.json for VSCode and insert the following lines:
"rust-analyzer.linkedProjects": [
"<absolute path to this repo>/linux/fs/squirrelfs/rust-project.json"
],
Finally, replace the path above to the absolute path of the rust-project.json file you modified above.
For other text editors, reference this man page.