ftl: fix find_last_group() to use proper group offsets
This commit is contained in:
parent
51da9338ea
commit
e6c1197d07
1 changed files with 5 additions and 3 deletions
|
@ -264,6 +264,9 @@ static uint32_t find_last_group(struct ftl_map *map, uint32_t block)
|
||||||
uint32_t ngroups = UINT32_C(1) << map->log2_groups_per_block;
|
uint32_t ngroups = UINT32_C(1) << map->log2_groups_per_block;
|
||||||
uint32_t mid, low = 0, high = ngroups - 1;
|
uint32_t mid, low = 0, high = ngroups - 1;
|
||||||
|
|
||||||
|
low += block << map->log2_groups_per_block;
|
||||||
|
high += block << map->log2_groups_per_block;
|
||||||
|
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
mid = (low + high) / 2;
|
mid = (low + high) / 2;
|
||||||
|
|
||||||
|
@ -272,9 +275,8 @@ static uint32_t find_last_group(struct ftl_map *map, uint32_t block)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((mid + 1) >= ngroups) ||
|
if (is_group_erased(map, mid + 1))
|
||||||
is_group_erased(map, mid + 1))
|
return mid;
|
||||||
return (block << map->log2_groups_per_block) + mid;
|
|
||||||
|
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue