buse

package
v9.4.40+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

README

What is BUSE?

BUSE is a block driver in user space. It leverages NBD to provide block volume access to a container. In the back, it writes data out to a local file.

Using BUSE

Declare buse as a driver in your OSD config file as such:

---
osd:
  cluster:
    nodeid: "1"
    clusterid: "deadbeeef"
  drivers:
    buse:

BUSE relies on NBD to export block devices. Therefore, remember to modprobe nbd.

Documentation

Overview

Package buse uses the Linux NBD layer to emulate a block device in user space

Index

Constants

View Source
const (
	// Name of the driver
	Name = "buse"
	// Type of the driver
	Type = api.DriverType_DRIVER_TYPE_BLOCK
	// BuseDBKey for openstorage
	BuseDBKey = "OpenStorageBuseKey"
	// BuseMountPath mount path for openstorage
	BuseMountPath = "/var/lib/openstorage/buse/"
)
View Source
const (
	// Defined in <linux/fs.h>:
	BLKROSET = 4701
	// Defined in <linux/nbd.h>:
	NBD_SET_SOCK        = 43776
	NBD_SET_BLKSIZE     = 43777
	NBD_SET_SIZE        = 43778
	NBD_CONNECT         = 43779
	NBD_CLEAR_SOCK      = 43780
	NBD_CLEAR_QUE       = 43781
	NBD_PRINT_DEBUG     = 43782
	NBD_SET_SIZE_BLOCKS = 43783
	NBD_DISCONNECT      = 43784
	NBD_SET_TIMEOUT     = 43785
	NBD_SET_FLAGS       = 43786
	// enum
	NBD_CMD_READ  = 0
	NBD_CMD_WRITE = 1
	NBD_CMD_DISC  = 2
	NBD_CMD_FLUSH = 3
	NBD_CMD_TRIM  = 4
	// values for flags field
	NBD_FLAG_HAS_FLAGS  = (1 << 0) // nbd-server supports flags
	NBD_FLAG_READ_ONLY  = (1 << 1) // device is read-only
	NBD_FLAG_SEND_FLUSH = (1 << 2) // can flush writeback cache
	NBD_FLAG_SEND_FUA   = (1 << 3) // Send FUA (Force Unit Access)
	NBD_FLAG_ROTATIONAL = (1 << 4) // Use elevator algorithm - rotational media
	NBD_FLAG_SEND_TRIM  = (1 << 5) // Send TRIM (discard)

	// These are sent over the network in the request/reply magic fields
	NBD_REQUEST_MAGIC = 0x25609513
	NBD_REPLY_MAGIC   = 0x67446698
)

Variables

This section is empty.

Functions

func Init

func Init(params map[string]string) (volume.VolumeDriver, error)

Init intialized the buse driver

Types

type Device

type Device interface {
	ReadAt(b []byte, off int64) (n int, err error)
	WriteAt(b []byte, off int64) (n int, err error)
}

Device interface is a subset of os.File.

type NBD

type NBD struct {
	// contains filtered or unexported fields
}

NBD type

func Create

func Create(device Device, id string, size int64) *NBD

Create creates a NBD type interface

func (*NBD) Connect

func (nbd *NBD) Connect() (dev string, err error)

Connect the network block device.

func (*NBD) Disconnect

func (nbd *NBD) Disconnect()

Disconnect disconnects the network block device

func (*NBD) GetSize

func (nbd *NBD) GetSize() int64

GetSize returns the size of the NBD.

func (*NBD) IsConnected

func (nbd *NBD) IsConnected() bool

IsConnected returns true if connected.

func (*NBD) Size

func (nbd *NBD) Size(size int64) (err error)

Size sets the size of the NBD.

Jump to

Keyboard shortcuts

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