mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: check: lowmem: introduce repair_block_accounting
Introduce repair_block_accounting() which calls btrfs_fix_block_accounting() to repair block group accouting. Replace btrfs_fix_block_accounting() with the new function. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b9fb29a9ba
commit
ea8763bd05
@ -537,6 +537,30 @@ static int end_avoid_extents_overwrite(struct btrfs_fs_info *fs_info)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapper function for btrfs_fix_block_accounting().
|
||||||
|
*
|
||||||
|
* Returns 0 on success.
|
||||||
|
* Returns != 0 on error.
|
||||||
|
*/
|
||||||
|
static int repair_block_accounting(struct btrfs_fs_info *fs_info)
|
||||||
|
{
|
||||||
|
struct btrfs_trans_handle *trans = NULL;
|
||||||
|
struct btrfs_root *root = fs_info->extent_root;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
trans = btrfs_start_transaction(root, 1);
|
||||||
|
if (IS_ERR(trans)) {
|
||||||
|
ret = PTR_ERR(trans);
|
||||||
|
error("fail to start transaction %s", strerror(-ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = btrfs_fix_block_accounting(trans, root);
|
||||||
|
btrfs_commit_transaction(trans, root);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function only handles BACKREF_MISSING,
|
* This function only handles BACKREF_MISSING,
|
||||||
* If corresponding extent item exists, increase the ref, else insert an extent
|
* If corresponding extent item exists, increase the ref, else insert an extent
|
||||||
@ -4991,7 +5015,7 @@ out:
|
|||||||
|
|
||||||
reset_cached_block_groups(fs_info);
|
reset_cached_block_groups(fs_info);
|
||||||
/* update block accounting */
|
/* update block accounting */
|
||||||
ret = btrfs_fix_block_accounting(trans, root);
|
ret = repair_block_accounting(fs_info);
|
||||||
if (ret)
|
if (ret)
|
||||||
err |= ret;
|
err |= ret;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user