storagetransfer

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storagetransfer provides HTTP streaming of vdisk files and subvolumes to/from presigned S3 URLs. It is used to move a deployment's persistent bytes (zmount disks and VM rootfs layers) between nodes during a contract move. The helpers are shared by both the storage and storage_light modules.

Index

Constants

View Source
const SnapshotSuffix = ".live-snapshot"

SnapshotSuffix names the live snapshot kept next to a disk file.

Variables

This section is empty.

Functions

func ApplyDelta added in v1.1.6

func ApplyDelta(dst *os.File, r io.Reader) error

ApplyDelta applies a delta to dst: it sets dst's size, writes each data record and punches each zero range as a hole.

func DownloadDir

func DownloadDir(dir, url string) error

DownloadDir GETs url and extracts the tar stream into `dir`.

func DownloadDirCompressed added in v1.1.5

func DownloadDirCompressed(dir, url string, c Compression) error

DownloadDirCompressed GETs url, decodes it with c, and extracts the tar into dir.

func DownloadToFile

func DownloadToFile(path, url string) error

DownloadToFile GETs url and writes the body into an existing file, truncating it.

func DownloadToFileCompressed added in v1.1.5

func DownloadToFileCompressed(path, url string, c Compression) error

DownloadToFileCompressed GETs url, decodes it with c, and writes it into the existing file at path, truncating it. A compressed download leaves runs of zeros as holes, so a mostly empty disk stays sparse.

func DropSnapshot added in v1.1.6

func DropSnapshot(path string) error

DropSnapshot removes the live snapshot of the disk at path, if any.

func Snapshot added in v1.1.6

func Snapshot(src, dst string) (err error)

Snapshot makes dst an instant reflink copy of src (both on one btrfs volume). dst takes src's NOCOW attribute first: btrfs clones only between files that agree on it, and a zos vdisk is NOCOW.

func SnapshotPath added in v1.1.6

func SnapshotPath(path string) string

SnapshotPath is where the live snapshot of the disk at path is kept.

func UploadDelta added in v1.1.6

func UploadDelta(path, url string, c Compression) error

UploadDelta PUTs to url (encoded with c) the delta of the disk at path since its live snapshot, then drops the snapshot. The VM must be paused: the disk is read twice (once to size the upload) and must not change in between.

func UploadDir

func UploadDir(dir, url string) error

UploadDir streams a tar of `dir` to url. It uses two passes so it needs no temp file (nodes run from a small tmpfs): pass 1 tars to a byte counter to get the exact Content-Length (presigned PUT rejects chunked encoding), pass 2 tars straight into the request body via an io.Pipe. The source is a paused VM's rootfs, so it is static between the two passes.

func UploadDirCompressed added in v1.1.5

func UploadDirCompressed(dir, url string, c Compression) error

UploadDirCompressed PUTs a tar of dir to url, encoded with c.

func UploadFile

func UploadFile(path, url string) error

UploadFile PUTs a seekable file so net/http sets a definite Content-Length (presigned S3/MinIO PUT rejects chunked transfer encoding).

func UploadFileCompressed added in v1.1.5

func UploadFileCompressed(path, url string, c Compression) error

UploadFileCompressed PUTs the file at path to url, encoded with c.

func UploadLive added in v1.1.6

func UploadLive(path, url string, c Compression) error

UploadLive takes a fresh live snapshot of the disk at path and PUTs it to url, encoded with c, while the VM keeps running. The snapshot stays for UploadDelta (or DropSnapshot).

func WriteDelta added in v1.1.6

func WriteDelta(w io.Writer, disk io.ReaderAt, size int64, ranges []Range) error

WriteDelta writes the delta of `ranges`, reading their data from disk.

Types

type Compression added in v1.1.5

type Compression string

Compression names how a transfer's bytes are encoded on the wire.

The empty value sends them as they are (a raw disk file, a plain tar). Zstd compresses them: a zmount disk is uploaded whole, unused space included, so a 15 GB disk holding 2 GB of files sends 15 GB raw and about 1 GB compressed.

const (
	// CompressionNone sends the bytes as they are.
	CompressionNone Compression = ""
	// CompressionZstd sends one zstd frame of the bytes.
	CompressionZstd Compression = "zstd"
)

func ParseCompression added in v1.1.5

func ParseCompression(s string) (Compression, error)

ParseCompression accepts the wire names of the supported encodings.

type Extent added in v1.1.6

type Extent struct {
	Logical uint64
	Length  uint64
	Flags   uint32
}

Extent is one entry of a file's extent map.

func Extents added in v1.1.6

func Extents(path string) ([]Extent, error)

Extents reads the extent map of the file at path (FIEMAP, after a sync).

type Range added in v1.1.6

type Range struct {
	Off  int64
	Len  int64
	Zero bool
}

Range is a span of the disk the delta carries: its data, or zeros.

func ChangedRanges added in v1.1.6

func ChangedRanges(disk, snap []Extent, size int64) []Range

ChangedRanges is what changed in a disk since its reflink snapshot, from their extent maps and the disk's size:

  • the disk's extents no longer shared with the snapshot (the VM wrote them): their data, or zeros for an unwritten (preallocated) extent;
  • the snapshot's written extents where the disk now has no extent at all (the VM discarded them): zeros.

The result is sorted, clipped to the size and merged where adjacent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL