About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / device-mapper / cache-policies.txt

Custom Search

Based on kernel version 3.13. Page generated on 2014-01-20 22:00 EST.

1	Guidance for writing policies
2	=============================
4	Try to keep transactionality out of it.  The core is careful to
5	avoid asking about anything that is migrating.  This is a pain, but
6	makes it easier to write the policies.
8	Mappings are loaded into the policy at construction time.
10	Every bio that is mapped by the target is referred to the policy.
11	The policy can return a simple HIT or MISS or issue a migration.
13	Currently there's no way for the policy to issue background work,
14	e.g. to start writing back dirty blocks that are going to be evicte
15	soon.
17	Because we map bios, rather than requests it's easy for the policy
18	to get fooled by many small bios.  For this reason the core target
19	issues periodic ticks to the policy.  It's suggested that the policy
20	doesn't update states (eg, hit counts) for a block more than once
21	for each tick.  The core ticks by watching bios complete, and so
22	trying to see when the io scheduler has let the ios run.
25	Overview of supplied cache replacement policies
26	===============================================
28	multiqueue
29	----------
31	This policy is the default.
33	The multiqueue policy has three sets of 16 queues: one set for entries
34	waiting for the cache and another two for those in the cache (a set for
35	clean entries and a set for dirty entries).
37	Cache entries in the queues are aged based on logical time. Entry into
38	the cache is based on variable thresholds and queue selection is based
39	on hit count on entry. The policy aims to take different cache miss
40	costs into account and to adjust to varying load patterns automatically.
42	Message and constructor argument pairs are:
43		'sequential_threshold <#nr_sequential_ios>' and
44		'random_threshold <#nr_random_ios>'.
46	The sequential threshold indicates the number of contiguous I/Os
47	required before a stream is treated as sequential.  The random threshold
48	is the number of intervening non-contiguous I/Os that must be seen
49	before the stream is treated as random again.
51	The sequential and random thresholds default to 512 and 4 respectively.
53	Large, sequential ios are probably better left on the origin device
54	since spindles tend to have good bandwidth. The io_tracker counts
55	contiguous I/Os to try to spot when the io is in one of these sequential
56	modes.
58	cleaner
59	-------
61	The cleaner writes back all dirty blocks in a cache to decommission it.
63	Examples
64	========
66	The syntax for a table is:
67		cache <metadata dev> <cache dev> <origin dev> <block size>
68		<#feature_args> [<feature arg>]*
69		<policy> <#policy_args> [<policy arg>]*
71	The syntax to send a message using the dmsetup command is:
72		dmsetup message <mapped device> 0 sequential_threshold 1024
73		dmsetup message <mapped device> 0 random_threshold 8
75	Using dmsetup:
76		dmsetup create blah --table "0 268435456 cache /dev/sdb /dev/sdc \
77		    /dev/sdd 512 0 mq 4 sequential_threshold 1024 random_threshold 8"
78		creates a 128GB large mapped device named 'blah' with the
79		sequential threshold set to 1024 and the random_threshold set to 8.
Hide Line Numbers
About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.