2017-03-17 06:18:50 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_RECOVERY_H
|
|
|
|
#define _BCACHEFS_RECOVERY_H
|
|
|
|
|
2019-04-12 02:39:39 +00:00
|
|
|
#define for_each_journal_key(keys, i) \
|
|
|
|
for (i = (keys).d; i < (keys).d + (keys).nr; (i)++)
|
|
|
|
|
2019-07-12 21:08:32 +00:00
|
|
|
struct journal_iter {
|
2021-01-27 01:15:46 +00:00
|
|
|
struct list_head list;
|
2020-03-16 03:29:43 +00:00
|
|
|
enum btree_id btree_id;
|
|
|
|
unsigned level;
|
2021-01-27 01:15:46 +00:00
|
|
|
size_t idx;
|
2019-07-12 21:08:32 +00:00
|
|
|
struct journal_keys *keys;
|
|
|
|
};
|
|
|
|
|
2020-03-16 03:29:43 +00:00
|
|
|
/*
|
|
|
|
* Iterate over keys in the btree, with keys from the journal overlaid on top:
|
|
|
|
*/
|
2019-12-28 01:51:35 +00:00
|
|
|
|
2020-03-16 03:29:43 +00:00
|
|
|
struct btree_and_journal_iter {
|
|
|
|
struct btree *b;
|
|
|
|
struct btree_node_iter node_iter;
|
|
|
|
struct bkey unpacked;
|
|
|
|
|
2019-12-28 01:51:35 +00:00
|
|
|
struct journal_iter journal;
|
|
|
|
|
|
|
|
enum last_key_returned {
|
|
|
|
none,
|
|
|
|
btree,
|
|
|
|
journal,
|
|
|
|
} last;
|
|
|
|
};
|
|
|
|
|
2021-12-24 02:35:28 +00:00
|
|
|
int bch2_journal_key_insert_take(struct bch_fs *, enum btree_id,
|
|
|
|
unsigned, struct bkey_i *);
|
2021-01-27 01:15:46 +00:00
|
|
|
int bch2_journal_key_insert(struct bch_fs *, enum btree_id,
|
|
|
|
unsigned, struct bkey_i *);
|
|
|
|
int bch2_journal_key_delete(struct bch_fs *, enum btree_id,
|
|
|
|
unsigned, struct bpos);
|
2021-12-31 22:54:13 +00:00
|
|
|
void bch2_journal_key_overwritten(struct bch_fs *, enum btree_id,
|
|
|
|
unsigned, struct bpos);
|
2021-01-27 01:15:46 +00:00
|
|
|
|
2019-12-28 01:51:35 +00:00
|
|
|
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-16 03:29:43 +00:00
|
|
|
|
2021-01-27 01:15:46 +00:00
|
|
|
void bch2_btree_and_journal_iter_exit(struct btree_and_journal_iter *);
|
2020-03-16 03:29:43 +00:00
|
|
|
void bch2_btree_and_journal_iter_init_node_iter(struct btree_and_journal_iter *,
|
2021-01-27 01:15:46 +00:00
|
|
|
struct bch_fs *,
|
2020-03-16 03:29:43 +00:00
|
|
|
struct btree *);
|
2019-07-12 21:08:32 +00:00
|
|
|
|
2021-10-29 22:43:18 +00:00
|
|
|
typedef int (*btree_walk_key_fn)(struct btree_trans *, struct bkey_s_c);
|
2020-05-24 18:06:10 +00:00
|
|
|
|
2021-10-29 22:43:18 +00:00
|
|
|
int bch2_btree_and_journal_walk(struct btree_trans *, enum btree_id, btree_walk_key_fn);
|
2020-05-24 18:06:10 +00:00
|
|
|
|
2020-03-25 20:12:33 +00:00
|
|
|
void bch2_journal_keys_free(struct journal_keys *);
|
|
|
|
void bch2_journal_entries_free(struct list_head *);
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
int bch2_fs_recovery(struct bch_fs *);
|
|
|
|
int bch2_fs_initialize(struct bch_fs *);
|
|
|
|
|
|
|
|
#endif /* _BCACHEFS_RECOVERY_H */
|