2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public
4 * License v2 as published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 * General Public License for more details.
11 * You should have received a copy of the GNU General Public
12 * License along with this program; if not, write to the
13 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14 * Boston, MA 021110-1307, USA.
17 #ifndef __BTRFS_CONVERT_SOURCE_FS_H__
18 #define __BTRFS_CONVERT_SOURCE_FS_H__
20 #include "kerncompat.h"
24 #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID
27 * Reresents a simple contiguous range.
29 * For multiple or non-contiguous ranges, use extent_cache_tree from
37 extern const struct simple_range btrfs_reserved_ranges[3];
42 pthread_mutex_t mutex;
45 struct task_info *info;
48 struct btrfs_convert_context;
50 #define SOURCE_FS_NAME_LEN (16)
52 #define CONVERT_FLAG_DATACSUM (1U << 0)
53 #define CONVERT_FLAG_INLINE_DATA (1U << 1)
54 #define CONVERT_FLAG_XATTR (1U << 2)
55 #define CONVERT_FLAG_COPY_LABEL (1U << 3)
56 #define CONVERT_FLAG_SET_LABEL (1U << 4)
58 struct btrfs_convert_operations {
59 const char name[SOURCE_FS_NAME_LEN];
60 int (*open_fs)(struct btrfs_convert_context *cctx, const char *devname);
61 int (*read_used_space)(struct btrfs_convert_context *cctx);
62 int (*copy_inodes)(struct btrfs_convert_context *cctx,
63 struct btrfs_root *root, u32 covert_flags,
65 void (*close_fs)(struct btrfs_convert_context *cctx);
66 int (*check_state)(struct btrfs_convert_context *cctx);
69 struct btrfs_trans_handle;
71 struct btrfs_inode_item;
73 struct blk_iterate_data {
74 struct btrfs_trans_handle *trans;
75 struct btrfs_root *root;
76 struct btrfs_root *convert_root;
77 struct btrfs_inode_item *inode;
88 void init_convert_context(struct btrfs_convert_context *cctx);
89 void clean_convert_context(struct btrfs_convert_context *cctx);
90 int block_iterate_proc(u64 disk_block, u64 file_block,
91 struct blk_iterate_data *idata);
92 void init_blk_iterate_data(struct blk_iterate_data *data,
93 struct btrfs_trans_handle *trans,
94 struct btrfs_root *root,
95 struct btrfs_inode_item *inode,
96 u64 objectid, int checksum);
97 int convert_insert_dirent(struct btrfs_trans_handle *trans,
98 struct btrfs_root *root,
99 const char *name, size_t name_len,
100 u64 dir, u64 objectid,
101 u8 file_type, u64 index_cnt,
102 struct btrfs_inode_item *inode);
103 int read_disk_extent(struct btrfs_root *root, u64 bytenr,
104 u32 num_bytes, char *buffer);
105 int record_file_blocks(struct blk_iterate_data *data,
106 u64 file_block, u64 disk_block, u64 num_blocks);
109 * Simple range functions
111 * Get range end (exclusive)
113 static inline u64 range_end(const struct simple_range *range)
115 return (range->start + range->len);