xref: /linux/Documentation/admin-guide/device-mapper/thin-provisioning.rst (revision 6cf2a73cb2bc422a03984b285a63632c27f8c4e4)
1*f0ba4377SMauro Carvalho Chehab=================
2*f0ba4377SMauro Carvalho ChehabThin provisioning
3*f0ba4377SMauro Carvalho Chehab=================
4*f0ba4377SMauro Carvalho Chehab
5991d9fa0SJoe ThornberIntroduction
6991d9fa0SJoe Thornber============
7991d9fa0SJoe Thornber
84998d8edSMasanari IidaThis document describes a collection of device-mapper targets that
9991d9fa0SJoe Thornberbetween them implement thin-provisioning and snapshots.
10991d9fa0SJoe Thornber
11991d9fa0SJoe ThornberThe main highlight of this implementation, compared to the previous
12991d9fa0SJoe Thornberimplementation of snapshots, is that it allows many virtual devices to
13991d9fa0SJoe Thornberbe stored on the same data volume.  This simplifies administration and
14991d9fa0SJoe Thornberallows the sharing of data between volumes, thus reducing disk usage.
15991d9fa0SJoe Thornber
16991d9fa0SJoe ThornberAnother significant feature is support for an arbitrary depth of
17991d9fa0SJoe Thornberrecursive snapshots (snapshots of snapshots of snapshots ...).  The
18991d9fa0SJoe Thornberprevious implementation of snapshots did this by chaining together
19991d9fa0SJoe Thornberlookup tables, and so performance was O(depth).  This new
20991d9fa0SJoe Thornberimplementation uses a single data structure to avoid this degradation
21991d9fa0SJoe Thornberwith depth.  Fragmentation may still be an issue, however, in some
22991d9fa0SJoe Thornberscenarios.
23991d9fa0SJoe Thornber
24991d9fa0SJoe ThornberMetadata is stored on a separate device from data, giving the
25991d9fa0SJoe Thornberadministrator some freedom, for example to:
26991d9fa0SJoe Thornber
27991d9fa0SJoe Thornber- Improve metadata resilience by storing metadata on a mirrored volume
28991d9fa0SJoe Thornber  but data on a non-mirrored one.
29991d9fa0SJoe Thornber
30991d9fa0SJoe Thornber- Improve performance by storing the metadata on SSD.
31991d9fa0SJoe Thornber
32991d9fa0SJoe ThornberStatus
33991d9fa0SJoe Thornber======
34991d9fa0SJoe Thornber
356c7413c0SMike SnitzerThese targets are considered safe for production use.  But different use
366c7413c0SMike Snitzercases will have different performance characteristics, for example due
376c7413c0SMike Snitzerto fragmentation of the data volume.
38991d9fa0SJoe Thornber
39991d9fa0SJoe ThornberIf you find this software is not performing as expected please mail
40991d9fa0SJoe Thornberdm-devel@redhat.com with details and we'll try our best to improve
41991d9fa0SJoe Thornberthings for you.
42991d9fa0SJoe Thornber
436c7413c0SMike SnitzerUserspace tools for checking and repairing the metadata have been fully
446c7413c0SMike Snitzerdeveloped and are available as 'thin_check' and 'thin_repair'.  The name
456c7413c0SMike Snitzerof the package that provides these utilities varies by distribution (on
466c7413c0SMike Snitzera Red Hat distribution it is named 'device-mapper-persistent-data').
47991d9fa0SJoe Thornber
48991d9fa0SJoe ThornberCookbook
49991d9fa0SJoe Thornber========
50991d9fa0SJoe Thornber
51991d9fa0SJoe ThornberThis section describes some quick recipes for using thin provisioning.
52991d9fa0SJoe ThornberThey use the dmsetup program to control the device-mapper driver
53991d9fa0SJoe Thornberdirectly.  End users will be advised to use a higher-level volume
54991d9fa0SJoe Thornbermanager such as LVM2 once support has been added.
55991d9fa0SJoe Thornber
56991d9fa0SJoe ThornberPool device
57991d9fa0SJoe Thornber-----------
58991d9fa0SJoe Thornber
59991d9fa0SJoe ThornberThe pool device ties together the metadata volume and the data volume.
60991d9fa0SJoe ThornberIt maps I/O linearly to the data volume and updates the metadata via
61991d9fa0SJoe Thornbertwo mechanisms:
62991d9fa0SJoe Thornber
63991d9fa0SJoe Thornber- Function calls from the thin targets
64991d9fa0SJoe Thornber
65991d9fa0SJoe Thornber- Device-mapper 'messages' from userspace which control the creation of new
66991d9fa0SJoe Thornber  virtual devices amongst other things.
67991d9fa0SJoe Thornber
68991d9fa0SJoe ThornberSetting up a fresh pool device
69991d9fa0SJoe Thornber------------------------------
70991d9fa0SJoe Thornber
71991d9fa0SJoe ThornberSetting up a pool device requires a valid metadata device, and a
72991d9fa0SJoe Thornberdata device.  If you do not have an existing metadata device you can
73991d9fa0SJoe Thornbermake one by zeroing the first 4k to indicate empty metadata.
74991d9fa0SJoe Thornber
75991d9fa0SJoe Thornber    dd if=/dev/zero of=$metadata_dev bs=4096 count=1
76991d9fa0SJoe Thornber
77991d9fa0SJoe ThornberThe amount of metadata you need will vary according to how many blocks
78991d9fa0SJoe Thornberare shared between thin devices (i.e. through snapshots).  If you have
79991d9fa0SJoe Thornberless sharing than average you'll need a larger-than-average metadata device.
80991d9fa0SJoe Thornber
81991d9fa0SJoe ThornberAs a guide, we suggest you calculate the number of bytes to use in the
82991d9fa0SJoe Thornbermetadata device as 48 * $data_dev_size / $data_block_size but round it up
83c4a69ecdSMike Snitzerto 2MB if the answer is smaller.  If you're creating large numbers of
84c4a69ecdSMike Snitzersnapshots which are recording large amounts of change, you may find you
85c4a69ecdSMike Snitzerneed to increase this.
86991d9fa0SJoe Thornber
87c4a69ecdSMike SnitzerThe largest size supported is 16GB: If the device is larger,
88c4a69ecdSMike Snitzera warning will be issued and the excess space will not be used.
89991d9fa0SJoe Thornber
90991d9fa0SJoe ThornberReloading a pool table
91991d9fa0SJoe Thornber----------------------
92991d9fa0SJoe Thornber
93991d9fa0SJoe ThornberYou may reload a pool's table, indeed this is how the pool is resized
94991d9fa0SJoe Thornberif it runs out of space.  (N.B. While specifying a different metadata
95991d9fa0SJoe Thornberdevice when reloading is not forbidden at the moment, things will go
96991d9fa0SJoe Thornberwrong if it does not route I/O to exactly the same on-disk location as
97991d9fa0SJoe Thornberpreviously.)
98991d9fa0SJoe Thornber
99991d9fa0SJoe ThornberUsing an existing pool device
100991d9fa0SJoe Thornber-----------------------------
101991d9fa0SJoe Thornber
102*f0ba4377SMauro Carvalho Chehab::
103*f0ba4377SMauro Carvalho Chehab
104991d9fa0SJoe Thornber    dmsetup create pool \
105991d9fa0SJoe Thornber	--table "0 20971520 thin-pool $metadata_dev $data_dev \
106991d9fa0SJoe Thornber		 $data_block_size $low_water_mark"
107991d9fa0SJoe Thornber
108991d9fa0SJoe Thornber$data_block_size gives the smallest unit of disk space that can be
109a561ddbeSCarlos Maiolinoallocated at a time expressed in units of 512-byte sectors.
110a561ddbeSCarlos Maiolino$data_block_size must be between 128 (64KB) and 2097152 (1GB) and a
111a561ddbeSCarlos Maiolinomultiple of 128 (64KB).  $data_block_size cannot be changed after the
112a561ddbeSCarlos Maiolinothin-pool is created.  People primarily interested in thin provisioning
113a561ddbeSCarlos Maiolinomay want to use a value such as 1024 (512KB).  People doing lots of
114a561ddbeSCarlos Maiolinosnapshotting may want a smaller value such as 128 (64KB).  If you are
115a561ddbeSCarlos Maiolinonot zeroing newly-allocated data, a larger $data_block_size in the
116a561ddbeSCarlos Maiolinoregion of 256000 (128MB) is suggested.
117991d9fa0SJoe Thornber
118991d9fa0SJoe Thornber$low_water_mark is expressed in blocks of size $data_block_size.  If
119991d9fa0SJoe Thornberfree space on the data device drops below this level then a dm event
120991d9fa0SJoe Thornberwill be triggered which a userspace daemon should catch allowing it to
121991d9fa0SJoe Thornberextend the pool device.  Only one such event will be sent.
1229b28a110Smulhern
1239b28a110SmulhernNo special event is triggered if a just resumed device's free space is below
1249b28a110Smulhernthe low water mark. However, resuming a device always triggers an
1259b28a110Smulhernevent; a userspace daemon should verify that free space exceeds the low
1269b28a110Smulhernwater mark when handling this event.
127991d9fa0SJoe Thornber
12807f2b6e0SMike SnitzerA low water mark for the metadata device is maintained in the kernel and
12907f2b6e0SMike Snitzerwill trigger a dm event if free space on the metadata device drops below
13007f2b6e0SMike Snitzerit.
13107f2b6e0SMike Snitzer
13207f2b6e0SMike SnitzerUpdating on-disk metadata
13307f2b6e0SMike Snitzer-------------------------
13407f2b6e0SMike Snitzer
13507f2b6e0SMike SnitzerOn-disk metadata is committed every time a FLUSH or FUA bio is written.
13607f2b6e0SMike SnitzerIf no such requests are made then commits will occur every second.  This
13707f2b6e0SMike Snitzermeans the thin-provisioning target behaves like a physical disk that has
13807f2b6e0SMike Snitzera volatile write cache.  If power is lost you may lose some recent
13907f2b6e0SMike Snitzerwrites.  The metadata should always be consistent in spite of any crash.
14007f2b6e0SMike Snitzer
14107f2b6e0SMike SnitzerIf data space is exhausted the pool will either error or queue IO
14207f2b6e0SMike Snitzeraccording to the configuration (see: error_if_no_space).  If metadata
14307f2b6e0SMike Snitzerspace is exhausted or a metadata operation fails: the pool will error IO
14407f2b6e0SMike Snitzeruntil the pool is taken offline and repair is performed to 1) fix any
14507f2b6e0SMike Snitzerpotential inconsistencies and 2) clear the flag that imposes repair.
14607f2b6e0SMike SnitzerOnce the pool's metadata device is repaired it may be resized, which
14707f2b6e0SMike Snitzerwill allow the pool to return to normal operation.  Note that if a pool
14807f2b6e0SMike Snitzeris flagged as needing repair, the pool's data and metadata devices
14907f2b6e0SMike Snitzercannot be resized until repair is performed.  It should also be noted
15007f2b6e0SMike Snitzerthat when the pool's metadata space is exhausted the current metadata
15107f2b6e0SMike Snitzertransaction is aborted.  Given that the pool will cache IO whose
15207f2b6e0SMike Snitzercompletion may have already been acknowledged to upper IO layers
15307f2b6e0SMike Snitzer(e.g. filesystem) it is strongly suggested that consistency checks
15407f2b6e0SMike Snitzer(e.g. fsck) be performed on those layers when repair of the pool is
15507f2b6e0SMike Snitzerrequired.
15607f2b6e0SMike Snitzer
157991d9fa0SJoe ThornberThin provisioning
158991d9fa0SJoe Thornber-----------------
159991d9fa0SJoe Thornber
160991d9fa0SJoe Thornberi) Creating a new thinly-provisioned volume.
161991d9fa0SJoe Thornber
162991d9fa0SJoe Thornber  To create a new thinly- provisioned volume you must send a message to an
163*f0ba4377SMauro Carvalho Chehab  active pool device, /dev/mapper/pool in this example::
164991d9fa0SJoe Thornber
165991d9fa0SJoe Thornber    dmsetup message /dev/mapper/pool 0 "create_thin 0"
166991d9fa0SJoe Thornber
167991d9fa0SJoe Thornber  Here '0' is an identifier for the volume, a 24-bit number.  It's up
168991d9fa0SJoe Thornber  to the caller to allocate and manage these identifiers.  If the
169991d9fa0SJoe Thornber  identifier is already in use, the message will fail with -EEXIST.
170991d9fa0SJoe Thornber
171991d9fa0SJoe Thornberii) Using a thinly-provisioned volume.
172991d9fa0SJoe Thornber
173*f0ba4377SMauro Carvalho Chehab  Thinly-provisioned volumes are activated using the 'thin' target::
174991d9fa0SJoe Thornber
175991d9fa0SJoe Thornber    dmsetup create thin --table "0 2097152 thin /dev/mapper/pool 0"
176991d9fa0SJoe Thornber
177991d9fa0SJoe Thornber  The last parameter is the identifier for the thinp device.
178991d9fa0SJoe Thornber
179991d9fa0SJoe ThornberInternal snapshots
180991d9fa0SJoe Thornber------------------
181991d9fa0SJoe Thornber
182991d9fa0SJoe Thornberi) Creating an internal snapshot.
183991d9fa0SJoe Thornber
184991d9fa0SJoe Thornber  Snapshots are created with another message to the pool.
185991d9fa0SJoe Thornber
186991d9fa0SJoe Thornber  N.B.  If the origin device that you wish to snapshot is active, you
187991d9fa0SJoe Thornber  must suspend it before creating the snapshot to avoid corruption.
188991d9fa0SJoe Thornber  This is NOT enforced at the moment, so please be careful!
189991d9fa0SJoe Thornber
190*f0ba4377SMauro Carvalho Chehab  ::
191*f0ba4377SMauro Carvalho Chehab
192991d9fa0SJoe Thornber    dmsetup suspend /dev/mapper/thin
193991d9fa0SJoe Thornber    dmsetup message /dev/mapper/pool 0 "create_snap 1 0"
194991d9fa0SJoe Thornber    dmsetup resume /dev/mapper/thin
195991d9fa0SJoe Thornber
196991d9fa0SJoe Thornber  Here '1' is the identifier for the volume, a 24-bit number.  '0' is the
197991d9fa0SJoe Thornber  identifier for the origin device.
198991d9fa0SJoe Thornber
199991d9fa0SJoe Thornberii) Using an internal snapshot.
200991d9fa0SJoe Thornber
201991d9fa0SJoe Thornber  Once created, the user doesn't have to worry about any connection
202991d9fa0SJoe Thornber  between the origin and the snapshot.  Indeed the snapshot is no
203991d9fa0SJoe Thornber  different from any other thinly-provisioned device and can be
204991d9fa0SJoe Thornber  snapshotted itself via the same method.  It's perfectly legal to
205991d9fa0SJoe Thornber  have only one of them active, and there's no ordering requirement on
206991d9fa0SJoe Thornber  activating or removing them both.  (This differs from conventional
207991d9fa0SJoe Thornber  device-mapper snapshots.)
208991d9fa0SJoe Thornber
209*f0ba4377SMauro Carvalho Chehab  Activate it exactly the same way as any other thinly-provisioned volume::
210991d9fa0SJoe Thornber
211991d9fa0SJoe Thornber    dmsetup create snap --table "0 2097152 thin /dev/mapper/pool 1"
212991d9fa0SJoe Thornber
2132dd9c257SJoe ThornberExternal snapshots
2142dd9c257SJoe Thornber------------------
2152dd9c257SJoe Thornber
216*f0ba4377SMauro Carvalho ChehabYou can use an external **read only** device as an origin for a
2172dd9c257SJoe Thornberthinly-provisioned volume.  Any read to an unprovisioned area of the
2182dd9c257SJoe Thornberthin device will be passed through to the origin.  Writes trigger
2192dd9c257SJoe Thornberthe allocation of new blocks as usual.
2202dd9c257SJoe Thornber
2212dd9c257SJoe ThornberOne use case for this is VM hosts that want to run guests on
2222dd9c257SJoe Thornberthinly-provisioned volumes but have the base image on another device
2232dd9c257SJoe Thornber(possibly shared between many VMs).
2242dd9c257SJoe Thornber
2252dd9c257SJoe ThornberYou must not write to the origin device if you use this technique!
2262dd9c257SJoe ThornberOf course, you may write to the thin device and take internal snapshots
2272dd9c257SJoe Thornberof the thin volume.
2282dd9c257SJoe Thornber
2292dd9c257SJoe Thornberi) Creating a snapshot of an external device
2302dd9c257SJoe Thornber
2312dd9c257SJoe Thornber  This is the same as creating a thin device.
2322dd9c257SJoe Thornber  You don't mention the origin at this stage.
2332dd9c257SJoe Thornber
234*f0ba4377SMauro Carvalho Chehab  ::
235*f0ba4377SMauro Carvalho Chehab
2362dd9c257SJoe Thornber    dmsetup message /dev/mapper/pool 0 "create_thin 0"
2372dd9c257SJoe Thornber
2382dd9c257SJoe Thornberii) Using a snapshot of an external device.
2392dd9c257SJoe Thornber
240*f0ba4377SMauro Carvalho Chehab  Append an extra parameter to the thin target specifying the origin::
2412dd9c257SJoe Thornber
2422dd9c257SJoe Thornber    dmsetup create snap --table "0 2097152 thin /dev/mapper/pool 0 /dev/image"
2432dd9c257SJoe Thornber
2442dd9c257SJoe Thornber  N.B. All descendants (internal snapshots) of this snapshot require the
2452dd9c257SJoe Thornber  same extra origin parameter.
2462dd9c257SJoe Thornber
247991d9fa0SJoe ThornberDeactivation
248991d9fa0SJoe Thornber------------
249991d9fa0SJoe Thornber
250991d9fa0SJoe ThornberAll devices using a pool must be deactivated before the pool itself
251991d9fa0SJoe Thornbercan be.
252991d9fa0SJoe Thornber
253*f0ba4377SMauro Carvalho Chehab::
254*f0ba4377SMauro Carvalho Chehab
255991d9fa0SJoe Thornber    dmsetup remove thin
256991d9fa0SJoe Thornber    dmsetup remove snap
257991d9fa0SJoe Thornber    dmsetup remove pool
258991d9fa0SJoe Thornber
259991d9fa0SJoe ThornberReference
260991d9fa0SJoe Thornber=========
261991d9fa0SJoe Thornber
262991d9fa0SJoe Thornber'thin-pool' target
263991d9fa0SJoe Thornber------------------
264991d9fa0SJoe Thornber
265991d9fa0SJoe Thornberi) Constructor
266991d9fa0SJoe Thornber
267*f0ba4377SMauro Carvalho Chehab    ::
268*f0ba4377SMauro Carvalho Chehab
269991d9fa0SJoe Thornber      thin-pool <metadata dev> <data dev> <data block size (sectors)> \
270991d9fa0SJoe Thornber	        <low water mark (blocks)> [<number of feature args> [<arg>]*]
271991d9fa0SJoe Thornber
272991d9fa0SJoe Thornber    Optional feature arguments:
27367e2e2b2SJoe Thornber
274*f0ba4377SMauro Carvalho Chehab      skip_block_zeroing:
275*f0ba4377SMauro Carvalho Chehab	Skip the zeroing of newly-provisioned blocks.
27667e2e2b2SJoe Thornber
277*f0ba4377SMauro Carvalho Chehab      ignore_discard:
278*f0ba4377SMauro Carvalho Chehab	Disable discard support.
27967e2e2b2SJoe Thornber
280*f0ba4377SMauro Carvalho Chehab      no_discard_passdown:
281*f0ba4377SMauro Carvalho Chehab	Don't pass discards down to the underlying
28267e2e2b2SJoe Thornber	data device, but just remove the mapping.
283991d9fa0SJoe Thornber
284*f0ba4377SMauro Carvalho Chehab      read_only:
285*f0ba4377SMauro Carvalho Chehab		 Don't allow any changes to be made to the pool
28628700a36SMike Snitzer		 metadata.  This mode is only available after the
28728700a36SMike Snitzer		 thin-pool has been created and first used in full
28828700a36SMike Snitzer		 read/write mode.  It cannot be specified on initial
28928700a36SMike Snitzer		 thin-pool creation.
290e49e5829SJoe Thornber
291*f0ba4377SMauro Carvalho Chehab      error_if_no_space:
292*f0ba4377SMauro Carvalho Chehab	Error IOs, instead of queueing, if no space.
293787a996cSMike Snitzer
294991d9fa0SJoe Thornber    Data block size must be between 64KB (128 sectors) and 1GB
295991d9fa0SJoe Thornber    (2097152 sectors) inclusive.
296991d9fa0SJoe Thornber
297991d9fa0SJoe Thornber
298991d9fa0SJoe Thornberii) Status
299991d9fa0SJoe Thornber
300*f0ba4377SMauro Carvalho Chehab    ::
301*f0ba4377SMauro Carvalho Chehab
302991d9fa0SJoe Thornber      <transaction id> <used metadata blocks>/<total metadata blocks>
303991d9fa0SJoe Thornber      <used data blocks>/<total data blocks> <held metadata root>
3047efd5fedSmulhern      ro|rw|out_of_data_space [no_]discard_passdown [error|queue]_if_no_space
30563c8ecb6SAndy Grover      needs_check|- metadata_low_watermark
306991d9fa0SJoe Thornber
307991d9fa0SJoe Thornber    transaction id:
308991d9fa0SJoe Thornber	A 64-bit number used by userspace to help synchronise with metadata
309991d9fa0SJoe Thornber	from volume managers.
310991d9fa0SJoe Thornber
311991d9fa0SJoe Thornber    used data blocks / total data blocks
312991d9fa0SJoe Thornber	If the number of free blocks drops below the pool's low water mark a
313991d9fa0SJoe Thornber	dm event will be sent to userspace.  This event is edge-triggered and
314991d9fa0SJoe Thornber	it will occur only once after each resume so volume manager writers
315991d9fa0SJoe Thornber	should register for the event and then check the target's status.
316991d9fa0SJoe Thornber
317991d9fa0SJoe Thornber    held metadata root:
318f6d16d32SMike Snitzer	The location, in blocks, of the metadata root that has been
319991d9fa0SJoe Thornber	'held' for userspace read access.  '-' indicates there is no
320f6d16d32SMike Snitzer	held root.
321991d9fa0SJoe Thornber
322e49e5829SJoe Thornber    discard_passdown|no_discard_passdown
323e49e5829SJoe Thornber	Whether or not discards are actually being passed down to the
324e49e5829SJoe Thornber	underlying device.  When this is enabled when loading the table,
325e49e5829SJoe Thornber	it can get disabled if the underlying device doesn't support it.
326e49e5829SJoe Thornber
327e4c78e21SMike Snitzer    ro|rw|out_of_data_space
328e49e5829SJoe Thornber	If the pool encounters certain types of device failures it will
329e49e5829SJoe Thornber	drop into a read-only metadata mode in which no changes to
330e49e5829SJoe Thornber	the pool metadata (like allocating new blocks) are permitted.
331e49e5829SJoe Thornber
332e49e5829SJoe Thornber	In serious cases where even a read-only mode is deemed unsafe
333e49e5829SJoe Thornber	no further I/O will be permitted and the status will just
334e49e5829SJoe Thornber	contain the string 'Fail'.  The userspace recovery tools
335e49e5829SJoe Thornber	should then be used.
336e49e5829SJoe Thornber
337787a996cSMike Snitzer    error_if_no_space|queue_if_no_space
338787a996cSMike Snitzer	If the pool runs out of data or metadata space, the pool will
339787a996cSMike Snitzer	either queue or error the IO destined to the data device.  The
34080c57893SMike Snitzer	default is to queue the IO until more space is added or the
34180c57893SMike Snitzer	'no_space_timeout' expires.  The 'no_space_timeout' dm-thin-pool
34280c57893SMike Snitzer	module parameter can be used to change this timeout -- it
34380c57893SMike Snitzer	defaults to 60 seconds but may be disabled using a value of 0.
344787a996cSMike Snitzer
345e4c78e21SMike Snitzer    needs_check
346e4c78e21SMike Snitzer	A metadata operation has failed, resulting in the needs_check
347e4c78e21SMike Snitzer	flag being set in the metadata's superblock.  The metadata
348e4c78e21SMike Snitzer	device must be deactivated and checked/repaired before the
349e4c78e21SMike Snitzer	thin-pool can be made fully operational again.  '-' indicates
350e4c78e21SMike Snitzer	needs_check is not set.
351e4c78e21SMike Snitzer
35263c8ecb6SAndy Grover    metadata_low_watermark:
35363c8ecb6SAndy Grover	Value of metadata low watermark in blocks.  The kernel sets this
35463c8ecb6SAndy Grover	value internally but userspace needs to know this value to
35563c8ecb6SAndy Grover	determine if an event was caused by crossing this threshold.
35663c8ecb6SAndy Grover
357991d9fa0SJoe Thornberiii) Messages
358991d9fa0SJoe Thornber
359991d9fa0SJoe Thornber    create_thin <dev id>
360991d9fa0SJoe Thornber	Create a new thinly-provisioned device.
361991d9fa0SJoe Thornber	<dev id> is an arbitrary unique 24-bit identifier chosen by
362991d9fa0SJoe Thornber	the caller.
363991d9fa0SJoe Thornber
364991d9fa0SJoe Thornber    create_snap <dev id> <origin id>
365991d9fa0SJoe Thornber	Create a new snapshot of another thinly-provisioned device.
366991d9fa0SJoe Thornber	<dev id> is an arbitrary unique 24-bit identifier chosen by
367991d9fa0SJoe Thornber	the caller.
368991d9fa0SJoe Thornber	<origin id> is the identifier of the thinly-provisioned device
369991d9fa0SJoe Thornber	of which the new device will be a snapshot.
370991d9fa0SJoe Thornber
371991d9fa0SJoe Thornber    delete <dev id>
372991d9fa0SJoe Thornber	Deletes a thin device.  Irreversible.
373991d9fa0SJoe Thornber
374991d9fa0SJoe Thornber    set_transaction_id <current id> <new id>
375991d9fa0SJoe Thornber	Userland volume managers, such as LVM, need a way to
376991d9fa0SJoe Thornber	synchronise their external metadata with the internal metadata of the
377991d9fa0SJoe Thornber	pool target.  The thin-pool target offers to store an
378991d9fa0SJoe Thornber	arbitrary 64-bit transaction id and return it on the target's
379991d9fa0SJoe Thornber	status line.  To avoid races you must provide what you think
380991d9fa0SJoe Thornber	the current transaction id is when you change it with this
381991d9fa0SJoe Thornber	compare-and-swap message.
382991d9fa0SJoe Thornber
383cc8394d8SJoe Thornber    reserve_metadata_snap
384cc8394d8SJoe Thornber        Reserve a copy of the data mapping btree for use by userland.
385cc8394d8SJoe Thornber        This allows userland to inspect the mappings as they were when
386cc8394d8SJoe Thornber        this message was executed.  Use the pool's status command to
387cc8394d8SJoe Thornber        get the root block associated with the metadata snapshot.
388cc8394d8SJoe Thornber
389cc8394d8SJoe Thornber    release_metadata_snap
390cc8394d8SJoe Thornber        Release a previously reserved copy of the data mapping btree.
391cc8394d8SJoe Thornber
392991d9fa0SJoe Thornber'thin' target
393991d9fa0SJoe Thornber-------------
394991d9fa0SJoe Thornber
395991d9fa0SJoe Thornberi) Constructor
396991d9fa0SJoe Thornber
397*f0ba4377SMauro Carvalho Chehab    ::
398*f0ba4377SMauro Carvalho Chehab
3992dd9c257SJoe Thornber        thin <pool dev> <dev id> [<external origin dev>]
400991d9fa0SJoe Thornber
401991d9fa0SJoe Thornber    pool dev:
402991d9fa0SJoe Thornber	the thin-pool device, e.g. /dev/mapper/my_pool or 253:0
403991d9fa0SJoe Thornber
404991d9fa0SJoe Thornber    dev id:
405991d9fa0SJoe Thornber	the internal device identifier of the device to be
406991d9fa0SJoe Thornber	activated.
407991d9fa0SJoe Thornber
4082dd9c257SJoe Thornber    external origin dev:
4092dd9c257SJoe Thornber	an optional block device outside the pool to be treated as a
4102dd9c257SJoe Thornber	read-only snapshot origin: reads to unprovisioned areas of the
4112dd9c257SJoe Thornber	thin target will be mapped to this device.
4122dd9c257SJoe Thornber
413991d9fa0SJoe ThornberThe pool doesn't store any size against the thin devices.  If you
414991d9fa0SJoe Thornberload a thin target that is smaller than you've been using previously,
415991d9fa0SJoe Thornberthen you'll have no access to blocks mapped beyond the end.  If you
416991d9fa0SJoe Thornberload a target that is bigger than before, then extra blocks will be
417991d9fa0SJoe Thornberprovisioned as and when needed.
418991d9fa0SJoe Thornber
419991d9fa0SJoe Thornberii) Status
420991d9fa0SJoe Thornber
421991d9fa0SJoe Thornber    <nr mapped sectors> <highest mapped sector>
422e49e5829SJoe Thornber	If the pool has encountered device errors and failed, the status
423e49e5829SJoe Thornber	will just contain the string 'Fail'.  The userspace recovery
424e49e5829SJoe Thornber	tools should then be used.
4252bc8a61cSmulhern
4262bc8a61cSmulhern    In the case where <nr mapped sectors> is 0, there is no highest
4272bc8a61cSmulhern    mapped sector and the value of <highest mapped sector> is unspecified.
428