Linux平台技术分享OpenChannelSSD_QemuLinux学习|Gentoo/Arch/FreeBSD

[Qemu OpenChannelSSD] Hello worl

2016-12-15  本文已影响792人  Quasars
sudo qemu-system-x86_64 --enable-kvm -m 4G -smp 2 -hda ./VMs/vm1.raw -hdb ./VMs/vm1_1.raw -net nic -net tap \
-drive file=./VMs/blknvme.1,if=none,id=blknvme.1 \
-device nvme,drive=blknvme.1,serial=deadbeef,namespaces=1,lver=1,nlbaf=5,lba_index=3,mdts=10
serial=deadbeef,
namespaces=1,  # namespaces=<int> : Namespaces to make out of the backing storage, Default:1
lver=1,        # lver=<int> : version of the LightNVM standard to use, Default:1
nlbaf=5,       # nlbaf=<int> : Number of logical block formats, Default:1
lba_index=3,   # lba_index=<int> : Default namespace block format index, Default:0
mdts=10        # mdts=<int> : Maximum data transfer size, Default:5
work@vm1:~$ sudo nvme lnvm list
Number of devices: 1
Device          Block manager   Version
nvme0n1         none            (0,0,0)
work@vm1:~$ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb       8:16   0    30G  0 disk 
└─sdb1    8:17   0    30G  0 part /home/work/mnt/1
sr0      11:0    1  1024M  0 rom  
sda       8:0    0    20G  0 disk 
├─sda2    8:2    0   1.4G  0 part [SWAP]
└─sda1    8:1    0  18.6G  0 part /
nvme0n1 259:0    0    16G  0 disk 
work@vm1:~$ sudo nvme lnvm init -d nvme0n1
work@vm1:~$ sudo nvme lnvm list
Number of devices: 1
Device          Block manager   Version
nvme0n1         gennvm          (0,1,0)
#include <stdio.h>
#include <liblightnvm.h>
int main(int argc, char **argv)
{
    NVM_DEV dev = nvm_dev_open("/dev/nvme0n1");
    if (!dev) {
        perror("nvm_dev_open");
        return 1;
}
nvm_dev_pr(dev);
nvm_dev_close(dev);
return 0;
 gcc hello_nvme.c -llightnvm -o hello_nvme
work@vm1:~/mnt/1/OpenChannelSSD/src/hello_nvme$ sudo ./hello_nvme 
dev { path(/dev/nvme0n1), name(nvme0n1), fd(3) }
dev-geo {
 nchannels(1), nluns(1), nplanes(1),
 nblocks(16352), npages(256), nsectors(1),
 page_nbytes(4096), sector_nbytes(4096), meta_nbytes(16),
 tbytes(17146314752b:16352Mb),
 vpg_nbytes(4096b:4Kb),
 vblk_nbytes(1048576b:1Mb)
}
dev-lba_map {
 channel_nbytes(17146314752)
 lun_nbytes(17146314752)
 plane_nbytes(4096)
 block_nbytes(1048576)
 page_nbytes(4096)
 sector_nbytes(4096)
}
dev-fmt {
 ch_ofz(20), ch_len(0),
 lun_ofz(20), lun_len(0),
 pl_ofz(20), pl_len(0),
 blk_ofz(0), blk_len(12),
 pg_ofz(12), pg_len(8),
 sec_ofz(20), sec_len(0)
}
Paste_Image.png
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/liblightnvm.so: undefined reference to `GOMP_parallel@GOMP_4.0'

看一下我的GCC版本

work@vm1:~/mnt/1/OpenChannelSSD/src/hello_nvme$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

查一下这个GOMP是个所谓的多线程框架,gcc自带的,并且版本关系如下:

From GCC 4.2.0, OpenMP 2.5 is fully supported.
From GCC 4.4.0, OpenMP 3.0 is fully supported.
From GCC 4.7.0, OpenMP 3.1 is fully supported.
In GCC 4.9.0, OpenMP 4.0 is supported for C and C++, but not Fortran.
From GCC 4.9.1, OpenMP 4.0 is fully supported.

所以这里应该是gcc的版本不够.按照这个threadUbuntu 14.04 LTS 下升级 gcc 到 gcc-4.9、gcc-5 版本
装个gcc-4.9.
简要步骤如下:

1 sudo add-apt-repository ppa:ubuntu-toolchain-r/test
2 sudo apt-get update
3 sudo apt-get upgrade
4 sudo apt-get install gcc-4.9 g++-4.9
work@vm1:~/mnt/1/OpenChannelSSD/src/hello_nvme$ gcc-4.9 --version
gcc-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

再编译果然就OK.

Linux Kernel Support (https://github.com/OpenChannelSSD/linux) Implements support for Open-Channel SSDs in the kernel. It is the core of identifying, managing, and using the Open-Channel SSDs.

liblightnvm Library (https://github.com/OpenChannelSSD/liblightnvm)A library that abstracts the underlying "raw" Open-Channel SSD device and provides abstractions such as append only, bad block management, etc.

General documentation (https://github.com/OpenChannelSSD/documentation)The documentation that is exposed through readthedocs.org

liblightnvm documentation (http://lightnvm.io/liblightnvm)The liblightnvm documentation

LightNVM Conditioning Tool (https://github.com/OpenChannelSSD/lnvm) Provides the lnvm-tool
cli management tool for verifying and conditioning Open-Channel SSDs.

LightNVM Test Tools (https://github.com/OpenChannelSSD/lightnvm-hw)Various tools to test kernel and target implementations.

QEMU with NVMe Open-Channel Support (https://github.com/OpenChannelSSD/qemu-nvme)Implements support for exposing a virtual open-channel SSD. Very useful for development.

上一篇下一篇

猜你喜欢

热点阅读