projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fio 1.16.4
[fio.git]
/
io_u.c
diff --git
a/io_u.c
b/io_u.c
index b48c99dad3ed4a3eb25650de53f59203463af850..6290ebbc6ffda5757ac686859cffb4d17ea18e7f 100644
(file)
--- a/
io_u.c
+++ b/
io_u.c
@@
-6,7
+6,6
@@
#include <assert.h>
#include "fio.h"
#include <assert.h>
#include "fio.h"
-#include "os.h"
/*
* Change this define to play with the timeout handling
/*
* Change this define to play with the timeout handling
@@
-85,7
+84,7
@@
static int get_next_free_block(struct thread_data *td, struct fio_file *f,
*b = (i * BLOCKS_PER_MAP);
while ((*b) * td->o.rw_min_bs < f->real_file_size) {
if (f->file_map[i] != -1UL) {
*b = (i * BLOCKS_PER_MAP);
while ((*b) * td->o.rw_min_bs < f->real_file_size) {
if (f->file_map[i] != -1UL) {
- *b += ffz(f->file_map[i]);
+ *b += f
io_f
fz(f->file_map[i]);
f->last_free_lookup = i;
return 0;
}
f->last_free_lookup = i;
return 0;
}
@@
-110,20
+109,40
@@
static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
*b = 0;
else
*b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0));
*b = 0;
else
*b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0));
+ /*
+ * if we are not maintaining a random map, we are done.
+ */
if (td->o.norandommap)
if (td->o.norandommap)
- break;
+ return 0;
+
+ /*
+ * calculate map offset and chec if it's free
+ */
rb = *b + (f->file_offset / td->o.min_bs[ddir]);
rb = *b + (f->file_offset / td->o.min_bs[ddir]);
- loops--;
- } while (!random_map_free(td, f, rb) && loops);
+ if (random_map_free(td, f, rb))
+ return 0;
+
+ } while (--loops);
/*
/*
- * if we failed to retrieve a truly random offset within
- * the loops assigned, see if there are free ones left at all
+ * we get here, if we didn't suceed in looking up a block. generate
+ * a random start offset into the filemap, and find the first free
+ * block from there.
*/
*/
- if (!loops && get_next_free_block(td, f, b))
- return 1;
+ loops = 10;
+ do {
+ f->last_free_lookup = (f->num_maps - 1) * (r / (RAND_MAX+1.0));
+ if (!get_next_free_block(td, f, b))
+ return 0;
- return 0;
+ r = os_random_long(&td->random_state);
+ } while (--loops);
+
+ /*
+ * that didn't work either, try exhaustive search from the start
+ */
+ f->last_free_lookup = 0;
+ return get_next_free_block(td, f, b);
}
/*
}
/*
@@
-266,6
+285,9
@@
void put_io_u(struct thread_data *td, struct io_u *io_u)
assert((io_u->flags & IO_U_F_FREE) == 0);
io_u->flags |= IO_U_F_FREE;
assert((io_u->flags & IO_U_F_FREE) == 0);
io_u->flags |= IO_U_F_FREE;
+ if (io_u->file)
+ put_file(td, io_u->file);
+
io_u->file = NULL;
list_del(&io_u->list);
list_add(&io_u->list, &td->io_u_freelist);
io_u->file = NULL;
list_del(&io_u->list);
list_add(&io_u->list, &td->io_u_freelist);
@@
-290,7
+312,7
@@
static int fill_io_u(struct thread_data *td, struct io_u *io_u)
/*
* If using an iolog, grab next piece if any available.
*/
/*
* If using an iolog, grab next piece if any available.
*/
- if (td->o.read_iolog)
+ if (td->o.read_iolog
_file
)
return read_iolog_get(td, io_u);
/*
return read_iolog_get(td, io_u);
/*
@@
-541,12
+563,14
@@
struct io_u *get_io_u(struct thread_data *td)
set_file:
io_u->file = f;
set_file:
io_u->file = f;
+ get_file(f);
if (!fill_io_u(td, io_u))
break;
/*
if (!fill_io_u(td, io_u))
break;
/*
- * No more to do for this file, close it
+ * td_io_close() does a put_file() as well, so no need to
+ * do that here.
*/
io_u->file = NULL;
td_io_close_file(td, f);
*/
io_u->file = NULL;
td_io_close_file(td, f);
@@
-569,6
+593,8
@@
set_file:
}
} while (1);
}
} while (1);
+ assert(io_u->file->flags & FIO_FILE_OPEN);
+
if (td->zone_bytes >= td->o.zone_size) {
td->zone_bytes = 0;
f->last_pos += td->o.zone_skip;
if (td->zone_bytes >= td->o.zone_size) {
td->zone_bytes = 0;
f->last_pos += td->o.zone_skip;
@@
-589,6
+615,7
@@
set_file:
/*
* Set io data pointers.
*/
/*
* Set io data pointers.
*/
+ io_u->endpos = io_u->offset + io_u->buflen;
out:
io_u->xfer_buf = io_u->buf;
io_u->xfer_buflen = io_u->buflen;
out:
io_u->xfer_buf = io_u->buf;
io_u->xfer_buflen = io_u->buflen;
@@
-627,8
+654,6
@@
static void io_completed(struct thread_data *td, struct io_u *io_u,
assert(io_u->flags & IO_U_F_FLIGHT);
io_u->flags &= ~IO_U_F_FLIGHT;
assert(io_u->flags & IO_U_F_FLIGHT);
io_u->flags &= ~IO_U_F_FLIGHT;
- put_file(td, io_u->file);
-
if (io_u->ddir == DDIR_SYNC) {
td->last_was_sync = 1;
return;
if (io_u->ddir == DDIR_SYNC) {
td->last_was_sync = 1;
return;
@@
-646,7
+671,7
@@
static void io_completed(struct thread_data *td, struct io_u *io_u,
td->zone_bytes += bytes;
td->this_io_bytes[idx] += bytes;
td->zone_bytes += bytes;
td->this_io_bytes[idx] += bytes;
- io_u->file->last_completed_pos = io_u->
offset + io_u->buflen
;
+ io_u->file->last_completed_pos = io_u->
endpos
;
msec = mtime_since(&io_u->issue_time, &icd->time);
msec = mtime_since(&io_u->issue_time, &icd->time);
@@
-654,7
+679,7
@@
static void io_completed(struct thread_data *td, struct io_u *io_u,
add_bw_sample(td, idx, &icd->time);
io_u_mark_latency(td, msec);
add_bw_sample(td, idx, &icd->time);
io_u_mark_latency(td, msec);
- if (
(td_rw(td) || td_write(td)
) && idx == DDIR_WRITE &&
+ if (
td_write(td
) && idx == DDIR_WRITE &&
td->o.verify != VERIFY_NONE)
log_io_piece(td, io_u);
td->o.verify != VERIFY_NONE)
log_io_piece(td, io_u);