Method and apparatus to maintain data integrity in disk cache memory during and after periods of cache inaccessibility
View Patent ↗A volatile or nonvolatile cache memory can cache mass storage device read data and write data. The cache memory may become inaccessible, and I/O operations may go directly to the mass storage device, bypassing the cache memory. A log of write operations may be maintained to update the cache memory when it becomes available.
1. A method comprising:
during a low power state, performing reads and writes from and to a hard disk while a disk cache is inaccessible;
logging, in a log file, information associated with write operations to the hard disk performed while the disk cache is inaccessible;
determining a state of the disk cache has changed from inaccessible to accessible;
accessing the log file that includes information regarding previous writes to the hard disk performed while the disk cache was inaccessible to determining if the log is corrupt or if the log has overflowed;
in response to determining the log is corrupt or has overflowed, invalidating the entire disk cache; and
in response to determining the log is not corrupt and has not overflowed, invalidating disk cache entries that correspond to the previous writes to the hard disk.
2. The method of claim 1 wherein the low power state comprises a transition from booting from a power-off state.
3. The method of claim 1 wherein the low power state comprises a transition from recovering from a system crash.
4. The method of claim 1 wherein the low power state comprises a transition from awaking from a hibernation state.
5. The method of claim 1 wherein accessing the log file that includes information regarding previous writes comprises accessing a log on the hard disk.
6. The method of claim 1 wherein accessing the log file that includes information regarding previous writes log comprises accessing a log in the disk cache.
7. The method of claim 1 , wherein the disk cache comprises flash memory.
8. A computer-readable medium comprising a non-transitory storage medium having instructions stored thereon that when executed result in the computer performing:
during a low power state, performing reads and writes from and to a hard disk while a disk cache is inaccessible;
logging, in a log file, information associated with write operations to the hard disk performed while the disk cache is inaccessible;
determining a state of the disk cache has changed from inaccessible to accessible;
accessing the log file that includes information regarding previous writes to the hard disk performed while the disk cache was inaccessible to determining if the log is corrupt or if the log has overflowed;
in response to determining the log is corrupt or has overflowed, invalidating the entire disk cache; and
in response to determining the log is not corrupt and has not overflowed, invalidating disk cache entries that correspond to the previous writes to the hard disk.
9. The computer-readable medium of claim 8 wherein the low power state comprises a transition from booting from a power-off state.
10. The computer-readable medium of claim 8 wherein the low power state comprises a transition from recovering from a system crash.
11. The computer-readable medium of claim 8 wherein the low power state comprises a transition from awaking from a hibernation state.
12. The computer-readable medium of claim 8 wherein accessing the log file that includes information regarding previous writes log comprises accessing a log on the hard disk.
13. The computer-readable medium of claim 8 wherein accessing the log file that includes information regarding previous writes log comprises accessing a log in the disk cache.
14. The computer-readable medium of claim 8 , wherein the disk cache comprises flash memory.