So flashcache module is a Kernel module that allows to use a SSD as a caching device that caches IO requests. You can think of it as similar to the cache present on a RAID controller.
Now let me answer your questions.
- to use random write or sequential write on Flashcache?
SSDs give best performance for random IO operations while the HDDs give best performance for sequential IO operations. Hence, its best to let SSD handle all the random IO and let the rotating disks handle the sequential IO. This can be configured when flashcache is configured to run in writeback mode by tuning the sysctl parameter “skip_seq_thresh_kb”, this can be done as follows:
dev.flashcache.sdb+c0d2.skip_seq_thresh_kb = 1024
Here “sdb+c0d2” is the name of the flashcache device. By setting skip_seq_thresh_kb to 1024 we are instructing the flashcache module to let IO operations greater than 1MB to pass through to the HDDs.
why writeback is persistent, but writethrough is non-persistent?
In writeback mode the writes are first performed on the SSD and then written back to the HDDs at a later time. In writethrough mode all writes are performed on the SSDs and immediately performed on the HDDs as well, which means that all the data that is present on the SSDs is also present on the HDDs and hence there is no need to maintain persistence
when writing into Flashcache, if cache miss occurs how will it deal with? I mean that is firstly reading original blocks from disk into Flashcache and then writing flashcache, OR directly writing into cache.
As in all caching mechanisms, upon a cache miss, the ata block is read from the disk and written to the SSD and then modified on the SSD afterwards what happens depends on the cache policy being used. If the cache policy is writeback, then the write is not immediately performed on the disk, however if the cache policy is writethrough then the write is immediately performed on the disk as well.