0003-patch-check-kernel-support-for-io-uring.patch
text/x-patch
Filename: 0003-patch-check-kernel-support-for-io-uring.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch 0003
| File | + | − |
|---|---|---|
| src/backend/storage/aio/aio.c | 37 | 0 |
| src/backend/utils/misc/guc_parameters.dat | 1 | 0 |
| src/include/utils/guc_hooks.h | 2 | 0 |
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 */