Log-structured, transactional virtual block device backed by S3

Related tags

Command-line mvps
Overview

mvps

Log-structured, transactional virtual block device compatible with the NBD protocol. mvps stands for "multi-versioned page store".

MVPS can store data on any S3-compatible object storage service, like Amazon S3, Google Cloud Storage, Cloudflare R2, or MinIO. The local disk is only used as a write buffer.

Usage

Create a bucket on an S3-compatible object storage service. If running locally, you can use minio.

Start the transaction engine:

export MVPS_TE_JWT_SECRET="insecure_token"
export AWS_ACCESS_KEY_ID=minioadmin
export AWS_SECRET_ACCESS_KEY=minioadmin
export AWS_REGION=us-east-1
export S3_ENDPOINT=http://localhost:8355

cargo run -p mvps-te --release -- \
  --listen 127.0.0.1:10809 \
  --image-store s3 \
  --image-store-s3-bucket mvps-image-store \
  --image-store-s3-prefix test/ \
  --buffer-store-path /path/to/buffer/store

Sign a JWT with the secret provided in environment variable MVPS_TE_JWT_SECRET. Here's one you can use:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZV9pZCI6IlRFU1RJTUctMDIubXZwcy1pbWFnZSIsImltYWdlX3NpemUiOjEwNzM3NDE4MjQsInBhZ2Vfc2l6ZV9iaXRzIjoxMiwiZXhwIjoxOTAxMTU0OTQxLCJjbGllbnRfaWQiOiJjOWVmZDk2Yy1kYTU5LTQzNTEtYjMxMS0zNTEyOTVmYTk4ZTIifQ.j-nR5Opn-pK6whrm8pJIgyItO5XvlYf0oy7RzR00T1Y

The payload of this JWT is:

{
  "image_id": "TESTIMG-02.mvps-image",
  "image_size": 1073741824,
  "page_size_bits": 12,
  "exp": 1901154941,
  "client_id": "c9efd96c-da59-4351-b311-351295fa98e2"
}

Now, you can attach this virtual block device to your system:

nbd-client -N eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZV9pZCI6IlRFU1RJTUctMDIubXZwcy1pbWFnZSIsImltYWdlX3NpemUiOjEwNzM3NDE4MjQsInBhZ2Vfc2l6ZV9iaXRzIjoxMiwiZXhwIjoxOTAxMTU0OTQxLCJjbGllbnRfaWQiOiJjOWVmZDk2Yy1kYTU5LTQzNTEtYjMxMS0zNTEyOTVmYTk4ZTIifQ.j-nR5Opn-pK6whrm8pJIgyItO5XvlYf0oy7RzR00T1Y 127.0.0.1 10809 /dev/nbd0 -b 4096

mkfs.ext4 /dev/nbd0
mount /dev/nbd0 /mnt

Note that you should never use the same image with different buffer stores. Doing so causes data corruption. An exception to this rule is when the previous buffer store has become permanently inaccessible (e.g. deleted) - in this case, you can use a new buffer store, and the data that is not yet flushed to object storage in the previous buffer store is lost. Transactional consistency is preserved.

Garbage collection

Like any log-structured storage system, MVPS needs to perform background tasks like checkpointing, compaction, and garbage collection. Checkpointing and compaction are performed by the transaction engine. Garbage collection, due to its global nature, is performed by a separate garbage collector process, mvps-s3-gc.

The transaction engine uses the object storage as an immutable store. Without doing garbage collection, the bucket will grow indefinitely. mvps-s3-gc scans the bucket for:

  • Historic versions of images
  • Objects that are no longer referenced by any image

and deletes them.

To run garbage collection once:

export AWS_ACCESS_KEY_ID=minioadmin
export AWS_SECRET_ACCESS_KEY=minioadmin
export AWS_REGION=us-east-1
export S3_ENDPOINT=http://localhost:8355

cargo run -p mvps-s3-gc -- \
  --bucket mvps-image-store --prefix test/ \
  --threshold-inactive-days 0

Transactional extension

MVPS extends the NBD protocol with 4 custom commands:

pub const NBD_CMD_MVPS_BEGIN_TXN: u16 = 64;
pub const NBD_CMD_MVPS_COMMIT_TXN: u16 = 65;
pub const NBD_CMD_MVPS_ROLLBACK_TXN: u16 = 66;
pub const NBD_CMD_MVPS_LOCK_TXN: u16 = 67;

All writes issued between NBD_CMD_MVPS_BEGIN_TXN and NBD_CMD_MVPS_{COMMIT,ROLLBACK}_TXN are atomically committed or rolled back. When a transaction is active, reads follow the read-your-writes semantics.

You might also like...
Provides a cross platform way to shut down, reboot or log out operations

@napi-rs/system-shutdown This package provides a cross platform way to shut down, reboot or log out operations. Supported platforms: Linux, Windows an

DeFiChain octopus is a codename research & development for DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support.

DeFiCh/octopus DeFiChain octopus is a codename research & development for DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support . Proposed as a DFI

Nederlandse programmeertaal. Geinterpreteerd en met dynamische types. Met bytecode compiler en virtual machine, in Rust.

Nederlang Nederlang is een geinterpreteerde programmeertaal, in het Nederlands! Met als bestandsnaam extensie.... .nl! Het maakt gebruik van dynamisch

Horus is an open source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual machine, and the Rust programming language.
Horus is an open source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual machine, and the Rust programming language.

Horus Horus is an open-source tool for running forensic and administrative tasks at the kernel level using eBPF, a low-overhead in-kernel virtual mach

A simple made in Rust crack, automatic for Winrar, activated from shared virtual memory, for studies.
A simple made in Rust crack, automatic for Winrar, activated from shared virtual memory, for studies.

Simple Winrar Crack in Rust What does it do ? A simple project that allows you to modify the license check used by WinRaR, "RegKey" from virtual memor

Nimbus - A virtual, networked filesystem with strong upfront safety guarantees

The Nimbus Filesystem Nimbus is a virtual, networked filesystem that provides upfront safety guarantees to a user, intended for personal use. In parti

Shared execution environment for constructing 3D virtual spaces from the inside.

Hearth Hearth is a shared, always-on execution environment for constructing 3D virtual spaces from the inside. Come join our Discord server! The Histo

A Windows virtual display driver written in Rust (works with VR, etc)

Virtual Display Driver This is a Windows driver made in Rust which creates a virtual desktop. It has many uses, such as: A private virtual desktop for

A visual canvas and virtual machine for writing assembly to build cool things. Create machines and connect them together.
A visual canvas and virtual machine for writing assembly to build cool things. Create machines and connect them together.

Visual Assembly Canvas A highly visual assembly editor, infinite canvas for wiring blocks and machines together, bytecode virtual machine runnable nat

Owner
Heyang Zhou
Working on distributed data infrastructure at Deno. I'm interested in digital systems in general, and their human sides as well.
Heyang Zhou
Valq - macros for querying and extracting value from structured data by JavaScript-like syntax

valq   valq provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax. Look & Feel: u

Takumi Fujiwara 24 Dec 21, 2022
Translation support for mdbook. The plugins here give you a structured way to maintain a translated book.

Gettext Translation Support for mdbook The plugins here makes it easy to translate documentation written in mdbook into multiple languages. Support fo

Google 19 Apr 5, 2023
Costless typed identifiers backed by UUID, with kind readable in serialized versions

Why kind ? With kind, you use typed identifiers in Rust, with no overhead over Uuid have the type be human readable and obvious in JSON and any export

Wingback 67 Mar 24, 2024
Expose standard or fully custom USB peripherals (gadgets) through a USB device controller (UDC) on Linux using Rust.

usb-gadget This library allows implementation of USB peripherals, so called USB gadgets, on Linux devices that have a USB device controller (UDC). Bot

Sebastian Urban 21 Oct 30, 2023
A device-tree source parser, analyzer and language server.

Ginko A device-tree source parser, analyzer and language server. The main goal of this project is to make working with device-trees easy. For example,

Lukas Scheller 4 Feb 28, 2024
A minimalist tool for managing block-lists from the terminal.

Block List A minimalist hosts-based tool for managing block lists and ad-blocking. This project uses the excellent and regularly updated Unified Hosts

Oliver Brotchie 7 Aug 14, 2022
A Write Ahead Log (WAL) implementation in Rust

Okay WAL A write-ahead log (WAL) implementation for Rust. There's The Great Wall, and then there's this: an okay WAL. This crate exposes a WAL that su

Khonsu Labs 5 Oct 28, 2022
Uses the cardano mini-protocols to receive every block and transaction, and save them to a configurable destination

cardano-slurp Connects to one or more cardano-node's, streams all available transactions, and saves them to disk (or to S3) in raw cbor format. Usage

Pi Lanningham 16 Jan 31, 2023
A command-line utility which aligns a block of text within the terminal (or a specified number of columns), written in Rust.

align: a command line utility for aligning text. ⭐ Overview Aligns text within the terminal (or a specified number of columns). The text is treated as

Khalil Ouali 6 Aug 11, 2023
Convert local CAN log files to "routes" suitable for Cabana

Make Cabana Route Utility that takes CSV formatted CAN log files and (optionally) accompanying videos, convert them to "routes" that can be opened in

Angus Gratton 3 Oct 23, 2023