From: Brian Foster <[email protected]>
To: Zorro Lang <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH 1/3] src/feature: add IO_URING feature checking
Date: Fri, 2 Oct 2020 14:19:47 -0400 [thread overview]
Message-ID: <20201002181947.GC4708@bfoster> (raw)
In-Reply-To: <[email protected]>
On Thu, Sep 17, 2020 at 01:14:41AM +0800, Zorro Lang wrote:
> IO_URING is a new feature for GNU/Linux system, if someone case of
> xfstests tests this feature, better to check if current system
> supports it, or need _notrun.
>
> Signed-off-by: Zorro Lang <[email protected]>
> ---
Reviewed-by: Brian Foster <[email protected]>
> src/Makefile | 4 ++++
> src/feature.c | 41 ++++++++++++++++++++++++++++++++++++++---
> 2 files changed, 42 insertions(+), 3 deletions(-)
>
> diff --git a/src/Makefile b/src/Makefile
> index 643c1916..f1422c5c 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -65,6 +65,10 @@ SUBDIRS += aio-dio-regress
> LLDLIBS += -laio
> endif
>
> +ifeq ($(HAVE_URING), true)
> +LLDLIBS += -luring
> +endif
> +
> CFILES = $(TARGETS:=.c)
> LDIRT = $(TARGETS) fssum
>
> diff --git a/src/feature.c b/src/feature.c
> index a7eb7595..df550cf6 100644
> --- a/src/feature.c
> +++ b/src/feature.c
> @@ -19,6 +19,7 @@
> *
> * Test for machine features
> * -A test whether AIO syscalls are available
> + * -R test whether IO_URING syscalls are available
> * -o report a number of online cpus
> * -s report pagesize
> * -w report bits per long
> @@ -39,6 +40,10 @@
> #include <libaio.h>
> #endif
>
> +#ifdef HAVE_LIBURING_H
> +#include <liburing.h>
> +#endif
> +
> #ifndef USRQUOTA
> #define USRQUOTA 0
> #endif
> @@ -59,7 +64,7 @@ usage(void)
> fprintf(stderr, "Usage: feature [-v] -<q|u|g|p|U|G|P> <filesystem>\n");
> fprintf(stderr, " feature [-v] -c <file>\n");
> fprintf(stderr, " feature [-v] -t <file>\n");
> - fprintf(stderr, " feature -A | -o | -s | -w\n");
> + fprintf(stderr, " feature -A | -R | -o | -s | -w\n");
> exit(1);
> }
>
> @@ -215,6 +220,29 @@ check_aio_support(void)
> #endif
> }
>
> +static int
> +check_uring_support(void)
> +{
> +#ifdef HAVE_LIBURING_H
> + struct io_uring ring;
> + int err;
> +
> + err = io_uring_queue_init(1, &ring, 0);
> + if (err == 0)
> + return 0;
> +
> + if (err == -ENOSYS) /* CONFIG_IO_URING=n */
> + return 1;
> +
> + fprintf(stderr, "unexpected error from io_uring_queue_init(): %s\n",
> + strerror(-err));
> + return 2;
> +#else
> + /* liburing is unavailable, assume IO_URING is unsupported */
> + return 1;
> +#endif
> +}
> +
>
> int
> main(int argc, char **argv)
> @@ -228,6 +256,7 @@ main(int argc, char **argv)
> int pflag = 0;
> int Pflag = 0;
> int qflag = 0;
> + int Rflag = 0;
> int sflag = 0;
> int uflag = 0;
> int Uflag = 0;
> @@ -235,7 +264,7 @@ main(int argc, char **argv)
> int oflag = 0;
> char *fs = NULL;
>
> - while ((c = getopt(argc, argv, "ActgGopPqsuUvw")) != EOF) {
> + while ((c = getopt(argc, argv, "ActgGopPqRsuUvw")) != EOF) {
> switch (c) {
> case 'A':
> Aflag++;
> @@ -264,6 +293,9 @@ main(int argc, char **argv)
> case 'q':
> qflag++;
> break;
> + case 'R':
> + Rflag++;
> + break;
> case 's':
> sflag++;
> break;
> @@ -289,7 +321,7 @@ main(int argc, char **argv)
> if (optind != argc-1) /* need a device */
> usage();
> fs = argv[argc-1];
> - } else if (Aflag || wflag || sflag || oflag) {
> + } else if (Aflag || Rflag || wflag || sflag || oflag) {
> if (optind != argc)
> usage();
> } else
> @@ -317,6 +349,9 @@ main(int argc, char **argv)
> if (Aflag)
> return(check_aio_support());
>
> + if (Rflag)
> + return(check_uring_support());
> +
> if (sflag) {
> printf("%d\n", getpagesize());
> exit(0);
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-10-02 18:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 17:14 [PATCH 0/3] xfstests: add IO_URING test cases Zorro Lang
2020-09-16 17:14 ` [PATCH 1/3] src/feature: add IO_URING feature checking Zorro Lang
2020-10-02 18:19 ` Brian Foster [this message]
2020-09-16 17:14 ` [PATCH 2/3] generic: fsx IO_URING soak tests Zorro Lang
2020-10-02 18:20 ` Brian Foster
2020-09-16 17:14 ` [PATCH 3/3] generic: IO_URING direct IO fsx test Zorro Lang
2020-10-02 18:20 ` Brian Foster
2020-10-05 16:45 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2020-09-16 13:11 [PATCH 0/3] xfstests: new io_uring " Zorro Lang
2020-09-16 13:11 ` [PATCH 1/3] src/feature: add IO_URING feature checking Zorro Lang
2020-09-16 12:30 [PATCH 0/3] xfstests: new io_uring fsx test Zorro Lang
2020-09-16 12:30 ` [PATCH 1/3] src/feature: add IO_URING feature checking Zorro Lang
2020-09-16 12:23 [PATCH 0/3] " Zorro Lang
2020-09-16 12:23 ` [PATCH 1/3] " Zorro Lang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201002181947.GC4708@bfoster \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox