X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fsolarisaio.c;h=21e95935b20bdc387a41f5c176fd806ff3c8f504;hb=f2d6de5d997b039cebac9c34912871baa5e12d49;hp=b519fc54339b0ddde7fb3192db3b6afda9d9d64c;hpb=556e831d2b6e788fd48f724047d22ebb29676d42;p=fio.git diff --git a/engines/solarisaio.c b/engines/solarisaio.c index b519fc54..21e95935 100644 --- a/engines/solarisaio.c +++ b/engines/solarisaio.c @@ -10,8 +10,6 @@ #include "../fio.h" -#ifdef FIO_HAVE_SOLARISAIO - #include struct solarisaio_data { @@ -30,7 +28,7 @@ static int fio_solarisaio_cancel(struct thread_data fio_unused *td, static int fio_solarisaio_prep(struct thread_data fio_unused *td, struct io_u *io_u) { - struct solarisaio_data *sd = td->io_ops->data; + struct solarisaio_data *sd = td->io_ops_data; io_u->resultp.aio_return = AIO_INPROGRESS; io_u->engine_data = sd; @@ -62,26 +60,22 @@ static void wait_for_event(struct timeval *tv) io_u->resid = io_u->xfer_buflen - io_u->resultp.aio_return; io_u->error = 0; } else - io_u->error = io_u->resultp.aio_return; + io_u->error = io_u->resultp.aio_errno; /* * For SIGIO, we need a write barrier between the two, so that * the ->aio_pending store is seen after the ->aio_events store */ sd->aio_events[sd->aio_pending] = io_u; + write_barrier(); sd->aio_pending++; sd->nr--; } -static void fio_solarisaio_sigio(int sig) -{ - wait_for_event(NULL); -} - static int fio_solarisaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { - struct solarisaio_data *sd = td->io_ops->data; + struct solarisaio_data *sd = td->io_ops_data; struct timeval tv; int ret; @@ -97,24 +91,24 @@ static int fio_solarisaio_getevents(struct thread_data *td, unsigned int min, wait_for_event(&tv); /* - * Needs locking here for SIGIO + * should be OK without locking, as int operations should be atomic */ ret = sd->aio_pending; - sd->aio_pending = 0; + sd->aio_pending -= ret; return ret; } static struct io_u *fio_solarisaio_event(struct thread_data *td, int event) { - struct solarisaio_data *sd = td->io_ops->data; + struct solarisaio_data *sd = td->io_ops_data; return sd->aio_events[event]; } -static int fio_solarisaio_queue(struct thread_data fio_unused *td, +static enum fio_q_status fio_solarisaio_queue(struct thread_data fio_unused *td, struct io_u *io_u) { - struct solarisaio_data *sd = td->io_ops->data; + struct solarisaio_data *sd = td->io_ops_data; struct fio_file *f = io_u->file; off_t off; int ret; @@ -130,6 +124,15 @@ static int fio_solarisaio_queue(struct thread_data fio_unused *td, return FIO_Q_COMPLETED; } + if (io_u->ddir == DDIR_DATASYNC) { + if (sd->nr) + return FIO_Q_BUSY; + if (fdatasync(f->fd) < 0) + io_u->error = errno; + + return FIO_Q_COMPLETED; + } + if (sd->nr == sd->max_depth) return FIO_Q_BUSY; @@ -152,7 +155,7 @@ static int fio_solarisaio_queue(struct thread_data fio_unused *td, static void fio_solarisaio_cleanup(struct thread_data *td) { - struct solarisaio_data *sd = td->io_ops->data; + struct solarisaio_data *sd = td->io_ops_data; if (sd) { free(sd->aio_events); @@ -161,20 +164,24 @@ static void fio_solarisaio_cleanup(struct thread_data *td) } /* - * Set USE_SIGNAL_COMPLETIONS to use SIGIO as completion events. Needs - * locking around ->aio_pending and ->aio_events, see comment + * Set USE_SIGNAL_COMPLETIONS to use SIGIO as completion events. */ +#ifdef USE_SIGNAL_COMPLETIONS +static void fio_solarisaio_sigio(int sig) +{ + wait_for_event(NULL); +} + static void fio_solarisaio_init_sigio(void) { -#ifdef USE_SIGNAL_COMPLETIONS struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = fio_solarisaio_sigio; act.sa_flags = SA_RESTART; sigaction(SIGIO, &act, NULL); -#endif } +#endif static int fio_solarisaio_init(struct thread_data *td) { @@ -193,9 +200,11 @@ static int fio_solarisaio_init(struct thread_data *td) memset(sd->aio_events, 0, max_depth * sizeof(struct io_u *)); sd->max_depth = max_depth; +#ifdef USE_SIGNAL_COMPLETIONS fio_solarisaio_init_sigio(); +#endif - td->io_ops->data = sd; + td->io_ops_data = sd; return 0; } @@ -211,29 +220,9 @@ static struct ioengine_ops ioengine = { .cleanup = fio_solarisaio_cleanup, .open_file = generic_open_file, .close_file = generic_close_file, + .get_file_size = generic_get_file_size, }; -#else /* FIO_HAVE_SOLARISAIO */ - -/* - * When we have a proper configure system in place, we simply wont build - * and install this io engine. For now install a crippled version that - * just complains and fails to load. - */ -static int fio_solarisaio_init(struct thread_data fio_unused *td) -{ - fprintf(stderr, "fio: solarisaio not available\n"); - return 1; -} - -static struct ioengine_ops ioengine = { - .name = "solarisaio", - .version = FIO_IOOPS_VERSION, - .init = fio_solarisaio_init, -}; - -#endif - static void fio_init fio_solarisaio_register(void) { register_ioengine(&ioengine);