From 1f440ece6127d2d274b961b6af0aa9091787702a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 30 Sep 2014 16:04:12 -0600 Subject: [PATCH] Constify a few more hot paths Signed-off-by: Jens Axboe --- engines/binject.c | 3 ++- engines/glusterfs_async.c | 2 +- engines/guasi.c | 2 +- engines/libaio.c | 10 ++++++++-- engines/null.c | 2 +- engines/posixaio.c | 2 +- engines/rbd.c | 2 +- engines/rdma.c | 2 +- engines/sg.c | 3 ++- engines/skeleton_external.c | 2 +- engines/solarisaio.c | 2 +- engines/sync.c | 2 +- engines/windowsaio.c | 5 +++-- fio_time.h | 10 +++++----- gettime.c | 10 +++++----- ioengine.h | 4 ++-- ioengines.c | 2 +- iolog.c | 4 ++-- iolog.h | 4 ++-- 19 files changed, 41 insertions(+), 32 deletions(-) diff --git a/engines/binject.c b/engines/binject.c index 43e31695..c0baf9d2 100644 --- a/engines/binject.c +++ b/engines/binject.c @@ -91,7 +91,8 @@ one_more: } static int fio_binject_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec fio_unused *t) + unsigned int max, + const struct timespec fio_unused *t) { struct binject_data *bd = td->io_ops->data; int left = max, ret, r = 0, ev_index = 0; diff --git a/engines/glusterfs_async.c b/engines/glusterfs_async.c index 7b0b30a7..599bc5df 100644 --- a/engines/glusterfs_async.c +++ b/engines/glusterfs_async.c @@ -20,7 +20,7 @@ static struct io_u *fio_gf_event(struct thread_data *td, int event) } static int fio_gf_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct gf_data *g = td->io_ops->data; unsigned int events = 0; diff --git a/engines/guasi.c b/engines/guasi.c index c9c74295..c586f09c 100644 --- a/engines/guasi.c +++ b/engines/guasi.c @@ -80,7 +80,7 @@ static struct io_u *fio_guasi_event(struct thread_data *td, int event) } static int fio_guasi_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct guasi_data *ld = td->io_ops->data; int n, r; diff --git a/engines/libaio.c b/engines/libaio.c index bcc296ff..cd10aabf 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -139,13 +139,19 @@ static int user_io_getevents(io_context_t aio_ctx, unsigned int max, } static int fio_libaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct libaio_data *ld = td->io_ops->data; struct libaio_options *o = td->eo; unsigned actual_min = td->o.iodepth_batch_complete == 0 ? 0 : min; + struct timespec __lt, *lt = NULL; int r, events = 0; + if (t) { + __lt = *t; + lt = &__lt; + } + do { if (o->userspace_reap == 1 && actual_min == 0 @@ -155,7 +161,7 @@ static int fio_libaio_getevents(struct thread_data *td, unsigned int min, ld->aio_events + events); } else { r = io_getevents(ld->aio_ctx, actual_min, - max, ld->aio_events + events, t); + max, ld->aio_events + events, lt); } if (r >= 0) events += r; diff --git a/engines/null.c b/engines/null.c index e7df6a13..60009305 100644 --- a/engines/null.c +++ b/engines/null.c @@ -32,7 +32,7 @@ static struct io_u *fio_null_event(struct thread_data *td, int event) static int fio_null_getevents(struct thread_data *td, unsigned int min_events, unsigned int fio_unused max, - struct timespec fio_unused *t) + const struct timespec fio_unused *t) { struct null_data *nd = (struct null_data *) td->io_ops->data; int ret = 0; diff --git a/engines/posixaio.c b/engines/posixaio.c index 2df26af3..8ab88fbb 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -91,7 +91,7 @@ static int fio_posixaio_prep(struct thread_data fio_unused *td, #define SUSPEND_ENTRIES 8 static int fio_posixaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct posixaio_data *pd = td->io_ops->data; os_aiocb_t *suspend_list[SUSPEND_ENTRIES]; diff --git a/engines/rbd.c b/engines/rbd.c index 85a705fc..6fe87b8d 100644 --- a/engines/rbd.c +++ b/engines/rbd.c @@ -222,7 +222,7 @@ static struct io_u *fio_rbd_event(struct thread_data *td, int event) } static int fio_rbd_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct rbd_data *rbd_data = td->io_ops->data; unsigned int events = 0; diff --git a/engines/rdma.c b/engines/rdma.c index af50187a..50812020 100644 --- a/engines/rdma.c +++ b/engines/rdma.c @@ -524,7 +524,7 @@ static struct io_u *fio_rdmaio_event(struct thread_data *td, int event) } static int fio_rdmaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { struct rdmaio_data *rd = td->io_ops->data; enum ibv_wc_opcode comp_opcode; diff --git a/engines/sg.c b/engines/sg.c index 1a027dae..6272b79b 100644 --- a/engines/sg.c +++ b/engines/sg.c @@ -62,7 +62,8 @@ static int pollin_events(struct pollfd *pfds, int fds) } static int fio_sgio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec fio_unused *t) + unsigned int max, + const struct timespec fio_unused *t) { struct sgio_data *sd = td->io_ops->data; int left = max, ret, r = 0; diff --git a/engines/skeleton_external.c b/engines/skeleton_external.c index f9a0e1cd..63a6f8d1 100644 --- a/engines/skeleton_external.c +++ b/engines/skeleton_external.c @@ -38,7 +38,7 @@ static struct io_u *fio_skeleton_event(struct thread_data *td, int event) * numbers. Required. */ static int fio_skeleton_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, const struct timespec *t) { return 0; } diff --git a/engines/solarisaio.c b/engines/solarisaio.c index 137dc225..55a0cb95 100644 --- a/engines/solarisaio.c +++ b/engines/solarisaio.c @@ -73,7 +73,7 @@ static void wait_for_event(struct timeval *tv) } 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 timeval tv; diff --git a/engines/sync.c b/engines/sync.c index 13299464..41612dfa 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -138,7 +138,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u) static int fio_vsyncio_getevents(struct thread_data *td, unsigned int min, unsigned int max, - struct timespec fio_unused *t) + const struct timespec fio_unused *t) { struct syncio_data *sd = td->io_ops->data; int ret; diff --git a/engines/windowsaio.c b/engines/windowsaio.c index 16df7403..ec8222c9 100644 --- a/engines/windowsaio.c +++ b/engines/windowsaio.c @@ -37,7 +37,7 @@ struct thread_ctx { static BOOL timeout_expired(DWORD start_count, DWORD end_count); static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t); + unsigned int max, const struct timespec *t); static struct io_u *fio_windowsaio_event(struct thread_data *td, int event); static int fio_windowsaio_queue(struct thread_data *td, struct io_u *io_u); @@ -256,7 +256,8 @@ static struct io_u* fio_windowsaio_event(struct thread_data *td, int event) } static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, + const struct timespec *t) { struct windowsaio_data *wd = td->io_ops->data; unsigned int dequeued = 0; diff --git a/fio_time.h b/fio_time.h index 9f7d209a..5fd3847d 100644 --- a/fio_time.h +++ b/fio_time.h @@ -2,11 +2,11 @@ #define FIO_TIME_H struct thread_data; -extern uint64_t utime_since(struct timeval *, struct timeval *); -extern uint64_t utime_since_now(struct timeval *); -extern uint64_t mtime_since(struct timeval *, struct timeval *); -extern uint64_t mtime_since_now(struct timeval *); -extern uint64_t time_since_now(struct timeval *); +extern uint64_t utime_since(const struct timeval *,const struct timeval *); +extern uint64_t utime_since_now(const struct timeval *); +extern uint64_t mtime_since(const struct timeval *, const struct timeval *); +extern uint64_t mtime_since_now(const struct timeval *); +extern uint64_t time_since_now(const struct timeval *); extern uint64_t mtime_since_genesis(void); extern uint64_t utime_since_genesis(void); extern void usec_spin(unsigned int); diff --git a/gettime.c b/gettime.c index 8a139239..9f836209 100644 --- a/gettime.c +++ b/gettime.c @@ -377,7 +377,7 @@ void fio_clock_init(void) log_info("fio: clocksource=cpu may not be reliable\n"); } -uint64_t utime_since(struct timeval *s, struct timeval *e) +uint64_t utime_since(const struct timeval *s, const struct timeval *e) { long sec, usec; uint64_t ret; @@ -400,7 +400,7 @@ uint64_t utime_since(struct timeval *s, struct timeval *e) return ret; } -uint64_t utime_since_now(struct timeval *s) +uint64_t utime_since_now(const struct timeval *s) { struct timeval t; @@ -408,7 +408,7 @@ uint64_t utime_since_now(struct timeval *s) return utime_since(s, &t); } -uint64_t mtime_since(struct timeval *s, struct timeval *e) +uint64_t mtime_since(const struct timeval *s, const struct timeval *e) { long sec, usec, ret; @@ -429,7 +429,7 @@ uint64_t mtime_since(struct timeval *s, struct timeval *e) return ret; } -uint64_t mtime_since_now(struct timeval *s) +uint64_t mtime_since_now(const struct timeval *s) { struct timeval t; void *p = __builtin_return_address(0); @@ -438,7 +438,7 @@ uint64_t mtime_since_now(struct timeval *s) return mtime_since(s, &t); } -uint64_t time_since_now(struct timeval *s) +uint64_t time_since_now(const struct timeval *s) { return mtime_since_now(s) / 1000; } diff --git a/ioengine.h b/ioengine.h index 0742a8b9..dfe84ac9 100644 --- a/ioengine.h +++ b/ioengine.h @@ -137,7 +137,7 @@ struct ioengine_ops { int (*prep)(struct thread_data *, struct io_u *); int (*queue)(struct thread_data *, struct io_u *); int (*commit)(struct thread_data *); - int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *); + int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *); struct io_u *(*event)(struct thread_data *, int); int (*cancel)(struct thread_data *, struct io_u *); void (*cleanup)(struct thread_data *); @@ -182,7 +182,7 @@ extern int __must_check td_io_init(struct thread_data *); extern int __must_check td_io_prep(struct thread_data *, struct io_u *); extern int __must_check td_io_queue(struct thread_data *, struct io_u *); extern int __must_check td_io_sync(struct thread_data *, struct fio_file *); -extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *); +extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *); extern int __must_check td_io_commit(struct thread_data *); extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); extern int td_io_close_file(struct thread_data *, struct fio_file *); diff --git a/ioengines.c b/ioengines.c index 56149381..07d1d567 100644 --- a/ioengines.c +++ b/ioengines.c @@ -220,7 +220,7 @@ int td_io_prep(struct thread_data *td, struct io_u *io_u) } int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max, - struct timespec *t) + const struct timespec *t) { int r = 0; diff --git a/iolog.c b/iolog.c index cfcab271..4a7d939a 100644 --- a/iolog.c +++ b/iolog.c @@ -28,7 +28,7 @@ void queue_io_piece(struct thread_data *td, struct io_piece *ipo) td->total_io_size += ipo->len; } -void log_io_u(struct thread_data *td, struct io_u *io_u) +void log_io_u(const struct thread_data *td, const struct io_u *io_u) { if (!td->o.write_iolog_file) return; @@ -282,7 +282,7 @@ void unlog_io_piece(struct thread_data *td, struct io_u *io_u) td->io_hist_len--; } -void trim_io_piece(struct thread_data *td, struct io_u *io_u) +void trim_io_piece(struct thread_data *td, const struct io_u *io_u) { struct io_piece *ipo = io_u->ipo; diff --git a/iolog.h b/iolog.h index fcd67942..a1e32ae7 100644 --- a/iolog.h +++ b/iolog.h @@ -174,12 +174,12 @@ enum file_log_act { struct io_u; extern int __must_check read_iolog_get(struct thread_data *, struct io_u *); -extern void log_io_u(struct thread_data *, struct io_u *); +extern void log_io_u(const struct thread_data *, const struct io_u *); extern void log_file(struct thread_data *, struct fio_file *, enum file_log_act); extern int __must_check init_iolog(struct thread_data *td); extern void log_io_piece(struct thread_data *, struct io_u *); extern void unlog_io_piece(struct thread_data *, struct io_u *); -extern void trim_io_piece(struct thread_data *, struct io_u *); +extern void trim_io_piece(struct thread_data *, const struct io_u *); extern void queue_io_piece(struct thread_data *, struct io_piece *); extern void prune_io_piece_log(struct thread_data *); extern void write_iolog_close(struct thread_data *); -- 2.25.1