disk

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 16 Imported by: 0

README

ndn-dpdk/container/disk

This package implements an on-disk storage of Data packets.

Disk-backed Data Store (DiskStore)

DiskStore is an on-disk storage of Data packets.

It is backed by an SPDK block device (bdev), whose block size must be 512 bytes. One or more adjacent blocks are joined together to form a slot, identified by a slot number. The DiskStore type stores and retrieves a Data packet via its slot number. It does not have an index, and cannot search Data packets by name.

The intended use case of the DiskStore is to extend the Content Store with additional capacity.

When the CS evicts an entry from memory, it may allocate a slot number and record it on the CS entry, and pass the Data to DiskStore_PutData. The DiskStore will asynchronously write the Data to the assigned slot, and then release its mbuf. Write failures are silently ignored.

When a future Interest matches a CS entry that has no associated packet but a slot number, the forwarding thread will pass the Interest and the slot number to DiskStore_GetData. The DiskStore will asynchronously read the Data from the provided slot into a new mbuf, and then return it back to forwarder data plane via a callback. Specifically, the Interest packet is enqueued, its PInterest struct has a non-zero diskSlot, and the Data packet is assigned to the diskData field; in case of a read/parse failure, the diskData field is set to NULL. The forwarder data plane should then re-process the Interest, and use the Data only if the Interest matches the same CS entry again.

Multiple CS instances can share the same DiskStore if they use disjoint ranges of slots. The CS is responsible for allocating and freeing slot numbers. It is unnecessary for the CS to inform the DiskStore when the Data in a slot is no longer needed: the CS can simply overwrite that slot with another Data packet when the time comes.

Since both PutData and GetData are asynchronous, it's possible for one or more GetData requests to arrive before the PutData on the same slot completes. DiskStore has a per-slot queue, indexed in a hashtable, to solve this issue. This ensures all requests on the same slot are processed in the order they are received, so that the forwarding thread does not need to concern the asynchronous nature of disk operations.

Disk Slot Allocator (DiskAlloc)

DiskAlloc allocates disk slots within a consecutive range of a DiskStore. Available slots of a DiskStore are statically partitioned and associated with each Content Store instance. The CS can then using a DiskAlloc instance to allocate a disk slot for each Data packet it wants to write to disk.

DiskAlloc is implemented as a bitmap. If a bit is set to 1, the disk slot is available. If a bit is cleared to 0, the disk slot is occupied.

Documentation

Overview

Package disk provides a disk-based Data packet store.

Index

Constants

This section is empty.

Variables

View Source
var (
	// StoreGetDataCallback is a C function type for store.GetData callback.
	StoreGetDataCallback = cptr.FunctionType{"Packet"}

	// StoreGetDataGo is a StoreGetDataCallback implementation for receiving the Data in Go code.
	StoreGetDataGo = StoreGetDataCallback.C(unsafe.Pointer(C.go_getDataCallback), uintptr(0))
)
View Source
var GqlStoreCountersType = graphql.NewObject(graphql.ObjectConfig{
	Name:   "DiskStoreCounters",
	Fields: gqlserver.BindFields[StoreCounters](nil),
})

GqlStoreCountersType is the GraphQL type for StoreCounters.

Functions

This section is empty.

Types

type Alloc

type Alloc C.DiskAlloc

Alloc is a disk slot allocator.

func NewAlloc

func NewAlloc(min, max uint64, socket eal.NumaSocket) *Alloc

NewAlloc creates an Alloc.

func NewAllocIn

func NewAllocIn(store *Store, i, nThreads int, socket eal.NumaSocket) *Alloc

NewAllocIn creates an Alloc from Store slot range.

func (*Alloc) Alloc

func (a *Alloc) Alloc() (slot uint64, e error)

Alloc allocates a disk slot.

func (*Alloc) Close

func (a *Alloc) Close() error

Close destroys the Alloc.

func (*Alloc) Free

func (a *Alloc) Free(slot uint64)

Free frees a disk slot.

func (*Alloc) Ptr

func (a *Alloc) Ptr() unsafe.Pointer

Ptr returns *C.DiskAlloc pointer.

func (*Alloc) SlotRange

func (a *Alloc) SlotRange() (min, max uint64)

SlotRange returns a range of possible slot numbers.

type SizeCalc

type SizeCalc struct {
	// NThreads is number of threads.
	NThreads int
	// NPackets is number of packets (capacity) per thread.
	NPackets int
	// PacketSize is size of each packet.
	PacketSize int
}

SizeCalc calculates Store and Alloc sizes.

func (SizeCalc) BlocksPerSlot

func (calc SizeCalc) BlocksPerSlot() int

BlocksPerSlot returns number of blocks per packet slot.

func (SizeCalc) MinBlocks

func (calc SizeCalc) MinBlocks() int64

MinBlocks calculates minimum number of blocks required in the Store.

type Store

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

Store represents a disk-backed Data Store.

func NewStore

func NewStore(device bdev.Device, th *spdkenv.Thread, nBlocksPerSlot int, getDataCb cptr.Function) (store *Store, e error)

NewStore creates a Store.

func (*Store) Close

func (store *Store) Close() error

Close closes this Store. The SPDK thread must still be active.

func (*Store) Counters

func (store *Store) Counters() (cnt StoreCounters)

Counters retrieves disk store counters.

func (*Store) GetData

func (store *Store) GetData(slotID uint64, interest *ndni.Packet, dataBuf *pktmbuf.Packet, sp bdev.StoredPacket) (data *ndni.Packet)

GetData retrieves a Data packet from specified slot and waits for completion. This can be used only if the Store was created with StoreGetDataGo.

func (*Store) Ptr

func (store *Store) Ptr() unsafe.Pointer

Ptr returns *C.DiskStore pointer.

func (*Store) PutData

func (store *Store) PutData(slotID uint64, data *ndni.Packet) (sp bdev.StoredPacket, e error)

PutData asynchronously stores a Data packet.

func (*Store) SlotRange

func (store *Store) SlotRange() (min, max uint64)

SlotRange returns a range of possible slot numbers.

type StoreCounters

type StoreCounters struct {
	NPutDataBegin   uint64 `json:"nPutDataBegin"`
	NPutDataSuccess uint64 `json:"nPutDataSuccess"`
	NPutDataFailure uint64 `json:"nPutDataFailure"`
	NGetDataBegin   uint64 `json:"nGetDataBegin"`
	NGetDataReuse   uint64 `json:"nGetDataReuse"`
	NGetDataSuccess uint64 `json:"nGetDataSuccess"`
	NGetDataFailure uint64 `json:"nGetDataFailure"`
}

StoreCounters contains disk store counters.

Jump to

Keyboard shortcuts

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