spdk基础使用
准备环境
- 为nvme设备/dev/nvme0n1创建文件系统
mkfs.ext4 /dev/nvme0n1
不能直接挂载块设备文件,要先格式化文件系统
2. 挂载
mount /dev/nvme0n1 /home/msk/nvmeext4
3.spdk不能操作FS格式化后的设备,只能操作裸块设备,即/dev/nvme0n1
4.spdk初始化
sudo ./scripts/setup.sh
5.生成nvme设备,输出为json文件
./scripts/gen_nvme.sh --json-with-subsystems [> ./build/examples/hello_bdev.json]
6.为nvme设备创建vhost
./build/bin/vhost -c ./build/examples/hello_bdev.json
使用之前创建的json文件
7.使用spdkcli连接vhost
./scripts/spdkcli.py
hello_world
1.启动nvmf_tgt use the -m to specify how many cores you want to use.
./nvmf -m 0xf -r /var/tmp/spdk.sock
2.配置nvmf_tgt属性,这样才能被我们使用 use the RPC cmd to config the nvmf target.
You can use the -h to get how many RPC cmd you can use.
./scripts/rpc.py -h
Next, You should use the RPC cmd to setup nvmf target.
./scripts/rpc.py nvmf_create_transport -t RDMA -g nvmf_example
./scripts/rpc.py nvmf_create_subsystem -t nvmf_example -s SPDK00000000000001 -a -m 32 nqn.2016-06.io.spdk:cnode1
./scripts/rpc.py bdev_malloc_create -b Malloc1 128 512
./scripts/rpc.py nvmf_subsystem_add_ns -t nvmf_example nqn.2016-06.io.spdk:cnode1 Malloc1
./scripts/rpc.py nvmf_subsystem_add_listener -t rdma -f Ipv4 -a 192.168.200.22 -s 4420 -p nvmf_example nqn.2016-06.io.spdk:cnode1
3.启动hello_word客户端,连接已经配置好的tgt
./build/examples/hello_world -r "trtype:tcp adrfam:IPv4 traddr:192.168.200.22 trsvcid:4420 subnqn:nqn.2016-06.io.spdk:cnode1"