1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_JOURNAL_IO_H
3 #define _BCACHEFS_JOURNAL_IO_H
7 void bch2_journal_pos_from_member_info_set(struct bch_fs *);
8 void bch2_journal_pos_from_member_info_resume(struct bch_fs *);
19 * Only used for holding the journal entries we read in btree_journal_read()
20 * during cache_registration
22 struct journal_replay {
23 DARRAY_PREALLOCATED(struct journal_ptr, 8) ptrs;
26 bool ignore_blacklisted;
27 bool ignore_not_dirty;
32 static inline bool journal_replay_ignore(struct journal_replay *i)
34 return !i || i->ignore_blacklisted || i->ignore_not_dirty;
37 static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
38 struct jset_entry *entry, unsigned type)
40 while (entry < vstruct_last(jset)) {
41 if (entry->type == type)
44 entry = vstruct_next(entry);
50 #define for_each_jset_entry_type(entry, jset, type) \
51 for (struct jset_entry *entry = (jset)->start; \
52 (entry = __jset_entry_type_next(jset, entry, type)); \
53 entry = vstruct_next(entry))
55 #define jset_entry_for_each_key(_e, _k) \
56 for (struct bkey_i *_k = (_e)->start; \
57 _k < vstruct_last(_e); \
60 #define for_each_jset_key(k, entry, jset) \
61 for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys)\
62 jset_entry_for_each_key(entry, k)
64 int bch2_journal_entry_validate(struct bch_fs *, struct jset *,
65 struct jset_entry *, unsigned, int,
66 struct bkey_validate_context);
67 void bch2_journal_entry_to_text(struct printbuf *, struct bch_fs *,
70 void bch2_journal_ptrs_to_text(struct printbuf *, struct bch_fs *,
71 struct journal_replay *);
73 int bch2_journal_read(struct bch_fs *, u64 *, u64 *, u64 *);
75 CLOSURE_CALLBACK(bch2_journal_write);
77 static inline struct jset_entry *jset_entry_init(struct jset_entry **end, size_t size)
79 struct jset_entry *entry = *end;
80 unsigned u64s = DIV_ROUND_UP(size, sizeof(u64));
82 memset(entry, 0, u64s * sizeof(u64));
84 * The u64s field counts from the start of data, ignoring the shared
87 entry->u64s = cpu_to_le16(u64s - 1);
89 *end = vstruct_next(*end);
93 #endif /* _BCACHEFS_JOURNAL_IO_H */