Filipe Manana | f3a84cc | 2021-03-11 14:31:07 +0000 | [diff] [blame] | 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, |
Filipe Manana | 406808a | 2021-03-11 14:31:08 +0000 | [diff] [blame] | 33 | bool log_removal); |
Filipe Manana | f3a84cc | 2021-03-11 14:31:07 +0000 | [diff] [blame] | 34 | int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, |
| 35 | enum btrfs_mod_log_op op, gfp_t flags); |
| 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); |
Filipe Manana | 4bae788 | 2021-03-11 14:31:12 +0000 | [diff] [blame] | 51 | u64 btrfs_tree_mod_log_lowest_seq(struct btrfs_fs_info *fs_info); |
Filipe Manana | f3a84cc | 2021-03-11 14:31:07 +0000 | [diff] [blame] | 52 | |
| 53 | #endif |