Skip to content

Commit c23b968

Browse files
committed
btrfs-progs: image: move defintions from main.c to header
Signed-off-by: David Sterba <[email protected]>
1 parent 6784355 commit c23b968

File tree

2 files changed

+86
-84
lines changed

2 files changed

+86
-84
lines changed

image/main.c

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
#include "image/metadump.h"
5858
#include "image/sanitize.h"
5959

60-
#define MAX_WORKER_THREADS (32)
61-
6260
const struct dump_version dump_versions[] = {
6361
/*
6462
* The original format, which only supports tree blocks and free space
@@ -82,88 +80,6 @@ const struct dump_version dump_versions[] = {
8280

8381
const struct dump_version *current_version = &dump_versions[0];
8482

85-
struct async_work {
86-
struct list_head list;
87-
struct list_head ordered;
88-
u64 start;
89-
u64 size;
90-
u8 *buffer;
91-
size_t bufsize;
92-
int error;
93-
};
94-
95-
struct metadump_struct {
96-
struct btrfs_root *root;
97-
FILE *out;
98-
99-
pthread_t threads[MAX_WORKER_THREADS];
100-
size_t num_threads;
101-
pthread_mutex_t mutex;
102-
pthread_cond_t cond;
103-
struct rb_root name_tree;
104-
105-
struct extent_io_tree seen;
106-
107-
struct list_head list;
108-
struct list_head ordered;
109-
size_t num_items;
110-
size_t num_ready;
111-
112-
u64 pending_start;
113-
u64 pending_size;
114-
115-
int compress_level;
116-
int done;
117-
int data;
118-
enum sanitize_mode sanitize_names;
119-
120-
int error;
121-
122-
union {
123-
struct meta_cluster cluster;
124-
char meta_cluster_bytes[IMAGE_BLOCK_SIZE];
125-
};
126-
};
127-
128-
struct mdrestore_struct {
129-
FILE *in;
130-
FILE *out;
131-
132-
pthread_t threads[MAX_WORKER_THREADS];
133-
size_t num_threads;
134-
pthread_mutex_t mutex;
135-
pthread_cond_t cond;
136-
137-
/*
138-
* Records system chunk ranges, so restore can use this to determine
139-
* if an item is in chunk tree range.
140-
*/
141-
struct cache_tree sys_chunks;
142-
struct rb_root chunk_tree;
143-
struct rb_root physical_tree;
144-
struct list_head list;
145-
struct list_head overlapping_chunks;
146-
struct btrfs_super_block *original_super;
147-
size_t num_items;
148-
u32 nodesize;
149-
u64 devid;
150-
u64 alloced_chunks;
151-
u64 last_physical_offset;
152-
/* An quicker checker for if a item is in sys chunk range */
153-
u64 sys_chunk_end;
154-
u8 uuid[BTRFS_UUID_SIZE];
155-
u8 fsid[BTRFS_FSID_SIZE];
156-
157-
int compress_method;
158-
int done;
159-
int error;
160-
int old_restore;
161-
int fixup_offset;
162-
int multi_devices;
163-
int clear_space_cache;
164-
struct btrfs_fs_info *info;
165-
};
166-
16783
static struct extent_buffer *alloc_dummy_eb(u64 bytenr, u32 size);
16884

16985
static void csum_block(u8 *buf, size_t len)

image/metadump.h

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
#define __BTRFS_IMAGE_METADUMP_H__
1919

2020
#include "kerncompat.h"
21+
#include <pthread.h>
2122
#include "kernel-lib/rbtree.h"
2223
#include "kernel-lib/list.h"
2324
#include "kernel-shared/ctree.h"
25+
#include "image/sanitize.h"
2426

2527
#define IMAGE_BLOCK_SIZE SZ_1K
2628
#define IMAGE_BLOCK_MASK (IMAGE_BLOCK_SIZE - 1)
@@ -31,6 +33,8 @@
3133
#define COMPRESS_NONE 0
3234
#define COMPRESS_ZLIB 1
3335

36+
#define MAX_WORKER_THREADS (32)
37+
3438
struct dump_version {
3539
u64 magic_cpu;
3640
int version;
@@ -41,6 +45,16 @@ struct dump_version {
4145
extern const struct dump_version dump_versions[];
4246
const extern struct dump_version *current_version;
4347

48+
struct async_work {
49+
struct list_head list;
50+
struct list_head ordered;
51+
u64 start;
52+
u64 size;
53+
u8 *buffer;
54+
size_t bufsize;
55+
int error;
56+
};
57+
4458
struct meta_cluster_item {
4559
__le64 bytenr;
4660
__le32 size;
@@ -75,4 +89,76 @@ struct fs_chunk {
7589
struct list_head list;
7690
};
7791

92+
struct metadump_struct {
93+
struct btrfs_root *root;
94+
FILE *out;
95+
96+
pthread_t threads[MAX_WORKER_THREADS];
97+
size_t num_threads;
98+
pthread_mutex_t mutex;
99+
pthread_cond_t cond;
100+
struct rb_root name_tree;
101+
102+
struct extent_io_tree seen;
103+
104+
struct list_head list;
105+
struct list_head ordered;
106+
size_t num_items;
107+
size_t num_ready;
108+
109+
u64 pending_start;
110+
u64 pending_size;
111+
112+
int compress_level;
113+
int done;
114+
int data;
115+
enum sanitize_mode sanitize_names;
116+
117+
int error;
118+
119+
union {
120+
struct meta_cluster cluster;
121+
char meta_cluster_bytes[IMAGE_BLOCK_SIZE];
122+
};
123+
};
124+
125+
struct mdrestore_struct {
126+
FILE *in;
127+
FILE *out;
128+
129+
pthread_t threads[MAX_WORKER_THREADS];
130+
size_t num_threads;
131+
pthread_mutex_t mutex;
132+
pthread_cond_t cond;
133+
134+
/*
135+
* Records system chunk ranges, so restore can use this to determine
136+
* if an item is in chunk tree range.
137+
*/
138+
struct cache_tree sys_chunks;
139+
struct rb_root chunk_tree;
140+
struct rb_root physical_tree;
141+
struct list_head list;
142+
struct list_head overlapping_chunks;
143+
struct btrfs_super_block *original_super;
144+
size_t num_items;
145+
u32 nodesize;
146+
u64 devid;
147+
u64 alloced_chunks;
148+
u64 last_physical_offset;
149+
/* An quicker checker for if a item is in sys chunk range */
150+
u64 sys_chunk_end;
151+
u8 uuid[BTRFS_UUID_SIZE];
152+
u8 fsid[BTRFS_FSID_SIZE];
153+
154+
int compress_method;
155+
int done;
156+
int error;
157+
int old_restore;
158+
int fixup_offset;
159+
int multi_devices;
160+
int clear_space_cache;
161+
struct btrfs_fs_info *info;
162+
};
163+
78164
#endif

0 commit comments

Comments
 (0)