[LTP] [PATCH v8 1/2] Rewrite aio-stress test using LTP API
Cyril Hrubis
chrubis@suse.cz
Mon Oct 24 16:42:22 CEST 2022
Hi!
> event_io = t->free_ious;
> t->free_ious = t->free_ious->next;
> if (grab_iou(event_io, oper)) {
> - fprintf(stderr, "io unit on free list but not free\n");
> + tst_res(TINFO, "io unit on free list but not free");
> abort();
tst_brk(TBROK, ...) ?
> }
> return event_io;
> @@ -533,7 +523,8 @@ retry:
> if (nr > 0)
> goto retry;
> else
> - fprintf(stderr, "no free ious after read_some_events\n");
> + tst_res(TINFO, "no free ious after read_some_events");
> +
> return NULL;
> }
...
> /* starts some io for a given file, returns zero if all went well */
> -int run_built(struct thread_info *t, int num_ios, struct iocb **my_iocbs)
> +static int run_built(struct thread_info *t, int num_ios, struct iocb **my_iocbs)
> {
> int ret;
> struct timeval start_time;
> @@ -778,17 +757,17 @@ resubmit:
> */
> if (ret > 0 || ret == -EAGAIN) {
> int old_ret = ret;
> - if ((ret = read_some_events(t) > 0)) {
> +
> + ret = read_some_events(t);
> + if (ret > 0) {
> goto resubmit;
> } else {
> - fprintf(stderr, "ret was %d and now is %d\n",
> - ret, old_ret);
> + tst_res(TINFO, "ret was %d and now is %d", ret, old_ret);
> abort();
> }
> }
>
> - fprintf(stderr, "ret %d (%s) on io_submit\n", ret,
> - strerror(-ret));
> + tst_res(TINFO, "ret %d (%s) on io_submit", ret, tst_strerrno(-ret));
> return -1;
> }
> update_iou_counters(my_iocbs, ret, &stop_time);
> @@ -803,21 +782,18 @@ resubmit:
> static int restart_oper(struct io_oper *oper)
> {
> int new_rw = 0;
> +
> if (oper->last_err)
> return 0;
>
> - /* this switch falls through */
> - switch (oper->rw) {
> - case WRITE:
> - if (stages & (1 << READ))
> - new_rw = READ;
> - case READ:
> - if (!new_rw && stages & (1 << RWRITE))
> - new_rw = RWRITE;
> - case RWRITE:
> - if (!new_rw && stages & (1 << RREAD))
> - new_rw = RREAD;
> - }
> + if (oper->rw == WRITE && (stages & (1 << READ)))
> + new_rw = READ;
> +
> + if (oper->rw == READ && (!new_rw && stages & (1 << RWRITE)))
> + new_rw = RWRITE;
> +
> + if (oper->rw == RWRITE && (!new_rw && stages & (1 << RREAD)))
> + new_rw = RREAD;
Maybe this part would be a bit better with goto as:
if (oper->rv == WRITE && (staves & (1 << READ))) {
new_rw = READ;
goto restart;
}
if (oper->rv == READ && (stages & (1 << RWRITE))) {
new_rw = RWRITE;
goto restart;
}
...
restart:
> if (new_rw) {
> oper->started_ios = 0;
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list