Commit 3eedfe1a authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Journal pins must always have a flush_fn

flush_fn is how we identify journal pins in debugfs - this is a
debugging aid.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent df8e13cc
...@@ -840,6 +840,12 @@ static noinline int bch2_trans_commit_bkey_invalid(struct btree_trans *trans, ...@@ -840,6 +840,12 @@ static noinline int bch2_trans_commit_bkey_invalid(struct btree_trans *trans,
return -EINVAL; return -EINVAL;
} }
static int bch2_trans_commit_journal_pin_flush(struct journal *j,
struct journal_entry_pin *_pin, u64 seq)
{
return 0;
}
/* /*
* Get journal reservation, take write locks, and attempt to do btree update(s): * Get journal reservation, take write locks, and attempt to do btree update(s):
*/ */
...@@ -883,7 +889,8 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags ...@@ -883,7 +889,8 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags
if (!ret && trans->journal_pin) if (!ret && trans->journal_pin)
bch2_journal_pin_add(&c->journal, trans->journal_res.seq, bch2_journal_pin_add(&c->journal, trans->journal_res.seq,
trans->journal_pin, NULL); trans->journal_pin,
bch2_trans_commit_journal_pin_flush);
/* /*
* Drop journal reservation after dropping write locks, since dropping * Drop journal reservation after dropping write locks, since dropping
......
...@@ -815,6 +815,12 @@ static void btree_update_updated_node(struct btree_update *as, struct btree *b) ...@@ -815,6 +815,12 @@ static void btree_update_updated_node(struct btree_update *as, struct btree *b)
mutex_unlock(&c->btree_interior_update_lock); mutex_unlock(&c->btree_interior_update_lock);
} }
static int bch2_update_reparent_journal_pin_flush(struct journal *j,
struct journal_entry_pin *_pin, u64 seq)
{
return 0;
}
static void btree_update_reparent(struct btree_update *as, static void btree_update_reparent(struct btree_update *as,
struct btree_update *child) struct btree_update *child)
{ {
...@@ -825,7 +831,8 @@ static void btree_update_reparent(struct btree_update *as, ...@@ -825,7 +831,8 @@ static void btree_update_reparent(struct btree_update *as,
child->b = NULL; child->b = NULL;
child->mode = BTREE_INTERIOR_UPDATING_AS; child->mode = BTREE_INTERIOR_UPDATING_AS;
bch2_journal_pin_copy(&c->journal, &as->journal, &child->journal, NULL); bch2_journal_pin_copy(&c->journal, &as->journal, &child->journal,
bch2_update_reparent_journal_pin_flush);
} }
static void btree_update_updated_root(struct btree_update *as, struct btree *b) static void btree_update_updated_root(struct btree_update *as, struct btree *b)
...@@ -934,6 +941,12 @@ static void bch2_btree_update_get_open_buckets(struct btree_update *as, struct b ...@@ -934,6 +941,12 @@ static void bch2_btree_update_get_open_buckets(struct btree_update *as, struct b
b->ob.v[--b->ob.nr]; b->ob.v[--b->ob.nr];
} }
static int bch2_btree_update_will_free_node_journal_pin_flush(struct journal *j,
struct journal_entry_pin *_pin, u64 seq)
{
return 0;
}
/* /*
* @b is being split/rewritten: it may have pointers to not-yet-written btree * @b is being split/rewritten: it may have pointers to not-yet-written btree
* nodes and thus outstanding btree_updates - redirect @b's * nodes and thus outstanding btree_updates - redirect @b's
...@@ -985,11 +998,13 @@ static void bch2_btree_interior_update_will_free_node(struct btree_update *as, ...@@ -985,11 +998,13 @@ static void bch2_btree_interior_update_will_free_node(struct btree_update *as,
* when the new nodes are persistent and reachable on disk: * when the new nodes are persistent and reachable on disk:
*/ */
w = btree_current_write(b); w = btree_current_write(b);
bch2_journal_pin_copy(&c->journal, &as->journal, &w->journal, NULL); bch2_journal_pin_copy(&c->journal, &as->journal, &w->journal,
bch2_btree_update_will_free_node_journal_pin_flush);
bch2_journal_pin_drop(&c->journal, &w->journal); bch2_journal_pin_drop(&c->journal, &w->journal);
w = btree_prev_write(b); w = btree_prev_write(b);
bch2_journal_pin_copy(&c->journal, &as->journal, &w->journal, NULL); bch2_journal_pin_copy(&c->journal, &as->journal, &w->journal,
bch2_btree_update_will_free_node_journal_pin_flush);
bch2_journal_pin_drop(&c->journal, &w->journal); bch2_journal_pin_drop(&c->journal, &w->journal);
mutex_unlock(&c->btree_interior_update_lock); mutex_unlock(&c->btree_interior_update_lock);
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include <linux/sort.h> #include <linux/sort.h>
static int bch2_btree_write_buffer_journal_flush(struct journal *,
struct journal_entry_pin *, u64);
static int btree_write_buffered_key_cmp(const void *_l, const void *_r) static int btree_write_buffered_key_cmp(const void *_l, const void *_r)
{ {
const struct btree_write_buffered_key *l = _l; const struct btree_write_buffered_key *l = _l;
...@@ -150,7 +153,8 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f ...@@ -150,7 +153,8 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f
if (!locked && !mutex_trylock(&wb->flush_lock)) if (!locked && !mutex_trylock(&wb->flush_lock))
return 0; return 0;
bch2_journal_pin_copy(j, &pin, &wb->journal_pin, NULL); bch2_journal_pin_copy(j, &pin, &wb->journal_pin,
bch2_btree_write_buffer_journal_flush);
bch2_journal_pin_drop(j, &wb->journal_pin); bch2_journal_pin_drop(j, &wb->journal_pin);
s = btree_write_buffer_switch(wb); s = btree_write_buffer_switch(wb);
...@@ -252,16 +256,8 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f ...@@ -252,16 +256,8 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f
if (!i->journal_seq) if (!i->journal_seq)
continue; continue;
if (i->journal_seq > pin.seq) { bch2_journal_pin_update(j, i->journal_seq, &pin,
struct journal_entry_pin pin2; bch2_btree_write_buffer_journal_flush);
memset(&pin2, 0, sizeof(pin2));
bch2_journal_pin_add(j, i->journal_seq, &pin2, NULL);
bch2_journal_pin_drop(j, &pin);
bch2_journal_pin_copy(j, &pin, &pin2, NULL);
bch2_journal_pin_drop(j, &pin2);
}
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
commit_flags| commit_flags|
......
...@@ -374,14 +374,16 @@ static inline void bch2_journal_pin_set_locked(struct journal *j, u64 seq, ...@@ -374,14 +374,16 @@ static inline void bch2_journal_pin_set_locked(struct journal *j, u64 seq,
{ {
struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq); struct journal_entry_pin_list *pin_list = journal_seq_pin(j, seq);
/*
* flush_fn is how we identify journal pins in debugfs, so must always
* exist, even if it doesn't do anything:
*/
BUG_ON(!flush_fn);
atomic_inc(&pin_list->count); atomic_inc(&pin_list->count);
pin->seq = seq; pin->seq = seq;
pin->flush = flush_fn; pin->flush = flush_fn;
list_add(&pin->list, &pin_list->list[type]);
if (flush_fn)
list_add(&pin->list, &pin_list->list[type]);
else
list_add(&pin->list, &pin_list->flushed);
} }
void bch2_journal_pin_copy(struct journal *j, void bch2_journal_pin_copy(struct journal *j,
......
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