if (!td->odirect) {
if (!td->use_mmap) {
if (fadvise(td->fd, td->file_offset, td->io_size, POSIX_FADV_DONTNEED) < 0) {
- td->error = errno;
+ td_verror(td, errno);
goto out;
}
} else {
if (madvise(td->mmap, td->io_size, MADV_DONTNEED)) {
- td->error = errno;
+ td_verror(td, errno);
goto out;
}
}
if (td->cur_off != io_u->offset) {
if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) {
- td->error = errno;
+ td_verror(td, errno);
break;
}
}
ret = read(td->fd, io_u->buf, io_u->buflen);
if (ret < (int) io_u->buflen) {
if (ret == -1) {
- td->error = errno;
+ td_verror(td, errno);
break;
} else if (!ret)
break;
{
if (td->cur_off != io_u->offset) {
if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
}
if (ret < (int) io_u->buflen) {
if (ret == -1)
- td->error = errno;
+ td_verror(td, errno);
break;
}
rate_throttle(td, usec, io_u->buflen);
if (check_min_rate(td, &e)) {
- td->error = ENODATA;
+ td_verror(td, ENODATA);
break;
}
ret = io_u_queue(td, io_u);
if (ret) {
put_io_u(td, io_u);
- td->error = ret;
+ td_verror(td, ret);
break;
}
ret = io_u_getevents(td, 1, 1, NULL);
if (ret != 1) {
if (ret < 0)
- td->error = ret;
+ td_verror(td, ret);
break;
}
ret = io_u_queue(td, io_u);
if (ret) {
put_io_u(td, io_u);
- td->error = ret;
+ td_verror(td, ret);
break;
}
ret = io_u_getevents(td, min_evts, td->cur_depth, timeout);
if (ret < 0) {
- td->error = ret;
+ td_verror(td, ret);
break;
} else if (!ret)
continue;
rate_throttle(td, usec, bytes_done);
if (check_min_rate(td, &e)) {
- td->error = ENODATA;
+ td_verror(td, ENODATA);
break;
}
static int init_aio(struct thread_data *td)
{
if (io_queue_init(td->aio_depth, &td->aio_ctx)) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
else if (td->mem_type == MEM_SHM) {
td->shm_id = shmget(IPC_PRIVATE, td->orig_buffer_size, IPC_CREAT | 0600);
if (td->shm_id < 0) {
- td->error = errno;
+ td_verror(td, errno);
perror("shmget");
return 1;
}
td->orig_buffer = shmat(td->shm_id, NULL, 0);
if (td->orig_buffer == (void *) -1) {
- td->error = errno;
+ td_verror(td, errno);
perror("shmat");
td->orig_buffer = NULL;
return 1;
} else if (td->mem_type == MEM_MMAP) {
td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (td->orig_buffer == MAP_FAILED) {
- td->error = errno;
+ td_verror(td, errno);
perror("mmap");
td->orig_buffer = NULL;
return 1;
if (!size) {
fprintf(stderr, "Need size for create\n");
- td->error = EINVAL;
+ td_verror(td, EINVAL);
return 1;
}
td->fd = open(td->file_name, O_WRONLY | oflags, 0644);
if (td->fd < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
if (!extend && ftruncate(td->fd, td->file_size) == -1) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
continue;
} else {
if (r < 0)
- td->error = errno;
+ td_verror(td, errno);
else
- td->error = EIO;
+ td_verror(td, EIO);
break;
}
struct stat st;
if (fstat(td->fd, &st) == -1) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
size_t bytes;
if (ioctl(td->fd, BLKGETSIZE64, &bytes) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
td->io_size = td->file_size - td->file_offset;
if (td->io_size == 0) {
fprintf(stderr, "Client%d: no io blocks\n", td->thread_number);
- td->error = EINVAL;
+ td_verror(td, EINVAL);
return 1;
}
td->mmap = mmap(NULL, td->file_size, flags, MAP_SHARED, td->fd, td->file_offset);
if (td->mmap == MAP_FAILED) {
td->mmap = NULL;
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
if (td->invalidate_cache) {
if (madvise(td->mmap, td->file_size, MADV_DONTNEED) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
}
if (td->sequential) {
if (madvise(td->mmap, td->file_size, MADV_SEQUENTIAL) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
} else {
if (madvise(td->mmap, td->file_size, MADV_RANDOM) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
}
{
if (td->invalidate_cache) {
if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_DONTNEED) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
}
if (td->sequential) {
if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
} else {
if (fadvise(td->fd, td->file_offset, td->file_size, POSIX_FADV_RANDOM) < 0) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
}
if (stat(td->file_name, &st) == -1) {
if (errno != ENOENT) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
if (!td->create_file) {
- td->error = ENOENT;
+ td_verror(td, ENOENT);
return 1;
}
if (create_file(td, td->file_size, 0))
}
if (td->fd == -1) {
- td->error = errno;
+ td_verror(td, errno);
return 1;
}
goto err;
if (sched_setaffinity(td->pid, sizeof(td->cpumask), &td->cpumask) == -1) {
- td->error = errno;
+ td_verror(td, errno);
goto err;
}
if (td->ioprio) {
if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) {
- td->error = errno;
+ td_verror(td, errno);
goto err;
}
}
td = &threads[i];
- if (td->error)
+ if (td->error) {
+ printf("Client%d: %s\n", td->thread_number, td->verror);
continue;
+ }
rs = &runstats[td->groupid];