-CC = gcc
-CFLAGS = -W -Wwrite-strings -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+#CC = /opt/intel/cce/9.1.045/bin/icc
+CC = gcc -W
+CFLAGS = -Wwrite-strings -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
PROGS = fio
SCRIPTS = fio_generate_plots
OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o \
if (hdr->dxfer_direction != SG_DXFER_NONE) {
nr_blocks = io_u->buflen / sd->bs;
lba = io_u->offset / sd->bs;
- hdr->cmdp[2] = (lba >> 24) & 0xff;
- hdr->cmdp[3] = (lba >> 16) & 0xff;
- hdr->cmdp[4] = (lba >> 8) & 0xff;
- hdr->cmdp[5] = lba & 0xff;
- hdr->cmdp[7] = (nr_blocks >> 8) & 0xff;
- hdr->cmdp[8] = nr_blocks & 0xff;
+ hdr->cmdp[2] = (unsigned char) ((lba >> 24) & 0xff);
+ hdr->cmdp[3] = (unsigned char) ((lba >> 16) & 0xff);
+ hdr->cmdp[4] = (unsigned char) ((lba >> 8) & 0xff);
+ hdr->cmdp[5] = (unsigned char) (lba & 0xff);
+ hdr->cmdp[7] = (unsigned char) ((nr_blocks >> 8) & 0xff);
+ hdr->cmdp[8] = (unsigned char) (nr_blocks & 0xff);
}
return 0;
if (d || always_d) {
always_d = 1;
- str += sprintf(str, "%02dd:", d);
+ str += sprintf(str, "%02ud:", d);
}
if (h || always_h) {
always_h = 1;
- str += sprintf(str, "%02dh:", h);
+ str += sprintf(str, "%02uh:", h);
}
- str += sprintf(str, "%02dm:", m);
- str += sprintf(str, "%02ds", s);
+ str += sprintf(str, "%02um:", m);
+ str += sprintf(str, "%02us", s);
}
/*
static int thread_eta(struct thread_data *td, unsigned long elapsed)
{
unsigned long long bytes_total, bytes_done;
- unsigned int eta_sec = 0;
+ unsigned long eta_sec = 0;
bytes_total = td->total_io_size;
if (perc > 1.0)
perc = 1.0;
- eta_sec = (elapsed * (1.0 / perc)) - elapsed;
+ eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
if (td->timeout && eta_sec > (td->timeout - elapsed))
eta_sec = td->timeout - elapsed;
}
temp_stall_ts = 1;
- fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n",
+ fprintf(f_out, "%s: Laying out IO file(s) (%u x %LuMiB == %LuMiB)\n",
td->name, td->nr_uniq_files,
(td->total_file_size >> 20) / td->nr_uniq_files,
td->total_file_size >> 20);
rate = (td->this_io_bytes[ddir] - td->rate_bytes) / spent;
if (rate < td->ratemin) {
- fprintf(f_out, "%s: min rate %d not met, got %ldKiB/sec\n", td->name, td->ratemin, rate);
+ fprintf(f_out, "%s: min rate %u not met, got %luKiB/sec\n", td->name, td->ratemin, rate);
return 1;
}
}
* The main verify engine. Runs over the writes we previusly submitted,
* reads the blocks back in, and checks the crc/md5 of the data.
*/
-void do_verify(struct thread_data *td)
+static void do_verify(struct thread_data *td)
{
struct io_u *io_u, *v_io_u = NULL;
struct io_completion_data icd;
#include "arch.h"
#include "os.h"
+enum fio_ddir {
+ DDIR_READ = 0,
+ DDIR_WRITE,
+ DDIR_SYNC,
+};
+
struct io_stat {
unsigned long val;
unsigned long val_sq;
struct io_sample {
unsigned long time;
unsigned long val;
- unsigned int ddir;
+ enum fio_ddir ddir;
};
struct io_log {
struct fio_file *file;
unsigned long long offset;
unsigned int len;
- int ddir;
+ enum fio_ddir ddir;
};
/*
unsigned int resid;
unsigned int error;
- unsigned char ddir;
+ enum fio_ddir ddir;
/*
* io engine private data
unsigned long long agg[2];
};
-enum fio_ddir {
- DDIR_READ = 0,
- DDIR_WRITE,
- DDIR_SYNC,
-};
-
/*
* What type of allocation to use for io buffers
*/
extern FILE *f_out;
extern FILE *f_err;
extern int temp_stall_ts;
+extern unsigned long long mlock_size;
extern struct thread_data *threads;
/*
* Logging
*/
-extern void add_clat_sample(struct thread_data *, int, unsigned long);
-extern void add_slat_sample(struct thread_data *, int, unsigned long);
-extern void add_bw_sample(struct thread_data *, int, struct timeval *);
+extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long);
+extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long);
+extern void add_bw_sample(struct thread_data *, enum fio_ddir, struct timeval *);
extern void show_run_stats(void);
extern void init_disk_util(struct thread_data *);
extern void update_rusage_stat(struct thread_data *);
#endif /* FIO_DEBUG_TIME */
+#ifdef FIO_DEBUG_TIME
void fio_gettime(struct timeval *tp, void *caller)
+#else
+void fio_gettime(struct timeval *tp, void fio_unused *caller)
+#endif
{
#ifdef FIO_DEBUG_TIME
if (!caller)
caller = __builtin_return_address(0);
gtod_log_caller(caller);
-#else
- caller = NULL;
#endif
repeat:
if (!clock_gettime_works)
if (td->filetype == FIO_TYPE_FILE || td->filename) {
char tmp[PATH_MAX];
int len = 0;
- int i;
if (td->directory && td->directory[0] != '\0')
sprintf(tmp, "%s/", td->directory);
c3 = to_kmg(td->min_bs[DDIR_WRITE]);
c4 = to_kmg(td->max_bs[DDIR_WRITE]);
- fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%s-%s/%s-%s, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth);
+ fprintf(f_out, "%s: (g=%d): rw=%s, odir=%u, bs=%s-%s/%s-%s, rate=%u, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth);
free(c1);
free(c2);
td->sequential = 0;
return 0;
} else if (!strncmp(mem, "rw", 2)) {
- td->ddir = 0;
+ td->ddir = DDIR_READ;
td->iomix = 1;
td->sequential = 1;
return 0;
} else if (!strncmp(mem, "randrw", 6)) {
- td->ddir = 0;
+ td->ddir = DDIR_READ;
td->iomix = 1;
td->sequential = 0;
return 0;
/*
* This is our [ini] type file parser.
*/
-int parse_jobs_ini(char *file, int stonewall_flag)
+static int parse_jobs_ini(char *file, int stonewall_flag)
{
unsigned int global;
struct thread_data *td;
buflen = td->min_bs[ddir];
else {
r = os_random_long(&td->bsrange_state);
- buflen = (1 + (double) (td->max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
+ buflen = (unsigned int) (1 + (double) (td->max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
if (!td->bs_unaligned)
buflen = (buflen + td->min_bs[ddir] - 1) & ~(td->min_bs[ddir] - 1);
}
* mixed read/write workload, check the rwmix cycle and switch if
* necessary.
*/
-static int get_rw_ddir(struct thread_data *td)
+static enum fio_ddir get_rw_ddir(struct thread_data *td)
{
if (td_rw(td)) {
struct timeval now;
if (!io_u->error) {
unsigned int bytes = io_u->buflen - io_u->resid;
- const int idx = io_u->ddir;
+ const enum fio_ddir idx = io_u->ddir;
td->io_blocks[idx]++;
td->io_bytes[idx] += bytes;
void write_iolog_put(struct thread_data *td, struct io_u *io_u)
{
- fprintf(td->iolog_f, "%d,%llu,%u\n", io_u->ddir, io_u->offset, io_u->buflen);
+ fprintf(td->iolog_f, "%u,%llu,%u\n", io_u->ddir, io_u->offset, io_u->buflen);
}
int read_iolog_get(struct thread_data *td, struct io_u *io_u)
INIT_LIST_HEAD(&ipo->list);
ipo->offset = offset;
ipo->len = bytes;
- ipo->ddir = rw;
+ ipo->ddir = (enum fio_ddir) rw;
if (bytes > td->max_bs[rw])
td->max_bs[rw] = bytes;
list_add_tail(&ipo->list, &td->io_log_list);
else if (td->write_iolog_file)
ret = init_iolog_write(td);
- return 0;
+ return ret;
}
int setup_rate(struct thread_data *td)
#include "fio.h"
#include "os.h"
-extern unsigned long long mlock_size;
static void *pinned_mem;
void fio_unpin_memory(void)
} else if (td->mem_type == MEM_MMAP)
munmap(td->orig_buffer, td->orig_buffer_size);
else
- log_err("Bad memory type %d\n", td->mem_type);
+ log_err("Bad memory type %u\n", td->mem_type);
td->orig_buffer = NULL;
}
break;
}
default:
- fprintf(stderr, "Bad option type %d\n", o->type);
+ fprintf(stderr, "Bad option type %u\n", o->type);
ret = 1;
}
runtime = mtime_since(&td->epoch, &td->end_time);
if (runtime) {
- double runt = runtime;
+ double runt = (double) runtime;
usr_cpu = (double) td->usr_time * 100 / runt;
sys_cpu = (double) td->sys_time * 100 / runt;
show_ddir_status_terse(td, rs, 1);
if (td->runtime[0] + td->runtime[1]) {
- double runt = td->runtime[0] + td->runtime[1];
+ double runt = (double) (td->runtime[0] + td->runtime[1]);
usr_cpu = (double) td->usr_time * 100 / runt;
sys_cpu = (double) td->sys_time * 100 / runt;
}
static void add_log_sample(struct thread_data *td, struct io_log *iolog,
- unsigned long val, int ddir)
+ unsigned long val, enum fio_ddir ddir)
{
if (iolog->nr_samples == iolog->max_samples) {
int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
iolog->nr_samples++;
}
-void add_clat_sample(struct thread_data *td, int ddir, unsigned long msec)
+void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
+ unsigned long msec)
{
add_stat_sample(&td->clat_stat[ddir], msec);
add_log_sample(td, td->clat_log, msec, ddir);
}
-void add_slat_sample(struct thread_data *td, int ddir, unsigned long msec)
+void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
+ unsigned long msec)
{
add_stat_sample(&td->slat_stat[ddir], msec);
add_log_sample(td, td->slat_log, msec, ddir);
}
-void add_bw_sample(struct thread_data *td, int ddir, struct timeval *t)
+void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
+ struct timeval *t)
{
unsigned long spent = mtime_since(&td->stat_sample_time[ddir], t);
unsigned long rate;
unsigned long utime_since(struct timeval *s, struct timeval *e)
{
- double sec, usec;
+ long sec, usec;
sec = e->tv_sec - s->tv_sec;
usec = e->tv_usec - s->tv_usec;
unsigned long mtime_since(struct timeval *s, struct timeval *e)
{
- double sec, usec;
+ long sec, usec;
sec = e->tv_sec - s->tv_sec;
usec = e->tv_usec - s->tv_usec;
else if (hdr->verify_type == VERIFY_CRC32)
ret = verify_io_u_crc32(hdr, io_u);
else {
- log_err("Bad verify type %d\n", hdr->verify_type);
+ log_err("Bad verify type %u\n", hdr->verify_type);
ret = 1;
}