xref: /openbmc/linux/fs/btrfs/backref.h (revision b9e9a6cb)
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 inode_item_info(u64 inum, u64 ioff, struct btrfs_root *fs_root,
36a542ad1bSJan Schmidt 			struct btrfs_path *path);
37a542ad1bSJan Schmidt 
38a542ad1bSJan Schmidt int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
3969917e43SLiu Bo 			struct btrfs_path *path, struct btrfs_key *found_key,
4069917e43SLiu Bo 			u64 *flags);
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 				u64 extent_item_objectid,
487a3ae2f8SJan Schmidt 				u64 extent_offset, int search_commit_root,
49a542ad1bSJan Schmidt 				iterate_extent_inodes_t *iterate, void *ctx);
50a542ad1bSJan Schmidt 
51a542ad1bSJan Schmidt int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
52a542ad1bSJan Schmidt 				struct btrfs_path *path,
53a542ad1bSJan Schmidt 				iterate_extent_inodes_t *iterate, void *ctx);
54a542ad1bSJan Schmidt 
55a542ad1bSJan Schmidt int paths_from_inode(u64 inum, struct inode_fs_paths *ipath);
56a542ad1bSJan Schmidt 
578da6d581SJan Schmidt int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
588da6d581SJan Schmidt 				struct btrfs_fs_info *fs_info, u64 bytenr,
59097b8a7cSJan Schmidt 				u64 time_seq, struct ulist **roots);
6096b5bd77SJan Schmidt char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
6196b5bd77SJan Schmidt 			u32 name_len, unsigned long name_off,
6296b5bd77SJan Schmidt 			struct extent_buffer *eb_in, u64 parent,
6396b5bd77SJan Schmidt 			char *dest, u32 size);
648da6d581SJan Schmidt 
65a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes);
66a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
67a542ad1bSJan Schmidt 					struct btrfs_path *path);
68a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath);
69a542ad1bSJan Schmidt 
70f186373fSMark Fasheh int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
71f186373fSMark Fasheh 			  u64 start_off, struct btrfs_path *path,
72f186373fSMark Fasheh 			  struct btrfs_inode_extref **ret_extref,
73f186373fSMark Fasheh 			  u64 *found_off);
74f186373fSMark Fasheh 
75b9e9a6cbSWang Shilong int __init btrfs_prelim_ref_init(void);
76b9e9a6cbSWang Shilong void btrfs_prelim_ref_exit(void);
77a542ad1bSJan Schmidt #endif
78