- blocks = 0;
- busy_check = !(io_u->flags & IO_U_F_BUSY_OK);
-
- while (nr_blocks) {
- unsigned int idx, bit;
- unsigned long mask, this_blocks;
-
- /*
- * If we have a mixed random workload, we may
- * encounter blocks we already did IO to.
- */
- if (!busy_check) {
- blocks = nr_blocks;
- break;
- }
- if ((td->o.ddir_seq_nr == 1) && !random_map_free(f, block))
- break;
-
- idx = RAND_MAP_IDX(f, block);
- bit = RAND_MAP_BIT(f, block);
-
- fio_assert(td, idx < f->num_maps);
-
- this_blocks = nr_blocks;
- if (this_blocks + bit > BLOCKS_PER_MAP)
- this_blocks = BLOCKS_PER_MAP - bit;
-
- do {
- if (this_blocks == BLOCKS_PER_MAP)
- mask = -1UL;
- else
- mask = ((1UL << this_blocks) - 1) << bit;
-
- if (!(f->file_map[idx] & mask))
- break;