Two write modes for the cache
Sep 28, 2023The RAID controller has two options for handling upper-level write IO, as follows:
1.WriteBack mode: when the data is sent from the upper layer, the RAID controller will inform the host that I0 has completed immediately after saving it in the cache, so that the host can execute the next IO without waiting. At this time, the data is in the cache of the RAID controller card, but not really written to the disk, which plays a buffer role.
The RAID controller waits for the time to be idle and either writes to disk one by one, or writes to disk in bulk, or queues the IO (similar to the queuing technique on disk) for some optimization algorithm to write to disk efficiently. Because the disk write speed is slow, the RAID controller in this case deceives the host, but gains high speed, which is "keep the easy to the top, keep the trouble to yourself." This has a fatal shortcoming, that is, once the power fails unexpectedly, the data in the cache on the RAID card will all be lost, and at this time the host thinks that IO has completed, so the upper and lower layers will produce inconsistency, the consequences will be very serious.
As a result, critical applications such as databases have their own measures of consistency. Because of this, the high-end RAID card needs to use the battery to protect the cache, so that in the case of accidental power down, the battery can continue to power the cache to ensure that the data is not lost. When powered up again, the RAID card will first write the outstanding IO from the cache to disk.
2.WriteThrough mode: This is the writethrough mode, i.e., the top IO. Only after the data has actually been written to disk by the RAID controller will the host be notified of the completion of IO, which ensures high reliability. In this case, the cache's speedup is no longer beneficial, but its buffering is still effective.
In addition to being a write cache, the read cache is also very important. Caching is a complex subject and has a complex mechanism, one of which is called PreFctch, or prefetching, which reads data on disk that are "likely" to be accessed by the host next into the cache before the host has issued a read IO request. How do we calculate the possibility?
In fact, it is considered that the next time the host IO, there is a large rate of children will read the data in the disk location adjacent to the data read this time. This assumption is very useful for IO sequential reads, such as reading data that is logically contiguous, such as FTP large file transfer services, video on demand services, and so on, which are large file reading applications.
On the other hand, if many small files are also stored contiguously on disk, caching will greatly improve performance, because reading small files requires a high IOPS, and without caching, it will take a long time to rely on the head seek to complete IO each time.
There is also a caching algorithm, which is not based on prefetching, but on the assumption that the next time the host does IO, it may also read the data from the last or several (recent) reads.
This assumption is completely different from prefetching. After the RAID controller reads a piece of data into the cache, if the data is changed by the host's write IO, the controller does not immediately write it to disk for storage. It stays in the cache, because it assumes that the host may read the data again in the near future. Then there is no need to write to disk and delete the cache, and then wait for the host to read, and then read from the disk to the cache, it is better to static brake, simply stay in the cache, wait for the host to "toss" the frequency is not high, then write to disk.
Tips:Medium and high end RAID cards generally have more than 256MB of RAM as cache.
Unleash the power of RAID Experience high performance data storage with our advanced RAID cards. Trust our 10 + years of expertise.STOR Technology Limited will also provide you with a large number of original high-performance products, such as: lsi 9480 8i8e, lsi 9361 4i, lsi 9341 8i and so on, three-year warranty and unsurpassed factory price to reduce your concerns.