bcachefs: Journal replay refactoring
[linux-block.git] / fs / bcachefs / journal_io.h
CommitLineData
1c6fdbd8
KO
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _BCACHEFS_JOURNAL_IO_H
3#define _BCACHEFS_JOURNAL_IO_H
4
5/*
6 * Only used for holding the journal entries we read in btree_journal_read()
7 * during cache_registration
8 */
9struct journal_replay {
10 struct list_head list;
11 struct bch_devs_list devs;
12 /* must be last: */
13 struct jset j;
14};
15
16static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
17 struct jset_entry *entry, unsigned type)
18{
19 while (entry < vstruct_last(jset)) {
20 if (entry->type == type)
21 return entry;
22
23 entry = vstruct_next(entry);
24 }
25
26 return NULL;
27}
28
29#define for_each_jset_entry_type(entry, jset, type) \
30 for (entry = (jset)->start; \
31 (entry = __jset_entry_type_next(jset, entry, type)); \
32 entry = vstruct_next(entry))
33
34#define for_each_jset_key(k, _n, entry, jset) \
35 for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys) \
36 vstruct_for_each_safe(entry, k, _n)
37
1c6fdbd8
KO
38int bch2_journal_read(struct bch_fs *, struct list_head *);
39
1c6fdbd8
KO
40void bch2_journal_write(struct closure *);
41
42#endif /* _BCACHEFS_JOURNAL_IO_H */