In the event of a power failure or other disruption during the write process, the filesystem consistency is still maintained because the active pointers are still pointing to the pre-change data.
The write that was interrupted is still available in local NVRAM upon next boot.
This data is checked for and when found, is replayed to the local memory buffer and immediately re-processed through the WAFL and RAID layers and written to disk during the next CP.
This next boot period could be when power is returned, when hardware failures are corrected, or when in a clustered scenario-upon booting in a takeover on the partner head.
Since all write data for one node is also stored in the partner controller’s NVRAM, when the takeover occurs and the downed node boots virtually, all the writes that had been acknowledged are available for it to replay to its memory buffer and process through WAFL and RAID layers and then written to disk.
In this clustered environment, when the giveback is performed and the original node boots, it will find the contents in NVRAM from when the node went down.
However, instead of replaying this log into memory and processing it for writing to disk, the node is aware that it had been taken over and that this data was already processed.
Upon this realization, the NVRAM contents will be cleared since the data was already written to disk.
WAFL attempts to place blocks that are likely to be accessed together in locations close together on disk.
This is achieved by buffering multiple write requests into memory and logging the changes to the NVRAM.
After a certain interval (normally 10 seconds), RAID stripes are created from the contents of the buffer, parity is computed, and these are then flushed to disk.
A flush will also be initiated if the buffers are close to filling up before the normal interval has expired.