projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Correctly detect whether ioengine_load can exit early
[fio.git]
/
trim.c
diff --git
a/trim.c
b/trim.c
index 3da1e749206dc02aaaf633ee25562f3b08c6ee59..78cf67244efa22534604fd6b6652379457a571a2 100644
(file)
--- a/
trim.c
+++ b/
trim.c
@@
-11,7
+11,7
@@
#include "trim.h"
#ifdef FIO_HAVE_TRIM
#include "trim.h"
#ifdef FIO_HAVE_TRIM
-
int
get_next_trim(struct thread_data *td, struct io_u *io_u)
+
bool
get_next_trim(struct thread_data *td, struct io_u *io_u)
{
struct io_piece *ipo;
{
struct io_piece *ipo;
@@
-19,12
+19,12
@@
int get_next_trim(struct thread_data *td, struct io_u *io_u)
* this io_u is from a requeue, we already filled the offsets
*/
if (io_u->file)
* this io_u is from a requeue, we already filled the offsets
*/
if (io_u->file)
- return
0
;
+ return
true
;
if (flist_empty(&td->trim_list))
if (flist_empty(&td->trim_list))
- return
1
;
+ return
false
;
assert(td->trim_entries);
assert(td->trim_entries);
- ipo = flist_
entry(td->trim_list.nex
t, struct io_piece, trim_list);
+ ipo = flist_
first_entry(&td->trim_lis
t, struct io_piece, trim_list);
remove_trim_entry(td, ipo);
io_u->offset = ipo->offset;
remove_trim_entry(td, ipo);
io_u->offset = ipo->offset;
@@
-53,7
+53,7
@@
int get_next_trim(struct thread_data *td, struct io_u *io_u)
if (r) {
dprint(FD_VERIFY, "failed file %s open\n",
io_u->file->file_name);
if (r) {
dprint(FD_VERIFY, "failed file %s open\n",
io_u->file->file_name);
- return
1
;
+ return
false
;
}
}
}
}
@@
-64,21
+64,23
@@
int get_next_trim(struct thread_data *td, struct io_u *io_u)
io_u->xfer_buflen = io_u->buflen;
dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
io_u->xfer_buflen = io_u->buflen;
dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
- return
0
;
+ return
true
;
}
}
-
int
io_u_should_trim(struct thread_data *td, struct io_u *io_u)
+
bool
io_u_should_trim(struct thread_data *td, struct io_u *io_u)
{
unsigned long long val;
{
unsigned long long val;
- long r;
+ uint64_t frand_max;
+ unsigned long r;
if (!td->o.trim_percentage)
if (!td->o.trim_percentage)
- return
0
;
+ return
false
;
-
r = os_random_long
(&td->trim_state);
-
val = (OS_RAND_MAX / 100ULL
);
- val
*= (unsigned long long) td->o.trim_percentage
;
+
frand_max = rand_max
(&td->trim_state);
+
r = __rand(&td->trim_state
);
+ val
= (frand_max / 100ULL)
;
+ val *= (unsigned long long) td->o.trim_percentage;
return r <= val;
}
#endif
return r <= val;
}
#endif