summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
Diffstat (limited to 'check')
-rw-r--r--check/mode-lowmem.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index e8588c38..ea6163a6 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -538,6 +538,30 @@ static int end_avoid_extents_overwrite(struct btrfs_fs_info *fs_info)
}
/*
+ * 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,
* If corresponding extent item exists, increase the ref, else insert an extent
* item and backref.
@@ -4991,7 +5015,7 @@ out:
reset_cached_block_groups(fs_info);
/* update block accounting */
- ret = btrfs_fix_block_accounting(trans, root);
+ ret = repair_block_accounting(fs_info);
if (ret)
err |= ret;
else