1
2
3
4
5
6
7#ifndef DM_THIN_METADATA_H
8#define DM_THIN_METADATA_H
9
10#include "persistent-data/dm-block-manager.h"
11
12#define THIN_METADATA_BLOCK_SIZE 4096
13
14
15
16struct dm_pool_metadata;
17struct dm_thin_device;
18
19
20
21
22typedef uint64_t dm_thin_id;
23
24
25
26
27struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
28 sector_t data_block_size);
29
30int dm_pool_metadata_close(struct dm_pool_metadata *pmd);
31
32
33
34
35
36#define THIN_FEATURE_COMPAT_SUPP 0UL
37#define THIN_FEATURE_COMPAT_RO_SUPP 0UL
38#define THIN_FEATURE_INCOMPAT_SUPP 0UL
39
40
41
42
43int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev);
44
45
46
47
48
49
50
51int dm_pool_create_snap(struct dm_pool_metadata *pmd, dm_thin_id dev,
52 dm_thin_id origin);
53
54
55
56
57
58
59int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd,
60 dm_thin_id dev);
61
62
63
64
65
66int dm_pool_commit_metadata(struct dm_pool_metadata *pmd);
67
68
69
70
71int dm_pool_set_metadata_transaction_id(struct dm_pool_metadata *pmd,
72 uint64_t current_id,
73 uint64_t new_id);
74
75int dm_pool_get_metadata_transaction_id(struct dm_pool_metadata *pmd,
76 uint64_t *result);
77
78
79
80
81int dm_pool_hold_metadata_root(struct dm_pool_metadata *pmd);
82
83int dm_pool_get_held_metadata_root(struct dm_pool_metadata *pmd,
84 dm_block_t *result);
85
86
87
88
89
90
91
92
93int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_thin_id dev,
94 struct dm_thin_device **td);
95
96int dm_pool_close_thin_device(struct dm_thin_device *td);
97
98dm_thin_id dm_thin_dev_id(struct dm_thin_device *td);
99
100struct dm_thin_lookup_result {
101 dm_block_t block;
102 int shared;
103};
104
105
106
107
108
109
110
111int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block,
112 int can_block, struct dm_thin_lookup_result *result);
113
114
115
116
117int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result);
118
119
120
121
122int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block,
123 dm_block_t data_block);
124
125int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block);
126
127
128
129
130int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
131 dm_block_t *highest_mapped);
132
133int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result);
134
135int dm_pool_get_free_block_count(struct dm_pool_metadata *pmd,
136 dm_block_t *result);
137
138int dm_pool_get_free_metadata_block_count(struct dm_pool_metadata *pmd,
139 dm_block_t *result);
140
141int dm_pool_get_metadata_dev_size(struct dm_pool_metadata *pmd,
142 dm_block_t *result);
143
144int dm_pool_get_data_block_size(struct dm_pool_metadata *pmd, sector_t *result);
145
146int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result);
147
148
149
150
151
152int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size);
153
154
155
156#endif
157