Commit 2d594dfb authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Split out btree_trigger_flags

The trigger flags really belong with individual btree_insert_entries,
not the transaction commit flags - this splits out those  flags and
unifies them with the BCH_BUCKET_MARK flags. Todo - split out
btree_trigger.c from buckets.c
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 54e86b58
...@@ -380,7 +380,7 @@ int bch2_acl_chmod(struct btree_trans *trans, ...@@ -380,7 +380,7 @@ int bch2_acl_chmod(struct btree_trans *trans,
} }
new->k.p = iter->pos; new->k.p = iter->pos;
bch2_trans_update(trans, iter, &new->k_i); bch2_trans_update(trans, iter, &new->k_i, 0);
*new_acl = acl; *new_acl = acl;
acl = NULL; acl = NULL;
err: err:
......
...@@ -222,8 +222,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -222,8 +222,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret) for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret)
bch2_mark_key(c, k, 0, 0, NULL, 0, bch2_mark_key(c, k, 0, 0, NULL, 0,
BCH_BUCKET_MARK_ALLOC_READ| BTREE_TRIGGER_ALLOC_READ|
BCH_BUCKET_MARK_NOATOMIC); BTREE_TRIGGER_NOATOMIC);
ret = bch2_trans_exit(&trans) ?: ret; ret = bch2_trans_exit(&trans) ?: ret;
if (ret) { if (ret) {
...@@ -235,8 +235,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -235,8 +235,8 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
if (j->btree_id == BTREE_ID_ALLOC) if (j->btree_id == BTREE_ID_ALLOC)
bch2_mark_key(c, bkey_i_to_s_c(j->k), bch2_mark_key(c, bkey_i_to_s_c(j->k),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_ALLOC_READ| BTREE_TRIGGER_ALLOC_READ|
BCH_BUCKET_MARK_NOATOMIC); BTREE_TRIGGER_NOATOMIC);
percpu_down_write(&c->mark_lock); percpu_down_write(&c->mark_lock);
bch2_dev_usage_from_buckets(c); bch2_dev_usage_from_buckets(c);
...@@ -314,11 +314,10 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -314,11 +314,10 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
a->k.p = iter->pos; a->k.p = iter->pos;
bch2_alloc_pack(a, new_u); bch2_alloc_pack(a, new_u);
bch2_trans_update(trans, iter, &a->k_i); bch2_trans_update(trans, iter, &a->k_i,
BTREE_TRIGGER_NORUN);
ret = bch2_trans_commit(trans, NULL, NULL, ret = bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|flags);
BTREE_INSERT_NOMARK|
flags);
err: err:
if (ret == -EINTR) if (ret == -EINTR)
goto retry; goto retry;
...@@ -383,8 +382,7 @@ int bch2_alloc_replay_key(struct bch_fs *c, struct bkey_i *k) ...@@ -383,8 +382,7 @@ int bch2_alloc_replay_key(struct bch_fs *c, struct bkey_i *k)
ret = bch2_alloc_write_key(&trans, iter, ret = bch2_alloc_write_key(&trans, iter,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW| BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY| BTREE_INSERT_JOURNAL_REPLAY);
BTREE_INSERT_NOMARK);
bch2_trans_exit(&trans); bch2_trans_exit(&trans);
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
...@@ -901,7 +899,8 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans, ...@@ -901,7 +899,8 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans,
a->k.p = iter->pos; a->k.p = iter->pos;
bch2_alloc_pack(a, u); bch2_alloc_pack(a, u);
bch2_trans_update(trans, iter, &a->k_i); bch2_trans_update(trans, iter, &a->k_i,
BTREE_TRIGGER_BUCKET_INVALIDATE);
/* /*
* XXX: * XXX:
...@@ -917,7 +916,6 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans, ...@@ -917,7 +916,6 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_USE_RESERVE| BTREE_INSERT_USE_RESERVE|
BTREE_INSERT_USE_ALLOC_RESERVE| BTREE_INSERT_USE_ALLOC_RESERVE|
BTREE_INSERT_BUCKET_INVALIDATE|
flags); flags);
if (ret == -EINTR) if (ret == -EINTR)
goto retry; goto retry;
......
...@@ -118,8 +118,8 @@ static int bch2_gc_mark_key(struct bch_fs *c, struct bkey_s_c k, ...@@ -118,8 +118,8 @@ static int bch2_gc_mark_key(struct bch_fs *c, struct bkey_s_c k,
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
const struct bch_extent_ptr *ptr; const struct bch_extent_ptr *ptr;
unsigned flags = unsigned flags =
BCH_BUCKET_MARK_GC| BTREE_TRIGGER_GC|
(initial ? BCH_BUCKET_MARK_NOATOMIC : 0); (initial ? BTREE_TRIGGER_NOATOMIC : 0);
int ret = 0; int ret = 0;
if (initial) { if (initial) {
...@@ -296,8 +296,8 @@ static int mark_journal_key(struct bch_fs *c, enum btree_id id, ...@@ -296,8 +296,8 @@ static int mark_journal_key(struct bch_fs *c, enum btree_id id,
BTREE_ITER_SLOTS, k, ret) { BTREE_ITER_SLOTS, k, ret) {
percpu_down_read(&c->mark_lock); percpu_down_read(&c->mark_lock);
ret = bch2_mark_overwrite(&trans, iter, k, insert, NULL, ret = bch2_mark_overwrite(&trans, iter, k, insert, NULL,
BCH_BUCKET_MARK_GC| BTREE_TRIGGER_GC|
BCH_BUCKET_MARK_NOATOMIC); BTREE_TRIGGER_NOATOMIC);
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
if (!ret) if (!ret)
...@@ -409,7 +409,7 @@ static void bch2_mark_superblocks(struct bch_fs *c) ...@@ -409,7 +409,7 @@ static void bch2_mark_superblocks(struct bch_fs *c)
gc_pos_set(c, gc_phase(GC_PHASE_SB)); gc_pos_set(c, gc_phase(GC_PHASE_SB));
for_each_online_member(ca, c, i) for_each_online_member(ca, c, i)
bch2_mark_dev_superblock(c, ca, BCH_BUCKET_MARK_GC); bch2_mark_dev_superblock(c, ca, BTREE_TRIGGER_GC);
mutex_unlock(&c->sb_lock); mutex_unlock(&c->sb_lock);
} }
...@@ -426,7 +426,7 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c) ...@@ -426,7 +426,7 @@ static void bch2_mark_pending_btree_node_frees(struct bch_fs *c)
if (d->index_update_done) if (d->index_update_done)
bch2_mark_key(c, bkey_i_to_s_c(&d->key), bch2_mark_key(c, bkey_i_to_s_c(&d->key),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
mutex_unlock(&c->btree_interior_update_lock); mutex_unlock(&c->btree_interior_update_lock);
} }
...@@ -447,7 +447,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c) ...@@ -447,7 +447,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
fifo_for_each_entry(i, &ca->free_inc, iter) fifo_for_each_entry(i, &ca->free_inc, iter)
bch2_mark_alloc_bucket(c, ca, i, true, bch2_mark_alloc_bucket(c, ca, i, true,
gc_pos_alloc(c, NULL), gc_pos_alloc(c, NULL),
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
...@@ -455,7 +455,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c) ...@@ -455,7 +455,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
fifo_for_each_entry(i, &ca->free[j], iter) fifo_for_each_entry(i, &ca->free[j], iter)
bch2_mark_alloc_bucket(c, ca, i, true, bch2_mark_alloc_bucket(c, ca, i, true,
gc_pos_alloc(c, NULL), gc_pos_alloc(c, NULL),
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
} }
spin_unlock(&c->freelist_lock); spin_unlock(&c->freelist_lock);
...@@ -469,7 +469,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c) ...@@ -469,7 +469,7 @@ static void bch2_mark_allocator_buckets(struct bch_fs *c)
ca = bch_dev_bkey_exists(c, ob->ptr.dev); ca = bch_dev_bkey_exists(c, ob->ptr.dev);
bch2_mark_alloc_bucket(c, ca, PTR_BUCKET_NR(ca, &ob->ptr), true, bch2_mark_alloc_bucket(c, ca, PTR_BUCKET_NR(ca, &ob->ptr), true,
gc_pos_alloc(c, ob), gc_pos_alloc(c, ob),
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
} }
spin_unlock(&ob->lock); spin_unlock(&ob->lock);
} }
......
...@@ -245,6 +245,7 @@ static inline enum btree_iter_type btree_iter_type(struct btree_iter *iter) ...@@ -245,6 +245,7 @@ static inline enum btree_iter_type btree_iter_type(struct btree_iter *iter)
} }
struct btree_insert_entry { struct btree_insert_entry {
unsigned trigger_flags;
struct bkey_i *k; struct bkey_i *k;
struct btree_iter *iter; struct btree_iter *iter;
}; };
...@@ -484,6 +485,32 @@ static inline bool btree_node_is_extents(struct btree *b) ...@@ -484,6 +485,32 @@ static inline bool btree_node_is_extents(struct btree *b)
(1U << BKEY_TYPE_INODES)| \ (1U << BKEY_TYPE_INODES)| \
(1U << BKEY_TYPE_REFLINK)) (1U << BKEY_TYPE_REFLINK))
enum btree_trigger_flags {
__BTREE_TRIGGER_NORUN, /* Don't run triggers at all */
__BTREE_TRIGGER_NOOVERWRITES, /* Don't run triggers on overwrites */
__BTREE_TRIGGER_INSERT,
__BTREE_TRIGGER_OVERWRITE,
__BTREE_TRIGGER_OVERWRITE_SPLIT,
__BTREE_TRIGGER_GC,
__BTREE_TRIGGER_BUCKET_INVALIDATE,
__BTREE_TRIGGER_ALLOC_READ,
__BTREE_TRIGGER_NOATOMIC,
};
#define BTREE_TRIGGER_NORUN (1U << __BTREE_TRIGGER_NORUN)
#define BTREE_TRIGGER_NOOVERWRITES (1U << __BTREE_TRIGGER_NOOVERWRITES)
#define BTREE_TRIGGER_INSERT (1U << __BTREE_TRIGGER_INSERT)
#define BTREE_TRIGGER_OVERWRITE (1U << __BTREE_TRIGGER_OVERWRITE)
#define BTREE_TRIGGER_OVERWRITE_SPLIT (1U << __BTREE_TRIGGER_OVERWRITE_SPLIT)
#define BTREE_TRIGGER_GC (1U << __BTREE_TRIGGER_GC)
#define BTREE_TRIGGER_BUCKET_INVALIDATE (1U << __BTREE_TRIGGER_BUCKET_INVALIDATE)
#define BTREE_TRIGGER_ALLOC_READ (1U << __BTREE_TRIGGER_ALLOC_READ)
#define BTREE_TRIGGER_NOATOMIC (1U << __BTREE_TRIGGER_NOATOMIC)
static inline bool btree_node_type_needs_gc(enum btree_node_type type) static inline bool btree_node_type_needs_gc(enum btree_node_type type)
{ {
return BTREE_NODE_TYPE_HAS_TRIGGERS & (1U << type); return BTREE_NODE_TYPE_HAS_TRIGGERS & (1U << type);
......
...@@ -15,7 +15,7 @@ bool bch2_btree_bset_insert_key(struct btree_iter *, struct btree *, ...@@ -15,7 +15,7 @@ bool bch2_btree_bset_insert_key(struct btree_iter *, struct btree *,
void bch2_btree_journal_key(struct btree_trans *, struct btree_iter *, void bch2_btree_journal_key(struct btree_trans *, struct btree_iter *,
struct bkey_i *); struct bkey_i *);
enum { enum btree_insert_flags {
__BTREE_INSERT_NOUNLOCK, __BTREE_INSERT_NOUNLOCK,
__BTREE_INSERT_NOFAIL, __BTREE_INSERT_NOFAIL,
__BTREE_INSERT_NOCHECK_RW, __BTREE_INSERT_NOCHECK_RW,
...@@ -24,9 +24,6 @@ enum { ...@@ -24,9 +24,6 @@ enum {
__BTREE_INSERT_USE_ALLOC_RESERVE, __BTREE_INSERT_USE_ALLOC_RESERVE,
__BTREE_INSERT_JOURNAL_REPLAY, __BTREE_INSERT_JOURNAL_REPLAY,
__BTREE_INSERT_JOURNAL_RESERVED, __BTREE_INSERT_JOURNAL_RESERVED,
__BTREE_INSERT_NOMARK_OVERWRITES,
__BTREE_INSERT_NOMARK,
__BTREE_INSERT_BUCKET_INVALIDATE,
__BTREE_INSERT_NOWAIT, __BTREE_INSERT_NOWAIT,
__BTREE_INSERT_GC_LOCK_HELD, __BTREE_INSERT_GC_LOCK_HELD,
__BCH_HASH_SET_MUST_CREATE, __BCH_HASH_SET_MUST_CREATE,
...@@ -53,14 +50,6 @@ enum { ...@@ -53,14 +50,6 @@ enum {
#define BTREE_INSERT_JOURNAL_RESERVED (1 << __BTREE_INSERT_JOURNAL_RESERVED) #define BTREE_INSERT_JOURNAL_RESERVED (1 << __BTREE_INSERT_JOURNAL_RESERVED)
/* Don't mark overwrites, just new key: */
#define BTREE_INSERT_NOMARK_OVERWRITES (1 << __BTREE_INSERT_NOMARK_OVERWRITES)
/* Don't call mark new key at all: */
#define BTREE_INSERT_NOMARK (1 << __BTREE_INSERT_NOMARK)
#define BTREE_INSERT_BUCKET_INVALIDATE (1 << __BTREE_INSERT_BUCKET_INVALIDATE)
/* Don't block on allocation failure (for new btree nodes: */ /* Don't block on allocation failure (for new btree nodes: */
#define BTREE_INSERT_NOWAIT (1 << __BTREE_INSERT_NOWAIT) #define BTREE_INSERT_NOWAIT (1 << __BTREE_INSERT_NOWAIT)
#define BTREE_INSERT_GC_LOCK_HELD (1 << __BTREE_INSERT_GC_LOCK_HELD) #define BTREE_INSERT_GC_LOCK_HELD (1 << __BTREE_INSERT_GC_LOCK_HELD)
...@@ -108,15 +97,15 @@ static inline int bch2_trans_commit(struct btree_trans *trans, ...@@ -108,15 +97,15 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
} }
static inline void bch2_trans_update(struct btree_trans *trans, static inline void bch2_trans_update(struct btree_trans *trans,
struct btree_iter *iter, struct btree_iter *iter, struct bkey_i *k,
struct bkey_i *k) enum btree_trigger_flags flags)
{ {
EBUG_ON(trans->nr_updates >= trans->nr_iters); EBUG_ON(trans->nr_updates >= trans->nr_iters);
iter->flags |= BTREE_ITER_KEEP_UNTIL_COMMIT; iter->flags |= BTREE_ITER_KEEP_UNTIL_COMMIT;
trans->updates[trans->nr_updates++] = (struct btree_insert_entry) { trans->updates[trans->nr_updates++] = (struct btree_insert_entry) {
.iter = iter, .k = k .trigger_flags = flags, .iter = iter, .k = k
}; };
} }
......
...@@ -193,8 +193,8 @@ static void bch2_btree_node_free_index(struct btree_update *as, struct btree *b, ...@@ -193,8 +193,8 @@ static void bch2_btree_node_free_index(struct btree_update *as, struct btree *b,
gc_pos_cmp(c->gc_pos, gc_phase(GC_PHASE_PENDING_DELETE)) < 0) gc_pos_cmp(c->gc_pos, gc_phase(GC_PHASE_PENDING_DELETE)) < 0)
bch2_mark_key_locked(c, bkey_i_to_s_c(&d->key), bch2_mark_key_locked(c, bkey_i_to_s_c(&d->key),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_OVERWRITE| BTREE_TRIGGER_OVERWRITE|
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
} }
static void __btree_node_free(struct bch_fs *c, struct btree *b) static void __btree_node_free(struct bch_fs *c, struct btree *b)
...@@ -265,13 +265,13 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c, ...@@ -265,13 +265,13 @@ static void bch2_btree_node_free_ondisk(struct bch_fs *c,
BUG_ON(!pending->index_update_done); BUG_ON(!pending->index_update_done);
bch2_mark_key(c, bkey_i_to_s_c(&pending->key), bch2_mark_key(c, bkey_i_to_s_c(&pending->key),
0, 0, NULL, 0, BCH_BUCKET_MARK_OVERWRITE); 0, 0, NULL, 0, BTREE_TRIGGER_OVERWRITE);
if (gc_visited(c, gc_phase(GC_PHASE_PENDING_DELETE))) if (gc_visited(c, gc_phase(GC_PHASE_PENDING_DELETE)))
bch2_mark_key(c, bkey_i_to_s_c(&pending->key), bch2_mark_key(c, bkey_i_to_s_c(&pending->key),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_OVERWRITE| BTREE_TRIGGER_OVERWRITE|
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
} }
static struct btree *__bch2_btree_node_alloc(struct bch_fs *c, static struct btree *__bch2_btree_node_alloc(struct bch_fs *c,
...@@ -1084,12 +1084,12 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b) ...@@ -1084,12 +1084,12 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b)
bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key), bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key),
0, 0, &fs_usage->u, 0, 0, 0, &fs_usage->u, 0,
BCH_BUCKET_MARK_INSERT); BTREE_TRIGGER_INSERT);
if (gc_visited(c, gc_pos_btree_root(b->c.btree_id))) if (gc_visited(c, gc_pos_btree_root(b->c.btree_id)))
bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key), bch2_mark_key_locked(c, bkey_i_to_s_c(&b->key),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_INSERT| BTREE_TRIGGER_INSERT|
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
if (old && !btree_node_fake(old)) if (old && !btree_node_fake(old))
bch2_btree_node_free_index(as, NULL, bch2_btree_node_free_index(as, NULL,
...@@ -1182,13 +1182,13 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b ...@@ -1182,13 +1182,13 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
bch2_mark_key_locked(c, bkey_i_to_s_c(insert), bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
0, 0, &fs_usage->u, 0, 0, 0, &fs_usage->u, 0,
BCH_BUCKET_MARK_INSERT); BTREE_TRIGGER_INSERT);
if (gc_visited(c, gc_pos_btree_node(b))) if (gc_visited(c, gc_pos_btree_node(b)))
bch2_mark_key_locked(c, bkey_i_to_s_c(insert), bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_INSERT| BTREE_TRIGGER_INSERT|
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
while ((k = bch2_btree_node_iter_peek_all(node_iter, b)) && while ((k = bch2_btree_node_iter_peek_all(node_iter, b)) &&
bkey_iter_pos_cmp(b, &insert->k.p, k) > 0) bkey_iter_pos_cmp(b, &insert->k.p, k) > 0)
...@@ -2031,12 +2031,12 @@ static void __bch2_btree_node_update_key(struct bch_fs *c, ...@@ -2031,12 +2031,12 @@ static void __bch2_btree_node_update_key(struct bch_fs *c,
bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i), bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i),
0, 0, &fs_usage->u, 0, 0, 0, &fs_usage->u, 0,
BCH_BUCKET_MARK_INSERT); BTREE_TRIGGER_INSERT);
if (gc_visited(c, gc_pos_btree_root(b->c.btree_id))) if (gc_visited(c, gc_pos_btree_root(b->c.btree_id)))
bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i), bch2_mark_key_locked(c, bkey_i_to_s_c(&new_key->k_i),
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_INSERT|| BTREE_TRIGGER_INSERT||
BCH_BUCKET_MARK_GC); BTREE_TRIGGER_GC);
bch2_btree_node_free_index(as, NULL, bch2_btree_node_free_index(as, NULL,
bkey_i_to_s_c(&b->key), bkey_i_to_s_c(&b->key),
......
...@@ -395,17 +395,11 @@ static noinline void bch2_trans_mark_gc(struct btree_trans *trans) ...@@ -395,17 +395,11 @@ static noinline void bch2_trans_mark_gc(struct btree_trans *trans)
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct btree_insert_entry *i; struct btree_insert_entry *i;
unsigned mark_flags = trans->flags & BTREE_INSERT_BUCKET_INVALIDATE
? BCH_BUCKET_MARK_BUCKET_INVALIDATE
: 0;
if (unlikely(trans->flags & BTREE_INSERT_NOMARK))
return;
trans_for_each_update(trans, i) trans_for_each_update(trans, i)
if (gc_visited(c, gc_pos_btree_node(i->iter->l[0].b))) if (gc_visited(c, gc_pos_btree_node(i->iter->l[0].b)))
bch2_mark_update(trans, i->iter, i->k, NULL, bch2_mark_update(trans, i->iter, i->k, NULL,
mark_flags|BCH_BUCKET_MARK_GC); i->trigger_flags|BTREE_TRIGGER_GC);
} }
static inline int static inline int
...@@ -415,9 +409,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, ...@@ -415,9 +409,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct bch_fs_usage_online *fs_usage = NULL; struct bch_fs_usage_online *fs_usage = NULL;
struct btree_insert_entry *i; struct btree_insert_entry *i;
unsigned mark_flags = trans->flags & BTREE_INSERT_BUCKET_INVALIDATE
? BCH_BUCKET_MARK_BUCKET_INVALIDATE
: 0;
unsigned iter, u64s = 0; unsigned iter, u64s = 0;
bool marking = false; bool marking = false;
int ret; int ret;
...@@ -490,10 +481,9 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, ...@@ -490,10 +481,9 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
} }
trans_for_each_update(trans, i) trans_for_each_update(trans, i)
if (likely(!(trans->flags & BTREE_INSERT_NOMARK)) && if (iter_has_nontrans_triggers(i->iter))
iter_has_nontrans_triggers(i->iter))
bch2_mark_update(trans, i->iter, i->k, bch2_mark_update(trans, i->iter, i->k,
&fs_usage->u, mark_flags); &fs_usage->u, i->trigger_flags);
if (marking) if (marking)
bch2_trans_fs_usage_apply(trans, fs_usage); bch2_trans_fs_usage_apply(trans, fs_usage);
...@@ -753,9 +743,9 @@ int __bch2_trans_commit(struct btree_trans *trans) ...@@ -753,9 +743,9 @@ int __bch2_trans_commit(struct btree_trans *trans)
goto out; goto out;
} }
if (likely(!(trans->flags & BTREE_INSERT_NOMARK)) && if (iter_has_trans_triggers(i->iter)) {
iter_has_trans_triggers(i->iter)) { ret = bch2_trans_mark_update(trans, i->iter, i->k,
ret = bch2_trans_mark_update(trans, i->iter, i->k); i->trigger_flags);
if (unlikely(ret)) { if (unlikely(ret)) {
if (ret == -EINTR) if (ret == -EINTR)
trace_trans_restart_mark(trans->ip); trace_trans_restart_mark(trans->ip);
...@@ -805,7 +795,7 @@ static int __bch2_btree_insert(struct btree_trans *trans, ...@@ -805,7 +795,7 @@ static int __bch2_btree_insert(struct btree_trans *trans,
if (IS_ERR(iter)) if (IS_ERR(iter))
return PTR_ERR(iter); return PTR_ERR(iter);
bch2_trans_update(trans, iter, k); bch2_trans_update(trans, iter, k, 0);
return 0; return 0;
} }
...@@ -867,7 +857,7 @@ int bch2_btree_delete_at_range(struct btree_trans *trans, ...@@ -867,7 +857,7 @@ int bch2_btree_delete_at_range(struct btree_trans *trans,
break; break;
} }
bch2_trans_update(trans, iter, &delete); bch2_trans_update(trans, iter, &delete, 0);
ret = bch2_trans_commit(trans, NULL, journal_seq, ret = bch2_trans_commit(trans, NULL, journal_seq,
BTREE_INSERT_NOFAIL); BTREE_INSERT_NOFAIL);
if (ret) if (ret)
...@@ -893,7 +883,7 @@ int bch2_btree_delete_at(struct btree_trans *trans, ...@@ -893,7 +883,7 @@ int bch2_btree_delete_at(struct btree_trans *trans,
bkey_init(&k.k); bkey_init(&k.k);
k.k.p = iter->pos; k.k.p = iter->pos;
bch2_trans_update(trans, iter, &k); bch2_trans_update(trans, iter, &k, 0);
return bch2_trans_commit(trans, NULL, NULL, return bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_USE_RESERVE|flags); BTREE_INSERT_USE_RESERVE|flags);
......
...@@ -628,7 +628,7 @@ int bch2_replicas_delta_list_apply(struct bch_fs *c, ...@@ -628,7 +628,7 @@ int bch2_replicas_delta_list_apply(struct bch_fs *c,
percpu_rwsem_assert_held(&c->mark_lock); \ percpu_rwsem_assert_held(&c->mark_lock); \
\ \
for (gc = 0; gc < 2 && !ret; gc++) \ for (gc = 0; gc < 2 && !ret; gc++) \
if (!gc == !(flags & BCH_BUCKET_MARK_GC) || \ if (!gc == !(flags & BTREE_TRIGGER_GC) || \
(gc && gc_visited(c, pos))) \ (gc && gc_visited(c, pos))) \
ret = fn(c, __VA_ARGS__, gc); \ ret = fn(c, __VA_ARGS__, gc); \
ret; \ ret; \
...@@ -710,7 +710,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -710,7 +710,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
struct bch_fs_usage *fs_usage, struct bch_fs_usage *fs_usage,
u64 journal_seq, unsigned flags) u64 journal_seq, unsigned flags)
{ {
bool gc = flags & BCH_BUCKET_MARK_GC; bool gc = flags & BTREE_TRIGGER_GC;
struct bkey_alloc_unpacked u; struct bkey_alloc_unpacked u;
struct bch_dev *ca; struct bch_dev *ca;
struct bucket *g; struct bucket *g;
...@@ -719,8 +719,8 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -719,8 +719,8 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
/* /*
* alloc btree is read in by bch2_alloc_read, not gc: * alloc btree is read in by bch2_alloc_read, not gc:
*/ */
if ((flags & BCH_BUCKET_MARK_GC) && if ((flags & BTREE_TRIGGER_GC) &&
!(flags & BCH_BUCKET_MARK_BUCKET_INVALIDATE)) !(flags & BTREE_TRIGGER_BUCKET_INVALIDATE))
return 0; return 0;
ca = bch_dev_bkey_exists(c, k.k->p.inode); ca = bch_dev_bkey_exists(c, k.k->p.inode);
...@@ -743,7 +743,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -743,7 +743,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
} }
})); }));
if (!(flags & BCH_BUCKET_MARK_ALLOC_READ)) if (!(flags & BTREE_TRIGGER_ALLOC_READ))
bch2_dev_usage_update(c, ca, fs_usage, old, m, gc); bch2_dev_usage_update(c, ca, fs_usage, old, m, gc);
g->io_time[READ] = u.read_time; g->io_time[READ] = u.read_time;
...@@ -756,7 +756,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -756,7 +756,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
* not: * not:
*/ */
if ((flags & BCH_BUCKET_MARK_BUCKET_INVALIDATE) && if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
old.cached_sectors) { old.cached_sectors) {
update_cached_sectors(c, fs_usage, ca->dev_idx, update_cached_sectors(c, fs_usage, ca->dev_idx,
-old.cached_sectors); -old.cached_sectors);
...@@ -842,13 +842,13 @@ static s64 __ptr_disk_sectors_delta(unsigned old_size, ...@@ -842,13 +842,13 @@ static s64 __ptr_disk_sectors_delta(unsigned old_size,
{ {
BUG_ON(!n || !d); BUG_ON(!n || !d);
if (flags & BCH_BUCKET_MARK_OVERWRITE_SPLIT) { if (flags & BTREE_TRIGGER_OVERWRITE_SPLIT) {
BUG_ON(offset + -delta > old_size); BUG_ON(offset + -delta > old_size);
return -disk_sectors_scaled(n, d, old_size) + return -disk_sectors_scaled(n, d, old_size) +
disk_sectors_scaled(n, d, offset) + disk_sectors_scaled(n, d, offset) +
disk_sectors_scaled(n, d, old_size - offset + delta); disk_sectors_scaled(n, d, old_size - offset + delta);
} else if (flags & BCH_BUCKET_MARK_OVERWRITE) { } else if (flags & BTREE_TRIGGER_OVERWRITE) {
BUG_ON(offset + -delta > old_size); BUG_ON(offset + -delta > old_size);
return -disk_sectors_scaled(n, d, old_size) + return -disk_sectors_scaled(n, d, old_size) +
...@@ -874,8 +874,8 @@ static void bucket_set_stripe(struct bch_fs *c, ...@@ -874,8 +874,8 @@ static void bucket_set_stripe(struct bch_fs *c,
u64 journal_seq, u64 journal_seq,
unsigned flags) unsigned flags)
{ {
bool enabled = !(flags & BCH_BUCKET_MARK_OVERWRITE); bool enabled = !(flags & BTREE_TRIGGER_OVERWRITE);
bool gc = flags & BCH_BUCKET_MARK_GC; bool gc = flags & BTREE_TRIGGER_GC;
unsigned i; unsigned i;
for (i = 0; i < v->nr_blocks; i++) { for (i = 0; i < v->nr_blocks; i++) {
...@@ -922,7 +922,7 @@ static bool bch2_mark_pointer(struct bch_fs *c, ...@@ -922,7 +922,7 @@ static bool bch2_mark_pointer(struct bch_fs *c,
struct bch_fs_usage *fs_usage, struct bch_fs_usage *fs_usage,
u64 journal_seq, unsigned flags) u64 journal_seq, unsigned flags)
{ {
bool gc = flags & BCH_BUCKET_MARK_GC; bool gc = flags & BTREE_TRIGGER_GC;
struct bucket_mark old, new; struct bucket_mark old, new;
struct bch_dev *ca = bch_dev_bkey_exists(c, p.ptr.dev); struct bch_dev *ca = bch_dev_bkey_exists(c, p.ptr.dev);
struct bucket *g = PTR_BUCKET(ca, &p.ptr, gc); struct bucket *g = PTR_BUCKET(ca, &p.ptr, gc);
...@@ -970,7 +970,7 @@ static bool bch2_mark_pointer(struct bch_fs *c, ...@@ -970,7 +970,7 @@ static bool bch2_mark_pointer(struct bch_fs *c,
new.data_type = data_type; new.data_type = data_type;
} }
if (flags & BCH_BUCKET_MARK_NOATOMIC) { if (flags & BTREE_TRIGGER_NOATOMIC) {
g->_mark = new; g->_mark = new;
break; break;
} }
...@@ -1008,7 +1008,7 @@ static int bch2_mark_stripe_ptr(struct bch_fs *c, ...@@ -1008,7 +1008,7 @@ static int bch2_mark_stripe_ptr(struct bch_fs *c,
unsigned *nr_data, unsigned *nr_data,
unsigned *nr_parity) unsigned *nr_parity)
{ {
bool gc = flags & BCH_BUCKET_MARK_GC; bool gc = flags & BTREE_TRIGGER_GC;
struct stripe *m; struct stripe *m;
unsigned old, new; unsigned old, new;
int blocks_nonempty_delta; int blocks_nonempty_delta;
...@@ -1121,7 +1121,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k, ...@@ -1121,7 +1121,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
struct bch_fs_usage *fs_usage, struct bch_fs_usage *fs_usage,
u64 journal_seq, unsigned flags) u64 journal_seq, unsigned flags)
{ {
bool gc = flags & BCH_BUCKET_MARK_GC; bool gc = flags & BTREE_TRIGGER_GC;
struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k); struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);
size_t idx = s.k->p.offset; size_t idx = s.k->p.offset;
struct stripe *m = genradix_ptr(&c->stripes[gc], idx); struct stripe *m = genradix_ptr(&c->stripes[gc], idx);
...@@ -1129,14 +1129,14 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k, ...@@ -1129,14 +1129,14 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
spin_lock(&c->ec_stripes_heap_lock); spin_lock(&c->ec_stripes_heap_lock);
if (!m || ((flags & BCH_BUCKET_MARK_OVERWRITE) && !m->alive)) { if (!m || ((flags & BTREE_TRIGGER_OVERWRITE) && !m->alive)) {
spin_unlock(&c->ec_stripes_heap_lock); spin_unlock(&c->ec_stripes_heap_lock);
bch_err_ratelimited(c, "error marking nonexistent stripe %zu", bch_err_ratelimited(c, "error marking nonexistent stripe %zu",
idx); idx);
return -1; return -1;
} }
if (!(flags & BCH_BUCKET_MARK_OVERWRITE)) { if (!(flags & BTREE_TRIGGER_OVERWRITE)) {
m->sectors = le16_to_cpu(s.v->sectors); m->sectors = le16_to_cpu(s.v->sectors);
m->algorithm = s.v->algorithm; m->algorithm = s.v->algorithm;
m->nr_blocks = s.v->nr_blocks; m->nr_blocks = s.v->nr_blocks;
...@@ -1152,7 +1152,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k, ...@@ -1152,7 +1152,7 @@ static int bch2_mark_stripe(struct bch_fs *c, struct bkey_s_c k,
#endif #endif
/* gc recalculates these fields: */ /* gc recalculates these fields: */
if (!(flags & BCH_BUCKET_MARK_GC)) { if (!(flags & BTREE_TRIGGER_GC)) {
for (i = 0; i < s.v->nr_blocks; i++) { for (i = 0; i < s.v->nr_blocks; i++) {
m->block_sectors[i] = m->block_sectors[i] =
stripe_blockcount_get(s.v, i); stripe_blockcount_get(s.v, i);
...@@ -1185,16 +1185,16 @@ int bch2_mark_key_locked(struct bch_fs *c, ...@@ -1185,16 +1185,16 @@ int bch2_mark_key_locked(struct bch_fs *c,
preempt_disable(); preempt_disable();
if (!fs_usage || (flags & BCH_BUCKET_MARK_GC)) if (!fs_usage || (flags & BTREE_TRIGGER_GC))
fs_usage = fs_usage_ptr(c, journal_seq, fs_usage = fs_usage_ptr(c, journal_seq,
flags & BCH_BUCKET_MARK_GC); flags & BTREE_TRIGGER_GC);
switch (k.k->type) { switch (k.k->type) {
case KEY_TYPE_alloc: case KEY_TYPE_alloc:
ret = bch2_mark_alloc(c, k, fs_usage, journal_seq, flags); ret = bch2_mark_alloc(c, k, fs_usage, journal_seq, flags);
break; break;
case KEY_TYPE_btree_ptr: case KEY_TYPE_btree_ptr:
sectors = !(flags & BCH_BUCKET_MARK_OVERWRITE) sectors = !(flags & BTREE_TRIGGER_OVERWRITE)
? c->opts.btree_node_size ? c->opts.btree_node_size
: -c->opts.btree_node_size; : -c->opts.btree_node_size;
...@@ -1210,7 +1210,7 @@ int bch2_mark_key_locked(struct bch_fs *c, ...@@ -1210,7 +1210,7 @@ int bch2_mark_key_locked(struct bch_fs *c,
ret = bch2_mark_stripe(c, k, fs_usage, journal_seq, flags); ret = bch2_mark_stripe(c, k, fs_usage, journal_seq, flags);
break; break;
case KEY_TYPE_inode: case KEY_TYPE_inode:
if (!(flags & BCH_BUCKET_MARK_OVERWRITE)) if (!(flags & BTREE_TRIGGER_OVERWRITE))
fs_usage->nr_inodes++; fs_usage->nr_inodes++;
else else
fs_usage->nr_inodes--; fs_usage->nr_inodes--;
...@@ -1260,7 +1260,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans, ...@@ -1260,7 +1260,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans,
unsigned offset = 0; unsigned offset = 0;
s64 sectors = 0; s64 sectors = 0;
flags |= BCH_BUCKET_MARK_OVERWRITE; flags |= BTREE_TRIGGER_OVERWRITE;
if (btree_node_is_extents(b) if (btree_node_is_extents(b)
? bkey_cmp(new->k.p, bkey_start_pos(old.k)) <= 0 ? bkey_cmp(new->k.p, bkey_start_pos(old.k)) <= 0
...@@ -1288,7 +1288,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans, ...@@ -1288,7 +1288,7 @@ inline int bch2_mark_overwrite(struct btree_trans *trans,
offset = bkey_start_offset(&new->k) - offset = bkey_start_offset(&new->k) -
bkey_start_offset(old.k); bkey_start_offset(old.k);
sectors = -((s64) new->k.size); sectors = -((s64) new->k.size);
flags |= BCH_BUCKET_MARK_OVERWRITE_SPLIT; flags |= BTREE_TRIGGER_OVERWRITE_SPLIT;
break; break;
} }
...@@ -1311,15 +1311,18 @@ int bch2_mark_update(struct btree_trans *trans, ...@@ -1311,15 +1311,18 @@ int bch2_mark_update(struct btree_trans *trans,
struct bkey_packed *_k; struct bkey_packed *_k;
int ret = 0; int ret = 0;
if (unlikely(flags & BTREE_TRIGGER_NORUN))
return 0;
if (!btree_node_type_needs_gc(iter->btree_id)) if (!btree_node_type_needs_gc(iter->btree_id))
return 0; return 0;
bch2_mark_key_locked(c, bkey_i_to_s_c(insert), bch2_mark_key_locked(c, bkey_i_to_s_c(insert),
0, insert->k.size, 0, insert->k.size,
fs_usage, trans->journal_res.seq, fs_usage, trans->journal_res.seq,
BCH_BUCKET_MARK_INSERT|flags); BTREE_TRIGGER_INSERT|flags);
if (unlikely(trans->flags & BTREE_INSERT_NOMARK_OVERWRITES)) if (unlikely(flags & BTREE_TRIGGER_NOOVERWRITES))
return 0; return 0;
/* /*
...@@ -1450,7 +1453,7 @@ static void *trans_update_key(struct btree_trans *trans, ...@@ -1450,7 +1453,7 @@ static void *trans_update_key(struct btree_trans *trans,
return new_k; return new_k;
} }
bch2_trans_update(trans, iter, new_k); bch2_trans_update(trans, iter, new_k, 0);
return new_k; return new_k;
} }
...@@ -1689,7 +1692,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans, ...@@ -1689,7 +1692,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
goto err; goto err;
} }
if ((flags & BCH_BUCKET_MARK_OVERWRITE) && if ((flags & BTREE_TRIGGER_OVERWRITE) &&
(bkey_start_offset(k.k) < idx || (bkey_start_offset(k.k) < idx ||
k.k->p.offset > idx + sectors)) k.k->p.offset > idx + sectors))
goto out; goto out;
...@@ -1706,7 +1709,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans, ...@@ -1706,7 +1709,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
r_v = bkey_i_to_reflink_v(new_k); r_v = bkey_i_to_reflink_v(new_k);
le64_add_cpu(&r_v->v.refcount, le64_add_cpu(&r_v->v.refcount,
!(flags & BCH_BUCKET_MARK_OVERWRITE) ? 1 : -1); !(flags & BTREE_TRIGGER_OVERWRITE) ? 1 : -1);
if (!r_v->v.refcount) { if (!r_v->v.refcount) {
r_v->k.type = KEY_TYPE_deleted; r_v->k.type = KEY_TYPE_deleted;
...@@ -1750,7 +1753,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k, ...@@ -1750,7 +1753,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
switch (k.k->type) { switch (k.k->type) {
case KEY_TYPE_btree_ptr: case KEY_TYPE_btree_ptr:
sectors = !(flags & BCH_BUCKET_MARK_OVERWRITE) sectors = !(flags & BTREE_TRIGGER_OVERWRITE)
? c->opts.btree_node_size ? c->opts.btree_node_size
: -c->opts.btree_node_size; : -c->opts.btree_node_size;
...@@ -1763,7 +1766,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k, ...@@ -1763,7 +1766,7 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
case KEY_TYPE_inode: case KEY_TYPE_inode:
d = replicas_deltas_realloc(trans, 0); d = replicas_deltas_realloc(trans, 0);
if (!(flags & BCH_BUCKET_MARK_OVERWRITE)) if (!(flags & BTREE_TRIGGER_OVERWRITE))
d->nr_inodes++; d->nr_inodes++;
else else
d->nr_inodes--; d->nr_inodes--;
...@@ -1791,22 +1794,26 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k, ...@@ -1791,22 +1794,26 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
int bch2_trans_mark_update(struct btree_trans *trans, int bch2_trans_mark_update(struct btree_trans *trans,
struct btree_iter *iter, struct btree_iter *iter,
struct bkey_i *insert) struct bkey_i *insert,
unsigned flags)
{ {
struct btree *b = iter->l[0].b; struct btree *b = iter->l[0].b;
struct btree_node_iter node_iter = iter->l[0].iter; struct btree_node_iter node_iter = iter->l[0].iter;
struct bkey_packed *_k; struct bkey_packed *_k;
int ret; int ret;
if (unlikely(flags & BTREE_TRIGGER_NORUN))
return 0;
if (!btree_node_type_needs_gc(iter->btree_id)) if (!btree_node_type_needs_gc(iter->btree_id))
return 0; return 0;
ret = bch2_trans_mark_key(trans, bkey_i_to_s_c(insert), ret = bch2_trans_mark_key(trans, bkey_i_to_s_c(insert),
0, insert->k.size, BCH_BUCKET_MARK_INSERT); 0, insert->k.size, BTREE_TRIGGER_INSERT);
if (ret) if (ret)
return ret; return ret;
if (unlikely(trans->flags & BTREE_INSERT_NOMARK_OVERWRITES)) if (unlikely(flags & BTREE_TRIGGER_NOOVERWRITES))
return 0; return 0;
while ((_k = bch2_btree_node_iter_peek_filter(&node_iter, b, while ((_k = bch2_btree_node_iter_peek_filter(&node_iter, b,
...@@ -1815,7 +1822,7 @@ int bch2_trans_mark_update(struct btree_trans *trans, ...@@ -1815,7 +1822,7 @@ int bch2_trans_mark_update(struct btree_trans *trans,
struct bkey_s_c k; struct bkey_s_c k;
unsigned offset = 0; unsigned offset = 0;
s64 sectors = 0; s64 sectors = 0;
unsigned flags = BCH_BUCKET_MARK_OVERWRITE; unsigned flags = BTREE_TRIGGER_OVERWRITE;
k = bkey_disassemble(b, _k, &unpacked); k = bkey_disassemble(b, _k, &unpacked);
...@@ -1845,7 +1852,7 @@ int bch2_trans_mark_update(struct btree_trans *trans, ...@@ -1845,7 +1852,7 @@ int bch2_trans_mark_update(struct btree_trans *trans,
offset = bkey_start_offset(&insert->k) - offset = bkey_start_offset(&insert->k) -
bkey_start_offset(k.k); bkey_start_offset(k.k);
sectors = -((s64) insert->k.size); sectors = -((s64) insert->k.size);
flags |= BCH_BUCKET_MARK_OVERWRITE_SPLIT; flags |= BTREE_TRIGGER_OVERWRITE_SPLIT;
break; break;
} }
......
...@@ -258,14 +258,6 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *, ...@@ -258,14 +258,6 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
size_t, enum bch_data_type, unsigned, size_t, enum bch_data_type, unsigned,
struct gc_pos, unsigned); struct gc_pos, unsigned);
#define BCH_BUCKET_MARK_INSERT (1 << 0)
#define BCH_BUCKET_MARK_OVERWRITE (1 << 1)
#define BCH_BUCKET_MARK_OVERWRITE_SPLIT (1 << 2)
#define BCH_BUCKET_MARK_BUCKET_INVALIDATE (1 << 3)
#define BCH_BUCKET_MARK_GC (1 << 4)
#define BCH_BUCKET_MARK_ALLOC_READ (1 << 5)
#define BCH_BUCKET_MARK_NOATOMIC (1 << 6)
int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c, unsigned, s64, int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c, unsigned, s64,
struct bch_fs_usage *, u64, unsigned); struct bch_fs_usage *, u64, unsigned);
int bch2_mark_key(struct bch_fs *, struct bkey_s_c, unsigned, s64, int bch2_mark_key(struct bch_fs *, struct bkey_s_c, unsigned, s64,
...@@ -284,9 +276,8 @@ int bch2_replicas_delta_list_apply(struct bch_fs *, ...@@ -284,9 +276,8 @@ int bch2_replicas_delta_list_apply(struct bch_fs *,
struct replicas_delta_list *); struct replicas_delta_list *);
int bch2_trans_mark_key(struct btree_trans *, struct bkey_s_c, int bch2_trans_mark_key(struct btree_trans *, struct bkey_s_c,
unsigned, s64, unsigned); unsigned, s64, unsigned);
int bch2_trans_mark_update(struct btree_trans *, int bch2_trans_mark_update(struct btree_trans *, struct btree_iter *iter,
struct btree_iter *iter, struct bkey_i *insert, unsigned);
struct bkey_i *insert);
void bch2_trans_fs_usage_apply(struct btree_trans *, struct bch_fs_usage_online *); void bch2_trans_fs_usage_apply(struct btree_trans *, struct bch_fs_usage_online *);
/* disk reservations: */ /* disk reservations: */
......
...@@ -246,7 +246,7 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -246,7 +246,7 @@ int bch2_dirent_rename(struct btree_trans *trans,
*/ */
new_dst->k.p = src_iter->pos; new_dst->k.p = src_iter->pos;
bch2_trans_update(trans, src_iter, bch2_trans_update(trans, src_iter,
&new_dst->k_i); &new_dst->k_i, 0);
return 0; return 0;
} else { } else {
/* If we're overwriting, we can't insert new_dst /* If we're overwriting, we can't insert new_dst
...@@ -268,8 +268,8 @@ int bch2_dirent_rename(struct btree_trans *trans, ...@@ -268,8 +268,8 @@ int bch2_dirent_rename(struct btree_trans *trans,
} }
} }
bch2_trans_update(trans, src_iter, &new_src->k_i); bch2_trans_update(trans, src_iter, &new_src->k_i, 0);
bch2_trans_update(trans, dst_iter, &new_dst->k_i); bch2_trans_update(trans, dst_iter, &new_dst->k_i, 0);
return 0; return 0;
} }
......
...@@ -736,7 +736,7 @@ static int ec_stripe_bkey_insert(struct bch_fs *c, ...@@ -736,7 +736,7 @@ static int ec_stripe_bkey_insert(struct bch_fs *c,
stripe->k.p = iter->pos; stripe->k.p = iter->pos;
bch2_trans_update(&trans, iter, &stripe->k_i); bch2_trans_update(&trans, iter, &stripe->k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BTREE_INSERT_NOFAIL);
...@@ -818,7 +818,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c, ...@@ -818,7 +818,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
extent_stripe_ptr_add(e, s, ec_ptr, idx); extent_stripe_ptr_add(e, s, ec_ptr, idx);
bch2_trans_update(&trans, iter, sk.k); bch2_trans_update(&trans, iter, sk.k, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
...@@ -1230,7 +1230,7 @@ static int __bch2_stripe_write_key(struct btree_trans *trans, ...@@ -1230,7 +1230,7 @@ static int __bch2_stripe_write_key(struct btree_trans *trans,
spin_unlock(&c->ec_stripes_heap_lock); spin_unlock(&c->ec_stripes_heap_lock);
bch2_trans_update(trans, iter, &new_key->k_i); bch2_trans_update(trans, iter, &new_key->k_i, 0);
return bch2_trans_commit(trans, NULL, NULL, return bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL|flags); BTREE_INSERT_NOFAIL|flags);
...@@ -1316,8 +1316,8 @@ int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -1316,8 +1316,8 @@ int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys)
bch2_mark_key(c, btree ? btree_k : journal_k, bch2_mark_key(c, btree ? btree_k : journal_k,
0, 0, NULL, 0, 0, 0, NULL, 0,
BCH_BUCKET_MARK_ALLOC_READ| BTREE_TRIGGER_ALLOC_READ|
BCH_BUCKET_MARK_NOATOMIC); BTREE_TRIGGER_NOATOMIC);
if (btree) if (btree)
btree_k = bch2_btree_iter_next(btree_iter); btree_k = bch2_btree_iter_next(btree_iter);
......
...@@ -2465,7 +2465,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2465,7 +2465,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
struct bpos next_pos; struct bpos next_pos;
struct bpos move_pos = POS(inode->v.i_ino, offset >> 9); struct bpos move_pos = POS(inode->v.i_ino, offset >> 9);
struct bpos atomic_end; struct bpos atomic_end;
unsigned commit_flags = 0; unsigned trigger_flags = 0;
k = insert k = insert
? bch2_btree_iter_peek_prev(src) ? bch2_btree_iter_peek_prev(src)
...@@ -2536,15 +2536,12 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2536,15 +2536,12 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
bkey_start_pos(&delete.k)); bkey_start_pos(&delete.k));
} }
bch2_trans_update(&trans, dst, copy.k);
bch2_trans_update(&trans, del ?: src, &delete);
if (copy.k->k.size == k.k->size) { if (copy.k->k.size == k.k->size) {
/* /*
* If we're moving the entire extent, we can skip * If we're moving the entire extent, we can skip
* running triggers: * running triggers:
*/ */
commit_flags |= BTREE_INSERT_NOMARK; trigger_flags |= BTREE_TRIGGER_NORUN;
} else { } else {
/* We might end up splitting compressed extents: */ /* We might end up splitting compressed extents: */
unsigned nr_ptrs = unsigned nr_ptrs =
...@@ -2556,10 +2553,12 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2556,10 +2553,12 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
BUG_ON(ret); BUG_ON(ret);
} }
bch2_trans_update(&trans, dst, copy.k, trigger_flags);
bch2_trans_update(&trans, del ?: src, &delete, trigger_flags);
ret = bch2_trans_commit(&trans, &disk_res, ret = bch2_trans_commit(&trans, &disk_res,
&inode->ei_journal_seq, &inode->ei_journal_seq,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL);
commit_flags);
bch2_disk_reservation_put(c, &disk_res); bch2_disk_reservation_put(c, &disk_res);
bkey_err: bkey_err:
if (del) if (del)
......
...@@ -192,7 +192,7 @@ static int hash_redo_key(const struct bch_hash_desc desc, ...@@ -192,7 +192,7 @@ static int hash_redo_key(const struct bch_hash_desc desc,
bkey_init(&delete.k); bkey_init(&delete.k);
delete.k.p = k_iter->pos; delete.k.p = k_iter->pos;
bch2_trans_update(trans, k_iter, &delete); bch2_trans_update(trans, k_iter, &delete, 0);
return bch2_hash_set(trans, desc, &h->info, k_iter->pos.inode, return bch2_hash_set(trans, desc, &h->info, k_iter->pos.inode,
tmp, BCH_HASH_SET_MUST_CREATE) ?: tmp, BCH_HASH_SET_MUST_CREATE) ?:
...@@ -388,7 +388,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h, ...@@ -388,7 +388,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW, BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM, TRANS_RESET_MEM,
(bch2_trans_update(trans, iter, &d->k_i), 0)); (bch2_trans_update(trans, iter, &d->k_i, 0), 0));
if (ret) if (ret)
goto err; goto err;
...@@ -661,7 +661,7 @@ static int check_dirents(struct bch_fs *c) ...@@ -661,7 +661,7 @@ static int check_dirents(struct bch_fs *c)
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW, BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM, TRANS_RESET_MEM,
(bch2_trans_update(&trans, iter, &n->k_i), 0)); (bch2_trans_update(&trans, iter, &n->k_i, 0), 0));
kfree(n); kfree(n);
if (ret) if (ret)
goto err; goto err;
...@@ -1276,7 +1276,7 @@ static int check_inode(struct btree_trans *trans, ...@@ -1276,7 +1276,7 @@ static int check_inode(struct btree_trans *trans,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW, BTREE_INSERT_LAZY_RW,
TRANS_RESET_MEM, TRANS_RESET_MEM,
(bch2_trans_update(trans, iter, &p.inode.k_i), 0)); (bch2_trans_update(trans, iter, &p.inode.k_i, 0), 0));
if (ret) if (ret)
bch_err(c, "error in fsck: error %i " bch_err(c, "error in fsck: error %i "
"updating inode", ret); "updating inode", ret);
......
...@@ -223,7 +223,7 @@ int bch2_inode_write(struct btree_trans *trans, ...@@ -223,7 +223,7 @@ int bch2_inode_write(struct btree_trans *trans,
return PTR_ERR(inode_p); return PTR_ERR(inode_p);
bch2_inode_pack(inode_p, inode); bch2_inode_pack(inode_p, inode);
bch2_trans_update(trans, iter, &inode_p->inode.k_i); bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0);
return 0; return 0;
} }
...@@ -411,7 +411,7 @@ int bch2_inode_create(struct btree_trans *trans, ...@@ -411,7 +411,7 @@ int bch2_inode_create(struct btree_trans *trans,
inode_u->bi_generation = bkey_generation(k); inode_u->bi_generation = bkey_generation(k);
bch2_inode_pack(inode_p, inode_u); bch2_inode_pack(inode_p, inode_u);
bch2_trans_update(trans, iter, &inode_p->inode.k_i); bch2_trans_update(trans, iter, &inode_p->inode.k_i, 0);
return 0; return 0;
} }
} }
...@@ -493,7 +493,7 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr) ...@@ -493,7 +493,7 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr)
delete.v.bi_generation = cpu_to_le32(bi_generation); delete.v.bi_generation = cpu_to_le32(bi_generation);
} }
bch2_trans_update(&trans, iter, &delete.k_i); bch2_trans_update(&trans, iter, &delete.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BTREE_INSERT_NOFAIL);
......
...@@ -302,13 +302,13 @@ int bch2_extent_update(struct btree_trans *trans, ...@@ -302,13 +302,13 @@ int bch2_extent_update(struct btree_trans *trans,
if (delta || new_i_size) { if (delta || new_i_size) {
bch2_inode_pack(&inode_p, &inode_u); bch2_inode_pack(&inode_p, &inode_u);
bch2_trans_update(trans, inode_iter, bch2_trans_update(trans, inode_iter,
&inode_p.inode.k_i); &inode_p.inode.k_i, 0);
} }
bch2_trans_iter_put(trans, inode_iter); bch2_trans_iter_put(trans, inode_iter);
} }
bch2_trans_update(trans, iter, k); bch2_trans_update(trans, iter, k, 0);
ret = bch2_trans_commit(trans, disk_res, journal_seq, ret = bch2_trans_commit(trans, disk_res, journal_seq,
BTREE_INSERT_NOCHECK_RW| BTREE_INSERT_NOCHECK_RW|
...@@ -1740,7 +1740,7 @@ static void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio) ...@@ -1740,7 +1740,7 @@ static void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio)
if (!bch2_bkey_narrow_crcs(new.k, new_crc)) if (!bch2_bkey_narrow_crcs(new.k, new_crc))
goto out; goto out;
bch2_trans_update(&trans, iter, new.k); bch2_trans_update(&trans, iter, new.k, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_NOWAIT); BTREE_INSERT_NOWAIT);
......
...@@ -76,7 +76,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags ...@@ -76,7 +76,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
bch2_btree_iter_set_pos(iter, bkey_start_pos(&sk.k->k)); bch2_btree_iter_set_pos(iter, bkey_start_pos(&sk.k->k));
bch2_trans_update(&trans, iter, sk.k); bch2_trans_update(&trans, iter, sk.k, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, ret = bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BTREE_INSERT_NOFAIL);
......
...@@ -149,7 +149,7 @@ static int bch2_migrate_index_update(struct bch_write_op *op) ...@@ -149,7 +149,7 @@ static int bch2_migrate_index_update(struct bch_write_op *op)
goto next; goto next;
} }
bch2_trans_update(&trans, iter, insert); bch2_trans_update(&trans, iter, insert, 0);
ret = bch2_trans_commit(&trans, &op->res, ret = bch2_trans_commit(&trans, &op->res,
op_journal_seq(op), op_journal_seq(op),
......
...@@ -752,7 +752,7 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid, ...@@ -752,7 +752,7 @@ static int bch2_set_quota(struct super_block *sb, struct kqid qid,
if (qdq->d_fieldmask & QC_INO_HARD) if (qdq->d_fieldmask & QC_INO_HARD)
new_quota.v.c[Q_INO].hardlimit = cpu_to_le64(qdq->d_ino_hardlimit); new_quota.v.c[Q_INO].hardlimit = cpu_to_le64(qdq->d_ino_hardlimit);
bch2_trans_update(&trans, iter, &new_quota.k_i); bch2_trans_update(&trans, iter, &new_quota.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
......
...@@ -300,28 +300,24 @@ static int bch2_extent_replay_key(struct bch_fs *c, enum btree_id btree_id, ...@@ -300,28 +300,24 @@ static int bch2_extent_replay_key(struct bch_fs *c, enum btree_id btree_id,
bch2_cut_front(split_iter->pos, split); bch2_cut_front(split_iter->pos, split);
bch2_cut_back(atomic_end, split); bch2_cut_back(atomic_end, split);
bch2_trans_update(&trans, split_iter, split); bch2_trans_update(&trans, split_iter, split, !remark
? BTREE_TRIGGER_NORUN
: BTREE_TRIGGER_NOOVERWRITES);
bch2_btree_iter_set_pos(iter, split->k.p); bch2_btree_iter_set_pos(iter, split->k.p);
} while (bkey_cmp(iter->pos, k->k.p) < 0); } while (bkey_cmp(iter->pos, k->k.p) < 0);
if (remark) { if (remark) {
ret = bch2_trans_mark_key(&trans, bkey_i_to_s_c(k), ret = bch2_trans_mark_key(&trans, bkey_i_to_s_c(k),
0, -((s64) k->k.size), 0, -((s64) k->k.size),
BCH_BUCKET_MARK_OVERWRITE) ?: BTREE_TRIGGER_OVERWRITE);
bch2_trans_commit(&trans, &disk_res, NULL, if (ret)
BTREE_INSERT_NOFAIL| goto err;
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_NOMARK_OVERWRITES);
} else {
ret = bch2_trans_commit(&trans, &disk_res, NULL,
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY|
BTREE_INSERT_NOMARK);
} }
if (ret) ret = bch2_trans_commit(&trans, &disk_res, NULL,
goto err; BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY);
err: err:
if (ret == -EINTR) if (ret == -EINTR)
goto retry; goto retry;
...@@ -331,6 +327,30 @@ static int bch2_extent_replay_key(struct bch_fs *c, enum btree_id btree_id, ...@@ -331,6 +327,30 @@ static int bch2_extent_replay_key(struct bch_fs *c, enum btree_id btree_id,
return bch2_trans_exit(&trans) ?: ret; return bch2_trans_exit(&trans) ?: ret;
} }
static int __bch2_journal_replay_key(struct btree_trans *trans,
enum btree_id id, struct bkey_i *k)
{
struct btree_iter *iter;
iter = bch2_trans_get_iter(trans, id, bkey_start_pos(&k->k),
BTREE_ITER_INTENT);
if (IS_ERR(iter))
return PTR_ERR(iter);
bch2_trans_update(trans, iter, k, BTREE_TRIGGER_NORUN);
return 0;
}
static int bch2_journal_replay_key(struct bch_fs *c, enum btree_id id,
struct bkey_i *k)
{
return bch2_trans_do(c, NULL, NULL,
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY,
__bch2_journal_replay_key(&trans, id, k));
}
static int bch2_journal_replay(struct bch_fs *c, static int bch2_journal_replay(struct bch_fs *c,
struct journal_keys keys) struct journal_keys keys)
{ {
...@@ -348,12 +368,7 @@ static int bch2_journal_replay(struct bch_fs *c, ...@@ -348,12 +368,7 @@ static int bch2_journal_replay(struct bch_fs *c,
else if (btree_node_type_is_extents(i->btree_id)) else if (btree_node_type_is_extents(i->btree_id))
ret = bch2_extent_replay_key(c, i->btree_id, i->k); ret = bch2_extent_replay_key(c, i->btree_id, i->k);
else else
ret = bch2_btree_insert(c, i->btree_id, i->k, ret = bch2_journal_replay_key(c, i->btree_id, i->k);
NULL, NULL,
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW|
BTREE_INSERT_JOURNAL_REPLAY|
BTREE_INSERT_NOMARK);
if (ret) { if (ret) {
bch_err(c, "journal replay: error %d while replaying key", bch_err(c, "journal replay: error %d while replaying key",
......
...@@ -115,7 +115,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, ...@@ -115,7 +115,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
r_v->v.refcount = 0; r_v->v.refcount = 0;
memcpy(r_v->v.start, e->v.start, bkey_val_bytes(&e->k)); memcpy(r_v->v.start, e->v.start, bkey_val_bytes(&e->k));
bch2_trans_update(trans, reflink_iter, &r_v->k_i); bch2_trans_update(trans, reflink_iter, &r_v->k_i, 0);
r_p = bch2_trans_kmalloc(trans, sizeof(*r_p)); r_p = bch2_trans_kmalloc(trans, sizeof(*r_p));
if (IS_ERR(r_p)) if (IS_ERR(r_p))
...@@ -126,7 +126,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, ...@@ -126,7 +126,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
set_bkey_val_bytes(&r_p->k, sizeof(r_p->v)); set_bkey_val_bytes(&r_p->k, sizeof(r_p->v));
r_p->v.idx = cpu_to_le64(bkey_start_offset(&r_v->k)); r_p->v.idx = cpu_to_le64(bkey_start_offset(&r_v->k));
bch2_trans_update(trans, extent_iter, &r_p->k_i); bch2_trans_update(trans, extent_iter, &r_p->k_i, 0);
err: err:
if (!IS_ERR(reflink_iter)) { if (!IS_ERR(reflink_iter)) {
c->reflink_hint = reflink_iter->pos.offset; c->reflink_hint = reflink_iter->pos.offset;
......
...@@ -281,7 +281,7 @@ int bch2_hash_set(struct btree_trans *trans, ...@@ -281,7 +281,7 @@ int bch2_hash_set(struct btree_trans *trans,
swap(iter, slot); swap(iter, slot);
insert->k.p = iter->pos; insert->k.p = iter->pos;
bch2_trans_update(trans, iter, insert); bch2_trans_update(trans, iter, insert, 0);
} }
goto out; goto out;
...@@ -308,7 +308,7 @@ int bch2_hash_delete_at(struct btree_trans *trans, ...@@ -308,7 +308,7 @@ int bch2_hash_delete_at(struct btree_trans *trans,
delete->k.p = iter->pos; delete->k.p = iter->pos;
delete->k.type = ret ? KEY_TYPE_whiteout : KEY_TYPE_deleted; delete->k.type = ret ? KEY_TYPE_whiteout : KEY_TYPE_deleted;
bch2_trans_update(trans, iter, delete); bch2_trans_update(trans, iter, delete, 0);
return 0; return 0;
} }
......
...@@ -43,7 +43,7 @@ static void test_delete(struct bch_fs *c, u64 nr) ...@@ -43,7 +43,7 @@ static void test_delete(struct bch_fs *c, u64 nr)
ret = bch2_btree_iter_traverse(iter); ret = bch2_btree_iter_traverse(iter);
BUG_ON(ret); BUG_ON(ret);
bch2_trans_update(&trans, iter, &k.k_i); bch2_trans_update(&trans, iter, &k.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
BUG_ON(ret); BUG_ON(ret);
...@@ -75,7 +75,7 @@ static void test_delete_written(struct bch_fs *c, u64 nr) ...@@ -75,7 +75,7 @@ static void test_delete_written(struct bch_fs *c, u64 nr)
ret = bch2_btree_iter_traverse(iter); ret = bch2_btree_iter_traverse(iter);
BUG_ON(ret); BUG_ON(ret);
bch2_trans_update(&trans, iter, &k.k_i); bch2_trans_update(&trans, iter, &k.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
BUG_ON(ret); BUG_ON(ret);
...@@ -465,7 +465,7 @@ static void rand_mixed(struct bch_fs *c, u64 nr) ...@@ -465,7 +465,7 @@ static void rand_mixed(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p = iter->pos; k.k.p = iter->pos;
bch2_trans_update(&trans, iter, &k.k_i); bch2_trans_update(&trans, iter, &k.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
BUG_ON(ret); BUG_ON(ret);
} }
...@@ -509,7 +509,7 @@ static void seq_insert(struct bch_fs *c, u64 nr) ...@@ -509,7 +509,7 @@ static void seq_insert(struct bch_fs *c, u64 nr)
BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) { BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
insert.k.p = iter->pos; insert.k.p = iter->pos;
bch2_trans_update(&trans, iter, &insert.k_i); bch2_trans_update(&trans, iter, &insert.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
BUG_ON(ret); BUG_ON(ret);
...@@ -548,7 +548,7 @@ static void seq_overwrite(struct bch_fs *c, u64 nr) ...@@ -548,7 +548,7 @@ static void seq_overwrite(struct bch_fs *c, u64 nr)
bkey_reassemble(&u.k_i, k); bkey_reassemble(&u.k_i, k);
bch2_trans_update(&trans, iter, &u.k_i); bch2_trans_update(&trans, iter, &u.k_i, 0);
ret = bch2_trans_commit(&trans, NULL, NULL, 0); ret = bch2_trans_commit(&trans, NULL, NULL, 0);
BUG_ON(ret); BUG_ON(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