xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/device-mapper/writecache.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=================
2*4882a593SmuzhiyunWritecache target
3*4882a593Smuzhiyun=================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThe writecache target caches writes on persistent memory or on SSD. It
6*4882a593Smuzhiyundoesn't cache reads because reads are supposed to be cached in page cache
7*4882a593Smuzhiyunin normal RAM.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunWhen the device is constructed, the first sector should be zeroed or the
10*4882a593Smuzhiyunfirst sector should contain valid superblock from previous invocation.
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunConstructor parameters:
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun1. type of the cache device - "p" or "s"
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun	- p - persistent memory
17*4882a593Smuzhiyun	- s - SSD
18*4882a593Smuzhiyun2. the underlying device that will be cached
19*4882a593Smuzhiyun3. the cache device
20*4882a593Smuzhiyun4. block size (4096 is recommended; the maximum block size is the page
21*4882a593Smuzhiyun   size)
22*4882a593Smuzhiyun5. the number of optional parameters (the parameters with an argument
23*4882a593Smuzhiyun   count as two)
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun	start_sector n		(default: 0)
26*4882a593Smuzhiyun		offset from the start of cache device in 512-byte sectors
27*4882a593Smuzhiyun	high_watermark n	(default: 50)
28*4882a593Smuzhiyun		start writeback when the number of used blocks reach this
29*4882a593Smuzhiyun		watermark
30*4882a593Smuzhiyun	low_watermark x		(default: 45)
31*4882a593Smuzhiyun		stop writeback when the number of used blocks drops below
32*4882a593Smuzhiyun		this watermark
33*4882a593Smuzhiyun	writeback_jobs n	(default: unlimited)
34*4882a593Smuzhiyun		limit the number of blocks that are in flight during
35*4882a593Smuzhiyun		writeback. Setting this value reduces writeback
36*4882a593Smuzhiyun		throughput, but it may improve latency of read requests
37*4882a593Smuzhiyun	autocommit_blocks n	(default: 64 for pmem, 65536 for ssd)
38*4882a593Smuzhiyun		when the application writes this amount of blocks without
39*4882a593Smuzhiyun		issuing the FLUSH request, the blocks are automatically
40*4882a593Smuzhiyun		commited
41*4882a593Smuzhiyun	autocommit_time ms	(default: 1000)
42*4882a593Smuzhiyun		autocommit time in milliseconds. The data is automatically
43*4882a593Smuzhiyun		commited if this time passes and no FLUSH request is
44*4882a593Smuzhiyun		received
45*4882a593Smuzhiyun	fua			(by default on)
46*4882a593Smuzhiyun		applicable only to persistent memory - use the FUA flag
47*4882a593Smuzhiyun		when writing data from persistent memory back to the
48*4882a593Smuzhiyun		underlying device
49*4882a593Smuzhiyun	nofua
50*4882a593Smuzhiyun		applicable only to persistent memory - don't use the FUA
51*4882a593Smuzhiyun		flag when writing back data and send the FLUSH request
52*4882a593Smuzhiyun		afterwards
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun		- some underlying devices perform better with fua, some
55*4882a593Smuzhiyun		  with nofua. The user should test it
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunStatus:
58*4882a593Smuzhiyun1. error indicator - 0 if there was no error, otherwise error number
59*4882a593Smuzhiyun2. the number of blocks
60*4882a593Smuzhiyun3. the number of free blocks
61*4882a593Smuzhiyun4. the number of blocks under writeback
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunMessages:
64*4882a593Smuzhiyun	flush
65*4882a593Smuzhiyun		flush the cache device. The message returns successfully
66*4882a593Smuzhiyun		if the cache device was flushed without an error
67*4882a593Smuzhiyun	flush_on_suspend
68*4882a593Smuzhiyun		flush the cache device on next suspend. Use this message
69*4882a593Smuzhiyun		when you are going to remove the cache device. The proper
70*4882a593Smuzhiyun		sequence for removing the cache device is:
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun		1. send the "flush_on_suspend" message
73*4882a593Smuzhiyun		2. load an inactive table with a linear target that maps
74*4882a593Smuzhiyun		   to the underlying device
75*4882a593Smuzhiyun		3. suspend the device
76*4882a593Smuzhiyun		4. ask for status and verify that there are no errors
77*4882a593Smuzhiyun		5. resume the device, so that it will use the linear
78*4882a593Smuzhiyun		   target
79*4882a593Smuzhiyun		6. the cache device is now inactive and it can be deleted
80