"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-aio.c" between
stress-ng-0.12.09.tar.xz and stress-ng-0.12.10.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-aio.c  (stress-ng-0.12.09.tar.xz):stress-aio.c  (stress-ng-0.12.10.tar.xz)
skipping to change at line 172 skipping to change at line 172
continue; continue;
pr_err("%s: failed to issue aio request: %d (%s)\n", pr_err("%s: failed to issue aio request: %d (%s)\n",
name, errno, strerror(errno)); name, errno, strerror(errno));
} }
return ret; return ret;
} }
/* Given up */ /* Given up */
return 1; return 1;
} }
#if defined(HAVE_AIO_FSYNC) && \
defined(O_SYNC) && \
defined(O_DSYNC)
/*
* issue_aio_sync_request()
* construct an AIO sync request and action it
*/
static int issue_aio_sync_request(
const char *name,
const int fd,
stress_io_req_t *const io_req)
{
while (keep_stressing_flag()) {
int ret;
const int op = stress_mwc1() ? O_SYNC : O_DSYNC;
io_req->request = 0;
io_req->status = EINPROGRESS;
io_req->aiocb.aio_fildes = fd;
io_req->aiocb.aio_buf = 0;
io_req->aiocb.aio_nbytes = 0;
io_req->aiocb.aio_reqprio = 0;
io_req->aiocb.aio_offset = 0;
io_req->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
io_req->aiocb.aio_sigevent.sigev_signo = SIGUSR1;
io_req->aiocb.aio_sigevent.sigev_value.sival_ptr = io_req;
ret = aio_fsync(op, &io_req->aiocb);
if (ret < 0) {
if ((errno == EAGAIN) || (errno == EINTR))
continue;
pr_err("%s: failed to issue aio request: %d (%s)\n",
name, errno, strerror(errno));
}
return ret;
}
/* Given up */
return 1;
}
#endif
/* /*
* stress_aio * stress_aio
* stress asynchronous I/O * stress asynchronous I/O
*/ */
static int stress_aio(const stress_args_t *args) static int stress_aio(const stress_args_t *args)
{ {
int ret, fd, rc = EXIT_FAILURE; int ret, fd, rc = EXIT_FAILURE;
stress_io_req_t *io_reqs; stress_io_req_t *io_reqs;
struct sigaction sa, sa_old; struct sigaction sa, sa_old;
char filename[PATH_MAX]; char filename[PATH_MAX];
uint32_t total = 0, i, opt_aio_requests = DEFAULT_AIO_REQUESTS; uint32_t total = 0, i, opt_aio_requests = DEFAULT_AIO_REQUESTS;
double t1 = 0.0, t2 = 0.0, dt;
if (!stress_get_setting("aio-requests", &opt_aio_requests)) { if (!stress_get_setting("aio-requests", &opt_aio_requests)) {
if (g_opt_flags & OPT_FLAGS_MAXIMIZE) if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
opt_aio_requests = MAX_AIO_REQUESTS; opt_aio_requests = MAX_AIO_REQUESTS;
if (g_opt_flags & OPT_FLAGS_MINIMIZE) if (g_opt_flags & OPT_FLAGS_MINIMIZE)
opt_aio_requests = MIN_AIO_REQUESTS; opt_aio_requests = MIN_AIO_REQUESTS;
} }
if ((io_reqs = calloc(opt_aio_requests, sizeof(*io_reqs))) == NULL) { if ((io_reqs = calloc(opt_aio_requests, sizeof(*io_reqs))) == NULL) {
pr_err("%s: cannot allocate io request structures\n", args->name) ; pr_err("%s: cannot allocate io request structures\n", args->name) ;
skipping to change at line 234 skipping to change at line 276
aio_fill_buffer((uint8_t)i, io_reqs[i].buffer, BUFFER_SZ); aio_fill_buffer((uint8_t)i, io_reqs[i].buffer, BUFFER_SZ);
ret = issue_aio_request(args->name, fd, (off_t)i * BUFFER_SZ, ret = issue_aio_request(args->name, fd, (off_t)i * BUFFER_SZ,
&io_reqs[i], i, aio_write); &io_reqs[i], i, aio_write);
if (ret < 0) if (ret < 0)
goto cancel; goto cancel;
if (ret > 0) { if (ret > 0) {
rc = EXIT_SUCCESS; rc = EXIT_SUCCESS;
goto cancel; goto cancel;
} }
} }
stress_set_proc_state(args->name, STRESS_STATE_RUN); stress_set_proc_state(args->name, STRESS_STATE_RUN);
t1 = stress_time_now();
do { do {
(void)shim_usleep_interruptible(250000); /* wait until a signal o ccurs */ (void)shim_usleep_interruptible(250000); /* wait until a signal o ccurs */
for (i = 0; keep_stressing(args) && (i < opt_aio_requests); i++) { for (i = 0; keep_stressing(args) && (i < opt_aio_requests); i++) {
if (io_reqs[i].status != EINPROGRESS) if (io_reqs[i].status != EINPROGRESS)
continue; continue;
io_reqs[i].status = aio_error(&io_reqs[i].aiocb); io_reqs[i].status = aio_error(&io_reqs[i].aiocb);
switch (io_reqs[i].status) { switch (io_reqs[i].status) {
case ECANCELED: case ECANCELED:
case 0: case 0:
/* Succeeded or cancelled, so redo another */ /* Succeeded or cancelled, so redo another */
inc_counter(args); inc_counter(args);
if (issue_aio_request(args->name, fd, #if defined(HAVE_AIO_FSYNC) && \
defined(O_SYNC) && \
defined(O_DSYNC)
if (i != (opt_aio_requests - 1)) {
ret = issue_aio_request(args->name, fd,
(off_t)i * BUFFER_SZ,
&io_reqs[i], i,
stress_mwc1() ? aio_read : aio_wr
ite);
} else {
ret = issue_aio_sync_request(args->name,
fd, &io_reqs[i]);
}
#else
ret = issue_aio_request(args->name, fd,
(off_t)i * BUFFER_SZ, &io_reqs[i], i, (off_t)i * BUFFER_SZ, &io_reqs[i], i,
stress_mwc1() ? aio_read : aio_write) < 0 stress_mwc1() ? aio_read : aio_write);
) #endif
if (ret < 0)
goto cancel; goto cancel;
break; break;
case EINPROGRESS: case EINPROGRESS:
break; break;
case ENOSPC: case ENOSPC:
/* Silently ignore ENOSPC write failures */ /* Silently ignore ENOSPC write failures */
break; break;
default: default:
/* Something went wrong */ /* Something went wrong */
pr_fail("%s: aio_error, io_reqs[%" PRIu32 "].stat us = %d (%s)\n", pr_fail("%s: aio_error, io_reqs[%" PRIu32 "].stat us = %d (%s)\n",
args->name, i, args->name, i,
io_reqs[i].status, io_reqs[i].status,
strerror(io_reqs[i].status)); strerror(io_reqs[i].status));
goto cancel; goto cancel;
} }
} }
} while (keep_stressing(args)); } while (keep_stressing(args));
t2 = stress_time_now();
rc = EXIT_SUCCESS; rc = EXIT_SUCCESS;
cancel: cancel:
/* Stop accounting */ /* Stop accounting */
do_accounting = false; do_accounting = false;
/* Cancel pending AIO requests */ /* Cancel pending AIO requests */
for (i = 0; i < opt_aio_requests; i++) { for (i = 0; i < opt_aio_requests; i++) {
aio_issue_cancel(args->name, &io_reqs[i]); aio_issue_cancel(args->name, &io_reqs[i]);
total += io_reqs[i].count; total += io_reqs[i].count;
} }
(void)close(fd); (void)close(fd);
finish: finish:
stress_set_proc_state(args->name, STRESS_STATE_DEINIT); stress_set_proc_state(args->name, STRESS_STATE_DEINIT);
free(io_reqs); free(io_reqs);
pr_dbg("%s: total of %" PRIu32 " async I/O signals " pr_dbg("%s: total of %" PRIu32 " async I/O signals "
"caught (instance %d)\n", "caught (instance %d)\n",
args->name, total, args->instance); args->name, total, args->instance);
dt = t2 - t1;
if (dt > 0.0)
stress_misc_stats_set(args->misc_stats, 0, "async I/O signals per
sec", (double)total / dt);
(void)stress_temp_dir_rm_args(args); (void)stress_temp_dir_rm_args(args);
return rc; return rc;
} }
stressor_info_t stress_aio_info = { stressor_info_t stress_aio_info = {
.stressor = stress_aio, .stressor = stress_aio,
.class = CLASS_IO | CLASS_INTERRUPT | CLASS_OS, .class = CLASS_IO | CLASS_INTERRUPT | CLASS_OS,
.opt_set_funcs = opt_set_funcs, .opt_set_funcs = opt_set_funcs,
.help = help .help = help
}; };
 End of changes. 9 change blocks. 
4 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)