Lines Matching refs:oper
310 static void oper_list_add(struct io_oper *oper, struct io_oper **list) in oper_list_add() argument
313 *list = oper; in oper_list_add()
314 oper->prev = oper->next = oper; in oper_list_add()
317 oper->prev = (*list)->prev; in oper_list_add()
318 oper->next = *list; in oper_list_add()
319 (*list)->prev->next = oper; in oper_list_add()
320 (*list)->prev = oper; in oper_list_add()
324 static void oper_list_del(struct io_oper *oper, struct io_oper **list) in oper_list_del() argument
330 oper->prev->next = oper->next; in oper_list_del()
331 oper->next->prev = oper->prev; in oper_list_del()
332 if (*list == oper) in oper_list_del()
333 *list = oper->next; in oper_list_del()
377 static int grab_iou(struct io_unit *io, struct io_oper *oper) { in grab_iou() argument
383 io->io_oper = oper; in grab_iou()
401 static inline double oper_mb_trans(struct io_oper *oper) { in oper_mb_trans() argument
402 return ((double)oper->started_ios * (double)oper->reclen) / in oper_mb_trans()
406 static void print_time(struct io_oper *oper) { in print_time() argument
411 runtime = time_since_now(&oper->start_time); in print_time()
412 mb = oper_mb_trans(oper); in print_time()
415 stage_name(oper->rw), oper->file_name, tput, mb, runtime); in print_time()
453 struct io_oper *oper = io->io_oper; in finish_io() local
460 oper->num_pending--; in finish_io()
463 if (oper->num_pending == 0 && in finish_io()
464 (oper->started_ios == oper->total_ios || oper->stonewalled)) in finish_io()
466 print_time(oper); in finish_io()
502 static struct io_unit *find_iou(struct thread_info *t, struct io_oper *oper) in find_iou() argument
511 if (grab_iou(event_io, oper)) { in find_iou()
528 static int io_oper_wait(struct thread_info *t, struct io_oper *oper) { argument
532 if (oper == NULL) {
536 if (oper->num_pending == 0)
553 if (oper->num_pending == 0)
557 if (oper->num_err) {
559 oper->num_err, oper->last_err);
564 off_t random_byte_offset(struct io_oper *oper) { argument
566 off_t rand_byte = oper->start;
570 range = (oper->end - oper->start) / (1024 * 1024);
589 if (rand_byte + oper->reclen > oper->end) {
590 rand_byte -= oper->reclen;
603 static struct io_unit *build_iocb(struct thread_info *t, struct io_oper *oper) argument
608 io = find_iou(t, oper);
614 switch(oper->rw) {
616 io_prep_pwrite(&io->iocb,oper->fd, io->buf, oper->reclen,
617 oper->last_offset);
618 oper->last_offset += oper->reclen;
621 io_prep_pread(&io->iocb,oper->fd, io->buf, oper->reclen,
622 oper->last_offset);
623 oper->last_offset += oper->reclen;
626 rand_byte = random_byte_offset(oper);
627 oper->last_offset = rand_byte;
628 io_prep_pread(&io->iocb,oper->fd, io->buf, oper->reclen,
632 rand_byte = random_byte_offset(oper);
633 oper->last_offset = rand_byte;
634 io_prep_pwrite(&io->iocb,oper->fd, io->buf, oper->reclen,
648 finish_oper(struct thread_info *t, struct io_oper *oper) argument
652 io_oper_wait(t, oper);
653 last_err = oper->last_err;
654 if (oper->num_pending > 0) {
655 fprintf(stderr, "oper num_pending is %d\n", oper->num_pending);
657 close(oper->fd);
658 free(oper);
670 struct io_oper *oper; local
672 oper = malloc (sizeof(*oper));
673 if (!oper) {
677 memset(oper, 0, sizeof(*oper));
679 oper->depth = depth;
680 oper->start = start;
681 oper->end = end;
682 oper->last_offset = oper->start;
683 oper->fd = fd;
684 oper->reclen = reclen;
685 oper->rw = rw;
686 oper->total_ios = (oper->end - oper->start) / oper->reclen;
687 oper->file_name = file_name;
689 return oper;
696 int build_oper(struct thread_info *t, struct io_oper *oper, int num_ios, argument
702 if (oper->started_ios == 0)
703 gettimeofday(&oper->start_time, NULL);
706 num_ios = oper->total_ios;
708 if ((oper->started_ios + num_ios) > oper->total_ios)
709 num_ios = oper->total_ios - oper->started_ios;
712 io = build_iocb(t, oper);
785 static int restart_oper(struct io_oper *oper) { argument
787 if (oper->last_err)
791 switch(oper->rw) {
804 oper->started_ios = 0;
805 oper->last_offset = oper->start;
806 oper->stonewalled = 0;
812 if (oper->num_pending)
813 print_time(oper);
815 oper->rw = new_rw;
821 static int oper_runnable(struct io_oper *oper) { argument
828 if (oper->started_ios || oper->start == 0)
832 if (oper->rw >= RWRITE)
834 ret = fstat(oper->fd, &buf);
839 if (S_ISREG(buf.st_mode) && buf.st_size < oper->start)
859 struct io_oper *oper; local
865 oper = t->active_opers;
866 while(oper) {
867 if (!oper_runnable(oper)) {
868 oper = oper->next;
869 if (oper == t->active_opers)
873 ret = build_oper(t, oper, io_iter, my_iocbs);
877 oper_list_del(oper, &t->active_opers);
878 oper_list_add(oper, &built_opers);
879 oper = t->active_opers;
892 oper = built_opers;
893 oper_list_del(oper, &built_opers);
894 oper_list_add(oper, &t->active_opers);
895 if (oper->started_ios == oper->total_ios) {
896 oper_list_del(oper, &t->active_opers);
897 oper_list_add(oper, &t->finished_opers);
1096 struct io_oper *oper; local
1128 oper = t->active_opers;
1129 oper->stonewalled = 1;
1130 oper_list_del(oper, &t->active_opers);
1131 oper_list_add(oper, &t->finished_opers);
1144 oper = t->finished_opers;
1146 if (!oper)
1148 io_oper_wait(t, oper);
1149 oper = oper->next;
1150 } while(oper != t->finished_opers);
1155 oper = t->finished_opers;
1156 while(oper) {
1158 fsync(oper->fd);
1159 t->stage_mb_trans += oper_mb_trans(oper);
1160 if (restart_oper(oper)) {
1161 oper_list_del(oper, &t->finished_opers);
1162 oper_list_add(oper, &t->active_opers);
1163 oper = t->finished_opers;
1166 oper = oper->next;
1167 if (oper == t->finished_opers)
1199 oper = t->finished_opers;
1200 oper_list_del(oper, &t->finished_opers);
1201 status = finish_oper(t, oper);
1309 struct io_oper *oper; local
1475 oper = create_oper(rwfd, first_stage, j * context_offset,
1478 if (!oper) {
1482 oper_list_add(oper, &t[thread_index].active_opers);