]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/journal_io.h
Update bcachefs sources to e1d0fb8c5f bcachefs: Don't require flush/fua on every...
[bcachefs-tools-debian] / libbcachefs / journal_io.h
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  */
9 struct journal_replay {
10         struct list_head        list;
11         struct bch_devs_list    devs;
12         /* checksum error, but we may want to try using it anyways: */
13         bool                    bad;
14         bool                    ignore;
15         /* must be last: */
16         struct jset             j;
17 };
18
19 static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
20                                         struct jset_entry *entry, unsigned type)
21 {
22         while (entry < vstruct_last(jset)) {
23                 if (entry->type == type)
24                         return entry;
25
26                 entry = vstruct_next(entry);
27         }
28
29         return NULL;
30 }
31
32 #define for_each_jset_entry_type(entry, jset, type)                     \
33         for (entry = (jset)->start;                                     \
34              (entry = __jset_entry_type_next(jset, entry, type));       \
35              entry = vstruct_next(entry))
36
37 #define for_each_jset_key(k, _n, entry, jset)                           \
38         for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys)        \
39                 vstruct_for_each_safe(entry, k, _n)
40
41 int bch2_journal_read(struct bch_fs *, struct list_head *, u64 *, u64 *);
42
43 void bch2_journal_write(struct closure *);
44
45 #endif /* _BCACHEFS_JOURNAL_IO_H */