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