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