support ZONE_RESET_ALL in liburing
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.
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 4 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.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
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
Re: [PATCH 2/5] man: fixups for io_uring_prep_cmd_discard.3
Quoted 5 lines · Christoph Hellwig
Mention the ioctl this is modelled after instead of the
io_uringcmd used to implement io_uring_prep_cmd_discard.3, and drop an incorrect plural for page cache.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 3/5 liburiung: 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.14;
Signature · 1 line
2.53.0
Re: [PATCH 3/5] liburiung: add io_uring_prep_cmd_zone_reset
Quoted 3 lines · Christoph Hellwig
Add a helper for
io_uringzone_reset_allcommands.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 3/5] liburiung: add io_uring_prep_cmd_zone_reset
In reply to Christoph HellwigIn commit message, "liburiung" -> "liburing"?
Quoted 82 lines · Christoph Hellwig
Add a helper for
io_uringzone_reset_allcommands.Signed-off-by Christoph Hellwig <[email protected]>--- 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 EOFsrc/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 +0
-0
src/liburing-ffi.map LIBURING_2.15 { · line 282
Quoted 8 lines
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.14;
Does this 2.14 not need to be incremented to 2.15?
Best,
Caleb
PATCH 4/5 man: add io_uring_prep_cmd_zone_reset_all.3 man page
In reply to Christoph HellwigAdd doccumentation 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 "Jul 14, 2026" "liburing-2.8" "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
Re: [PATCH 4/5] man: add io_uring_prep_cmd_zone_reset_all.3 man page
Quoted 1 line · Christoph Hellwig
Add doccumentation for the new zone reset all
io_uringcmd.
s/doccumentation/documentation
Quoted 2 lines
Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 4/5] man: add io_uring_prep_cmd_zone_reset_all.3 man page
In reply to Christoph HellwigQuoted 14 lines · Christoph Hellwig
Add doccumentation for the new zone reset all
io_uringcmd.Signed-off-by Christoph Hellwig <[email protected]>--- 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.3man/io_uring_prep_cmd_zone_reset_all.3 new file +0
-0
man/io_uring_prep_cmd_zone_reset_all.3 line 5
Quoted 5 lines
man/io_uring_prep_cmd_zone_reset_all.3 new file +5
-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 "Jul 14, 2026" "liburing-2.8" "liburing Manual"
liburing-2.16
Quoted 52 lines
man/io_uring_prep_cmd_zone_reset_all.3 new file +49
-0+.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
Signature · 1 line
Gabriel Krisman Bertazi
PATCH 5/5 test: add zone_reset_all command test
In reply to Christoph HellwigBasic sanity checking for the simply 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
Re: [PATCH 5/5] test: add zone_reset_all command test
Quoted 1 line · Christoph Hellwig
Basic sanity checking for the simply
zone_reset_allcommand, mostly
s/simply/simple
Quoted 3 lines
taken from the discard test.
Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research