]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/journal_io.h
New upstream snapshot
[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_extent_ptr   ptrs[BCH_REPLICAS_MAX];
12         unsigned                nr_ptrs;
13
14         /* checksum error, but we may want to try using it anyways: */
15         bool                    bad;
16         bool                    ignore;
17         /* must be last: */
18         struct jset             j;
19 };
20
21 static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
22                                         struct jset_entry *entry, unsigned type)
23 {
24         while (entry < vstruct_last(jset)) {
25                 if (entry->type == type)
26                         return entry;
27
28                 entry = vstruct_next(entry);
29         }
30
31         return NULL;
32 }
33
34 #define for_each_jset_entry_type(entry, jset, type)                     \
35         for (entry = (jset)->start;                                     \
36              (entry = __jset_entry_type_next(jset, entry, type));       \
37              entry = vstruct_next(entry))
38
39 #define for_each_jset_key(k, _n, entry, jset)                           \
40         for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys)        \
41                 vstruct_for_each_safe(entry, k, _n)
42
43 int bch2_journal_entry_validate(struct bch_fs *, const char *,
44                                 struct jset_entry *, unsigned, int, int);
45 void bch2_journal_entry_to_text(struct printbuf *, struct bch_fs *,
46                                 struct jset_entry *);
47
48 int bch2_journal_read(struct bch_fs *, struct list_head *, u64 *, u64 *);
49
50 void bch2_journal_write(struct closure *);
51
52 #endif /* _BCACHEFS_JOURNAL_IO_H */