public inbox for [email protected]
 help / color / mirror / Atom feed
From: Brian Foster <[email protected]>
To: Zorro Lang <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH v4 4/5] fsx: introduce fsx_rw to combine aio_rw with general read and write
Date: Tue, 8 Sep 2020 14:35:31 -0400	[thread overview]
Message-ID: <20200908183531.GD737175@bfoster> (raw)
In-Reply-To: <[email protected]>

On Mon, Sep 07, 2020 at 01:55:12AM +0800, Zorro Lang wrote:
> The fsx contains different read and write operations, especially the
> AIO and general IO read/write. The fsx chooses one kind of read/write
> from AIO and general IO to run. To make the logic clear, use a common
> fsx_rw() function to swith between these two kinds of read/write.
> 
> Signed-off-by: Zorro Lang <[email protected]>
> ---

Reviewed-by: Brian Foster <[email protected]>

>  ltp/fsx.c | 32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index 7c76655a..92f506ba 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -181,16 +181,11 @@ int	mark_nr = 0;
>  int page_size;
>  int page_mask;
>  int mmap_mask;
> -#ifdef AIO
> -int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset);
> +int fsx_rw(int rw, int fd, char *buf, unsigned len, unsigned offset);
>  #define READ 0
>  #define WRITE 1
> -#define fsxread(a,b,c,d)	aio_rw(READ, a,b,c,d)
> -#define fsxwrite(a,b,c,d)	aio_rw(WRITE, a,b,c,d)
> -#else
> -#define fsxread(a,b,c,d)	read(a,b,c)
> -#define fsxwrite(a,b,c,d)	write(a,b,c)
> -#endif
> +#define fsxread(a,b,c,d)	fsx_rw(READ, a,b,c,d)
> +#define fsxwrite(a,b,c,d)	fsx_rw(WRITE, a,b,c,d)
>  
>  const char *replayops = NULL;
>  const char *recordops = NULL;
> @@ -2347,7 +2342,8 @@ getnum(char *s, char **e)
>  io_context_t	io_ctx;
>  struct iocb 	iocb;
>  
> -int aio_setup()
> +int
> +aio_setup()
>  {
>  	int ret;
>  	ret = io_queue_init(QSZ, &io_ctx);
> @@ -2360,7 +2356,7 @@ int aio_setup()
>  }
>  
>  int
> -__aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
> +aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
>  {
>  	struct io_event event;
>  	static struct timespec ts;
> @@ -2425,13 +2421,21 @@ out_error:
>  	errno = -ret;
>  	return -1;
>  }
> +#else
> +aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
> +{
> +	fprintf(stderr, "io_rw: need AIO support!\n");
> +	exit(111);
> +}
> +#endif
>  
> -int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
> +int
> +fsx_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
>  {
>  	int ret;
>  
>  	if (aio) {
> -		ret = __aio_rw(rw, fd, buf, len, offset);
> +		ret = aio_rw(rw, fd, buf, len, offset);
>  	} else {
>  		if (rw == READ)
>  			ret = read(fd, buf, len);
> @@ -2441,8 +2445,6 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
>  	return ret;
>  }
>  
> -#endif
> -
>  #define test_fallocate(mode) __test_fallocate(mode, #mode)
>  
>  int
> @@ -2602,7 +2604,7 @@ main(int argc, char **argv)
>  			do_fsync = 1;
>  			break;
>  		case 'A':
> -		        aio = 1;
> +			aio = 1;
>  			break;
>  		case 'D':
>  			debugstart = getnum(optarg, &endp);
> -- 
> 2.20.1
> 


  reply	other threads:[~2020-09-08 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 17:55 [PATCH v4 0/5] fsstress,fsx: add io_uring test and do some fix Zorro Lang
2020-09-06 17:55 ` [PATCH v4 1/5] fsstress: add IO_URING read and write operations Zorro Lang
2020-09-08 18:34   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 2/5] fsstress: reduce the number of events when io_setup Zorro Lang
2020-09-08 18:34   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 3/5] fsstress: fix memory leak in do_aio_rw Zorro Lang
2020-09-08 18:35   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 4/5] fsx: introduce fsx_rw to combine aio_rw with general read and write Zorro Lang
2020-09-08 18:35   ` Brian Foster [this message]
2020-09-06 17:55 ` [PATCH v4 5/5] fsx: add IO_URING test Zorro Lang
2020-09-08 18:36   ` Brian Foster
2020-09-09  3:58     ` 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=20200908183531.GD737175@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