Revert "drivers/fbd/action.c: removed some 64-bit functions"
This reverts commit 85e7d849c8
.
This introduce a bug in position computing for disk bigger than 4GB.
Change-Id: I281e60e9644d995cc4643006b50c05693f939b44
This commit is contained in:
parent
63d39b995c
commit
003ff52ebb
1 changed files with 8 additions and 8 deletions
|
@ -49,14 +49,14 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size,
|
||||||
to_eof = cmp64(rule->start, rule->end) >= 0;
|
to_eof = cmp64(rule->start, rule->end) >= 0;
|
||||||
|
|
||||||
if (cmp64(pos, rule->start) > 0) {
|
if (cmp64(pos, rule->start) > 0) {
|
||||||
if (skip != NULL) *skip = pos - rule->start;
|
if (skip != NULL) *skip = sub64(pos, rule->start);
|
||||||
|
|
||||||
off = 0;
|
off = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (skip != NULL) *skip = ((u64_t)(0));
|
if (skip != NULL) *skip = ((u64_t)(0));
|
||||||
|
|
||||||
delta = rule->start - pos;
|
delta = sub64(rule->start, pos);
|
||||||
|
|
||||||
assert(ex64hi(delta) == 0);
|
assert(ex64hi(delta) == 0);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size,
|
||||||
if (!to_eof) {
|
if (!to_eof) {
|
||||||
assert(cmp64(pos, rule->end) < 0);
|
assert(cmp64(pos, rule->end) < 0);
|
||||||
|
|
||||||
delta = rule->end - pos;
|
delta = sub64(rule->end, pos);
|
||||||
|
|
||||||
if (cmp64u(delta, *size) < 0)
|
if (cmp64u(delta, *size) < 0)
|
||||||
*size = ex64lo(delta);
|
*size = ex64lo(delta);
|
||||||
|
@ -186,16 +186,16 @@ static void action_pre_misdir(struct fbd_rule *rule, iovec_t *UNUSED(iov),
|
||||||
* here, because we have no idea about the actual disk size, and the
|
* here, because we have no idea about the actual disk size, and the
|
||||||
* resulting address must of course be valid..
|
* resulting address must of course be valid..
|
||||||
*/
|
*/
|
||||||
range = ((rule->params.misdir.end - rule->params.misdir.start) + 1)
|
range = div64u(add64u(sub64(rule->params.misdir.end,
|
||||||
/ rule->params.misdir.align;
|
rule->params.misdir.start), 1), rule->params.misdir.align);
|
||||||
|
|
||||||
if (range > 0)
|
if (range > 0)
|
||||||
choice = get_rand(range - 1);
|
choice = get_rand(range - 1);
|
||||||
else
|
else
|
||||||
choice = 0;
|
choice = 0;
|
||||||
|
|
||||||
*pos = rule->params.misdir.start +
|
*pos = add64(rule->params.misdir.start,
|
||||||
(u64_t)(choice * rule->params.misdir.align);
|
mul64u(choice, rule->params.misdir.align));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
|
Loading…
Reference in a new issue