projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix compilation on centos 7
[fio.git]
/
lib
/
axmap.c
diff --git
a/lib/axmap.c
b/lib/axmap.c
index 4dbef31c22738651efae5805fabeeff015e71635..454af0b9d0361806bbf515c2e9c5c94776db3891 100644
(file)
--- a/
lib/axmap.c
+++ b/
lib/axmap.c
@@
-156,10
+156,10
@@
static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr,
void *), void *data)
{
struct axmap_level *al;
void *), void *data)
{
struct axmap_level *al;
+ uint64_t index = bit_nr;
int i;
for (i = 0; i < axmap->nr_levels; i++) {
int i;
for (i = 0; i < axmap->nr_levels; i++) {
- unsigned long index = ulog64(bit_nr, i);
unsigned long offset = index >> UNIT_SHIFT;
unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
unsigned long offset = index >> UNIT_SHIFT;
unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
@@
-167,16
+167,17
@@
static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr,
if (func(al, offset, bit, data))
return true;
if (func(al, offset, bit, data))
return true;
+
+ if (index)
+ index >>= UNIT_SHIFT;
}
return false;
}
static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
}
return false;
}
static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
- bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *),
- void *data)
+ bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *))
{
{
- struct axmap_level *al;
int i;
for (i = axmap->nr_levels - 1; i >= 0; i--) {
int i;
for (i = axmap->nr_levels - 1; i >= 0; i--) {
@@
-184,9
+185,7
@@
static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
unsigned long offset = index >> UNIT_SHIFT;
unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
unsigned long offset = index >> UNIT_SHIFT;
unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
- al = &axmap->levels[i];
-
- if (func(al, offset, bit, data))
+ if (func(&axmap->levels[i], offset, bit, NULL))
return true;
}
return true;
}
@@
-231,15
+230,18
@@
static bool axmap_set_fn(struct axmap_level *al, unsigned long offset,
* Mask off any potential overlap, only sets contig regions
*/
overlap = al->map[offset] & mask;
* Mask off any potential overlap, only sets contig regions
*/
overlap = al->map[offset] & mask;
- if (overlap == mask)
+ if (overlap == mask) {
+done:
+ data->set_bits = 0;
return true;
return true;
+ }
if (overlap) {
const int __bit = ffz(~overlap);
nr_bits = __bit - bit;
if (!nr_bits)
if (overlap) {
const int __bit = ffz(~overlap);
nr_bits = __bit - bit;
if (!nr_bits)
-
return tru
e;
+
goto don
e;
mask = bit_masks[nr_bits] << bit;
}
mask = bit_masks[nr_bits] << bit;
}
@@
-304,7
+306,7
@@
unsigned int axmap_set_nr(struct axmap *axmap, uint64_t bit_nr,
unsigned int max_bits, this_set;
max_bits = BLOCKS_PER_UNIT - (bit_nr & BLOCKS_PER_UNIT_MASK);
unsigned int max_bits, this_set;
max_bits = BLOCKS_PER_UNIT - (bit_nr & BLOCKS_PER_UNIT_MASK);
- if (
max_bits < nr
_bits)
+ if (
nr_bits > max
_bits)
data.nr_bits = max_bits;
this_set = data.nr_bits;
data.nr_bits = max_bits;
this_set = data.nr_bits;
@@
-329,7
+331,7
@@
static bool axmap_isset_fn(struct axmap_level *al, unsigned long offset,
bool axmap_isset(struct axmap *axmap, uint64_t bit_nr)
{
if (bit_nr <= axmap->nr_bits)
bool axmap_isset(struct axmap *axmap, uint64_t bit_nr)
{
if (bit_nr <= axmap->nr_bits)
- return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn
, NULL
);
+ return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn);
return false;
}
return false;
}
@@
-347,13
+349,8
@@
static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
for (i = level; i >= 0; i--) {
struct axmap_level *al = &axmap->levels[i];
for (i = level; i >= 0; i--) {
struct axmap_level *al = &axmap->levels[i];
- /*
- * Clear 'ret', this is a bug condition.
- */
- if (index >= al->map_size) {
- ret = -1ULL;
- break;
- }
+ if (index >= al->map_size)
+ goto err;
for (j = index; j < al->map_size; j++) {
if (al->map[j] == -1UL)
for (j = index; j < al->map_size; j++) {
if (al->map[j] == -1UL)
@@
-371,6
+368,7
@@
static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
if (ret < axmap->nr_bits)
return ret;
if (ret < axmap->nr_bits)
return ret;
+err:
return (uint64_t) -1ULL;
}
return (uint64_t) -1ULL;
}