Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dm-thin-metadata.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2011 Red Hat, Inc.
3  *
4  * This file is released under the GPL.
5  */
6 
7 #ifndef DM_THIN_METADATA_H
8 #define DM_THIN_METADATA_H
9 
11 
12 #define THIN_METADATA_BLOCK_SIZE 4096
13 
14 /*
15  * The metadata device is currently limited in size.
16  *
17  * We have one block of index, which can hold 255 index entries. Each
18  * index entry contains allocation info about 16k metadata blocks.
19  */
20 #define THIN_METADATA_MAX_SECTORS (255 * (1 << 14) * (THIN_METADATA_BLOCK_SIZE / (1 << SECTOR_SHIFT)))
21 
22 /*
23  * A metadata device larger than 16GB triggers a warning.
24  */
25 #define THIN_METADATA_MAX_SECTORS_WARNING (16 * (1024 * 1024 * 1024 >> SECTOR_SHIFT))
26 
27 /*----------------------------------------------------------------*/
28 
29 struct dm_pool_metadata;
31 
32 /*
33  * Device identifier
34  */
35 typedef uint64_t dm_thin_id;
36 
37 /*
38  * Reopens or creates a new, empty metadata volume.
39  */
42  bool format_device);
43 
45 
46 /*
47  * Compat feature flags. Any incompat flags beyond the ones
48  * specified below will prevent use of the thin metadata.
49  */
50 #define THIN_FEATURE_COMPAT_SUPP 0UL
51 #define THIN_FEATURE_COMPAT_RO_SUPP 0UL
52 #define THIN_FEATURE_INCOMPAT_SUPP 0UL
53 
54 /*
55  * Device creation/deletion.
56  */
58 
59 /*
60  * An internal snapshot.
61  *
62  * You can only snapshot a quiesced origin i.e. one that is either
63  * suspended or not instanced at all.
64  */
67 
68 /*
69  * Deletes a virtual device from the metadata. It _is_ safe to call this
70  * when that device is open. Operations on that device will just start
71  * failing. You still need to call close() on the device.
72  */
74  dm_thin_id dev);
75 
76 /*
77  * Commits _all_ metadata changes: device creation, deletion, mapping
78  * updates.
79  */
81 
82 /*
83  * Discards all uncommitted changes. Rereads the superblock, rolling back
84  * to the last good transaction. Thin devices remain open.
85  * dm_thin_aborted_changes() tells you if they had uncommitted changes.
86  *
87  * If this call fails it's only useful to call dm_pool_metadata_close().
88  * All other methods will fail with -EINVAL.
89  */
91 
92 /*
93  * Set/get userspace transaction id.
94  */
96  uint64_t current_id,
97  uint64_t new_id);
98 
100  uint64_t *result);
101 
102 /*
103  * Hold/get root for userspace transaction.
104  *
105  * The metadata snapshot is a copy of the current superblock (minus the
106  * space maps). Userland can access the data structures for READ
107  * operations only. A small performance hit is incurred by providing this
108  * copy of the metadata to userland due to extra copy-on-write operations
109  * on the metadata nodes. Release this as soon as you finish with it.
110  */
113 
115  dm_block_t *result);
116 
117 /*
118  * Actions on a single virtual device.
119  */
120 
121 /*
122  * Opening the same device more than once will fail with -EBUSY.
123  */
125  struct dm_thin_device **td);
126 
128 
130 
133  unsigned shared:1;
134 };
135 
136 /*
137  * Returns:
138  * -EWOULDBLOCK iff @can_block is set and would block.
139  * -ENODATA iff that mapping is not present.
140  * 0 success
141  */
143  int can_block, struct dm_thin_lookup_result *result);
144 
145 /*
146  * Obtain an unused block.
147  */
149 
150 /*
151  * Insert or remove block.
152  */
154  dm_block_t data_block);
155 
157 
158 /*
159  * Queries.
160  */
162 
164 
166  dm_block_t *highest_mapped);
167 
169 
171  dm_block_t *result);
172 
174  dm_block_t *result);
175 
177  dm_block_t *result);
178 
180 
182 
183 /*
184  * Returns -ENOSPC if the new size is too small and already allocated
185  * blocks would be lost.
186  */
188 
189 /*
190  * Flicks the underlying block manager into read only mode, so you know
191  * that nothing is changing.
192  */
194 
195 /*----------------------------------------------------------------*/
196 
197 #endif