ioBuster framework v25.02.4 documentation


nvme

nvme

Collection of NVMe related functions

Methods

(static) createQueuePair() → {Number}

Creates an IO queue pair.

Example
// Creating a single IO queue pair
const qid1 = nvme.createQueuePair();
logger.info(`Created IO queue pair with Queue ID ${qid1}.`);

// Creating another IO queue pair
const qid2 = nvme.createQueuePair();
logger.info(`Created IO queue pair with Queue ID ${qid2}.`);

// If you want to create multiple queue pairs in a loop (assuming a hypothetical need to create 5 pairs)
for (let i = 0; i < 5; i++) {
    const qid = nvme.createQueuePair();
    logger.info(`Created IO queue pair with Queue ID ${qid}.`);
}
Returns:

Returns the created Queue ID.

Type
Number

(static) datasetManagement(ranges, options) → {nvme.CompletionQueueEntry}

Sends NVM Dataset Management command.

The Dataset Management command allows the host to indicate to the controller the ranges of logical blocks that the host no longer needs the data that is currently stored in those logical blocks. This command is typically used for TRIM operation in SSDs.

Example
var response = nvme.datasetManagement(
     [{ length: 100, startLba: 2000 }, { length: 50, startLba: 2100 }],
     { nsid: 1, qid: 2, attributes: 0b010 }
 );
 logger.info("Command Status:", response.status);
Parameters:
Name Type Description
ranges Array.<Object>

An array of range objects where each range has a length and starting LBA.

Properties
Name Type Description
length Number

Length in logical blocks.

startLba Number

Starting LBA of the range.

options Object

Optional parameters for the command.

Properties
Name Type Attributes Default Description
nsid Number <optional>
0

Namespace ID. If set to 0, it will use the first available namespace.

qid Number <optional>
0

Queue ID. If set to 0, it will use the first available queue.

attributes Number <optional>
0b100

Dataset management attributes. The default is 4 which represents the Deallocate attribute.

Returns:

Returns an object containing the status and any additional data from the command.

Type
nvme.CompletionQueueEntry

(static) deleteQueuePair(qid)

Deletes an IO queue pair.

Example
// Delete a specific IO queue pair with Queue ID 5
nvme.deleteQueuePair(5);
logger.info('Deleted IO queue pair with Queue ID 5.');

// Attempting to delete another IO queue pair with Queue ID 3
nvme.deleteQueuePair(3);
logger.info('Deleted IO queue pair with Queue ID 3.');

// If you want to delete multiple queue pairs sequentially (assuming a hypothetical range for demonstration)
for (let i = 1; i <= 10; i++) {
    nvme.deleteQueuePair(i);
    logger.info(`Deleted IO queue pair with Queue ID ${i}.`);
}
Parameters:
Name Type Description
qid Number

Queue ID to delete.

(static) disableCommandTracker()

Disables command history tracker

(static) disableDataValidator(optionsopt)

Disables data validation at a given namespace

Parameters:
Name Type Attributes Description
options Object <optional>

Optional Parameters

Properties
Name Type Attributes Default Description
nsid Number <optional>
0xFFFFFFFF

Namespace ID

(static) enableCommandTracker()

Enables command history tracker.

(static) enableDataValidator(optionsopt)

Enables data validation at a given namespace

Parameters:
Name Type Attributes Description
options Object <optional>

Optional Parameters

Properties
Name Type Attributes Default Description
nsid Number <optional>
0xFFFFFFFF

Namespace ID

(static) formatNvm(nsid, lbaFormat, optionsopt) → {nvme.CompletionQueueEntry}

Issues NVM Format command to a given namespace.

Example
// Format a specific namespace with default settings
nvme.formatNvm(1, 5);

// Format a specific namespace with User Data Erase secure settings and Protection Information enabled as Type 1
nvme.formatNvm(2, 7, { ses: 1, pi: 1 });

// Format with Cryptographic Erase and metadata in a separate buffer
nvme.formatNvm(3, 8, { ses: 2, mset: 0 });

// Format with Protection Information in the first bytes of metadata and metadata transferred as part of an extended LBA
nvme.formatNvm(4, 9, { pil: 1, mset: 1 });
Parameters:
Name Type Attributes Description
nsid Number

Namespace ID

lbaFormat Number

LBA Format (0 - 15)

options Object <optional>

Optional parameters

Properties
Name Type Attributes Default Description
ses Number <optional>
0

Secure Erase Settings (0 - 7)

  • 0: No secure erase operation requested
  • 1: User Data Erase
  • 2: Cryptographic Erase
  • 3: Reserved
pil Number <optional>
0

Protection Information Location (0 - 1)

  • 0: Last eight bytes of metadata
  • 1: First eight bytes of metadata
pi Number <optional>
0

Protection Information (0 - 7)

  • 0: Protection information is not enabled
  • 1: Protection information is enabled, Type 1
  • 2: Protection information is enabled, Type 2
  • 3: Protection information is enabled, Type 3
  • 4 - 7: Reserved
mset Number <optional>
0

Meta Settings (0 - 1)

  • 0: Separate buffer
  • 1: Extended LBA
Returns:
Type
nvme.CompletionQueueEntry

(static) getDeviceInfo() → {nvme.DeviceInfo}

Retrieves device information.

Returns:
Type
nvme.DeviceInfo

(static) getNamespaceInfo(nsid) → {nvme.NamespaceInfo}

Retrieves namespace information.

Parameters:
Name Type Description
nsid Number

Namespace ID

Returns:
Type
nvme.NamespaceInfo

(static) loadDriver()

Loads the device driver. Throws an exception if the driver is not loaded correctly.

DEPRECATED - Use nvme.probeController instead.

(static) probeController(options)

Probes an NVMe controller. Throws an exception if an NVMe device is not initialized successfully.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
pciLinkReadyTimeoutMs Number <optional>
30000

PCI link ready timeout in milliseconds

forceDriverReload Boolean <optional>
true

Always reload the driver when set

retryDriverReload Boolean <optional>
true

Retry driver reload

driverReloadTimeoutMs Number <optional>
30000

Driver reload timeout in milliseconds

cmdTimeout Number <optional>
300000

Command timeout in milliseconds

(static) read(startLba, numBlocks, options) → {nvme.CompletionQueueEntry}

Sends NVM Read command.

Example
const startLba = 500;
const numBlocks = 5;

// Using default nsid and qid values
const result1 = nvme.read(startLba, numBlocks);
logger.info(result1);

// Specifying nsid and qid values
const options = { nsid: 2, qid: 3 };
const result2 = nvme.read(startLba, numBlocks, options);
logger.info(result2);

// Using only the required parameters
const startLba = 1000;
const numBlocks = 2;

const result3 = nvme.read(startLba, numBlocks);
logger.info(result3);
Parameters:
Name Type Description
startLba Number

Start LBA where the data should be read from.

numBlocks Number

Number of Logical Blocks to read.

options Object

Additional configuration options.

Properties
Name Type Attributes Default Description
nsid Number <optional>
0

Namespace ID. Uses the first available namespace if nsid is 0.

qid Number <optional>
0

Queue ID. Uses the first available queue if qid is 0.

Returns:
  • Returns the completion queue entry after the command has been executed.
Type
nvme.CompletionQueueEntry

(static) registerPowerControl()

Registers power control script file paths

DEPRECATED - Use powerController.init instead.

(static) resetController()

Issues a controller level reset.

(static) sendAdminCommand(command, buffer, isHostToDevice) → {nvme.CompletionQueueEntry}

Sends an NVMe Admin Command.

Example
// Example: Sending an "Identify" command using the NVMe "sendAdminCommand" API
var identifyBuffer = Buffer.alloc(4096);  // Allocating a 4K buffer to retrieve identify information

nvme.sendAdminCommand({
   nsid: 0,               // Namespace ID (0 for controller, specific ID for namespace)
   opc: 0x06,            // Opcode for Identify command
   cdw10: 1,             // Specify what to identify (1 = namespace, 2 = controller)
}, identifyBuffer, false);  // Set to false since we're expecting data from the device
Parameters:
Name Type Description
command Object

NVMe command queue entry

Properties
Name Type Attributes Default Description
nsid Number

Namespace ID

opc Number

Opcode

cdw10 Number <optional>
0

Command Dword 10

cdw11 Number <optional>
0

Command Dword 11

cdw12 Number <optional>
0

Command Dword 12

cdw13 Number <optional>
0

Command Dword 13

cdw14 Number <optional>
0

Command Dword 14

cdw15 Number <optional>
0

Command Dword 15

buffer Buffer

Data buffer (usually a buffer to hold the retrieved information)

isHostToDevice Boolean

Data transfer direction

Returns:
Type
nvme.CompletionQueueEntry

(static) sendNvmCommand(qid, command, buffer, isHostToDevice) → {nvme.CompletionQueueEntry}

Sends an NVM Command.

Example
// Example: Sending a "Write" command using the NVMe "sendNvmCommand" API
var writeDataBuffer = Buffer.from('This is data to be written to NVMe drive');
var startLBA = 0x1FFFFFFFF;  // starting Logical Block Address
var numLBAs = (writeDataBuffer.length / 512) - 1;  // number of LBAs to write, assuming 512-byte sectors and subtracting 1 as it's 0-based.

var lower32bits = startLBA % 0x100000000; // Equivalent to startLBA & 0xFFFFFFFF for values > 32-bits
var upper32bits = Math.floor(startLBA / 0x100000000); // Obtain the upper 32 bits by dividing

nvme.sendNvmCommand(1, {
   nsid: 1,
   opc: 0x01, // Opcode for Write command
   cdw10: lower32bits, // Starting LBA (lower 32 bits)
   cdw11: upper32bits, // Starting LBA (upper 32 bits)
   cdw12: numLBAs
}, writeDataBuffer, true);
Parameters:
Name Type Description
qid Number

IO queue ID

command Object

NVMe command queue entry

Properties
Name Type Attributes Default Description
nsid Number

Namespace ID

opc Number

Opcode

cdw10 Number <optional>
0

Command Dword 10

cdw11 Number <optional>
0

Command Dword 11

cdw12 Number <optional>
0

Command Dword 12

cdw13 Number <optional>
0

Command Dword 13

cdw14 Number <optional>
0

Command Dword 14

cdw15 Number <optional>
0

Command Dword 15

buffer Buffer

Data buffer

isHostToDevice Boolean

Data transfer direction

Returns:
Type
nvme.CompletionQueueEntry

(static) setCommandTrackerLog(filename)

Sets the filename where command history will be dumped.

Parameters:
Name Type Description
filename String

Tracker log file path. Relative to workspace root.

(static) shutdown()

Issues a controller shutdown.

Example
// Initiating a controller shutdown
nvme.shutdown();

// You can log the shutdown initiation for record purposes
logger.info('Controller shutdown initiated.');

(static) startWorkloadGenerator(optionsopt) → {nvme.WorkloadResult}

Generates IO workloads.

Example
// basic workload generator type
nvme.startWorkloadGenerator({
   type: "basic",
   nsid: 1,
   queueDepth: 1024,
   xferSize: 4096,
   range: { startLba: 0x1234, size: 0x5 },
   loops: 1,
   duration: 60,
   nsid: 1,
   workload: 'random',
   readPercent: 50,
   alignment: 8, // Aligns Start LBA at 4K boundary if LBA size is 512B.
   xferSize: 4096,
   range: '100%'
})

// multiRange workload generator type
nvme.startWorkloadGenerator({
   type: "multiRange",
   nsid: 1,
   queueDepth: 1024,
   xferSize: 4096,
   range: { startLba: 0x1234, size: 0x5 },
   loops: 1,
   duration: 60,
   ranges: [
     {
       nsid: 1,
       workload: 'random',
       readPercent: 100,
       alignment: 0,
       startLba: 0,
       size: 10000,
       probability: 5,
       xfers: [
         { size: 512, probability: 5},
         { size: 1024, probability: 10},
         { size: 2048, probability: 20},
         { size: 4096, probability: 65}
       ]
     },
     {
       nsid: 1,
       workload: 'sequential',
       readPercent: 0,
       alignment: 8,
       startLba: 10000,
       size: 100000,
       probability: 95,
       xfers: [
         { size: 512, probability: 50},
         { size: 1024, probability: 50}
       ]
     }
   ]
})
Parameters:
Name Type Attributes Description
options nvme.WorkloadGeneratorBasicOptions | nvme.WorkloadGeneratorMultiRangeOptions <optional>

Optional parameters.

The following parameters are common across all available workload generator types

Properties
Name Type Attributes Default Description
type String <optional>
"basic"

Type of workload generator Available type

  • basic
  • multiRange
queueDepth Number <optional>
0

Queue Depth If queueDepth is 0, then queueDepth will be the same as MQES.

duration Number <optional>
0

duration in seconds

loops Number <optional>
1

Number of loops to repeat

dataPattern Buffer <optional>
null

Customized data buffer for write commands. Must be multiple of 8 bytes.

ignoreError Array.<Object> <optional>
null

Ignored command errors during execution of WorkloadGenerator.

Properties
Name Type Description
sct Number

Status Code Type from NVMe Completion Queue Entry.

sc Number

Status Code from NVMe Completion Queue Entry.

features nvme.WorkloadGeneratorFeatures <optional>

Optional Features

Returns:
Type
nvme.WorkloadResult

(static) write(startLba, numBlocks, options) → {nvme.CompletionQueueEntry}

Sends NVM Write command.

Example
const data = Buffer.from('0102030405060708', 'hex');
const startLba = 1000;
const numBlocks = 4;

// Using default nsid and qid values
const result1 = nvme.write(startLba, numBlocks, { dataPattern: data });
logger.info(result1);

// Specifying nsid and qid values
const options = { nsid: 2, qid: 3, dataPattern: data };
const result2 = nvme.write(startLba, numBlocks, options);
logger.info(result2);

// Using only the required parameters
const startLba = 2000;
const numBlocks = 3;

const result3 = nvme.write(startLba, numBlocks);
logger.info(result3);
Parameters:
Name Type Description
startLba Number

Start LBA where the data should be written.

numBlocks Number

Number of Logical Blocks to write.

options Object

Additional configuration options.

Properties
Name Type Attributes Default Description
nsid Number <optional>
0

Namespace ID. Uses the first available namespace if nsid is 0.

qid Number <optional>
0

Queue ID. Uses the first available queue if qid is 0.

dataPattern Buffer <optional>

Data pattern to fill the LBAs. The size of dataPattern must be multiples of 8.

Returns:
  • Returns the completion queue entry after the command has been executed.
Type
nvme.CompletionQueueEntry

Type Definitions

CommandErrorHistory

Properties:
Name Type Description
sct Number

Status Code Type

sc Number

Status Code

cmd String

Command name

nsid Number

Namespace ID

startLba Number

Command Start LBA

numBlocks Number

Number of blocks

Type:
  • Object

CompletionQueueEntry

Properties:
Name Type Description
cdw Number

Command Specific Response

sqhd Number

SQ Head Pointer

sqid Number

SQ Identifier

cid Number

Command Identifier

status CompletionStatus

Completion Status

Type:
  • object

CompletionStatus

Properties:
Name Type Description
sc Number

Status Code

sct Number

Status Code Type

m Number

More

p Number

Phase Tag

dnr Number

Do Not Retry

Type:
  • object

DeviceInfo

Properties:
Name Type Description
maxXferSize Number

Max Transfer Size

maxQueueDepth Number

Max Queue Depth.

maxNamespaceId Number

Max Namespace ID.

Type:
  • Object

NamespaceInfo

Properties:
Name Type Description
isActive Boolean

Is an active namespace.

lbaSize Number

Size of LBA.

metaSize Number

Size of Metadata.

size Number

Size of the Namespace in LBAs.

Type:
  • Object

WorkloadGeneratorBasicOptions

Properties:
Name Type Attributes Description
options Object <optional>
Properties
Name Type Attributes Default Description
type String <optional>
"basic"

Type of workload generator.

Available workload generator type:

  • "basic"
  • "multiRange"
queueDepth Number <optional>
0

Queue Depth.

nsid Number <optional>
0

Namespace ID.

If nsid is 0, then the first available namespace will be used.

workload String <optional>
"sequential"

Workload access pattern.

Available patterns:

  • "sequential"
  • "random"
readPercent Number <optional>
100

Percentage of read access.

trimPercent Number <optional>
0

Percentage of trim (dataset management) access.

alignment Number <optional>
0

LBA alignment.

  • If 0, each transfer will be aligned to the transfer size.
xferSize Number <optional>
4096

Transfer size in bytes.

  • Must be multiples of 512.
  • If 0, xferSize will be the maximum tranfer size for the given NVM controller.
range String | Array.<Number> | Object <optional>
"100%"

Access range.

  • If a String value is given and if it ends with %, then the workload generator will access ranges based on percentage of the value provided.

    For example, if 70% is provided, then the workload generator will access 50% of the total available ranges.

  • If a String value is given and if it ends with k,m,g,t, then the workload generator will access ranges based on bytes of the value provided.

    For example, if 100g is provided, then the workload generator will access 100GB of the total available ranges.

  • If an Object value is given, it must contain the following propertes:

    • startLba: start LBA of an interval.
    • size: size of an interval in logical blocks.
  • If a Number[] value is given, it contains a list LBAs. If queueDepth is 0, then queueDepth will be the same as MQES.

duration Number <optional>
0

Duration in seconds.

loops Number <optional>
1

Number of loops to repeat.

dataPattern Buffer <optional>
null

Customized data buffer for write commands. Must be multiple of 8 bytes.

ignoreError Array.<Object> <optional>
null

Ignored command errors during execution of WorkloadGenerator.

ignoreError[].sct Number

Status Code Type from NVMe Completion Queue Entry.

ignoreError[].sc Number

Status Code from NVMe Completion Queue Entry.

features nvme.WorkloadGeneratorFeatures <optional>

Features

Type:
  • Object

WorkloadGeneratorFeatures

Properties:
Name Type Attributes Description
features Object <optional>
Properties
Name Type Attributes Description
powerControl Object <optional>

Injects power cycle while generating IO traffic

Properties
Name Type Attributes Default Description
enabled Boolean <optional>
false

Enables power control feature

detectionTimeoutMs Number <optional>
0

Device detection timeout after power on in milliseconds.

removalTimeoutMs Number <optional>
0

Device removal timeout after power off in milliseconds.

offHoldTimeMs Number <optional>
0

Power off hold time in milliseconds.

onHoldTimeMs Number <optional>
0

Power on hold time in milliseconds.

histogram Object <optional>

Measure command latency and returns histogram and raw data

Properties
Name Type Attributes Default Description
enabled Boolean <optional>
false

Enables command latency measurement

startUs Number <optional>
1

Histogram start in microseconds. This value must be multiples of 10, except 1.

endUs Number <optional>
100000000

Histogram end in microseconds. This value must be multiples of 10, except 1.

precisions Number <optional>
4

Histogram precision. This value must be less than 9.

rawData Boolean <optional>
false

Returns histogram raw data.

intervalStats Object <optional>

Measures performance for a given interval size

Properties
Name Type Attributes Default Description
enabled Boolean <optional>
false

Enable interval performance measurement

interval Number <optional>
1

Observation interval in seconds

delay Number <optional>
0

Observation starts after delay number of seconds

Type:
  • Object

WorkloadGeneratorMultiRangeOptions

Properties:
Name Type Attributes Description
options Object <optional>
Properties
Name Type Attributes Default Description
type String <optional>
"multiRange"

Type of workload generator.

queueDepth Number <optional>
0

Queue Depth. If queueDepth is 0, then queueDepth will be the same as MQES.

duration Number <optional>
0

Duration in seconds.

loops Number <optional>
1

Number of loops to repeat.

dataPattern Buffer <optional>
null

Customized data buffer for write commands. Must be multiple of 8 bytes.

ignoreError Array.<Object> <optional>
null

Ignored command errors during execution of WorkloadGenerator.

ignoreError[].sct Number

Status Code Type from NVMe Completion Queue Entry.

ignoreError[].sc Number

Status Code from NVMe Completion Queue Entry.

features nvme.WorkloadGeneratorFeatures <optional>

Features

ranges Array.<Object>
ranges[].nsid Number <optional>
0

Namespace ID

If nsid is 0, then the first available namespace will be used.

ranges[].workload String <optional>
"sequential"

Workload access pattern.

Available patterns:

  • "sequential"
  • "random"
ranges[].readPercent Number <optional>
100

Percentage of read commands.

ranges[].trimPercent Number <optional>
0

Percentage of trim (dataset management) commands.

ranges[].alignment Number <optional>
0

LBA alignment.

  • If 0, each transfer will be aligned to the transfer size.
ranges[].startLba Number

Start LBA of a range.

ranges[].size Number

Size of a range in logical blocks.

ranges[].probability Number

Probablity that defines how often this range will be accessed.

ranges[].xfers Array.<Object>

Data Transfers

ranges[].xfers[].size Number

Transfer size in bytes.

ranges[].xfers[].probability Number

Probability that defines how often this transfer size will be used.

Type:
  • Object

WorkloadResult

Properties:
Name Type Description
info nvme.WorkloadResultBasicInfo | nvme.WorkloadResultMultiRangeInfo

Returns the parameters passed to the workload generator.

  • info is WorkloadResultBasicInfo when "basic" is used for options.type.
  • info is WorkloadResultMultiRangeInfo when "multiRange" is used for options.type.
read nvme.WorkloadResultLatency

Latency information for read commands.

write nvme.WorkloadResultLatency

Latency information for write commands.

trim nvme.WorkloadResultLatency

Latency information for write commands.

errorHistory Array.<nvme.CommandErrorHistory>

Command errors commands.

Type:
  • Object

WorkloadResultBasicInfo

Properties:
Name Type Description
queueDepth Object

Number of maximum outstanding commands.

duration Object

Maximum execution time of the workload generator.

loops Number

Number of loops to repeat.

readPercent Number

Percentage of read commands.

trimPercent Number

Percentage of trim (dataset management) commands.

xferSize Number

Transfer size of each IO.

startLba Number

Start LBA of workload access range.

  • Not applicable when ranges were passed in Array.
size Number

Workload access range in LBAs.

  • Not applicable when ranges were passed in Array.
workload String

Workload type.

Type:
  • Object

WorkloadResultLatency

Properties:
Name Type Description
perf Object

Performance information.

Properties
Name Type Description
bandwidth Number

Throughput in Bytes/second

iops Number

IOs per Second

xfer Number

Data Transferred in Bytes

io Number

Number of IOs transferred

latency Object

Returned when histogram feature is enabled

Properties
Name Type Description
first Number

The highest latency

perc50 Number

The latency at 50% percentile

perc99 Number

The latency at 99% percentile

nines3 Number

The latency at 99.9% percentile

nines4 Number

The latency at 99.99% percentile

nines5 Number

The latency at 99.999% percentile

nines6 Number

The latency at 99.9999% percentile

nines7 Number

The latency at 99.99999% percentile

nines8 Number

The latency at 99.999999% percentile

unit String

The unit of latency

histogramRawData Object

Histogram raw data

Properties
Name Type Description
data Array.<Object>

List of histogram bins.

start Number

Beginning of a bin.

end Number

End of a bin

count Number

Counts in a bin

intervalData Array.<Object>

Interval measurement data. Returned when interval measurement is enabled.

This is a list of objects.

const result = nvme.startWorkloadGenerator({
  features: {
    intervalStats: {
      enabled: true
    }
  }
})
const data = result.read.intervalData
data.forEach((item) => {
  logger.info(`${item.throughput}B/s at ${item.sinceStart}s`)
})
Properties
Name Type Description
iops Number

IOPS

throughput Number

IO throughput in bytes/second

maxLatencyUs Number

Maximum command latency in microseconds

minLatencyUs Number

Minimum command latency in microseconds

avgLatencyUs Number

Average command latency in microseconds

totalIo Number

Total number of IOs transferred

totalXfers Number

Total IOs transferred in bytes

interval Number

Measurement inverval in seconds

sinceStart Number

The start of the interval in seconds. This is relative to the time when the 1st IO is submitted.

Type:
  • Object

WorkloadResultMultiRangeInfo

Properties:
Name Type Description
queueDepth Object

Number of maximum outstanding commands.

duration Object

Maximum execution time of the workload generator.

loops Number

Number of loops to repeat.

ranges Array.<Object>

Ranges

ranges[].startLba Number

Start LBA of a range interval.

ranges[].size Number

size of an interval in logical blocks.

ranges[].probability Number

Probability that defines how often this interval will be accesse.

ranges[].workload Number

Workload type.

ranges[].readPercent Number

Percentage of read commands.

ranges[].trimPercent Number

Percentage of trim (dataset management) commands.

ranges[].xfers Array.<Object>

Data Transfers

ranges[].xfers[].size Number

Transfer size.

ranges[].xfers[].probability Number

Probability that defines how often this transfer size will be used.

Type:
  • Object