]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/journal_io.h
rust: Fix ptr casting in Fs::open()
[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 journal_ptr {
11                 bool            csum_good;
12                 u8              dev;
13                 u32             bucket;
14                 u32             bucket_offset;
15                 u64             sector;
16         }                       ptrs[BCH_REPLICAS_MAX];
17         unsigned                nr_ptrs;
18
19         bool                    csum_good;
20         bool                    ignore;
21         /* must be last: */
22         struct jset             j;
23 };
24
25 static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
26                                         struct jset_entry *entry, unsigned type)
27 {
28         while (entry < vstruct_last(jset)) {
29                 if (entry->type == type)
30                         return entry;
31
32                 entry = vstruct_next(entry);
33         }
34
35         return NULL;
36 }
37
38 #define for_each_jset_entry_type(entry, jset, type)                     \
39         for (entry = (jset)->start;                                     \
40              (entry = __jset_entry_type_next(jset, entry, type));       \
41              entry = vstruct_next(entry))
42
43 #define for_each_jset_key(k, _n, entry, jset)                           \
44         for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys)        \
45                 vstruct_for_each_safe(entry, k, _n)
46
47 int bch2_journal_entry_validate(struct bch_fs *, struct jset *,
48                                 struct jset_entry *, unsigned, int, int);
49 void bch2_journal_entry_to_text(struct printbuf *, struct bch_fs *,
50                                 struct jset_entry *);
51
52 void bch2_journal_ptrs_to_text(struct printbuf *, struct bch_fs *,
53                                struct journal_replay *);
54
55 int bch2_journal_read(struct bch_fs *, u64 *, u64 *, u64 *);
56
57 void bch2_journal_write(struct closure *);
58
59 #endif /* _BCACHEFS_JOURNAL_IO_H */