Re: [PATCH 2/3] fsstress: bypass io_uring testing if io_uring_queue_init returns EPERM

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



Zorro Lang <zlang@xxxxxxxxxx> writes:

> I found the io_uring testing still fails as:
>   io_uring_queue_init failed
> even if kernel supports io_uring feature.
>
> That because of the /proc/sys/kernel/io_uring_disabled isn't 0.
>
> Different value means:
>   0 All processes can create io_uring instances as normal.
>   1 io_uring creation is disabled (io_uring_setup() will fail with
>     -EPERM) for unprivileged processes not in the io_uring_group
>     group. Existing io_uring instances can still be used.  See the
>     documentation for io_uring_group for more information.
>   2 io_uring creation is disabled for all processes. io_uring_setup()
>     always fails with -EPERM. Existing io_uring instances can still
>     be used.
>
> So besides the CONFIG_IO_URING kernel config, there's another switch
> can on or off the io_uring supporting. And the "2" or "1" might be
> the default on some systems.
>
> On this situation the io_uring_queue_init returns -EPERM, so I change
> the fsstress to ignore io_uring testing if io_uring_queue_init returns
> -ENOSYS or -EPERM. And print different verbose message for debug.
>
> Signed-off-by: Zorro Lang <zlang@xxxxxxxxxx>
> ---
>  ltp/fsstress.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> index 482395c4..9c75f27b 100644
> --- a/ltp/fsstress.c
> +++ b/ltp/fsstress.c
> @@ -762,12 +762,23 @@ int main(int argc, char **argv)
>  #endif
>  #ifdef URING
>  			have_io_uring = true;
> -			/* If ENOSYS, just ignore uring, other errors are fatal. */
> +			/*
> +			 * If ENOSYS, just ignore uring, due to kernel doesn't support it.
> +			 * If EPERM, might due to sysctl kernel.io_uring_disabled isn't 0,
> +			 *           or some selinux policies, etc.
> +			 * Other errors are fatal.
> +			 */
>  			if ((c = io_uring_queue_init(URING_ENTRIES, &ring, 0)) != 0) {
>  				if (c == -ENOSYS) {
>  					have_io_uring = false;
> +					if (verbose)
> +						printf("io_uring isn't supported by kernel\n");
> +				} else if (c == -EPERM) {
> +					have_io_uring = false;
> +					if (verbose)
> +						printf("io_uring isn't allowed, check io_uring_disabled sysctl or selinux policy\n");
>  				} else {
> -					fprintf(stderr, "io_uring_queue_init failed\n");
> +					fprintf(stderr, "io_uring_queue_init failed, errno=%d\n", c);

I think you want to use -c here, right?

Other than that:

Reviewed-by: Jeff Moyer <jmoyer@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux