OK I was wrong: I can use io_uring_get_probe() if postgres has been
built with liburing flag.
So I have replaced uname() call by io_uring_get_probe() call and I have
modified the error messages: Linux kernel version is neither directly
used nor mentioned.
Le 14/01/2026 à 11:18, Pierre a écrit :
Le 14/01/2026 à 08:31, Steven Niu a écrit :
From: Andreas Karlsson <[email protected]>
Sent: Wednesday, January 14, 2026 15:27
To: Steven Niu <[email protected]>; Pierre
<[email protected]>; [email protected]
<[email protected]>
Subject: Re: [PATCH] check kernel version for io_method
On 1/14/26 8:22 AM, Steven Niu wrote:
I agree that you are correct for now. But in future, the IoMethod
may have new member. Then we have to process it.
How about change to like this:
+ #else
+ if (*newval == IOMETHOD_IO_URING)
+ {
+ GUC_check_errdetail("io_uring not enabled.");
+ return false;
+ }
No, that would be incorrect. It would not even compile.
IOMETHOD_IO_URING is not even defined if we do not compile with liburing
enabled. You can try it out yourself by compiling PostgreSQL without
io_uring support and then try to enable it. You will get an error and
that code will never be reached.
Andreas
________________________________________
Yes, you are definitely correct.
I'd like to withdwar my proposal.
Hello,
I have modified message in case io_uring is not enabled when building
PG. But currently I cannot test it, GUC parameter is rejected in
earlier steps:
pg_ctl start
waiting for server to start....2026-01-14 09:35:37.046 GMT [16336]
LOG: invalid value for parameter "io_method": "io_uring"
2026-01-14 09:35:37.046 GMT [16336] HINT: Available values: sync,
worker.
2026-01-14 10:35:37.047 CET [16336] FATAL: configuration file
"/home/pierre/pgdata/postgresql.conf" contains errors
stopped waiting
pg_ctl: could not start server
I don't know how to test io_uring features in code because if io_uring
is not enabled at compilation time, I don't think it is possible to
compile code calling io_uring_get_probe_ring() or
io_uring_opcode_supported() ?
Thanks.
diff --git a/src/backend/storage/aio/aio.c b/src/backend/storage/aio/aio.c
index d2c9cd6f20a..6fb5d3d5dee 100644
--- a/src/backend/storage/aio/aio.c
+++ b/src/backend/storage/aio/aio.c
@@ -50,6 +50,9 @@
#include "utils/resowner.h"
#include "utils/wait_event_types.h"
+#ifdef IOMETHOD_IO_URING_ENABLED
+#include <liburing.h>
+#endif
static inline void pgaio_io_update_state(PgAioHandle *ioh, PgAioHandleState new_state);
static void pgaio_io_reclaim(PgAioHandle *ioh);
@@ -1346,3 +1349,37 @@ check_io_max_concurrency(int *newval, void **extra, GucSource source)
return true;
}
+
+
+bool
+check_io_method(int *newval, void **extra, GucSource source)
+{
+#ifdef IOMETHOD_IO_URING_ENABLED
+ if (*newval == IOMETHOD_IO_URING)
+ {
+ struct io_uring_probe *probe = io_uring_get_probe();
+
+ if (probe == NULL)
+ {
+ GUC_check_errdetail("liburing probe is not supported by this operating system kernel: setting io_method to io_uring is not possible.");
+ return false;
+ }
+ }
+
+ return true;
+#else
+ if (*newval == IOMETHOD_WORKER || *newval == IOMETHOD_SYNC)
+ {
+ /*
+ * OK
+ */
+ }
+ else
+ {
+ GUC_check_errdetail("liburing has not been enabled at build time for this executable: setting io_method to io_uring is not possible.");
+ return false;
+ }
+
+ return true;
+#endif
+}
diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat
index 7c60b125564..2246af79808 100644
--- a/src/backend/utils/misc/guc_parameters.dat
+++ b/src/backend/utils/misc/guc_parameters.dat
@@ -1339,6 +1339,7 @@
boot_val => 'DEFAULT_IO_METHOD',
options => 'io_method_options',
assign_hook => 'assign_io_method',
+ check_hook => 'check_io_method',
},
{ name => 'io_workers', type => 'int', context => 'PGC_SIGHUP', group => 'RESOURCES_IO',
diff --git a/src/include/utils/guc_hooks.h b/src/include/utils/guc_hooks.h
index f723668da9e..1c33dff4b55 100644
--- a/src/include/utils/guc_hooks.h
+++ b/src/include/utils/guc_hooks.h
@@ -176,4 +176,6 @@ extern bool check_synchronized_standby_slots(char **newval, void **extra,
GucSource source);
extern void assign_synchronized_standby_slots(const char *newval, void *extra);
+extern bool check_io_method(int *newval, void **extra, GucSource source);
+
#endif /* GUC_HOOKS_H */