support ZONE_RESET_ALL in liburing v3
Hi Jens,
this is the liburing support for the just submitted ZONE_RESET_ALL uring cmd support. Also a few fixup for the discard support that stood model.
Changes since v2:
- fix inheritance in the shared library map file
Changes since v1:
- misc spelling fixes
PATCH 1/5 configure: shorten the message for the discard command
The current message is pretty long, drop the redundant io_uring. This aligns it with the soon to be added zone_reset_all message.
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -467,7 +467,7 @@ EOF if compile_prog "" "" "discard command"; then discard_cmd="yes" fi -print_config "io_uring discard command support" "$discard_cmd" +print_config "discard command support" "$discard_cmd" ########################################## # Check idtype_t support
Signature · 1 line
2.53.0
Re: [PATCH 1/5] configure: shorten the message for the discard command
Quoted 2 lines · Christoph Hellwig
The current message is pretty long, drop the redundant
io_uring. This aligns it with the soon to be addedzone_reset_allmessage.
Applied, thanks!
[1/5] configure: shorten the message for the discard command
commit: 16390826c1ffe9e989c4b8e922d8aeec30cbe030
[2/5] man: fixups for io_uring_prep_cmd_discard.3
commit: 96980531859b99fc21feda893c49750879e8c6c1
[3/5] liburing: add io_uring_prep_cmd_zone_reset
commit: fae20287f440d59b12a1626ef9d7dc15f7764933
[4/5] man: add io_uring_prep_cmd_zone_reset_all.3 man page
commit: 9d179918fcd060494c680f42eba525e9c656e766
[5/5] test: add zone_reset_all command test
commit: 6bfe0f9180f95d23b0c7e9724d2d0c84972141a4Best regards,
Signature · 1 line
Jens Axboe
PATCH 2/5 man: fixups for io_uring_prep_cmd_discard.3
In reply to Christoph HellwigMention the ioctl this is modelled after instead of the io_uring cmd used to implement io_uring_prep_cmd_discard.3, and drop an incorrect plural for page cache.
--- man/io_uring_prep_cmd_discard.3 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
man/io_uring_prep_cmd_discard.3 +4 -4
@@ -26,14 +26,14 @@ to start discarding at the specified .IR offset . -The command is an asynchronous equivalent of -.B BLOCK_URING_CMD_DISCARD +The command is an asynchronous equivalent of the +.B BLKDISCARD ioctl with a few differences. It allows multiple parallel discards, and it does not exclude concurrent writes and reads. As a result, it may lead to races for the data on the disk, if the application has IO inflight for the same ranges that the discard operates on. It's the user's responsibility to account for that. -Furthermore, only best efforts are done to invalidate page caches. The user has -to make sure that no other inflight requests are modifying or reading the +Furthermore, only best efforts are done to invalidate the page cache. The user +has to make sure that no other inflight requests are modifying or reading the range(s). If that is the case, it might result in stale page cache and data inconsistencies.
Signature · 1 line
2.53.0
PATCH 3/5 liburing: add io_uring_prep_cmd_zone_reset
In reply to Christoph HellwigAdd a helper for io_uring zone_reset_all commands.
--- configure | 31 +++++++++++++++++++++++++++++++ src/include/liburing.h | 7 +++++++ src/liburing-ffi.map | 5 +++++ 3 files changed, 43 insertions(+)
configure +31 -0
@@ -469,6 +469,21 @@ if compile_prog "" "" "discard command"; then fi print_config "discard command support" "$discard_cmd" +########################################## +# Check block zone_reset_all cmd support +zone_reset_all_cmd="no" +cat > $TMPC << EOF +#include <linux/blkdev.h> +int main(void) +{ + return BLOCK_URING_CMD_ZONE_RESET_ALL; +} +EOF +if compile_prog "" "" "zone_reset_all command"; then + zone_reset_all_cmd="yes" +fi +print_config "zone_reset_all command support" "$zone_reset_all_cmd" + ########################################## # Check idtype_t support has_idtype_t="no"
@@ -797,6 +812,22 @@ else cat >> $compat_h << EOF EOF fi +if test "$zone_reset_all_cmd" != "yes"; then +cat >> $compat_h << EOF + +#include <linux/ioctl.h> + +#ifndef BLOCK_URING_CMD_ZONE_RESET_ALL +#define BLOCK_URING_CMD_ZONE_RESET_ALL _IO(0x12, 1) +#endif + +EOF +else cat >> $compat_h << EOF +#include <linux/blkdev.h> + +EOF +fi + cat >> $compat_h << EOF #endif EOF
src/include/liburing.h +7 -0
@@ -1685,6 +1685,13 @@ IOURINGINLINE void io_uring_prep_cmd_discard(struct io_uring_sqe *sqe, sqe->addr3 = nbytes; } +IOURINGINLINE void io_uring_prep_cmd_zone_reset_all(struct io_uring_sqe *sqe, +int fd) +LIBURING_NOEXCEPT +{ +io_uring_prep_uring_cmd (sqe,BLOCK_URING_CMD_ZONE_RESET_ALL , fd); +} + IOURINGINLINE void io_uring_prep_pipe(struct io_uring_sqe *sqe, int *fds,int pipe_flags) {
src/liburing-ffi.map +5 -0
@@ -275,3 +275,8 @@ LIBURING_2.15 { io_uring_register_zcrx_ctrl; io_uring_register_query; } LIBURING_2.14; + +LIBURING_2.16 { + global: + io_uring_prep_cmd_zone_reset_all; +} LIBURING_2.15;
Signature · 1 line
2.53.0
PATCH 4/5 man: add io_uring_prep_cmd_zone_reset_all.3 man page
In reply to Christoph HellwigAdd documentation for the new zone reset all io_uring cmd.
--- man/io_uring_prep_cmd_zone_reset_all.3 | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 man/io_uring_prep_cmd_zone_reset_all.3
man/io_uring_prep_cmd_zone_reset_all.3 new file +54 -0
@@ -0,0 +1,54 @@ +.\" Copyright (C) 2026 Christoph Hellwig <[email protected]> +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_prep_cmd_zone_reset_all 3 "Aug 11, 2026" "liburing-2.16" "liburing Manual" +.SH NAME +io_uring_prep_cmd_zone_reset_all \- prepare a zone_reset_all command +.SH SYNOPSIS +.nf +.B #include <liburing.h> +.PP +.BI "void io_uring_prep_cmd_zone_reset_all(struct io_uring_sqe *" sqe ", int " fd ");" +.fi +.SH DESCRIPTION +The +.BR io_uring_prep_cmd_zone_reset_all (3) +function prepares a zone_reset_all command request. The submission queue entry +.I sqe +is setup to reset all sequential write required zones on the block device +pointed to by +.IR fd . + +This command does not synchronize against concurrent file operations, including +but not limited to reads, write, ioctls and other uring_cmds and only performs +a best effort invalidation of the page cache for the device. The user has +to make sure that no other in-flight requests are modifying or reading the +range(s). If that is the case, it might result in stale page cache and data +inconsistencies. + +Available since Linux 7.TBD. + +.SH RETURN VALUE +None +.SH ERRORS +The CQE +.I res +field will contain the result of the operation. On success, this field will be +set to +.B 0 . +On error, a negative error value is returned. Note that where synchronous +system calls will return +.B -1 +on failure and set +.I errno +to the actual error value, io_uring never uses +.IR errno . +Instead it returns the negated +.I errno +directly in the CQE +.I res +field. +.SH SEE ALSO +.BR io_uring_get_sqe (3), +.BR io_uring_submit (3),
Signature · 1 line
2.53.0
PATCH 5/5 test: add zone_reset_all command test
In reply to Christoph HellwigBasic sanity checking for the zone_reset_all command, mostly taken from the discard test.
--- test/Makefile | 1 + test/cmd-zone-reset-all.c | 164 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 test/cmd-zone-reset-all.c
test/Makefile +1 -0
@@ -90,6 +90,7 @@ test_srcs := \ connect-rep.c \ coredump.c \ cmd-discard.c \ + cmd-zone-reset-all.c \ cq-full.c \ cq-overflow.c \ cq-peek-batch.c \
test/cmd-zone-reset-all.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
2.53.0