Documentation
¶
Overview ¶
Package bdev contains bindings of SPDK block device layer.
Index ¶
- Constants
- func TruncateFile(filename string, size int64) error
- type Bdev
- func (bd *Bdev) Close() error
- func (bd *Bdev) CopyToC(ptr unsafe.Pointer)
- func (bd *Bdev) ReadPacket(blockOffset int64, pkt *pktmbuf.Packet, sp StoredPacket) error
- func (bd *Bdev) UnmapBlocks(blockOffset, blockCount int64) error
- func (bd *Bdev) WritePacket(blockOffset int64, pkt *pktmbuf.Packet) (sp StoredPacket, e error)
- type Delay
- type DelayConfig
- type Device
- type DeviceCloser
- type ErrorInjection
- type File
- type FileDriver
- type IOType
- type Info
- func (bdi *Info) BlockSize() int
- func (bdi *Info) BufAlign() int
- func (bdi *Info) CountBlocks() int64
- func (bdi *Info) DevInfo() *Info
- func (bdi *Info) DriverInfo() (value any)
- func (bdi *Info) HasIOType(ioType IOType) bool
- func (bdi *Info) HasWriteCache() bool
- func (bdi *Info) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (bdi *Info) Name() string
- func (bdi *Info) OptimalIOBoundary() (boundary int, mandatory bool)
- func (bdi *Info) ProductName() string
- func (bdi *Info) WriteUnitSize() int
- type Locator
- type Malloc
- type Mode
- type Nvme
- type NvmeNamespace
- type StoredPacket
- type WriteMode
Constants ¶
const RequiredBlockSize = C.BdevBlockSize
RequiredBlockSize is the expected block size.
Variables ¶
This section is empty.
Functions ¶
func TruncateFile ¶
TruncateFile creates and truncates a file.
Types ¶
type Bdev ¶
type Bdev struct { Device // contains filtered or unexported fields }
Bdev represents an open block device descriptor.
func (*Bdev) ReadPacket ¶
ReadPacket reads blocks via scatter gather list.
func (*Bdev) UnmapBlocks ¶
UnmapBlocks notifies the device that the data in the blocks are no longer needed.
func (*Bdev) WritePacket ¶
WritePacket writes blocks via scatter gather list.
type Delay ¶
type Delay struct {
*Info
}
Delay represents a delay block device.
type DelayConfig ¶
type DelayConfig struct { AvgReadLatency time.Duration P99ReadLatency time.Duration AvgWriteLatency time.Duration P99WriteLatency time.Duration }
DelayConfig configures Delay bdev.
type Device ¶
type Device interface {
DevInfo() *Info
}
Device interface represents a device.
func OverrideWriteMode ¶
OverrideWriteMode forces a specific WriteMode for unit testing.
type DeviceCloser ¶
DeviceCloser interface is a device that can be closed.
type ErrorInjection ¶
type ErrorInjection struct {
*Info
}
ErrorInjection represents an error injection block device.
func NewErrorInjection ¶
func NewErrorInjection(inner Device) (device *ErrorInjection, e error)
NewErrorInjection creates an error injection block device.
func (*ErrorInjection) Close ¶
func (device *ErrorInjection) Close() error
Close destroys this block device. The inner device is not closed.
type File ¶
type File struct { *Info // contains filtered or unexported fields }
File represents a file-backed block device. This may use either AIO or Uring driver.
func NewFileWithDriver ¶
func NewFileWithDriver(driver FileDriver, filename string) (device *File, e error)
NewFileWithDriver opens a file-backed block device with specified driver.
type FileDriver ¶
type FileDriver string
FileDriver indicates a file-backed block device driver.
const ( FileAio FileDriver = "aio" FileUring FileDriver = "uring" )
FileDriver values.
type IOType ¶
type IOType int
IOType represents an I/O type.
const ( IORead IOType = C.SPDK_BDEV_IO_TYPE_READ IOWrite IOType = C.SPDK_BDEV_IO_TYPE_WRITE IOUnmap IOType = C.SPDK_BDEV_IO_TYPE_UNMAP IONvmeAdmin IOType = C.SPDK_BDEV_IO_TYPE_NVME_ADMIN IONvmeIO IOType = C.SPDK_BDEV_IO_TYPE_NVME_IO )
type Info ¶
type Info C.struct_spdk_bdev
Info provides information about a block device.
func (*Info) CountBlocks ¶
CountBlocks returns size of block device in logical blocks.
func (*Info) DriverInfo ¶
DriverInfo returns driver-specific information.
func (*Info) HasWriteCache ¶
HasWriteCache returns whether write cache is enabled.
func (*Info) MarshalLogObject ¶
func (bdi *Info) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaler interface.
func (*Info) OptimalIOBoundary ¶
OptimalIOBoundary returns optimal I/O boundary in logical blocks and whether it's mandatory.
func (*Info) WriteUnitSize ¶
WriteUnitSize returns write unit size in logical blocks.
type Locator ¶
type Locator struct { // Malloc=true creates a simulated block device in hugepages memory. Malloc bool `json:"malloc,omitempty"` // File, if not empty, specifies a filename and creates a block device backed by this file. // The file is automatically created and truncated to the required size. File string `json:"file,omitempty"` // FileDriver customizes the SPDK driver for the file-backed block device. FileDriver *FileDriver `json:"fileDriver,omitempty"` // PCIAddr, if not nil, attaches an NVMe device. // The first NVMe namespace that has the expected block size and block count is used. PCIAddr *pciaddr.PCIAddress `json:"pciAddr,omitempty"` }
Locator describes where to create or attach a block device.
type Malloc ¶
type Malloc struct {
*Info
}
Malloc represents a memory-backed block device.
type Nvme ¶
type Nvme struct { // Namespaces is a list of NVMe namespaces as block devices. Namespaces []*NvmeNamespace // contains filtered or unexported fields }
Nvme represents an NVMe controller.
func AttachNvme ¶
func AttachNvme(pciAddr pciaddr.PCIAddress) (nvme *Nvme, e error)
AttachNvme attaches block devices on an NVMe controller.
func (*Nvme) ControllerName ¶
ControllerName returns NVMe controller name.
func (*Nvme) SglSupport ¶
SglSupport reports whether NVMe controller supports scatter-gather lists and whether it requires dword alignment.
type NvmeNamespace ¶
type NvmeNamespace struct {
// contains filtered or unexported fields
}
NvmeNamespace represents an NVMe namespace.
func (*NvmeNamespace) Controller ¶
func (nn *NvmeNamespace) Controller() *Nvme
Controller returns NVMe controller.
func (*NvmeNamespace) DevInfo ¶
func (nn *NvmeNamespace) DevInfo() *Info
DevInfo implements Device interface.
type StoredPacket ¶
type StoredPacket C.BdevStoredPacket
StoredPacket describes length and alignment of a stored packet.
func StoredPacketFromPtr ¶
func StoredPacketFromPtr(ptr unsafe.Pointer) *StoredPacket
StoredPacketFromPtr converts *C.BdevStoredPacket pointer to StoredPacket.
func (*StoredPacket) Ptr ¶
func (sp *StoredPacket) Ptr() unsafe.Pointer
Ptr returns *C.BdevStoredPacket pointer.