Documentation
¶
Index ¶
- func CalculateAlignment(r Region) (uint64, []interface{})
- func DestroyNamespaceByName(ndctx Context, name string) error
- func IsSpaceAvailable(ndctx Context, size uint64) bool
- type Bus
- type Context
- type CreateNamespaceOpts
- type Dimm
- type MapLocation
- type Mapping
- type Namespace
- type NamespaceMode
- type NamespaceType
- type Region
- type RegionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateAlignment ¶ added in v1.0.0
CalculateAlignment considers region and namespace alignment. It returns the final alignment value and key/value pairs for logging.
func DestroyNamespaceByName ¶ added in v1.0.0
DestroyNamespaceByName deletes the namespace with the given name.
func IsSpaceAvailable ¶ added in v1.0.0
IsSpaceAvailable checks if a region is available with given free size.
Types ¶
type Bus ¶
type Bus interface {
// Provider returns the bus provider.
Provider() string
// DeviceName returns the bus device name.
DeviceName() string
// Dimms returns the dimms provided by the bus.
Dimms() []Dimm
// ActiveRegions returns all active regions in the bus.
ActiveRegions() []Region
// AllRegions returns all regions in the bus including disabled regions.
AllRegions() []Region
// GetRegionByPhysicalAddress finds a region by physical address.
GetRegionByPhysicalAddress(address uint64) Region
}
Bus is a go wrapper for ndctl_bus.
type Context ¶
type Context interface {
// Free destroys the context.
Free()
// GetBuses returns all available buses.
GetBuses() []Bus
}
Context is a go wrapper for ndctl context
type CreateNamespaceOpts ¶
type CreateNamespaceOpts struct {
Name string
Size uint64
SectorSize uint64
Type NamespaceType
Mode NamespaceMode
Location MapLocation
}
CreateNamespaceOpts options to create a namespace
type Dimm ¶
type Dimm interface {
// Enabled returns if the dimm is enabled.
Enabled() bool
// Active returns if the the device is active.
Active() bool
// ID returns the dimm's unique identifier string.
ID() string
// PhysicalID returns the dimm's physical id number.
PhysicalID() int
// DeviceName returns the dimm's device name.
DeviceName() string
// Handle returns the dimm's handle.
Handle() int16
}
Dimm is a go wrapper for ndctl_dimm.
type MapLocation ¶
type MapLocation string
const ( MemoryMap MapLocation = "mem" // RAM DeviceMap MapLocation = "dev" // Block Device NoneMap MapLocation = "none" )
type Mapping ¶
type Mapping interface {
// Offset returns the offset within the region.
Offset() uint64
// Length returns the mapping's length.
Length() uint64
// Position returns the mapping's position.
Position() int
// Region gets the associated region.
Region() Region
// Dimm gets the associated dimm.
Dimm() Dimm
}
Mapping is a go wrapper for ndctl_mapping.
type Namespace ¶
type Namespace interface {
// ID returns the namespace id.
ID() uint
// Name returns the name of the namespace.
Name() string
// DeviceName returns the device name of the namespace.
DeviceName() string
// BlockDeviceName returns the block device name of the namespace.
BlockDeviceName() string
// Size returns the size of the device provided by the namespace.
Size() uint64
// RawSize returns the amount of PMEM used by the namespace
// in the underlying region, which is more than Size().
RawSize() uint64
// Mode returns the namespace mode.
Mode() NamespaceMode
// Type returns the namespace type.
Type() NamespaceType
// Enabled return true if the namespace is enabled.
Enabled() bool
// Active returns true if the namespace is active.
Active() bool
// UUID returns the uuid of the namespace.
UUID() uuid.UUID
// Location returns the namespace mapping location.
Location() MapLocation
// Region returns reference to the region that contains the namespace.
Region() Region
// SetAltName changes the alternative name of the namespace.
SetAltName(name string) error
// SetSize changes the size of the namespace.
SetSize(size uint64) error
// SetUUID changes the uuid of the namespace.
SetUUID(uid uuid.UUID) error
// SetSectorSize changes the sector size of the namespace.
SetSectorSize(sectorSize uint64) error
// SetEnforceMode changes how the namespace mode.
SetEnforceMode(mode NamespaceMode) error
// Enable activates the namespace.
Enable() error
// Disable deactivates the namespace.
Disable() error
// RawMode enables or disables direct access to the block device.
SetRawMode(raw bool) error
// SetPfnSeed creates a PFN for the namespace.
SetPfnSeed(loc MapLocation, align uint64) error
}
Namespace is a go wrapper for ndctl_namespace.
func CreateNamespace ¶ added in v1.0.0
func CreateNamespace(ctx gocontext.Context, ndctx Context, opts CreateNamespaceOpts) (Namespace, error)
CreateNamespace creates a new namespace with given opts in some arbitrary region. It returns an error if creation fails in all regions.
func GetActiveNamespaces ¶ added in v1.0.0
GetActiveNamespaces returns a list of all active namespaces in all regions.
func GetAllNamespaces ¶ added in v1.0.0
GetAllNamespaces returns a list of all namespaces in all regions including idle namespaces.
type NamespaceMode ¶
type NamespaceMode string
NamespaceMode represents mode of the namespace
const ( DaxMode NamespaceMode = "dax" //DevDax FsdaxMode NamespaceMode = "fsdax" //Memory RawMode NamespaceMode = "raw" SectorMode NamespaceMode = "sector" UnknownMode NamespaceMode = "unknown" )
type NamespaceType ¶
type NamespaceType string
NamespaceType type to represent namespace type
const ( //PmemNamespace pmem type namespace PmemNamespace NamespaceType = "pmem" //BlockNamespace block type namespace BlockNamespace NamespaceType = "blk" //IoNamespace io type namespace IoNamespace NamespaceType = "io" //UnknownType unknown namespace UnknownType NamespaceType = "unknown" )
type Region ¶
type Region interface {
// ID returns region id.
ID() uint
// DeviceName returns region name.
DeviceName() string
// Size returns the total size of the region.
Size() uint64
// AvailableSize returns the size of remaining available space in the region.
AvailableSize() uint64
// MaxAvailableExtent returns max available extent size in the region.
MaxAvailableExtent() uint64
// Type identifies the kind of region.
Type() RegionType
// TypeName returns the name for the region type.
TypeName() string
// Enabled returns true if the region is enabled.
Enabled() bool
// Readonly returns true if the region is read/only.
Readonly() bool
// InterleaveWays returns the interleaving of the region.
InterleaveWays() uint64
// ActiveNamespaces returns all active namespaces in the region.
ActiveNamespaces() []Namespace
// AllNamespaces returns all non-zero sized namespaces in the region
// as sometime a deleted namespace also lies around with size zero, we can ignore
// such namespace.
AllNamespaces() []Namespace
// Bus returns the bus associated with the region.
Bus() Bus
// Mappings returns all available mappings in the region.
Mappings() []Mapping
// SeedNamespace returns the initial namespace in the region.
SeedNamespace() Namespace
// CreateNamespace creates a new namespace in the region.
CreateNamespace(ctx gocontext.Context, opts CreateNamespaceOpts) (Namespace, error)
// DestroyNamespace destroys the given namespace in the region.
DestroyNamespace(ns Namespace, force bool) error
// FsdaxAlignment returns the default alignment for an fsdax namespace.
// It always returns a non-zero value.
FsdaxAlignment() uint64
// GetAlign returns region alignment. 0 if unknown.
GetAlign() uint64
}
Region go wrapper for ndctl_region
type RegionType ¶
type RegionType string
const ( PmemRegion RegionType = "pmem" //C.ND_DEVICE_REGION_PMEM BlockRegion RegionType = "blk" //C.ND_DEVICE_REGION_BLK UnknownRegion RegionType = "unknown" )