WO2012163027A1 - 控制缓存映射的方法及缓存系统 - Google Patents

控制缓存映射的方法及缓存系统 Download PDF

Info

Publication number
WO2012163027A1
WO2012163027A1 PCT/CN2011/081449 CN2011081449W WO2012163027A1 WO 2012163027 A1 WO2012163027 A1 WO 2012163027A1 CN 2011081449 W CN2011081449 W CN 2011081449W WO 2012163027 A1 WO2012163027 A1 WO 2012163027A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
target data
cache
storage medium
erasures
Prior art date
Application number
PCT/CN2011/081449
Other languages
English (en)
French (fr)
Inventor
王朱珍
王子毅
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to KR1020147005543A priority Critical patent/KR20140043497A/ko
Priority to AU2011369945A priority patent/AU2011369945B2/en
Priority to EP11866630.4A priority patent/EP2662774A4/en
Priority to CN201180002426.5A priority patent/CN102439572B/zh
Priority to RU2014113342/08A priority patent/RU2556459C1/ru
Priority to PCT/CN2011/081449 priority patent/WO2012163027A1/zh
Publication of WO2012163027A1 publication Critical patent/WO2012163027A1/zh
Priority to US14/034,817 priority patent/US20140025875A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7211Wear leveling

Definitions

  • the present invention relates to a cache mapping technology of a cache system, and more particularly to a method for controlling cache mapping when a flash medium is used as a cache and a cache system. Background technique
  • Flash Memory media is a long-lived non-volatile memory that retains stored data information in the event of a power outage.
  • flash media is often used as a cache of a conventional disk storage system such as a hard disk or a hard disk array to mitigate performance constraints caused by poor input and output performance of the underlying storage medium.
  • the mapping strategy employed between the cache and the underlying storage medium is a group associative mapping.
  • the underlying storage medium as a mapping source is divided into a plurality of groups according to the size of the cache as a mapping target, wherein the capacity size of each group is equal to the size of the cache.
  • Each group of the underlying storage medium is divided into the same number of regions (i.e., data blocks) according to the number and size of the target data blocks included in the cache, and the size of each region is consistent with the size of one target data block in the cache.
  • regions i.e., data blocks
  • different blocks of data correspond to different target blocks of data in the cache.
  • the data blocks of the corresponding locations are mapped to the same target data block in the cache.
  • Figure 1 shows an example of a group associative mapping.
  • the flash memory as the cache is divided into four target data blocks from the target data block 0 to the target data block 3.
  • the hard disk as the mapping source includes two groups, and each group is divided into four target data buffered.
  • the data block corresponding to the block, and the size of each data block in the hard disk is the same as the size of each target data block in the flash medium.
  • the mapping relationship between the hard disk and the cached group is as follows: in the first group of the hard disk (including data block 0 - data block 3), the data block 0 and the second group (including data block 4 - data block 7)
  • the data block 4 is mapped to the target data block 0 in the flash medium
  • the data block 1 in the first group of the hard disk and the data block 5 in the second group are mapped to the target data block 1 in the flash medium
  • the first group of the hard disk Data block 2 in the second group and data block 6 in the second group are mapped to the target data block 2 in the flash medium
  • the data in the first group of the hard disk Block 3 and data block 7 in the second group are mapped to target data block 3 in the flash medium.
  • the data in the data block 0 and the data block 4 are buffered into the target data block 0, and the data in the data block 1 and the data block 5 are buffered into the target data block 1, in the data block 2 and the data block 6.
  • the data is buffered into the target data block 2, and the data in the data block 3 and the data block 7 is buffered into the target data block 3.
  • the mapping relationship between the cache and the underlying storage medium is usually static. During the entire operation of the system, the target data blocks in the cache to which the data blocks in the underlying storage medium are mapped are usually unchanged. In this way, when the flash media is used as a cache, the number of erasures of the media area of the flash media mapped by the frequently accessed data in the system will be too frequent for an application scenario where the data access to the local area is abnormal in the system. Since the number of erases of flash media is limited, this will cause the media area of the flash media to which the frequently accessed data is mapped to reach the limit of the number of erases faster than other regions, resulting in the entire flash media being unavailable. Summary of the invention
  • embodiments of the present invention provide a method for controlling cache mapping and a cache system, and a dynamic mapping strategy is adopted between the cache and the underlying storage medium so that data frequently accessed in the system is not Statically maps to a target block of data on the cache, which optimizes the lifetime of the flash media as a cache.
  • An embodiment of the present invention provides a method for controlling a cache mapping, in which at least one data block in an underlying storage medium is mapped to a target data block in a cache of the underlying storage medium in a predetermined period of time, wherein the bottom layer One or more data blocks in the storage medium are only mapped to one target data block in the cache, the cache of the underlying storage medium includes a flash medium, and the replaced target data block in the cache includes the current cache.
  • An embodiment of the present invention provides a method for controlling a cache mapping, where the method includes: monitoring a number of erasures of each target data block in a cache of an underlying storage medium, wherein one or more data blocks in the underlying storage medium Mapping only to one target data block in the cache, the cache of the underlying storage medium including a flash memory medium;
  • Replacing the underlying storage medium when a difference between the number of erasures between the target data block having the maximum number of erasures and the target data block having the minimum number of erasures reaches a preset erasing threshold a target data block in the cache to which at least one data block is mapped,
  • the target data block in the cache that is replaced includes a target data block having the largest number of erasures in the current cache;
  • the number of erasures generated after the replacement of each target data block in the cache is continued.
  • An embodiment of the present invention provides a cache system, including: an underlying storage medium; a flash medium coupled to the underlying storage medium for use as a cache of the underlying storage medium, wherein one or more of the underlying storage media The data block is only mapped to one target data block in the cache; the processor is configured to: replace, by the predetermined time period, the target data in the cache of the underlying storage medium to which the at least one data block in the underlying storage medium is mapped Block, the target data block in the cache that is replaced includes a target data block having the largest number of erasures in the current cache.
  • An embodiment of the present invention provides a cache system, including: an underlying storage medium; a flash medium coupled to the underlying storage medium for use as a cache of the underlying storage medium, wherein one or more of the underlying storage media The data block is only mapped to one target data block in the cache; the processor is configured to: monitor the number of erasures of each target data block in the cache; when the cache has the largest number of erased target data blocks Replacing a target in the cache to which at least one of the underlying storage media is mapped when a difference between the number of erasures between the number of erasures between the target data block having the minimum number of erasures reaches a preset erasing threshold a data block, the target data block in the cache that is replaced includes a target data block having a maximum number of erasures in the current cache;
  • the number of erasures generated after the replacement of each target data block in the cache is continued.
  • the method and apparatus of the embodiment of the present invention replaces a target data block in a cache to which at least one data block including the data block corresponding to the target data block having the largest number of erasures is mapped, in the underlying storage medium, Optimized for the useful life of flash media acting as a cache.
  • Figure 1 shows an example of a group associative mapping
  • 2 is a schematic flow chart of a method for controlling cache mapping according to a first embodiment of the present invention
  • FIG. 3 to FIG. 5 are diagrams showing an example of controlling cache mapping by using the method of the first embodiment of the present invention, in different switching cycles. Schematic diagram of the mapping relationship;
  • FIG. 6 to FIG. 11 are diagrams showing a mapping relationship in different switching periods in another example of controlling cache mapping by using the method of the first embodiment of the present invention.
  • FIG. 12 is a schematic flow chart showing a method of controlling cache mapping according to Embodiment 2 of the present invention.
  • FIG. 13 to FIG. 14 are diagrams showing a mapping relationship in an example of controlling a cache map by using the method of the second embodiment of the present invention.
  • FIG. 15 illustrates a cache system in accordance with an embodiment of the present invention.
  • Embodiments of the present invention provide a method for controlling a cache mapping and a cache system, wherein the method includes: replacing at least one data block in an underlying storage medium with the underlying storage in a predetermined period of time a target data block in the cache of the medium, wherein one or more data blocks in the underlying storage medium are only mapped to one target data block in the cache, and the cache of the underlying storage medium includes a flash medium, replaced
  • the target data block in the cache includes a target data block having the largest number of erasures in the current cache.
  • FIG. 2 is a schematic flowchart diagram of a method for controlling cache mapping according to a first embodiment of the present invention.
  • the flash medium is used as a cache
  • the underlying storage medium is illustratively a hard disk, and one or more data blocks in the underlying storage medium are only mapped to one target data block in the cache.
  • flash media includes solid state disks (SSDs).
  • the method for controlling cache mapping in the first embodiment includes the following steps: In step S201, a timer is triggered to start timing according to a preset switching period T.
  • step S202 in each switching cycle of a switching cycle, the target data block in the cache to which the at least one data block in the hard disk is mapped is replaced, so that after one switching cycle, The number of erasures of each target data block in the cache is similar, wherein the number of switching cycles included in one switching cycle is not less than the number N of target data blocks included in the buffer.
  • FIG. 1 and FIG. 3 to FIG. 5 show a specific example of controlling cache mapping by using the method of the first embodiment of the present invention. In this example, in each switching cycle of a switching cycle, the target data block in the cache to which each data block in the hard disk is mapped is replaced, so that each data block in the hard disk is in a different switching cycle of one switching cycle.
  • the cache has 4 target data blocks
  • the hard disk includes two groups, each group is divided into 4 data blocks corresponding to the cached 4 target data blocks, and the hard disk The size of each data block in it is the same as the size of each target data block in the flash media.
  • this example adopts a periodic rotation dynamic switching strategy.
  • N is greater than An integer of 0.
  • N 4.
  • each time a switching cycle is passed the mapping target corresponding to each data block in the hard disk is switched.
  • Each data block in the hard disk has a different target data block mapped in different switching cycles.
  • the example initially adopts the mapping relationship shown in FIG.
  • the mapping relationship between the hard disk and the cache is: Data block 0 and data block 4 of the hard disk are mapped to the cached target data block 0, and the data block 1 of the hard disk is The data block 5 is mapped to the cached target data block 1, the data block 2 and the data block 6 of the hard disk are mapped to the cached target data block 2, and the data block 3 and the data block 7 of the hard disk are mapped to the cached target data block 3.
  • the above numbers are the numbers of data blocks or target data blocks.
  • the data buffered in each target data block in the flash medium is migrated to other target data blocks, respectively.
  • the valid data currently cached in the target data block 0 in the flash medium is migrated to the target data block 1
  • the currently cached valid data in the target data block 1 is migrated to the target data block 2
  • the target data is The valid data currently cached in block 2 is migrated to the target data block 3
  • the currently cached valid data in the target data block 3 is migrated to the target data block 0.
  • the modified mapping relationship is as shown in FIG. 3.
  • the valid data currently cached in the target data block 0 in the flash medium is also migrated to the target data block 1, and the currently cached valid data in the target data block 1 is migrated to the target data block 2, and the target data is The valid data currently cached in block 2 is migrated to the target data block 3, and the currently cached valid data in the target data block 3 is migrated to the target data block 0.
  • the mapping relationship between the cache and the hard disk is modified according to the migration, and the modified mapping relationship is as shown in FIG. 4 .
  • the valid data currently cached in the target data block 0 in the flash medium is also migrated to the target data block 1, and the currently cached valid data in the target data block 1 is migrated to the target data block 2, and the target data is The valid data currently cached in block 2 is migrated to the target data block 3, and the currently cached valid data in the target data block 3 is migrated to the target data block 0.
  • the mapping relationship between the cache and the hard disk is modified according to the migration, and the modified mapping relationship is modified.
  • the modified mapping relationship is as shown in FIG. 5.
  • the mapping relationship is modified accordingly, and the modified mapping relationship is as shown in FIG. 1, that is, the mapping relationship during the first period is returned. Such a switching cycle ends. Then, you can continue the switching process of the next switching cycle.
  • the replacement of the mapped target data block can be performed by updating the cache metadata stored in the flash medium and/or the memory.
  • the frequently accessed data blocks in the hard disk are respectively mapped to different target data blocks in the flash medium, thereby enabling access in the hard disk.
  • Frequent locales do not statically map only to a fixed target block of data, thereby extending and optimizing the life of the flash media.
  • the number of erasures of each target data block in the flash medium is close to, and close to the average value, the erasure times of each target data block are relatively evenly distributed, thereby enabling The life of the flash media is optimized.
  • the data of each target data block in the cache is separately transferred to the target data adjacent to the number according to the number order of the target data blocks in the cache.
  • the data currently cached in the target data block 0 may be migrated to the target data block 3, and the data currently cached in the target data block 3 is migrated to the target data block 2, which is currently in the target data block 2.
  • the cached data is migrated to target data block 1, target data
  • target data The order in which the currently cached data in block 1 is migrated to the target data block 0 is implemented to migrate the data cached in each target data block in the cache when the switching cycle arrives, and then replace each of the underlying storage media such as the hard disk accordingly.
  • the target data block to which the data block is mapped, and the mapping relationship between the hard disk and the cache is replaced accordingly.
  • the number of erasing and erasing of each target data block in the cache is close.
  • the approaching may be that the number of times of erasing and erasing of each target data block is close to an average value.
  • the difference in the number of times of erasing and erasing of each target data block may be less than a predetermined threshold of difference in erasing times.
  • the difference threshold can be set according to needs or a specific application scenario.
  • FIG. 6-11 illustrate another example of controlling cache mapping using a method in accordance with Embodiment 1 of the present invention.
  • the strategy of periodically arranging the dynamic switching mapping is performed to replace the target data block in the buffer to which each data block in the hard disk is mapped, so that after a switching cycle, each target data block in the buffer is The number of erases is close.
  • the number of switching cycles included in one switching cycle is equal to N multiplied by (N-1), where N is the number of target data blocks contained in the cache and N is an integer greater than zero.
  • N 3 in this example, so one switching cycle in this example includes 6 switching cycles.
  • the flash medium is used as a cache
  • the underlying storage medium is exemplarily a hard disk.
  • the cache has three target data blocks
  • the hard disk includes two groups, and each group is divided into three caches.
  • the target data block corresponds to three data blocks, and the size of each data block in the hard disk is consistent with the size of each target data block in the flash medium.
  • the data cached in the target data block that currently has the maximum number of erasures in the cache and other targets in the cache other than the maximum number of erasures In the data block, the data in the current switching cycle is exchanged a minimum number of times, and the target data exchanged with the target data block having the current maximum number of erasures in the last switching cycle in the current switching cycle.
  • the data buffered in any of the target data blocks of the block is exchanged, that is, the data migrates with each other, and according to the number of buffers in the target data block According to the migration, the target data block to which the data block in the corresponding hard disk is mapped is replaced accordingly.
  • each target data block in the cache has N-1 chances to become the target data block with the maximum number of erasures, that is, each target data block is the largest wipe in different N-1 cycles in one switching cycle.
  • the target data block of the number of writes corresponds to the most frequently accessed data block.
  • the target data block 0 in the flash medium has the largest number of erasures, which indicates that the data block 0 and the data block 3 currently mapped to the target data block 0 in the hard disk are accessed most frequently.
  • the target data blocks other than the target data block 0 are the target data block 1 and the target data block 2. As shown in FIG.
  • mapping relationship between the hard disk and the cache before the arrival of the first cycle is: Data block 0 and data block 3 of the hard disk are mapped to the cached target data block 0, and the data block of the hard disk 1 and data block 4 are mapped to the cached target data block 1, and the data block 2 and data block 5 of the hard disk are mapped to the cached target data block 2.
  • the valid data buffered in the target data block 0 in the flash medium is migrated to the target data block 1, and the currently cached valid data in the target data block 1 is migrated to the target data.
  • Block 0. After the data in the cache is migrated, according to the migration of the data in the target data block, the target data block in the cache to which the data block 0 and the data block 3 are mapped in the hard disk and the data block 1 and the data block 4 are mapped accordingly.
  • the target data block in the cache After the migration, the modified mapping relationship is as shown in Fig. 7. At this time, the most frequently accessed data block 0 and the data block 3 are mapped to the target data block 1.
  • the valid data buffered in the target data block 1 having the maximum number of erasures in the flash medium is migrated to the target data block 2, and the currently cached valid data in the target data block 2 is migrated to the target data block. 1.
  • the data migration in the cache according to the migration of the data in the target data block, the data block 0 and the data block 3 in the hard disk and the target data block in the buffer to which the data block 2 and the data block 5 are mapped are replaced accordingly.
  • the modified mapping relationship is as shown in FIG. 8. At this time, the most frequently accessed data block 0 and data block 3 in the hard disk are mapped to the target data block 2.
  • the valid data buffered in the target data block 2 with the maximum number of erasures in the flash medium is migrated to the target data block 0, and the currently cached valid data in the target data block 0 is migrated to the target data block. 2.
  • the modified mapping relationship is as shown in FIG. 9. At this time, the most frequently accessed data block 0 and data block 3 in the hard disk are mapped to the target data block 0.
  • the valid data cached in the target data block 0 with the maximum number of erasures in the flash medium is migrated to the target data block 1, and the currently cached valid data in the target data block 1 is migrated to the target data block.
  • the modified mapping relationship is as shown in FIG. At this time, the most frequently accessed data block 0 and data block 3 in the hard disk are mapped to the target data block 1.
  • the valid data buffered in the target data block 1 having the maximum number of erasures in the flash medium is migrated to the target data block 2, and the currently cached valid data in the target data block 2 is migrated to the target data block.
  • the modified mapping relationship is as shown in FIG. At this time, the most frequently accessed data block 0 and data block 3 in the hard disk are mapped to the target data block 2.
  • the valid data buffered in the target data block 2 with the maximum number of erasures in the flash medium is migrated to the target data block 0, and the currently cached valid data in the target data block 0 is migrated to the target data block. 2.
  • the modified mapping relationship returns to that shown in FIG. 6. At this time, the switching cycle ends, starting from Fig. 6, and the next switching cycle is continued in the switching sequence of Figs. 6-11.
  • the target data block that has the largest number of erasures is selected in the order of the number of the target data block.
  • the switching target may be selected according to the order of the number of the target data blocks, and the switching target is only the data in the current switching cycle.
  • the other target data blocks are exchanged with a minimum number of times and are different from the target data block that has just been switched by the target data block that currently has the largest number of erasures in the last switching cycle of the current switching cycle.
  • the replacement of the mapped target data block can be performed by updating the cache metadata stored in the flash medium and/or the memory.
  • the periodic dynamic mapping switching method between the underlying storage medium and the cache shown in the above is applicable to the application scenario in which the service presents periodicity, and is particularly applicable to the data in which the service presents periodic rules and the system accesses the most frequently. Store a fixed location on the scene.
  • the embodiment of the present invention further provides a scheme for controlling a cache mapping, the solution comprising: monitoring a number of erasures of each target data block in a cache of the underlying storage medium, wherein one or more data blocks in the underlying storage medium are only Mapping to a target data block in the cache, the cache of the underlying storage medium comprising a flash medium; between the target data block having the maximum number of erasures in the cache and the target data block having the minimum number of erasures When the difference between the erasing times reaches a preset erasing threshold, replacing the target data block in the cache to which the at least one data block in the underlying storage medium is mapped, and replacing the target data in the cache
  • the block includes a target data block having a maximum number of erasures in the current cache; and continuously monitoring the number of erasures generated after the replacement of each target data block in the cache.
  • Figure 12 is a flow chart showing a method of controlling cache mapping according to a second embodiment of the present invention.
  • the flash medium is used as a cache
  • the underlying storage medium is exemplarily a hard disk.
  • the cache has four target data blocks
  • the hard disk includes two groups, and each group is divided into four caches.
  • the target data block corresponds to 4 data blocks, and the size of each data block in the hard disk is consistent with the size of each target data block in the flash medium.
  • the method for controlling cache mapping in this embodiment includes:
  • step S1201 the number of erasures of each target data block in the cache is monitored and recorded.
  • step S1202 when the difference between the number of erasures between the target data block having the maximum number of erasures and the target data block having the minimum number of erasures reaches a preset erasing threshold, the maximum erasing will be performed.
  • the target data block of the number of times is exchanged with the data buffered between the target data blocks having the minimum number of erasures.
  • step S1203 according to the exchange made to the target data block, all the data blocks currently mapped to the target data block having the maximum number of erasure times in the underlying storage medium are correspondingly replaced and the target data currently mapped to the minimum number of erasures is mapped.
  • the target data block in the cache to which all data blocks of the block are mapped. Specifically, all the data blocks in the underlying storage medium that are currently mapped to the target data block having the maximum number of erasures are replaced with the target data block that is currently mapped to the minimum number of erasures, and the current storage medium is mapped to have the smallest All data blocks of the target data block of the number of erasures are replaced with the target data block mapped to the current maximum number of erasures. Specifically, the mapping relationship between the data block in the hard disk and the target data block in the cache may be changed by changing the cache metadata.
  • step S1204 after the above-mentioned change is made to the mapping between the hard disk and the cache, the number of times of erasing of the recorded target data blocks of the cache is cleared. Then, returning to step S1201, the monitoring and recording of the number of times of erasing of each target data block generated after the above-described mapping change is continued, and steps S1203-S1204 are performed when the condition is satisfied.
  • a counter can be utilized to record the number of erasures of each target data block. After each mapping change, the counter is cleared, then the count is overwritten, and the number of erases generated after the mapping change is recorded.
  • FIG. 1 and 13 to 14 show a specific example of controlling a cache map by using the method of the second embodiment of the present invention.
  • the mapping relationship shown in Figure 1 is used between the hard disk and the cache at the initial stage.
  • the mapping relationship between the hard disk and the cache is: Data block 0 and data block 4 of the hard disk are mapped to the cached target data block 0, and data block 1 and data block 5 of the hard disk are mapped to the cache.
  • the target data block 1, the data block 2 and the data block 6 of the hard disk are mapped to the cached target data block 2, and the data block 3 and the data block 7 of the hard disk are mapped to the cached target data block 3.
  • the target data block 1 has the minimum number of erasures.
  • the number of erasures of each target data block is monitored and recorded.
  • the target data block 0 having the maximum erasing frequency is cached with the target data block 1 having the minimum erasing frequency.
  • the data is exchanged, and correspondingly all data blocks currently mapped to the target data block 0 in the hard disk (in this case, data block 0 and data block 4) are replaced with the target data block 1, and the current mapping to the target All data blocks of data block 1 (in this example, data block 1 and data block 5) are replaced with a mapping to target data block 0.
  • the changed mapping relationship is as shown in FIG. Then clear the number of erasures of each target data block in the cache, and continue to monitor the number of targets in the cache. The number of erases generated after the block is changed in the mapping.
  • the data blocks (data block 3 and data block 7 in this example) are replaced with the mapping to the target data block 2.
  • the changed mapping relationship is shown in Figure 14.
  • the number of erasures of each target data block in the cache is cleared, and the number of erasures generated after the mapping change of each target data block in the cache is continuously monitored, and the target data block having the maximum number of erasures is minimized.
  • a preset erasing threshold S a similar replacement as shown above is made for the mapping between the hard disk and the cache.
  • the number of times of replacement may be used instead of the number of erasing, and the dynamic mapping switching may be performed by monitoring and recording the number of replacements of the target data block.
  • the cache the operation of swapping out data and rewriting other data is called a cache replacement.
  • the user can select to enable each dynamic mapping policy shown above according to the actual application scenario, and turn off the dynamic mapping policy when it is not needed.
  • the user can also set corresponding parameters, such as switching cycle, switching cycle, and/or erasing threshold, through the corresponding interface module according to actual needs.
  • the user can use the default mapping policy, such as direct mapping, fully associative mapping, group associative mapping, and so on.
  • mapping handover method using other handover sequences, as long as the handover method enables data in frequently accessed data blocks in the underlying storage medium to be not Always only corresponds to a fixed number of cache targets According to the block, it is possible to make a certain target data block as a cached flash medium not reach the use limit very quickly, thereby extending the life of the flash medium.
  • the lifetime of the flash media can be maximized when the switching method causes the number of erases and writes of each target data block in the cache to be close as desired.
  • FIG. 15 there is shown a cache system in accordance with an embodiment of the present invention.
  • the cache system 1500 of the embodiment of the present invention includes: an underlying storage medium 1510; a flash medium 1520 coupled to the underlying storage medium for use as a cache of the underlying storage medium, wherein the underlying storage medium One or more data blocks in the mapping are only mapped to one target data block in the cache; the processor 1530 is configured to: replace the at least one data block in the underlying storage medium to be mapped to the predetermined time period
  • the target data block in the cache, the target data block in the cache that is replaced includes a target data block having the largest number of erasures in the current cache.
  • the processor in the cache system may be further configured to: replace, in each of the switching cycles, the target data in the cache to which the at least one data block in the underlying storage medium is mapped a block, such that the number of erasures of each target data block in the cache is close after a switching cycle, wherein the number of switching cycles included in one switching cycle is not less than the target data block included in the cache Number N.
  • the processor in the cache system may be further configured to: replace, in each of the switching cycles, a target data in the cache to which each of the underlying storage media is mapped Blocking, causing each of the data blocks in the underlying storage medium to be mapped to different target data blocks in the cache in different switching cycles of one switching cycle; wherein, the number of switching cycles included in one switching cycle is equal to the cache The number of target data blocks included.
  • the processor in the cache system may be further configured to: rotate each of the caches in a round robin manner according to the number order of the target data blocks in the cache in each switching cycle of a switching cycle
  • the data of the target data block is respectively migrated to the target data block adjacent to the number, and the target data block to which each data block in the underlying storage medium is mapped is replaced according to the migration of the data in the target data block.
  • the processor in the cache system may be further configured to: cache data in the target data block that has the maximum number of erasures in the cache and the cache in each switching cycle of a switching cycle.
  • the data in the current switching cycle is exchanged a minimum number of times, and in the last switching cycle of the current switching cycle with the current
  • the target data block exchanged by the target data block of the maximum number of erasures is exchanged for data buffered in any one of the target data blocks, and the corresponding target data to which the data block in the underlying storage medium is mapped is replaced accordingly.
  • the one switching cycle includes N times (N-1) switching periods, and in the one switching cycle, the cached target data blocks are in different N-1 switching cycles.
  • the target data block with the maximum number of erasures in the cache is exchanged a minimum number of times, and in the last switching cycle of the current switching cycle with the current
  • the target data block exchanged by the target data block of the maximum number of erasures is exchanged for data buffered in any one of the target data blocks, and the corresponding target data to which the data block in the underlying storage medium is mapped is replaced accordingly.
  • the one switching cycle includes N times (N-1) switching periods, and in
  • the embodiment of the present invention further provides a cache system, the storage system comprising: an underlying storage medium; a flash medium coupled to the underlying storage medium for use as a cache of the underlying storage medium, wherein the underlying storage medium One or more data blocks are only mapped to one target data block in the cache; the processor is configured to: monitor the number of erasures of each target data block in the cache; when the cache has the largest erasure When the difference between the number of erasures between the target data block of the number of times and the target data block having the minimum number of erasures reaches a preset erasing threshold, the location to which at least one of the underlying storage media is mapped is replaced.
  • the processor in the cache system may be further configured to: exchange data cached between the target data block having the maximum number of erasures and the target data block having the minimum number of erasures, and correspondingly Replacing all data blocks currently mapped to the target data block having the maximum number of erasures in the underlying storage medium to be mapped to the target data block having the minimum number of erasures, and mapping the current mapping in the underlying storage medium All of the data blocks to the target data block having the minimum number of erasures are replaced with the target data block having the maximum number of erasures.
  • the functionality of the processor in device 1500 can be implemented in software, hardware, or a combination of hardware and software.
  • Embodiments of the present invention also provide a machine readable storage medium storing machine executable instructions that, when executed, cause a machine to perform at least one data block in an underlying storage medium to be mapped to a predetermined time period a target data block in a cache of the underlying storage medium, wherein one or more data blocks in the underlying storage medium are only mapped to one target data block in the cache, and the cache of the underlying storage medium includes a flash memory medium.
  • the target data block in the cache that is replaced includes a target data block having the largest number of erasures in the current cache.
  • the method may further include the steps of: replacing, in each of the switching cycles of the switching cycle, the target data block in the cache to which the at least one data block in the underlying storage medium is mapped, such that After the switching cycle, the number of erasing and erasing of each target data block in the buffer is similar, wherein the number of switching cycles included in one switching cycle is not less than the number N of target data blocks included in the buffer.
  • the method may further include the steps of: replacing, in each switching period of a switching cycle, a target data block in the cache to which each data block in the underlying storage medium is mapped, such that the bottom layer Each data block in the storage medium is mapped to a different target data block in the cache in different switching cycles of one switching cycle; wherein, the number of switching cycles included in one switching cycle is equal to the target data block included in the cache The number N.
  • the transmitting step described above may further include the steps of: rotating each target in the cache in a round robin manner according to the number order of the target data blocks in the cache during each switching cycle of a switching cycle
  • the data of the data block is respectively migrated into the target data block adjacent to the number, and the target data block to which each data block in the underlying storage medium is mapped is replaced according to the migration of the data in the target data block.
  • the detecting step described above may further include the following steps: in each of the switching cycles of the switching cycle, the data buffered in the target data block having the maximum number of erasing times in the cache is compared with the cache. In addition to the target data block having the maximum number of erasures, the data therein has been exchanged a minimum number of times in the current switching cycle, and with the current maximum in the last switching cycle of the current switching cycle And erasing the data buffered in the target data block of the target data block exchanged by the target data block of the number of times of erasing, and correspondingly replacing the target data block to which the data block in the corresponding underlying storage medium is mapped Wherein the one switching cycle includes N times (N-1) switching cycles, in one Each target data block in the cache in the switching cycle is a target data block having the maximum number of erasures in the cache in different N-1 switching cycles.
  • Embodiments of the present invention also provide a machine readable storage medium storing machine executable instructions, wherein when the machine executable instructions are executed, causing a machine to perform a number of erasures of each target data block in a cache of the underlying storage medium, Wherein the one or more data blocks in the underlying storage medium are only mapped to one target data block in the cache, the cache of the underlying storage medium includes a flash memory medium; and the target having the maximum number of erasures in the cache When the difference between the number of erasures between the data block and the target data block having the minimum number of erasures reaches a preset erasing threshold, replacing the cache to which the at least one data block in the underlying storage medium is mapped Target data block, the target data block in the cache that is replaced includes a target data block having the largest number of erasures in the current cache; and continuing to monitor each target data block in the cache after performing the replacement The number of erases generated.
  • the method may further include the steps of: exchanging data cached between the target data block having the maximum number of erasures and the target data block having the minimum number of erasures, and correspondingly in the underlying storage medium All data blocks currently mapped to the target data block having the maximum number of erasures are replaced with a target data block mapped to the minimum number of erasures, and the underlying storage medium is currently mapped to the minimum wipe All data blocks of the target data block of the write count are replaced with the target data block mapped to the maximum number of erase times.

Abstract

本发明涉及控制缓存映射的方法及缓存系统,其中,该方法包括:以预定的时间周期更换底层存储介质中至少一个数据块所映射到底层存储介质的缓存中的目标数据块,其中,底层存储介质中一个或多个数据块只映射到缓存中的一个目标数据块,底层存储介质的缓存包括闪存介质,所更换的缓存中的目标数据块包括当前缓存中具有最大擦写次数的目标数据块。利用该技术方案可以优化闪存介质的使用寿命。

Description

控制缓存映射的方法及缓存系统 技术领域
本发明涉及缓存系统的缓存映射技术, 特别涉及一种闪存介质作为缓 存时控制缓存映射的方法及一种缓存系统。 背景技术
闪存(Flash Memory)介质是一种长寿命的非易失性存储器, 其在断电 情况下仍能保持所存储的数据信息。 现有技术中常利用闪存介质作为底层 存储介质如硬盘、 硬盘阵列等传统磁盘存储系统的缓存, 以缓解受底层存 储介质输入输出性能不佳所带来的性能约束。
通常, 利用闪存介质作为缓存时, 在缓存和底层存储介质之间采用的 映射策略是组相联映射。 在组相联映射中, 按照作为映射目标的缓存的大 小, 将作为映射源的底层存储介质划分成多个组, 其中每个组的容量大小 等于缓存的大小。 根据缓存所包含的目标数据块的数目及大小, 将底层存 储介质的每个组划分成相同数目的区域 (即数据块) , 每个区域的大小与 缓存中的一个目标数据块的大小一致。 在底层存储介质的一个组中, 不同 的数据块与缓存中的不同的目标数据块相对应。 在底层存储介质的不同组 中, 对应位置的数据块映射到缓存中相同的目标数据块。
图 1示出了组相联映射的一个示例。 该例中, 作为缓存的闪存介质划分 成从目标数据块 0到目标数据块 3的 4个目标数据块, 作为映射源的硬盘包括 两个组, 每个组划分成与缓存的 4个目标数据块相对应的数据块, 并且硬盘 中的每一个数据块的大小与闪存介质中的每一个目标数据块的大小一致。 该例中, 硬盘与缓存的组相联映射关系为: 硬盘的第一组 (包括数据块 0- 数据块 3 )中的数据块 0与第二组(包括数据块 4-数据块 7 )中的数据块 4映射 到闪存介质中的目标数据块 0, 硬盘的第一组中的数据块 1与第二组中的数 据块 5映射到闪存介质中的目标数据块 1, 硬盘的第一组中的数据块 2与第二 组中的数据块 6映射到闪存介质中的目标数据块 2, 硬盘的第一组中的数据 块 3与第二组中的数据块 7映射到闪存介质中的目标数据块 3。 按照该映射 关系, 数据块 0和数据块 4中的数据缓存到目标数据块 0中, 数据块 1和数据 块 5中的数据缓存到目标数据块 1中, 数据块 2与数据块 6中的数据缓存到目 标数据块 2中, 数据块 3与数据块 7中的数据缓存到目标数据块 3中。
但是, 在现有技术中, 缓存与底层存储介质之间的映射关系通常是静 态的。 在系统工作的整个过程中, 底层存储介质中的数据块所映射到的缓 存中的目标数据块通常是不变的。 这样, 当闪存介质作为缓存时, 对于系 统中局部区域数据访问异常频繁的应用场景, 系统中频繁访问的数据所映 射到的闪存介质的介质区域的擦写次数将过于频繁。 由于闪存介质的擦写 次数是有限的, 这样将导致频繁访问的数据所映射到的闪存介质的介质区 域将比其它的区域更快地达到擦写次数的极限, 进而导致整个闪存介质不 可用。 发明内容
考虑到现有技术的上述缺陷, 本发明的实施例提出一种控制缓存映射 的方法及一种缓存系统, 在缓存与底层存储介质之间采取动态映射策略以 使得系统中频繁访问的数据并不是静态地映射到缓存上的某一目标数据 块, 从而可以优化作为缓存的闪存介质的寿命。
本发明实施例提供一种控制缓存映射的方法, 其中, 以预定的时间周 期更换底层存储介质中至少一个数据块所映射到所述底层存储介质的缓存 中的目标数据块, 其中, 所述底层存储介质中一个或多个数据块只映射到 所述缓存中的一个目标数据块, 所述底层存储介质的缓存包括闪存介质, 所更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数 的目标数据块
本发明实施例提供一种控制缓存映射的方法, 其中, 所述方法包括: 监控底层存储介质的缓存中各目标数据块的擦写次数, 其中, 所述底 层存储介质中一个或多个数据块只映射到所述缓存中的一个目标数据块, 所述底层存储介质的缓存包括闪存介质;
当所述缓存中具有最大擦写次数的目标数据块与具有最小擦写次数的 目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 更换所述底 层存储介质中的至少一个数据块所映射到的所述缓存中的目标数据块, 所 更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的 目标数据块; 以及
继续监控所述缓存中的各目标数据块在进行所述更换后所产生的擦写 次数。
本发明实施例提供一种缓存系统, 包括: 底层存储介质; 闪存介质, 耦合至所述底层存储介质, 用于作为所述底层存储介质的缓存, 其中所述 底层存储介质中的一个或多个数据块只映射到所述缓存中的一个目标数据 块; 处理器, 被配置成: 以预定的时间周期更换底层存储介质中至少一个 数据块所映射到所述底层存储介质的缓存中的目标数据块, 所更换的所述 缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的目标数据 块。
本发明实施例提供一种缓存系统, 包括: 底层存储介质; 闪存介质, 耦合至所述底层存储介质, 用于作为所述底层存储介质的缓存, 其中所述 底层存储介质中的一个或多个数据块只映射到所述缓存中的一个目标数据 块; 处理器, 被配置成: 监控所述缓存中各目标数据块的擦写次数; 当所 述缓存中具有最大擦写次数的目标数据块与具有最小擦写次数的目标数据 块之间的擦写次数之差达到预先设定的擦写阈值时, 更换所述底层存储介 质中的至少一个数据块所映射到的所述缓存中的目标数据块, 所更换的所 述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的目标数据 块; 以及
继续监控所述缓存中的各目标数据块在进行所述更换后所产生的擦写 次数。
本发明实施例的方法和装置, 通过更换底层存储介质中包括与当前具 有最大擦写次数的目标数据块所对应的数据块在内的至少一个数据块所映 射到的缓存中的目标数据块, 实现了对充当缓存的闪存介质的使用寿命的 优化。 附图说明
本发明的目的、 特点、 特征和优点通过以下结合附图的详细描述将变 得显而易见。 其中:
图 1示出了组相联映射的一个示例; 图 2示出了根据本发明实施例一的控制缓存映射的方法的流程示意图; 图 3-图 5示出了在利用本发明实施例一的方法控制缓存映射的一个实例 中, 不同切换周期中的映射关系示意图;
图 6-图 11示出了在利用本发明实施例一的方法控制缓存映射的另一个 实例中, 不同切换周期中的映射关系示意图;
图 12示出了根据本发明实施例二的控制缓存映射的方法的流程示意 图; 以及
图 13-图 14示出了在利用本发明实施例二的方法控制缓存映射的一个实 例中的映射关系示意图;
图 15示出了按照本发明实施例的缓存系统。 具体实施方式 本发明的实施例提供一种控制缓存映射的方法及一种缓存系统, 其中, 所述方法包括: 以预定的时间周期更换底层存储介质中至少一个数据块所 映射到所述底层存储介质的缓存中的目标数据块, 其中, 所述底层存储介 质中一个或多个数据块只映射到所述缓存中的一个目标数据块, 所述底层 存储介质的缓存包括闪存介质, 所更换的所述缓存中的目标数据块包括当 前所述缓存中具有最大擦写次数的目标数据块。
下面将结合附图详细描述本发明的各个实施例。 图 2示出了根据本发明实施例一的控制缓存映射的方法的流程示意图。 本实施例中, 闪存介质作为缓存, 底层存储介质示例性地为硬盘, 底层存 储介质中的一个或多个数据块只映射到所述缓存中的一个目标数据块。 其 中, 闪存介质包括固态磁盘即 SSD (solid state disk) 磁盘。
如图 2所示出的, 该实施例一的控制缓存映射的方法包括如下步骤: 在步骤 S201 , 根据预先设置的切换周期 T, 触发计时器开始计时。
在步骤 S202, 在一个切换循环的每一个切换周期内, 更换硬盘中的至 少一个数据块所映射到的缓存中的目标数据块, 以使得在一个切换循环后, 缓存中的各目标数据块的擦写次数相接近, 其中, 一个切换循环所包括的 切换周期的数目不小于缓存所包含的目标数据块的数目 N。 图 1、图 3-图 5示出了利用本发明实施例一的方法控制缓存映射的一个具 体实例。 该实例中在一个切换循环的每一个切换周期内, 更换硬盘中的每 一个数据块所映射到的缓存中的目标数据块, 使得硬盘中的每一个数据块 在一个切换循环的不同切换周期内映射到缓存中的不同目标数据块, 其中, 一个切换循环包括的切换周期的数目等于缓存所包含的目标数据块的数目 N。 在该实例中, 示例性但不作为限制地, 缓存具有 4个目标数据块, 硬盘 包括两个组, 每个组划分成与缓存的 4个目标数据块相对应的 4个数据块, 并且硬盘中的每一个数据块的大小与闪存介质中的每一个目标数据块的大 小一致。
如图 1、 图 3-图 5所示出的, 本实例采用周期性轮转动态切换策略, 一个 切换循环中包含的切换周期的数目等于缓存中所包含的目标数据块的数目 N, N为大于 0的整数。 该例中 N=4。 在本实例中, 每经过一个切换周期, 切 换硬盘中的每一个数据块所对应的映射目标。 硬盘中的各数据块在不同的 切换周期内所映射到的目标数据块不同。
具体地, 该实例在初始时采用图 1所示出的映射关系。 如图 1所示出的, 在该例中, 在初始时, 硬盘与缓存之间的映射关系为: 硬盘的数据块 0和数 据块 4映射到缓存的目标数据块 0, 硬盘的数据块 1和数据块 5映射到缓存的 目标数据块 1, 硬盘的数据块 2和数据块 6映射到缓存的目标数据块 2, 硬盘 的数据块 3和数据块 7映射到缓存的目标数据块 3。 上述数字为对数据块或目 标数据块的编号。
在第一切换周期 (简称第一周期) 到达时, 分别将闪存介质中各目标 数据块中所缓存的数据迁移至其它的目标数据块中。 该例中, 示例性地, 将闪存介质中目标数据块 0中当前缓存的有效数据迁移至目标数据块 1, 将 目标数据块 1中当前缓存的有效数据迁移至目标数据块 2, 将目标数据块 2中 当前缓存的有效数据迁移至目标数据块 3, 将目标数据块 3中当前缓存的有 效数据迁移至目标数据块 0。 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移, 相应地更换硬盘中每一个数据块所映射到的目标数据块。 经过 该次迁移后, 修改得到的映射关系如图 3所示出的。 在第二周期到达时, 同样将闪存介质中目标数据块 0中当前缓存的有效 数据迁移至目标数据块 1, 将目标数据块 1中当前缓存的有效数据迁移至目 标数据块 2, 将目标数据块 2中当前缓存的有效数据迁移至目标数据块 3, 将 目标数据块 3中当前缓存的有效数据迁移至目标数据块 0。 经过该次迁移后, 根据该次迁移修改缓存与硬盘的映射关系, 修改后的映射关系如图 4所示出 的。
在第三周期到达时, 同样将闪存介质中目标数据块 0中当前缓存的有效 数据迁移至目标数据块 1, 将目标数据块 1中当前缓存的有效数据迁移至目 标数据块 2, 将目标数据块 2中当前缓存的有效数据迁移至目标数据块 3, 将 目标数据块 3中当前缓存的有效数据迁移至目标数据块 0。 经过该次迁移后, 根据该次迁移修改缓存与硬盘的映射关系, 修改后的映射关系, 修改得到 的映射关系如图 5所示出的。 在第四周期到达时, 同样进行上述的迁移后, 相应地修改映射关系, 修改得到的映射关系如图 1所示出的, 即回到了在第 一周期期间的映射关系。 这样一个切换循环结束。 然后, 可以继续下一个 切换循环的切换过程。
在本实施例中, 在进行目标数据块中缓存数据的迁移后, 可以通过更 新存储在闪存介质和 /或内存中的缓存元数据来进行所映射的目标数据块的 更换。
在硬盘中局部区域如某一数据块访问频繁的场景下, 在一个切换循环 的各切换周期中, 硬盘中访问频繁的数据块分别映射到闪存介质中不同的 目标数据块, 从而使得硬盘中访问频繁的局域不会静态地一直只映射到某 一固定的目标数据块, 从而可以延长及优化闪存介质的寿命。 并且, 在经 过一个如上文所述的轮转切换循环后, 闪存介质中的各目标数据块的擦除 次数接近, 并且接近于平均值, 各目标数据块的擦除次数分布比较均匀, 从而可以使得闪存介质的寿命最优化。
本实施例中, 在进行映射关系的动态切换时, 按照缓存中目标数据块 的编号顺序, 以轮转的方式将所述缓存中每一目标数据块的数据分别迁移 至编号与其相邻的目标数据块中。 上述例子只是示例性地, 其它的轮转方 式也适用。 举例说明, 在到达切换周期时, 可以按照: 目标数据块 0中当前 缓存的数据迁移至目标数据块 3, 目标数据块 3中当前缓存的数据迁移至目 标数据块 2, 目标数据块 2中当前缓存的数据迁移至目标数据块 1, 目标数据 块 1中当前缓存的数据迁移至目标数据块 0的顺序来实现在切换周期到达 时, 对缓存中各目标数据块中缓存的数据的迁移, 然后相应地更换底层存 储介质如硬盘中的每一个数据块所映射到的目标数据块, 硬盘和缓存之间 的映射关系相应更换。
当然, 除了上文所述的轮转方式外, 其它的更换所述底层存储介质中 的至少一个数据块所映射到的所述缓存中的目标数据块的方式也适用, 只 要能使得在一个切换循环后, 所述缓存中的各目标数据块的擦写次数相接 近就可以了。 所述的接近可以是各目标数据块的擦写次数均接近平均值, 具体地, 可以是各目标数据块的擦写次数的差异小于预定的擦写次数差异 阈值。 该差异阈值可以根据需要或具体的应用场景来设置。
采用周期性轮转动态切换策略时, 用户可根据应用场景灵活设置切换 周期, 其切换循环较短, 但是, 每次切换映射目标时, 缓存中的所有有效 数据都会迁移, 因而周期性轮转动态切换策略更适用于小容量的缓存。 图 6-图 11示出了利用根据本发明实施例一的方法控制缓存映射的另一 实例。 在该例中, 采样周期性排列动态切换映射的策略来更换硬盘中的每 一个数据块所映射到的缓存中的目标数据块, 以使得在一个切换循环后, 缓存中的各目标数据块的擦写次数相接近。 在该例中, 一个切换循环中包 含的切换周期的数目等于 N乘以 (N-1 ) , 其中 N为缓存中所包含的目标数 据块的数目, N为大于 0的整数。 示例性地, 该例中 N=3, 所以该例中一个 切换循环包括 6个切换周期。
该例中, 闪存介质作为缓存, 底层存储介质示例性地为硬盘, 示例性 但不作为限制地, 缓存具有 3个目标数据块, 硬盘包括两个组, 每个组划分 成与缓存的 3个目标数据块相对应的 3个数据块, 并且硬盘中的每一个数据 块的大小与闪存介质中的每一个目标数据块的大小一致。
在该例中, 在一个切换循环的每一个切换周期内, 将缓存中当前具有 最大擦写次数的目标数据块中缓存的数据与所述缓存中除该具有最大擦写 次数之外的其它目标数据块中、 在当前的切换循环中其内数据进行过最少 次数的交换、 并且与在当前的切换循环中上一个切换周期中与该当前具有 最大擦写次数的目标数据块进行交换的目标数据块不同的任一个目标数据 块中缓存的数据相交换, 即数据相互迁移, 并且根据目标数据块中缓存数 据的迁移, 相应地更换所对应的硬盘中的数据块所映射到的目标数据块。 其中, 缓存中各目标数据块都有 N-1次机会成为具有最大擦写次数的目标数 据块, 也就是说在一个切换循环中各目标数据块在不同的 N-1个周期内为最 大擦写次数的目标数据块即与访问最频繁的数据块相对应。
示例性地, 假定在该切换循环开始时, 闪存介质中的目标数据块 0具有 最大的擦写次数, 这表明硬盘中当前映射到目标数据块 0的数据块 0和数据 块 3的访问最频繁。 除了目标数据块 0的目标数据块是目标数据块 1和目标数 据块 2。 如图 6所示出的, 该例中, 在第一周期到达之前硬盘与缓存之间的 映射关系为: 硬盘的数据块 0和数据块 3映射到缓存的目标数据块 0, 硬盘的 数据块 1和数据块 4映射到缓存的目标数据块 1, 硬盘的数据块 2和数据块 5映 射到缓存的目标数据块 2。
该例中, 示例性地, 在第一周期到达时, 将闪存介质中目标数据块 0中 缓存的有效数据迁移至目标数据块 1, 将目标数据块 1中当前缓存的有效数 据迁移至目标数据块 0。 在缓存中的数据迁移后, 根据目标数据块中数据的 迁移, 相应地更换硬盘中数据块 0和数据块 3所映射到的缓存中的目标数据 块以及数据块 1和数据块 4所映射到的缓存中的目标数据块。 经过该次迁移 后, 修改得到的映射关系如图 7所示出的, 此时访问最频繁的数据块 0和数 据块 3映射到目标数据块 1。
在第二周期到达时, 将闪存介质中当前具有最大擦写次数的目标数据 块 1中缓存的有效数据迁移至目标数据块 2, 将目标数据块 2中当前缓存的有 效数据迁移至目标数据块 1, 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移, 相应地更换硬盘中数据块 0和数据块 3以及数据块 2和数据块 5所 映射到的缓存中的目标数据块。 经过该次迁移后, 修改得到的映射关系如 图 8所示出的。 此时, 硬盘中访问最频繁的数据块 0和数据块 3映射到了目标 数据块 2。
在第三周期到达时, 将闪存介质中当前具有最大擦写次数的目标数据 块 2中缓存的有效数据迁移至目标数据块 0, 将目标数据块 0中当前缓存的有 效数据迁移至目标数据块 2, 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移。 经过该次迁移后, 修改得到的映射关系如图 9所示出的。 此时, 硬盘中访问最频繁的数据块 0和数据块 3映射到了目标数据块 0。 在第四周期到达时, 将闪存介质中当前具有最大擦写次数的目标数据 块 0中缓存的有效数据迁移至目标数据块 1, 将目标数据块 1中当前缓存的有 效数据迁移至目标数据块 0, 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移。 经过该次迁移后, 修改得到的映射关系如图 10所示出的。 此时, 硬盘中访问最频繁的数据块 0和数据块 3映射到了目标数据块 1。
在第五周期到达时, 将闪存介质中当前具有最大擦写次数的目标数据 块 1中缓存的有效数据迁移至目标数据块 2, 将目标数据块 2中当前缓存的有 效数据迁移至目标数据块 1, 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移。 经过该次迁移后, 修改得到的映射关系如图 11所示出的。 此时, 硬盘中访问最频繁的数据块 0和数据块 3映射到了目标数据块 2。
在第六周期到达时, 将闪存介质中当前具有最大擦写次数的目标数据 块 2中缓存的有效数据迁移至目标数据块 0, 将目标数据块 0中当前缓存的有 效数据迁移至目标数据块 2, 在缓存中的数据迁移后, 根据目标数据块中数 据的迁移。 经过该次迁移后, 修改得到的映射关系回到如图 6所示出的。 此 时, 一次切换循环结束, 从图 6开始, 按照图 6-图 11的切换顺序继续进行下 一个切换循环。
该例中, 在到达每一个周期时, 当前具有最大擦写次数的目标数据块 即当前访问最频繁的数据块所映射到的目标数据块是按照目标数据块的编 号的顺序来选择切换目标的。 在其它实施例中, 当目标数据块的数目超过 3 个时可以按照也可以不按照目标数据块的编号的顺序来选择切换目标, 只 需该切换目标是在当前的切换循环中其内数据与其它目标数据块进行过最 少次数的交换、 并且与在当前切换循环的上一次切换周期中当前具有最大 擦写次数的目标数据块刚进行切换的目标数据块不同的任一个目标数据 块。
在本实施例中, 在进行目标数据块中缓存数据的迁移后, 可以通过更 新存储在闪存介质和 /或内存中的缓存元数据来进行所映射的目标数据块的 更换。
在硬盘中局部区域如某一数据块访问频繁的场景下, 在一个切换循环 的各切换周期中, 硬盘中访问频繁的数据块分别映射到闪存介质中不同的 目标数据块, 从而使得硬盘中访问频繁的局域不会一直只映射到某一固定 的目标数据块, 从而可以延长及优化闪存介质的寿命。 并且, 在经过一个 如上文所述的周期性排列切换循环后, 闪存介质中的各目标数据块的擦除 次数接近, 并且接近于平均值, 各目标数据块的擦除次数分布比较均匀, 从而可以使得闪存介质的寿命最优化。 并且, 采用本实施例的周期性排列 动态切换映射策略, 每次切换映射目标时, 仅仅迁移缓存中的两个目标数 据块中的有效数据, 不会对性能产生严重的影响, 可以适用于各种尺寸的 缓存。
上文所示出的底层存储介质与缓存之间的各周期性动态映射切换方 法, 适用于业务呈现周期性规律的应用场景, 尤其适用于业务呈现周期性 规律且系统访问最为频繁的数据在硬盘上存储位置固定的场景。 本发明的实施例还提供一种控制缓存映射的方案, 该方案包括: 监控 底层存储介质的缓存中各目标数据块的擦写次数, 其中, 所述底层存储介 质中一个或多个数据块只映射到所述缓存中的一个目标数据块, 所述底层 存储介质的缓存包括闪存介质; 当所述缓存中具有最大擦写次数的目标数 据块与具有最小擦写次数的目标数据块之间的擦写次数之差达到预先设定 的擦写阈值时, 更换所述底层存储介质中的至少一个数据块所映射到的所 述缓存中的目标数据块, 所更换的所述缓存中的目标数据块包括当前所述 缓存中具有最大擦写次数的目标数据块; 以及继续监控所述缓存中的各目 标数据块在进行所述更换后所产生的擦写次数。 图 12示出了根据本发明实施例二的控制缓存映射的方法的流程示意 图。 本实施例中, 闪存介质作为缓存, 底层存储介质示例性地为硬盘, 示 例性但不作为限制地, 缓存具有 4个目标数据块, 硬盘包括两个组, 每个组 划分成与缓存的 4个目标数据块相对应的 4个数据块, 并且硬盘中的每一个 数据块的大小与闪存介质中的每一个目标数据块的大小一致。
如图 12所示出的, 本实施例的控制缓存映射的方法包括:
在步骤 S1201中, 监控缓存中各目标数据块的擦写次数, 并记录。 在步骤 S1202中, 当缓存中具有最大擦写次数的目标数据块与具有最小 擦写次数的目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 将具有最大擦写次数的目标数据块与具有最小擦写次数的目标数据块之间 缓存的数据进行交换。 在步骤 S1203中, 根据对目标数据块所做的交换, 相应地更换底层存储 介质中当前映射至具有最大擦写次数的目标数据块的所有数据块和当前映 射至具有最小擦写次数的目标数据块的所有数据块所映射到的缓存中的目 标数据块。 具体地, 即将底层存储介质中当前映射至具有最大擦写次数的 目标数据块的所有数据块更换为映射至当前具有最小擦写次数的目标数据 块, 而将底层存储介质中当前映射至具有最小擦写次数的目标数据块的所 有数据块更换为映射至当前具有最大擦写次数的目标数据块。 具体地, 可 以通过更改缓存元数据来改变硬盘中的数据块和缓存中的目标数据块的映 射关系。
在步骤 S1204中, 在对硬盘与缓存之间的映射进行上述改变后, 将所记 录的所述缓存的各目标数据块的擦写次数清零。 然后回到步骤 S1201 , 继续 监控并记录在经过上述映射改变之后所产生的各目标数据块的擦写次数, 并在满足条件时执行步骤 S1203-S1204。 示例性地, 可以利用计数器来记录 各目标数据块的擦写次数。 在每次映射改变后, 将计数器清零, 然后重写 计数, 记录映射改变后的产生的擦写次数。
图 1、图 13-图 14示出了利用本发明实施例二的方法来控制缓存映射的 一个具体实例。 在该例中, 假定在初始时硬盘与缓存之间采用图 1 所示的 映射关系。 如图 1 所示出的, 在初始时, 硬盘与缓存的映射关系为: 硬盘 的数据块 0和数据块 4映射到缓存的目标数据块 0,硬盘的数据块 1和数据 块 5映射到缓存的目标数据块 1,硬盘的数据块 2和数据块 6映射到缓存的 目标数据块 2, 硬盘的数据块 3和数据块 7映射到缓存的目标数据块 3。 监 控缓存中各目标数据块的擦写次数。
假定当前目标数据块 0具有最大的擦写次数, 目标数据块 1具有最小 的擦写次数。 随着数据缓存的进行, 监控并记录各目标数据块的擦写次数。 当确定出目标数据块 0与目标数据块 1的擦写次数之差达到擦写阈值 S时, 将具有最大擦写次数的目标数据块 0与具有最小擦写次数的目标数据块 1 之间缓存的数据进行交换, 并相应地将硬盘中当前映射至目标数据块 0 的 所有数据块 (该例中为数据块 0和数据块 4) 更换为映射至目标数据块 1, 而将当前映射至目标数据块 1的所有数据块 (该例中为数据块 1和数据块 5 ) 更换为映射至目标数据块 0。 改变后的映射关系如图 13中所示出的。 然后 将缓存中的各目标数据块的擦写次数清零, 并继续监控缓存中的各目标数 据块在进行映射改变后所产生的擦写次数。
在该例中在进行上次交换后, 随着数据缓存的进行, 假定目标数据块 3 的擦写次数变成最小, 目标数据块 2的擦写次数变成最大, 当目标数据块 2 的擦写次数与目标数据块 3的擦写次数之差达到擦写阈值 S时, 将具有最 大擦写次数的目标数据块 2与具有最小擦写次数的目标数据块 3之间缓存 的数据进行交换, 并相应地将硬盘中当前映射至目标数据块 2 的所有数据 块 (该例中为数据块 2和数据块 6 ) 更换为映射至目标数据块 3, 而将当前 映射至目标数据块 3的所有数据块(该例中为数据块 3和数据块 7 )更换为 映射至目标数据块 2。 改变后的映射关系如图 14所示。 然后, 将缓存中的 各目标数据块的擦写次数清零, 并继续监控缓存中各目标数据块在映射改 变后产生的擦写次数, 并在具有最大擦写次数的目标数据块与具有最小擦 写次数的目标数据块之间的擦写次数之差达到预先设定的擦写阈值 S 时, 对硬盘与缓存之间的映射作出上文所示出的类似的更换。
利用本实施例可以保证闪存介质中的目标数据块及擦除块的最大擦写 次数和最小擦写次数的差距可控, 使得各个目标数据块的擦写次数接近平 均值。 并且通过设置擦写阈值 S可以控制闪存介质中目标数据块擦写次数 的方差。 本实施例尤其适用于业务不呈现周期性现象或周期性现象不明显 的应用场景。
在本发明实施例的实现中, 可以利用替换次数来代替擦写次数, 通过 监控并记录目标数据块的替换次数来进行动态映射切换。 如本领域技术人 员所理解的, 在缓存中, 把数据换出并重新写入其它数据的操作叫做缓存 的替换。
在具体应用中, 用户可以根据实际的应用场景, 选择启用上文所示出 的各动态映射策略, 并在不需要的时候关闭动态映射策略。 进而, 在选择 动态映射策略后, 用户还可根据实际的需要通过相应的接口模块设置相应 的参数, 如切换周期、 切换循环和 /或擦写阈值等。 在未选择动态切换策略 时, 用户可以使用默认的映射策略, 如可以是直接映射、 全相联映射、 组 相联映射等。
本领域技术人员应当理解, 除了上文所示出的切换方法外, 还可以有 利用其它的切换顺序的映射切换方法, 只要该切换方法能使得底层存储介 质中访问频繁的数据块中的数据不是一直只对应某一个固定的缓存目标数 据块, 就可以使得作为缓存的闪存介质的某一目标数据块不是很快地达到 使用极限, 从而可以延长闪存介质的寿命。
本领域技术人员应当理解, 当切换方法使得缓存中的各目标数据块的 擦写次数相接近如趋于平均时, 可以最大化闪存介质的寿命。
现在参考图 15, 其示出了按照本发明实施例的缓存系统。
如图 15所示,本发明实施例的缓存系统 1500包括:底层存储介质 1510; 闪存介质 1520, 耦合至所述底层存储介质, 用于作为所述底层存储介质的 缓存, 其中所述底层存储介质中的一个或多个数据块只映射到所述缓存中 的一个目标数据块; 处理器 1530, 被配置成: 以预定的时间周期更换所述 底层存储介质中的至少一个数据块所映射到的所述缓存中的目标数据块, 所更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数 的目标数据块。 其中, 缓存系统中所述处理器还可以进一步被配置成: 在一个切换循 环的每一个切换周期内, 更换所述底层存储介质中的至少一个数据块所映 射到的所述缓存中的目标数据块, 以使得在一个切换循环后, 所述缓存中 的各目标数据块的擦写次数相接近, 其中, 一个切换循环所包括的切换周 期的数目不小于所述缓存所包含的目标数据块的数目 N。 其中, 缓存系统中所述处理器还可以进一步被配置成: 在一个切换循 环的每一个切换周期内, 更换所述底层存储介质中的每一个数据块所映射 到的所述缓存中的目标数据块, 使得所述底层存储介质中的每一个数据块 在一个切换循环的不同切换周期内映射到所述缓存中的不同目标数据块; 其中, 一个切换循环包括的切换周期的数目等于所述缓存所包含的目标数 据块的数目。 其中, 缓存系统中所述处理器还可以进一步被配置成: 在一个切换循 环的每一个切换周期内, 按照所述缓存中目标数据块的编号顺序, 以轮转 的方式将所述缓存中每一目标数据块的数据分别迁移至编号与其相邻的目 标数据块中, 并根据目标数据块中数据的迁移, 相应地更换所述底层存储 介质中每一个数据块所映射到的目标数据块。 其中, 缓存系统中所述处理器还可以进一步被配置成: 在一个切换循 环的每一个切换周期内, 将所述缓存中当前具有最大擦写次数的目标数据 块中缓存的数据与所述缓存中除该具有最大擦写次数之外的其它目标数据 块中、 在当前的切换循环中其内数据进行过最少次数的交换、 并且与在当 前的切换循环的上一个切换周期中与该当前具有最大擦写次数的目标数据 块进行交换的目标数据块不同的任一个目标数据块中缓存的数据相交换, 并且相应地更换所对应的所述底层存储介质中的数据块所映射到的目标数 据块; 其中, 所述一个切换循环包含 N乘以 (N-1 )个切换周期, 在所述一 个切换循环中, 所述缓存的各目标数据块在不同的 N-1个切换周期内为所 述缓存中具有最大擦写次数的目标数据块。 本发明实施例还提供了一种缓存系统, 该存储系统包括: 底层存储介 质; 闪存介质, 耦合至所述底层存储介质, 用于作为所述底层存储介质的 缓存, 其中所述底层存储介质中的一个或多个数据块只映射到所述缓存中 的一个目标数据块; 处理器, 被配置成: 监控所述缓存中各目标数据块的 擦写次数; 当所述缓存中具有最大擦写次数的目标数据块与具有最小擦写 次数的目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 更换 所述底层存储介质中的至少一个数据块所映射到的所述缓存中的目标数据 块, 所更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写 次数的目标数据块; 以及继续监控所述缓存中的各目标数据块在进行所述 更换后所产生的擦写次数。 其中, 缓存系统中所述处理器还可以进一步被配置成: 将所述具有最 大擦写次数的目标数据块与具有最小擦写次数的目标数据块之间缓存的数 据进行交换, 并相应地将所述底层存储介质中当前映射至所述具有最大擦 写次数的目标数据块的所有数据块更换为映射至所述具有最小擦写次数的 目标数据块, 而将所述底层存储介质中当前映射至所述具有最小擦写次数 的目标数据块的所有数据块更换为映射至所述具有最大擦写次数的目标数 据块。 本领域技术人员应当理解, 可以利用软件、 硬件或者软硬件结合的方 式来实现装置 1500中处理器的功能。
本发明实施例还提供机器可读存储介质, 其存储有机器可执行指令, 当该机器可执行指令被执行时使得机器实施以预定的时间周期更换底层存 储介质中至少一个数据块所映射到所述底层存储介质的缓存中的目标数据 块, 其中, 所述底层存储介质中一个或多个数据块只映射到所述缓存中的 一个目标数据块, 所述底层存储介质的缓存包括闪存介质, 所更换的所述 缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的目标数据块。
其中, 该方法还可以包括以下步骤: 在一个切换循环的每一个切换周 期内, 更换所述底层存储介质中的至少一个数据块所映射到的所述缓存中 的目标数据块, 以使得在一个切换循环后, 所述缓存中的各目标数据块的 擦写次数相接近, 其中, 一个切换循环所包括的切换周期的数目不小于所 述缓存所包含的目标数据块的数目 N。
其中, 该方法还可以包括以下步骤: 在一个切换循环的每一个切换周 期内, 更换所述底层存储介质中的每一个数据块所映射到的所述缓存中的 目标数据块, 使得所述底层存储介质中的每一个数据块在一个切换循环的 不同切换周期内映射到所述缓存中的不同目标数据块; 其中, 一个切换循 环包括的切换周期的数目等于所述缓存所包含的目标数据块的数目 N。
其中, 上面所描述的发送步骤还可以进一步包括以下步骤: 在一个切 换循环的每一个切换周期内, 按照所述缓存中目标数据块的编号顺序, 以 轮转的方式将所述缓存中每一目标数据块的数据分别迁移至编号与其相邻 的目标数据块中, 并根据目标数据块中数据的迁移, 相应地更换所述底层 存储介质中每一个数据块所映射到的目标数据块。
其中, 上面所描述的检测步骤还可以进一步包括以下步骤: 在一个切 换循环的每一个切换周期内, 将所述缓存中当前具有最大擦写次数的目标 数据块中缓存的数据与所述缓存中除该具有最大擦写次数之外的其它目标 数据块中、 在当前的切换循环中其内数据进行过最少次数的交换、 并且与 在当前的切换循环的上一个切换周期中与该当前具有最大擦写次数的目标 数据块进行交换的目标数据块不同的任一个目标数据块中缓存的数据相交 换, 并且相应地更换所对应的所述底层存储介质中的数据块所映射到的目 标数据块; 其中, 所述一个切换循环包含 N乘以 (N-1 )个切换周期, 在一 个切换循环中所述缓存中的各目标数据块在不同的 N-1个切换周期内为所 述缓存中具有最大擦写次数的目标数据块。
本发明实施例还提供机器可读存储介质, 其存储有机器可执行指令, 其中, 当该机器可执行指令被执行时使得机器实施监控底层存储介质的缓 存中各目标数据块的擦写次数, 其中, 所述底层存储介质中一个或多个数 据块只映射到所述缓存中的一个目标数据块, 所述底层存储介质的缓存包 括闪存介质; 当所述缓存中具有最大擦写次数的目标数据块与具有最小擦 写次数的目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 更 换所述底层存储介质中的至少一个数据块所映射到的所述缓存中的目标数 据块, 所更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦 写次数的目标数据块; 以及继续监控所述缓存中的各目标数据块在进行所 述更换后所产生的擦写次数。
其中, 该方法还可以包括以下步骤: 将所述具有最大擦写次数的目标 数据块与具有最小擦写次数的目标数据块之间缓存的数据进行交换, 并相 应地将所述底层存储介质中当前映射至所述具有最大擦写次数的目标数据 块的所有数据块更换为映射至所述具有最小擦写次数的目标数据块, 而将 所述底层存储介质中当前映射至所述具有最小擦写次数的目标数据块的所 有数据块更换为映射至所述具有最大擦写次数的目标数据块。 本领域技术人员应当理解, 本发明的各个实施例所公开的方法和装置, 可以在不偏离发明实质的情况下做出各种变形和改变, 这些变形和改变都 应当落入在本发明的保护范围之内。 因此, 本发明的保护范围由所附的权 利要求书来定义。

Claims

权 利 要 求 书
1、 一种控制缓存映射的方法, 其特征在于, 所述方法包括: 以预定的时间周期更换底层存储介质中至少一个数据块所映射到所述 底层存储介质的缓存中的目标数据块, 其中, 所述底层存储介质中一个或 多个数据块只映射到所述缓存中的一个目标数据块, 所述底层存储介质的 缓存包括闪存介质, 所更换的所述缓存中的目标数据块包括当前所述缓存 中具有最大擦写次数的目标数据块。
2、 根据权利要求 1所述的方法, 其特征在于, 所述以预定的时间周期 更换所述底层存储介质中的至少一个数据块所映射到的所述缓存中的目标 数据块的步骤包括:
在一个切换循环的每一个切换周期内, 更换所述底层存储介质中至少 一个数据块所映射到的所述缓存中的目标数据块, 以使得在一个切换循环 后, 所述缓存中的各目标数据块的擦写次数相接近, 其中, 一个切换循环 所包括的切换周期的数目不小于所述缓存所包含的目标数据块的数目 N。
3、 根据权利要求 1所述的方法, 其特征在于, 所述以预定的时间周期 更换所述底层存储介质中的至少一个数据块所映射到的所述缓存中的目标 数据块的步骤包括:
在一个切换循环的每一个切换周期内, 更换所述底层存储介质中的每 一个数据块所映射到的所述缓存中的目标数据块, 使得所述底层存储介质 中的每一个数据块在一个切换循环的不同切换周期内映射到所述缓存中的 不同目标数据块; 其中, 一个切换循环包括的切换周期的数目等于所述缓 存所包含的目标数据块的数目 N。
4、 根据权利要求 3所述的方法, 其特征在于, 所述在一个切换循环的 每一个切换周期内, 更换所述底层存储介质中的每一个数据块所映射到的 所述缓存中的目标数据块的步骤包括:
在一个切换循环的每一个切换周期内, 按照所述缓存中目标数据块的 编号顺序, 以轮转的方式将所述缓存中每一目标数据块的数据分别迁移至 编号与其相邻的目标数据块中, 并根据目标数据块中数据的迁移, 相应地 更换所述底层存储介质中每一个数据块所映射到的目标数据块。
5、 根据权利要求 1所述的方法, 其特征在于, 所述以预定的时间周期 更换所述底层存储介质中的至少一个数据块所映射到的所述缓存中的目标 数据块的步骤包括:
在一个切换循环的每一个切换周期内, 将所述缓存中当前具有最大擦 写次数的目标数据块中缓存的数据与所述缓存中除该具有最大擦写次数之 外的其它目标数据块中、 在当前的切换循环中其内数据进行过最少次数的 交换、 并且与在当前的切换循环的上一个切换周期中与该当前具有最大擦 写次数的目标数据块进行交换的目标数据块不同的任一个目标数据块中缓 存的数据相交换, 并且相应地更换所对应的所述底层存储介质中的数据块 所映射到的目标数据块;
其中, 所述一个切换循环包含 N乘以 (N-1 )个切换周期, 在所述一个 切换循环中, 所述缓存的各目标数据块在不同的 N-1个切换周期内为所述 缓存中具有最大擦写次数的目标数据块。
6、 一种控制缓存映射的方法, 其特征在于, 所述方法包括: 监控底层存储介质的缓存中各目标数据块的擦写次数, 其中, 所述底 层存储介质中一个或多个数据块只映射到所述缓存中的一个目标数据块, 所述底层存储介质的缓存包括闪存介质;
当所述缓存中具有最大擦写次数的目标数据块与具有最小擦写次数的 目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 更换所述底 层存储介质中的至少一个数据块所映射到的所述缓存中的目标数据块, 所 更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的 目标数据块; 以及
继续监控所述缓存中的各目标数据块在进行所述更换后所产生的擦写 次数。
7、 根据权利要求 6所述的方法, 其特征在于, 所述更换所述底层存储 介质中的至少一个数据块所映射到的所述缓存中的目标数据块的步骤包 括:
将所述具有最大擦写次数的目标数据块与具有最小擦写次数的目标数 据块之间缓存的数据进行交换, 并相应地将所述底层存储介质中当前映射 至所述具有最大擦写次数的目标数据块的所有数据块更换为映射至所述具 有最小擦写次数的目标数据块, 而将所述底层存储介质中当前映射至所述 具有最小擦写次数的目标数据块的所有数据块更换为映射至所述具有最大 擦写次数的目标数据块。
8、 一种缓存系统, 其特征在于, 包括:
底层存储介质;
闪存介质, 耦合至所述底层存储介质, 用于作为所述底层存储介质的 缓存, 其中所述底层存储介质中一个或多个数据块只映射到所述缓存中的 一个目标数据块;
处理器, 被配置成:
以预定的时间周期更换底层存储介质中至少一个数据块所映射到所述 底层存储介质的缓存中的目标数据块, 所更换的所述缓存中的目标数据块 包括当前所述缓存中具有最大擦写次数的目标数据块。
9、 根据权利要求 8所述的缓存系统, 其特征在于, 所述处理器进一步 被配置成:
在一个切换循环的每一个切换周期内, 更换所述底层存储介质中至少 一个数据块所映射到的所述缓存中的目标数据块, 以使得在一个切换循环 后, 所述缓存中的各目标数据块的擦写次数相接近, 其中, 一个切换循环 所包括的切换周期的数目不小于所述缓存所包含的目标数据块的数目 N。
10、 根据权利要求 8所述的缓存系统, 其特征在于, 所述处理器进一 被配置成:
在一个切换循环的每一个切换周期内, 更换所述底层存储介质中的每 个数据块所映射到的所述缓存中的目标数据块, 使得所述底层存储介质 的每一个数据块在一个切换循环的不同切换周期内映射到所述缓存中的 不同目标数据块; 其中, 一个切换循环包括的切换周期的数目等于所述缓 存所包含的目标数据块的数目 N。
11、 根据权利要求 10所述的缓存系统, 其特征在于, 所述处理器进一 步被配置成:
在一个切换循环的每一个切换周期内, 按照所述缓存中目标数据块的 编号顺序, 以轮转的方式将所述缓存中每一目标数据块的数据分别迁移至 编号与其相邻的目标数据块中, 并根据目标数据块中数据的迁移, 相应地 更换所述底层存储介质中每一个数据块所映射到的目标数据块。
12、 根据权利要求 8所述的缓存系统, 其特征在于, 所述处理器进一 步配置成:
在一个切换循环的每一个切换周期内, 将所述缓存中当前具有最大擦 写次数的目标数据块中缓存的数据与所述缓存中除该具有最大擦写次数之 外的其它目标数据块中、 在当前的切换循环中其内数据进行过最少次数的 交换、 并且与在当前的切换循环的上一个切换周期中与该当前具有最大擦 写次数的目标数据块进行交换的目标数据块不同的任一个目标数据块中缓 存的数据相交换, 并且相应地更换所对应的所述底层存储介质中的数据块 所映射到的目标数据块;
其中, 所述一个切换循环包含 N乘以 (N-1 )个切换周期, 在所述一个 切换循环中, 所述缓存中的各目标数据块中各自在 N-1个切换周期内为所 述缓存中具有最大擦写次数的目标数据块。
13、 一种缓存系统, 其特征在于, 包括:
底层存储介质;
闪存介质, 耦合至所述底层存储介质, 用于作为所述底层存储介质的 缓存, 其中所述底层存储介质中的一个或多个数据块只映射到所述缓存中 的一个目标数据块;
处理器, 被配置成:
监控所述缓存中各目标数据块的擦写次数;
当所述缓存中具有最大擦写次数的目标数据块与具有最小擦写次数的 目标数据块之间的擦写次数之差达到预先设定的擦写阈值时, 更换所述底 层存储介质中的至少一个数据块所映射到的所述缓存中的目标数据块, 所 更换的所述缓存中的目标数据块包括当前所述缓存中具有最大擦写次数的 目标数据块; 以及
继续监控所述缓存中的各目标数据块在进行所述更换后所产生的擦写 次数。
14、 根据权利要求 13所述的缓存系统, 其特征在于, 所述处理器进一 步被配置成:
将所述具有最大擦写次数的目标数据块与具有最小擦写次数的目标数 据块之间缓存的数据进行交换, 并相应地将所述底层存储介质中当前映射 至所述具有最大擦写次数的目标数据块的所有数据块更换为映射至所述具 有最小擦写次数的目标数据块, 而将所述底层存储介质中当前映射至所述 具有最小擦写次数的目标数据块的所有数据块更换为映射至所述具有最大 擦写次数的目标数据块。
15、 一种机器可读存储介质, 其存储机器可执行指令, 当所述机器可 执行指令被执行时使得机器执行权利要求 1-7的任何一个权利要求中的步 骤。
PCT/CN2011/081449 2011-10-27 2011-10-27 控制缓存映射的方法及缓存系统 WO2012163027A1 (zh)

Priority Applications (7)

Application Number Priority Date Filing Date Title
KR1020147005543A KR20140043497A (ko) 2011-10-27 2011-10-27 캐시 매핑 및 캐시 시스템을 제어하기 위한 방법
AU2011369945A AU2011369945B2 (en) 2011-10-27 2011-10-27 Method for Controlling Cache Mapping and Cache System
EP11866630.4A EP2662774A4 (en) 2011-10-27 2011-10-27 METHOD FOR CONTROLLING BUFFER MAPPING AND BUFFER SYSTEM
CN201180002426.5A CN102439572B (zh) 2011-10-27 2011-10-27 控制缓存映射的方法及缓存系统
RU2014113342/08A RU2556459C1 (ru) 2011-10-27 2011-10-27 Способ для управления отображением кэша и системой кэша
PCT/CN2011/081449 WO2012163027A1 (zh) 2011-10-27 2011-10-27 控制缓存映射的方法及缓存系统
US14/034,817 US20140025875A1 (en) 2011-10-27 2013-09-24 Method for Controlling Cache Mapping and Cache System

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/081449 WO2012163027A1 (zh) 2011-10-27 2011-10-27 控制缓存映射的方法及缓存系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/034,817 Continuation US20140025875A1 (en) 2011-10-27 2013-09-24 Method for Controlling Cache Mapping and Cache System

Publications (1)

Publication Number Publication Date
WO2012163027A1 true WO2012163027A1 (zh) 2012-12-06

Family

ID=45986241

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/081449 WO2012163027A1 (zh) 2011-10-27 2011-10-27 控制缓存映射的方法及缓存系统

Country Status (7)

Country Link
US (1) US20140025875A1 (zh)
EP (1) EP2662774A4 (zh)
KR (1) KR20140043497A (zh)
CN (1) CN102439572B (zh)
AU (1) AU2011369945B2 (zh)
RU (1) RU2556459C1 (zh)
WO (1) WO2012163027A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016507847A (ja) * 2013-02-21 2016-03-10 クアルコム,インコーポレイテッド 限定的書込み耐久性を有するキャッシュのためのセット間ウェアレベリング
JP2016510475A (ja) * 2013-02-19 2016-04-07 クアルコム,インコーポレイテッド 書込み耐久性が限られたメモリのためのイントラセットウェアレベリングのための方法および装置

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140097924A (ko) * 2013-01-30 2014-08-07 한국전자통신연구원 우선 순위를 가지는 이중 캐싱 방법 및 이를 위한 장치
CN105426114B (zh) * 2014-09-23 2019-04-19 北京联想核芯科技有限公司 一种确定硬盘中擦写对象的方法及装置
CN104599708A (zh) * 2015-01-16 2015-05-06 珠海格力电器股份有限公司 显示器数据存储方法
CN106328201A (zh) * 2015-07-01 2017-01-11 上海华虹集成电路有限责任公司 非易失性存储器擦写控制电路及方法
US20170271030A1 (en) * 2016-03-18 2017-09-21 Alibaba Group Holding Limited Method and system for using downgraded flash die for cache applications
US10891201B1 (en) * 2017-04-27 2021-01-12 EMC IP Holding Company LLC Dynamic rule based model for long term retention
CN107861885A (zh) * 2017-11-07 2018-03-30 浪潮软件股份有限公司 一种数据传输方法及传输装置
CN109445681B (zh) * 2018-08-27 2021-05-11 华为技术有限公司 数据的存储方法、装置和存储系统
CN112799595B (zh) * 2021-02-02 2023-06-23 联想(北京)有限公司 数据处理方法、设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6865650B1 (en) * 2000-09-29 2005-03-08 Emc Corporation System and method for hierarchical data storage
CN101034399A (zh) * 2006-03-07 2007-09-12 日立系统服务公司 半导体闪存的数据管理及控制系统和半导体闪存收容装置
CN101122887A (zh) * 2007-01-17 2008-02-13 晶天电子(深圳)有限公司 一种采用数据区域切换指针缓冲硬盘驱动器的闪存卡

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1556868B1 (en) * 2002-10-28 2007-09-05 SanDisk Corporation Automated wear leveling in non-volatile storage systems
EP1713085A1 (en) * 2002-10-28 2006-10-18 SanDisk Corporation Automated wear leveling in non-volatile storage systems
US7069389B2 (en) * 2003-11-26 2006-06-27 Microsoft Corporation Lazy flushing of translation lookaside buffers
JP4863749B2 (ja) * 2006-03-29 2012-01-25 株式会社日立製作所 フラッシュメモリを用いた記憶装置、その消去回数平準化方法、及び消去回数平準化プログラム
KR100843543B1 (ko) * 2006-10-25 2008-07-04 삼성전자주식회사 플래시 메모리 장치를 포함하는 시스템 및 그것의 데이터복구 방법
US20080140918A1 (en) * 2006-12-11 2008-06-12 Pantas Sutardja Hybrid non-volatile solid state memory system
US8001318B1 (en) * 2008-10-28 2011-08-16 Netapp, Inc. Wear leveling for low-wear areas of low-latency random read memory

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6865650B1 (en) * 2000-09-29 2005-03-08 Emc Corporation System and method for hierarchical data storage
CN101034399A (zh) * 2006-03-07 2007-09-12 日立系统服务公司 半导体闪存的数据管理及控制系统和半导体闪存收容装置
CN101122887A (zh) * 2007-01-17 2008-02-13 晶天电子(深圳)有限公司 一种采用数据区域切换指针缓冲硬盘驱动器的闪存卡

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016510475A (ja) * 2013-02-19 2016-04-07 クアルコム,インコーポレイテッド 書込み耐久性が限られたメモリのためのイントラセットウェアレベリングのための方法および装置
JP2016507847A (ja) * 2013-02-21 2016-03-10 クアルコム,インコーポレイテッド 限定的書込み耐久性を有するキャッシュのためのセット間ウェアレベリング

Also Published As

Publication number Publication date
CN102439572B (zh) 2014-04-02
AU2011369945A1 (en) 2014-03-13
AU2011369945B2 (en) 2015-06-25
US20140025875A1 (en) 2014-01-23
CN102439572A (zh) 2012-05-02
RU2556459C1 (ru) 2015-07-10
EP2662774A4 (en) 2014-01-08
EP2662774A1 (en) 2013-11-13
KR20140043497A (ko) 2014-04-09

Similar Documents

Publication Publication Date Title
WO2012163027A1 (zh) 控制缓存映射的方法及缓存系统
US10761777B2 (en) Tiered storage using storage class memory
KR101257691B1 (ko) 메모리 컨트롤러 및 이의 데이터 관리방법
JP6007329B2 (ja) ストレージコントローラ、ストレージ装置、ストレージシステム
KR101726824B1 (ko) 캐시 아키텍처에서 하이브리드 미디어의 효율적인 사용
CN104216665B (zh) 多层单元固态硬盘的存储管理方法
US10740242B2 (en) Sensing device data caching
JP2008015769A (ja) ストレージシステム及び書き込み分散方法
JP6711121B2 (ja) 情報処理装置、キャッシュメモリ制御方法、およびキャッシュメモリ制御プログラム
US20140254042A1 (en) Dynamic allocation of lba to un-shingled media partition
US8947817B1 (en) Storage system with media scratch pad
US8332575B2 (en) Data management systems, methods and computer program products using a phase-change random access memory for selective data maintenance
JPWO2014049678A1 (ja) ソリッドステートドライブにデータを再配置するストレージ装置、ストレージコントローラ及び方法
TW201824010A (zh) 資訊處理裝置及記憶體存取方法
JP2004272324A (ja) ディスクアレイ装置
JP4829202B2 (ja) 記憶装置及びメモリ制御方法
JP5594647B2 (ja) ストレージ装置及びその制御方法
JP2014530422A (ja) バッファマッピングを制御するための方法およびバッファシステム
JP5950470B2 (ja) バッファマッピングを制御するための方法およびバッファシステム
JP2015185133A (ja) 情報記憶装置および情報記憶方法
JP2012164136A (ja) ストレージ装置、ストレージ装置の制御プログラム、及びストレージ装置の制御方法
WO2021208089A1 (zh) 存储器的管理方法和控制装置
JP2023176257A (ja) ストレージ装置、ストレージ制御方法およびストレージ制御プログラム
KR20090113624A (ko) 솔리드 스테이트 드라이브 및 그 동작 제어방법
WO2014141545A1 (ja) ストレージ制御装置、及びストレージ制御システム

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201180002426.5

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11866630

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2011866630

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2011866630

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 20147005543

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2011369945

Country of ref document: AU

Date of ref document: 20111027

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2014531069

Country of ref document: JP

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2014113342

Country of ref document: RU

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE