Add more context to the error messages
authorJens Axboe <jens.axboe@oracle.com>
Thu, 22 Feb 2007 18:36:48 +0000 (19:36 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 22 Feb 2007 18:36:48 +0000 (19:36 +0100)
Errors like:

fio: pid=0, err=22/file:filesetup.c:380, error=Invalid argument

do not give a lot of clue as to what is wrong, unless you
have a matching source. So add a context relevant info
message as well.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
16 files changed:
engines/cpu.c
engines/libaio.c
engines/mmap.c
engines/net.c
engines/posixaio.c
engines/sg.c
engines/splice.c
engines/sync.c
engines/syslet-rw.c
filesetup.c
fio.c
fio.h
init.c
io_u.c
ioengines.c
memory.c

index 27ec6da1f261575bdd98999cacb81184e2c78d77..6ad547b60ad597cf2e06c27c08e05960692914ef 100644 (file)
@@ -9,7 +9,7 @@ static int fio_cpuio_setup(struct thread_data fio_unused *td)
 static int fio_cpuio_init(struct thread_data *td)
 {
        if (!td->cpuload) {
 static int fio_cpuio_init(struct thread_data *td)
 {
        if (!td->cpuload) {
-               td_vmsg(td, EINVAL, "cpu thread needs rate");
+               td_vmsg(td, EINVAL, "cpu thread needs rate", "cpu_load");
                return 1;
        } else if (td->cpuload > 100)
                td->cpuload = 100;
                return 1;
        } else if (td->cpuload > 100)
                td->cpuload = 100;
index a659ba9bc141890b57ff0b29180eb446bf6dc17f..bd702e30f132ab082a69add4b729ca9e6dd6d9b5 100644 (file)
@@ -178,7 +178,7 @@ static int fio_libaio_init(struct thread_data *td)
 
        memset(ld, 0, sizeof(*ld));
        if (io_queue_init(td->iodepth, &ld->aio_ctx)) {
 
        memset(ld, 0, sizeof(*ld));
        if (io_queue_init(td->iodepth, &ld->aio_ctx)) {
-               td_verror(td, errno);
+               td_verror(td, errno, "io_queue_init");
                free(ld);
                return 1;
        }
                free(ld);
                return 1;
        }
index 08bbd991463d4e8546ea40a31d14b9213ffd0d11..d4299143ecccb02cc17c43147a09b8e873dea086 100644 (file)
@@ -37,7 +37,7 @@ static int fio_mmapio_queue(struct thread_data *td, struct io_u *io_u)
        }
 
        if (io_u->error)
        }
 
        if (io_u->error)
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "sync");
 
        return FIO_Q_COMPLETED;
 }
 
        return FIO_Q_COMPLETED;
 }
@@ -56,7 +56,7 @@ static int fio_mmapio_init(struct thread_data *td)
         */
        for_each_file(td, f, i) {
                if (ftruncate(f->fd, f->file_size) < 0) {
         */
        for_each_file(td, f, i) {
                if (ftruncate(f->fd, f->file_size) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "ftruncate");
                        return 1;
                }
        }
                        return 1;
                }
        }
index 381c731c9bf3892c9261aabcb45bf0d5812f21a2..55b2128e8b3f8c1fdc26fea9a0c331762a81e7be 100644 (file)
@@ -25,7 +25,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u)
         */
        if ((send_to_net(td) && io_u->ddir == DDIR_READ) ||
            (!send_to_net(td) && io_u->ddir == DDIR_WRITE)) {
         */
        if ((send_to_net(td) && io_u->ddir == DDIR_READ) ||
            (!send_to_net(td) && io_u->ddir == DDIR_WRITE)) {
-               td_verror(td, EINVAL);
+               td_verror(td, EINVAL, "bad direction");
                return 1;
        }
                
                return 1;
        }
                
@@ -38,7 +38,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u)
         * If offset is different from last end position, it's a seek.
         * As network io is purely sequential, we don't allow seeks.
         */
         * If offset is different from last end position, it's a seek.
         * As network io is purely sequential, we don't allow seeks.
         */
-       td_verror(td, EINVAL);
+       td_verror(td, EINVAL, "cannot seek");
        return 1;
 }
 
        return 1;
 }
 
@@ -72,7 +72,7 @@ static int fio_netio_queue(struct thread_data *td, struct io_u *io_u)
        }
 
        if (io_u->error)
        }
 
        if (io_u->error)
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
 
        return FIO_Q_COMPLETED;
 }
 
        return FIO_Q_COMPLETED;
 }
@@ -93,7 +93,7 @@ static int fio_netio_setup_connect(struct thread_data *td, const char *host,
 
                hent = gethostbyname(host);
                if (!hent) {
 
                hent = gethostbyname(host);
                if (!hent) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "gethostbyname");
                        return 1;
                }
 
                        return 1;
                }
 
@@ -103,12 +103,12 @@ static int fio_netio_setup_connect(struct thread_data *td, const char *host,
        for_each_file(td, f, i) {
                f->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                if (f->fd < 0) {
        for_each_file(td, f, i) {
                f->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                if (f->fd < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "socket");
                        return 1;
                }
 
                if (connect(f->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                        return 1;
                }
 
                if (connect(f->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "connect");
                        return 1;
                }
        }
                        return 1;
                }
        }
@@ -142,7 +142,7 @@ static int fio_netio_accept_connections(struct thread_data *td, int fd,
                        if (errno == EINTR)
                                continue;
 
                        if (errno == EINTR)
                                continue;
 
-                       td_verror(td, errno);
+                       td_verror(td, errno, "poll");
                        break;
                } else if (!ret)
                        continue;
                        break;
                } else if (!ret)
                        continue;
@@ -159,7 +159,7 @@ static int fio_netio_accept_connections(struct thread_data *td, int fd,
 
                        f->fd = accept(fd, (struct sockaddr *) addr, &socklen);
                        if (f->fd < 0) {
 
                        f->fd = accept(fd, (struct sockaddr *) addr, &socklen);
                        if (f->fd < 0) {
-                               td_verror(td, errno);
+                               td_verror(td, errno, "accept");
                                return 1;
                        }
                        accepts++;
                                return 1;
                        }
                        accepts++;
@@ -177,18 +177,18 @@ static int fio_netio_setup_listen(struct thread_data *td, unsigned short port)
 
        fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if (fd < 0) {
 
        fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if (fd < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "socket");
                return 1;
        }
 
        opt = 1;
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
                return 1;
        }
 
        opt = 1;
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "setsockopt");
                return 1;
        }
 #ifdef SO_REUSEPORT
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
                return 1;
        }
 #ifdef SO_REUSEPORT
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "setsockopt");
                return 1;
        }
 #endif
                return 1;
        }
 #endif
@@ -199,11 +199,11 @@ static int fio_netio_setup_listen(struct thread_data *td, unsigned short port)
        addr.sin_port = htons(port);
 
        if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
        addr.sin_port = htons(port);
 
        if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "bind");
                return 1;
        }
        if (listen(fd, 1) < 0) {
                return 1;
        }
        if (listen(fd, 1) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "listen");
                return 1;
        }
 
                return 1;
        }
 
index a56ab3a691e9251c9684c91104774981e811684e..ebd6faf86b14b30e2dd4eabf8b5f9726d1d8d6aa 100644 (file)
@@ -153,7 +153,7 @@ static int fio_posixaio_queue(struct thread_data fio_unused *td,
 
        if (ret) {
                io_u->error = errno;
 
        if (ret) {
                io_u->error = errno;
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
                return FIO_Q_COMPLETED;
        }
 
                return FIO_Q_COMPLETED;
        }
 
index f955c20a74ca770f3a69b6d06361e0ca0cb3c485..b9033b8f7c2a0c8528b35d28f776ef62062028ad 100644 (file)
@@ -97,7 +97,7 @@ static int fio_sgio_getevents(struct thread_data *td, int min, int max,
                        if (ret < 0) {
                                if (!r)
                                        r = -errno;
                        if (ret < 0) {
                                if (!r)
                                        r = -errno;
-                               td_verror(td, errno);
+                               td_verror(td, errno, "poll");
                                break;
                        } else if (!ret)
                                continue;
                                break;
                        } else if (!ret)
                                continue;
@@ -118,7 +118,7 @@ re_read:
                                if (errno == EAGAIN)
                                        continue;
                                r = -errno;
                                if (errno == EAGAIN)
                                        continue;
                                r = -errno;
-                               td_verror(td, errno);
+                               td_verror(td, errno, "read");
                                break;
                        } else if (ret) {
                                p += ret;
                                break;
                        } else if (ret) {
                                p += ret;
@@ -253,7 +253,7 @@ static int fio_sgio_queue(struct thread_data *td, struct io_u *io_u)
        }
 
        if (io_u->error) {
        }
 
        if (io_u->error) {
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
                return FIO_Q_COMPLETED;
        }
 
                return FIO_Q_COMPLETED;
        }
 
@@ -339,14 +339,14 @@ static int fio_sgio_init(struct thread_data *td)
 
        if (td->filetype == FIO_TYPE_BD) {
                if (ioctl(f->fd, BLKSSZGET, &bs) < 0) {
 
        if (td->filetype == FIO_TYPE_BD) {
                if (ioctl(f->fd, BLKSSZGET, &bs) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "ioctl");
                        goto err;
                }
        } else if (td->filetype == FIO_TYPE_CHAR) {
                int version;
 
                if (ioctl(f->fd, SG_GET_VERSION_NUM, &version) < 0) {
                        goto err;
                }
        } else if (td->filetype == FIO_TYPE_CHAR) {
                int version;
 
                if (ioctl(f->fd, SG_GET_VERSION_NUM, &version) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "ioctl");
                        goto err;
                }
 
                        goto err;
                }
 
index 5c4411cce3bcdfdecdfe3f40a5b2e0d3530fd66a..a20f4e034eb76e807c30e046294780b61756c757 100644 (file)
@@ -125,7 +125,7 @@ static int fio_spliceio_queue(struct thread_data *td, struct io_u *io_u)
        }
 
        if (io_u->error)
        }
 
        if (io_u->error)
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
 
        return FIO_Q_COMPLETED;
 }
 
        return FIO_Q_COMPLETED;
 }
@@ -147,7 +147,7 @@ static int fio_spliceio_init(struct thread_data *td)
        struct spliceio_data *sd = malloc(sizeof(*sd));
 
        if (pipe(sd->pipe) < 0) {
        struct spliceio_data *sd = malloc(sizeof(*sd));
 
        if (pipe(sd->pipe) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "pipe");
                free(sd);
                return 1;
        }
                free(sd);
                return 1;
        }
index 5cf73662ad6dcc9f1e9893f12e34a3669d6e5124..ad02e09464f1935de33dc4a726ecef4edc3a8db8 100644 (file)
@@ -21,7 +21,7 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
                return 0;
 
        if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
                return 0;
 
        if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "lseek");
                return 1;
        }
 
                return 1;
        }
 
@@ -50,7 +50,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
        }
 
        if (io_u->error)
        }
 
        if (io_u->error)
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
 
        return FIO_Q_COMPLETED;
 }
 
        return FIO_Q_COMPLETED;
 }
index f188d1c665fac1a7240504c3957364e036a2a451..d4398106632f287674580d426737c16ee6fd2000 100644 (file)
@@ -190,7 +190,7 @@ static int fio_syslet_queue(struct thread_data *td, struct io_u *io_u)
        assert(sd->nr_events < td->iodepth);
 
        if (io_u->error)
        assert(sd->nr_events < td->iodepth);
 
        if (io_u->error)
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "xfer");
 
        return FIO_Q_COMPLETED;
 }
 
        return FIO_Q_COMPLETED;
 }
index 08742247d58c1f345303fbedb968c3594650aa48..4cd62d68a3fae3bd16cecd857b3e0468abbac3be 100644 (file)
@@ -41,17 +41,17 @@ static int create_file(struct thread_data *td, struct fio_file *f)
 
        f->fd = open(f->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (f->fd < 0) {
 
        f->fd = open(f->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (f->fd < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "open");
                return 1;
        }
 
        if (ftruncate(f->fd, f->file_size) == -1) {
                return 1;
        }
 
        if (ftruncate(f->fd, f->file_size) == -1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "ftruncate");
                goto err;
        }
 
        if (posix_fallocate(f->fd, 0, f->file_size) < 0) {
                goto err;
        }
 
        if (posix_fallocate(f->fd, 0, f->file_size) < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "posix_fallocate");
                goto err;
        }
 
                goto err;
        }
 
@@ -71,9 +71,9 @@ static int create_file(struct thread_data *td, struct fio_file *f)
                        continue;
                } else {
                        if (r < 0)
                        continue;
                } else {
                        if (r < 0)
-                               td_verror(td, errno);
+                               td_verror(td, errno, "write");
                        else
                        else
-                               td_verror(td, EIO);
+                               td_verror(td, EIO, "write");
 
                        break;
                }
 
                        break;
                }
@@ -128,7 +128,7 @@ static int create_files(struct thread_data *td)
 
        if (!td->total_file_size) {
                log_err("Need size for create\n");
 
        if (!td->total_file_size) {
                log_err("Need size for create\n");
-               td_verror(td, EINVAL);
+               td_verror(td, EINVAL, "file_size");
                return 1;
        }
 
                return 1;
        }
 
@@ -172,7 +172,7 @@ static int file_size(struct thread_data *td, struct fio_file *f)
 
        if (td->overwrite) {
                if (fstat(f->fd, &st) == -1) {
 
        if (td->overwrite) {
                if (fstat(f->fd, &st) == -1) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "fstat");
                        return 1;
                }
 
                        return 1;
                }
 
@@ -193,7 +193,7 @@ static int bdev_size(struct thread_data *td, struct fio_file *f)
 
        r = blockdev_size(f->fd, &bytes);
        if (r) {
 
        r = blockdev_size(f->fd, &bytes);
        if (r) {
-               td_verror(td, r);
+               td_verror(td, r, "blockdev_size");
                return 1;
        }
 
                return 1;
        }
 
@@ -248,7 +248,7 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
                ret = 0;
 
        if (ret < 0) {
                ret = 0;
 
        if (ret < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "invalidate_cache");
                return 1;
        }
 
                return 1;
        }
 
@@ -272,7 +272,7 @@ static int __setup_file_mmap(struct thread_data *td, struct fio_file *f)
        f->mmap = mmap(NULL, f->file_size, flags, MAP_SHARED, f->fd, f->file_offset);
        if (f->mmap == MAP_FAILED) {
                f->mmap = NULL;
        f->mmap = mmap(NULL, f->file_size, flags, MAP_SHARED, f->fd, f->file_offset);
        if (f->mmap == MAP_FAILED) {
                f->mmap = NULL;
-               td_verror(td, errno);
+               td_verror(td, errno, "mmap");
                return 1;
        }
 
                return 1;
        }
 
@@ -281,12 +281,12 @@ static int __setup_file_mmap(struct thread_data *td, struct fio_file *f)
 
        if (td->sequential) {
                if (madvise(f->mmap, f->file_size, MADV_SEQUENTIAL) < 0) {
 
        if (td->sequential) {
                if (madvise(f->mmap, f->file_size, MADV_SEQUENTIAL) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "madvise");
                        return 1;
                }
        } else {
                if (madvise(f->mmap, f->file_size, MADV_RANDOM) < 0) {
                        return 1;
                }
        } else {
                if (madvise(f->mmap, f->file_size, MADV_RANDOM) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "madvise");
                        return 1;
                }
        }
                        return 1;
                }
        }
@@ -315,12 +315,12 @@ static int __setup_file_plain(struct thread_data *td, struct fio_file *f)
 
        if (td->sequential) {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
 
        if (td->sequential) {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_SEQUENTIAL) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "fadvise");
                        return 1;
                }
        } else {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_RANDOM) < 0) {
                        return 1;
                }
        } else {
                if (fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_RANDOM) < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "fadvise");
                        return 1;
                }
        }
                        return 1;
                }
        }
@@ -383,7 +383,11 @@ static int setup_file(struct thread_data *td, struct fio_file *f)
        }
 
        if (f->fd == -1) {
        }
 
        if (f->fd == -1) {
-               td_verror(td, errno);
+               int __e = errno;
+
+               td_verror(td, __e, "open");
+               if (__e == EINVAL && td->odirect)
+                       log_err("fio: destinations does not support O_DIRECT\n");
                return 1;
        }
 
                return 1;
        }
 
@@ -446,7 +450,7 @@ int setup_files(struct thread_data *td)
        td->io_size = td->total_file_size;
        if (td->io_size == 0) {
                log_err("%s: no io blocks\n", td->name);
        td->io_size = td->total_file_size;
        if (td->io_size == 0) {
                log_err("%s: no io blocks\n", td->name);
-               td_verror(td, EINVAL);
+               td_verror(td, EINVAL, "total_file_size");
                return 1;
        }
 
                return 1;
        }
 
diff --git a/fio.c b/fio.c
index 0e1eadb35ce2d11555ee1a1ad3213083d136c5c5..920639395cbda1101ba57c36b7cc421f6a3d4f27 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -203,7 +203,7 @@ static int fio_io_sync(struct thread_data *td, struct fio_file *f)
 requeue:
        ret = td_io_queue(td, io_u);
        if (ret < 0) {
 requeue:
        ret = td_io_queue(td, io_u);
        if (ret < 0) {
-               td_verror(td, io_u->error);
+               td_verror(td, io_u->error, "td_io_queue");
                put_io_u(td, io_u);
                return 1;
        } else if (ret == FIO_Q_QUEUED) {
                put_io_u(td, io_u);
                return 1;
        } else if (ret == FIO_Q_QUEUED) {
@@ -211,7 +211,7 @@ requeue:
                        return 1;
        } else if (ret == FIO_Q_COMPLETED) {
                if (io_u->error) {
                        return 1;
        } else if (ret == FIO_Q_COMPLETED) {
                if (io_u->error) {
-                       td_verror(td, io_u->error);
+                       td_verror(td, io_u->error, "td_io_queue");
                        return 1;
                }
 
                        return 1;
                }
 
@@ -298,7 +298,7 @@ requeue:
                        break;
                default:
                        assert(ret < 0);
                        break;
                default:
                        assert(ret < 0);
-                       td_verror(td, -ret);
+                       td_verror(td, -ret, "td_io_queue");
                        break;
                }
 
                        break;
                }
 
@@ -463,7 +463,7 @@ requeue:
                if (check_min_rate(td, &comp_time)) {
                        if (exitall_on_terminate)
                                terminate_threads(td->groupid, 0);
                if (check_min_rate(td, &comp_time)) {
                        if (exitall_on_terminate)
                                terminate_threads(td->groupid, 0);
-                       td_verror(td, ENODATA);
+                       td_verror(td, ENODATA, "check_min_rate");
                        break;
                }
 
                        break;
                }
 
@@ -585,7 +585,7 @@ static int switch_ioscheduler(struct thread_data *td)
 
        f = fopen(tmp, "r+");
        if (!f) {
 
        f = fopen(tmp, "r+");
        if (!f) {
-               td_verror(td, errno);
+               td_verror(td, errno, "fopen");
                return 1;
        }
 
                return 1;
        }
 
@@ -594,7 +594,7 @@ static int switch_ioscheduler(struct thread_data *td)
         */
        ret = fwrite(td->ioscheduler, strlen(td->ioscheduler), 1, f);
        if (ferror(f) || ret != 1) {
         */
        ret = fwrite(td->ioscheduler, strlen(td->ioscheduler), 1, f);
        if (ferror(f) || ret != 1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "fwrite");
                fclose(f);
                return 1;
        }
                fclose(f);
                return 1;
        }
@@ -606,7 +606,7 @@ static int switch_ioscheduler(struct thread_data *td)
         */
        ret = fread(tmp, 1, sizeof(tmp), f);
        if (ferror(f) || ret < 0) {
         */
        ret = fread(tmp, 1, sizeof(tmp), f);
        if (ferror(f) || ret < 0) {
-               td_verror(td, errno);
+               td_verror(td, errno, "fread");
                fclose(f);
                return 1;
        }
                fclose(f);
                return 1;
        }
@@ -614,7 +614,7 @@ static int switch_ioscheduler(struct thread_data *td)
        sprintf(tmp2, "[%s]", td->ioscheduler);
        if (!strstr(tmp, tmp2)) {
                log_err("fio: io scheduler %s not found\n", td->ioscheduler);
        sprintf(tmp2, "[%s]", td->ioscheduler);
        if (!strstr(tmp, tmp2)) {
                log_err("fio: io scheduler %s not found\n", td->ioscheduler);
-               td_verror(td, EINVAL);
+               td_verror(td, EINVAL, "iosched_switch");
                fclose(f);
                return 1;
        }
                fclose(f);
                return 1;
        }
@@ -670,7 +670,7 @@ static void *thread_main(void *data)
                goto err;
 
        if (fio_setaffinity(td) == -1) {
                goto err;
 
        if (fio_setaffinity(td) == -1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "cpu_set_affinity");
                goto err;
        }
 
                goto err;
        }
 
@@ -679,13 +679,13 @@ static void *thread_main(void *data)
 
        if (td->ioprio) {
                if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) {
 
        if (td->ioprio) {
                if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "ioprio_set");
                        goto err;
                }
        }
 
        if (nice(td->nice) == -1) {
                        goto err;
                }
        }
 
        if (nice(td->nice) == -1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "nice");
                goto err;
        }
 
                goto err;
        }
 
diff --git a/fio.h b/fio.h
index 7a4b1d19c8ebfa527814bee59976b014b5de9a99..959e52f3d032f332a3f67f22287228fdac7b68fa 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -443,18 +443,20 @@ struct thread_data {
 #define IO_U_TIMEOUT_INC       5
 #define IO_U_TIMEOUT           30
 
 #define IO_U_TIMEOUT_INC       5
 #define IO_U_TIMEOUT           30
 
-#define __td_verror(td, err, msg)                                      \
+#define __td_verror(td, err, msg, func)                                        \
        do {                                                            \
                if ((td)->error)                                        \
                        break;                                          \
                int e = (err);                                          \
                (td)->error = e;                                        \
        do {                                                            \
                if ((td)->error)                                        \
                        break;                                          \
                int e = (err);                                          \
                (td)->error = e;                                        \
-               snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, (msg));        \
+               snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg));       \
        } while (0)
 
 
        } while (0)
 
 
-#define td_verror(td, err)     __td_verror((td), (err), strerror((err)))
-#define td_vmsg(td, err, msg)  __td_verror((td), (err), (msg))
+#define td_verror(td, err, func)       \
+       __td_verror((td), (err), strerror((err)), (func))
+#define td_vmsg(td, err, msg, func)    \
+       __td_verror((td), (err), (msg), (func))
 
 extern int exitall_on_terminate;
 extern int thread_number;
 
 extern int exitall_on_terminate;
 extern int thread_number;
diff --git a/init.c b/init.c
index a235e2f155909638cd07e517d8d6bb27047d247a..c8f27ade76e7f2aafaef4e98320d189c2a26e347 100644 (file)
--- a/init.c
+++ b/init.c
@@ -725,7 +725,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                if (td->directory && td->directory[0] != '\0') {
                        if (lstat(td->directory, &sb) < 0) {
                                log_err("fio: %s is not a directory\n", td->directory);
                if (td->directory && td->directory[0] != '\0') {
                        if (lstat(td->directory, &sb) < 0) {
                                log_err("fio: %s is not a directory\n", td->directory);
-                               td_verror(td, errno);
+                               td_verror(td, errno, "lstat");
                                return 1;
                        }
                        if (!S_ISDIR(sb.st_mode)) {
                                return 1;
                        }
                        if (!S_ISDIR(sb.st_mode)) {
@@ -850,12 +850,12 @@ int init_random_state(struct thread_data *td)
 
        fd = open("/dev/urandom", O_RDONLY);
        if (fd == -1) {
 
        fd = open("/dev/urandom", O_RDONLY);
        if (fd == -1) {
-               td_verror(td, errno);
+               td_verror(td, errno, "open");
                return 1;
        }
 
        if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
                return 1;
        }
 
        if (read(fd, seeds, sizeof(seeds)) < (int) sizeof(seeds)) {
-               td_verror(td, EIO);
+               td_verror(td, EIO, "read");
                close(fd);
                return 1;
        }
                close(fd);
                return 1;
        }
diff --git a/io_u.c b/io_u.c
index c93896001296419f1a348f2b5f9f46f660b0a366..8141991c27ca2619fe630aa903a7c4a959cb1e80 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -548,7 +548,7 @@ long io_u_queued_complete(struct thread_data *td, int min_events,
        if (min_events > 0) {
                ret = td_io_commit(td);
                if (ret < 0) {
        if (min_events > 0) {
                ret = td_io_commit(td);
                if (ret < 0) {
-                       td_verror(td, -ret);
+                       td_verror(td, -ret, "td_io_commit");
                        return ret;
                }
        } else {
                        return ret;
                }
        } else {
@@ -559,7 +559,7 @@ long io_u_queued_complete(struct thread_data *td, int min_events,
 
        ret = td_io_getevents(td, min_events, td->cur_depth, tvp);
        if (ret < 0) {
 
        ret = td_io_getevents(td, min_events, td->cur_depth, tvp);
        if (ret < 0) {
-               td_verror(td, -ret);
+               td_verror(td, -ret, "td_io_getevents");
                return ret;
        } else if (!ret)
                return ret;
                return ret;
        } else if (!ret)
                return ret;
index 441f36fc530969b47474f43d240385edf32f11c3..0b3ec16485124df5eb3e3e7396e0208a4cd4ac27 100644 (file)
@@ -102,7 +102,7 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
        dlerror();
        dlhandle = dlopen(engine_lib, RTLD_LAZY);
        if (!dlhandle) {
        dlerror();
        dlhandle = dlopen(engine_lib, RTLD_LAZY);
        if (!dlhandle) {
-               td_vmsg(td, -1, dlerror());
+               td_vmsg(td, -1, dlerror(), "dlopen");
                return NULL;
        }
 
                return NULL;
        }
 
@@ -112,7 +112,7 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
         */
        ops = dlsym(dlhandle, "ioengine");
        if (!ops) {
         */
        ops = dlsym(dlhandle, "ioengine");
        if (!ops) {
-               td_vmsg(td, -1, dlerror());
+               td_vmsg(td, -1, dlerror(), "dlsym");
                dlclose(dlhandle);
                return NULL;
        }
                dlclose(dlhandle);
                return NULL;
        }
@@ -234,6 +234,8 @@ int td_io_init(struct thread_data *td)
 
 int td_io_commit(struct thread_data *td)
 {
 
 int td_io_commit(struct thread_data *td)
 {
+       if (!td->cur_depth)
+               return 0;
        if (td->io_ops->commit)
                return td->io_ops->commit(td);
 
        if (td->io_ops->commit)
                return td->io_ops->commit(td);
 
index 079c0760f0993d22baee775c43561e11d90c7bb1..d9cfe9bae2c0b35f24ec3e301ef74d459b4d8407 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -69,14 +69,14 @@ int allocate_io_mem(struct thread_data *td)
 
                td->shm_id = shmget(IPC_PRIVATE, td->orig_buffer_size, flags);
                if (td->shm_id < 0) {
 
                td->shm_id = shmget(IPC_PRIVATE, td->orig_buffer_size, flags);
                if (td->shm_id < 0) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "shmget");
                        perror("shmget");
                        return 1;
                }
 
                td->orig_buffer = shmat(td->shm_id, NULL, 0);
                if (td->orig_buffer == (void *) -1) {
                        perror("shmget");
                        return 1;
                }
 
                td->orig_buffer = shmat(td->shm_id, NULL, 0);
                if (td->orig_buffer == (void *) -1) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "shmat");
                        perror("shmat");
                        td->orig_buffer = NULL;
                        return 1;
                        perror("shmat");
                        td->orig_buffer = NULL;
                        return 1;
@@ -90,7 +90,7 @@ int allocate_io_mem(struct thread_data *td)
                        td->mmapfd = open(td->mmapfile, O_RDWR|O_CREAT, 0644);
 
                        if (td->mmapfd < 0) {
                        td->mmapfd = open(td->mmapfile, O_RDWR|O_CREAT, 0644);
 
                        if (td->mmapfd < 0) {
-                               td_verror(td, errno);
+                               td_verror(td, errno, "open");
                                perror("open mmap file");
                                td->orig_buffer = NULL;
                                return 1;
                                perror("open mmap file");
                                td->orig_buffer = NULL;
                                return 1;
@@ -100,7 +100,7 @@ int allocate_io_mem(struct thread_data *td)
 
                td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, flags, td->mmapfd, 0);
                if (td->orig_buffer == MAP_FAILED) {
 
                td->orig_buffer = mmap(NULL, td->orig_buffer_size, PROT_READ | PROT_WRITE, flags, td->mmapfd, 0);
                if (td->orig_buffer == MAP_FAILED) {
-                       td_verror(td, errno);
+                       td_verror(td, errno, "mmap");
                        perror("mmap");
                        td->orig_buffer = NULL;
                        if (td->mmapfd) {
                        perror("mmap");
                        td->orig_buffer = NULL;
                        if (td->mmapfd) {