xref: /openbmc/linux/fs/btrfs/backref.h (revision a542ad1b)
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"
23a542ad1bSJan Schmidt 
24a542ad1bSJan Schmidt struct inode_fs_paths {
25a542ad1bSJan Schmidt 	struct btrfs_path		*btrfs_path;
26a542ad1bSJan Schmidt 	struct btrfs_root		*fs_root;
27a542ad1bSJan Schmidt 	struct btrfs_data_container	*fspath;
28a542ad1bSJan Schmidt };
29a542ad1bSJan Schmidt 
30a542ad1bSJan Schmidt typedef int (iterate_extent_inodes_t)(u64 inum, u64 offset, u64 root,
31a542ad1bSJan Schmidt 		void *ctx);
32a542ad1bSJan Schmidt typedef int (iterate_irefs_t)(u64 parent, struct btrfs_inode_ref *iref,
33a542ad1bSJan Schmidt 				struct extent_buffer *eb, 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,
39a542ad1bSJan Schmidt 			struct btrfs_path *path, struct btrfs_key *found_key);
40a542ad1bSJan Schmidt 
41a542ad1bSJan Schmidt int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb,
42a542ad1bSJan Schmidt 				struct btrfs_extent_item *ei, u32 item_size,
43a542ad1bSJan Schmidt 				u64 *out_root, u8 *out_level);
44a542ad1bSJan Schmidt 
45a542ad1bSJan Schmidt int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
46a542ad1bSJan Schmidt 				struct btrfs_path *path,
47a542ad1bSJan Schmidt 				u64 extent_item_objectid,
48a542ad1bSJan Schmidt 				u64 extent_offset,
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 
57a542ad1bSJan Schmidt struct btrfs_data_container *init_data_container(u32 total_bytes);
58a542ad1bSJan Schmidt struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
59a542ad1bSJan Schmidt 					struct btrfs_path *path);
60a542ad1bSJan Schmidt void free_ipath(struct inode_fs_paths *ipath);
61a542ad1bSJan Schmidt 
62a542ad1bSJan Schmidt #endif
63