2#2 |
The Virtual Disk Cache talks to the Virtual Disk Proxy module on one end and the Virtual Disk Server on the other (see Figure 2). To keep track of what pages are being cached, each cache instance maintains a hash table with an entry for each page. The page entry indicates whether the current instance owns the page. In this case that cache instance has exclusive access to write to the page. If the cache instance is not the owner, it may still be able to read from the page. All readers of a page are guaranteed to receive an invalidation request before the page gets changed. When the caches are started, one of the caches is specified as the initial owner of all pages. Whenever a cache needs to read or write a page it contacts the probable owner of that page. The contacted cache will either give up the page (if it is the owner), or forward the request to what it thinks is the owner.
The idea of ownership being to specific to each page may not be a good one. DynamO [9] uses a hierarchical ownership model which may have peformance advantages.
The Virtual Disk Cache will request a page from the Virtual Disk Server if there is no page entry for the page. When pages are written to, the Virtual Disk Cache will lazily write the copies back to the Server. Writes to the Server are asynchronous. The cache instance builds a queue of outstanding write requests and empties the queue as the acknowledgements arrive from the server. When the server fails to respond a thread that runs periodically will force a resend of the write requests.
The cache instances use spinlocks on pages that are currently being written to or read from to prevent corruption of data.