18c2ecf20Sopenharmony_ci================= 28c2ecf20Sopenharmony_ciWritecache target 38c2ecf20Sopenharmony_ci================= 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThe writecache target caches writes on persistent memory or on SSD. It 68c2ecf20Sopenharmony_cidoesn't cache reads because reads are supposed to be cached in page cache 78c2ecf20Sopenharmony_ciin normal RAM. 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciWhen the device is constructed, the first sector should be zeroed or the 108c2ecf20Sopenharmony_cifirst sector should contain valid superblock from previous invocation. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciConstructor parameters: 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci1. type of the cache device - "p" or "s" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci - p - persistent memory 178c2ecf20Sopenharmony_ci - s - SSD 188c2ecf20Sopenharmony_ci2. the underlying device that will be cached 198c2ecf20Sopenharmony_ci3. the cache device 208c2ecf20Sopenharmony_ci4. block size (4096 is recommended; the maximum block size is the page 218c2ecf20Sopenharmony_ci size) 228c2ecf20Sopenharmony_ci5. the number of optional parameters (the parameters with an argument 238c2ecf20Sopenharmony_ci count as two) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci start_sector n (default: 0) 268c2ecf20Sopenharmony_ci offset from the start of cache device in 512-byte sectors 278c2ecf20Sopenharmony_ci high_watermark n (default: 50) 288c2ecf20Sopenharmony_ci start writeback when the number of used blocks reach this 298c2ecf20Sopenharmony_ci watermark 308c2ecf20Sopenharmony_ci low_watermark x (default: 45) 318c2ecf20Sopenharmony_ci stop writeback when the number of used blocks drops below 328c2ecf20Sopenharmony_ci this watermark 338c2ecf20Sopenharmony_ci writeback_jobs n (default: unlimited) 348c2ecf20Sopenharmony_ci limit the number of blocks that are in flight during 358c2ecf20Sopenharmony_ci writeback. Setting this value reduces writeback 368c2ecf20Sopenharmony_ci throughput, but it may improve latency of read requests 378c2ecf20Sopenharmony_ci autocommit_blocks n (default: 64 for pmem, 65536 for ssd) 388c2ecf20Sopenharmony_ci when the application writes this amount of blocks without 398c2ecf20Sopenharmony_ci issuing the FLUSH request, the blocks are automatically 408c2ecf20Sopenharmony_ci commited 418c2ecf20Sopenharmony_ci autocommit_time ms (default: 1000) 428c2ecf20Sopenharmony_ci autocommit time in milliseconds. The data is automatically 438c2ecf20Sopenharmony_ci commited if this time passes and no FLUSH request is 448c2ecf20Sopenharmony_ci received 458c2ecf20Sopenharmony_ci fua (by default on) 468c2ecf20Sopenharmony_ci applicable only to persistent memory - use the FUA flag 478c2ecf20Sopenharmony_ci when writing data from persistent memory back to the 488c2ecf20Sopenharmony_ci underlying device 498c2ecf20Sopenharmony_ci nofua 508c2ecf20Sopenharmony_ci applicable only to persistent memory - don't use the FUA 518c2ecf20Sopenharmony_ci flag when writing back data and send the FLUSH request 528c2ecf20Sopenharmony_ci afterwards 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci - some underlying devices perform better with fua, some 558c2ecf20Sopenharmony_ci with nofua. The user should test it 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciStatus: 588c2ecf20Sopenharmony_ci1. error indicator - 0 if there was no error, otherwise error number 598c2ecf20Sopenharmony_ci2. the number of blocks 608c2ecf20Sopenharmony_ci3. the number of free blocks 618c2ecf20Sopenharmony_ci4. the number of blocks under writeback 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciMessages: 648c2ecf20Sopenharmony_ci flush 658c2ecf20Sopenharmony_ci flush the cache device. The message returns successfully 668c2ecf20Sopenharmony_ci if the cache device was flushed without an error 678c2ecf20Sopenharmony_ci flush_on_suspend 688c2ecf20Sopenharmony_ci flush the cache device on next suspend. Use this message 698c2ecf20Sopenharmony_ci when you are going to remove the cache device. The proper 708c2ecf20Sopenharmony_ci sequence for removing the cache device is: 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci 1. send the "flush_on_suspend" message 738c2ecf20Sopenharmony_ci 2. load an inactive table with a linear target that maps 748c2ecf20Sopenharmony_ci to the underlying device 758c2ecf20Sopenharmony_ci 3. suspend the device 768c2ecf20Sopenharmony_ci 4. ask for status and verify that there are no errors 778c2ecf20Sopenharmony_ci 5. resume the device, so that it will use the linear 788c2ecf20Sopenharmony_ci target 798c2ecf20Sopenharmony_ci 6. the cache device is now inactive and it can be deleted 80