19888c340SDavid Sterba /* SPDX-License-Identifier: GPL-2.0 */ 2a542ad1bSJan Schmidt /* 3a542ad1bSJan Schmidt * Copyright (C) 2011 STRATO. All rights reserved. 4a542ad1bSJan Schmidt */ 5a542ad1bSJan Schmidt 69888c340SDavid Sterba #ifndef BTRFS_BACKREF_H 79888c340SDavid Sterba #define BTRFS_BACKREF_H 8a542ad1bSJan Schmidt 955e301fdSFilipe Brandenburger #include <linux/btrfs.h> 108da6d581SJan Schmidt #include "ulist.h" 1191cb916cSAlexander Block #include "extent_io.h" 12a542ad1bSJan Schmidt 13a542ad1bSJan Schmidt struct inode_fs_paths { 14a542ad1bSJan Schmidt struct btrfs_path *btrfs_path; 15a542ad1bSJan Schmidt struct btrfs_root *fs_root; 16a542ad1bSJan Schmidt struct btrfs_data_container *fspath; 17a542ad1bSJan Schmidt }; 18a542ad1bSJan Schmidt 19a542ad1bSJan Schmidt typedef int (iterate_extent_inodes_t)(u64 inum, u64 offset, u64 root, 20a542ad1bSJan Schmidt void *ctx); 21a542ad1bSJan Schmidt 22a542ad1bSJan Schmidt int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, 2369917e43SLiu Bo struct btrfs_path *path, struct btrfs_key *found_key, 2469917e43SLiu Bo u64 *flags); 25a542ad1bSJan Schmidt 26a542ad1bSJan Schmidt int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, 276eda71d0SLiu Bo struct btrfs_key *key, struct btrfs_extent_item *ei, 286eda71d0SLiu Bo u32 item_size, u64 *out_root, u8 *out_level); 29a542ad1bSJan Schmidt 30a542ad1bSJan Schmidt int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 31a542ad1bSJan Schmidt u64 extent_item_objectid, 327a3ae2f8SJan Schmidt u64 extent_offset, int search_commit_root, 33c995ab3cSZygo Blaxell iterate_extent_inodes_t *iterate, void *ctx, 34c995ab3cSZygo Blaxell bool ignore_offset); 35a542ad1bSJan Schmidt 36a542ad1bSJan Schmidt int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 37a542ad1bSJan Schmidt struct btrfs_path *path, 38c995ab3cSZygo Blaxell iterate_extent_inodes_t *iterate, void *ctx, 39c995ab3cSZygo Blaxell bool ignore_offset); 40a542ad1bSJan Schmidt 41a542ad1bSJan Schmidt int paths_from_inode(u64 inum, struct inode_fs_paths *ipath); 42a542ad1bSJan Schmidt 438da6d581SJan Schmidt int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 448da6d581SJan Schmidt struct btrfs_fs_info *fs_info, u64 bytenr, 45c995ab3cSZygo Blaxell u64 time_seq, struct ulist **roots, bool ignore_offset); 4696b5bd77SJan Schmidt char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, 4796b5bd77SJan Schmidt u32 name_len, unsigned long name_off, 4896b5bd77SJan Schmidt struct extent_buffer *eb_in, u64 parent, 4996b5bd77SJan Schmidt char *dest, u32 size); 508da6d581SJan Schmidt 51a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes); 52a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 53a542ad1bSJan Schmidt struct btrfs_path *path); 54a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath); 55a542ad1bSJan Schmidt 56f186373fSMark Fasheh int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid, 57f186373fSMark Fasheh u64 start_off, struct btrfs_path *path, 58f186373fSMark Fasheh struct btrfs_inode_extref **ret_extref, 59f186373fSMark Fasheh u64 *found_off); 60bb739cf0SEdmund Nadolski int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr); 61f186373fSMark Fasheh 62b9e9a6cbSWang Shilong int __init btrfs_prelim_ref_init(void); 63e67c718bSDavid Sterba void __cold btrfs_prelim_ref_exit(void); 6400142756SJeff Mahoney 6500142756SJeff Mahoney struct prelim_ref { 6600142756SJeff Mahoney struct rb_node rbnode; 6700142756SJeff Mahoney u64 root_id; 6800142756SJeff Mahoney struct btrfs_key key_for_search; 6900142756SJeff Mahoney int level; 7000142756SJeff Mahoney int count; 7100142756SJeff Mahoney struct extent_inode_elem *inode_list; 7200142756SJeff Mahoney u64 parent; 7300142756SJeff Mahoney u64 wanted_disk_byte; 7400142756SJeff Mahoney }; 7500142756SJeff Mahoney 76a542ad1bSJan Schmidt #endif 77