bcachefs: delete duplicated code
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 5 Apr 2019 04:20:02 +0000 (00:20 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:20 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c
fs/bcachefs/journal.h
fs/bcachefs/recovery.c

index 2e84af8a044c5050fde750cb163930e120574951..969612e612e0e306bcf1731b0df998cb6861a755 100644 (file)
@@ -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;
index 3447b4ad462dd297e4236024a2f377cb63cdaeec..36066ea7de7a1e5bbcfab31871e08c8428fc2e0d 100644 (file)
@@ -231,6 +231,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,
index 9411a1f550f3af05a226a740b1a1ac8da4943d9d..b1fcc105cffd17150c39e64c11bc595194e2c4b2 100644 (file)
@@ -322,32 +322,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)