Add more context to the error messages
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>
diff --git a/engines/net.c b/engines/net.c
index 381c731..55b2128 100644
--- a/engines/net.c
+++ b/engines/net.c
@@ -25,7 +25,7 @@
*/
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;
}
@@ -38,7 +38,7 @@
* 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;
}
@@ -72,7 +72,7 @@
}
if (io_u->error)
- td_verror(td, io_u->error);
+ td_verror(td, io_u->error, "xfer");
return FIO_Q_COMPLETED;
}
@@ -93,7 +93,7 @@
hent = gethostbyname(host);
if (!hent) {
- td_verror(td, errno);
+ td_verror(td, errno, "gethostbyname");
return 1;
}
@@ -103,12 +103,12 @@
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) {
- td_verror(td, errno);
+ td_verror(td, errno, "connect");
return 1;
}
}
@@ -142,7 +142,7 @@
if (errno == EINTR)
continue;
- td_verror(td, errno);
+ td_verror(td, errno, "poll");
break;
} else if (!ret)
continue;
@@ -159,7 +159,7 @@
f->fd = accept(fd, (struct sockaddr *) addr, &socklen);
if (f->fd < 0) {
- td_verror(td, errno);
+ td_verror(td, errno, "accept");
return 1;
}
accepts++;
@@ -177,18 +177,18 @@
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) {
- 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) {
- td_verror(td, errno);
+ td_verror(td, errno, "setsockopt");
return 1;
}
#endif
@@ -199,11 +199,11 @@
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) {
- td_verror(td, errno);
+ td_verror(td, errno, "listen");
return 1;
}