xref: /openbmc/linux/fs/btrfs/tree-mod-log.h (revision c30ff698)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef BTRFS_TREE_MOD_LOG_H
4 #define BTRFS_TREE_MOD_LOG_H
5 
6 #include "ctree.h"
7 
8 /* Represents a tree mod log user. */
9 struct btrfs_seq_list {
10 	struct list_head list;
11 	u64 seq;
12 };
13 
14 #define BTRFS_SEQ_LIST_INIT(name) { .list = LIST_HEAD_INIT((name).list), .seq = 0 }
15 #define BTRFS_SEQ_LAST            ((u64)-1)
16 
17 enum btrfs_mod_log_op {
18 	BTRFS_MOD_LOG_KEY_REPLACE,
19 	BTRFS_MOD_LOG_KEY_ADD,
20 	BTRFS_MOD_LOG_KEY_REMOVE,
21 	BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING,
22 	BTRFS_MOD_LOG_KEY_REMOVE_WHILE_MOVING,
23 	BTRFS_MOD_LOG_MOVE_KEYS,
24 	BTRFS_MOD_LOG_ROOT_REPLACE,
25 };
26 
27 u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
28 			   struct btrfs_seq_list *elem);
29 void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
30 			    struct btrfs_seq_list *elem);
31 int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root,
32 				   struct extent_buffer *new_root,
33 				   bool log_removal);
34 int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot,
35 				  enum btrfs_mod_log_op op);
36 int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb);
37 struct extent_buffer *btrfs_tree_mod_log_rewind(struct btrfs_fs_info *fs_info,
38 						struct btrfs_path *path,
39 						struct extent_buffer *eb,
40 						u64 time_seq);
41 struct extent_buffer *btrfs_get_old_root(struct btrfs_root *root, u64 time_seq);
42 int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq);
43 int btrfs_tree_mod_log_eb_copy(struct extent_buffer *dst,
44 			       struct extent_buffer *src,
45 			       unsigned long dst_offset,
46 			       unsigned long src_offset,
47 			       int nr_items);
48 int btrfs_tree_mod_log_insert_move(struct extent_buffer *eb,
49 				   int dst_slot, int src_slot,
50 				   int nr_items);
51 u64 btrfs_tree_mod_log_lowest_seq(struct btrfs_fs_info *fs_info);
52 
53 #endif
54