mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fsx: introduce fsx_rw to combine aio_rw with general read and write
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 <zlang@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user