Add two assert statements in mark_random_map()
authorBart Van Assche <bart.vanassche@wdc.com>
Fri, 24 Aug 2018 18:31:26 +0000 (11:31 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 24 Aug 2018 18:54:35 +0000 (12:54 -0600)
Add two assert statements that verify whether mark_random_map() is
used correctly.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_u.c

diff --git a/io_u.c b/io_u.c
index eed7d9d91c8d12d829321ba8ec01b69e2576a381..9b5f203c4733c2eabc122d2a3d32e56fd298c9ce 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -41,9 +41,12 @@ static uint64_t mark_random_map(struct thread_data *td, struct io_u *io_u,
 
        block = (offset - f->file_offset) / (uint64_t) min_bs;
        nr_blocks = (buflen + min_bs - 1) / min_bs;
 
        block = (offset - f->file_offset) / (uint64_t) min_bs;
        nr_blocks = (buflen + min_bs - 1) / min_bs;
+       assert(nr_blocks > 0);
 
 
-       if (!(io_u->flags & IO_U_F_BUSY_OK))
+       if (!(io_u->flags & IO_U_F_BUSY_OK)) {
                nr_blocks = axmap_set_nr(f->io_axmap, block, nr_blocks);
                nr_blocks = axmap_set_nr(f->io_axmap, block, nr_blocks);
+               assert(nr_blocks > 0);
+       }
 
        if ((nr_blocks * min_bs) < buflen)
                buflen = nr_blocks * min_bs;
 
        if ((nr_blocks * min_bs) < buflen)
                buflen = nr_blocks * min_bs;