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" 24a542ad1bSJan Schmidt 25a542ad1bSJan Schmidt struct inode_fs_paths { 26a542ad1bSJan Schmidt struct btrfs_path *btrfs_path; 27a542ad1bSJan Schmidt struct btrfs_root *fs_root; 28a542ad1bSJan Schmidt struct btrfs_data_container *fspath; 29a542ad1bSJan Schmidt }; 30a542ad1bSJan Schmidt 31a542ad1bSJan Schmidt typedef int (iterate_extent_inodes_t)(u64 inum, u64 offset, u64 root, 32a542ad1bSJan Schmidt void *ctx); 33a542ad1bSJan Schmidt typedef int (iterate_irefs_t)(u64 parent, struct btrfs_inode_ref *iref, 34a542ad1bSJan Schmidt struct extent_buffer *eb, void *ctx); 35a542ad1bSJan Schmidt 36a542ad1bSJan Schmidt int inode_item_info(u64 inum, u64 ioff, struct btrfs_root *fs_root, 37a542ad1bSJan Schmidt struct btrfs_path *path); 38a542ad1bSJan Schmidt 39a542ad1bSJan Schmidt int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, 40a542ad1bSJan Schmidt struct btrfs_path *path, struct btrfs_key *found_key); 41a542ad1bSJan Schmidt 42a542ad1bSJan Schmidt int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, 43a542ad1bSJan Schmidt struct btrfs_extent_item *ei, u32 item_size, 44a542ad1bSJan Schmidt u64 *out_root, u8 *out_level); 45a542ad1bSJan Schmidt 46a542ad1bSJan Schmidt int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 47a542ad1bSJan Schmidt struct btrfs_path *path, 48a542ad1bSJan Schmidt u64 extent_item_objectid, 49a542ad1bSJan Schmidt u64 extent_offset, 50a542ad1bSJan Schmidt iterate_extent_inodes_t *iterate, void *ctx); 51a542ad1bSJan Schmidt 52a542ad1bSJan Schmidt int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 53a542ad1bSJan Schmidt struct btrfs_path *path, 54a542ad1bSJan Schmidt iterate_extent_inodes_t *iterate, void *ctx); 55a542ad1bSJan Schmidt 56a542ad1bSJan Schmidt int paths_from_inode(u64 inum, struct inode_fs_paths *ipath); 57a542ad1bSJan Schmidt 588da6d581SJan Schmidt int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 598da6d581SJan Schmidt struct btrfs_fs_info *fs_info, u64 bytenr, 608da6d581SJan Schmidt u64 num_bytes, u64 seq, struct ulist **roots); 618da6d581SJan Schmidt 62a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes); 63a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 64a542ad1bSJan Schmidt struct btrfs_path *path); 65a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath); 66a542ad1bSJan Schmidt 67a542ad1bSJan Schmidt #endif 68