1+ =====
2+ Cache
3+ =====
4+
15Introduction
26============
37
@@ -24,10 +28,13 @@ scenarios (eg. a vm image server).
2428Glossary
2529========
2630
27- Migration - Movement of the primary copy of a logical block from one
31+ Migration
32+ Movement of the primary copy of a logical block from one
2833 device to the other.
29- Promotion - Migration from slow device to fast device.
30- Demotion - Migration from fast device to slow device.
34+ Promotion
35+ Migration from slow device to fast device.
36+ Demotion
37+ Migration from fast device to slow device.
3138
3239The origin device always contains a copy of the logical block, which
3340may be out of date or kept in sync with the copy on the cache device
@@ -169,45 +176,53 @@ Target interface
169176Constructor
170177-----------
171178
172- cache <metadata dev> <cache dev> <origin dev> <block size>
173- <#feature args> [<feature arg>]*
174- <policy> <#policy args> [policy args]*
179+ ::
180+
181+ cache <metadata dev> <cache dev> <origin dev> <block size>
182+ <#feature args> [<feature arg>]*
183+ <policy> <#policy args> [policy args]*
175184
176- metadata dev : fast device holding the persistent metadata
177- cache dev : fast device holding cached data blocks
178- origin dev : slow device holding original data blocks
179- block size : cache unit size in sectors
185+ ================ =======================================================
186+ metadata dev fast device holding the persistent metadata
187+ cache dev fast device holding cached data blocks
188+ origin dev slow device holding original data blocks
189+ block size cache unit size in sectors
180190
181- #feature args : number of feature arguments passed
182- feature args : writethrough or passthrough (The default is writeback.)
191+ #feature args number of feature arguments passed
192+ feature args writethrough or passthrough (The default is writeback.)
183193
184- policy : the replacement policy to use
185- #policy args : an even number of arguments corresponding to
186- key/value pairs passed to the policy
187- policy args : key/value pairs passed to the policy
188- E.g. 'sequential_threshold 1024'
189- See cache-policies.txt for details.
194+ policy the replacement policy to use
195+ #policy args an even number of arguments corresponding to
196+ key/value pairs passed to the policy
197+ policy args key/value pairs passed to the policy
198+ E.g. 'sequential_threshold 1024'
199+ See cache-policies.txt for details.
200+ ================ =======================================================
190201
191202Optional feature arguments are:
192- writethrough : write through caching that prohibits cache block
193- content from being different from origin block content.
194- Without this argument, the default behaviour is to write
195- back cache block contents later for performance reasons,
196- so they may differ from the corresponding origin blocks.
197-
198- passthrough : a degraded mode useful for various cache coherency
199- situations (e.g., rolling back snapshots of
200- underlying storage). Reads and writes always go to
201- the origin. If a write goes to a cached origin
202- block, then the cache block is invalidated.
203- To enable passthrough mode the cache must be clean.
204-
205- metadata2 : use version 2 of the metadata. This stores the dirty bits
206- in a separate btree, which improves speed of shutting
207- down the cache.
208-
209- no_discard_passdown : disable passing down discards from the cache
210- to the origin's data device.
203+
204+
205+ ==================== ========================================================
206+ writethrough write through caching that prohibits cache block
207+ content from being different from origin block content.
208+ Without this argument, the default behaviour is to write
209+ back cache block contents later for performance reasons,
210+ so they may differ from the corresponding origin blocks.
211+
212+ passthrough a degraded mode useful for various cache coherency
213+ situations (e.g., rolling back snapshots of
214+ underlying storage). Reads and writes always go to
215+ the origin. If a write goes to a cached origin
216+ block, then the cache block is invalidated.
217+ To enable passthrough mode the cache must be clean.
218+
219+ metadata2 use version 2 of the metadata. This stores the dirty
220+ bits in a separate btree, which improves speed of
221+ shutting down the cache.
222+
223+ no_discard_passdown disable passing down discards from the cache
224+ to the origin's data device.
225+ ==================== ========================================================
211226
212227A policy called 'default' is always registered. This is an alias for
213228the policy we currently think is giving best all round performance.
@@ -218,54 +233,61 @@ the characteristics of a specific policy, always request it by name.
218233Status
219234------
220235
221- <metadata block size> <#used metadata blocks>/<#total metadata blocks>
222- <cache block size> <#used cache blocks>/<#total cache blocks>
223- <#read hits> <#read misses> <#write hits> <#write misses>
224- <#demotions> <#promotions> <#dirty> <#features> <features>*
225- <#core args> <core args>* <policy name> <#policy args> <policy args>*
226- <cache metadata mode>
227-
228- metadata block size : Fixed block size for each metadata block in
229- sectors
230- #used metadata blocks : Number of metadata blocks used
231- #total metadata blocks : Total number of metadata blocks
232- cache block size : Configurable block size for the cache device
233- in sectors
234- #used cache blocks : Number of blocks resident in the cache
235- #total cache blocks : Total number of cache blocks
236- #read hits : Number of times a READ bio has been mapped
237- to the cache
238- #read misses : Number of times a READ bio has been mapped
239- to the origin
240- #write hits : Number of times a WRITE bio has been mapped
241- to the cache
242- #write misses : Number of times a WRITE bio has been
243- mapped to the origin
244- #demotions : Number of times a block has been removed
245- from the cache
246- #promotions : Number of times a block has been moved to
247- the cache
248- #dirty : Number of blocks in the cache that differ
249- from the origin
250- #feature args : Number of feature args to follow
251- feature args : 'writethrough' (optional)
252- #core args : Number of core arguments (must be even)
253- core args : Key/value pairs for tuning the core
254- e.g. migration_threshold
255- policy name : Name of the policy
256- #policy args : Number of policy arguments to follow (must be even)
257- policy args : Key/value pairs e.g. sequential_threshold
258- cache metadata mode : ro if read-only, rw if read-write
259- In serious cases where even a read-only mode is deemed unsafe
260- no further I/O will be permitted and the status will just
261- contain the string 'Fail'. The userspace recovery tools
262- should then be used.
263- needs_check : 'needs_check' if set, '-' if not set
264- A metadata operation has failed, resulting in the needs_check
265- flag being set in the metadata's superblock. The metadata
266- device must be deactivated and checked/repaired before the
267- cache can be made fully operational again. '-' indicates
268- needs_check is not set.
236+ ::
237+
238+ <metadata block size> <#used metadata blocks>/<#total metadata blocks>
239+ <cache block size> <#used cache blocks>/<#total cache blocks>
240+ <#read hits> <#read misses> <#write hits> <#write misses>
241+ <#demotions> <#promotions> <#dirty> <#features> <features>*
242+ <#core args> <core args>* <policy name> <#policy args> <policy args>*
243+ <cache metadata mode>
244+
245+
246+ ========================= =====================================================
247+ metadata block size Fixed block size for each metadata block in
248+ sectors
249+ #used metadata blocks Number of metadata blocks used
250+ #total metadata blocks Total number of metadata blocks
251+ cache block size Configurable block size for the cache device
252+ in sectors
253+ #used cache blocks Number of blocks resident in the cache
254+ #total cache blocks Total number of cache blocks
255+ #read hits Number of times a READ bio has been mapped
256+ to the cache
257+ #read misses Number of times a READ bio has been mapped
258+ to the origin
259+ #write hits Number of times a WRITE bio has been mapped
260+ to the cache
261+ #write misses Number of times a WRITE bio has been
262+ mapped to the origin
263+ #demotions Number of times a block has been removed
264+ from the cache
265+ #promotions Number of times a block has been moved to
266+ the cache
267+ #dirty Number of blocks in the cache that differ
268+ from the origin
269+ #feature args Number of feature args to follow
270+ feature args 'writethrough' (optional)
271+ #core args Number of core arguments (must be even)
272+ core args Key/value pairs for tuning the core
273+ e.g. migration_threshold
274+ policy name Name of the policy
275+ #policy args Number of policy arguments to follow (must be even)
276+ policy args Key/value pairs e.g. sequential_threshold
277+ cache metadata mode ro if read-only, rw if read-write
278+
279+ In serious cases where even a read-only mode is
280+ deemed unsafe no further I/O will be permitted and
281+ the status will just contain the string 'Fail'.
282+ The userspace recovery tools should then be used.
283+ needs_check 'needs_check' if set, '-' if not set
284+ A metadata operation has failed, resulting in the
285+ needs_check flag being set in the metadata's
286+ superblock. The metadata device must be
287+ deactivated and checked/repaired before the
288+ cache can be made fully operational again.
289+ '-' indicates needs_check is not set.
290+ ========================= =====================================================
269291
270292Messages
271293--------
@@ -274,11 +296,12 @@ Policies will have different tunables, specific to each one, so we
274296need a generic way of getting and setting these. Device-mapper
275297messages are used. (A sysfs interface would also be possible.)
276298
277- The message format is:
299+ The message format is::
278300
279301 <key> <value>
280302
281- E.g.
303+ E.g.::
304+
282305 dmsetup message my_cache 0 sequential_threshold 1024
283306
284307
@@ -290,11 +313,12 @@ of values from 5 to 9. Each cblock must be expressed as a decimal
290313value, in the future a variant message that takes cblock ranges
291314expressed in hexadecimal may be needed to better support efficient
292315invalidation of larger caches. The cache must be in passthrough mode
293- when invalidate_cblocks is used.
316+ when invalidate_cblocks is used::
294317
295318 invalidate_cblocks [<cblock>|<cblock begin>-<cblock end>]*
296319
297- E.g.
320+ E.g.::
321+
298322 dmsetup message my_cache 0 invalidate_cblocks 2345 3456-4567 5678-6789
299323
300324Examples
@@ -304,8 +328,10 @@ The test suite can be found here:
304328
305329https://github.com/jthornber/device-mapper-test-suite
306330
307- dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
308- /dev/mapper/ssd /dev/mapper/origin 512 1 writeback default 0'
309- dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
310- /dev/mapper/ssd /dev/mapper/origin 1024 1 writeback \
311- mq 4 sequential_threshold 1024 random_threshold 8'
331+ ::
332+
333+ dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
334+ /dev/mapper/ssd /dev/mapper/origin 512 1 writeback default 0'
335+ dmsetup create my_cache --table '0 41943040 cache /dev/mapper/metadata \
336+ /dev/mapper/ssd /dev/mapper/origin 1024 1 writeback \
337+ mq 4 sequential_threshold 1024 random_threshold 8'
0 commit comments