2019-07-10 23:12:15 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-06-27 21:41:51 +03:00
|
|
|
#ifndef _BCACHEFS_RECOVERY_H
|
|
|
|
#define _BCACHEFS_RECOVERY_H
|
|
|
|
|
2019-04-18 00:01:40 +03:00
|
|
|
struct journal_keys {
|
|
|
|
struct journal_key {
|
|
|
|
enum btree_id btree_id:8;
|
2020-03-25 22:56:38 +03:00
|
|
|
unsigned level:8;
|
2019-04-18 00:01:40 +03:00
|
|
|
struct bkey_i *k;
|
|
|
|
u32 journal_seq;
|
|
|
|
u32 journal_offset;
|
|
|
|
} *d;
|
|
|
|
size_t nr;
|
|
|
|
u64 journal_seq_base;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define for_each_journal_key(keys, i) \
|
|
|
|
for (i = (keys).d; i < (keys).d + (keys).nr; (i)++)
|
|
|
|
|
2019-07-13 00:11:10 +03:00
|
|
|
struct journal_iter {
|
2020-03-25 22:56:38 +03:00
|
|
|
enum btree_id btree_id;
|
|
|
|
unsigned level;
|
2019-07-13 00:11:10 +03:00
|
|
|
struct journal_keys *keys;
|
|
|
|
struct journal_key *k;
|
|
|
|
};
|
|
|
|
|
2020-03-25 22:56:38 +03:00
|
|
|
/*
|
|
|
|
* Iterate over keys in the btree, with keys from the journal overlaid on top:
|
|
|
|
*/
|
2020-02-23 00:21:32 +03:00
|
|
|
|
2020-03-25 22:56:38 +03:00
|
|
|
struct btree_and_journal_iter {
|
2020-02-23 00:21:32 +03:00
|
|
|
struct btree_iter *btree;
|
2020-03-25 22:56:38 +03:00
|
|
|
|
|
|
|
struct btree *b;
|
|
|
|
struct btree_node_iter node_iter;
|
|
|
|
struct bkey unpacked;
|
|
|
|
|
2020-02-23 00:21:32 +03:00
|
|
|
struct journal_iter journal;
|
|
|
|
|
|
|
|
enum last_key_returned {
|
|
|
|
none,
|
|
|
|
btree,
|
|
|
|
journal,
|
|
|
|
} last;
|
|
|
|
};
|
|
|
|
|
|
|
|
void bch2_btree_and_journal_iter_advance(struct btree_and_journal_iter *);
|
|
|
|
struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter *);
|
|
|
|
struct bkey_s_c bch2_btree_and_journal_iter_next(struct btree_and_journal_iter *);
|
2020-03-25 22:56:38 +03:00
|
|
|
|
2020-02-23 00:21:32 +03:00
|
|
|
void bch2_btree_and_journal_iter_init(struct btree_and_journal_iter *,
|
|
|
|
struct btree_trans *,
|
|
|
|
struct journal_keys *,
|
|
|
|
enum btree_id, struct bpos);
|
2020-03-25 22:56:38 +03:00
|
|
|
void bch2_btree_and_journal_iter_init_node_iter(struct btree_and_journal_iter *,
|
|
|
|
struct journal_keys *,
|
|
|
|
struct btree *);
|
2019-07-13 00:11:10 +03:00
|
|
|
|
2018-06-27 21:41:51 +03:00
|
|
|
int bch2_fs_recovery(struct bch_fs *);
|
|
|
|
int bch2_fs_initialize(struct bch_fs *);
|
|
|
|
|
|
|
|
#endif /* _BCACHEFS_RECOVERY_H */
|