projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use read-writer locks in smalloc
[fio.git]
/
fio.c
diff --git
a/fio.c
b/fio.c
index 6e25c5fe6feb6df17a530b283612e695224437c6..de6132c034a3daa04a64c0b4e60967ccbf99d331 100644
(file)
--- a/
fio.c
+++ b/
fio.c
@@
-36,6
+36,7
@@
#include "fio.h"
#include "hash.h"
#include "fio.h"
#include "hash.h"
+#include "smalloc.h"
unsigned long page_mask;
unsigned long page_size;
unsigned long page_mask;
unsigned long page_size;
@@
-49,7
+50,7
@@
int nr_thread = 0;
int shm_id = 0;
int temp_stall_ts;
int shm_id = 0;
int temp_stall_ts;
-static struct fio_
sem *startup_sem
;
+static struct fio_
mutex *startup_mutex
;
static volatile int fio_abort;
static int exit_value;
static volatile int fio_abort;
static int exit_value;
@@
-82,8
+83,12
@@
static void terminate_threads(int group_id)
*/
if (td->runstate < TD_RUNNING)
kill(td->pid, SIGQUIT);
*/
if (td->runstate < TD_RUNNING)
kill(td->pid, SIGQUIT);
- else if (td->io_ops->flags & FIO_SIGQUIT)
- kill(td->pid, SIGQUIT);
+ else {
+ struct ioengine_ops *ops = td->io_ops;
+
+ if (ops && (ops->flags & FIO_SIGQUIT))
+ kill(td->pid, SIGQUIT);
+ }
}
}
}
}
}
}
@@
-355,7
+360,6
@@
static void do_verify(struct thread_data *td)
io_u->xfer_buflen = io_u->resid;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
io_u->xfer_buflen = io_u->resid;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
- f->last_completed_pos = io_u->offset;
td->ts.short_io_u[io_u->ddir]++;
td->ts.short_io_u[io_u->ddir]++;
@@
-481,7
+485,6
@@
static void do_io(struct thread_data *td)
io_u->xfer_buflen = io_u->resid;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
io_u->xfer_buflen = io_u->resid;
io_u->xfer_buf += bytes;
io_u->offset += bytes;
- f->last_completed_pos = io_u->offset;
td->ts.short_io_u[io_u->ddir]++;
td->ts.short_io_u[io_u->ddir]++;
@@
-783,8
+786,7
@@
static int clear_io_state(struct thread_data *td)
if (td->o.time_based || td->o.loops)
td->nr_done_files = 0;
if (td->o.time_based || td->o.loops)
td->nr_done_files = 0;
- for_each_file(td, f, i)
- td_io_close_file(td, f);
+ close_files(td);
ret = 0;
for_each_file(td, f, i) {
ret = 0;
for_each_file(td, f, i) {
@@
-822,14
+824,14
@@
static void *thread_main(void *data)
td->io_hist_tree = RB_ROOT;
td_set_runstate(td, TD_INITIALIZED);
td->io_hist_tree = RB_ROOT;
td_set_runstate(td, TD_INITIALIZED);
- fio_
sem_up(startup_sem
);
- fio_
sem
_down(td->mutex);
+ fio_
mutex_up(startup_mutex
);
+ fio_
mutex
_down(td->mutex);
/*
/*
- * the ->mutex
semaphore
is now no longer used, close it to avoid
+ * the ->mutex
mutex
is now no longer used, close it to avoid
* eating a file descriptor
*/
* eating a file descriptor
*/
- fio_
sem
_remove(td->mutex);
+ fio_
mutex
_remove(td->mutex);
/*
* May alter parameters that init_io_u() will use, so we need to
/*
* May alter parameters that init_io_u() will use, so we need to
@@
-962,7
+964,7
@@
static void *thread_main(void *data)
err:
if (td->error)
printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
err:
if (td->error)
printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
- close_files(td);
+ close_
and_free_
files(td);
close_ioengine(td);
cleanup_io_u(td);
close_ioengine(td);
cleanup_io_u(td);
@@
-1152,7
+1154,18
@@
static void run_threads(void)
log_err("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
td_set_runstate(td, TD_REAPED);
todo--;
log_err("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
td_set_runstate(td, TD_REAPED);
todo--;
- }
+ } else {
+ struct fio_file *f;
+ unsigned int i;
+
+ /*
+ * for sharing to work, each job must always open
+ * its own files. so close them, if we opened them
+ * for creation
+ */
+ for_each_file(td, f, i)
+ td_io_close_file(td, f);
+ }
init_disk_util(td);
}
init_disk_util(td);
}
@@
-1213,7
+1226,7
@@
static void run_threads(void)
exit(ret);
}
}
exit(ret);
}
}
- fio_
sem_down(startup_sem
);
+ fio_
mutex_down(startup_mutex
);
}
/*
}
/*
@@
-1268,7
+1281,7
@@
static void run_threads(void)
m_rate += td->o.ratemin;
t_rate += td->o.rate;
todo--;
m_rate += td->o.ratemin;
t_rate += td->o.rate;
todo--;
- fio_
sem
_up(td->mutex);
+ fio_
mutex
_up(td->mutex);
}
reap_threads(&nr_running, &t_rate, &m_rate);
}
reap_threads(&nr_running, &t_rate, &m_rate);
@@
-1290,6
+1303,8
@@
int main(int argc, char *argv[])
{
long ps;
{
long ps;
+ sinit();
+
/*
* We need locale for number printing, if it isn't set then just
* go with the US format.
/*
* We need locale for number printing, if it isn't set then just
* go with the US format.
@@
-1317,7
+1332,7
@@
int main(int argc, char *argv[])
setup_log(&agg_io_log[DDIR_WRITE]);
}
setup_log(&agg_io_log[DDIR_WRITE]);
}
- startup_
sem = fio_sem
_init(0);
+ startup_
mutex = fio_mutex
_init(0);
set_genesis_time();
set_genesis_time();
@@
-1333,6
+1348,6
@@
int main(int argc, char *argv[])
}
}
}
}
- fio_
sem_remove(startup_sem
);
+ fio_
mutex_remove(startup_mutex
);
return exit_value;
}
return exit_value;
}