Skip to content

target cleanup and zc support #121

Merged
ming1 merged 14 commits intomasterfrom
cleanup_and_zc
Mar 29, 2025
Merged

target cleanup and zc support #121
ming1 merged 14 commits intomasterfrom
cleanup_and_zc

Conversation

@ming1
Copy link
Copy Markdown
Collaborator

@ming1 ming1 commented Mar 28, 2025

No description provided.

ming1 added 9 commits March 26, 2025 09:14
Now we can reply on ublksrv_is_recovering(), and needn't to pass this
parameter any more.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
This variable will be cleared in __nbd_handle_io_bg(), so no need to
do it in nbd_handle_send_bg().

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
We have nbd_queue_data->chained_send_ios already, so no necessary to
maintain another variable just for showing if this current send chain
is active.

It can be replaced with checking against `nbd_queue_data->chained_send_ios`
and `nbd_queue_data->chain_active`.

The point is that `->chain_active` is more readable and easier to
maintain.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
It is more readable to call nbd_handle_send_bg() and
nbd_handle_recv_bg() directly.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
It is just fine to use io_uring_prep_sendmsg*() to send message with
single vector.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Not necessary to add the two flag for deciding if the io_uring OP
belongs to normal UBLK_IO_* io command, and we have carried the exact
ublk op code in ->userdata.

So remove the two.

So far:

	UBLK_IO_OP_* < 0x20

	_IO_NR(UBLK_U_IO_*) > 0x20: register io buffer, unregister io buffer

	UBLK_USER_COPY_READ:  0x80
	UBLK_USER_COPY_WRITE: 0x81

Add is_ublk_io_cmd() helper for checking if the io_uring OP belongs to
normal ublk io command.

In this way, the target data field in ->user_data can be reserved for
future usage, such as the ublk stripe usage:

https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/ublk/stripe.c#n148

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Move -EAGAIN handling out of ublksrv_tgt_process_cqe(), and the handling
has to be done after the whole sqe series are done.

Meantime improve error handling for loop, any failure in this sqe series
will fail the loop io command.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
@ming1 ming1 force-pushed the cleanup_and_zc branch 2 times, most recently from 51f5501 to b79a944 Compare March 29, 2025 00:39
ming1 added 5 commits March 29, 2025 05:28
- add two uapi register/unregister buffer cmd code

- add uapi dma alignment parameter, which is usually needed,
otherwise zc may fail, so it is one soft dependency.

- register buffer table

- pass zero buffer address and not allocate user buffer for zc

ublk zero copy requires linux kernel v6.15.

Reviewed-by: Ronnie Sahlberg <rsahlberg@whamcloud.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add helpers for enabling zero copy.

Add zero copy command line.

By default disable zero copy for the three targets.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
ublk zero copy feature is introduced in linux kernel v6.15, so try to
add the support on null target first.

Reviewed-by: Ronnie Sahlberg <rsahlberg@whamcloud.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Enable zero copy support, and set default dma alignment as 511 which
should cover all hardware.

In the future, segment limit can be setup by aligning with backing file
device for reaching good perf.

Reviewed-by: Ronnie Sahlberg <rsahlberg@whamcloud.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
@ming1 ming1 merged commit 31dd5e1 into master Mar 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant