Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
ioengine is file based, you can specify a number of files
by seperating the names with a ':' colon. So if you wanted
a job to open /dev/sda and /dev/sdb as the two working files,
ioengine is file based, you can specify a number of files
by seperating the names with a ':' colon. So if you wanted
a job to open /dev/sda and /dev/sdb as the two working files,
- you would use filename=/dev/sda:/dev/sdb
+ you would use filename=/dev/sda:/dev/sdb. '-' is a reserved
+ name, meaning stdin or stdout. Which of the two depends
+ on the read/write direction set.
opendir=str Tell fio to recursively add any file it can find in this
directory and down the file system tree.
opendir=str Tell fio to recursively add any file it can find in this
directory and down the file system tree.
int generic_open_file(struct thread_data *td, struct fio_file *f)
{
int generic_open_file(struct thread_data *td, struct fio_file *f)
{
+ if (!strcmp(f->file_name, "-")) {
+ if (td_rw(td)) {
+ log_err("fio: can't read/write to stdin/out\n");
+ return 1;
+ }
+ is_std = 1;
+ }
+
if (td->o.odirect)
flags |= OS_O_DIRECT;
if (td->o.sync_io)
if (td->o.odirect)
flags |= OS_O_DIRECT;
if (td->o.sync_io)
if (f->filetype == FIO_TYPE_FILE)
flags |= O_CREAT;
if (f->filetype == FIO_TYPE_FILE)
flags |= O_CREAT;
- f->fd = open(f->file_name, flags, 0600);
+ if (is_std)
+ f->fd = dup(STDOUT_FILENO);
+ else
+ f->fd = open(f->file_name, flags, 0600);
} else {
if (f->filetype == FIO_TYPE_CHAR)
flags |= O_RDWR;
else
flags |= O_RDONLY;
} else {
if (f->filetype == FIO_TYPE_CHAR)
flags |= O_RDWR;
else
flags |= O_RDONLY;
- f->fd = open(f->file_name, flags);
+ if (is_std)
+ f->fd = dup(STDIN_FILENO);
+ else
+ f->fd = open(f->file_name, flags);
- f->filetype = FIO_TYPE_FILE;
+ if (!strcmp(f->file_name, "-"))
+ f->filetype = FIO_TYPE_PIPE;
+ else
+ f->filetype = FIO_TYPE_FILE;
if (!lstat(f->file_name, &sb)) {
if (S_ISBLK(sb.st_mode))
if (!lstat(f->file_name, &sb)) {
if (S_ISBLK(sb.st_mode))
if (--f->references)
return;
if (--f->references)
return;
- if (should_fsync(td) && td->o.fsync_on_close)
+ if (should_fsync(td) && td->o.fsync_on_close &&
+ (f->filetype == FIO_TYPE_FILE || f->filetype == FIO_TYPE_BD))
fsync(f->fd);
if (td->io_ops->close_file)
fsync(f->fd);
if (td->io_ops->close_file)
+ if (f->filetype == FIO_TYPE_PIPE) {
+ if (td_random(td)) {
+ log_err("fio: can't seek on pipes (no random io)\n");
+ goto err;
+ }
+ }
+
f->last_free_lookup = 0;
f->last_completed_pos = 0;
f->last_pos = 0;
f->last_free_lookup = 0;
f->last_completed_pos = 0;
f->last_pos = 0;
if (td->o.invalidate_cache && file_invalidate_cache(td, f))
goto err;
if (td->o.invalidate_cache && file_invalidate_cache(td, f))
goto err;
- if (td->o.fadvise_hint) {
+ if (td->o.fadvise_hint &&
+ (f->filetype == FIO_TYPE_BD || f->filetype == FIO_TYPE_FILE)) {
+
int flags;
if (td_random(td))
int flags;
if (td_random(td))