Skip to content

Commit 48debaf

Browse files
Mikulas Patockasnitm
Mikulas Patocka
authored andcommitted
dm: add writecache target
The writecache target caches writes on persistent memory or SSD. It is intended for databases or other programs that need extremely low commit latency. The writecache target doesn't cache reads because reads are supposed to be cached in page cache in normal RAM. If persistent memory isn't available this target can still be used in SSD mode. Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Colin Ian King <[email protected]> # fix missing goto Signed-off-by: Ross Zwisler <[email protected]> # fix compilation issue with !DAX Signed-off-by: Dan Carpenter <[email protected]> # use msecs_to_jiffies Acked-by: Dan Williams <[email protected]> # reworks to unify ARM and x86 flushing Signed-off-by: Mike Snitzer <[email protected]>
1 parent 72d711c commit 48debaf

File tree

4 files changed

+2385
-0
lines changed

4 files changed

+2385
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
The writecache target caches writes on persistent memory or on SSD. It
2+
doesn't cache reads because reads are supposed to be cached in page cache
3+
in normal RAM.
4+
5+
When the device is constructed, the first sector should be zeroed or the
6+
first sector should contain valid superblock from previous invocation.
7+
8+
Constructor parameters:
9+
1. type of the cache device - "p" or "s"
10+
p - persistent memory
11+
s - SSD
12+
2. the underlying device that will be cached
13+
3. the cache device
14+
4. block size (4096 is recommended; the maximum block size is the page
15+
size)
16+
5. the number of optional parameters (the parameters with an argument
17+
count as two)
18+
high_watermark n (default: 50)
19+
start writeback when the number of used blocks reach this
20+
watermark
21+
low_watermark x (default: 45)
22+
stop writeback when the number of used blocks drops below
23+
this watermark
24+
writeback_jobs n (default: unlimited)
25+
limit the number of blocks that are in flight during
26+
writeback. Setting this value reduces writeback
27+
throughput, but it may improve latency of read requests
28+
autocommit_blocks n (default: 64 for pmem, 65536 for ssd)
29+
when the application writes this amount of blocks without
30+
issuing the FLUSH request, the blocks are automatically
31+
commited
32+
autocommit_time ms (default: 1000)
33+
autocommit time in milliseconds. The data is automatically
34+
commited if this time passes and no FLUSH request is
35+
received
36+
fua (by default on)
37+
applicable only to persistent memory - use the FUA flag
38+
when writing data from persistent memory back to the
39+
underlying device
40+
nofua
41+
applicable only to persistent memory - don't use the FUA
42+
flag when writing back data and send the FLUSH request
43+
afterwards
44+
- some underlying devices perform better with fua, some
45+
with nofua. The user should test it
46+
47+
Status:
48+
1. error indicator - 0 if there was no error, otherwise error number
49+
2. the number of blocks
50+
3. the number of free blocks
51+
4. the number of blocks under writeback
52+
53+
Messages:
54+
flush
55+
flush the cache device. The message returns successfully
56+
if the cache device was flushed without an error
57+
flush_on_suspend
58+
flush the cache device on next suspend. Use this message
59+
when you are going to remove the cache device. The proper
60+
sequence for removing the cache device is:
61+
1. send the "flush_on_suspend" message
62+
2. load an inactive table with a linear target that maps
63+
to the underlying device
64+
3. suspend the device
65+
4. ask for status and verify that there are no errors
66+
5. resume the device, so that it will use the linear
67+
target
68+
6. the cache device is now inactive and it can be deleted

drivers/md/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ config DM_CACHE_SMQ
334334
of less memory utilization, improved performance and increased
335335
adaptability in the face of changing workloads.
336336

337+
config DM_WRITECACHE
338+
tristate "Writecache target"
339+
depends on BLK_DEV_DM
340+
---help---
341+
The writecache target caches writes on persistent memory or SSD.
342+
It is intended for databases or other programs that need extremely
343+
low commit latency.
344+
345+
The writecache target doesn't cache reads because reads are supposed
346+
to be cached in standard RAM.
347+
337348
config DM_ERA
338349
tristate "Era target (EXPERIMENTAL)"
339350
depends on BLK_DEV_DM

drivers/md/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ obj-$(CONFIG_DM_ERA) += dm-era.o
6767
obj-$(CONFIG_DM_LOG_WRITES) += dm-log-writes.o
6868
obj-$(CONFIG_DM_INTEGRITY) += dm-integrity.o
6969
obj-$(CONFIG_DM_ZONED) += dm-zoned.o
70+
obj-$(CONFIG_DM_WRITECACHE) += dm-writecache.o
7071

7172
ifeq ($(CONFIG_DM_UEVENT),y)
7273
dm-mod-objs += dm-uevent.o

0 commit comments

Comments
 (0)