Help requested in handle_event/ublksrv_complete_io()

6 views
Skip to first unread message

ronnie sahlberg

unread,
Apr 10, 2025, 12:07:30 AMApr 10
to ub...@googlegroups.com
Any help appreciated.

I tried to build a NFS target using the async API in libnfs.
I have put the code so far in https://github.com/ublk-org/ublksrv/pull/123

It is incomplete and only implement OP_READ so far but my struggle right now is
when I apply the second patch in this wip series, moving the call to ublksrv_complete_io()
to happen inside the .handle_vent methot is causes the target to hand and I can not get a good backtrace from gdb.

Ming,  would you be able to review the PR and see if you can see what I do wrong?


(libiscsi will soon have a multithreading api almost identical to libnfs, so once we get this PR working and I finish the multithreading support in libiscsi it should be fairly trivial to build a ublk.iscsi target too.)


regards
ronnie sahlberg

ronnie sahlberg

unread,
Apr 10, 2025, 12:19:12 AMApr 10
to ublk
Please ignore.
Somehow I lost the ublksrv_queue_send_event() call. It works now.


Ming Lei

unread,
Apr 11, 2025, 10:03:15 AMApr 11
to ronnie sahlberg, ublk
On Thu, Apr 10, 2025 at 12:19 PM ronnie sahlberg
<ronnies...@gmail.com> wrote:
>
> Please ignore.
> Somehow I lost the ublksrv_queue_send_event() call. It works now.

It looks not work in my side, and the following change is needed:

diff --git a/targets/ublk.nfs.cpp b/targets/ublk.nfs.cpp
index 84d6f4f..656a061 100644
--- a/targets/ublk.nfs.cpp
+++ b/targets/ublk.nfs.cpp
@@ -136,13 +136,16 @@ static int nfs_handle_io_async(const struct
ublksrv_queue *q,
return nfs_tgt_write(q, iod, data->tag);
case UBLK_IO_OP_DISCARD:
ublk_err("UBLK_IO_OP_DISCARD is not supported");
- return -EINVAL;
+ ublksrv_complete_io(q, data->tag, -ENOTSUP);
+ break;
case UBLK_IO_OP_FLUSH:
ublk_err("UBLK_IO_OP_FLUSH is not supported");
+ ublksrv_complete_io(q, data->tag, 0);
break;
case UBLK_IO_OP_WRITE_ZEROES:
ublk_err("UBLK_IO_OP_WRITE_ZEROS is not supported");
- return -EINVAL;
+ ublksrv_complete_io(q, data->tag, -ENOTSUP);
+ break;
default:
return -EINVAL;
}




Thanks,
Ming Lei

Ming Lei

unread,
Apr 11, 2025, 10:07:06 AMApr 11
to ronnie sahlberg, ublk
On Fri, Apr 11, 2025 at 10:02 PM Ming Lei <tom.l...@gmail.com> wrote:
>
> On Thu, Apr 10, 2025 at 12:19 PM ronnie sahlberg
> <ronnies...@gmail.com> wrote:
> >
> > Please ignore.
> > Somehow I lost the ublksrv_queue_send_event() call. It works now.
>
> It looks not work in my side, and the following change is needed:
>
> diff --git a/targets/ublk.nfs.cpp b/targets/ublk.nfs.cpp
> index 84d6f4f..656a061 100644
> --- a/targets/ublk.nfs.cpp
> +++ b/targets/ublk.nfs.cpp
> @@ -136,13 +136,16 @@ static int nfs_handle_io_async(const struct
> ublksrv_queue *q,
> return nfs_tgt_write(q, iod, data->tag);
> case UBLK_IO_OP_DISCARD:
> ublk_err("UBLK_IO_OP_DISCARD is not supported");
> - return -EINVAL;
> + ublksrv_complete_io(q, data->tag, -ENOTSUP);
> + break;
> case UBLK_IO_OP_FLUSH:
> ublk_err("UBLK_IO_OP_FLUSH is not supported");
> + ublksrv_complete_io(q, data->tag, 0);

Forget to mention, here you have to support FLUSH command because
UBLK_ATTR_VOLATILE_CACHE is setup.

If FLUSH can't be supported, UBLK_ATTR_VOLATILE_CACHE has to be cleared.




Thanks,
Ming Lei
Reply all
Reply to author
Forward
0 new messages