splice engine: add unmapping for vmsplice-to-user
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 18e3c3f1c5b9d08d40e4b3b40876b8a36e6a8e4d..1a68ad1171c2a175950f6ac20ac5bcdf1f1803c9 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -162,10 +162,11 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u)
                if (get_next_rand_offset(td, f, ddir, &b))
                        return 1;
        } else {
-               if (f->last_pos >= f->real_file_size)
-                       return 1;
-
-               b = f->last_pos / td->o.min_bs[ddir];
+               if (f->last_pos >= f->real_file_size) {
+                       if (!td_random(td) || get_next_rand_offset(td, f, ddir, &b))
+                               return 1;
+               } else
+                       b = (f->last_pos - f->file_offset) / td->o.min_bs[ddir];
        }
 
        io_u->offset = (b * td->o.min_bs[ddir]) + f->file_offset;
@@ -769,6 +770,8 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
                        if (ret && !icd->error)
                                icd->error = ret;
                }
+               if (io_u->unmap)
+                       io_u->unmap(td, io_u);
        } else {
                icd->error = io_u->error;
                io_u_log_error(td, io_u);