CN103488582B - Write the method and device of cache memory - Google Patents
Write the method and device of cache memory Download PDFInfo
- Publication number
- CN103488582B CN103488582B CN201310400488.2A CN201310400488A CN103488582B CN 103488582 B CN103488582 B CN 103488582B CN 201310400488 A CN201310400488 A CN 201310400488A CN 103488582 B CN103488582 B CN 103488582B
- Authority
- CN
- China
- Prior art keywords
- flash memory
- data block
- stored
- memory card
- block
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
Abstract
本申请提供一种写高速缓冲存储器的方法,应用闪存卡(即FLASH存储器)作为高速缓冲存储器,在进行数据缓存时,判断闪存卡中是否缓存有与待存储的数据块的磁盘逻辑块地址相同的旧数据块,如果存在,则直接将待存储数据块以异步方式写入所述闪存卡中,如果不存在,则将待存储数据块以异步方式写入所述闪存卡的空闲块中,实现了写数据的缓存,而由于闪存卡不需要备用电池保电,掉电后数据也不会丢失,因此能耗低,而且,闪存卡自身的价格低于动态随机存储器的价格,因此,本申请实施例提供的写高速缓冲存储器的方法,降低了存储系统的实现成本。本申请实施例还提供一种写高速缓冲存储器的装置。
The present application provides a method for writing a cache memory, using a flash memory card (that is, a FLASH memory) as a cache memory, and judging whether the flash memory card has the same disk logic block address as the data block to be stored when caching data If it exists, then directly write the data block to be stored in the flash memory card in an asynchronous manner, if it does not exist, then write the data block to be stored in a free block of the flash memory card in an asynchronous manner, The write data cache is realized, and because the flash memory card does not need a backup battery to keep the power, the data will not be lost after power failure, so the energy consumption is low, and the price of the flash memory card itself is lower than the price of the dynamic random access memory. Therefore, this The method for writing the cache memory provided in the embodiment of the application reduces the implementation cost of the storage system. The embodiment of the present application also provides a device for writing a cache memory.
Description
技术领域technical field
本发明涉及数据存储技术领域,尤其涉及一种读、写高速缓冲存储器的方法及装置。The invention relates to the technical field of data storage, in particular to a method and device for reading and writing a cache memory.
背景技术Background technique
高速缓冲存储器(cache)是磁盘内部存储和外界接口之间的缓冲器。高速缓冲存储器的一个重要作用就是做为写cache对写入数据进行缓存,即在有数据需要存储至磁盘时,不会马上将数据写入到磁盘中,而是先将数据暂时写入高速缓冲存储器里,然后返回一个“数据已写入”的信号给系统,这时系统就会认为数据已经写入,并继续执行后续的工作,当高速缓存存储器中的数据达到一定程度时,再将数据从高速缓冲存储器写入到磁盘中。高速缓存存储器的使用,一方面减少了实际的磁盘操作,有效保护磁盘免于重复的读写操作而导致的损坏,一方面也可以减少数据写入所需的时间,从而提高了存储系统的写性能。A cache is a buffer between the disk's internal storage and the external interface. An important function of the cache memory is to cache the written data as a write cache, that is, when there is data to be stored on the disk, the data will not be written to the disk immediately, but the data will be temporarily written to the cache first memory, and then return a "data has been written" signal to the system, then the system will think that the data has been written, and continue to perform follow-up work, when the data in the cache memory reaches a certain level, and then write the data Write from cache memory to disk. The use of cache memory, on the one hand, reduces the actual disk operations, effectively protecting the disk from damage caused by repeated read and write operations, and on the other hand, it can also reduce the time required for data writing, thereby improving the write performance of the storage system. performance.
然而,目前多使用带备用电池(Battery Backup Unit,BBU)保电的动态随机存储器(Dynamic Random Access Memory,DRAM)做为写cache,而备用电池的价格昂贵,能够支持的内存有限,因此,维护动态随机存储器需要消耗更多的电能,因而,使用动态随机存储器做为写cache使得存储系统的实现成本较高。However, at present, Dynamic Random Access Memory (DRAM) with backup battery (Battery Backup Unit, BBU) is mostly used as write cache, and the backup battery is expensive and the memory that can be supported is limited. Therefore, maintenance The DRAM needs to consume more power. Therefore, using the DRAM as a write cache makes the implementation cost of the storage system higher.
发明内容Contents of the invention
本发明实施例提供了一种写高速缓冲存储器的方法,以降低存储系统的实现成本。An embodiment of the present invention provides a method for writing a cache memory, so as to reduce the implementation cost of a storage system.
本发明的第一方面提供一种写高速缓冲存储器的方法,所高速缓冲存储器为闪存卡,所述方法包括:A first aspect of the present invention provides a method for writing a cache memory, the cache memory is a flash memory card, and the method includes:
判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;Judging whether the old data block with the same old data block address as the disk logical block address of the data block to be stored is cached in the flash memory card;
如果是,则将所述待存储数据块以异步方式写入所述闪存卡中;If so, then write the data block to be stored in the flash memory card in an asynchronous manner;
如果否,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中。If not, write the data block to be stored into a free block in the flash memory card in an asynchronous manner.
在第一方面的第一种可能的实现方式中,所述将所述待存储数据块写入所述闪存卡的空闲块中包括:In a first possible implementation manner of the first aspect, writing the data block to be stored into a free block of the flash memory card includes:
判断所述闪存卡中是否存在空闲块;Judging whether there is a free block in the flash memory card;
如果存在,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;If it exists, then write the data block to be stored in a free block in the flash memory card in an asynchronous manner;
如果不存在,则将所述待存储数据块加入到等待队列,并在所述闪存卡中出现空闲块时,执行将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中的步骤。If it does not exist, the data block to be stored is added to the waiting queue, and when a free block occurs in the flash memory card, the data block to be stored is written into the free block in the flash memory card in an asynchronous manner in the steps.
在第一方面的第二种可能的实现方式中,在将所述待存储的数据块写入所述闪存卡中的空闲块后,还包括:In a second possible implementation manner of the first aspect, after writing the data block to be stored into a free block in the flash memory card, further comprising:
保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。The corresponding relationship between the disk logical block address of the data block to be stored and the flash memory logical block address of the data block to be stored is stored.
结合第一方面的第二种可能实现方式,在第一方面的第三种可能的实现方式中,所述判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块包括:In combination with the second possible implementation of the first aspect, in the third possible implementation of the first aspect, the judging whether there is an old memory card cached in the flash memory card that is the same as the disk logical block address of the data block to be stored Data blocks include:
判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;Judging whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
如果存在,则确定所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块;否则,确定所述述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。If it exists, then determine that the same old data block as the disk logical block address of the data block to be stored is cached in the flash memory card; otherwise, determine that there is no cache with the data block to be stored in the flash memory card The old data block with the same disk logical block address.
结合第一方面或第一方面的任意一种实现方式,在第一方面的第四种可能的实现方式中,还包括:In combination with the first aspect or any implementation manner of the first aspect, the fourth possible implementation manner of the first aspect further includes:
将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。Marking the data block to be stored as a dirty data block, and adding the data block to be stored to a queue of dirty data blocks.
结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,还包括:In combination with the fourth possible implementation of the first aspect, the fifth possible implementation of the first aspect further includes:
获取所述闪存卡的当前空闲空间比例;Obtain the current free space ratio of the flash memory card;
当所述空闲空间的比例小于第一预设阈值时,确定待读取的脏数据块的个数;When the ratio of the free space is less than a first preset threshold, determine the number of dirty data blocks to be read;
将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;performing heap sorting on each dirty data block in the dirty data block queue according to the disk logic block address, and obtaining a first sorting heap;
发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆堆头开始依次异步读取闪存卡中的脏数据块;Initiate several first asynchronous requests, and read the dirty data blocks in the flash memory card sequentially asynchronously from the head of the first sorting pile according to the number of dirty data blocks to be read;
根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行堆排序,获取第二排序堆;Perform heap sorting on the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks to obtain a second sorting heap;
发起第二异步请求,将所述读取到的脏数据块从第二排序堆的堆头开始依次异步写入磁盘中,所述第二异步请求的个数为所述待读取的脏数据块的个数。Initiate a second asynchronous request to asynchronously write the read dirty data blocks to the disk sequentially from the heap head of the second sorting heap, and the number of the second asynchronous request is the dirty data to be read the number of blocks.
结合第一方面的第五种可能的实现方式,在第一方面的第六种可能的实现方式中,所述堆排序为最小堆排序。With reference to the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, the heap sorting is min-heap sorting.
结合第一方面的第五种可能的实现方式,在第一方面的第七种可能的实现方式中,所述堆排序为最大堆排序。With reference to the fifth possible implementation manner of the first aspect, in a seventh possible implementation manner of the first aspect, the heap sort is a maximum heap sort.
结合第一方面的第五种可能的实现方式,在第一方面的第八种可能的实现方式中,所述第一异步请求的个数依据第一公式确定,所述第一公式为:With reference to the fifth possible implementation of the first aspect, in the eighth possible implementation of the first aspect, the number of the first asynchronous requests is determined according to a first formula, and the first formula is:
V=N+(M-N)*RV=N+(M-N)*R
其中,V为第一异步请求的个数;N为预设的异步请求个数的下限;M为预设的异步请求个数的上限;R为闪存卡当前的空间利用率。Wherein, V is the number of the first asynchronous request; N is the lower limit of the preset number of asynchronous requests; M is the upper limit of the preset number of asynchronous requests; R is the current space utilization rate of the flash memory card.
本发明的第二方面提供一种写高速缓冲存储器的装置,所述高速缓冲存储器为闪存卡,所述装置包括:A second aspect of the present invention provides a device for writing a cache memory, the cache memory is a flash memory card, and the device includes:
判断模块,用于判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;Judging module, used to judge whether there is an old data block with the same old data block address as the disk logical block address of the data block to be stored in the flash memory card;
第一写模块,用于在所述判断模块判断出所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块时,将所述待存储数据块以异步方式写入所述闪存卡中;The first writing module is used to write the data block to be stored in an asynchronous manner when the judging module judges that an old data block with the same disk logic block address as the data block to be stored is cached in the flash memory card Write in the flash memory card;
第二写模块,用于在所述判断模块判断出所述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块时,将所述待存储数据块以异步方式写入所述闪存卡的空闲块中。The second writing module is used to write the data block to be stored asynchronously when the judging module judges that there is no old data block cached in the flash memory card with the same disk logic block address as the data block to be stored mode to write to the free block of the flash memory card.
在第二方面的第一种可能的实现方式中,所述第二写模块包括:In a first possible implementation manner of the second aspect, the second writing module includes:
第一判断单元,用于判断所述闪存卡中是否存在空闲块;A first judging unit, configured to judge whether there is a free block in the flash memory card;
第一写单元,用于在所述第一判断单元判断出所述闪存卡中存在空闲块时,将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;A first writing unit, configured to asynchronously write the data block to be stored into a free block in the flash memory card when the first judging unit judges that there is a free block in the flash memory card;
第二写单元,用于在所述判断单元判断出所述闪存卡中不存在空闲块时,将所述待存储数据块加入等待队列,并在所述闪存卡中出现空闲块时,将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中。The second writing unit is used to add the data block to be stored to the waiting queue when the judging unit judges that there is no free block in the flash memory card, and write the data block to the waiting queue when there is a free block in the flash memory card. The data blocks to be stored are written into free blocks in the flash memory card in an asynchronous manner.
在第二方面的第二种可能的实现方式中,还包括:In a second possible implementation manner of the second aspect, it also includes:
保存模块,用于在所述第二写模块将所述待存储数据块写入所述闪存卡中的空闲块后,保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。A saving module, configured to save the disk logical block address of the data block to be stored and the data block to be stored after the second writing module writes the data block to be stored into a free block in the flash memory card The corresponding relationship of the logical block address of the flash memory.
在第二方面的第三种可能的实现方式中,所述判断模块包括:In a third possible implementation manner of the second aspect, the judging module includes:
第二判断单元,用于判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;The second judging unit is used to judge whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
第三判断单元,用于在所述第二判断单元判断出存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址时,确定所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块;The third judging unit is used to determine that the flash memory card caches the data to be stored when the second judging unit judges that there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored. The old data block with the same disk logical block address as the storage data block;
第四判断单元,用于在所述第二判断单元判断出不存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址时,确定所述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。The fourth judging unit is used to determine that the flash memory card is not cached in the flash memory card when the second judging unit judges that there is no flash memory logical block address corresponding to the disk logical block address of the data block to be stored. Describe the old data block with the same disk logical block address as the data block to be stored.
结合第二方面或第二方面的任意一种可能的实现方式,在第二方面的第四中可能的实现方式中,还包括:In combination with the second aspect or any possible implementation manner of the second aspect, the fourth possible implementation manner of the second aspect further includes:
标记模块,用于在所述第一写模块或第二写模块将所述待存储数据块写入闪存卡后,将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。A marking module, configured to mark the data block to be stored as a dirty data block after the first writing module or the second writing module writes the data block to be stored into the flash memory card, and write the data to be stored The block is added to the dirty data block queue.
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,还包括:In combination with the fourth possible implementation of the second aspect, the fifth possible implementation of the second aspect further includes:
获取模块,用于获取所述闪存卡的当前空闲空间比例;An acquisition module, configured to acquire the current free space ratio of the flash memory card;
确定模块,用于当所述空闲空间比例小于第一预设阈值时,确定待读取的脏数据块的个数;A determining module, configured to determine the number of dirty data blocks to be read when the free space ratio is less than a first preset threshold;
第一排序模块,用于将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;The first sorting module is configured to perform heap sorting on each dirty data block in the dirty data block queue according to the disk logical block address, and obtain a first sorting heap;
第一读模块,用于发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆堆头开始依次异步读取闪存卡中的脏数据块;The first reading module is used to initiate several first asynchronous requests, and reads the dirty data blocks in the flash memory card sequentially and asynchronously from the head of the first sorting pile according to the number of dirty data blocks to be read;
第二排序模块,用于根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行堆排序,获取第二排序堆;The second sorting module is configured to perform heap sorting on the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks, to obtain a second sorting heap;
第三写模块,用于发起第二异步请求,将所述读取到的脏数据块从所述第二排序堆的堆头开始依次写入到磁盘中,所述第二异步请求的个数为所述待读取的脏数据块的个数。The third writing module is configured to initiate a second asynchronous request, and write the read dirty data blocks to the disk sequentially from the heap head of the second sorting heap, the number of the second asynchronous request is the number of dirty data blocks to be read.
本发明的第三方面提供一种写高速缓冲存储器的装置,所述高速缓冲存储器为闪存卡,所述装置包括:A third aspect of the present invention provides a device for writing a cache memory, the cache memory is a flash memory card, and the device includes:
至少一个处理器,其被配置为:At least one processor configured to:
判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;Judging whether the old data block with the same old data block address as the disk logical block address of the data block to be stored is cached in the flash memory card;
如果有,则将所述待存储数据块以异步方式写入所述闪存卡中;If yes, then write the data block to be stored in the flash memory card in an asynchronous manner;
如果没有,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;以及If not, then write the data block to be stored in a free block in the flash memory card in an asynchronous manner; and
存储器,其耦合至所述至少一个处理器。memory coupled to the at least one processor.
在第三方面的第一种可能的实现方式中,被配置为将所述待存储数据块写入所述闪存卡的空闲块中的至少一个处理器进一步被配置为:In a first possible implementation manner of the third aspect, at least one processor configured to write the data block to be stored into a free block of the flash memory card is further configured to:
判断所述闪存卡中是否存在空闲块;Judging whether there is a free block in the flash memory card;
如果存在,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;If it exists, then write the data block to be stored in a free block in the flash memory card in an asynchronous manner;
如果不存在,则将所述待存储数据块加入到等待队列,并在所述闪存卡中出现空闲块时,执行将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中的步骤。If it does not exist, the data block to be stored is added to the waiting queue, and when a free block occurs in the flash memory card, the data block to be stored is written into the free block in the flash memory card in an asynchronous manner in the steps.
在第三方面的第二种可能的实现方式中,所述至少一个处理器进一步被配置为:In a second possible implementation manner of the third aspect, the at least one processor is further configured to:
在将所述待存储的数据块写入所述闪存卡中的空闲块后,保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。After the data block to be stored is written into the free block in the flash memory card, the corresponding relationship between the disk logical block address of the data block to be stored and the flash memory logical block address of the data block to be stored is saved.
结合第三方面的第二种可能的实现方式,在第三方面的第三种可能的实现方式中,被配置为判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块的至少一个处理器进一步被配置为:With reference to the second possible implementation of the third aspect, in the third possible implementation of the third aspect, it is configured to determine whether the flash memory card caches a disk with the same logical block address as the data block to be stored At least one processor of the old data block is further configured to:
判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;Judging whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
如果存在,则确定所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块;否则,确定所述述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。If it exists, then determine that the same old data block as the disk logical block address of the data block to be stored is cached in the flash memory card; otherwise, determine that there is no cache with the data block to be stored in the flash memory card The old data block with the same disk logical block address.
结合第三方面或第三方面的任意一种可能的实现方式,在第三方面的第四种可能的实现方式中,所述至少一个处理器进一步被配置为:With reference to the third aspect or any possible implementation manner of the third aspect, in a fourth possible implementation manner of the third aspect, the at least one processor is further configured to:
在将所述待存储的数据块写入所述闪存卡后,将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。After the data block to be stored is written into the flash memory card, the data block to be stored is marked as a dirty data block, and the data block to be stored is added to a queue of dirty data blocks.
结合第三方面的第四种可能的实现方式,在第三方面的第五种可能的实现方式中,所述至少一个处理器进一步被配置为:With reference to the fourth possible implementation manner of the third aspect, in a fifth possible implementation manner of the third aspect, the at least one processor is further configured to:
获取所述闪存卡的当前空闲空间比例;Obtain the current free space ratio of the flash memory card;
当所述空闲空间的比例小于第一预设阈值时,确定待读取的脏数据块的个数;When the ratio of the free space is less than a first preset threshold, determine the number of dirty data blocks to be read;
将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;performing heap sorting on each dirty data block in the dirty data block queue according to the disk logic block address, and obtaining a first sorting heap;
发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆堆头开始依次异步读取闪存卡中的脏数据块;Initiate several first asynchronous requests, and read the dirty data blocks in the flash memory card sequentially asynchronously from the head of the first sorting pile according to the number of dirty data blocks to be read;
根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行堆排序,获取第二排序堆;Perform heap sorting on the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks to obtain a second sorting heap;
发起第二异步请求,将所述读取到的脏数据块从第二排序堆的堆头开始依次异步写入磁盘中,所述第二异步请求的个数为所述待读取的脏数据块的个数。Initiate a second asynchronous request to asynchronously write the read dirty data blocks to the disk sequentially from the heap head of the second sorting heap, and the number of the second asynchronous request is the dirty data to be read the number of blocks.
本发明实施例提供的一种写高速缓冲存储器的方法,应用闪存卡(即FLASH存储器)作为高速缓冲存储器,在进行数据缓存时,判断闪存卡中是否缓存有与待存储的数据块的磁盘逻辑块地址相同的旧数据块,如果存在,则直接将待存储数据块以异步方式写入所述闪存卡中,如果不存在,则将待存储数据块以异步方式写入所述闪存卡的空闲块中,实现了写数据的缓存,而由于闪存卡不需要备用电池保电,掉电后数据也不会丢失,因此能耗低,而且,闪存卡自身的价格低于动态随机存储器的价格,因此,本申请实施例提供的写高速缓冲存储器的方法,降低了存储系统的实现成本。A method for writing a cache memory provided by an embodiment of the present invention uses a flash memory card (that is, a FLASH memory) as a cache memory, and when data caching is performed, it is judged whether there is a disk logic cached with a data block to be stored in the flash memory card If the old data block with the same block address exists, the data block to be stored is directly written into the flash memory card in an asynchronous manner; In the block, the write data cache is realized, and because the flash memory card does not need a backup battery to keep the power, the data will not be lost after power failure, so the energy consumption is low, and the price of the flash memory card itself is lower than that of the DRAM. Therefore, the method for writing the cache memory provided by the embodiment of the present application reduces the implementation cost of the storage system.
附图说明Description of drawings
图1是本申请实施例提供的一种写高速缓冲存储器的方法的流程图;FIG. 1 is a flow chart of a method for writing a cache memory provided in an embodiment of the present application;
图2是本申请实施例提供的另一种写高速缓冲存储器的方法的流程图;FIG. 2 is a flow chart of another method for writing a cache memory provided by an embodiment of the present application;
图3是本申请实施例提供的又一种写高速缓冲存储器的方法的流程图;FIG. 3 is a flow chart of another method for writing a cache memory provided by an embodiment of the present application;
图4为本申请实施例提供的又一种写高速缓冲存储器的方法的流程图;FIG. 4 is a flowchart of another method for writing a cache memory provided by an embodiment of the present application;
图5为本申请实施例提供的将高速缓存存储器中的数据写入到磁盘中的过程的示意图;FIG. 5 is a schematic diagram of a process of writing data in a cache memory to a disk provided by an embodiment of the present application;
图6为本申请实施例提供的一种写高速缓冲存储器的装置的结构示意图;FIG. 6 is a schematic structural diagram of an apparatus for writing a cache memory according to an embodiment of the present application;
图7为本申请实施例提供的另一种写高速缓冲存储器的装置的结构示意图;FIG. 7 is a schematic structural diagram of another device for writing a cache memory according to an embodiment of the present application;
图8为本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图;FIG. 8 is a schematic structural diagram of another device for writing a cache memory according to an embodiment of the present application;
图9为本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图;FIG. 9 is a schematic structural diagram of another device for writing a cache memory according to an embodiment of the present application;
图10为本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图;FIG. 10 is a schematic structural diagram of another device for writing a cache memory according to an embodiment of the present application;
图11为本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图;FIG. 11 is a schematic structural diagram of another device for writing a cache memory provided by an embodiment of the present application;
图12为本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图;FIG. 12 is a schematic structural diagram of another device for writing a cache memory provided by an embodiment of the present application;
图13为本申请实施例提供的一体机系统中的高速缓冲存储器的架构图;FIG. 13 is a structural diagram of a cache memory in an all-in-one system provided by an embodiment of the present application;
图14为本申请实施例提供的块存储磁盘阵列中高速缓冲存储器的架构图。FIG. 14 is a structural diagram of a cache memory in a block storage disk array provided by an embodiment of the present application.
具体实施方式detailed description
为了使本领域技术人员能进一步了解本发明的特征及技术内容,请参阅以下有关本发明的详细说明与附图,附图仅提供参考与说明,并非用来限制本发明。In order for those skilled in the art to further understand the features and technical contents of the present invention, please refer to the following detailed description and accompanying drawings of the present invention. The accompanying drawings are provided for reference and illustration only, and are not intended to limit the present invention.
请参看图1,图1为本申请实施例提供的一种写高速缓冲存储器的方法的流程图,其中,所述高速缓冲存储器为闪存卡,即FLASH存储器;所述方法包括:Please refer to Fig. 1, Fig. 1 is a flow chart of a method for writing a cache memory provided by an embodiment of the present application, wherein the cache memory is a flash memory card, i.e. a FLASH memory; the method includes:
步骤S101:判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;如果是,则执行步骤S102,否则,执行步骤S103;Step S101: judging whether there is an old data block cached in the flash memory card which is the same as the disk logic block address of the data block to be stored; if yes, then execute step S102, otherwise, execute step S103;
块存储是最传统的存储形式,本申请实施例正是基于块存储技术的写高速缓冲存储器的方法,即数据以数据块的形式存储在高速缓冲存储器和磁盘中。Block storage is the most traditional form of storage. The embodiment of the present application is a method of writing cache memory based on block storage technology, that is, data is stored in the cache memory and disk in the form of data blocks.
本申请实例中,所述闪存卡被划为若干逻辑块In the example of this application, the flash memory card is divided into several logical blocks
所述待存储数据块的磁盘逻辑块地址是写请求中携带的信息,用于指示待存储数据块在磁盘中的存储位置。The disk logic block address of the data block to be stored is information carried in the write request, and is used to indicate the storage location of the data block to be stored in the disk.
本申请实施例中,在接收到写请求后,首先判断高速缓存存储器中是否已经存在与待存储数据块的磁盘逻辑块地址相同的旧数据块,即判断闪存卡中是否存在数据块,而该数据块的磁盘逻辑块地址与所述待存储数据块的磁盘逻辑块地址是相同的。In the embodiment of the present application, after receiving the write request, it is first judged whether there is an old data block identical to the disk logical block address of the data block to be stored in the cache memory, that is, whether there is a data block in the flash memory card, and the The disk logic block address of the data block is the same as the disk logic block address of the data block to be stored.
步骤S102:将所述待存储数据块以异步方式写入所述闪存卡中;Step S102: writing the data block to be stored into the flash memory card in an asynchronous manner;
本申请实施例中,如果闪存卡中已经存在与所述待存储数据块的逻辑块地址相同的旧数据块,则不管闪存卡中是否存在空闲块,直接发起对闪存卡的异步写操作,将待存储数据写入所述闪存卡中。In the embodiment of the present application, if there is already an old data block with the same logical block address as the data block to be stored in the flash memory card, no matter whether there is a free block in the flash memory card, an asynchronous write operation to the flash memory card is directly initiated, and the The data to be stored is written into the flash memory card.
需要说明是,本申请实施例中,所述的空闲块为逻辑意义上的空闲块,因此,在没有空闲块的情况下,其可能还会有物理意义上的空闲空间,因此,在没有空闲块的情况下,还是可以将待存储数据块写入闪存卡中的,进一步的,在没有空闲块也没有物理意义上的空闲空间的情况下,闪存卡会执行擦除流程,具体擦除过程是本领域的公知常识,这里不再赘述。It should be noted that in the embodiment of the present application, the free block is a logical free block. Therefore, if there is no free block, it may have a physical free space. Therefore, when there is no free block In the case of blocks, the data blocks to be stored can still be written into the flash memory card. Further, when there are no free blocks and no free space in the physical sense, the flash memory card will execute the erasing process. The specific erasing process It is common knowledge in this field and will not be repeated here.
步骤S103:将所述待存储数据块以异步方式写入所述闪存卡的空闲块中。Step S103: writing the data block to be stored into a free block of the flash memory card in an asynchronous manner.
本申请实施例中,如果闪存卡中不存在与所述待存储数据块的逻辑块地址相同的旧数据块,则在所述闪存卡中存在空闲块时,发起对闪存卡的异步写操作,将待存储数据写入所述闪存卡中。In the embodiment of the present application, if there is no old data block with the same logical block address as the data block to be stored in the flash memory card, when there is a free block in the flash memory card, initiate an asynchronous write operation to the flash memory card, Write the data to be stored into the flash memory card.
本申请实施例提供的一种写高速缓冲存储器的方法,应用闪存卡(即FLASH存储器)作为高速缓冲存储器,在进行数据缓存时,判断闪存卡中是否缓存有与待存储的数据块的磁盘逻辑块地址相同的旧数据块,如果存在,则直接将待存储数据块以异步方式写入所述闪存卡中,如果不存在,则将待存储数据块以异步方式写入所述闪存卡的空闲块中,实现了写数据的缓存,而由于闪存卡不需要备用电池保电,掉电后数据也不会丢失,因此能耗低,而且,闪存卡自身的价格低于动态随机存储器的价格,因此,本申请实施例提供的写高速缓冲存储器的方法,降低了存储系统的实现成本,或者说,在同样成本的情况下,本申请实施例能够实现的缓存容量更大。A method for writing a cache memory provided by the embodiment of the present application uses a flash memory card (that is, a FLASH memory) as a cache memory. When performing data caching, it is judged whether there is a disk logic cached in the flash memory card and the data block to be stored. If the old data block with the same block address exists, the data block to be stored is directly written into the flash memory card in an asynchronous manner; In the block, the write data cache is realized, and because the flash memory card does not need a backup battery to keep the power, the data will not be lost after power failure, so the energy consumption is low, and the price of the flash memory card itself is lower than that of the DRAM. Therefore, the method for writing the cache memory provided by the embodiment of the present application reduces the implementation cost of the storage system, or in other words, the embodiment of the present application can realize a larger cache capacity under the same cost.
而且,FLASH存储器能够适应当前主流的硬件平台,不限定操作系统,不限定硬件平台,只要有一个PCI-E插槽即可。Moreover, the FLASH memory can adapt to the current mainstream hardware platform, and does not limit the operating system or hardware platform, as long as there is a PCI-E slot.
上述实施例,优选的,在将待存储数据块写入闪存卡中时,可以采用日志形式的数据布局,即将待存储数据块按闪存逻辑块地址从小到大的顺序依次存储,这样可以有效保证数据I/O的连续性,从而可以使得闪存卡进行垃圾回收时,垃圾块中的有效数据很少,减小了闪存卡的写放大(即减少了对闪存卡的写的次数),从而避免因对闪存卡的写而造成的闪存卡的使用寿命减短的问题。In the above-described embodiment, preferably, when writing the data block to be stored in the flash memory card, a data layout in the form of a log can be adopted, that is, the data block to be stored is stored sequentially according to the order of the logical block address of the flash memory from small to large, which can effectively ensure The continuity of data I/O, so that when the flash memory card is garbage collected, there is very little valid data in the garbage block, which reduces the write amplification of the flash memory card (that is, reduces the number of writes to the flash memory card), thereby avoiding There is a problem that the service life of the flash memory card is shortened due to writing to the flash memory card.
本申请实施例提供的另一种写高速缓冲存储器的方法的流程图如图2所示,所述步骤S103具体实现流程可以包括:The flow chart of another method for writing a cache memory provided by the embodiment of the present application is shown in FIG. 2 , and the specific implementation process of step S103 may include:
步骤S201,判断所述闪存卡中是否存在空闲块;如果存在,则执行步骤S202,否则,执行步骤S203;Step S201, judging whether there is a free block in the flash memory card; if yes, execute step S202, otherwise, execute step S203;
步骤S202:将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;Step S202: writing the data block to be stored into a free block in the flash memory card in an asynchronous manner;
步骤S203:将所述待存储数据块加入到等待队列中;Step S203: adding the data block to be stored into a waiting queue;
步骤S204:判断闪存卡中是否出现空闲块,如果是,则执行步骤S202;否则,继续等待。Step S204: Determine whether there is a free block in the flash memory card, if yes, execute step S202; otherwise, continue to wait.
本申请实施例中,在闪存卡中没有缓存与所述待存储数据块的磁盘逻辑块地址相同的旧数据块时,先判断闪存卡中是否有空闲块,如果有空闲块,则直接对闪存卡发起异步写操作,将待存储数据块写入闪存卡中;如果没有空闲块,则进行等待,直到闪存卡中出现空闲块时,才向闪存卡发起异步写操作,将待存数数据块写入闪存卡的空闲块中。In the embodiment of the present application, when there is no old data block cached in the flash memory card that is identical to the disk logical block address of the data block to be stored, it is first judged whether there is a free block in the flash memory card, and if there is a free block, then directly to the flash memory The card initiates an asynchronous write operation, and writes the data block to be stored into the flash memory card; if there is no free block, it waits until a free block appears in the flash memory card, and then initiates an asynchronous write operation to the flash memory card, and writes the data block to be stored Write to a free block of the flash memory card.
上述实施例,在将所述待存储的数据块写入所述闪存卡中的空闲块后,还可以包括:The above embodiment, after writing the data block to be stored into the free block in the flash memory card, may also include:
保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。The corresponding relationship between the disk logical block address of the data block to be stored and the flash memory logical block address of the data block to be stored is saved.
其中,所述待存储数据块的闪存逻辑块地址就是所述待存储数据块在所述闪存卡中的逻辑块地址,也就是说,在所述缓存卡中没有缓存与所述待存储数据块的磁盘逻辑块地址对应的旧数据块时,在将待存储数据块写入缓存卡中的空闲块中后,保存待存储数据块的磁盘逻辑块地址与该待存储数据块在缓存卡中的逻辑块地址的对应关系。Wherein, the logical block address of the flash memory of the data block to be stored is the logical block address of the data block to be stored in the flash memory card, that is to say, there is no cache in the cache card related to the data block to be stored. When the old data block corresponding to the disk logic block address of the data block is stored, after the data block to be stored is written into the free block in the cache card, the disk logic block address of the data block to be stored and the address of the data block to be stored in the cache card are saved. Correspondence between logical block addresses.
具体在保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系时,可以使用哈希表,如表1所示:Specifically when saving the correspondence between the disk logical block address of the data block to be stored and the flash memory logical block address of the data block to be stored, a hash table can be used, as shown in Table 1:
表1哈希表Table 1 hash table
表1中,各个索引的值(Hn,n=1,2,3,…)是由磁盘逻辑块地址经过哈希算法获取的。DLBAm(m=1,2,3,…)表示磁盘逻辑块地址;FLBAp(p=1,2,3,…)表示闪存逻辑块地址;由于不同的磁盘逻辑块地址经过哈希运算后得到的可能是同一个索引值,所以,在一个索引值下,可能对应多个磁盘逻辑块地址和闪存逻辑块地址的对应关系(如表1所示,索引H1对应两个磁盘逻辑块地址和闪存逻辑块地址的对应关系)。本申请实施例中,为了减少冲突(即为了减少哈希表中同一个索引下对应关系的个数),将索引的个数设置为闪存卡中逻辑块地址个数的1.5倍。In Table 1, the values of each index (Hn, n=1, 2, 3, ...) are obtained from the logical block address of the disk through a hash algorithm. DLBAm (m=1, 2, 3, ...) indicates the disk logical block address; FLBAp (p = 1, 2, 3, ...) indicates the flash memory logical block address; because different disk logical block addresses are obtained after hashing It may be the same index value, so under one index value, it may correspond to the corresponding relationship between multiple disk logical block addresses and flash memory logical block addresses (as shown in Table 1, index H1 corresponds to two disk logical block addresses and flash memory logical block addresses Correspondence of block addresses). In the embodiment of the present application, in order to reduce conflicts (that is, to reduce the number of corresponding relationships under the same index in the hash table), the number of indexes is set to 1.5 times the number of logical block addresses in the flash memory card.
所述哈希算法可以为:磁盘逻辑块地址乘以一个无符号的32位的16进制整数,如所述无符号的32位的16进制整数可以为9e370001,然后,将磁盘逻辑块地址与无符号的32位的16进制整数的乘积对闪存卡中逻辑块地址的个数做取余运算,即可得到磁盘逻辑块地址所对应的哈希值(即索引值),由于磁盘逻辑块地址为32位的16进制数,因此,磁盘逻辑块地址对应的索引值也为32位的16进制数,具体的,可以按照第二公式确定,第二公式为:The hash algorithm can be as follows: the disk logic block address is multiplied by an unsigned 32-bit hexadecimal integer, such as the unsigned 32-bit hexadecimal integer can be 9e370001, and then the disk logic block address By multiplying the product with an unsigned 32-bit hexadecimal integer, the number of logical block addresses in the flash memory card is subtracted to obtain the hash value (ie index value) corresponding to the logical block address of the disk. The block address is a 32-bit hexadecimal number. Therefore, the index value corresponding to the logical block address of the disk is also a 32-bit hexadecimal number. Specifically, it can be determined according to the second formula, which is:
H=(DLBA*0x9e370001UL)%N,H=(DLBA*0x9e370001UL)%N,
其中,H表示磁盘逻辑块地址DLBA所对应的索引值;0x9e370001UL为无符号的32位的16进制整数9e370001;“%”表示对N做取余运算;N表示闪存卡中逻辑块地址的个数。Among them, H represents the index value corresponding to the disk logic block address DLBA; 0x9e370001UL is an unsigned 32-bit hexadecimal integer 9e370001; "%" represents the remainder operation on N; N represents the number of logic block addresses in the flash memory card number.
上述实施例,优选的,所述判断闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块可以包括:In the above embodiment, preferably, the judging whether there is an old data block cached in the flash memory card with the same address as the disk logical block address of the data block to be stored may include:
判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;Judging whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
如果存在,则确定所述闪存卡中缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;否则,确定所述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。If it exists, then determine that the same old data block as the disk logic block address of the data block to be stored is cached in the flash memory card; otherwise, it is determined that there is no disk logic block with the disk logic block of the data block to be stored in the flash memory card The old data block with the same address.
也就是说,本申请实施例通过磁盘逻辑块地址和闪存逻辑块地址之间的对应关系确定闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块,提高了写数据的速率。That is to say, the embodiment of the present application determines whether an old data block with the same old data block address as the disk logical block address of the data block to be stored is cached in the flash memory card through the correspondence between the disk logical block address and the flash memory logical block address, which improves the efficiency of writing data. s speed.
本申请实施例提供的又一种写高速缓冲存储器的方法的流程图如图3所示,在将所述待存储的数据块写入所述闪存卡后,还可以包括:The flow chart of another method for writing the cache memory provided by the embodiment of the present application is shown in FIG. 3. After writing the data block to be stored into the flash memory card, it may also include:
步骤S301:将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。Step S301: Mark the data block to be stored as a dirty data block, and add the data block to be stored into a queue of dirty data blocks.
本申请实施例提供的又一种写高速缓冲存储器的方法的流程图如图4所示,为了保证存储系统的有效性,当高速缓冲存储器中的存储的数据量达到一定值时,需要将高速缓存存储器中的数据写入到磁盘中,因此,本申请实施例提供的写高速缓冲存储器的方法还可以包括:The flow chart of another method for writing the cache memory provided by the embodiment of the present application is shown in Figure 4. In order to ensure the effectiveness of the storage system, when the amount of data stored in the cache memory reaches a certain value, the high-speed The data in the cache memory is written to the disk. Therefore, the method for writing the cache memory provided in the embodiment of the present application may further include:
步骤S401:获取所述闪存卡的当前空闲空间比例;Step S401: Obtain the current free space ratio of the flash memory card;
本申请实施例中,将闪存卡中脏数据块所占用的空间以外的空间称为空闲空间,那么,闪存卡的当前空闲空间比例为闪存卡内当前空闲空间占闪存卡总空间的比例。In the embodiment of the present application, the space other than the space occupied by dirty data blocks in the flash memory card is called free space, then the current free space ratio of the flash memory card is the ratio of the current free space in the flash memory card to the total space of the flash memory card.
步骤S402:判断所述空闲空间比例是否小于第一预设阈值,如果是,则执行步骤S403,否则,执行步骤S401;Step S402: judging whether the free space ratio is smaller than a first preset threshold, if yes, execute step S403, otherwise, execute step S401;
所述第一预设阈值可以为20%,当然,也可以根据实际需要进行设置,这里不做具体限定。The first preset threshold may be 20%, and of course, it may also be set according to actual needs, which is not specifically limited here.
步骤S403:确定待读取的脏数据块的个数;Step S403: Determine the number of dirty data blocks to be read;
所述待读取的脏数据块的个数即是需要从所述高速缓冲存储器中写入磁盘中的数据块的个数。所述待读取的脏数据块的个数可以依据所述空闲空间的比例确定,如,读取脏数据块后,所述闪存卡中空闲空间的比例大于第二预设阈值。所述第二预设阈值可以等于所述第一预设阈值,当然也可以大于所述第一预设阈值,这里不做具体限定。The number of dirty data blocks to be read is the number of data blocks that need to be written from the cache memory to the disk. The number of the dirty data blocks to be read may be determined according to the ratio of the free space, for example, after the dirty data blocks are read, the ratio of the free space in the flash memory card is greater than a second preset threshold. The second preset threshold may be equal to the first preset threshold, of course, may also be greater than the first preset threshold, which is not specifically limited here.
步骤S404:将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;Step S404: performing heap sorting on each dirty data block in the dirty data block queue according to the logical block address of the disk to obtain a first sorted heap;
为了提高将数据从高速缓冲存储器中写入磁盘中的效率,本申请实施例对脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,所述堆排序可以为最小堆排序,即第一排序堆的堆头为磁盘逻辑块地址最小的脏数据块;所述堆排序也可以为对大堆排序,即第一排序堆的堆头为磁盘逻辑块地址最大的脏数据块。In order to improve the efficiency of writing data from the cache memory to the disk, the embodiment of the present application performs heap sorting on each dirty data block in the dirty data block queue according to the logical block address of the disk, and the heap sorting can be a minimum heap sorting, That is, the heap head of the first sorting heap is the dirty data block with the smallest disk logical block address; the heap sorting can also be sorting a large heap, that is, the heap head of the first sorting heap is the dirty data block with the largest disk logical block address.
具体采用哪种排序方式可以根据磁盘的性能确定:如果磁盘支持按磁盘逻辑块地址从小到大的顺序访问,则可以选择最小堆排序;而如果磁盘支持按磁盘逻辑块地址从大到小的顺序访问,则可以选择最大堆排序;Which sorting method to use can be determined according to the performance of the disk: if the disk supports access in the order of disk logical block addresses from small to large, you can choose the minimum heap sort; and if the disk supports the order of disk logical block addresses from large to small Access, you can choose the maximum heap sort;
本步骤中,由于时对脏数据块队列中的所有脏数据块队列进行堆排序,所以,也可以称之为全局堆排序。In this step, since heap sorting is performed on all the dirty data block queues in the dirty data block queue, it can also be called global heap sorting.
步骤S405:发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆的堆头开始依次异步读取闪存卡中的脏数据块;Step S405: Initiate several first asynchronous requests, and sequentially asynchronously read the dirty data blocks in the flash memory card from the head of the first sorting heap according to the number of dirty data blocks to be read;
所述第一异步请求的个数可以为预设值;The number of the first asynchronous requests may be a preset value;
步骤S406:根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行对排序,获取第二排序堆;Step S406: sort the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks, and obtain a second sorting heap;
本步骤中,只对读取到的脏数据块进行堆排序,因此,也可以称为局部堆排序,需要说明的是,两次堆排序都使用相同的堆排序方式,即要么都采用最小堆排序,要么都使用最大堆排序。In this step, only the read dirty data blocks are heap sorted, so it can also be called partial heap sorting. It should be noted that both heap sorting uses the same heap sorting method, that is, both use the minimum heap Sort, or both use max heap sort.
步骤S407:发起第二异步请求,将所述读取到的脏数据块从第二对序列的堆头开始依次异步写入磁盘中,所述第二异步请求的个数为所述待读取的脏数据块的个数。Step S407: Initiate a second asynchronous request, and write the read dirty data blocks to the disk sequentially and asynchronously from the heap head of the second pair of sequences, and the number of the second asynchronous requests is the number of the to-be-read The number of dirty data blocks.
在将读取到的脏数据块写入磁盘中后,闪存卡中就有空闲空间了,此时,等待队列中的待存储数据就可以写入闪存卡了。After the read dirty data block is written into the disk, there is free space in the flash memory card. At this time, the data to be stored in the waiting queue can be written into the flash memory card.
需要说明的是,在进行最小堆排序的过程中,如果脏数据块队列中新增加的脏数据块的逻辑块地址小于堆头的数据块的逻辑块地址,则将该新增加的脏数据块加入到与该排序堆相对应的脏数据块等待队列中,当堆上的脏数据块都读完时,再对脏数据块等待队列中的脏数据块进行堆排序,以保证从闪存卡中读取的数据块都处于增序状态;如果脏数据块队列中新增加的脏数据块的逻辑块地址大于堆头的数据块的逻辑块地址,则将该新增加的脏数据块直接加入排序堆中进行最小堆排序。It should be noted that, in the process of sorting the minimum heap, if the logical block address of the newly added dirty data block in the dirty data block queue is smaller than the logical block address of the data block at the heap head, the newly added dirty data block Join the dirty data block waiting queue corresponding to the sorting heap, and when all the dirty data blocks on the heap have been read, perform heap sorting on the dirty data blocks in the dirty data block waiting queue to ensure that the The read data blocks are in ascending order; if the logical block address of the newly added dirty data block in the dirty data block queue is greater than the logical block address of the data block at the heap head, the newly added dirty data block will be directly added to the sorting Perform min-heap sort on the heap.
而在进行最大堆排序的过程中,如果脏数据块队列中新增加的脏数据块的逻辑块地址大于堆头的数据块的逻辑块地址,则将该新增加的脏数据块加入到与该排序堆相对应的脏数据块等待队列中,当堆上的脏数据块都读完时,再对脏数据块等待队列中的脏数据块进行堆排序,以保证从闪存卡中读取的数据块都处于降序状态;如果脏数据块队列中新增加的脏数据块的逻辑块地址小于堆头的数据块的逻辑块地址,则将该新增加的脏数据块直接加入到排序堆中进行最大堆排序。And in the process of carrying out the maximum heap sorting, if the logical block address of the newly added dirty data block in the dirty data block queue is greater than the logical block address of the data block at the heap head, then the newly added dirty data block is added to the In the dirty data block waiting queue corresponding to the sorting heap, when all the dirty data blocks on the heap have been read, heap sort the dirty data blocks in the dirty data block waiting queue to ensure that the data read from the flash memory card The blocks are in descending order; if the logical block address of the newly added dirty data block in the dirty data block queue is smaller than the logical block address of the data block at the heap head, the newly added dirty data block is directly added to the sorting heap for maximum Heap sort.
下面举例说明本实施例提供的将高速缓存存储器中的数据写入到磁盘中过程,请参看图5,图5为本申请实施例提供的将高速缓存存储器中的数据写入到磁盘中的过程的示意图;The following example illustrates the process of writing the data in the cache memory to the disk provided by this embodiment. Please refer to FIG. 5. FIG. 5 is the process of writing the data in the cache memory to the disk provided by the embodiment of the present application. schematic diagram;
本例中,脏数据块队列中有10个脏数据块,图中各个脏数据块中的标号为脏数据块的磁盘逻辑块地址;待读取的脏数据块的个数为5个,那么,当闪存卡中,空闲空间的比例小于第一预设阈值时,将该10个脏数据块进行最小堆排序,获得第一排序堆,第一排序堆的堆头为磁盘逻辑块地址为23的脏数据块,后续脏数据块的磁盘逻辑块地址依次为32、33、44、48、79、95、158、189、789;然后,以异步方式从所述第一排序堆的堆头开始,读取磁盘逻辑块地址最小的五个脏数据块,本例中,读取的五个脏数据块的磁盘逻辑块地址分别为:44、32、23、33、48;然后,对读取到的这五个脏数据再次进行最小堆排序,获得第二排序堆,第二排序堆的堆头依然为磁盘逻辑块地址为23的脏数据块,后续脏数据块的磁盘逻辑块地址依次为32、33、44、48;然后,从第二排序堆的堆头开始,将这五个脏数据块以异步方式写入到磁盘中。In this example, there are 10 dirty data blocks in the dirty data block queue, and the label in each dirty data block in the figure is the disk logical block address of the dirty data block; the number of dirty data blocks to be read is 5, then , when the proportion of free space in the flash memory card is less than the first preset threshold, the 10 dirty data blocks are sorted by the minimum heap to obtain the first sorted heap, the heap head of the first sorted heap is the logical block address of the disk is 23 The dirty data blocks, the disk logical block addresses of subsequent dirty data blocks are 32, 33, 44, 48, 79, 95, 158, 189, 789 in sequence; then, start from the heap head of the first sorting heap in an asynchronous manner , read the five dirty data blocks with the smallest logical block addresses on the disk. In this example, the disk logical block addresses of the five dirty data blocks read are: 44, 32, 23, 33, and 48; The five dirty data obtained are sorted by the minimum heap again to obtain the second sorted heap. The heap head of the second sorted heap is still the dirty data block with disk logical block address 23, and the disk logical block addresses of subsequent dirty data blocks are 32, 33, 44, 48; then, starting from the heap head of the second sorting heap, write these five dirty data blocks to the disk in an asynchronous manner.
本申请实施例中,在将高速缓冲存储器中的数据写入磁盘中时,采用全局堆排序和局部堆排序,并为全局排序堆和局部排序堆都维护了一个等待队列(其中,全局排序堆对应脏数据块队列,局部排序堆对应脏数据块等待队列)保证数据块从高速缓冲存储器中写入磁盘时的顺序性,提高了数据从高速缓冲存储器写入到磁盘中的效率,即提高了刷盘效率。In the embodiment of the present application, when the data in the cache memory is written to the disk, the global sorting heap and the local heap sorting are adopted, and a waiting queue is maintained for both the global sorting heap and the local sorting heap (the global sorting heap Corresponding to the dirty data block queue, the local sorting heap corresponds to the dirty data block waiting queue) to ensure the order of data blocks written from the cache memory to the disk, and improve the efficiency of data writing from the cache memory to the disk, that is, to improve Brush efficiency.
上述实施例,优选的,所述第一异步请求的个数也可以通过如下方式确定:In the above embodiment, preferably, the number of the first asynchronous requests may also be determined in the following manner:
所述第一异步请求的个数也可以根据预设的异步请求个数的上限和下限,以及高速缓冲存储器的空间利用率确定,假设第一异步请求的个数的下限为N,即第一异步请求最少可以发起N个,第一异步请求的个数的上限为M,即第一异步请求最多可以发起M个,高速缓冲存储器的空间利用率为R,那么,第一异步请求的个数可以依据第一公式确定,其中,第一公式为:The number of the first asynchronous requests can also be determined according to the preset upper limit and lower limit of the number of asynchronous requests, and the space utilization rate of the cache memory, assuming that the lower limit of the number of the first asynchronous requests is N, that is, the first At least N asynchronous requests can be initiated, the upper limit of the number of the first asynchronous request is M, that is, the first asynchronous request can be initiated at most M, and the space utilization rate of the cache memory is R, then, the number of the first asynchronous request It can be determined according to the first formula, wherein the first formula is:
V=N+(M-N)*RV=N+(M-N)*R
其中,V为第一异步请求的个数;R=1-P,P为闪存卡中空闲空间的比例。Wherein, V is the number of first asynchronous requests; R=1-P, and P is the proportion of free space in the flash memory card.
具体的,N的取值可以为4,M的取值可以为256。Specifically, the value of N may be 4, and the value of M may be 256.
本申请实施例中,根据高速缓冲存储器的空间利用率动态调整第一异步请求的个数,使得在高速缓冲存储器的空间利用率较小的时候以较少的异步请求对磁盘进行操作,而在高速缓冲存储器的空间利用率较大时,以较多的异步请求对磁盘进行操作,而由于异步请求的个数越多,速率越快,对磁盘的操作也就越多,因此,本申请实施例既保证在空间利用率较大时(即空间比较紧张时)以较快的速率将高速缓冲存储器中的数据写入到磁盘中,即在空间利用率较大时,以较快的速率回收缓存空间;又可以保证在空间利用较小时(即空间不紧张时),减少了对磁盘的操作,以减少由于对磁盘的读或写对磁盘造成的损害。In the embodiment of the present application, the number of first asynchronous requests is dynamically adjusted according to the space utilization rate of the cache memory, so that when the space utilization rate of the cache memory is small, fewer asynchronous requests are used to operate the disk, while in When the space utilization rate of the cache memory is large, the disk is operated with more asynchronous requests, and because the more the number of asynchronous requests, the faster the speed, the more operations are performed on the disk. Therefore, the application implements For example, it ensures that the data in the cache memory is written to the disk at a faster rate when the space utilization rate is high (that is, when the space is relatively tight), that is, the data in the cache memory is recycled at a faster rate when the space utilization rate is high. Cache space; it can also ensure that when the space utilization is small (that is, when the space is not tight), the operation on the disk is reduced, so as to reduce the damage to the disk caused by reading or writing to the disk.
与方法实施例相对应,本申请实施例提供的一种写高速缓冲存储器的装置的结构示意图如图6所示,其中所述高速缓冲存储器为闪存卡,所述装置可以包括:Corresponding to the method embodiment, a schematic structural diagram of a device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 6, wherein the cache memory is a flash memory card, and the device may include:
判断模块601,第一写模块602和第二写模块603;A judging module 601, a first writing module 602 and a second writing module 603;
判断模块601用于判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;The judging module 601 is used to judge whether there is an old data block with the same old data block address as the disk logical block address of the data block to be stored in the flash memory card;
第一写模块602用于在所述判断模块601判断出所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块时,将所述待存储数据块以异步方式写入所述闪存卡中;The first writing module 602 is used to write the data block to be stored in asynchronous manner mode to write in the flash memory card;
第二写模块603用于在所述判断模块601判断出所述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块时,将所述待存储数据块以异步方式写入所述闪存卡的空闲块中。The second writing module 603 is used to write the data block to be stored as Asynchronously write to the free block of the flash memory card.
本申请实施例提供的另一种写高速缓冲存储器的装置的结构示意图如图7所示,所述第二写模块603可以包括:A schematic structural diagram of another device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 7 , and the second writing module 603 may include:
第一判断单元701,第一写单元702和第二写单元703;A first judging unit 701, a first writing unit 702 and a second writing unit 703;
第一判断单元701用于判断所述闪存卡中是否存在空闲块;The first judging unit 701 is used to judge whether there is a free block in the flash memory card;
第一写单元702用于在所述第一判断单元701判断出所述闪存卡中存在空闲块时,将所述待存储数据块以异步方式写入所述闪存卡的空闲块中。The first writing unit 702 is configured to asynchronously write the data block to be stored into the free block of the flash memory card when the first judging unit 701 judges that there is a free block in the flash memory card.
第二写单元703用于在所述判断单元判断出所述闪存卡中不存在空闲块时,将所述待存储数据加入等待队列,并在所述闪存卡中出现空闲块时,将所述待存储数据块以异步方式写入所述闪存卡的空闲块中。The second writing unit 703 is used to add the data to be stored to a waiting queue when the judging unit judges that there is no free block in the flash memory card, and write the data to the waiting queue when there is a free block in the flash memory card. The data block to be stored is written into the free block of the flash memory card in an asynchronous manner.
本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图如图8所示,还可以包括:A schematic structural diagram of another device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 8 , and may further include:
保存模块801,用于在所述第二写模块603将所述待存储数据块写入所述闪存卡中的空闲块后,保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。The saving module 801 is used to save the disk logical block address of the data block to be stored and the data block to be stored after the second writing module 603 writes the data block to be stored into a free block in the flash memory card. Corresponding relationship of the logical block address of the flash memory of the data block.
在图8所示实施例的基础上,本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图如图9所示,所述判断模块601可以包括:On the basis of the embodiment shown in FIG. 8 , a schematic structural diagram of another device for writing a cache memory provided in the embodiment of the present application is shown in FIG. 9 , and the judging module 601 may include:
第二判断单元901,第三判断单元902和第四判断单元903;The second judging unit 901, the third judging unit 902 and the fourth judging unit 903;
第二判断单元901用于判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;The second judging unit 901 is used to judge whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
第三判断单元902用于在所述第二判断单元901判断出存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址时,确定所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块;The third judging unit 902 is used to determine that the flash memory card caches the flash memory logical block address corresponding to the disk logical block address of the data block to be stored when the second judging unit 901 judges that there is a The old data block with the same disk logical block address as the data block to be stored;
第四判断单元903用于在所述第二判断单元901判断出不存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址时,确定所述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。The fourth judging unit 903 is used to determine that there is no flash memory card cached with The old data block with the same disk logical block address as the data block to be stored.
本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图如图10所示,还可以包括:A schematic structural diagram of another device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 10 , and may further include:
标记模块1001,用于在所述第一写模块602或所述第二写模块603将所述待存储数据块写入闪存卡后,将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。A marking module 1001, configured to mark the data block to be stored as a dirty data block after the first writing module 602 or the second writing module 603 writes the data block to be stored into the flash memory card, and The data block to be stored is added to the dirty data block queue.
本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图如图11所示,还可以包括:A schematic structural diagram of another device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 11 , and may further include:
获取模块1101,确定模块1102,第一排序模块1103,第一读模块1104,第二排序模块1105,第三写模块1106;Obtaining module 1101, determining module 1102, first sorting module 1103, first reading module 1104, second sorting module 1105, third writing module 1106;
获取模块1101用于获取所述闪存卡的当前空闲空间比例;The obtaining module 1101 is used to obtain the current free space ratio of the flash memory card;
确定模块1102用于当所述空闲空间比例小于第一预设阈值时,确定待读取的脏数据的个数;The determining module 1102 is configured to determine the number of dirty data to be read when the free space ratio is less than a first preset threshold;
第一排序模块1103用于将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;The first sorting module 1103 is configured to perform heap sorting on each dirty data block in the dirty data block queue according to the disk logic block address, and obtain a first sorting heap;
第一读模块1104用于发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆的堆头开始依次异步读取闪存卡中的脏数据块;The first reading module 1104 is used for initiating several first asynchronous requests, according to the number of the dirty data blocks to be read from the heap head of the first sorting heap to asynchronously read the dirty data blocks in the flash memory card sequentially ;
第二排序模块1105用于根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行对排序,获取第二排序堆;The second sorting module 1105 is configured to sort the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks, and obtain a second sorting heap;
第三写模块1106用于发起第二异步请求,将所述读取到的脏数据块从所述第二排序堆的堆头开始依次写入磁盘中,其中,所述第二异步请求的个数为所述待读取的脏数据块的个数。The third writing module 1106 is configured to initiate a second asynchronous request, and write the read dirty data blocks to the disk sequentially starting from the heap head of the second sorting heap, wherein each of the second asynchronous request The number is the number of dirty data blocks to be read.
本申请实施例提供的又一种写高速缓冲存储器的装置的结构示意图如图12所示,其中,所述高速缓冲存储器为闪存卡,所述装置可以包括:A schematic structural diagram of another device for writing a cache memory provided in an embodiment of the present application is shown in FIG. 12 , wherein the cache memory is a flash memory card, and the device may include:
至少一个处理器1201,以及与所述至少一个处理器耦合的存储器1202;at least one processor 1201, and a memory 1202 coupled to the at least one processor;
所述至少一个处理器被配置为:The at least one processor is configured to:
判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块;Judging whether the old data block with the same old data block address as the disk logical block address of the data block to be stored is cached in the flash memory card;
如果有,则将所述待存储数据块以异步方式写入所述闪存卡中;If yes, then write the data block to be stored in the flash memory card in an asynchronous manner;
如果没有,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中。If not, write the data block to be stored into a free block in the flash memory card in an asynchronous manner.
上述实施例,优选的,被配置为将所述待存储数据块写入所述闪存卡的空闲块中的至少一个处理器进一步可以被配置为:In the above embodiment, preferably, at least one processor configured to write the data block to be stored into a free block of the flash memory card may further be configured to:
判断所述闪存卡中是否存在空闲块;Judging whether there is a free block in the flash memory card;
如果存在,则将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中;If it exists, then write the data block to be stored in a free block in the flash memory card in an asynchronous manner;
如果不存在,则将所述待存储数据块加入到等待队列,并在所述闪存卡中出现空闲块时,执行将所述待存储数据块以异步方式写入所述闪存卡中的空闲块中的步骤。If it does not exist, the data block to be stored is added to the waiting queue, and when a free block occurs in the flash memory card, the data block to be stored is written into the free block in the flash memory card in an asynchronous manner in the steps.
上述实施例,优选的,所述至少一个处理器进一步可以被配置为:In the above embodiment, preferably, the at least one processor may be further configured to:
在将所述待存储的数据块写入所述闪存卡中的空闲块后,保存所述待存储数据块的磁盘逻辑块地址和所述待存储数据块的闪存逻辑块地址的对应关系。After the data block to be stored is written into the free block in the flash memory card, the corresponding relationship between the disk logical block address of the data block to be stored and the flash memory logical block address of the data block to be stored is saved.
上述实施例,优选的,被配置为判断所述闪存卡中是否缓存有与待存储数据块的磁盘逻辑块地址相同的旧数据块的至少一个处理器进一步可以被配置为:In the above embodiment, preferably, at least one processor configured to judge whether an old data block with the same old data block address as the disk logical block address of the data block to be stored is cached in the flash memory card may further be configured to:
判断是否存在与所述待存储数据块的磁盘逻辑块地址相对应的闪存逻辑块地址;Judging whether there is a flash memory logical block address corresponding to the disk logical block address of the data block to be stored;
如果存在,则确定所述闪存卡中缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块;否则,确定所述述闪存卡中未缓存有与所述待存储数据块的磁盘逻辑块地址相同的旧数据块。If it exists, then determine that the same old data block as the disk logical block address of the data block to be stored is cached in the flash memory card; otherwise, determine that there is no cache with the data block to be stored in the flash memory card The old data block with the same disk logical block address.
上述实施例,优选的,所述至少一个处理器进一步可以被配置为:In the above embodiment, preferably, the at least one processor may be further configured to:
在将所述待存储的数据块写入所述闪存卡后,将所述待存储数据块标记为脏数据块,并将所述待存储数据块加入脏数据块队列。After the data block to be stored is written into the flash memory card, the data block to be stored is marked as a dirty data block, and the data block to be stored is added to a queue of dirty data blocks.
上述实施例,优选的,所述至少一个处理器进一步可以被配置为:In the above embodiment, preferably, the at least one processor may be further configured to:
获取所述闪存卡的当前空闲空间比例;Obtain the current free space ratio of the flash memory card;
当所述空闲空间的比例小于第一预设阈值时,确定待读取的脏数据块的个数;When the ratio of the free space is less than a first preset threshold, determine the number of dirty data blocks to be read;
将所述脏数据块队列中的各个脏数据块按照磁盘逻辑块地址进行堆排序,获取第一排序堆;performing heap sorting on each dirty data block in the dirty data block queue according to the disk logic block address, and obtaining a first sorting heap;
发起若干个第一异步请求,依据所述待读取的脏数据块的个数从所述第一排序堆堆头开始依次异步读取闪存卡中的脏数据块;Initiate several first asynchronous requests, and read the dirty data blocks in the flash memory card sequentially asynchronously from the head of the first sorting pile according to the number of dirty data blocks to be read;
根据读取到的脏数据块的磁盘逻辑块地址将读取到的脏数据块进行堆排序,获取第二排序堆;Perform heap sorting on the read dirty data blocks according to the disk logical block addresses of the read dirty data blocks to obtain a second sorting heap;
发起第二异步请求,将所述读取到的脏数据块从第二排序堆的堆头开始依次异步写入磁盘中,所述第二异步请求的个数为所述待读取的脏数据块的个数。Initiate a second asynchronous request to asynchronously write the read dirty data blocks to the disk sequentially from the heap head of the second sorting heap, and the number of the second asynchronous request is the dirty data to be read the number of blocks.
本申请实施例可以应用与一体机系统中的Cache架构,与现有技术中的一体机系统中的Cache架构不同,本申请实施例提供的一体机系统中用FLASH存储器替代NVDIMM(Non-Volatile DIMM,一种非易失性内存)作为高速缓冲存储器,如图13所示;The embodiment of the present application can be applied to the Cache architecture in the all-in-one system. Unlike the Cache architecture in the all-in-one system in the prior art, the all-in-one system provided by the embodiment of the present application uses FLASH memory instead of NVDIMM (Non-Volatile DIMM , a non-volatile memory) as a cache memory, as shown in Figure 13;
在一体机的Cache架构中,Cache不存在于业务处理模块,而是存在于各个存储节点中,业务处理模块的功能与现有技术中相同,主要用于I/O(输入/输出)请求的分发处理。I/O请求通过业务处理模块的分发,就可以找到其访问的存储区域所在的是哪个存储节点。In the Cache architecture of the all-in-one machine, the Cache does not exist in the business processing module, but exists in each storage node. The function of the business processing module is the same as that in the prior art, and it is mainly used for I/O (input/output) requests. Distribution processing. By distributing the I/O request through the service processing module, it is possible to find out which storage node the storage area accessed by it is located.
存储节点时I/O请求的处理单元,每一个存储节点中包含自己独立的CPU、独立的Cache,以及一块或者几块磁盘,每个存储节点的磁盘数和Cache大小完全相同,所有的存储节点构成整个存储系统的存储池。A storage node is a processing unit for I/O requests. Each storage node contains its own independent CPU, independent Cache, and one or several disks. The number of disks in each storage node is exactly the same as the size of the Cache. All storage nodes The storage pools that make up the entire storage system.
本申请实施例中,对于一体机系统的写请求,通过业务处理模块的路由到达存储节点,存储节点内的CPU通过本申请实施例提供的写高速缓冲存储器的方法,将写请求写入FLASH存储器后返回“写成功”信息。当FLASH存储器的写数据量达到一定程度时,再通过本申请实施例提供的写高速缓冲存储器的方法,将FLASH存储器的写数据刷新到磁盘中,以回收FLASH存储器上的空间,供后续的写请求使用。In the embodiment of the present application, the write request of the all-in-one system reaches the storage node through the route of the service processing module, and the CPU in the storage node writes the write request into the FLASH memory through the method of writing the cache memory provided in the embodiment of the present application After that, the message "Write Successfully" is returned. When the amount of written data in the FLASH memory reaches a certain level, the write data in the FLASH memory is refreshed to the disk through the method for writing the cache memory provided by the embodiment of the present application, so as to reclaim the space on the FLASH memory for subsequent writing. Request to use.
本申请实施例也可以用于块存储磁盘阵列中,与现有技术中的块存储磁盘阵列不同,本申请实施例提供的阵列存储系统中用FLASH存储器替代NVRAM(Non-Volatile RandomAccess Memory,非易失性随机访问存储器)作为高速缓冲存储器,如图14所示。The embodiments of the present application can also be used in block storage disk arrays. Unlike the block storage disk arrays in the prior art, the array storage system provided by the embodiments of the present application uses FLASH memory instead of NVRAM (Non-Volatile Random Access Memory, non-volatile volatile random access memory) as a cache memory, as shown in Figure 14.
在块存储磁盘阵列一般采用一拖N(即负责业务处理的机头+N台多盘位的磁盘簇的方式组成整体的存储系统),高速缓冲存储器存在于存储系统的机头部分,机头中的高速缓冲存储器承载着后面左右扩展柜磁盘的I/O缓存功能,机头与磁盘簇一般通过SAS总线连接。本申请实施例中,机头部分的CPU实现写高速缓冲存储器的功能。The block storage disk array generally adopts one dragging N (that is, the head responsible for business processing + N multi-disk disk clusters to form an overall storage system), the cache memory exists in the head part of the storage system, and the head The high-speed cache memory in the computer carries the I/O cache function of the disks in the left and right expansion cabinets at the back, and the machine head and the disk cluster are generally connected through the SAS bus. In the embodiment of the present application, the CPU of the head part realizes the function of writing the cache memory.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,以上所述的本发明实施方式,并不构成对本发明保护范围的限定。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明的权利要求保护范围之内。The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be directly implemented by hardware, software modules executed by a processor, or a combination of both. The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the embodiments of the present invention described above are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the claims of the present invention.
Claims (18)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310400488.2A CN103488582B (en) | 2013-09-05 | 2013-09-05 | Write the method and device of cache memory |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310400488.2A CN103488582B (en) | 2013-09-05 | 2013-09-05 | Write the method and device of cache memory |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103488582A CN103488582A (en) | 2014-01-01 |
CN103488582B true CN103488582B (en) | 2017-07-28 |
Family
ID=49828830
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310400488.2A Active CN103488582B (en) | 2013-09-05 | 2013-09-05 | Write the method and device of cache memory |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103488582B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105095116B (en) * | 2014-05-19 | 2017-12-12 | 华为技术有限公司 | Cache method, cache controller and the processor replaced |
CN105988719B (en) * | 2015-02-07 | 2019-03-01 | 深圳市硅格半导体有限公司 | Storage device and its method for handling data |
CN105117351B (en) * | 2015-09-08 | 2018-07-03 | 华为技术有限公司 | To the method and device of buffering write data |
CN109189726B (en) * | 2018-08-08 | 2020-12-22 | 奇安信科技集团股份有限公司 | A processing method and device for reading and writing logs |
CN109783023B (en) * | 2019-01-04 | 2024-06-07 | 平安科技(深圳)有限公司 | Method and related device for data scrubbing |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5636355A (en) * | 1993-06-30 | 1997-06-03 | Digital Equipment Corporation | Disk cache management techniques using non-volatile storage |
CN1527973A (en) * | 2000-06-23 | 2004-09-08 | 英特尔公司 | Non-volatile cache |
CN1862475A (en) * | 2005-07-15 | 2006-11-15 | 华为技术有限公司 | Method for managing magnetic disk array buffer storage |
CN102136274A (en) * | 2009-12-30 | 2011-07-27 | 爱国者电子科技有限公司 | Mobile hard disk with two storage media |
CN102169464A (en) * | 2010-11-30 | 2011-08-31 | 北京握奇数据系统有限公司 | Caching method and device used for non-volatile memory, and intelligent card |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102004706B (en) * | 2009-09-01 | 2012-09-19 | 联芯科技有限公司 | Flash erasing power-fail protection method based on FTL(Flash Translation Layer) |
CN102981783A (en) * | 2012-11-29 | 2013-03-20 | 浪潮电子信息产业股份有限公司 | Cache accelerating method based on Nand Flash |
-
2013
- 2013-09-05 CN CN201310400488.2A patent/CN103488582B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5636355A (en) * | 1993-06-30 | 1997-06-03 | Digital Equipment Corporation | Disk cache management techniques using non-volatile storage |
CN1527973A (en) * | 2000-06-23 | 2004-09-08 | 英特尔公司 | Non-volatile cache |
CN1862475A (en) * | 2005-07-15 | 2006-11-15 | 华为技术有限公司 | Method for managing magnetic disk array buffer storage |
CN102136274A (en) * | 2009-12-30 | 2011-07-27 | 爱国者电子科技有限公司 | Mobile hard disk with two storage media |
CN102169464A (en) * | 2010-11-30 | 2011-08-31 | 北京握奇数据系统有限公司 | Caching method and device used for non-volatile memory, and intelligent card |
Also Published As
Publication number | Publication date |
---|---|
CN103488582A (en) | 2014-01-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108804350B (en) | A memory access method and computer system | |
CN104461393B (en) | Mixed mapping method of flash memory | |
CN105095116B (en) | Cache method, cache controller and the processor replaced | |
CN109753231B (en) | Key-value storage device and method for operating the same | |
US10754785B2 (en) | Checkpointing for DRAM-less SSD | |
US10860494B2 (en) | Flushing pages from solid-state storage device | |
CN103019955B (en) | The EMS memory management process of PCR-based AM main memory application | |
US20150032938A1 (en) | System and method for performing efficient processing of data stored in a storage node | |
WO2017041570A1 (en) | Method and apparatus for writing data to cache | |
CN103488582B (en) | Write the method and device of cache memory | |
CN109952565B (en) | memory access technology | |
CN115794669A (en) | Method, device and related equipment for expanding memory | |
CN104461964A (en) | Memory device | |
CN109164976B (en) | Optimizing storage device performance using write caching | |
CN108762671A (en) | Hybrid memory system based on PCM and DRAM and management method thereof | |
CN108153682B (en) | Method for mapping addresses of flash translation layer by utilizing internal parallelism of flash memory | |
CN103838676A (en) | Data storage system, data storage method and PCM bridge | |
CN104575595A (en) | Nonvolatile random access memory device | |
CN102999441B (en) | Fine granularity memory access method | |
TW202219773A (en) | Method for establishing look-up table and inquiring memory address, method for establishing host memory address look-up table, and method for inquiring host memory address | |
CN107766002A (en) | A Virtual Hybrid File System Based on Hybrid Storage Devices | |
CN105630699B (en) | A kind of solid state hard disk and read-write cache management method using MRAM | |
CN104834606A (en) | Heterogeneous confusion hierarchical memory device | |
CN105608014B (en) | A kind of storage device using MRAM | |
KR20130117266A (en) | Memory system and operating method the same |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C41 | Transfer of patent application or patent right or utility model | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20160726 Address after: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Applicant after: Huawei Technologies Co., Ltd. Address before: Building 2, B District, Bantian HUAWEI base, Longgang District, Shenzhen, Guangdong Applicant before: Shenzhen Huawei Technologies Co., Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |