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 mid, low = 0, high = ngroups - 1;
|
||||
|
||||
low += block << map->log2_groups_per_block;
|
||||
high += block << map->log2_groups_per_block;
|
||||
|
||||
while (low <= high) {
|
||||
mid = (low + high) / 2;
|
||||
|
||||
|
@ -272,9 +275,8 @@ static uint32_t find_last_group(struct ftl_map *map, uint32_t block)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (((mid + 1) >= ngroups) ||
|
||||
is_group_erased(map, mid + 1))
|
||||
return (block << map->log2_groups_per_block) + mid;
|
||||
if (is_group_erased(map, mid + 1))
|
||||
return mid;
|
||||
|
||||
low = mid + 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue