Commit d248ee56 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add iter_flags arg to bch2_btree_delete_range()

Will be used by the new snapshot tests, to pass in
BTREE_ITER_ALL_SNAPSHOTS.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 200472e9
...@@ -63,7 +63,7 @@ int bch2_btree_insert(struct bch_fs *, enum btree_id, struct bkey_i *, ...@@ -63,7 +63,7 @@ int bch2_btree_insert(struct bch_fs *, enum btree_id, struct bkey_i *,
int bch2_btree_delete_range_trans(struct btree_trans *, enum btree_id, int bch2_btree_delete_range_trans(struct btree_trans *, enum btree_id,
struct bpos, struct bpos, unsigned, u64 *); struct bpos, struct bpos, unsigned, u64 *);
int bch2_btree_delete_range(struct bch_fs *, enum btree_id, int bch2_btree_delete_range(struct bch_fs *, enum btree_id,
struct bpos, struct bpos, u64 *); struct bpos, struct bpos, unsigned, u64 *);
int bch2_btree_node_rewrite(struct btree_trans *, struct btree_iter *, int bch2_btree_node_rewrite(struct btree_trans *, struct btree_iter *,
struct btree *, unsigned); struct btree *, unsigned);
......
...@@ -1475,7 +1475,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, ...@@ -1475,7 +1475,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
*/ */
delete.k.p = iter.pos; delete.k.p = iter.pos;
if (btree_node_type_is_extents(id)) { if (iter.flags & BTREE_ITER_IS_EXTENTS) {
unsigned max_sectors = unsigned max_sectors =
KEY_SIZE_MAX & (~0 << trans->c->block_bits); KEY_SIZE_MAX & (~0 << trans->c->block_bits);
...@@ -1512,8 +1512,10 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, ...@@ -1512,8 +1512,10 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
*/ */
int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id, int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id,
struct bpos start, struct bpos end, struct bpos start, struct bpos end,
unsigned iter_flags,
u64 *journal_seq) u64 *journal_seq)
{ {
return bch2_trans_do(c, NULL, journal_seq, 0, return bch2_trans_do(c, NULL, journal_seq, 0,
bch2_btree_delete_range_trans(&trans, id, start, end, 0, journal_seq)); bch2_btree_delete_range_trans(&trans, id, start, end,
iter_flags, journal_seq));
} }
...@@ -677,7 +677,7 @@ static int ec_stripe_delete(struct bch_fs *c, size_t idx) ...@@ -677,7 +677,7 @@ static int ec_stripe_delete(struct bch_fs *c, size_t idx)
return bch2_btree_delete_range(c, BTREE_ID_stripes, return bch2_btree_delete_range(c, BTREE_ID_stripes,
POS(0, idx), POS(0, idx),
POS(0, idx + 1), POS(0, idx + 1),
NULL); 0, NULL);
} }
static void ec_stripe_delete_work(struct work_struct *work) static void ec_stripe_delete_work(struct work_struct *work)
......
...@@ -570,7 +570,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -570,7 +570,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
ret = bch2_btree_delete_range(c, BTREE_ID_quotas, ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_USR, 0), POS(QTYP_USR, 0),
POS(QTYP_USR + 1, 0), POS(QTYP_USR + 1, 0),
NULL); 0, NULL);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -582,7 +582,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -582,7 +582,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
ret = bch2_btree_delete_range(c, BTREE_ID_quotas, ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_GRP, 0), POS(QTYP_GRP, 0),
POS(QTYP_GRP + 1, 0), POS(QTYP_GRP + 1, 0),
NULL); 0, NULL);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -594,7 +594,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -594,7 +594,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
ret = bch2_btree_delete_range(c, BTREE_ID_quotas, ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_PRJ, 0), POS(QTYP_PRJ, 0),
POS(QTYP_PRJ + 1, 0), POS(QTYP_PRJ + 1, 0),
NULL); 0, NULL);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -1484,7 +1484,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) ...@@ -1484,7 +1484,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
return bch2_btree_delete_range(c, BTREE_ID_alloc, return bch2_btree_delete_range(c, BTREE_ID_alloc,
POS(ca->dev_idx, 0), POS(ca->dev_idx, 0),
POS(ca->dev_idx + 1, 0), POS(ca->dev_idx + 1, 0),
NULL); 0, NULL);
} }
int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
......
...@@ -14,14 +14,14 @@ static void delete_test_keys(struct bch_fs *c) ...@@ -14,14 +14,14 @@ static void delete_test_keys(struct bch_fs *c)
int ret; int ret;
ret = bch2_btree_delete_range(c, BTREE_ID_extents, ret = bch2_btree_delete_range(c, BTREE_ID_extents,
SPOS(0, 0, U32_MAX), POS_MIN, SPOS_MAX,
SPOS(0, U64_MAX, U32_MAX), BTREE_ITER_ALL_SNAPSHOTS,
NULL); NULL);
BUG_ON(ret); BUG_ON(ret);
ret = bch2_btree_delete_range(c, BTREE_ID_xattrs, ret = bch2_btree_delete_range(c, BTREE_ID_xattrs,
SPOS(0, 0, U32_MAX), POS_MIN, SPOS_MAX,
SPOS(0, U64_MAX, U32_MAX), BTREE_ITER_ALL_SNAPSHOTS,
NULL); NULL);
BUG_ON(ret); BUG_ON(ret);
} }
...@@ -749,7 +749,9 @@ static int seq_delete(struct bch_fs *c, u64 nr) ...@@ -749,7 +749,9 @@ static int seq_delete(struct bch_fs *c, u64 nr)
int ret; int ret;
ret = bch2_btree_delete_range(c, BTREE_ID_xattrs, ret = bch2_btree_delete_range(c, BTREE_ID_xattrs,
SPOS(0, 0, U32_MAX), POS_MAX, NULL); POS_MIN, SPOS_MAX,
BTREE_ITER_ALL_SNAPSHOTS,
NULL);
if (ret) if (ret)
bch_err(c, "error in seq_delete: %i", ret); bch_err(c, "error in seq_delete: %i", ret);
return ret; return ret;
......
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