Lines Matching refs:td

140 static int __check_min_rate(struct thread_data *td, struct timeval *now,
153 if (!td->o.ratemin[ddir] && !td->o.rate_iops_min[ddir])
159 if (mtime_since(&td->start, now) < 2000)
162 iops += td->this_io_blocks[ddir];
163 bytes += td->this_io_bytes[ddir];
164 ratemin += td->o.ratemin[ddir];
165 rate_iops += td->o.rate_iops[ddir];
166 rate_iops_min += td->o.rate_iops_min[ddir];
171 if (td->rate_bytes[ddir] || td->rate_blocks[ddir]) {
172 spent = mtime_since(&td->lastrate[ddir], now);
173 if (spent < td->o.ratecycle)
176 if (td->o.rate[ddir]) {
180 if (bytes < td->rate_bytes[ddir]) {
181 log_err("%s: min rate %u not met\n", td->o.name,
186 rate = ((bytes - td->rate_bytes[ddir]) * 1000) / spent;
191 bytes < td->rate_bytes[ddir]) {
193 " %luKB/sec\n", td->o.name,
204 td->o.name, rate_iops);
208 rate = ((iops - td->rate_blocks[ddir]) * 1000) / spent;
213 iops < td->rate_blocks[ddir]) {
215 " got %lu\n", td->o.name,
222 td->rate_bytes[ddir] = bytes;
223 td->rate_blocks[ddir] = iops;
224 memcpy(&td->lastrate[ddir], now, sizeof(*now));
228 static int check_min_rate(struct thread_data *td, struct timeval *now,
234 ret |= __check_min_rate(td, now, DDIR_READ);
236 ret |= __check_min_rate(td, now, DDIR_WRITE);
238 ret |= __check_min_rate(td, now, DDIR_TRIM);
247 static void cleanup_pending_aio(struct thread_data *td)
254 r = io_u_queued_complete(td, 0, NULL);
261 if (td->io_ops->cancel) {
265 io_u_qiter(&td->io_u_all, io_u, i) {
267 r = td->io_ops->cancel(td, io_u);
269 put_io_u(td, io_u);
274 if (td->cur_depth)
275 r = io_u_queued_complete(td, td->cur_depth, NULL);
282 static int fio_io_sync(struct thread_data *td, struct fio_file *f)
284 struct io_u *io_u = __get_io_u(td);
293 if (td_io_prep(td, io_u)) {
294 put_io_u(td, io_u);
299 ret = td_io_queue(td, io_u);
301 td_verror(td, io_u->error, "td_io_queue");
302 put_io_u(td, io_u);
305 if (io_u_queued_complete(td, 1, NULL) < 0)
309 td_verror(td, io_u->error, "td_io_queue");
313 if (io_u_sync_complete(td, io_u, NULL) < 0)
316 if (td_io_commit(td))
324 static int fio_file_fsync(struct thread_data *td, struct fio_file *f)
329 return fio_io_sync(td, f);
331 if (td_io_open_file(td, f))
334 ret = fio_io_sync(td, f);
335 td_io_close_file(td, f);
339 static inline void __update_tv_cache(struct thread_data *td)
341 fio_gettime(&td->tv_cache, NULL);
344 static inline void update_tv_cache(struct thread_data *td)
346 if ((++td->tv_cache_nr & td->tv_cache_mask) == td->tv_cache_mask)
347 __update_tv_cache(td);
350 static inline int runtime_exceeded(struct thread_data *td, struct timeval *t)
352 if (in_ramp_time(td))
354 if (!td->o.timeout)
356 if (utime_since(&td->epoch, t) >= td->o.timeout)
362 static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir,
367 if (ret < 0 || td->error) {
368 int err = td->error;
375 if (!(td->o.continue_on_error & (1 << eb)))
378 if (td_non_fatal_error(td, eb, err)) {
383 update_error_count(td, err);
384 td_clear_error(td);
387 } else if (td->o.fill_device && err == ENOSPC) {
392 td_clear_error(td);
393 td->terminate = 1;
400 update_error_count(td, err);
408 static void check_update_rusage(struct thread_data *td)
410 if (td->update_rusage) {
411 td->update_rusage = 0;
412 update_rusage_stat(td);
413 fio_mutex_up(td->rusage_sem);
421 static void do_verify(struct thread_data *td, uint64_t verify_bytes)
435 for_each_file(td, f, i) {
438 if (fio_io_sync(td, f))
440 if (file_invalidate_cache(td, f))
444 check_update_rusage(td);
446 if (td->error)
449 td_set_runstate(td, TD_VERIFYING);
452 while (!td->terminate) {
456 update_tv_cache(td);
457 check_update_rusage(td);
459 if (runtime_exceeded(td, &td->tv_cache)) {
460 __update_tv_cache(td);
461 if (runtime_exceeded(td, &td->tv_cache)) {
462 td->terminate = 1;
467 if (flow_threshold_exceeded(td))
470 if (!td->o.experimental_verify) {
471 io_u = __get_io_u(td);
475 if (get_next_verify(td, io_u)) {
476 put_io_u(td, io_u);
480 if (td_io_prep(td, io_u)) {
481 put_io_u(td, io_u);
485 if (ddir_rw_sum(bytes_done) + td->o.rw_min_bs > verify_bytes)
488 while ((io_u = get_io_u(td)) != NULL) {
505 td->io_issues[DDIR_READ]++;
506 put_io_u(td, io_u);
516 put_io_u(td, io_u);
525 if (td->o.verify_async)
532 ret = td_io_queue(td, io_u);
537 clear_io_u(td, io_u);
545 td_verror(td, EIO, "full resid");
546 put_io_u(td, io_u);
555 td->ts.short_io_u[io_u->ddir]++;
561 requeue_io_u(td, &io_u);
564 ret = io_u_sync_complete(td, io_u, bytes_done);
572 requeue_io_u(td, &io_u);
573 ret2 = td_io_commit(td);
579 td_verror(td, -ret, "td_io_queue");
583 if (break_on_this_error(td, ddir, &ret))
592 full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth);
593 if (full || !td->o.iodepth_batch_complete) {
594 min_events = min(td->o.iodepth_batch_complete,
595 td->cur_depth);
608 if (io_u_queued_complete(td, min_events, bytes_done) < 0) {
612 } while (full && (td->cur_depth > td->o.iodepth_low));
618 check_update_rusage(td);
620 if (!td->error) {
621 min_events = td->cur_depth;
624 ret = io_u_queued_complete(td, min_events, NULL);
626 cleanup_pending_aio(td);
628 td_set_runstate(td, TD_RUNNING);
633 static unsigned int exceeds_number_ios(struct thread_data *td)
637 if (!td->o.number_ios)
640 number_ios = ddir_rw_sum(td->this_io_blocks);
641 number_ios += td->io_u_queued + td->io_u_in_flight;
643 return number_ios >= td->o.number_ios;
646 static int io_bytes_exceeded(struct thread_data *td)
650 if (td_rw(td))
651 bytes = td->this_io_bytes[DDIR_READ] + td->this_io_bytes[DDIR_WRITE];
652 else if (td_write(td))
653 bytes = td->this_io_bytes[DDIR_WRITE];
654 else if (td_read(td))
655 bytes = td->this_io_bytes[DDIR_READ];
657 bytes = td->this_io_bytes[DDIR_TRIM];
659 if (td->o.io_limit)
660 limit = td->o.io_limit;
662 limit = td->o.size;
664 return bytes >= limit || exceeds_number_ios(td);
673 static uint64_t do_io(struct thread_data *td)
680 if (in_ramp_time(td))
681 td_set_runstate(td, TD_RAMP);
683 td_set_runstate(td, TD_RUNNING);
685 lat_target_init(td);
692 total_bytes = td->o.size;
693 if (td->o.verify != VERIFY_NONE &&
694 (td_write(td) && td->o.verify_backlog))
695 total_bytes += td->o.size;
697 while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
698 (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) ||
699 td->o.time_based) {
706 check_update_rusage(td);
708 if (td->terminate || td->done)
711 update_tv_cache(td);
713 if (runtime_exceeded(td, &td->tv_cache)) {
714 __update_tv_cache(td);
715 if (runtime_exceeded(td, &td->tv_cache)) {
716 td->terminate = 1;
721 if (flow_threshold_exceeded(td))
727 io_u = get_io_u(td);
736 if (td->o.latency_target)
745 * - Asked to verify (!td_rw(td))
748 if (td->o.verify != VERIFY_NONE && io_u->ddir == DDIR_READ &&
749 ((io_u->flags & IO_U_F_VER_LIST) || !td_rw(td))) {
751 if (!td->o.verify_pattern_bytes) {
752 io_u->rand_seed = __rand(&td->__verify_state);
754 io_u->rand_seed *= __rand(&td->__verify_state);
757 if (td->o.verify_async)
761 td_set_runstate(td, TD_VERIFYING);
762 } else if (in_ramp_time(td))
763 td_set_runstate(td, TD_RAMP);
765 td_set_runstate(td, TD_RUNNING);
772 if (td_write(td) && io_u->ddir == DDIR_WRITE &&
773 td->o.do_verify &&
774 td->o.verify != VERIFY_NONE &&
775 !td->o.experimental_verify)
776 log_io_piece(td, io_u);
778 ret = td_io_queue(td, io_u);
783 unlog_io_piece(td, io_u);
784 clear_io_u(td, io_u);
791 trim_io_piece(td, io_u);
797 unlog_io_piece(td, io_u);
798 td_verror(td, EIO, "full resid");
799 put_io_u(td, io_u);
808 td->ts.short_io_u[io_u->ddir]++;
813 requeue_io_u(td, &io_u);
816 if (__should_check_rate(td, DDIR_READ) ||
817 __should_check_rate(td, DDIR_WRITE) ||
818 __should_check_rate(td, DDIR_TRIM))
821 ret = io_u_sync_complete(td, io_u, bytes_done);
833 if (td->io_ops->commit == NULL)
834 io_u_queued(td, io_u);
838 unlog_io_piece(td, io_u);
839 requeue_io_u(td, &io_u);
840 ret2 = td_io_commit(td);
846 put_io_u(td, io_u);
850 if (break_on_this_error(td, ddir, &ret))
859 full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth);
860 if (full || !td->o.iodepth_batch_complete) {
861 min_evts = min(td->o.iodepth_batch_complete,
862 td->cur_depth);
869 if (__should_check_rate(td, DDIR_READ) ||
870 __should_check_rate(td, DDIR_WRITE) ||
871 __should_check_rate(td, DDIR_TRIM))
875 ret = io_u_queued_complete(td, min_evts, bytes_done);
879 } while (full && (td->cur_depth > td->o.iodepth_low));
884 if (!ddir_rw_sum(bytes_done) && !(td->io_ops->flags & FIO_NOIO))
887 if (!in_ramp_time(td) && should_check_rate(td, bytes_done)) {
888 if (check_min_rate(td, &comp_time, bytes_done)) {
890 fio_terminate_threads(td->groupid);
891 td_verror(td, EIO, "check_min_rate");
895 if (!in_ramp_time(td) && td->o.latency_target)
896 lat_target_check(td);
898 if (td->o.thinktime) {
901 b = ddir_rw_sum(td->io_blocks);
902 if (!(b % td->o.thinktime_blocks)) {
905 io_u_quiesce(td);
907 if (td->o.thinktime_spin)
908 usec_spin(td->o.thinktime_spin);
910 left = td->o.thinktime - td->o.thinktime_spin;
912 usec_sleep(td, left);
917 check_update_rusage(td);
919 if (td->trim_entries)
920 log_err("fio: %lu trim entries leaked?\n", td->trim_entries);
922 if (td->o.fill_device && td->error == ENOSPC) {
923 td->error = 0;
924 td->terminate = 1;
926 if (!td->error) {
929 i = td->cur_depth;
931 ret = io_u_queued_complete(td, i, bytes_done);
932 if (td->o.fill_device && td->error == ENOSPC)
933 td->error = 0;
936 if (should_fsync(td) && td->o.end_fsync) {
937 td_set_runstate(td, TD_FSYNCING);
939 for_each_file(td, f, i) {
940 if (!fio_file_fsync(td, f))
948 cleanup_pending_aio(td);
953 if (!ddir_rw_sum(td->this_io_bytes))
954 td->done = 1;
959 static void cleanup_io_u(struct thread_data *td)
963 while ((io_u = io_u_qpop(&td->io_u_freelist)) != NULL) {
965 if (td->io_ops->io_u_free)
966 td->io_ops->io_u_free(td, io_u);
971 free_io_mem(td);
973 io_u_rexit(&td->io_u_requeues);
974 io_u_qexit(&td->io_u_freelist);
975 io_u_qexit(&td->io_u_all);
978 static int init_io_u(struct thread_data *td)
986 max_units = td->o.iodepth;
987 max_bs = td_max_bs(td);
988 min_write = td->o.min_bs[DDIR_WRITE];
989 td->orig_buffer_size = (unsigned long long) max_bs
992 if ((td->io_ops->flags & FIO_NOIO) || !(td_read(td) || td_write(td)))
996 err += io_u_rinit(&td->io_u_requeues, td->o.iodepth);
997 err += io_u_qinit(&td->io_u_freelist, td->o.iodepth);
998 err += io_u_qinit(&td->io_u_all, td->o.iodepth);
1011 if (td->o.odirect || td->o.mem_align || td->o.oatomic ||
1012 (td->io_ops->flags & FIO_RAWIO))
1013 td->orig_buffer_size += page_mask + td->o.mem_align;
1015 if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE) {
1018 bs = td->orig_buffer_size + td->o.hugepage_size - 1;
1019 td->orig_buffer_size = bs & ~(td->o.hugepage_size - 1);
1022 if (td->orig_buffer_size != (size_t) td->orig_buffer_size) {
1027 if (data_xfer && allocate_io_mem(td))
1030 if (td->o.odirect || td->o.mem_align || td->o.oatomic ||
1031 (td->io_ops->flags & FIO_RAWIO))
1032 p = PAGE_ALIGN(td->orig_buffer) + td->o.mem_align;
1034 p = td->orig_buffer;
1041 if (td->terminate)
1059 if (td_write(td))
1060 io_u_fill_buffer(td, io_u, min_write, max_bs);
1061 if (td_write(td) && td->o.verify_pattern_bytes) {
1066 fill_verify_pattern(td, io_u->buf, max_bs, io_u, 0, 0);
1072 io_u_qpush(&td->io_u_freelist, io_u);
1078 io_u_qpush(&td->io_u_all, io_u);
1080 if (td->io_ops->io_u_init) {
1081 int ret = td->io_ops->io_u_init(td, io_u);
1095 static int switch_ioscheduler(struct thread_data *td)
1101 if (td->io_ops->flags & FIO_DISKLESSIO)
1104 sprintf(tmp, "%s/queue/scheduler", td->sysfs_root);
1113 td_verror(td, errno, "fopen iosched");
1120 ret = fwrite(td->o.ioscheduler, strlen(td->o.ioscheduler), 1, f);
1122 td_verror(td, errno, "fwrite");
1134 td_verror(td, errno, "fread");
1141 sprintf(tmp2, "[%s]", td->o.ioscheduler);
1143 log_err("fio: io scheduler %s not found\n", td->o.ioscheduler);
1144 td_verror(td, EINVAL, "iosched_switch");
1153 static int keep_running(struct thread_data *td)
1157 if (td->done)
1159 if (td->o.time_based)
1161 if (td->o.loops) {
1162 td->o.loops--;
1165 if (exceeds_number_ios(td))
1168 if (td->o.io_limit)
1169 limit = td->o.io_limit;
1171 limit = td->o.size;
1173 if (limit != -1ULL && ddir_rw_sum(td->io_bytes) < limit) {
1180 diff = limit - ddir_rw_sum(td->io_bytes);
1181 if (diff < td_max_bs(td))
1184 if (fio_files_done(td))
1213 static uint64_t do_dry_run(struct thread_data *td)
1217 td_set_runstate(td, TD_RUNNING);
1219 while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
1220 (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) {
1224 if (td->terminate || td->done)
1227 io_u = get_io_u(td);
1235 td->io_issues[acct_ddir(io_u)]++;
1237 io_u_mark_depth(td, 1);
1238 td->ts.total_io_u[io_u->ddir]++;
1241 if (td_write(td) && io_u->ddir == DDIR_WRITE &&
1242 td->o.do_verify &&
1243 td->o.verify != VERIFY_NONE &&
1244 !td->o.experimental_verify)
1245 log_io_piece(td, io_u);
1247 ret = io_u_sync_complete(td, io_u, bytes_done);
1261 struct thread_data *td = data;
1262 struct thread_options *o = &td->o;
1269 td->pid = getpid();
1271 td->pid = gettid();
1280 dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
1283 fio_server_send_start(td);
1285 INIT_FLIST_HEAD(&td->io_log_list);
1286 INIT_FLIST_HEAD(&td->io_hist_list);
1287 INIT_FLIST_HEAD(&td->verify_list);
1288 INIT_FLIST_HEAD(&td->trim_list);
1289 INIT_FLIST_HEAD(&td->next_rand_list);
1290 pthread_mutex_init(&td->io_u_lock, NULL);
1291 td->io_hist_tree = RB_ROOT;
1294 pthread_cond_init(&td->verify_cond, &attr);
1295 pthread_cond_init(&td->free_cond, &attr);
1297 td_set_runstate(td, TD_INITIALIZED);
1300 dprint(FD_MUTEX, "wait on td->mutex\n");
1301 fio_mutex_down(td->mutex);
1302 dprint(FD_MUTEX, "done waiting on td->mutex\n");
1309 td_verror(td, errno, "setgid");
1313 td_verror(td, errno, "setuid");
1330 ret = fio_cpus_split(&o->cpumask, td->thread_number - 1);
1334 td_verror(td, EINVAL, "cpus_split");
1338 ret = fio_setaffinity(td->pid, o->cpumask);
1340 td_verror(td, errno, "cpu_set_affinity");
1352 td_verror(td, errno, "Does not support NUMA API\n");
1361 td_verror(td, errno, \
1398 if (fio_pin_memory(td))
1405 if (init_iolog(td))
1408 if (init_io_u(td))
1411 if (o->verify_async && verify_async_init(td))
1417 td_verror(td, errno, "ioprio_set");
1422 if (o->cgroup && cgroup_setup(td, cgroup_list, &cgroup_mnt))
1427 td_verror(td, errno, "nice");
1431 if (o->ioscheduler && switch_ioscheduler(td))
1434 if (!o->create_serialize && setup_files(td))
1437 if (td_io_init(td))
1440 if (init_random_map(td))
1447 if (pre_read_files(td) < 0)
1451 fio_verify_init(td);
1453 fio_gettime(&td->epoch, NULL);
1454 fio_getrusage(&td->ru_start);
1456 while (keep_running(td)) {
1459 fio_gettime(&td->start, NULL);
1460 memcpy(&td->bw_sample_time, &td->start, sizeof(td->start));
1461 memcpy(&td->iops_sample_time, &td->start, sizeof(td->start));
1462 memcpy(&td->tv_cache, &td->start, sizeof(td->start));
1466 memcpy(&td->lastrate[DDIR_READ], &td->bw_sample_time,
1467 sizeof(td->bw_sample_time));
1468 memcpy(&td->lastrate[DDIR_WRITE], &td->bw_sample_time,
1469 sizeof(td->bw_sample_time));
1470 memcpy(&td->lastrate[DDIR_TRIM], &td->bw_sample_time,
1471 sizeof(td->bw_sample_time));
1475 clear_io_state(td);
1477 prune_io_piece_log(td);
1479 if (td->o.verify_only && (td_write(td) || td_rw(td)))
1480 verify_bytes = do_dry_run(td);
1482 verify_bytes = do_io(td);
1486 if (td_read(td) && td->io_bytes[DDIR_READ]) {
1487 elapsed = utime_since_now(&td->start);
1488 td->ts.runtime[DDIR_READ] += elapsed;
1490 if (td_write(td) && td->io_bytes[DDIR_WRITE]) {
1491 elapsed = utime_since_now(&td->start);
1492 td->ts.runtime[DDIR_WRITE] += elapsed;
1494 if (td_trim(td) && td->io_bytes[DDIR_TRIM]) {
1495 elapsed = utime_since_now(&td->start);
1496 td->ts.runtime[DDIR_TRIM] += elapsed;
1499 if (td->error || td->terminate)
1504 (td->io_ops->flags & FIO_UNIDIR))
1507 clear_io_state(td);
1509 fio_gettime(&td->start, NULL);
1511 do_verify(td, verify_bytes);
1513 td->ts.runtime[DDIR_READ] += utime_since_now(&td->start);
1515 if (td->error || td->terminate)
1519 update_rusage_stat(td);
1520 td->ts.runtime[DDIR_READ] = (td->ts.runtime[DDIR_READ] + 999) / 1000;
1521 td->ts.runtime[DDIR_WRITE] = (td->ts.runtime[DDIR_WRITE] + 999) / 1000;
1522 td->ts.runtime[DDIR_TRIM] = (td->ts.runtime[DDIR_TRIM] + 999) / 1000;
1523 td->ts.total_run_time = mtime_since_now(&td->epoch);
1524 td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ];
1525 td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE];
1526 td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
1528 fio_unpin_memory(td);
1530 fio_writeout_logs(td);
1536 fio_terminate_threads(td->groupid);
1539 if (td->error)
1540 log_info("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
1541 td->verror);
1544 verify_async_exit(td);
1546 close_and_free_files(td);
1547 cleanup_io_u(td);
1548 close_ioengine(td);
1549 cgroup_shutdown(td, &cgroup_mnt);
1554 td_verror(td, ret, "fio_cpuset_exit");
1561 write_iolog_close(td);
1563 fio_mutex_remove(td->rusage_sem);
1564 td->rusage_sem = NULL;
1566 fio_mutex_remove(td->mutex);
1567 td->mutex = NULL;
1569 td_set_runstate(td, TD_EXITED);
1570 return (void *) (uintptr_t) td->error;
1575 * We cannot pass the td data into a forked process, so attach the td and
1580 struct thread_data *td;
1598 td = data + offset * sizeof(struct thread_data);
1599 ret = thread_main(td);
1610 struct thread_data *td;
1618 for_each_td(td, i) {
1625 if (td->io_ops && !strcmp(td->io_ops->name, "cpuio"))
1630 if (!td->pid) {
1634 if (td->runstate == TD_REAPED)
1636 if (td->o.use_thread) {
1637 if (td->runstate == TD_EXITED) {
1638 td_set_runstate(td, TD_REAPED);
1645 if (td->runstate == TD_EXITED)
1651 ret = waitpid(td->pid, &status, flags);
1655 (int) td->pid, td->runstate);
1656 td->sig = ECHILD;
1657 td_set_runstate(td, TD_REAPED);
1661 } else if (ret == td->pid) {
1667 (int) td->pid, sig);
1668 td->sig = sig;
1669 td_set_runstate(td, TD_REAPED);
1673 if (WEXITSTATUS(status) && !td->error)
1674 td->error = WEXITSTATUS(status);
1676 td_set_runstate(td, TD_REAPED);
1688 (*m_rate) -= ddir_rw_sum(td->o.ratemin);
1689 (*t_rate) -= ddir_rw_sum(td->o.rate);
1690 if (!td->pid)
1693 if (td->error)
1696 done_secs += mtime_since_now(&td->epoch) / 1000;
1697 profile_td_exit(td);
1715 struct thread_data *td;
1727 for_each_td(td, i) {
1728 if (td->o.use_thread)
1754 for_each_td(td, i) {
1755 print_status_init(td->thread_number - 1);
1757 if (!td->o.create_serialize)
1765 if (setup_files(td)) {
1767 if (td->error)
1769 (int) td->pid, td->error, td->verror);
1770 td_set_runstate(td, TD_REAPED);
1781 for_each_file(td, f, j) {
1783 td_io_close_file(td, f);
1801 for_each_td(td, i) {
1802 if (td->runstate != TD_NOT_CREATED)
1809 if (td->terminate) {
1814 if (td->o.start_delay) {
1817 if (td->o.start_delay > spent)
1821 if (td->o.stonewall && (nr_started || nr_running)) {
1823 td->o.name);
1827 init_disk_util(td);
1829 td->rusage_sem = fio_mutex_init(FIO_MUTEX_LOCKED);
1830 td->update_rusage = 0;
1836 td_set_runstate(td, TD_CREATED);
1837 map[this_jobs++] = td;
1840 if (td->o.use_thread) {
1844 ret = pthread_create(&td->thread, NULL,
1845 thread_main, td);
1852 ret = pthread_detach(td->thread);
1891 td = map[i];
1892 if (!td)
1894 if (td->runstate == TD_INITIALIZED) {
1897 } else if (td->runstate >= TD_EXITED) {
1910 td = map[i];
1911 if (!td)
1913 kill(td->pid, SIGTERM);
1921 for_each_td(td, i) {
1922 if (td->runstate != TD_INITIALIZED)
1925 if (in_ramp_time(td))
1926 td_set_runstate(td, TD_RAMP);
1928 td_set_runstate(td, TD_RUNNING);
1931 m_rate += ddir_rw_sum(td->o.ratemin);
1932 t_rate += ddir_rw_sum(td->o.rate);
1934 fio_mutex_up(td->mutex);
2015 struct thread_data *td;
2057 for_each_td(td, i)
2058 fio_options_free(td);