projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for redirection replay of blktrace traces to another device
[fio.git]
/
fio.c
diff --git
a/fio.c
b/fio.c
index 7d4c96a2b8a5045cda742f4be7842deb66529637..1d20cf79413a95ea184a223065635e923674b43b 100644
(file)
--- a/
fio.c
+++ b/
fio.c
@@
-40,6
+40,8
@@
#include "verify.h"
#include "diskutil.h"
#include "cgroup.h"
#include "verify.h"
#include "diskutil.h"
#include "cgroup.h"
+#include "profile.h"
+#include "lib/rand.h"
unsigned long page_mask;
unsigned long page_size;
unsigned long page_mask;
unsigned long page_size;
@@
-134,23
+136,12
@@
static void sig_quit(int sig)
static void sig_int(int sig)
{
if (threads) {
static void sig_int(int sig)
{
if (threads) {
-
printf
("\nfio: terminating on signal %d\n", sig);
+
log_info
("\nfio: terminating on signal %d\n", sig);
fflush(stdout);
terminate_threads(TERMINATE_ALL);
}
}
fflush(stdout);
terminate_threads(TERMINATE_ALL);
}
}
-static void sig_ill(int fio_unused sig)
-{
- if (!threads)
- return;
-
- log_err("fio: illegal instruction. your cpu does not support "
- "the sse4.2 instruction for crc32c\n");
- terminate_threads(TERMINATE_ALL);
- exit(4);
-}
-
static void set_sig_handlers(void)
{
struct sigaction act;
static void set_sig_handlers(void)
{
struct sigaction act;
@@
-165,11
+156,6
@@
static void set_sig_handlers(void)
act.sa_flags = SA_RESTART;
sigaction(SIGINT, &act, NULL);
act.sa_flags = SA_RESTART;
sigaction(SIGINT, &act, NULL);
- memset(&act, 0, sizeof(act));
- act.sa_handler = sig_ill;
- act.sa_flags = SA_RESTART;
- sigaction(SIGILL, &act, NULL);
-
memset(&act, 0, sizeof(act));
act.sa_handler = sig_quit;
act.sa_flags = SA_RESTART;
memset(&act, 0, sizeof(act));
act.sa_handler = sig_quit;
act.sa_flags = SA_RESTART;
@@
-190,6
+176,8
@@
static int __check_min_rate(struct thread_data *td, struct timeval *now,
unsigned int rate_iops = 0;
unsigned int rate_iops_min = 0;
unsigned int rate_iops = 0;
unsigned int rate_iops_min = 0;
+ assert(ddir_rw(ddir));
+
if (!td->o.ratemin[ddir] && !td->o.rate_iops_min[ddir])
return 0;
if (!td->o.ratemin[ddir] && !td->o.rate_iops_min[ddir])
return 0;
@@
-432,6
+420,8
@@
static void do_verify(struct thread_data *td)
int ret, min_events;
unsigned int i;
int ret, min_events;
unsigned int i;
+ dprint(FD_VERIFY, "starting loop\n");
+
/*
* sync io first and invalidate cache, to make sure we really
* read from disk.
/*
* sync io first and invalidate cache, to make sure we really
* read from disk.
@@
-503,7
+493,8
@@
static void do_verify(struct thread_data *td)
io_u->xfer_buf += bytes;
io_u->offset += bytes;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
- td->ts.short_io_u[io_u->ddir]++;
+ if (ddir_rw(io_u->ddir))
+ td->ts.short_io_u[io_u->ddir]++;
if (io_u->offset == f->real_file_size)
goto sync_done;
if (io_u->offset == f->real_file_size)
goto sync_done;
@@
-569,6
+560,8
@@
sync_done:
cleanup_pending_aio(td);
td_set_runstate(td, TD_RUNNING);
cleanup_pending_aio(td);
td_set_runstate(td, TD_RUNNING);
+
+ dprint(FD_VERIFY, "exiting loop\n");
}
/*
}
/*
@@
-646,7
+639,8
@@
static void do_io(struct thread_data *td)
io_u->xfer_buf += bytes;
io_u->offset += bytes;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
- td->ts.short_io_u[io_u->ddir]++;
+ if (ddir_rw(io_u->ddir))
+ td->ts.short_io_u[io_u->ddir]++;
if (io_u->offset == f->real_file_size)
goto sync_done;
if (io_u->offset == f->real_file_size)
goto sync_done;
@@
-841,6
+835,13
@@
static int init_io_u(struct thread_data *td)
if (td_write(td) && !td->o.refill_buffers)
io_u_fill_buffer(td, io_u, max_bs);
if (td_write(td) && !td->o.refill_buffers)
io_u_fill_buffer(td, io_u, max_bs);
+ else if (td_write(td) && td->o.verify_pattern_bytes) {
+ /*
+ * Fill the buffer with the pattern if we are
+ * going to be doing writes.
+ */
+ fill_pattern(td, io_u->buf, max_bs, io_u);
+ }
}
io_u->index = i;
}
io_u->index = i;
@@
-1041,6
+1042,15
@@
static void *thread_main(void *data)
*/
fio_mutex_remove(td->mutex);
*/
fio_mutex_remove(td->mutex);
+ if (td->o.uid != -1U && setuid(td->o.uid)) {
+ td_verror(td, errno, "setuid");
+ goto err;
+ }
+ if (td->o.gid != -1U && setgid(td->o.gid)) {
+ td_verror(td, errno, "setgid");
+ goto err;
+ }
+
/*
* May alter parameters that init_io_u() will use, so we need to
* do this first.
/*
* May alter parameters that init_io_u() will use, so we need to
* do this first.
@@
-1178,6
+1188,13
@@
static void *thread_main(void *data)
} else
finish_log(td, td->ts.bw_log, "bw");
}
} else
finish_log(td, td->ts.bw_log, "bw");
}
+ if (td->ts.lat_log) {
+ if (td->o.lat_log_file) {
+ finish_log_named(td, td->ts.lat_log,
+ td->o.lat_log_file, "lat");
+ } else
+ finish_log(td, td->ts.lat_log, "lat");
+ }
if (td->ts.slat_log) {
if (td->o.lat_log_file) {
finish_log_named(td, td->ts.slat_log,
if (td->ts.slat_log) {
if (td->o.lat_log_file) {
finish_log_named(td, td->ts.slat_log,
@@
-1201,7
+1218,7
@@
static void *thread_main(void *data)
err:
if (td->error)
err:
if (td->error)
-
printf
("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
+
log_info
("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
td->verror);
if (td->o.verify_async)
td->verror);
if (td->o.verify_async)
@@
-1367,9
+1384,13
@@
static void *gtod_thread_main(void *data)
static int fio_start_gtod_thread(void)
{
static int fio_start_gtod_thread(void)
{
+ pthread_attr_t attr;
int ret;
int ret;
- ret = pthread_create(>od_thread, NULL, gtod_thread_main, NULL);
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+ ret = pthread_create(>od_thread, &attr, gtod_thread_main, NULL);
+ pthread_attr_destroy(&attr);
if (ret) {
log_err("Can't create gtod thread: %s\n", strerror(ret));
return 1;
if (ret) {
log_err("Can't create gtod thread: %s\n", strerror(ret));
return 1;
@@
-1403,17
+1424,17
@@
static void run_threads(void)
return;
if (!terse_output) {
return;
if (!terse_output) {
-
printf
("Starting ");
+
log_info
("Starting ");
if (nr_thread)
if (nr_thread)
-
printf
("%d thread%s", nr_thread,
+
log_info
("%d thread%s", nr_thread,
nr_thread > 1 ? "s" : "");
if (nr_process) {
if (nr_thread)
printf(" and ");
nr_thread > 1 ? "s" : "");
if (nr_process) {
if (nr_thread)
printf(" and ");
-
printf
("%d process%s", nr_process,
+
log_info
("%d process%s", nr_process,
nr_process > 1 ? "es" : "");
}
nr_process > 1 ? "es" : "");
}
-
printf
("\n");
+
log_info
("\n");
fflush(stdout);
}
fflush(stdout);
}
@@
-1622,6
+1643,7
@@
int main(int argc, char *argv[])
long ps;
sinit();
long ps;
sinit();
+ init_rand(&__fio_rand_state);
/*
* We need locale for number printing, if it isn't set then just
/*
* We need locale for number printing, if it isn't set then just
@@
-1644,6
+1666,9
@@
int main(int argc, char *argv[])
if (parse_options(argc, argv))
return 1;
if (parse_options(argc, argv))
return 1;
+ if (exec_profile && load_profile(exec_profile))
+ return 1;
+
if (!thread_number)
return 0;
if (!thread_number)
return 0;
@@
-1675,8
+1700,7
@@
int main(int argc, char *argv[])
cgroup_kill(cgroup_list);
sfree(cgroup_list);
cgroup_kill(cgroup_list);
sfree(cgroup_list);
- if (cgroup_mnt)
- sfree(cgroup_mnt);
+ sfree(cgroup_mnt);
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);
fio_mutex_remove(startup_mutex);
fio_mutex_remove(writeout_mutex);