X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fsyslet-rw.c;h=15e4c2578fe9ee978af4f4a1847ecf571871718e;hb=6035e7d6d1ed462176402615da37d4f987588c16;hp=49bbc712c86a013765e33d0504f758a232667df5;hpb=db6defc77508f5bf217f0a6768d13426eee21119;p=fio.git diff --git a/engines/syslet-rw.c b/engines/syslet-rw.c index 49bbc712..15e4c257 100644 --- a/engines/syslet-rw.c +++ b/engines/syslet-rw.c @@ -14,8 +14,7 @@ #include #include "../fio.h" -#include "../indirect.h" -#include "../syslet.h" +#include "../lib/fls.h" #ifdef FIO_HAVE_SYSLET @@ -75,9 +74,7 @@ static void fio_syslet_wait_for_events(struct thread_data *td) { struct syslet_data *sd = td->io_ops->data; struct syslet_ring *ring = sd->ring; - unsigned int events; - events = 0; do { unsigned int kh = ring->kernel_head; int ret; @@ -89,9 +86,8 @@ static void fio_syslet_wait_for_events(struct thread_data *td) unsigned int nr = kh - ring->user_tail; fio_syslet_add_events(td, nr); - events += nr; ring->user_tail = kh; - continue; + break; } /* @@ -99,25 +95,23 @@ static void fio_syslet_wait_for_events(struct thread_data *td) */ ret = syscall(__NR_syslet_ring_wait, ring, ring->user_tail); assert(!ret); - } while (!events); + } while (1); } -static int fio_syslet_getevents(struct thread_data *td, int min, - int fio_unused max, +static int fio_syslet_getevents(struct thread_data *td, unsigned int min, + unsigned int fio_unused max, struct timespec fio_unused *t) { struct syslet_data *sd = td->io_ops->data; long ret; - do { - /* - * do we have enough immediate completions? - */ - if (sd->nr_events >= (unsigned int) min) - break; - + /* + * While we have less events than requested, block waiting for them + * (if we have to, there may already be more completed events ready + * for us - see fio_syslet_wait_for_events() + */ + while (sd->nr_events < min) fio_syslet_wait_for_events(td); - } while (1); ret = sd->nr_events; sd->nr_events = 0; @@ -137,6 +131,12 @@ static void fio_syslet_prep_sync(struct fio_file *f, FILL_IN(*regs, __NR_fsync, (long) f->fd); } +static void fio_syslet_prep_datasync(struct fio_file *f, + struct indirect_registers *regs) +{ + FILL_IN(*regs, __NR_fdatasync, (long) f->fd); +} + static void fio_syslet_prep_rw(struct io_u *io_u, struct fio_file *f, struct indirect_registers *regs) { @@ -160,6 +160,8 @@ static void fio_syslet_prep(struct io_u *io_u, struct indirect_registers *regs) if (io_u->ddir == DDIR_SYNC) fio_syslet_prep_sync(f, regs); + else if (io_u->ddir == DDIR_DATASYNC) + fio_syslet_prep_datasync(f, regs); else fio_syslet_prep_rw(io_u, f, regs); } @@ -227,9 +229,7 @@ static void fio_syslet_cleanup(struct thread_data *td) if (sd) { free(sd->events); free(sd->ring); - free(sd->stack); free(sd); - td->io_ops->data = NULL; } } @@ -249,14 +249,8 @@ static int fio_syslet_init(struct thread_data *td) * The ring needs to be a power-of-2, so round it up if we have to */ ring_nr = td->o.iodepth; - if (ring_nr & (ring_nr - 1)) { - int bits = 1; - - while (ring_nr >>= 1) - bits++; - - ring_nr = 1 << bits; - } + if (ring_nr & (ring_nr - 1)) + ring_nr = 1 << __fls(ring_nr); ring_size = sizeof(struct syslet_ring) + ring_nr * sizeof(struct syslet_completion); @@ -298,6 +292,7 @@ static struct ioengine_ops ioengine = { .cleanup = fio_syslet_cleanup, .open_file = generic_open_file, .close_file = generic_close_file, + .get_file_size = generic_get_file_size, }; #else /* FIO_HAVE_SYSLET */ @@ -309,7 +304,7 @@ static struct ioengine_ops ioengine = { */ static int fio_syslet_init(struct thread_data fio_unused *td) { - fprintf(stderr, "fio: syslet not available\n"); + log_err("fio: syslet not available\n"); return 1; }