Re: [PATCH] check kernel version for io_method

From: Steven Niu <niushiji(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, Pierre <pierre(dot)forstmann(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] check kernel version for io_method
Date: 2026-01-14 07:22:35
Message-ID: MN2PR15MB302195F72D8A5F65328B91CCA78FA@MN2PR15MB3021.namprd15.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Andreas Karlsson <andreas(at)proxel(dot)se>
Sent: Wednesday, January 14, 2026 11:09
To: Steven Niu <niushiji(at)gmail(dot)com>; Pierre <pierre(dot)forstmann(at)gmail(dot)com>; pgsql-hackers(at)lists(dot)postgresql(dot)org <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] check kernel version for io_method

On 1/14/26 3:31 AM, Steven Niu wrote:
> BTW, the error message in the following code block is wrong as it locates in branch that IO_URING is not enabled.
>
> #else
> +     if (*newval == IOMETHOD_WORKER || *newval == IOMETHOD_SYNC)
> +     {
> +             /*
> +              * OK
> +              */
> +     }
> +     else
> +     {
> +             GUC_check_errdetail("io_uring requires Linux kernel 5.6 or later.");
> +             return false;
> +     }

That code is unreachable so it should just be deleted. Look at the enum.

/* Enum for io_method GUC. */
typedef enum IoMethod
{
        IOMETHOD_SYNC = 0,
        IOMETHOD_WORKER,
#ifdef IOMETHOD_IO_URING_ENABLED
        IOMETHOD_IO_URING,
#endif
}                       IoMethod;

Andreas

________________________________________

Hi, Andreas,

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;
+     }

Thanks,
Steven

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2026-01-14 07:27:07 Re: [PATCH] check kernel version for io_method
Previous Message Andreas Karlsson 2026-01-14 07:13:17 Re: Remove redundant assignment in CreateWorkExprContext