Commit 283eda57 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix fallocate FL_INSERT_RANGE

This was another bug because of bch2_btree_iter_set_pos() invalidating
iterators.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 59a38a38
...@@ -2484,10 +2484,8 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2484,10 +2484,8 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
bkey_on_stack_reassemble(&copy, c, k); bkey_on_stack_reassemble(&copy, c, k);
if (insert && if (insert &&
bkey_cmp(bkey_start_pos(k.k), move_pos) < 0) { bkey_cmp(bkey_start_pos(k.k), move_pos) < 0)
bch2_cut_front(move_pos, copy.k); bch2_cut_front(move_pos, copy.k);
bch2_btree_iter_set_pos(src, bkey_start_pos(&copy.k->k));
}
copy.k->k.p.offset += shift >> 9; copy.k->k.p.offset += shift >> 9;
bch2_btree_iter_set_pos(dst, bkey_start_pos(&copy.k->k)); bch2_btree_iter_set_pos(dst, bkey_start_pos(&copy.k->k));
...@@ -2507,8 +2505,9 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2507,8 +2505,9 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
} }
bkey_init(&delete.k); bkey_init(&delete.k);
delete.k.p = src->pos; delete.k.p = copy.k->k.p;
bch2_key_resize(&delete.k, copy.k->k.size); delete.k.size = copy.k->k.size;
delete.k.p.offset -= shift >> 9;
next_pos = insert ? bkey_start_pos(&delete.k) : delete.k.p; next_pos = insert ? bkey_start_pos(&delete.k) : delete.k.p;
...@@ -2529,6 +2528,8 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2529,6 +2528,8 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
BUG_ON(ret); BUG_ON(ret);
} }
bch2_btree_iter_set_pos(src, bkey_start_pos(&delete.k));
ret = bch2_trans_update(&trans, src, &delete, trigger_flags) ?: ret = bch2_trans_update(&trans, src, &delete, trigger_flags) ?:
bch2_trans_update(&trans, dst, copy.k, trigger_flags) ?: bch2_trans_update(&trans, dst, copy.k, trigger_flags) ?:
bch2_trans_commit(&trans, &disk_res, bch2_trans_commit(&trans, &disk_res,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment