CC = gcc
-CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INC_DEBUG
PROGS = fio
SCRIPTS = fio_generate_plots
OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o filesetup.o \
OBJS += engines/null.o
OBJS += engines/net.o
-all: depend $(PROGS) $(SCRIPTS)
+OBJS += lib/strsep.o
+INSTALL = install
+prefix = /usr/local
+bindir = $(prefix)/bin
+mandir = $(prefix)/man
+
+%.o: %.c
+ $(CC) -o $*.o -c $(CFLAGS) $<
fio: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) -lc -lpthread -lm -laio -lrt -ldl
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(EXTLIBS) -lpthread -lm -ldl -laio -lrt -lnsl -lsocket
-clean:
- -rm -f *.o .depend cscope.out $(PROGS)
+all: $(PROGS) $(SCRIPTS)
-depend:
- @$(CC) -MM $(ALL_CFLAGS) *.c engines/*.c 1> .depend
+clean:
+ -rm -f *.o .depend cscope.out $(PROGS) engines/*.o crc/*.o lib/*.o core.* core
cscope:
@cscope -b
-INSTALL = install
-prefix = /usr/local
-bindir = $(prefix)/bin
-
install: $(PROGS) $(SCRIPTS)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
#error "Unsupported arch"
#endif
-#define BITS_PER_LONG (__WORDSIZE)
-
#endif
*/
#include <string.h>
#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
#include "sha256.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __be32_to_cpu(x) __bswap_32(x)
+static int __be32_to_cpu(uint32_t val)
+{
+ uint32_t c1, c2, c3, c4;
+
+ c1 = (val >> 24) & 0xff;
+ c2 = (val >> 16) & 0xff;
+ c3 = (val >> 8) & 0xff;
+ c4 = val & 0xff;
+
+ return c1 | c2 << 8 | c3 << 16 | c4 << 24;
+}
#else
#define __be32_to_cpu(x) (x)
#endif
#include <string.h>
#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
#include "sha512.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __be64_to_cpu(x) __bswap_64(x)
+static int __be64_to_cpu(uint64_t val)
+{
+ uint64_t c1, c2, c3, c4, c5, c6, c7, c8;
+
+ c1 = (val >> 56) & 0xff;
+ c2 = (val >> 48) & 0xff;
+ c3 = (val >> 40) & 0xff;
+ c4 = (val >> 32) & 0xff;
+ c5 = (val >> 24) & 0xff;
+ c6 = (val >> 16) & 0xff;
+ c7 = (val >> 8) & 0xff;
+ c8 = val & 0xff;
+
+ return c1 | c2 << 8 | c3 << 16 | c4 << 24 | c5 << 32 | c6 << 40 | c7 << 48 | c8 << 56;
+}
#else
#define __be64_to_cpu(x) (x)
#endif
&& pid != *fio_debug_jobp) \
break; \
log_info("%-8s ", debug_levels[(type)].name); \
- log_info("%-5u ", pid); \
+ log_info("%-5u ", (int) pid); \
log_info(str, ##args); \
} while (0)
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#include <sys/mman.h>
#include "../fio.h"
return 0;
}
+#ifdef FIO_HAVE_SPLICE
static int splice_io_u(int fdin, int fdout, unsigned int len)
{
int bytes = 0;
return ret;
}
+#else
+static int fio_netio_splice_in(struct thread_data *td, struct io_u *io_u)
+{
+ errno = -EOPNOTSUPP;
+ return -1;
+}
+
+static int fio_netio_splice_out(struct thread_data *td, struct io_u *io_u)
+{
+ errno = -EOPNOTSUPP;
+ return -1;
+}
+#endif
static int fio_netio_send(struct thread_data *td, struct io_u *io_u)
{
/*
* if we are going to write more, set MSG_MORE
*/
+#ifdef MSG_MORE
if (td->this_io_bytes[DDIR_WRITE] + io_u->xfer_buflen < td->o.size)
flags = MSG_MORE;
+#endif
return send(io_u->file->fd, io_u->xfer_buf, io_u->xfer_buflen, flags);
}
return 0;
}
+#ifdef FIO_HAVE_SPLICE
static int fio_netio_setup_splice(struct thread_data *td)
{
struct netio_data *nd;
return 1;
}
-static struct ioengine_ops ioengine_rw = {
- .name = "net",
+static struct ioengine_ops ioengine_splice = {
+ .name = "netsplice",
.version = FIO_IOOPS_VERSION,
.prep = fio_netio_prep,
.queue = fio_netio_queue,
- .setup = fio_netio_setup,
+ .setup = fio_netio_setup_splice,
.init = fio_netio_init,
.cleanup = fio_netio_cleanup,
.open_file = fio_netio_open_file,
.flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
FIO_SIGQUIT,
};
+#endif
-static struct ioengine_ops ioengine_splice = {
- .name = "netsplice",
+static struct ioengine_ops ioengine_rw = {
+ .name = "net",
.version = FIO_IOOPS_VERSION,
.prep = fio_netio_prep,
.queue = fio_netio_queue,
- .setup = fio_netio_setup_splice,
+ .setup = fio_netio_setup,
.init = fio_netio_init,
.cleanup = fio_netio_cleanup,
.open_file = fio_netio_open_file,
static void fio_init fio_netio_register(void)
{
register_ioengine(&ioengine_rw);
+#ifdef FIO_HAVE_SPLICE
register_ioengine(&ioengine_splice);
+#endif
}
static void fio_exit fio_netio_unregister(void)
{
unregister_ioengine(&ioengine_rw);
+#ifdef FIO_HAVE_SPLICE
unregister_ioengine(&ioengine_splice);
+#endif
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/uio.h>
#include <errno.h>
#include <assert.h>
if (td->o.sync_io)
flags |= O_SYNC;
if (f->filetype != FIO_TYPE_FILE)
- flags |= O_NOATIME;
+ flags |= FIO_O_NOATIME;
open_again:
if (td_write(td)) {
char buf[FIO_VERROR_SIZE];
int __e = errno;
- if (errno == EPERM && (flags & O_NOATIME)) {
- flags &= ~O_NOATIME;
+ if (errno == EPERM && (flags & FIO_O_NOATIME)) {
+ flags &= ~FIO_O_NOATIME;
goto open_again;
}
if (td->runstate == runstate)
return;
- dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", td->pid, td->runstate,
- runstate);
+ dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", (int) td->pid,
+ td->runstate, runstate);
td->runstate = runstate;
}
for_each_td(td, i) {
if (group_id == TERMINATE_ALL || groupid == td->groupid) {
dprint(FD_PROCESS, "setting terminate on %s/%d\n",
- td->o.name, td->pid);
+ td->o.name, (int) td->pid);
td->terminate = 1;
td->o.start_delay = 0;
td->pid = getpid();
- dprint(FD_PROCESS, "jobs pid=%d started\n", td->pid);
+ dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
INIT_LIST_HEAD(&td->io_u_freelist);
INIT_LIST_HEAD(&td->io_u_busylist);
err:
if (td->error)
- printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error,
+ printf("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
td->verror);
close_and_free_files(td);
close_ioengine(td);
ret = waitpid(td->pid, &status, flags);
if (ret < 0) {
if (errno == ECHILD) {
- log_err("fio: pid=%d disappeared %d\n", td->pid,
- td->runstate);
+ log_err("fio: pid=%d disappeared %d\n",
+ (int) td->pid, td->runstate);
td_set_runstate(td, TD_REAPED);
goto reaped;
}
if (sig != SIGQUIT)
log_err("fio: pid=%d, got signal=%d\n",
- td->pid, sig);
+ (int) td->pid, sig);
td_set_runstate(td, TD_REAPED);
goto reaped;
}
if (setup_files(td)) {
exit_value++;
if (td->error)
- log_err("fio: pid=%d, err=%d/%s\n", td->pid,
- td->error, td->verror);
+ log_err("fio: pid=%d, err=%d/%s\n",
+ (int) td->pid, td->error, td->verror);
td_set_runstate(td, TD_REAPED);
todo--;
} else {
struct fio_file *f = io_u->file;
dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
- io_u->offset, io_u->buflen, io_u->ddir);
+ (unsigned long long) io_u->offset,
+ io_u->buflen, io_u->ddir);
if (fio_debug & (1 << FD_IO)) {
if (f)
log_info("/%s", f->file_name);
* them can use shifts and additions instead of multiplications for
* machines where multiplications are slow.
*/
+
+#ifdef __WORDSIZE
+#define BITS_PER_LONG __WORDSIZE
+#else
+#define BITS_PER_LONG 32
+#endif
+
#if BITS_PER_LONG == 32
/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
#define GOLDEN_RATIO_PRIME 0x9e370001UL
}
if (o->fill_device && !o->size)
- o->size = ULONG_LONG_MAX;
+ o->size = -1ULL;
if (td_rw(td) && td->o.verify != VERIFY_NONE)
log_info("fio: mixed read/write workload with verify. May not "
*/
#include <stdio.h>
#include <stdlib.h>
+#include <libgen.h>
#include <assert.h>
#include "list.h"
#include "fio.h"
/*
* Memory helpers
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/mman.h>
void fio_mutex_remove(struct fio_mutex *mutex)
{
close(mutex->mutex_fd);
- munmap(mutex, sizeof(*mutex));
+ munmap((void *) mutex, sizeof(*mutex));
}
struct fio_mutex *fio_mutex_init(int value)
goto err;
}
- mutex = mmap(NULL, sizeof(struct fio_mutex), PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0);
+ mutex = (void *) mmap(NULL, sizeof(struct fio_mutex),
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mutex == MAP_FAILED) {
perror("mmap mutex");
close(fd);
#include <getopt.h>
#include <assert.h>
#include <libgen.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "fio.h"
#include "parse.h"
o = &options[0];
while (o->name) {
- long_options[i].name = o->name;
+ long_options[i].name = (char *) o->name;
long_options[i].val = FIO_GETOPT_JOB;
if (o->type == FIO_OPT_STR_SET)
long_options[i].has_arg = no_argument;
#define FIO_HAVE_HUGETLB
#define FIO_HAVE_RAWBIND
#define FIO_HAVE_BLKTRACE
+#define FIO_HAVE_STRSEP
#define OS_MAP_ANON (MAP_ANONYMOUS)
return 0;
}
+#define FIO_O_NOATIME O_NOATIME
+
#endif
#include <scsi/sg.h>
#endif
+#ifndef FIO_HAVE_STRSEP
+#include "../lib/lib.h"
+#endif
+
#ifndef FIO_HAVE_FADVISE
#define fadvise(fd, off, len, advice) (0)
#ifndef FIO_HAVE_CPU_AFFINITY
#define fio_setaffinity(td) (0)
-#define fio_getaffinity(pid, mask) (0)
+#define fio_getaffinity(pid, mask) do { } while(0)
#endif
#ifndef FIO_HAVE_IOPRIO
#endif
#endif
+#ifndef FIO_O_NOATIME
+#define FIO_O_NOATIME 0
+#endif
+
#ifndef FIO_HAVE_RAWBIND
#define fio_lookup_raw(dev, majdev, mindev) 1
#endif
{
return 0;
}
+struct thread_data;
static inline int load_blktrace(struct thread_data *td, const char *fname)
{
return 1;
if (!ts->error) {
log_info("%s: (groupid=%d, jobs=%d): err=%2d: pid=%d\n",
ts->name, ts->groupid, ts->members,
- ts->error, ts->pid);
+ ts->error, (int) ts->pid);
} else {
log_info("%s: (groupid=%d, jobs=%d): err=%2d (%s): pid=%d\n",
ts->name, ts->groupid, ts->members,
- ts->error, ts->verror, ts->pid);
+ ts->error, ts->verror, (int) ts->pid);
}
if (ts->description)
*/
static inline unsigned int __hdr_size(int verify_type)
{
- unsigned int len;
+ unsigned int len = len;
switch (verify_type) {
case VERIFY_NONE: