Patent ID: 7979655

Claim:
A method for dynamically optimizing a write cache policy-controlling metric for a storage adapter connected to a plurality of storage devices, the storage adapter having a write cache that includes a plurality of write cache spaces, each write cache space storing data for one of the plurality of storage devices and including a plurality of cache lines, the method comprising: selecting one write cache space from the plurality of write cache spaces, the selected write cache space storing data for a corresponding one of the plurality of storage devices in N cache lines thereof; maintaining a figure of locality for the data in the selected write cache space, including setting a locality flag for each of the N cache lines in which data have high spatial locality, counting a number of cache lines that have the locality flag set, and dividing the number of cache lines that have the locality flag set by N to obtain the figure of locality, wherein the setting includes: when a write operation is directed to a sequence of cache lines in the selected write cache space, clearing the locality flag of the first cache line in the sequence and setting the locality flag of each of the subsequent cache lines in the sequence, and when a sequentially prior cache line of a select cache line in the selected write cache space contains data, setting the locality flag of the select cache line; and calculating the policy-controlling metric dynamically using the figure of locality and device-related information.