diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-04-05 00:20:02 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2019-04-05 00:21:44 -0400 |
commit | 1649784834c1d4b0d0fa495726fe3ade323b3558 (patch) | |
tree | 59f7898e0dfb5bd26da2c4e018b266102e6cf84b | |
parent | 4681c31c9e1c0d90ad8e214af0005e31b71248ad (diff) |
bcachefs: delete duplicated code
-rw-r--r-- | fs/bcachefs/journal.c | 13 | ||||
-rw-r--r-- | fs/bcachefs/journal.h | 13 | ||||
-rw-r--r-- | fs/bcachefs/recovery.c | 29 |
3 files changed, 16 insertions, 39 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index d092dc0be543..3d52e68b94ff 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -55,19 +55,6 @@ static void bch2_journal_buf_init(struct journal *j) 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) { union journal_res_state old, new; diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h index 7b1523ef4d02..2e7bc8e4553c 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -228,6 +228,19 @@ static inline void bch2_journal_add_keys(struct journal *j, struct journal_res * 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); static inline void bch2_journal_buf_put(struct journal *j, unsigned idx, diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index a5651a9cadcf..4d7f5b3391e7 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -321,32 +321,9 @@ fsck_err: static bool journal_empty(struct list_head *journal) { - struct journal_replay *i; - struct jset_entry *entry; - - 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; + return list_empty(journal) || + journal_entry_empty(&list_last_entry(journal, + struct journal_replay, list)->j); } int bch2_fs_recovery(struct bch_fs *c) |