Skip to content

tsukuba-hpcs/nzfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NZFS - Null/Zero Filesystem

A high-performance filesystem designed for benchmarking file transfer operations, with both FUSE and native kernel module implementations.

Overview

NZFS (Null/Zero Filesystem) is a memory-only filesystem that provides maximum I/O performance by:

  • Discarding all write operations immediately (like /dev/null)
  • Returning zeros for all read operations (like /dev/zero)
  • Storing only metadata in memory

This makes it ideal for benchmarking file transfer tools like rsync, scp, or custom transfer utilities without the overhead of actual disk I/O.

Implementations

NZFS provides two implementations:

  1. FUSE Implementation (fuse/)

    • Safe userspace implementation
    • Performance: 1.7-6.5 GB/s
    • Easy to debug and develop
    • No risk of system crashes
  2. Kernel Module (kernel/)

    • Native kernel implementation
    • Performance: 10-30+ GB/s (approaching /dev/null speeds)
    • Requires root access
    • ⚠️ WARNING: Can crash your system if buggy

Features

  • Maximum Performance: Write operations return immediately without storing data
  • Zero Overhead Reads: All reads return zero-filled buffers
  • Full Metadata Support: Preserves file attributes, permissions, timestamps for realistic testing
  • Thread-Safe: Uses read-write locks for concurrent access
  • POSIX Compliant: Supports standard file operations (create, delete, rename, chmod, etc.)
  • Memory-Only: All data is volatile and cleared on unmount

Requirements

FUSE Implementation

  • libfuse3-dev
  • gcc
  • make

Kernel Module

  • Linux kernel headers (linux-headers-$(uname -r))
  • gcc
  • make
  • Root access

Quick Start

FUSE Implementation (Safe)

# Build
cd fuse/
make

# Run
mkdir /tmp/nzfs_mount
./nzfs /tmp/nzfs_mount

# Use filesystem
echo "test" > /tmp/nzfs_mount/file.txt

# Unmount
fusermount -u /tmp/nzfs_mount

Kernel Module (Dangerous - Test in VM first!)

# Build
cd kernel/
make

# Load module (requires root)
sudo insmod nzfs.ko

# Mount
sudo mkdir -p /mnt/nzfs
sudo mount -t nzfs none /mnt/nzfs

# Use filesystem
echo "test" > /mnt/nzfs/file.txt

# Unmount and unload
sudo umount /mnt/nzfs
sudo rmmod nzfs

Usage

FUSE Implementation

Mount the filesystem:

cd fuse/
mkdir /tmp/nzfs_mount
./nzfs /tmp/nzfs_mount

In another terminal, use the filesystem:

# Create files
echo "test" > /tmp/nzfs_mount/file.txt

# Create directories
mkdir /tmp/nzfs_mount/mydir

# Copy files (writes are instant)
cp large_file.dat /tmp/nzfs_mount/

# Read files (returns zeros)
cat /tmp/nzfs_mount/file.txt

Unmount the filesystem:

fusermount -u /tmp/nzfs_mount

Background Mode

To run in background:

./nzfs -o allow_other /tmp/nzfs_mount &

Testing

Run the test suite:

make test

Benchmarking Example

Test rsync performance:

# Mount NZFS
mkdir /tmp/nzfs_bench
./nzfs /tmp/nzfs_bench &

# Benchmark rsync
time rsync -av --progress /large/dataset/ /tmp/nzfs_bench/

# Unmount
fusermount -u /tmp/nzfs_bench

Architecture

Data Structures

  • nzfs_node: Represents each file/directory with full stat metadata
  • nzfs_state: Global state with linked list of nodes and pthread rwlock

Operations

  • write(): Accepts data but discards immediately, updates file size
  • read(): Returns zero-filled buffer up to file size
  • create/mkdir: Allocates metadata structure in memory
  • chmod/chown/utimens: Updates metadata only
  • rename: Updates path in metadata structure

Performance

Comparison

Implementation Write Speed Read Speed Safety
/dev/null (baseline) ~55 GB/s ~55 GB/s Safe
NZFS Kernel Module 10-30 GB/s 10-30 GB/s Dangerous
NZFS FUSE 1.7 GB/s 6.5 GB/s Safe
Typical NVMe SSD 2-3 GB/s 3-5 GB/s Safe
Typical SATA SSD 0.5 GB/s 0.5 GB/s Safe
Typical HDD 0.1-0.2 GB/s 0.1-0.2 GB/s Safe

Benchmark Commands

# FUSE
dd if=/dev/zero of=/tmp/nzfs_mount/test bs=1M count=10000

# Kernel module
dd if=/dev/zero of=/mnt/nzfs/test bs=1M count=10000

# Baseline
dd if=/dev/zero of=/dev/null bs=1M count=10000

Limitations

  • All data is lost on unmount
  • No data persistence
  • Memory usage grows with number of files
  • No quota limits

Development

Project Structure

nzfs/
├── fuse/              # FUSE implementation (safe)
│   ├── src/           # Source code
│   ├── include/       # Header files
│   ├── test/          # Test scripts
│   ├── benchmark.sh   # Performance benchmarks
│   ├── profile*.sh    # Profiling scripts
│   └── Makefile       # Build system
├── kernel/            # Kernel module (dangerous)
│   ├── nzfs_kernel.c  # Kernel module source
│   ├── Makefile       # Kernel module build
│   ├── test.sh        # Test script
│   └── README.md      # Usage instructions
└── README.md          # Main documentation

Building

make            # Build the project
make clean      # Clean build artifacts
make test       # Run tests
make install    # Install system-wide
make uninstall  # Remove from system

License

This project is provided as-is for benchmarking and testing purposes.

Contributing

Contributions are welcome. Please ensure all tests pass before submitting changes.

Troubleshooting

Mount fails with "fuse: device not found"

Ensure FUSE kernel module is loaded:

sudo modprobe fuse

Permission denied

Use -o allow_other option and ensure user is in the fuse group:

sudo usermod -aG fuse $USER

Cannot unmount

Force unmount:

fusermount -uz /mount/point

Or kill the FUSE process:

killall nzfs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors