Get rid of lockfile callback
[fio.git] / engines / sg.c
index fcd9c41397a8bf20644b04336c2020bdc63b2215..6272b79b568242239ae93cd028e919029b83c7b7 100644 (file)
@@ -62,7 +62,8 @@ static int pollin_events(struct pollfd *pfds, int fds)
 }
 
 static int fio_sgio_getevents(struct thread_data *td, unsigned int min,
-                             unsigned int max, struct timespec fio_unused *t)
+                             unsigned int max,
+                             const struct timespec fio_unused *t)
 {
        struct sgio_data *sd = td->io_ops->data;
        int left = max, ret, r = 0;
@@ -78,7 +79,9 @@ static int fio_sgio_getevents(struct thread_data *td, unsigned int min,
                 * don't block for min events == 0
                 */
                if (!min)
-                       fio_set_fd_nonblocking(f->fd, "sg");
+                       sd->fd_flags[i] = fio_set_fd_nonblocking(f->fd, "sg");
+               else
+                       sd->fd_flags[i] = -1;
 
                sd->pfds[i].fd = f->fd;
                sd->pfds[i].events = POLLIN;
@@ -142,8 +145,13 @@ re_read:
        }
 
        if (!min) {
-               for_each_file(td, f, i)
-                       fcntl(f->fd, F_SETFL, sd->fd_flags[i]);
+               for_each_file(td, f, i) {
+                       if (sd->fd_flags[i] == -1)
+                               continue;
+
+                       if (fcntl(f->fd, F_SETFL, sd->fd_flags[i]) < 0)
+                               log_err("fio: sg failed to restore fcntl flags: %s\n", strerror(errno));
+               }
        }
 
        return r;