ublk-org / ublksrv

ublk: userspace block device driver
MIT License
149 stars 53 forks source link

runtime error need help when trying to build ublk server in ubuntu kernel 6.1.9 #43

Closed gaowayne closed 1 year ago

gaowayne commented 1 year ago

here is build error on ubuntu kernel 6.19. I also build and install latest liburing.

but when I try to add loop null, it shows below error, could you please shed light?

wayne@wayne-VirtualBox:~/wayne/ubdsrv$ ls
aclocal.m4               compile       config.log     configure.ac  demo_event.c             demo_null-demo_null.o  install-sh  ltmain.sh    Makefile.in  README.rst    tgt_null.cpp   ublksrv_tgt.cpp
autom4te.cache           config.guess  config.status  COPYING       demo_event-demo_event.o  depcomp                lib         m4           missing      stamp-h1      ublk           ublk-tgt_loop.o
build_with_liburing_src  config.h      config.sub     COPYING.LGPL  demo_null                doc                    libtool     Makefile     nbd          tests         ublksrv.pc     ublk-tgt_null.o
ci                       config.h.in   configure      demo_event    demo_null.c              include                LICENSE     Makefile.am  qcow2        tgt_loop.cpp  ublksrv.pc.in  ublk-ublksrv_tgt.o
wayne@wayne-VirtualBox:~/wayne/ubdsrv$ sudo ./ublk -h
unknown command: -h
ublk add -t {null|loop|qcow2|nbd} -n DEV_ID -q NR_HW_QUEUES -d QUEUE_DEPTH -u URING_COMP -g NEED_GET_DATA -r USER_RECOVERY -i USER_RECOVERY_REISSUE
           loop: -f backing_file [--buffered_io]
            default is direct IO to backing file
           qcow2: -f backing_file
           nbd: --host=$HOST [--port=$PORT] | --unix=$UNIX_PATH
ublk del -n DEV_ID [-a | --all]
ublk list [-n DEV_ID]
wayne@wayne-VirtualBox:~/wayne/ubdsrv$ sudo ./ublk add -t null
can't get sqe ret -22
can't add dev -1, ret -22
wayne@wayne-VirtualBox:~/wayne/ubdsrv$ 
ming1 commented 1 year ago

Hello,

Can you disable selinux(setenforce 0) before running ublk?

Thanks,

ming1 commented 1 year ago

Also the build failure is caused because your liburing doesn't support net send zc, and it has been addressed by commit ba83b49

gaowayne commented 1 year ago

Hello,

Can you disable selinux(setenforce 0) before running ublk?

Thanks,

thank you so much. I will try disable selinux. build issue is already fixed when I install latest liburing. :)

ming1 commented 1 year ago

Hello, Can you disable selinux(setenforce 0) before running ublk? Thanks,

thank you so much. I will try disable selinux. build issue is already fixed when I install latest liburing. :)

ublksrv requires liburing 2.2+(2.2 is included), but net send zc is added to liburing 2.3.

commit ba83b49 has fixed this issue, so if you build the latest ublksrv against liburing 2.2, it still works, but nbd send zc won't be supported.

gaowayne commented 1 year ago

@ming1 I already fix the setenforce 0, actually it is never enabled in my VM. and I also get liburing tag 2.2, build and install. then I try to add null device with below, still have the same error.

wayne@wayne-VirtualBox:~$ setenforce 0
setenforce: SELinux is disabled

root@wayne-VirtualBox:/home/wayne/wayne/ubdsrv# ./ublk add -t null
can't get sqe ret -22
can't add dev -1, ret -22
ming1 commented 1 year ago

@ming1 I already fix the setenforce 0, actually it is never enabled in my VM. and I also get liburing tag 2.2, build and install. then I try to add null device with below, still have the same error.

wayne@wayne-VirtualBox:~$ setenforce 0
setenforce: SELinux is disabled

root@wayne-VirtualBox:/home/wayne/wayne/ubdsrv# ./ublk add -t null
can't get sqe ret -22
can't add dev -1, ret -22

Can you share how to get the ubuntu kernel 6.1.9? Is it one cloud image? I will try to see if I can reproduce it.

The 1st failure message just means that there isn't sqe from the ring, not get idea how it is triggered, and not see such issue before.

thanks,

ming1 commented 1 year ago

BTW, follows the whole build step

1) if liburing is built from source, build & install liburing; other install liburing2.2+ directly:

2) build ublksrv

gaowayne commented 1 year ago

@ming1 I already fix the setenforce 0, actually it is never enabled in my VM. and I also get liburing tag 2.2, build and install. then I try to add null device with below, still have the same error.

wayne@wayne-VirtualBox:~$ setenforce 0
setenforce: SELinux is disabled

root@wayne-VirtualBox:/home/wayne/wayne/ubdsrv# ./ublk add -t null
can't get sqe ret -22
can't add dev -1, ret -22

Can you share how to get the ubuntu kernel 6.1.9? Is it one cloud image? I will try to see if I can reproduce it.

The 1st failure message just means that there isn't sqe from the ring, not get idea how it is triggered, and not see such issue before.

thanks,

hello buddy, I follow this link guide to get 6.1.9 https://dev.to/amarjargal/testing-ublk-on-ubuntu-2204-9pe

gaowayne commented 1 year ago
  1. if liburing is built from source, build & install liburing; other install liburing2.2+ directly:
  • cd liburing
  • ./configure&& ./make && make install

actually I follow this steps already. for liburing, I build the source code(tag 2.2) and install it.

ming1 commented 1 year ago
  1. if liburing is built from source, build & install liburing; other install liburing2.2+ directly:
  • cd liburing
  • ./configure&& ./make && make install

actually I follow this steps already. for liburing, I build the source code(tag 2.2) and install it.

OK, can you run some liburing tests and see if io_uring works? such as:

cd liburing ./test/nop ./examples/io_uring-test ./examples/io_uring-test

gaowayne commented 1 year ago
  • ./configure&& ./make && make install

thank you so much for help. my io_uring-test works fine. I do not have test/nop anyway.

root@wayne-VirtualBox:/home/wayne/wayne/liburing/test# ./nop
-bash: ./nop: No such file or directory
root@wayne-VirtualBox:/home/wayne/wayne/liburing/test# cd ..
root@wayne-VirtualBox:/home/wayne/wayne/liburing# ./examples/io_uring-test ./examples/io_uring-test
Submitted=4, completed=4, bytes=16384
root@wayne-VirtualBox:/home/wayne/wayne/liburing# 
ming1 commented 1 year ago

Can you build the raw ublk test code in the following link and see if ublk device can be created?

https://lore.kernel.org/linux-block/78E62777-98A7-4D19-9608-D8A3412D9800@intel.com/

Suppose you name it as raw_ublk.c, then run the following steps and see if /dev/ublkc0 can be created.

[root@ktest-36 ublksrv]# gcc -g -o raw_ublk raw_ublk.c -luring [root@ktest-36 ublksrv]# ./raw_ublk [root@ktest-36 ublksrv]# ls -l /dev/ublk* crw-------. 1 root root 236, 0 Feb 5 07:48 /dev/ublkc0 crw-rw-rw-. 1 root root 10, 123 Feb 5 07:48 /dev/ublk-control

gaowayne commented 1 year ago

I follow the instruction to build this raw ublk test, it works fine as below

the only thing I hacked is that when I build raw_ublk.c, gcc cannot find ublk_cmd.h automatically, I copy this file from kernel source tree in my local, then in my code, I point it to this local .h file, now it works.

I did not see any build error when I build ubdsrv

root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# ls -l /dev/ublk*
crw------- 1 root root 236,   0  2月  5 17:28 /dev/ublkc0
crw------- 1 root root  10, 119  2月  5 17:13 /dev/ublk-control
root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# 
ming1 commented 1 year ago

I follow the instruction to build this raw ublk test, it works fine as below

the only thing I hacked is that when I build raw_ublk.c, gcc cannot find ublk_cmd.h automatically, I copy this file from kernel source tree in my local, then in my code, I point it to this local .h file, now it works.

I did not see any build error when I build ubdsrv

root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# ls -l /dev/ublk*
crw------- 1 root root 236,   0  2月  5 17:28 /dev/ublkc0
crw------- 1 root root  10, 119  2月  5 17:13 /dev/ublk-control
root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# 

That is weird.

I just tried to build ublksrv on ubuntu 22.10, and can't reproduce the issue.

What is your ubuntu distribution release?

Thanks,

gaowayne commented 1 year ago

I follow the instruction to build this raw ublk test, it works fine as below the only thing I hacked is that when I build raw_ublk.c, gcc cannot find ublk_cmd.h automatically, I copy this file from kernel source tree in my local, then in my code, I point it to this local .h file, now it works. I did not see any build error when I build ubdsrv

root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# ls -l /dev/ublk*
crw------- 1 root root 236,   0  2月  5 17:28 /dev/ublkc0
crw------- 1 root root  10, 119  2月  5 17:13 /dev/ublk-control
root@wayne-VirtualBox:/home/wayne/wayne/linux-6.1.9/include/uapi/linux# 

That is weird.

I just tried to build ublksrv on ubuntu 22.10, and can't reproduce the issue.

What is your ubuntu distribution release?

Thanks,

I switch root account and build install for both liburing and ubdsrv, now it works from my side now. :) thank you so much!~

root@wayne-VirtualBox:/home/wayne/wayne/ubdsrv# ./ublk add -t null
dev id 1: nr_hw_queues 1 queue_depth 128 block size 512 dev_capacity 524288000
    max rq size 524288 daemon pid 8690 flags 0x2 state LIVE
    queue 0: tid 8691 affinity(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 )
    target {"dev_size":268435456000,"name":"null","type":0}
root@wayne-VirtualBox:/home/wayne/wayne/ubdsrv# 
gaowayne commented 1 year ago

@ming1 buddy, I found that I failed to update my custom build 6.1.9 headers into system, could you please share me how to make it for sure happen? that is why I cannot build raw_ublk.c naturally.

ming1 commented 1 year ago

make -j$(nproc) all sudo make modules_install sudo make install

If you have trouble to install headers, maybe you can try to run the last two steps in root session(sudo su and not use sudo).

gaowayne commented 1 year ago

make -j$(nproc) all sudo make modules_install sudo make install

If you have trouble to install headers, maybe you can try to run the last two steps in root session(sudo su and not use sudo).

thank you so much man!~ I used run these steps. I found it fix things if I just manually copy that header file into below location. /usr/include/linux 👍

ming1 commented 1 year ago

OK, looks it is one build environment issue, close it now. If turns out it is one ublksrv problem, feel free to re-open this ticket.