Add unmap hook that belongs to the IO engines
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 55f3c78c72cbd773cf24a503e30814a9c788e1cf..1a68ad1171c2a175950f6ac20ac5bcdf1f1803c9 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -165,9 +165,8 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u)
                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 / td->o.min_bs[ddir];
-               }
+               } 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;
@@ -771,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);