backend: don't allocate memory buffers for non-data workloads
authorJens Axboe <axboe@kernel.dk>
Mon, 24 Sep 2012 12:25:33 +0000 (14:25 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 24 Sep 2012 12:25:33 +0000 (14:25 +0200)
A trim workload doesn't transfer any actual data, so don't any
backing memory for the IO buffers.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c

index 39d13a330581e91974c4f04b36f187b149ff180b..88623bea3d88c97e34c19029849fa31dc81529ef 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -802,6 +802,7 @@ static int init_io_u(struct thread_data *td)
        struct io_u *io_u;
        unsigned int max_bs, min_write;
        int cl_align, i, max_units;
        struct io_u *io_u;
        unsigned int max_bs, min_write;
        int cl_align, i, max_units;
+       int data_xfer = 1;
        char *p;
 
        max_units = td->o.iodepth;
        char *p;
 
        max_units = td->o.iodepth;
@@ -811,6 +812,9 @@ static int init_io_u(struct thread_data *td)
        td->orig_buffer_size = (unsigned long long) max_bs
                                        * (unsigned long long) max_units;
 
        td->orig_buffer_size = (unsigned long long) max_bs
                                        * (unsigned long long) max_units;
 
+       if ((td->io_ops->flags & FIO_NOIO) || !td_rw(td))
+               data_xfer = 0;
+
        if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE) {
                unsigned long bs;
 
        if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE) {
                unsigned long bs;
 
@@ -823,7 +827,7 @@ static int init_io_u(struct thread_data *td)
                return 1;
        }
 
                return 1;
        }
 
-       if (allocate_io_mem(td))
+       if (data_xfer && allocate_io_mem(td))
                return 1;
 
        if (td->o.odirect || td->o.mem_align ||
                return 1;
 
        if (td->o.odirect || td->o.mem_align ||
@@ -851,7 +855,7 @@ static int init_io_u(struct thread_data *td)
                INIT_FLIST_HEAD(&io_u->list);
                dprint(FD_MEM, "io_u alloc %p, index %u\n", io_u, i);
 
                INIT_FLIST_HEAD(&io_u->list);
                dprint(FD_MEM, "io_u alloc %p, index %u\n", io_u, i);
 
-               if (!(td->io_ops->flags & FIO_NOIO)) {
+               if (data_xfer) {
                        io_u->buf = p;
                        dprint(FD_MEM, "io_u %p, mem %p\n", io_u, io_u->buf);
 
                        io_u->buf = p;
                        dprint(FD_MEM, "io_u %p, mem %p\n", io_u, io_u->buf);