* May alter parameters that init_io_u() will use, so we need to
* do this first.
*/
- if (init_iolog(td))
+ if (!init_iolog(td))
goto err;
if (init_io_u(td))
* Check if this is a blktrace binary data file. We read a single trace
* into memory and check for the magic signature.
*/
-int is_blktrace(const char *filename, int *need_swap)
+bool is_blktrace(const char *filename, int *need_swap)
{
struct blk_io_trace t;
int fd, ret;
fd = open(filename, O_RDONLY);
if (fd < 0)
- return 0;
+ return false;
ret = read(fd, &t, sizeof(t));
close(fd);
if (ret < 0) {
perror("read blktrace");
- return 0;
+ return false;
} else if (ret != sizeof(t)) {
log_err("fio: short read on blktrace file\n");
- return 0;
+ return false;
}
if ((t.magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) {
*need_swap = 0;
- return 1;
+ return true;
}
/*
t.magic = fio_swap32(t.magic);
if ((t.magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) {
*need_swap = 1;
- return 1;
+ return true;
}
- return 0;
+ return false;
}
#define FMINORBITS 20
t->pdu_len = fio_swap16(t->pdu_len);
}
-static int t_is_write(struct blk_io_trace *t)
+static bool t_is_write(struct blk_io_trace *t)
{
return (t->action & BLK_TC_ACT(BLK_TC_WRITE | BLK_TC_DISCARD)) != 0;
}
* Load a blktrace file by reading all the blk_io_trace entries, and storing
* them as io_pieces like the fio text version would do.
*/
-int load_blktrace(struct thread_data *td, const char *filename, int need_swap)
+bool load_blktrace(struct thread_data *td, const char *filename, int need_swap)
{
struct blk_io_trace t;
unsigned long ios[DDIR_RWDIR_SYNC_CNT] = { };
fd = open(filename, O_RDONLY);
if (fd < 0) {
td_verror(td, errno, "open blktrace file");
- return 1;
+ return false;
}
fifo = fifo_alloc(TRACE_FIFO_SIZE);
if (!td->files_index) {
log_err("fio: did not find replay device(s)\n");
- return 1;
+ return false;
}
/*
if (!ios[DDIR_READ] && !ios[DDIR_WRITE] && !ios[DDIR_TRIM] &&
!ios[DDIR_SYNC]) {
log_err("fio: found no ios in blktrace data\n");
- return 1;
+ return false;
} else if (ios[DDIR_READ] && !ios[DDIR_WRITE]) {
td->o.td_ddir = TD_DDIR_READ;
td->o.max_bs[DDIR_READ] = rw_bs[DDIR_READ];
if (!fio_option_is_set(&td->o, iodepth))
td->o.iodepth = td->o.iodepth_low = max_depth;
- return 0;
+ return true;
err:
close(fd);
fifo_free(fifo);
- return 1;
+ return false;
}
#ifdef FIO_HAVE_BLKTRACE
-int is_blktrace(const char *, int *);
-int load_blktrace(struct thread_data *, const char *, int);
+bool is_blktrace(const char *, int *);
+bool load_blktrace(struct thread_data *, const char *, int);
#else
-static inline int is_blktrace(const char *fname, int *need_swap)
+static inline bool is_blktrace(const char *fname, int *need_swap)
{
- return 0;
+ return false;
}
-static inline int load_blktrace(struct thread_data *td, const char *fname,
- int need_swap)
+static inline bool load_blktrace(struct thread_data *td, const char *fname,
+ int need_swap)
{
- return 1;
+ return false;
}
#endif
* Read version 2 iolog data. It is enhanced to include per-file logging,
* syncs, etc.
*/
-static int read_iolog2(struct thread_data *td, FILE *f)
+static bool read_iolog2(struct thread_data *td, FILE *f)
{
unsigned long long offset;
unsigned int bytes;
}
if (!reads && !writes && !waits)
- return 1;
+ return false;
else if (reads && !writes)
td->o.td_ddir = TD_DDIR_READ;
else if (!reads && writes)
else
td->o.td_ddir = TD_DDIR_RW;
- return 0;
+ return true;
}
/*
* open iolog, check version, and call appropriate parser
*/
-static int init_iolog_read(struct thread_data *td)
+static bool init_iolog_read(struct thread_data *td)
{
char buffer[256], *p;
FILE *f;
- int ret;
+ bool ret;
f = fopen(td->o.read_iolog_file, "r");
if (!f) {
perror("fopen read iolog");
- return 1;
+ return false;
}
p = fgets(buffer, sizeof(buffer), f);
td_verror(td, errno, "iolog read");
log_err("fio: unable to read iolog\n");
fclose(f);
- return 1;
+ return false;
}
/*
ret = read_iolog2(td, f);
else {
log_err("fio: iolog version 1 is no longer supported\n");
- ret = 1;
+ ret = false;
}
fclose(f);
/*
* Set up a log for storing io patterns.
*/
-static int init_iolog_write(struct thread_data *td)
+static bool init_iolog_write(struct thread_data *td)
{
struct fio_file *ff;
FILE *f;
f = fopen(td->o.write_iolog_file, "a");
if (!f) {
perror("fopen write iolog");
- return 1;
+ return false;
}
/*
*/
if (fprintf(f, "%s\n", iolog_ver2) < 0) {
perror("iolog init\n");
- return 1;
+ return false;
}
/*
for_each_file(td, ff, i)
log_file(td, ff, FIO_LOG_ADD_FILE);
- return 0;
+ return true;
}
-int init_iolog(struct thread_data *td)
+bool init_iolog(struct thread_data *td)
{
- int ret = 0;
+ bool ret;
if (td->o.read_iolog_file) {
int need_swap;
ret = init_iolog_read(td);
} else if (td->o.write_iolog_file)
ret = init_iolog_write(td);
+ else
+ ret = false;
- if (ret)
+ if (!ret)
td_verror(td, EINVAL, "failed initializing iolog");
return ret;
extern int __must_check read_iolog_get(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 bool __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 *, const struct io_u *);