From 6fa14b995d65be5d4fd423664f4d339568c3c846 Mon Sep 17 00:00:00 2001 From: chenh Date: Tue, 8 Apr 2014 13:02:26 -0400 Subject: [PATCH] glusterfs api fadvise support --- Makefile | 3 +++ configure | 24 +++++++++++++++++++++++- engines/glusterfs.c | 13 +++++++++++++ engines/glusterfs_async.c | 8 ++++++-- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 499f8e49..c80a64a3 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,9 @@ ifdef CONFIG_GFAPI SOURCE += engines/glusterfs.c SOURCE += engines/glusterfs_sync.c SOURCE += engines/glusterfs_async.c + ifdef CONFIG_GF_FADVISE + CFLAGS += "-DGFAPI_USE_FADVISE" + endif endif ifeq ($(CONFIG_TARGET_OS), Linux) diff --git a/configure b/configure index 3a4a37a5..063ccab4 100755 --- a/configure +++ b/configure @@ -1181,8 +1181,27 @@ if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then LIBS="-lgfapi -lglusterfs $LIBS" gfapi="yes" fi -echo "Gluster API engine $gfapi" + echo "Gluster API engine $gfapi" +########################################## +# check for gfapi fadvise support +gf_fadvise="no" +cat > $TMPC << EOF +#include + +int main(int argc, char **argv) +{ + struct glfs_fd *fd; + int ret = glfs_fadvise(fd, 0, 0, 1); + + return 0; +} +EOF + +if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then + gf_fadvise="yes" +fi +echo "Gluster API use fadvise $gf_fadvise" ############################################################################# @@ -1314,6 +1333,9 @@ fi if test "$gfapi" = "yes" ; then output_sym "CONFIG_GFAPI" fi +if test "$gf_fadvise" = "yes" ; then + output_sym "CONFIG_GF_FADVISE" +fi echo "LIBS+=$LIBS" >> $config_host_mak echo "CFLAGS+=$CFLAGS" >> $config_host_mak diff --git a/engines/glusterfs.c b/engines/glusterfs.c index e9132b79..230274af 100644 --- a/engines/glusterfs.c +++ b/engines/glusterfs.c @@ -223,6 +223,19 @@ int fio_gf_open_file(struct thread_data *td, struct fio_file *f) } } } +#if defined(GFAPI_USE_FADVISE) + { + int r = 0; + if (td_random(td)){ + r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_RANDOM); + }else{ + r = glfs_fadvise(g->fd, 0, f->real_file_size, POSIX_FADV_SEQUENTIAL); + } + if (r){ + dprint(FD_FILE, "fio %p fadvise %s status %d\n", g->fs, f->file_name, r); + } + } +#endif dprint(FD_FILE, "fio %p created %s\n", g->fs, f->file_name); f->fd = -1; f->shadow_fd = -1; diff --git a/engines/glusterfs_async.c b/engines/glusterfs_async.c index e2c76dc2..bea95497 100644 --- a/engines/glusterfs_async.c +++ b/engines/glusterfs_async.c @@ -10,6 +10,7 @@ struct fio_gf_iou { struct io_u *io_u; int io_complete; }; +static ulong cb_count = 0, issued = 0; static struct io_u *fio_gf_event(struct thread_data *td, int event) { @@ -46,7 +47,7 @@ static int fio_gf_getevents(struct thread_data *td, unsigned int min, } if (events < min) - usleep(10); + usleep(100); else break; @@ -66,6 +67,7 @@ static void fio_gf_io_u_free(struct thread_data *td, struct io_u *io_u) io_u->engine_data = NULL; free(io); } + fprintf(stderr, "issued %lu finished %lu\n", issued, cb_count); } static int fio_gf_io_u_init(struct thread_data *td, struct io_u *io_u) @@ -95,6 +97,7 @@ static void gf_async_cb(glfs_fd_t *fd, ssize_t ret, void *data) dprint(FD_IO, "%s ret %lu\n", __FUNCTION__, ret); iou->io_complete = 1; + cb_count ++; } static int fio_gf_async_queue(struct thread_data fio_unused *td, struct io_u *io_u) @@ -125,7 +128,7 @@ static int fio_gf_async_queue(struct thread_data fio_unused *td, struct io_u *io io_u->error = r; goto failed; } - + issued ++; return FIO_Q_QUEUED; failed: @@ -145,6 +148,7 @@ int fio_gf_async_setup(struct thread_data *td) if (r){ return r; } + td->o.use_thread = 1; g = td->io_ops->data; g->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *)); if (!g->aio_events){ -- 2.25.1