SPDK官方文档Introduction/Getting Started

Posted xasz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SPDK官方文档Introduction/Getting Started相关的知识,希望对你有一定的参考价值。

Getting Started

Getting the Source Code

git clone https://github.com/spdk/spdk
cd spdk
git submodule update --init
-------------------------------------------------------

获取源码

git clone https://github.com/spdk/spdk
cd spdk
git submodule update --init

 

Installing Prerequisites

The scripts/pkgdep.sh script will automatically install the bare minimum dependencies required to build SPDK. Use --help to see information on installing dependencies for optional components.

sudo scripts/pkgdep.sh

Option –all will install all dependencies needed by SPDK features.

sudo scripts/pkgdep.sh --all
--------------------------------------------------------

安装依赖

脚本scripts/pkgdep.sh自动安装SPDK的最小依赖.使用--help查看安装依赖的可选组件信息。

sudo scripts/pkgdep.sh

选项–all将会安装SPDK特性的所有依赖

 

Building

Linux:

./configure
make

FreeBSD: Note: Make sure you have the matching kernel source in /usr/src/

./configure
gmake

There are a number of options available for the configure script, which can be viewed by running

./configure --help

Note that not all features are enabled by default. For example, RDMA support (and hence NVMe over Fabrics) is not enabled by default. You can enable it by doing the following:

./configure --with-rdma
make
-------------------------------------------------------
构建

Linux:

./configure
make

FreeBSD: 确保你有匹配的内核源码在/usr/src/。

./configure
gmake

运行过程中将会看到一些可用的配置脚本选项。

./configure --help

注意不是所有特性在默认情况下可用。如RDMA(NVMe over Fabrics)默认形况不可用,可以通过以下方式使其可用:

./configure --with-rdma
make

 

Running the Unit Tests

It‘s always a good idea to confirm your build worked by running the unit tests.

./test/unit/unittest.sh

You will see several error messages when running the unit tests, but they are part of the test suite. The final message at the end of the script indicates success or failure.

-------------------------------------------------------

运行单元用例

通过运行单元用例确认你的构建结果的工作情况是个不错的想法。

./test/unit/unittest.sh

当运行单元用例时你将会看到一些错误信息,但是这些都是测试套的一部分。在脚本最后的信息说明执行成功或失败。

 

Running the Example Applications

Before running an SPDK application, some hugepages must be allocated and any NVMe and I/OAT devices must be unbound from the native kernel drivers. SPDK includes a script to automate this process on both Linux and FreeBSD. This script should be run as root. It only needs to be run once on the system.

sudo scripts/setup.sh

To rebind devices back to the kernel, you can run

sudo scripts/setup.sh reset

By default, the script allocates 2048MB of hugepages. To change this number, specify HUGEMEM (in MB) as follows:

sudo HUGEMEM=4096 scripts/setup.sh

On Linux machines HUGEMEM will be rounded up to system-default huge page size boundary.

All available params can be viewed by running

scripts/setup.sh help

Example code is located in the examples directory. The examples are compiled automatically as part of the build process. Simply call any of the examples with no arguments to see the help output. If your system has its IOMMU enabled you can run the examples as your regular user. If it doesn‘t, you‘ll need to run as a privileged user (root).

A good example to start with is examples/nvme/identify/identify, which prints out information about all of the NVMe devices on your system.

Larger, more fully functional applications are available in the app directory. This includes the iSCSI and NVMe-oF target.

-------------------------------------------------------

运行示例程序

在运行SPDK应用之前一些大页必须要设置,一些NVMe或I/OAT设备必须从内核驱动解绑。SPDK有脚本会自动完成这个操作在Linux和FreeBSD。这个脚本必须使用root运行,值用在系统中运行一次。

sudo scripts/setup.sh

从新绑定回设备,可以这样运行

sudo scripts/setup.sh reset

默认情况,脚本配置2048MB的大页。要修改这个值,设置HUGEMEM (单位MB)如下:

sudo HUGEMEM=4096 scripts/setup.sh

在Linux机器上HUGEMEM将被设置位系统默认大页上边界。

通过以下操作可看到所有可用参数

scripts/setup.sh help

示例代码在示例目录下,示例在构建程序时被自动编译。不使用参数的调用任意实例程序将会看到帮助信息。如果你的系统IOMMU可用你可以通过常规用户运行样例,如果没有,你需要使用root运行。

使用样例examples/nvme/identify/identify将会打印你的系统中所有的NVMe设备信息。

更大更全功能的应用在app目录下,包括iSCSI target和NVMe-oF target。

以上是关于SPDK官方文档Introduction/Getting Started的主要内容,如果未能解决你的问题,请参考以下文章

[转]spdk线程模型 spdk_thread

[SPDK/NVMe源代码分析]001 - SPDK/NVMe概述

您如何读取 SPDK 内部 NVME 设备上的封装温度?

spdk dpdk编译动态库( shared library )

[SPDK/NVMe存储技术分析]005 - DPDK概述

文章汇总(包括NVMe SPDK vSAN Ceph xfs等)