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 2255e301fdSFilipe Brandenburger #include <linux/btrfs.h> 238da6d581SJan Schmidt #include "ulist.h" 2491cb916cSAlexander Block #include "extent_io.h" 25a542ad1bSJan Schmidt 26a542ad1bSJan Schmidt struct inode_fs_paths { 27a542ad1bSJan Schmidt struct btrfs_path *btrfs_path; 28a542ad1bSJan Schmidt struct btrfs_root *fs_root; 29a542ad1bSJan Schmidt struct btrfs_data_container *fspath; 30a542ad1bSJan Schmidt }; 31a542ad1bSJan Schmidt 32a542ad1bSJan Schmidt typedef int (iterate_extent_inodes_t)(u64 inum, u64 offset, u64 root, 33a542ad1bSJan Schmidt void *ctx); 34a542ad1bSJan Schmidt 35a542ad1bSJan Schmidt int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, 3669917e43SLiu Bo struct btrfs_path *path, struct btrfs_key *found_key, 3769917e43SLiu Bo u64 *flags); 38a542ad1bSJan Schmidt 39a542ad1bSJan Schmidt int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, 406eda71d0SLiu Bo struct btrfs_key *key, struct btrfs_extent_item *ei, 416eda71d0SLiu Bo u32 item_size, u64 *out_root, u8 *out_level); 42a542ad1bSJan Schmidt 43a542ad1bSJan Schmidt int iterate_extent_inodes(struct btrfs_fs_info *fs_info, 44a542ad1bSJan Schmidt u64 extent_item_objectid, 457a3ae2f8SJan Schmidt u64 extent_offset, int search_commit_root, 46c995ab3cSZygo Blaxell iterate_extent_inodes_t *iterate, void *ctx, 47c995ab3cSZygo Blaxell bool ignore_offset); 48a542ad1bSJan Schmidt 49a542ad1bSJan Schmidt int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, 50a542ad1bSJan Schmidt struct btrfs_path *path, 51c995ab3cSZygo Blaxell iterate_extent_inodes_t *iterate, void *ctx, 52c995ab3cSZygo Blaxell bool ignore_offset); 53a542ad1bSJan Schmidt 54a542ad1bSJan Schmidt int paths_from_inode(u64 inum, struct inode_fs_paths *ipath); 55a542ad1bSJan Schmidt 568da6d581SJan Schmidt int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 578da6d581SJan Schmidt struct btrfs_fs_info *fs_info, u64 bytenr, 58c995ab3cSZygo Blaxell u64 time_seq, struct ulist **roots, bool ignore_offset); 5996b5bd77SJan Schmidt char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, 6096b5bd77SJan Schmidt u32 name_len, unsigned long name_off, 6196b5bd77SJan Schmidt struct extent_buffer *eb_in, u64 parent, 6296b5bd77SJan Schmidt char *dest, u32 size); 638da6d581SJan Schmidt 64a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes); 65a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 66a542ad1bSJan Schmidt struct btrfs_path *path); 67a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath); 68a542ad1bSJan Schmidt 69f186373fSMark Fasheh int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid, 70f186373fSMark Fasheh u64 start_off, struct btrfs_path *path, 71f186373fSMark Fasheh struct btrfs_inode_extref **ret_extref, 72f186373fSMark Fasheh u64 *found_off); 73bb739cf0SEdmund Nadolski int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr); 74f186373fSMark Fasheh 75b9e9a6cbSWang Shilong int __init btrfs_prelim_ref_init(void); 76b9e9a6cbSWang Shilong void btrfs_prelim_ref_exit(void); 7700142756SJeff Mahoney 7800142756SJeff Mahoney struct prelim_ref { 7900142756SJeff Mahoney struct rb_node rbnode; 8000142756SJeff Mahoney u64 root_id; 8100142756SJeff Mahoney struct btrfs_key key_for_search; 8200142756SJeff Mahoney int level; 8300142756SJeff Mahoney int count; 8400142756SJeff Mahoney struct extent_inode_elem *inode_list; 8500142756SJeff Mahoney u64 parent; 8600142756SJeff Mahoney u64 wanted_disk_byte; 8700142756SJeff Mahoney }; 8800142756SJeff Mahoney 89a542ad1bSJan Schmidt #endif 90