fsstress: add io_uring test and do some fix
cover fsstress: add io_uring test and do some fix
This patchset tries to add new IO_URING test into fsstress [1/3]. And then do some changes and bug fix by the way [2/3 and 3/3].
fsstress is an important tool in xfstests to do random filesystem I/Os test, lots of test cases use it. So add IO_URING operation into fsstress will help to make lots of test cases cover IO_URING test naturally.
I'm not an IO_URING expert, so cc io-uring@ list, please feel free to tell me if you find something wrong or have any suggestions to improve the test.
Thanks,
Zorro
PATCH 1/3 fsstress: add IO_URING read and write operations
IO_URING is a new feature of curent linux kernel, add basic IO_URING read/write into fsstess to cover this kind of IO testing.
--- README | 4 +- configure.ac | 1 + include/builddefs.in | 1 + ltp/Makefile | 5 ++ ltp/fsstress.c | 139 ++++++++++++++++++++++++++++++++++++++++- m4/Makefile | 1 + m4/package_liburing.m4 | 4 ++ 7 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 m4/package_liburing.m4
README +2 -2
@@ -8,13 +8,13 @@ _______________________ sudo apt-get install xfslibs-dev uuid-dev libtool-bin \ e2fsprogs automake gcc libuuid1 quota attr libattr1-dev make \ libacl1-dev libaio-dev xfsprogs libgdbm-dev gawk fio dbench \ - uuid-runtime python sqlite3 + uuid-runtime python sqlite3 liburing-dev For Fedora, RHEL, or CentOS: yum install acl attr automake bc dbench dump e2fsprogs fio \ gawk gcc indent libtool lvm2 make psmisc quota sed \ xfsdump xfsprogs \ libacl-devel libattr-devel libaio-devel libuuid-devel \ - xfsprogs-devel btrfs-progs-devel python sqlite + xfsprogs-devel btrfs-progs-devel python sqlite liburing-devel (Older distributions may require xfsprogs-qa-devel as well.) (Note that for RHEL and CentOS, you may need the EPEL repo.) - run make
configure.ac +1 -0
@@ -61,6 +61,7 @@ AC_PACKAGE_NEED_ACLINIT_LIBACL AC_PACKAGE_WANT_GDBM AC_PACKAGE_WANT_AIO +AC_PACKAGE_WANT_URING AC_PACKAGE_WANT_DMAPI AC_PACKAGE_WANT_LINUX_FIEMAP_H AC_PACKAGE_WANT_FALLOCATE
include/builddefs.in +1 -0
@@ -61,6 +61,7 @@ RPM_VERSION = @rpm_version@ ENABLE_SHARED = @enable_shared@ HAVE_DB = @have_db@ HAVE_AIO = @have_aio@ +HAVE_URING = @have_uring@ HAVE_FALLOCATE = @have_fallocate@ HAVE_OPEN_BY_HANDLE_AT = @have_open_by_handle_at@ HAVE_DMAPI = @have_dmapi@
ltp/Makefile +5 -0
@@ -24,6 +24,11 @@ LCFLAGS += -DAIO LLDLIBS += -laio -lpthread endif +ifeq ($(HAVE_URING), true) +LCFLAGS += -DURING +LLDLIBS += -luring +endif + ifeq ($(HAVE_LIBBTRFSUTIL), true) LLDLIBS += -lbtrfsutil endif
ltp/fsstress.c +138 -1
187 lines not on this page · raw message
m4/Makefile +1 -0
@@ -14,6 +14,7 @@ LSRCFILES = \ package_dmapidev.m4 \ package_globals.m4 \ package_libcdev.m4 \ + package_liburing.m4 \ package_ncurses.m4 \ package_pthread.m4 \ package_ssldev.m4 \
m4/package_liburing.m4 new file +4 -0
@@ -0,0 +1,4 @@ +AC_DEFUN([AC_PACKAGE_WANT_URING], + [ AC_CHECK_HEADERS(liburing.h, [ have_uring=true ], [ have_uring=false ]) + AC_SUBST(have_uring) + ])
Signature · 1 line
2.20.1
PATCH 2/3 fsstress: reduce the number of events when io_setup
In reply to Zorro LangThe original number(128) of aio events for io_setup is a little big. When try to run lots of fsstress processes(e.g. -p 1000) always hit io_setup EAGAIN error, due to the nr_events exceeds the limit of available events. So reduce it from 128 to 64, to make more fsstress processes can do AIO test.
--- ltp/fsstress.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ltp/fsstress.c +4 -3
@@ -28,6 +28,7 @@#endif #ifdef AIO #include <libaio.h> +#define AIO_ENTRIES 64io_context_t io_ctx;#endif #ifdef URING
@@ -699,8 +700,8 @@ int main(int argc, char **argv) } procid = i;#ifdef AIO -if (io_setup (128 , &io_ctx) !=0 ) { -fprintf (stderr,"io_setup failed" ); +if (io_setup (AIO_ENTRIES , &io_ctx) !=0 ) { +fprintf (stderr,"io_setup failed\n" );exit (1 ); }#endif
@@ -714,7 +715,7 @@ int main(int argc, char **argv)doproc ();#ifdef AIO if (io_destroy (io_ctx) !=0 ) { -fprintf (stderr,"io_destroy failed" ); +fprintf (stderr,"io_destroy failed\n" );return 1 ; }#endif
Signature · 1 line
2.20.1
PATCH 3/3 fsstress: fix memory leak in do_aio_rw
In reply to Zorro LangIf io_submit or io_getevents fails, the do_aio_rw() won't free the "buf" and cause memory leak.
--- ltp/fsstress.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
ltp/fsstress.c +16 -15
@@ -2099,8 +2099,7 @@ do_aio_rw(int opno, long r, int flags)if (!get_fname (FT_REGFILE , r, &f,NULL ,NULL , &v)) {if (v)printf ("%d/%d: do_aio_rw - no filename\n" , procid, opno); -free_pathname (&f); -return ; + goto aio_out3; } fd =open_path (&f, flags|O_DIRECT ); e = fd <0 ? errno :0 ;
@@ -2109,16 +2108,13 @@ do_aio_rw(int opno, long r, int flags)if (v)printf ("%d/%d: do_aio_rw - open %s failed %d\n" , procid, opno, f.path, e); -free_pathname (&f); -return ; + goto aio_out3; }if (fstat64 (fd, &stb) <0 ) {if (v)printf ("%d/%d: do_aio_rw - fstat64 %s failed %d\n" , procid, opno, f.path, errno); -free_pathname (&f); -close (fd); -return ; + goto aio_out2; }inode_info (st,sizeof (st), &stb, v);if (!iswrite && stb.st_size ==0 ) {
@@ -2150,6 +2146,12 @@ do_aio_rw(int opno, long r, int flags)else if (len > diob.d_maxiosz) len = diob.d_maxiosz; buf =memalign (diob.d_mem, len); +if (!buf) { +if (v) +printf ("%d/%d: do_aio_rw - memalign failed\n" , + procid, opno); + goto aio_out2; + }if (iswrite) { off = (off64_t)(lr %MIN (stb.st_size + (1024 *1024 ),MAXFSIZE ));
@@ -2166,27 +2168,26 @@ do_aio_rw(int opno, long r, int flags)if (v)printf ("%d/%d: %s - io_submit failed %d\n" , procid, opno, iswrite ?"awrite" :"aread" , e); -free_pathname (&f); -close (fd); - return; + goto aio_out1; }if ((e =io_getevents (io_ctx,1 ,1 , &event,NULL )) !=1 ) {if (v)printf ("%d/%d: %s - io_getevents failed %d\n" , procid, opno, iswrite ?"awrite" :"aread" , e); -free_pathname (&f); -close (fd); -return ; + goto aio_out1; } e = event.res != len ? event.res2 :0 ; -free (buf);if (v)printf ("%d/%d: %s %s%s [%lld,%d] %d\n" , procid, opno, iswrite ?"awrite" :"aread" , f.path, st, (long long )off, (int )len, e); -free_pathname (&f); + aio_out1: +free (buf); + aio_out2:close (fd); + aio_out3: +free_pathname (&f); }#endif
Signature · 1 line
2.20.1