Commit 478259b7 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: delete duplicated code

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 330581f1
...@@ -55,19 +55,6 @@ static void bch2_journal_buf_init(struct journal *j) ...@@ -55,19 +55,6 @@ static void bch2_journal_buf_init(struct journal *j)
buf->data->u64s = 0; buf->data->u64s = 0;
} }
static inline bool journal_entry_empty(struct jset *j)
{
struct jset_entry *i;
if (j->seq != j->last_seq)
return false;
vstruct_for_each(j, i)
if (i->type || i->u64s)
return false;
return true;
}
void bch2_journal_halt(struct journal *j) void bch2_journal_halt(struct journal *j)
{ {
union journal_res_state old, new; union journal_res_state old, new;
......
...@@ -231,6 +231,19 @@ static inline void bch2_journal_add_keys(struct journal *j, struct journal_res * ...@@ -231,6 +231,19 @@ static inline void bch2_journal_add_keys(struct journal *j, struct journal_res *
id, 0, k, k->k.u64s); id, 0, k, k->k.u64s);
} }
static inline bool journal_entry_empty(struct jset *j)
{
struct jset_entry *i;
if (j->seq != j->last_seq)
return false;
vstruct_for_each(j, i)
if (i->type == BCH_JSET_ENTRY_btree_keys && i->u64s)
return false;
return true;
}
void __bch2_journal_buf_put(struct journal *, bool); void __bch2_journal_buf_put(struct journal *, bool);
static inline void bch2_journal_buf_put(struct journal *j, unsigned idx, static inline void bch2_journal_buf_put(struct journal *j, unsigned idx,
......
...@@ -322,32 +322,9 @@ static int read_btree_roots(struct bch_fs *c) ...@@ -322,32 +322,9 @@ static int read_btree_roots(struct bch_fs *c)
static bool journal_empty(struct list_head *journal) static bool journal_empty(struct list_head *journal)
{ {
struct journal_replay *i; return list_empty(journal) ||
struct jset_entry *entry; journal_entry_empty(&list_last_entry(journal,
struct journal_replay, list)->j);
if (list_empty(journal))
return true;
i = list_last_entry(journal, struct journal_replay, list);
if (i->j.last_seq != i->j.seq)
return false;
list_for_each_entry(i, journal, list) {
vstruct_for_each(&i->j, entry) {
if (entry->type == BCH_JSET_ENTRY_btree_root ||
entry->type == BCH_JSET_ENTRY_usage ||
entry->type == BCH_JSET_ENTRY_data_usage)
continue;
if (entry->type == BCH_JSET_ENTRY_btree_keys &&
!entry->u64s)
continue;
return false;
}
}
return true;
} }
int bch2_fs_recovery(struct bch_fs *c) int bch2_fs_recovery(struct bch_fs *c)
......
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