flashblock

package module
v0.0.0-...-f56d8ae Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 2 Imported by: 0

README

flashblock
==========

A simple simulated flash-based block device. The idea is to simulate the
behaviour of a (NAND) flash-based storage device, which only allows write-once
sectors and erasing of whole erase blocks. A simple Flash Translation Layer
(FTL) has been implemented to expose block device sematics.

The reason for writing this is mainly a learning exercise and curiosity. I
wanted a tool to be able to measure the effect of write amplification and erase
block lifetimes, on certain Linux workloads (git, compiling, databases, etc).
Although SSDs generally expose some metrics through SMART, finer granularity
statistics such as histograms of erase block utilisation or erase counts are
not visible to the average user.

So to gather these kind of statistics, I decided to implement a block device
which simulates (very poorly) an SSD and tracks these statistics.

This is a work-in-progress, so only basic histograms and logs are outputted.
Machine-readable/analysable logs are a future me problem. In addition, the
basic FTL isn't very good, and doesn't accurately simulate the behaviour of
NAND flash. In particular, it performs word-sized writes, which flash devices
may not do (at least from what I've seen looking at a few datasheets).

License
=======

flashblock is released under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteZero

func WriteZero(w io.WriterAt, off, length int64) (int64, error)

Types

type Chip

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

func NewChip

func NewChip(eraseBlockSize, size int64, backing ReadWriterAt) *Chip

func (*Chip) EraseBlock

func (c *Chip) EraseBlock(index int64) error

func (*Chip) EraseBlockCount

func (c *Chip) EraseBlockCount() int64

func (*Chip) EraseBlockSize

func (c *Chip) EraseBlockSize() int64

func (*Chip) ReadAtBlock

func (c *Chip) ReadAtBlock(index int64, p []byte, off int64) (int, error)

func (*Chip) Size

func (c *Chip) Size() int64

func (*Chip) WriteAtBlock

func (c *Chip) WriteAtBlock(index int64, p []byte, off int64) (int, error)

type EraseBlock

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

func NewEraseBlock

func NewEraseBlock(size int64, backing ReadWriterAt) *EraseBlock

func (*EraseBlock) Erase

func (b *EraseBlock) Erase() error

func (*EraseBlock) ReadAt

func (b *EraseBlock) ReadAt(p []byte, off int64) (int, error)

func (*EraseBlock) Size

func (b *EraseBlock) Size() int64

func (*EraseBlock) WriteAt

func (b *EraseBlock) WriteAt(p []byte, off int64) (int, error)

type ReadWriterAt

type ReadWriterAt interface {
	io.ReaderAt
	io.WriterAt
}

func NewOffsetReadWriterAt

func NewOffsetReadWriterAt(backing ReadWriterAt, offset int64) ReadWriterAt

Directories

Path Synopsis
cmds

Jump to

Keyboard shortcuts

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