summaryrefslogtreecommitdiff
path: root/check/mode-lowmem.c
diff options
context:
space:
mode:
authorSu Yue <suy.fnst@cn.fujitsu.com>2018-05-08 16:30:04 +0800
committerDavid Sterba <dsterba@suse.com>2018-06-07 16:37:31 +0200
commite9f0396a42eb3e59ad70c2ae2eb1fff7deea14db (patch)
tree542eaef7925de93ea5dc676b5c790606a95c2ef5 /check/mode-lowmem.c
parent50782a34d7eb85c38f12b95f76d2507af8b4cc6d (diff)
btrfs-progs: check: lowmem: remove parameter @trans of delete_extent_item
This patch removes the parameter @trans of delete_extent_item(). It calls try_avoid_extents_overwrite() and starts a transaction by itself. 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>
Diffstat (limited to 'check/mode-lowmem.c')
-rw-r--r--check/mode-lowmem.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index cad13149..55e06ebf 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -4124,13 +4124,22 @@ out:
return err;
}
-static int delete_extent_tree_item(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
+static int delete_extent_tree_item(struct btrfs_root *root,
struct btrfs_path *path)
{
struct btrfs_key key;
+ struct btrfs_trans_handle *trans;
int ret = 0;
+ ret = avoid_extents_overwrite(root->fs_info);
+ if (ret)
+ return ret;
+ trans = btrfs_start_transaction(root, 1);
+ if (IS_ERR(trans)) {
+ ret = PTR_ERR(trans);
+ error("fail to start transaction %s", strerror(-ret));
+ goto out;
+ }
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
btrfs_release_path(path);
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
@@ -4148,6 +4157,7 @@ static int delete_extent_tree_item(struct btrfs_trans_handle *trans,
else
path->slots[0]--;
out:
+ btrfs_commit_transaction(trans, root);
if (ret)
error("failed to delete root %llu item[%llu, %u, %llu]",
root->objectid, key.objectid, key.type, key.offset);
@@ -4199,7 +4209,7 @@ again:
ret = check_block_group_item(fs_info, eb, slot);
if (repair &&
ret & REFERENCER_MISSING)
- ret = delete_extent_tree_item(trans, root, path);
+ ret = delete_extent_tree_item(root, path);
err |= ret;
break;
case BTRFS_DEV_ITEM_KEY:
@@ -4230,7 +4240,7 @@ again:
key.objectid, -1);
if (repair &&
ret & (REFERENCER_MISMATCH | REFERENCER_MISSING))
- ret = delete_extent_tree_item(trans, root, path);
+ ret = delete_extent_tree_item(root, path);
err |= ret;
break;
case BTRFS_EXTENT_DATA_REF_KEY:
@@ -4243,7 +4253,7 @@ again:
btrfs_extent_data_ref_count(eb, dref));
if (repair &&
ret & (REFERENCER_MISMATCH | REFERENCER_MISSING))
- ret = delete_extent_tree_item(trans, root, path);
+ ret = delete_extent_tree_item(root, path);
err |= ret;
break;
case BTRFS_SHARED_BLOCK_REF_KEY:
@@ -4251,7 +4261,7 @@ again:
key.objectid, -1);
if (repair &&
ret & (REFERENCER_MISMATCH | REFERENCER_MISSING))
- ret = delete_extent_tree_item(trans, root, path);
+ ret = delete_extent_tree_item(root, path);
err |= ret;
break;
case BTRFS_SHARED_DATA_REF_KEY:
@@ -4259,7 +4269,7 @@ again:
key.objectid);
if (repair &&
ret & (REFERENCER_MISMATCH | REFERENCER_MISSING))
- ret = delete_extent_tree_item(trans, root, path);
+ ret = delete_extent_tree_item(root, path);
err |= ret;
break;
default: