smalloc: turn on the thread safe flag
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index ce08c59ce84dea7f79487592e5a7d14febe61431..c3939b32ad0df0f101fa24d0bdfef6ebe716c0ff 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -79,8 +79,16 @@ static inline unsigned long long last_block(struct thread_data *td,
                                            enum fio_ddir ddir)
 {
        unsigned long long max_blocks;
+       unsigned long long max_size;
 
-       max_blocks = f->io_size / (unsigned long long) td->o.min_bs[ddir];
+       /*
+        * Hmm, should we make sure that ->io_size <= ->real_file_size?
+        */
+       max_size = f->io_size;
+       if (max_size > f->real_file_size)
+               max_size = f->real_file_size;
+
+       max_blocks = max_size / (unsigned long long) td->o.min_bs[ddir];
        if (!max_blocks)
                return 0;
 
@@ -209,7 +217,7 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u)
 static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
 {
        const int ddir = io_u->ddir;
-       unsigned int buflen;
+       unsigned int buflen = buflen; /* silence dumb gcc warning */
        long r;
 
        if (td->o.min_bs[ddir] == td->o.max_bs[ddir])