1a542ad1bSJan Schmidt /* 2a542ad1bSJan Schmidt * Copyright (C) 2011 STRATO. All rights reserved. 3a542ad1bSJan Schmidt * 4a542ad1bSJan Schmidt * This program is free software; you can redistribute it and/or 5a542ad1bSJan Schmidt * modify it under the terms of the GNU General Public 6a542ad1bSJan Schmidt * License v2 as published by the Free Software Foundation. 7a542ad1bSJan Schmidt * 8a542ad1bSJan Schmidt * This program is distributed in the hope that it will be useful, 9a542ad1bSJan Schmidt * but WITHOUT ANY WARRANTY; without even the implied warranty of 10a542ad1bSJan Schmidt * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11a542ad1bSJan Schmidt * General Public License for more details. 12a542ad1bSJan Schmidt * 13a542ad1bSJan Schmidt * You should have received a copy of the GNU General Public 14a542ad1bSJan Schmidt * License along with this program; if not, write to the 15a542ad1bSJan Schmidt * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16a542ad1bSJan Schmidt * Boston, MA 021110-1307, USA. 17a542ad1bSJan Schmidt */ 18a542ad1bSJan Schmidt 19a542ad1bSJan Schmidt #ifndef __BTRFS_BACKREF__ 20a542ad1bSJan Schmidt #define __BTRFS_BACKREF__ 21a542ad1bSJan Schmidt 22a542ad1bSJan Schmidt #include "ioctl.h" 238da6d581SJan Schmidt #include "ulist.h" 2491cb916cSAlexander Block #include "extent_io.h" 25a542ad1bSJan Schmidt 267a3ae2f8SJan Schmidt #define BTRFS_BACKREF_SEARCH_COMMIT_ROOT ((struct btrfs_trans_handle *)0) 277a3ae2f8SJan Schmidt 28a542ad1bSJan Schmidt struct inode_fs_paths { 29a542ad1bSJan Schmidt struct btrfs_path *btrfs_path; 30a542ad1bSJan Schmidt struct btrfs_root *fs_root; 31a542ad1bSJan Schmidt struct btrfs_data_container *fspath; 32a542ad1bSJan Schmidt }; 33a542ad1bSJan Schmidt 34a542ad1bSJan Schmidt typedef int (iterate_extent_inodes_t)(u64 inum, u64 offset, u64 root, 35a542ad1bSJan Schmidt void *ctx); 36a542ad1bSJan Schmidt typedef int (iterate_irefs_t)(u64 parent, struct btrfs_inode_ref *iref, 37a542ad1bSJan Schmidt struct extent_buffer *eb, void *ctx); 38a542ad1bSJan Schmidt 39a542ad1bSJan Schmidt int inode_item_info(u64 inum, u64 ioff, struct btrfs_root *fs_root, 40a542ad1bSJan Schmidt struct btrfs_path *path); 41a542ad1bSJan Schmidt 42a542ad1bSJan Schmidt int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, 43a542ad1bSJan Schmidt struct btrfs_path *path, struct btrfs_key *found_key); 44a542ad1bSJan Schmidt 45a542ad1bSJan Schmidt int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, 46a542ad1bSJan Schmidt struct btrfs_extent_item *ei, u32 item_size, 47a542ad1bSJan Schmidt u64 *out_root, u8 *out_level); 48a542ad1bSJan Schmidt 49a542ad1bSJan Schmidt int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 50a542ad1bSJan Schmidt u64 extent_item_objectid, 517a3ae2f8SJan Schmidt u64 extent_offset, int search_commit_root, 52a542ad1bSJan Schmidt iterate_extent_inodes_t *iterate, void *ctx); 53a542ad1bSJan Schmidt 54a542ad1bSJan Schmidt int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 55a542ad1bSJan Schmidt struct btrfs_path *path, 56a542ad1bSJan Schmidt iterate_extent_inodes_t *iterate, void *ctx); 57a542ad1bSJan Schmidt 58a542ad1bSJan Schmidt int paths_from_inode(u64 inum, struct inode_fs_paths *ipath); 59a542ad1bSJan Schmidt 608da6d581SJan Schmidt int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 618da6d581SJan Schmidt struct btrfs_fs_info *fs_info, u64 bytenr, 628445f61cSJan Schmidt u64 delayed_ref_seq, u64 time_seq, 638445f61cSJan Schmidt struct ulist **roots); 6491cb916cSAlexander Block char *btrfs_iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, 6591cb916cSAlexander Block struct btrfs_inode_ref *iref, struct extent_buffer *eb, 6691cb916cSAlexander Block u64 parent, char *dest, u32 size); 678da6d581SJan Schmidt 68a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes); 69a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 70a542ad1bSJan Schmidt struct btrfs_path *path); 71a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath); 72a542ad1bSJan Schmidt 73a542ad1bSJan Schmidt #endif 74