aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-10-29 18:58:50 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:15 -0400
commit2debb1b875c140c7a5490d5eb9e88b3c51f375e2 (patch)
treef528c328e6687af143a9cabdace46e10ae281232
parent904823de497fa6637db8bc7c3b017f121b72bdf3 (diff)
bcachefs: BTREE_TRIGGER_INSERT now only means insert
This allows triggers to distinguish between a key entering the btree - i.e. being called from the trans commit path - vs. being called on a key that already exists, i.e. by GC. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/btree_gc.c4
-rw-r--r--fs/bcachefs/buckets.c26
-rw-r--r--fs/bcachefs/ec.c1
3 files changed, 6 insertions, 25 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 48fd89195357..197f5c0f3a9a 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -697,7 +697,6 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
struct bkey_ptrs_c ptrs;
const struct bch_extent_ptr *ptr;
unsigned flags =
- BTREE_TRIGGER_INSERT|
BTREE_TRIGGER_GC|
(initial ? BTREE_TRIGGER_NOATOMIC : 0);
char buf[200];
@@ -1117,8 +1116,7 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c)
for_each_pending_btree_node_free(c, as, d)
if (d->index_update_done)
- bch2_mark_key(c, bkey_i_to_s_c(&d->key),
- BTREE_TRIGGER_INSERT|BTREE_TRIGGER_GC);
+ bch2_mark_key(c, bkey_i_to_s_c(&d->key), BTREE_TRIGGER_GC);
mutex_unlock(&c->btree_interior_update_lock);
}
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index a114a1142340..6e1837a0fc64 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -929,7 +929,7 @@ static int bch2_mark_extent(struct btree_trans *trans,
bool gc = flags & BTREE_TRIGGER_GC;
u64 journal_seq = trans->journal_res.seq;
struct bch_fs *c = trans->c;
- struct bkey_s_c k = flags & BTREE_TRIGGER_INSERT ? new : old;
+ struct bkey_s_c k = flags & BTREE_TRIGGER_OVERWRITE ? old: new;
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
const union bch_extent_entry *entry;
struct extent_ptr_decoded p;
@@ -944,9 +944,6 @@ static int bch2_mark_extent(struct btree_trans *trans,
bool stale;
int ret;
- BUG_ON((flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)) ==
- (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE));
-
r.e.data_type = data_type;
r.e.nr_devs = 0;
r.e.nr_required = 1;
@@ -1112,7 +1109,7 @@ static int bch2_mark_reservation(struct btree_trans *trans,
unsigned flags)
{
struct bch_fs *c = trans->c;
- struct bkey_s_c k = flags & BTREE_TRIGGER_INSERT ? new : old;
+ struct bkey_s_c k = flags & BTREE_TRIGGER_OVERWRITE ? old: new;
struct bch_fs_usage __percpu *fs_usage;
unsigned replicas = bkey_s_c_to_reservation(k).v->nr_replicas;
s64 sectors = (s64) k.k->size;
@@ -1185,7 +1182,7 @@ static int bch2_mark_reflink_p(struct btree_trans *trans,
unsigned flags)
{
struct bch_fs *c = trans->c;
- struct bkey_s_c k = flags & BTREE_TRIGGER_INSERT ? new : old;
+ struct bkey_s_c k = flags & BTREE_TRIGGER_OVERWRITE ? old: new;
struct bkey_s_c_reflink_p p = bkey_s_c_to_reflink_p(k);
struct reflink_gc *ref;
size_t l, r, m;
@@ -1194,9 +1191,6 @@ static int bch2_mark_reflink_p(struct btree_trans *trans,
le32_to_cpu(p.v->back_pad);
int ret = 0;
- BUG_ON((flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)) ==
- (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE));
-
l = 0;
r = c->reflink_gc_nr;
while (l < r) {
@@ -1220,9 +1214,7 @@ static int bch2_mark_key_locked(struct btree_trans *trans,
struct bkey_s_c new,
unsigned flags)
{
- struct bkey_s_c k = flags & BTREE_TRIGGER_INSERT ? new : old;
-
- BUG_ON(!(flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)));
+ struct bkey_s_c k = flags & BTREE_TRIGGER_OVERWRITE ? old: new;
switch (k.k->type) {
case KEY_TYPE_alloc:
@@ -1541,9 +1533,6 @@ static int bch2_trans_mark_extent(struct btree_trans *trans,
bool stale;
int ret;
- BUG_ON((flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)) ==
- (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE));
-
r.e.data_type = data_type;
r.e.nr_devs = 0;
r.e.nr_required = 1;
@@ -1715,9 +1704,6 @@ static int bch2_trans_mark_reservation(struct btree_trans *trans,
s64 sectors = (s64) k.k->size;
struct replicas_delta_list *d;
- BUG_ON((flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)) ==
- (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE));
-
if (flags & BTREE_TRIGGER_OVERWRITE)
sectors = -sectors;
sectors *= replicas;
@@ -1837,9 +1823,7 @@ static int bch2_trans_mark_reflink_p(struct btree_trans *trans,
int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c old,
struct bkey_s_c new, unsigned flags)
{
- struct bkey_s_c k = flags & BTREE_TRIGGER_INSERT ? new : old;
-
- BUG_ON(!(flags & (BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE)));
+ struct bkey_s_c k = flags & BTREE_TRIGGER_OVERWRITE ? old: new;
switch (k.k->type) {
case KEY_TYPE_btree_ptr:
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 74dc6c40dc9e..32b17f05a750 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1642,7 +1642,6 @@ static int bch2_stripes_read_fn(struct btree_trans *trans, struct bkey_s_c k)
if (k.k->type == KEY_TYPE_stripe)
ret = __ec_stripe_mem_alloc(c, k.k->p.offset, GFP_KERNEL) ?:
bch2_mark_key(trans, k,
- BTREE_TRIGGER_INSERT|
BTREE_TRIGGER_NOATOMIC);
return ret;