mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-25 23:52:17 +00:00
Btrfs-progs: fix the allocator
The allocator looks for these hints when moving on to another block group which will make it reset which block group it looks at, when we've already searched that block group and didn't find any space to allocate, we need to fix this by just letting the allocator make the determination if the block group is good enough. This also fixes a problem where if we couldn't find space in the block group we were given we'd just error out instead of moving on to the next block group. Previously I couldn't fix some file systems that were relatively full, but with this patch I can now run fsck on them with no allocation errors. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
e0ac34931a
commit
7a70b159af
@ -245,24 +245,22 @@ static int noinline find_search_start(struct btrfs_root *root,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct btrfs_block_group_cache *cache = *cache_ret;
|
struct btrfs_block_group_cache *cache = *cache_ret;
|
||||||
u64 last;
|
u64 last = *start_ret;
|
||||||
u64 start = 0;
|
u64 start = 0;
|
||||||
u64 end = 0;
|
u64 end = 0;
|
||||||
u64 search_start = *start_ret;
|
u64 search_start = *start_ret;
|
||||||
int wrapped = 0;
|
int wrapped = 0;
|
||||||
|
|
||||||
if (!cache) {
|
if (!cache)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
again:
|
again:
|
||||||
ret = cache_block_group(root, cache);
|
ret = cache_block_group(root, cache);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
last = max(search_start, cache->key.objectid);
|
last = max(search_start, cache->key.objectid);
|
||||||
if (cache->ro || !block_group_bits(cache, data)) {
|
if (cache->ro || !block_group_bits(cache, data))
|
||||||
goto new_group;
|
goto new_group;
|
||||||
}
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
ret = find_first_extent_bit(&root->fs_info->free_space_cache,
|
ret = find_first_extent_bit(&root->fs_info->free_space_cache,
|
||||||
@ -283,6 +281,7 @@ again:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
*start_ret = last;
|
||||||
cache = btrfs_lookup_block_group(root->fs_info, search_start);
|
cache = btrfs_lookup_block_group(root->fs_info, search_start);
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
printk("Unable to find block group for %llu\n",
|
printk("Unable to find block group for %llu\n",
|
||||||
@ -296,7 +295,6 @@ new_group:
|
|||||||
wrapped:
|
wrapped:
|
||||||
cache = btrfs_lookup_first_block_group(root->fs_info, last);
|
cache = btrfs_lookup_first_block_group(root->fs_info, last);
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
no_cache:
|
|
||||||
if (!wrapped) {
|
if (!wrapped) {
|
||||||
wrapped = 1;
|
wrapped = 1;
|
||||||
last = search_start;
|
last = search_start;
|
||||||
@ -304,11 +302,6 @@ no_cache:
|
|||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
cache = btrfs_find_block_group(root, cache, last, data, 0);
|
|
||||||
cache = btrfs_find_block_group(root, cache, last, data, 0);
|
|
||||||
if (!cache)
|
|
||||||
goto no_cache;
|
|
||||||
|
|
||||||
*cache_ret = cache;
|
*cache_ret = cache;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -2599,7 +2592,7 @@ check_failed:
|
|||||||
ret = find_search_start(root, &block_group, &search_start,
|
ret = find_search_start(root, &block_group, &search_start,
|
||||||
total_needed, data);
|
total_needed, data);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto new_group;
|
||||||
|
|
||||||
ins->objectid = search_start;
|
ins->objectid = search_start;
|
||||||
ins->offset = num_bytes;
|
ins->offset = num_bytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user