Documentation
¶
Overview ¶
Package blk exports persistent sparse volumes through pure-Go NBD over Unix sockets or TCP. Other storage implementations can implement Device directly.
The volume adapter exposes persistent sparse volumes backed by the same chunk, compression, cache and writeback engine as compactfs files.
Index ¶
- Constants
- func Attach(ctx context.Context, cfg AttachConfig) error
- func Detach(devicePath string) error
- func List(ctx context.Context, network, address string) ([]string, error)
- type AttachConfig
- type Client
- func (c *Client) Close() error
- func (c *Client) Flush(ctx context.Context) error
- func (c *Client) Info() ExportInfo
- func (c *Client) ReadAt(ctx context.Context, p []byte, off int64) (int, error)
- func (c *Client) Trim(ctx context.Context, off int64, length uint32) error
- func (c *Client) WriteAt(ctx context.Context, p []byte, off int64) (int, error)
- func (c *Client) WriteAtFUA(ctx context.Context, p []byte, off int64, fua bool) (int, error)
- func (c *Client) Zero(ctx context.Context, off int64, length uint32, noHole, fua bool) error
- type Config
- type Device
- type Export
- type ExportInfo
- type Server
- type Stats
- type Volume
- func (v *Volume) Close(ctx context.Context) error
- func (v *Volume) Flush(ctx context.Context) error
- func (v *Volume) Name() string
- func (v *Volume) ReadAt(ctx context.Context, p []byte, off int64) (int, error)
- func (v *Volume) ReadOnly() bool
- func (v *Volume) Size() int64
- func (v *Volume) Trim(ctx context.Context, off, length int64) error
- func (v *Volume) WriteAt(ctx context.Context, p []byte, off int64) (int, error)
- func (v *Volume) Zero(ctx context.Context, off, length int64, noHole bool) error
- type VolumeConfig
Constants ¶
const ( FlagHasFlags = uint16(1) FlagReadOnly = uint16(2) FlagFlush = uint16(4) FlagFUA = uint16(8) FlagTrim = uint16(32) FlagWriteZeroes = uint16(64) FlagMultiConn = uint16(256) )
const ( SectorSize = 512 DefaultSize = int64(100 << 30) )
Variables ¶
This section is empty.
Functions ¶
func Attach ¶
func Attach(ctx context.Context, cfg AttachConfig) error
Attach negotiates in userspace and hands connected sockets to Linux NBD. It runs in the foreground until Detach or context cancellation. It neither formats nor mounts the block device and does not require cgo or nbd-client.
Types ¶
type AttachConfig ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a serial userspace NBD connection. Use several clients for parallel I/O, or Attach to let the Linux block layer multiplex requests itself.
func (*Client) Info ¶
func (c *Client) Info() ExportInfo
func (*Client) WriteAtFUA ¶
type ExportInfo ¶
type ExportInfo struct {
Name string `json:"name"`
Size int64 `json:"size"`
Flags uint16 `json:"flags"`
MinimumBlock uint32 `json:"minimum_block"`
PreferredBlock uint32 `json:"preferred_block"`
MaximumBlock uint32 `json:"maximum_block"`
}
ExportInfo is the geometry and capability information negotiated with NBD.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type Volume ¶
type Volume struct {
// contains filtered or unexported fields
}
func Open ¶
func Open(ctx context.Context, cfg VolumeConfig) (*Volume, error)
Open must be called once per exported volume; all connections share its File.
type VolumeConfig ¶
type VolumeConfig struct {
FileSystem *core.FileSystem
Name string
// Size is fixed at creation. Zero reopens the stored size, or creates a
// DefaultSize volume when it does not exist. Existing sizes never change.
Size int64
ReadOnly bool
// SyncBackend makes FLUSH/FUA wait for backend persistence. Otherwise the
// durable local raw cache is sufficient, as for mount --sync-mode=local.
// A shared option.WithSyncBackend(true) also requires backend persistence.
SyncBackend bool
}
VolumeConfig contains block-specific settings. Shared storage options (chunking, caches, quota and backups) are configured with fs/option in core.New.