CN114840364A - Method and device for backing up storage data in memory and electronic equipment - Google Patents
Method and device for backing up storage data in memory and electronic equipment Download PDFInfo
- Publication number
- CN114840364A CN114840364A CN202210506772.7A CN202210506772A CN114840364A CN 114840364 A CN114840364 A CN 114840364A CN 202210506772 A CN202210506772 A CN 202210506772A CN 114840364 A CN114840364 A CN 114840364A
- Authority
- CN
- China
- Prior art keywords
- storage unit
- backup
- data
- memory
- address
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 238000013507 mapping Methods 0.000 claims description 96
- 238000004590 computer program Methods 0.000 claims description 12
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000013500 data storage Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 10
- 230000008569 process Effects 0.000 description 3
- 238000007726 management method Methods 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
Description
技术领域technical field
本公开涉及数据存储技术,尤其涉及一种对内存中的存储数据进行备份的方法、装置及电子设备。The present disclosure relates to data storage technologies, and in particular, to a method, an apparatus and an electronic device for backing up stored data in a memory.
背景技术Background technique
目前,很多业务功能都是服务器提供的,而服务器的稳定性对业务质量的影响是重大的。At present, many business functions are provided by the server, and the stability of the server has a significant impact on the quality of the business.
若服务器的内存出现错误,则服务器容易出现宕机的问题。尤其是在内存出现了UE(Uncorrectable Errors,不可纠正的错误)类错误时,服务器很可能被自动重启,进而导致业务中断If there is an error in the memory of the server, the server is prone to downtime. Especially when a UE (Uncorrectable Errors, uncorrectable error) type error occurs in the memory, the server is likely to be automatically restarted, resulting in business interruption.
因此,如何在服务器的内存出现了UE类错误时仍然能够正常处理业务,是需要解决的技术问题。Therefore, how to still process services normally when a UE-type error occurs in the memory of the server is a technical problem that needs to be solved.
发明内容SUMMARY OF THE INVENTION
本公开提供一种对内存中的存储数据进行备份的方法、装置及电子设备,以解决现有技术中UE类错误导致服务器无法正常处理业务的问题。The present disclosure provides a method, an apparatus and an electronic device for backing up stored data in a memory, so as to solve the problem in the prior art that a server cannot normally process services due to UE-type errors.
本公开的第一个方面是提供一种对内存中的存储数据进行备份的方法,在内存中预先设置备份空间;A first aspect of the present disclosure is to provide a method for backing up stored data in a memory, and a backup space is preset in the memory;
所述方法包括:从内存的存储单元读取数据时,若确定所述存储单元存在发生不可纠正的错误的风险,则将所述存储单元中的数据写入所述备份空间,并确定所述存储单元所在的内存地址与所述数据在所述备份空间中的备份地址对应;The method includes: when reading data from a storage unit of the memory, if it is determined that the storage unit has a risk of uncorrectable errors, writing the data in the storage unit into the backup space, and determining the storage unit. The memory address where the storage unit is located corresponds to the backup address of the data in the backup space;
若再次从所述存储单元读取数据时发生了不可纠正的错误,则根据所述存储单元所在的内存地址所对应的备份地址,从所述备份空间中读取数据。If an uncorrectable error occurs when data is read from the storage unit again, the data is read from the backup space according to the backup address corresponding to the memory address where the storage unit is located.
本公开的第二个方面是提供一种对内存中的存储数据进行备份的装置,在内存中预先设置备份空间;A second aspect of the present disclosure is to provide a device for backing up stored data in a memory, and a backup space is preset in the memory;
所述装置包括:The device includes:
备份单元,用于从内存的存储单元读取数据时,若确定所述存储单元存在发生不可纠正的错误的风险,则将所述存储单元中的数据写入所述备份空间,并确定所述存储单元所在的内存地址与所述数据在所述备份空间中的备份地址对应;The backup unit is configured to write the data in the storage unit into the backup space if it is determined that there is a risk of uncorrectable errors occurring in the storage unit when reading data from the storage unit of the memory, and determine the storage unit. The memory address where the storage unit is located corresponds to the backup address of the data in the backup space;
备份数据读取单元,用于若再次从所述存储单元读取数据时发生了不可纠正的错误,则根据与所述存储单元所在的内存地址所对应的备份地址,从所述备份空间中读取数据。A backup data reading unit, configured to read from the backup space according to the backup address corresponding to the memory address where the storage unit is located if an uncorrectable error occurs when reading data from the storage unit again fetch data.
本公开的第三个方面是提供一种电子设备,包括:A third aspect of the present disclosure is to provide an electronic device, comprising:
存储器;memory;
处理器;以及processor; and
计算机程序;Computer program;
其中,所述计算机程序存储在所述存储器中,并配置为由所述处理器执行以实现如上述第一方面所述的对内存中的存储数据进行备份的方法。Wherein, the computer program is stored in the memory and configured to be executed by the processor to implement the method for backing up stored data in the memory as described in the first aspect above.
本公开第四个方面是提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行以实现如上述第一方面所述的对内存中的存储数据进行备份的方法。A fourth aspect of the present disclosure is to provide a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor to implement the method of backing up stored data in a memory as described in the first aspect above method.
本公开提供的对内存中的存储数据进行备份的方法、装置及电子设备的技术效果是:The technical effects of the method, device and electronic device for backing up stored data in memory provided by the present disclosure are:
本实施例提供的对内存中的存储数据进行备份的方法、装置及电子设备,在内存中预先设置备份空间;包括:从内存的存储单元读取数据时,若确定存储单元存在发生不可纠正的错误的风险,则将存储单元中的数据写入备份空间,并确定存储单元所在的内存地址与数据在备份空间中的备份地址之间对应;若再次从存储单元读取数据时发生了不可纠正的错误,则根据所述存储单元所在的内存地址所对应的备份地址,从所述备份空间中读取数据。本公开提供的方案中,可以利用内存的空间对存储单元的数据进行备份,且存储单元的大小可以根据需求设置,使得电子设备能够对内存中分散的可能存在UE错误的存储单元中的数据进行备份,以解决由于内存UE错误导致系统宕机的问题。The method, device and electronic device for backing up stored data in a memory provided by this embodiment, a backup space is preset in the memory; including: when reading data from a storage unit in the memory, if it is determined that there is an uncorrectable error in the storage unit If there is a risk of errors, write the data in the storage unit into the backup space, and determine the correspondence between the memory address where the storage unit is located and the backup address of the data in the backup space; if an uncorrectable error occurs when reading data from the storage unit again error, read data from the backup space according to the backup address corresponding to the memory address where the storage unit is located. In the solution provided by the present disclosure, the data of the storage unit can be backed up by using the space of the memory, and the size of the storage unit can be set according to the requirements, so that the electronic device can perform data backup on the data in the storage units scattered in the memory that may have UE errors. Backup to fix system downtime due to memory UE error.
附图说明Description of drawings
图1为本公开一示例性实施例示出的对内存中的存储数据进行备份的方法的流程示意图;FIG. 1 is a schematic flowchart of a method for backing up stored data in a memory according to an exemplary embodiment of the present disclosure;
图2为本公开另一示例性实施例示出的对内存中的存储数据进行备份的方法的流程图;FIG. 2 is a flowchart of a method for backing up stored data in a memory according to another exemplary embodiment of the present disclosure;
图3为本公开一示例性实施例示出的数据备份的示意图;3 is a schematic diagram of data backup according to an exemplary embodiment of the present disclosure;
图4为本公开另一示例性实施例示出的读取数据的示意图;4 is a schematic diagram of reading data according to another exemplary embodiment of the present disclosure;
图5为本公开一示例性实施例示出的对内存中的存储数据进行备份的装置的结构图;5 is a structural diagram of an apparatus for backing up stored data in a memory according to an exemplary embodiment of the present disclosure;
图6为本公开另一示例性实施例示出的对内存中的存储数据进行备份的装置的结构图;6 is a structural diagram of an apparatus for backing up stored data in a memory according to another exemplary embodiment of the present disclosure;
图7为本公开一示例性实施例示出的电子设备的结构图。FIG. 7 is a structural diagram of an electronic device according to an exemplary embodiment of the present disclosure.
具体实施方式Detailed ways
内存部件是计算机体系结构中直接向中央处理器提供数据缓存的关键部件,内存系统的故障,直接导致计算机的处理器停止响应,导致系统宕机。The memory component is a key component in the computer architecture that directly provides data cache to the central processing unit. The failure of the memory system directly causes the computer's processor to stop responding, resulting in system downtime.
内存的故障存在UE(Uncorrectable Errors,不可纠错的错误)类的错误,这类错误无法基于现有的ECC(“Error Correcting Code,错误检查和纠正)技术进行纠正,为了保证系统的可靠性和数据的准确性,系统极有可能重启。There are UE (Uncorrectable Errors, uncorrectable errors) errors in memory failures. Such errors cannot be corrected based on the existing ECC ("Error Correcting Code, Error Checking and Correction) technology. In order to ensure system reliability and The accuracy of the data, the system is very likely to restart.
若服务器中设置的内存由于UE错误导致重启,则会导致业务中断,进而带来不好的用户体验。If the memory set in the server is restarted due to a UE error, services will be interrupted, resulting in a bad user experience.
为了解决这一技术问题,可以基于内存镜像进行数据备份,当内存访问发生故障时,使用对应备份区块里的内容,但是,这种方式的缺点是备份空间要求连续,导致实现备份的最小单位比较大,导致用户可实际使用的内存空间降低。In order to solve this technical problem, data backup can be performed based on memory mirroring. When memory access fails, the content in the corresponding backup block is used. However, the disadvantage of this method is that the backup space is required to be continuous, resulting in the smallest unit of backup. It is relatively large, which reduces the memory space that the user can actually use.
另外一种方案中,内存中错误的bit(比特)可以被存在内存控制器里面的bit替换,然而内存控制器中的存储空间有限,导致这种单bit备份的方式成本过高,只能存放较少的备份bit。In another solution, the wrong bit (bit) in the memory can be replaced by the bit stored in the memory controller. However, the storage space in the memory controller is limited, resulting in the high cost of this single-bit backup method, which can only be stored Fewer backup bits.
还存在另一种方案中,可以利用内存中的冗余电路替换内容的坏行,具体可以将内存中的坏行重新映射到内置冗余的行上。但是,这种方式中用于备份的行数量有限,且这会增加硬件成本。In another solution, the redundant circuit in the memory can be used to replace the bad row of the content. Specifically, the bad row in the memory can be remapped to the row with built-in redundancy. However, this approach has a limited number of rows for backup, and this increases hardware costs.
为了解决上述技术问题,本公开提供的方案中,在内存中预先划分出备份空间,当确定存储单元所在的内存地址可能会发生UE错误时,可以将存储单元的数据写入备份空间,并确定存储单元所在的内存地址与备份地址之间的映射关系,从而实现对存储单元中的数据备份的目的。这种实现方式不会增加额外的硬件成本,且存储单元的大小可以根据需求设置,实现方式更加灵活。In order to solve the above technical problems, in the solution provided by the present disclosure, a backup space is pre-divided in the memory. When it is determined that a UE error may occur at the memory address where the storage unit is located, the data of the storage unit can be written into the backup space, and the determination of The mapping relationship between the memory address where the storage unit is located and the backup address, so as to realize the purpose of backing up the data in the storage unit. This implementation method does not increase additional hardware costs, and the size of the storage unit can be set according to requirements, and the implementation method is more flexible.
图1为本公开一示例性实施例示出的对内存中的存储数据进行备份的方法的流程示意图。FIG. 1 is a schematic flowchart of a method for backing up stored data in a memory according to an exemplary embodiment of the present disclosure.
本公开提供的方法可以应用在设置有内存的电子设备中,在电子设备开机时,电子设备可以在内存中划分出一块备份空间。比如,可以预先设置备份空间的大小,使得电子设备能够在内存中划分出相应大小的备份空间。该备份空间在内存中的地址可以是连续的地址,也可以是非连续的。The method provided by the present disclosure can be applied to an electronic device provided with a memory, and when the electronic device is powered on, the electronic device can divide a backup space in the memory. For example, the size of the backup space can be preset, so that the electronic device can divide the backup space of a corresponding size in the memory. The address of the backup space in the memory may be a continuous address or a non-continuous address.
如图1所示,本公开提供的对内存中的存储数据进行备份的方法,包括:As shown in FIG. 1 , the method for backing up stored data in memory provided by the present disclosure includes:
步骤101,从内存的存储单元读取数据时,若确定存储单元存在发生不可纠正的错误的风险,则将存储单元中的数据写入备份空间,并确定存储单元所在的内存地址与数据在备份空间中的备份地址对应。Step 101: When reading data from the storage unit of the memory, if it is determined that there is a risk of uncorrectable errors occurring in the storage unit, the data in the storage unit is written into the backup space, and it is determined that the memory address of the storage unit and the data are in the backup space. The backup address in the space corresponds.
其中,电子设备中的存储部件可以包括硬盘、内存、缓存等,其中,电子设备读取数据时可以先从缓存中读取,若缓存中没有则去内存中读取,若内存中还没有再去硬盘中读取。Among them, the storage components in the electronic device may include hard disks, memory, cache, etc., wherein, when the electronic device reads data, it can read data from the cache first, if there is no cache, read it from the memory, if there is no more data in the memory. read from the hard drive.
具体的,电子设备可以将比较常用的数据存储在缓存或内存中,以提高数据读取速度。因此,电子设备在运行时内存中通常存储有数据。Specifically, the electronic device may store the more commonly used data in the cache or the memory, so as to improve the data reading speed. Therefore, electronic devices typically have data stored in memory during runtime.
进一步的,当待读取的数据存储在内存中时,电子设备可以从内存中读取数据。比如,当用户操作对图片进行操作时,且该图片被存储在内存中,则电子设备可以从内存中读取该图片的数据。Further, when the data to be read is stored in the memory, the electronic device can read the data from the memory. For example, when a user operates a picture and the picture is stored in the memory, the electronic device can read the data of the picture from the memory.
实际应用时,内存可以被划分为多个存储单元,需要读取的数据可以分散在多个存储单元中,电子设备可以从这些存储单元中读取数据。存储单元的大小可以根据需求设置,比如可以是32B、64B、72B等。In practical applications, the memory can be divided into multiple storage units, the data to be read can be scattered in multiple storage units, and the electronic device can read data from these storage units. The size of the storage unit can be set according to requirements, for example, it can be 32B, 64B, 72B and so on.
一种可选的实现方式中,存储单元的大小可以是电子设备读取数据时最少的数据量大小。比如,电子设备将内存中的数据写入缓存时,每次最少写入64B(byte,字节),则存储单元的大小也为64B。In an optional implementation manner, the size of the storage unit may be the size of the smallest amount of data when the electronic device reads data. For example, when the electronic device writes the data in the memory into the cache, at least 64B (byte, byte) is written each time, and the size of the storage unit is also 64B.
另一种可选的实现方式中,存储单元的大小还可以基于需求设置,比如可以是64B*2,64B*3等。In another optional implementation manner, the size of the storage unit may also be set based on requirements, for example, it may be 64B*2, 64B*3, and so on.
其中,电子设备从存储单元中读取数据时,若确定存储单元存在发生UE错误的风险,则可以将该存储单元中的数据写入备份空间。Wherein, when the electronic device reads data from the storage unit, if it is determined that there is a risk of UE error occurring in the storage unit, the data in the storage unit can be written into the backup space.
具体的,电子设备可以采用现有技术中的方案确定存储单元是否存在发生UE错误的风险,比如,若一个存储单元出现了多次CE错误,则可以确定该存储单元存在发生UE错误的风险。Specifically, the electronic device can use the solutions in the prior art to determine whether the storage unit has the risk of UE errors. For example, if a storage unit has multiple CE errors, it can be determined that the storage unit has the risk of UE errors.
进一步的,存储单元具有对应的内存地址,比如,内存地址为0-63B的空间为第一个存储单元,内存地址为64-127B的空间为第二个存储单元。若内存地址为0-63B的空间出现过多次CE错误,比如第4个字节出现过一次CE错误,再比如第10个字节出现过8次CE错误,则可以确定内存地址为0-63B的空间存在发生UE错误的风险,进而确定内存地址为0-63B所对应的存储单元存在出现UE错误的风险。Further, the storage unit has a corresponding memory address. For example, a space with a memory address of 0-63B is the first storage unit, and a space with a memory address of 64-127B is the second storage unit. If the space with memory address 0-63B has CE errors many times, such as one CE error in the 4th byte, and 8 CE errors in the 10th byte, it can be determined that the memory address is 0- There is a risk of UE error occurring in the space of 63B, and it is further determined that there is a risk of UE error occurring in the storage unit corresponding to the memory address 0-63B.
实际应用时,若确定存储单元发生存在UE错误的风险,则将该存储单元中的数据备份到备份空间,具体可以将存储单元中的数据写入备份空间。In practical application, if it is determined that there is a risk of UE error in the storage unit, the data in the storage unit is backed up to the backup space, and specifically, the data in the storage unit may be written into the backup space.
其中,每次向备份空间写入存储单元中的数据时,可以依次在备份空间中写入数据,比如,确定了第一存储单元存在UE错误风险,则可以将第一存储单元中的数据写入备份空间,此后,若再次确定了第四存储单元存在UE错误风险,则可以将第四存储单元中的数据也写入备份空间,第四存储单元中的数据可以排在第一存储单元中的数据之后。Wherein, each time the data in the storage unit is written to the backup space, the data may be written in the backup space in sequence. For example, if it is determined that the first storage unit has a UE error risk, the data in the first storage unit may be written to After that, if it is determined again that the fourth storage unit has the risk of UE error, the data in the fourth storage unit can also be written into the backup space, and the data in the fourth storage unit can be arranged in the first storage unit. after the data.
具体的,若存储单元存在UE错误风险,则可以认为在该存储单元中存储的数据存在无法读取的风险,此时将该存储单元中的数据进行备份,能够在存储单元真的出现了UE错误时,从备份空间中读取相应的数据,以避免内存中的UE错误导致宕机的问题。Specifically, if there is a risk of UE errors in the storage unit, it can be considered that the data stored in the storage unit has a risk of being unreadable. At this time, backing up the data in the storage unit can prevent the UE from actually appearing in the storage unit. When there is an error, the corresponding data is read from the backup space to avoid the problem of downtime caused by UE errors in memory.
进一步的,将存储单元中的数据备份到备份空间之后,还可以确定数据的源地址与备份地址之间对应,比如,可以确定二者之间具有映射关系,具体可以将存储单元所在的内存地址确定为数据的源地址,将数据在备份空间中的地址作为备份地址。Further, after the data in the storage unit is backed up to the backup space, the correspondence between the source address of the data and the backup address can also be determined. For example, it can be determined that there is a mapping relationship between the two. Specifically, the memory address where the storage unit is located can be determined. It is determined as the source address of the data, and the address of the data in the backup space is used as the backup address.
比如,第一个存储单元的内存地址为0-63B,第一存储单元中的数据被写在备份空间中,该数据所在的地址为N-(N+63B),则确定地址(0-63B)与地址(N-(N+63B))对应。For example, the memory address of the first storage unit is 0-63B, the data in the first storage unit is written in the backup space, and the address of the data is N-(N+63B), then determine the address (0-63B ) corresponds to the address (N-(N+63B)).
实际应用时,若确定地址之间具有映射关系,则可以生成地址映射表,可以将确定的映射关系写入地址映射表中。In practical application, if it is determined that there is a mapping relationship between addresses, an address mapping table can be generated, and the determined mapping relationship can be written into the address mapping table.
这种实现方式中,可以以存储单元为单位备份数据,存储单元的粒度可以根据需求控制,例如可以控制为64B,从而可以备份最小读取粒度的数据。In this implementation, data can be backed up in units of storage units, and the granularity of the storage units can be controlled according to requirements, for example, can be controlled to 64B, so that data with the smallest read granularity can be backed up.
其中,存储单元所在的内存地址和数据的备份地址是指物理地址。The memory address where the storage unit is located and the backup address of the data refer to physical addresses.
步骤102,若再次从存储单元读取数据时发生了不可纠正的错误,则根据存储单元所在的内存地址所对应的备份地址,从备份空间中读取数据。Step 102: If an uncorrectable error occurs when data is read from the storage unit again, read data from the backup space according to the backup address corresponding to the memory address where the storage unit is located.
其中,若再次从存储单元读取数据时,发生了UE错误,则可以确定是否备份了该存储单元中的数据,若已备份,则可以从备份空间中读取相应的数据,以免系统宕机进而造成业务中断。Among them, if a UE error occurs when reading data from the storage unit again, it can be determined whether the data in the storage unit has been backed up, and if it has been backed up, the corresponding data can be read from the backup space to avoid system downtime resulting in business interruption.
具体可以确定与存储单元所在的内存地址对应的备份地址,并基于该备份地址从备份空间中读取相应的数据。比如,第一源地址与第一备份地址对应,从存储单元读取数据时发生了UE错误,该存储单元所在的内存地址为第一源地址,则可以从备份空间中的第一备份地址读取备份的数据。Specifically, a backup address corresponding to the memory address where the storage unit is located can be determined, and corresponding data can be read from the backup space based on the backup address. For example, if the first source address corresponds to the first backup address, and a UE error occurs when data is read from the storage unit, and the memory address where the storage unit is located is the first source address, it can be read from the first backup address in the backup space. Take backup data.
一种可选的实现方式中,将存储单元中的数据备份到备份空间之后,还可以为存储单元添加标记,比如可以添加备份标记。In an optional implementation manner, after the data in the storage unit is backed up to the backup space, a mark may be added to the storage unit, for example, a backup mark may be added.
若再次从存储单元中读取数据时出现了UE错误,且电子设备确定该存储单元具有备份标记,则电子设备可以根据存储单元所在的内存地址所对应的备份地址从备份空间的备份地址中读取数据,比如可以根据映射关系确定与存储单元所在的内存地址对应的备份地址,再从备份地址中获取数据。If a UE error occurs when reading data from the storage unit again, and the electronic device determines that the storage unit has a backup mark, the electronic device can read from the backup address of the backup space according to the backup address corresponding to the memory address where the storage unit is located. To obtain data, for example, a backup address corresponding to the memory address where the storage unit is located can be determined according to the mapping relationship, and then data is obtained from the backup address.
另一种可选的实现方式中,若再次从存储单元中读取数据时出现了UE错误,则电子设备可以确定存储单元所在的内存地址,并根据存储单元所在的内存地址所对应的备份地址,再从备份地址中获取数据。In another optional implementation manner, if a UE error occurs when data is read from the storage unit again, the electronic device can determine the memory address where the storage unit is located, and according to the backup address corresponding to the memory address where the storage unit is located , and then get the data from the backup address.
这种实现方式中,即使存储单元发生了UE错误,也不会导致系统宕机。In this implementation, even if a UE error occurs in the storage unit, the system will not be down.
本公开提供的方案中,能够对存储单元进行预判,确定具有发生UE错误风险的存储单元,从而可以对存在UE错误风险的存储单元的数据进行备份,当该存储单元发生了UE错误时,能够从备份空间中读取相应的数据,以免由于存储单元的UE错误导致无法获取数据的问题。In the solution provided by the present disclosure, the storage unit can be pre-judged to determine the storage unit with the risk of UE error, so that the data of the storage unit with the risk of UE error can be backed up. When the UE error occurs in the storage unit, The corresponding data can be read from the backup space, so as to avoid the problem that the data cannot be obtained due to the UE error of the storage unit.
本公开提供的对内存中的存储数据进行备份的方法,在内存中预先设置备份空间;方法包括:从内存的存储单元读取数据时,若确定存储单元存在发生不可纠正的错误的风险,则将存储单元中的数据写入备份空间,并确定存储单元所在的内存地址与数据在备份空间中的备份地址之间对应;若再次从存储单元读取数据时发生了不可纠正的错误,则根据存储单元所在的内存地址所对应的备份地址,从备份空间中读取数据。本公开提供的方案中,可以利用内存的空间对存储单元的数据进行备份,且存储单元的大小可以根据需求设置,使得电子设备能够对内存中分散的可能存在UE错误的存储单元中的数据进行备份,以解决由于内存UE错误导致系统宕机的问题。The method for backing up stored data in a memory provided by the present disclosure includes presetting a backup space in the memory; the method includes: when reading data from a storage unit in the memory, if it is determined that there is a risk of uncorrectable errors occurring in the storage unit, then Write the data in the storage unit into the backup space, and determine the correspondence between the memory address where the storage unit is located and the backup address of the data in the backup space; if an uncorrectable error occurs when reading the data from the storage unit again, according to The backup address corresponding to the memory address where the storage unit is located, reads data from the backup space. In the solution provided by the present disclosure, the space of the memory can be used to back up the data of the storage unit, and the size of the storage unit can be set according to the requirements, so that the electronic device can perform the data backup of the data in the storage units scattered in the memory and possibly having UE errors. Backup to fix system downtime due to memory UE error.
图2为本公开另一示例性实施例示出的对内存中的存储数据进行备份的方法的流程图。FIG. 2 is a flowchart of a method for backing up stored data in a memory according to another exemplary embodiment of the present disclosure.
如图2所示,本实施例提供的对内存中的存储数据进行备份的方法,包括:As shown in FIG. 2 , the method for backing up stored data in the memory provided by this embodiment includes:
步骤201,从内存的存储单元读取数据时,若确定存储单元存在发生可纠正的错误的风险,则确定内存可纠正错误信息;内存可纠正错误信息用于确定存储单元是否存在发生不可纠正的错误的风险。Step 201, when reading data from the storage unit of the memory, if it is determined that the storage unit has the risk of a correctable error, then determine that the memory can correct the error information; risk of error.
本公开提供的方法可以由设置有内存的电子设备执行,该电子设备在开机时可以在内存中划分出备份空间。备份空间的大小可以基于需求设置,以满足多种应用场景的业务需求。The method provided by the present disclosure can be performed by an electronic device provided with a memory, and the electronic device can divide a backup space in the memory when the electronic device is powered on. The size of the backup space can be set based on demand to meet the business needs of various application scenarios.
其中,内存可以被划分为多个存储单元,需要读取的数据可以分散在多个存储单元中,电子设备可以从这些存储单元中读取数据。The memory can be divided into multiple storage units, the data to be read can be scattered in multiple storage units, and the electronic device can read data from these storage units.
具体的,电子设备从存储单元中读取数据时,若确定存储单元存在发生CE错误的风险,则电子设备可以确定内存可纠正错误信息,该内存可纠正错误信息可以包括错误发生的位置、原因等。Specifically, when the electronic device reads data from the storage unit, if it is determined that the storage unit has the risk of CE error, the electronic device can determine the correctable error information in the memory, and the correctable error information in the memory may include the location and cause of the error. Wait.
该内存可纠正错误信息用于确定存储单元是否存在发生UE错误的风险。This memory correctable error information is used to determine whether the storage unit is at risk of UE errors.
一种可选的实现方式中,电子设备中可以设置管理程序,可以由电子设备中的管理程序根据内存可纠正错误信息确定存储单元是否发生了UE错误的风险。In an optional implementation manner, a management program may be set in the electronic device, and the management program in the electronic device may determine whether the risk of UE error occurs in the storage unit according to the memory correctable error information.
另一种可选的实现方式中,电子设备还可以将内存可纠正错误信息发送给云端,由云端根据内存可纠正错误信息确定存储单元是否发生了UE错误的风险。In another optional implementation manner, the electronic device may also send memory-correctable error information to the cloud, and the cloud determines whether a risk of UE error occurs in the storage unit according to the memory-correctable error information.
进一步的,还可以设置预测策略,在根据内存可纠正错误信息用于确定存储单元是否存在发生UE错误的风险时,可以结合预测策略以及内存可纠正错误信息,确定存储单元是否存在发生UE错误的风险。Further, a prediction strategy can also be set, and when the memory correctable error information is used to determine whether there is a risk of UE errors occurring in the storage unit, the prediction strategy and the memory correctable error information can be combined to determine whether there is a UE error in the storage unit. risk.
比如,若根据内存可纠正错误信息,确定存储单元中的多个字节发生过CE错误,则可以确定存储单元是否存在发生UE错误的风险。比如,可以根据历史接收到的内存可纠正错误信息和当前接收的内存可纠正错误信息,确定与当前接收的内存可纠正错误信息对应的存储单元中,是否存在多个字节都发生过CE错误,若是,则可以确定该存储单元存在发生UE错误的风险。For example, if it is determined that CE errors have occurred in multiple bytes in the storage unit according to the correctable error information in the memory, it can be determined whether there is a risk of UE errors occurring in the storage unit. For example, according to the historically received memory correctable error information and the currently received memory correctable error information, it can be determined whether there are multiple bytes in the storage unit corresponding to the currently received memory correctable error information and CE errors have occurred , if yes, it can be determined that there is a risk of UE error occurring in the storage unit.
步骤202,获取用于表征存储单元存在发生不可纠正的错误的风险的信息。Step 202: Obtain information for characterizing the risk of uncorrectable errors occurring in the storage unit.
其中,若由电子设备的管理程序确定存储单元存在发送UE错误的风险,则该管理程序还可以生成用于表征存储单元存在发生不可纠正的错误的风险的信息,使得电子设备可以获取到该信息。Wherein, if the management program of the electronic device determines that the storage unit has the risk of sending UE errors, the management program may also generate information for representing the risk of uncorrectable errors occurring in the storage unit, so that the electronic device can obtain the information .
该管理程序可以设置在电子设备中,也可以设置在云端,若设置在电子设备中,具体可以设置在BIOS(Basic Input Output System,基本输入输出系统)中,还可以设置在BMC(Baseboard Management Controller,基板管理控制器)中,或者设置在OS(operatingsystem,操作系统)中,本公开不对其进行限制。The management program can be set in the electronic device or in the cloud. If it is set in the electronic device, it can be set in the BIOS (Basic Input Output System), or in the BMC (Baseboard Management Controller). , baseboard management controller), or set in an OS (operating system, operating system), which is not limited in the present disclosure.
步骤203,将存储单元中的数据写入备份空间的第一备份地址以及第二备份地址。Step 203: Write the data in the storage unit into the first backup address and the second backup address of the backup space.
进一步的,将数据写入备份空间中,可以备份两次该数据,比如,可以在备份空间中连续写两次该数据,从而使得数据更加安全。Further, when data is written into the backup space, the data can be backed up twice, for example, the data can be written in the backup space twice continuously, thereby making the data more secure.
实际应用时,可以将存储单元中的数据写在备份空间的第一备份地址和第二备份地址,通过多次备份的方式以进一步的确保数据稳定性。比如,在备份空间中的数据可以包括数据A、数据A’、数据B、数据B’,其中的数据A和数据A’相同,数据B和数据B’相同。In practical application, the data in the storage unit can be written in the first backup address and the second backup address of the backup space, and the data stability can be further ensured by means of multiple backups. For example, the data in the backup space may include data A, data A', data B, and data B', wherein data A and data A' are the same, and data B and data B' are the same.
步骤204,对存储单元添加备份标记;备份标记用于表征存储单元的数据被写入备份空间中。
本公开提供的方法中,将存储单元的数据备份到备份空间之后,电子设备还可以对该存储单元添加备份标记,从而表征该存储单元中的数据被备份到了备份空间中。In the method provided by the present disclosure, after the data of the storage unit is backed up to the backup space, the electronic device may further add a backup mark to the storage unit, thereby indicating that the data in the storage unit is backed up in the backup space.
比如,存在第一存储单元,电子设备将第一存储单元中的数据存储到备份空间中,则可以对第一存储单元添加备份标记。再比如,存在第四存储单元,电子设备将第四存储单元中的数据存储到备份空间中,则可以对第四存储单元添加备份标记。For example, if there is a first storage unit, and the electronic device stores data in the first storage unit in a backup space, a backup mark may be added to the first storage unit. For another example, if there is a fourth storage unit, and the electronic device stores data in the fourth storage unit in the backup space, a backup mark may be added to the fourth storage unit.
图3为本公开一示例性实施例示出的数据备份的示意图。FIG. 3 is a schematic diagram of data backup according to an exemplary embodiment of the present disclosure.
如图3所示,内存中具有备份空间31,备份空间31的大小大于存储单元的大小。As shown in FIG. 3 , there is a
若电子设备确定存储单元32存在可能发生UE错误的风险,则将存储单元32中的数据data32写入备份空间31中。此后,若电子设备又确定存储单元33存在可能发生UE错误的风险,则将存储单元33中的数据data33也写入备份空间31中。If the electronic device determines that the
需要说明的是,用于备份数据的备份空间中的地址可以连续也可以不连续。比如,可以在第三备份地址写入data32,在第四备份地址写入data33,第三备份地址和第四备份地址可以是不连续的。It should be noted that the addresses in the backup space for backing up data may be continuous or discontinuous. For example, data32 may be written to the third backup address, and data33 may be written to the fourth backup address, and the third backup address and the fourth backup address may be discontinuous.
其中,在获取用于表征存储单元存在发生不可纠正的错误的风险的信息后,电子设备还可以对存储单元添加备份标记,比如,可以为存储单元32和存储单元33均添加备份标记。Wherein, after acquiring the information representing the risk of uncorrectable errors occurring in the storage unit, the electronic device may also add a backup mark to the storage unit, for example, may add a backup mark to both the
步骤205,根据存储单元所在的内存地址与用于在备份空间中备份数据的备份地址,生成地址映射项。Step 205: Generate an address mapping item according to the memory address where the storage unit is located and the backup address used for backing up data in the backup space.
步骤203-205的执行顺序不做限制,即对备份数据、为存储单元添加备份标记以及生成地址映射项的执行顺序,不做限制。The execution sequence of steps 203-205 is not limited, that is, the execution sequence of backing up data, adding a backup mark to a storage unit, and generating an address mapping item is not limited.
一种可选的实现方式中,在需要备份数据时,可以先确定用于备份数据的备份地址,再生成存储单元所在的内存地址与备份地址之间的映射项,再将需要备份的数据写入该备份地址中。In an optional implementation, when data needs to be backed up, a backup address for backing up data can be determined first, and then a mapping item between the memory address where the storage unit is located and the backup address can be generated, and then the data that needs to be backed up is written. into the backup address.
再一种可选的实现方式中,在需要备份数据时,可以先在备份空间中写入数据,再根据写入数据的位置确定备份地址,并生成地址映射项。In another optional implementation manner, when data needs to be backed up, data can be written in the backup space first, and then the backup address can be determined according to the location of the written data, and an address mapping item can be generated.
进一步的,电子设备可以确定存储单元所在的内存地址,与用于在备份空间中备份数据的备份地址,生成地址映射项。比如,存储单元所在的内存地址为地址1,存储单元中的数据将被写入到备份空间中,写入的备份地址为地址2,则可以根据地址1和地址2生成地址映射项,地址映射项用于表征地址1与地址2对应。Further, the electronic device can determine the memory address where the storage unit is located and the backup address used for backing up data in the backup space, and generate an address mapping item. For example, if the memory address where the storage unit is located is address 1, the data in the storage unit will be written into the backup space, and the written backup address is address 2, then an address mapping item can be generated according to address 1 and address 2, and the address mapping The entry is used to represent that address 1 corresponds to address 2.
进一步的,若在备份空间中备份两份或多份相同的数据,则电子设备还可以确定存储单元所在的内存地址与第一备份地址之间对应,比如,可以确定存储单元所在的内存地址与第一备份地址之间具有第一映射关系,还可以确定第一备份地址与第二备份地址之间对应,比如确定第一备份地址与第二备份地址之间具有第二映射关系。第一映射关系和第二映射关系均可以被写入地址映射表中。Further, if two or more copies of the same data are backed up in the backup space, the electronic device can also determine the correspondence between the memory address where the storage unit is located and the first backup address, for example, the memory address where the storage unit is located is determined to be the same as the first backup address. The first backup addresses have a first mapping relationship, and the correspondence between the first backup address and the second backup address can also be determined, for example, it is determined that the first backup address and the second backup address have a second mapping relationship. Both the first mapping relationship and the second mapping relationship can be written into the address mapping table.
比如,存储单元的内存地址为address 1,该存储单元中的数据被存储到了备份空间中,具体存储的位置为address 2,则可以确定address 1与address 2之间具有第一映射关系,同时,还将该数据存储在备份空间的另一位置address 3处,则可以确定address 2与address 3之间具有第二映射关系。For example, if the memory address of the storage unit is address 1, the data in the storage unit is stored in the backup space, and the specific storage location is address 2, it can be determined that there is a first mapping relationship between address 1 and address 2, and at the same time, If the data is also stored at another location address 3 in the backup space, it can be determined that there is a second mapping relationship between address 2 and address 3.
这种实现方式中,若读取存储单元的数据时出现了UE错误,则电子设备可以从第一备份地址读取备份数据,若从第一备份地址读取数据时也出现了UE错误,则电子设备还可以从第二备份地址读取备份数据。从而解决由于备份空间中用于备份数据的地址出现了UE错误,而导致系统宕机的问题。In this implementation, if a UE error occurs when reading the data of the storage unit, the electronic device can read the backup data from the first backup address. If a UE error also occurs when reading data from the first backup address, then The electronic device can also read the backup data from the second backup address. Therefore, the problem of system downtime caused by UE error occurs in the address used for backing up data in the backup space is solved.
步骤206,将地址映射项写入地址映射表。
实际应用时,还可以生成地址映射表,用于记录地址映射项。In practical application, an address mapping table may also be generated for recording address mapping items.
电子设备可以确定当前是否存在能够写入地址映射项的地址映射表,若不存在地址映射表,则电子设备还可以生成新的地址映射表,并在其中写入地址映射项。The electronic device can determine whether there is currently an address mapping table capable of writing address mapping items, and if there is no address mapping table, the electronic device can also generate a new address mapping table and write the address mapping items in it.
若存在能够写入地址映射项的地址映射表,则电子设备可以将当前生成的地址映射项写入地址映射表。If there is an address mapping table in which the address mapping item can be written, the electronic device can write the currently generated address mapping item into the address mapping table.
其中,电子设备还可以根据存储单元所在的内存地址确定哈希值,根据哈希值在地址映射表中确定目标位置;将地址映射项存储在地址映射表的目标位置。The electronic device can also determine the hash value according to the memory address where the storage unit is located, and determine the target position in the address mapping table according to the hash value; and store the address mapping item in the target position of the address mapping table.
具体的,电子设备可以根据内存地址的低位数值确定哈希值,比如,可以利用内存地址的低4位数值确定哈希值。再利用哈希值作为映射表的偏移项,从而确定目标位置。比如,哈希值为hash(m),则可以将地址映射表的第hash(m)行作为目标位置。这种实现方式中,需要查询存储单元的地址映射项时,能够根据存储单元的内存地址快速定位到地址映射表中的目标位置,从而快速读取到地址映射项,以便快速读取备份地址。Specifically, the electronic device may determine the hash value according to the low-order value of the memory address, for example, the hash value may be determined by using the low-order 4-bit value of the memory address. Then use the hash value as the offset item of the mapping table to determine the target position. For example, if the hash value is hash(m), the hash(m) row of the address mapping table can be used as the target location. In this implementation, when the address mapping item of the storage unit needs to be queried, the target position in the address mapping table can be quickly located according to the memory address of the storage unit, so that the address mapping item can be quickly read so as to quickly read the backup address.
进一步的,若通过地址映射表的方式记录地址映射项,则可以将地址映射表存储在内存中,这种方式能够存储数量较多的地址映射项。Further, if the address mapping items are recorded by means of an address mapping table, the address mapping table can be stored in the memory, and a large number of address mapping items can be stored in this manner.
一种可选的实现方式中,可以在内存中存储两份地址映射表,比如,在内存的第一位置处存储地址映射表,还可以在第二位置处存储备份表,该备份表与地址映射表的内容相同。In an optional implementation, two copies of the address mapping table can be stored in the memory, for example, the address mapping table is stored in the first position of the memory, and the backup table can also be stored in the second position. The contents of the mapping table are the same.
地址映射表为逻辑表,在存储介质中存储的内容为地址映射项,地址映射表可以看成是地址映射项的集合,这些地址映射项在存储介质中的地址可以连续,也可以不连续。The address mapping table is a logical table, and the contents stored in the storage medium are address mapping items. The address mapping table can be regarded as a collection of address mapping items. The addresses of these address mapping items in the storage medium can be continuous or discontinuous.
实际应用时,每次在地址映射表中添加地址映射项时,还可以以相同的方式在备份表中也添加地址映射项,使得两个表的内容同步。In practical application, every time an address mapping item is added to the address mapping table, an address mapping item can also be added to the backup table in the same way, so that the contents of the two tables are synchronized.
其中,电子设备的缓存中还可以预留一些位置,用于存储部分地址映射项。比如,可以预留能够存储N个地址映射项的位置,以便电子设备能够更加快速的读取到备份地址。Among them, some locations may also be reserved in the cache of the electronic device for storing some address mapping items. For example, a location capable of storing N address mapping items may be reserved, so that the electronic device can read the backup address more quickly.
具体的,缓存中存储的地址映射项能够被更新,具体可以将最近读取过的地址映射项存储在缓存中。Specifically, the address mapping items stored in the cache can be updated, and specifically, the recently read address mapping items can be stored in the cache.
在步骤2-3、204、206之后,可以执行步骤207,还可以执行步骤209。After steps 2-3, 204, and 206,
步骤207,若从存储单元中读取数据时发生了不可纠正的错误,且存储单元具有备份标记,则根据映射关系从备份空间的备份地址中读取数据。Step 207: If an uncorrectable error occurs when reading data from the storage unit, and the storage unit has a backup mark, read data from the backup address of the backup space according to the mapping relationship.
其中,若电子设备从存储单元中读取数据时发生了UE错误,则电子设备可以确定该存储单元是否具有备份标记,若有,则说明该存储单元中的数据已备份到备份空间,因此,可以根据映射关系从备份空间的备份地址中读取数据。Wherein, if the UE error occurs when the electronic device reads data from the storage unit, the electronic device can determine whether the storage unit has a backup mark, and if so, it means that the data in the storage unit has been backed up to the backup space, therefore, Data can be read from the backup address of the backup space according to the mapping relationship.
具体的,若利用地址映射表记录地址的映射关系,则电子设备可以在地址映射表中查询与存储单元所在的内存地址对应的备份地址,并从备份地址中读取数据。Specifically, if the address mapping table is used to record the address mapping relationship, the electronic device can query the address mapping table for the backup address corresponding to the memory address where the storage unit is located, and read data from the backup address.
这种实现方式中,即使存储数据的存储单元出现了UE错误,电子设备仍然能够从备份空间中读取相应的数据,以避免系统重启。In this implementation manner, even if a UE error occurs in the storage unit storing the data, the electronic device can still read the corresponding data from the backup space to avoid system restart.
可选的,若电子设备从存储单元中读取数据成功的话,电子设备还可以将该数据存储在缓存中,并且在缓存中记录存储单元具有备份标记的信息,使得下次将数据从缓存同步到内存存储单元时,能够确定该数据被备份到备份空间中过,因此,电子设备可以根据地址映射表将该数据同步到备份地址中。Optionally, if the electronic device successfully reads the data from the storage unit, the electronic device can also store the data in the cache, and record the information that the storage unit has a backup mark in the cache, so that the data is synchronized from the cache next time. When reaching the memory storage unit, it can be determined that the data has been backed up in the backup space, so the electronic device can synchronize the data to the backup address according to the address mapping table.
图4为本公开另一示例性实施例示出的读取数据的示意图。FIG. 4 is a schematic diagram of reading data according to another exemplary embodiment of the present disclosure.
如图4所示,在备份空间41中存储有data42,data42是存储单元42中的数据,在备份空间41中还存储有data43,data43是存储单元43中的数据。As shown in FIG. 4 , data42 is stored in the
记录有data42在备份空间41中的备份地址与存储单元42的内存地址之间的对应关系,还记录有data43在备份空间41中的备份地址与存储单元43的内存地址之间的对应关系.The correspondence between the backup address of data42 in the
电子设备从存储单元42读取数据时,若出现了UE错误,则电子设备可以根据地址的映射关系查询与存储单元42的内存地址对应的备份地址,而data42在备份空间41中的备份地址与存储单元42的内存地址之间对应,因此,能够从该备份地址中读取到data42。When the electronic device reads data from the
步骤208,若从备份空间中读取数据时发生了不可纠正的错误,则输出用于表征内存存在不可纠正的错误的信息。
其中,备份空间是内存的一部分,因此,备份空间也可能发生UE错误,若从备份空间中读取数据时发生了UE错误,则电子设备最终无法获取有效数据,因此,电子设备可以输出用于表征内存存在UE错误的信息。Among them, the backup space is a part of the memory. Therefore, UE errors may also occur in the backup space. If a UE error occurs when reading data from the backup space, the electronic device cannot obtain valid data in the end. Therefore, the electronic device can output data for Information that characterizes the existence of UE errors in memory.
步骤209,响应对存储单元的写指令,若确定存储单元具有备份标记,则确定存储单元所在的内存地址所对应的备份地址。Step 209: In response to the write instruction to the storage unit, if it is determined that the storage unit has a backup flag, determine the backup address corresponding to the memory address where the storage unit is located.
具体的,电子设备还可以对存储单元进行写操作,具体可以执行写指令。比如,用户可以更改电子设备中存储的数据,则电子设备能够基于该操作执行对存储单元的写指令,再比如,电子设备执行程序时也会更新存储单元中的数据,在执行过程中也会对存储单元进行写操作,具体可以执行相应的写指令。Specifically, the electronic device can also perform a write operation on the storage unit, and specifically can execute a write instruction. For example, if the user can change the data stored in the electronic device, the electronic device can execute the write instruction to the storage unit based on the operation. For another example, when the electronic device executes the program, the data in the storage unit will also be updated, and the data in the storage unit will also be updated during the execution process. A write operation is performed on the storage unit, and a corresponding write instruction can be specifically executed.
进一步的,电子设备在执行对存储单元的写指令时,若确定存储单元具有备份标记,则可以确定与存储单元所在的内存地址对应的备份地址。Further, when the electronic device executes the write instruction to the storage unit, if it is determined that the storage unit has a backup flag, the backup address corresponding to the memory address where the storage unit is located may be determined.
比如,可以根据确定的地址之间的映射关系,确定存储单元所在的内存地址所对应的备份地址,若利用地址映射表记录地址的映射关系,则电子设备可以在地址映射表中查询与存储单元所在的内存地址对应的备份地址。For example, the backup address corresponding to the memory address where the storage unit is located can be determined according to the determined mapping relationship between the addresses. If the address mapping table is used to record the address mapping relationship, the electronic device can query the address mapping table with the storage unit. The backup address corresponding to the memory address where it is located.
步骤210,根据写指令在存储单元和备份地址中写入数据。Step 210: Write data in the storage unit and the backup address according to the write instruction.
实际应用时,电子设备可以根据写指令在存储单元中写入数据,还可以在于该存储单元对应的备份地址中写入数据。这种实现方式中,能够保证存储单元以及备份空间中的数据保持一致。In practical application, the electronic device may write data in the storage unit according to the write instruction, and may also write data in the backup address corresponding to the storage unit. In this implementation manner, the data in the storage unit and the backup space can be guaranteed to be consistent.
在上述任一种实施例中,存储单元的存储空间的大小,与缓存的缓存行的大小相同。缓存是电子设备中的另一存储部件,缓存分为多个组,每个组具有多个cacheline(缓存行),缓存行的大小linesize是一个cacheline的大小,电子设备将内存中的数据写入缓存时,数据的最小粒度是linesize,即每次向缓存中写入数据时,数据量最少为linesize。In any of the above embodiments, the size of the storage space of the storage unit is the same as the size of the cache line of the cache. The cache is another storage component in the electronic device. The cache is divided into multiple groups, and each group has multiple cachelines (cache lines). The size of the cache line is the size of one cacheline. The electronic device writes the data in the memory. When caching, the minimum granularity of data is linesize, that is, each time data is written to the cache, the minimum amount of data is linesize.
这种实现方式中,能够将内存中可能存在UE错误风险的存储单元中的数据进行备份,且存储单元的大小为cacheline的大小,因此能够利用少量的备份空间对内存中分散的可能会出错的各大小为linesize的数据块进行备份,以提升电子设备的可靠性和稳定性。In this implementation, the data in the storage unit that may have the risk of UE error in the memory can be backed up, and the size of the storage unit is the size of the cacheline, so a small amount of backup space can be used to scatter the data in the memory that may be wrong. Each data block with the size of linesize is backed up to improve the reliability and stability of the electronic device.
图5为本公开一示例性实施例示出的对内存中的存储数据进行备份的装置的结构图。FIG. 5 is a structural diagram of an apparatus for backing up stored data in a memory according to an exemplary embodiment of the present disclosure.
如图5所示,本实施例提供的对内存中的存储数据进行备份的装置500,在内存中预先设置备份空间;所述装置包括:As shown in FIG. 5 , the
备份单元510,用于从内存的存储单元读取数据时,若确定所述存储单元存在发生不可纠正的错误的风险,则将所述存储单元中的数据写入所述备份空间,并确定所述存储单元所在的内存地址与所述数据在所述备份空间中的备份地址对应;The
备份数据读取单元530,用于若再次从所述存储单元读取数据时发生了不可纠正的错误,则根据所述存储单元所在的内存地址所对应的备份地址,从所述备份空间中读取数据。The backup
本公开提供的方案中,可以利用内存的空间对存储单元的数据进行备份,且存储单元的大小可以根据需求设置,使得电子设备能够对内存中分散的可能存在UE错误的存储单元中的数据进行备份,以解决由于内存UE错误导致系统宕机的问题。In the solution provided by the present disclosure, the space of the memory can be used to back up the data of the storage unit, and the size of the storage unit can be set according to the requirements, so that the electronic device can perform the data backup of the data in the storage units scattered in the memory and possibly having UE errors. Backup to fix system downtime due to memory UE error.
图6为本公开另一示例性实施例示出的对内存中的存储数据进行备份的装置的结构图。FIG. 6 is a structural diagram of an apparatus for backing up stored data in a memory according to another exemplary embodiment of the present disclosure.
如图6所示,在上述实施例的基础上,本实施例提供的对内存中的存储数据进行备份的装置600,所述备份单元510包括:As shown in FIG. 6 , on the basis of the foregoing embodiment, the
映射项生成模块511,用于根据所述存储单元所在的内存地址与用于在所述备份空间中备份所述数据的备份地址,生成地址映射项;The mapping item generating module 511 is used for generating an address mapping item according to the memory address where the storage unit is located and the backup address for backing up the data in the backup space;
写入模块512,用于将所述地址映射项写入地址映射表。The
所述写入模块512具体用于:The
根据所述存储单元所在的内存地址确定哈希值,根据所述哈希值在所述地址映射表中确定目标位置;Determine a hash value according to the memory address where the storage unit is located, and determine a target position in the address mapping table according to the hash value;
将所述地址映射项存储在所述地址映射表的所述目标位置。The address mapping entry is stored in the target location of the address mapping table.
一种可选的实现方式中,所述地址映射表存储在所述内存的第一位置处,与所述地址映射表相同的备份表存储在所述内存的第二位置处。In an optional implementation manner, the address mapping table is stored in a first location of the memory, and a backup table identical to the address mapping table is stored in a second location of the memory.
可选的,所述内存设置在电子设备中,所述电子设备中还设置有缓存;Optionally, the memory is provided in an electronic device, and a cache is also provided in the electronic device;
所述装置还包括缓存单元530,用于:The apparatus further includes a
在所述缓存中存储所述地址映射表中的N个所述地址映射项,N为正整数。N pieces of the address mapping entries in the address mapping table are stored in the cache, where N is a positive integer.
可选的,所述装置还包括标记单元540,用于:Optionally, the device further includes a marking
对所述存储单元添加备份标记;所述备份标记用于表征所述存储单元的数据被写入所述备份空间中;adding a backup mark to the storage unit; the backup mark is used to represent that data of the storage unit is written into the backup space;
所述备份数据读取单元520包括读取模块521,用于:The backup
若从存储单元中读取所述数据时发生了不可纠正的错误,且所述存储单元具有所述备份标记,则根据所述存储单元所在的内存地址所对应的备份地址,从所述备份空间中读取数据。If an uncorrectable error occurs when the data is read from the storage unit, and the storage unit has the backup flag, then according to the backup address corresponding to the memory address where the storage unit is located, from the backup space read data in.
所述装置还包括写单元550,用于:The apparatus also includes a
响应对所述存储单元的写指令,若确定所述存储单元具有所述备份标记,则确定所述存储单元所在的内存地址所对应的备份地址;In response to the write instruction to the storage unit, if it is determined that the storage unit has the backup mark, then determine the backup address corresponding to the memory address where the storage unit is located;
根据所述写指令在所述存储单元和所述备份地址中写入数据。Data is written in the storage unit and the backup address according to the write instruction.
可选的,所述备份数据读取单元520还包括输出模块522,用于:Optionally, the backup
若从所述备份空间中读取所述数据时发生了不可纠正的错误,则输出用于表征内存存在不可纠正的错误的信息。If an uncorrectable error occurs when the data is read from the backup space, output information representing that the memory has an uncorrectable error.
可选的,所述内存设置在电子设备中,所述电子设备中还设置有缓存;Optionally, the memory is provided in an electronic device, and a cache is also provided in the electronic device;
所述存储单元的存储空间的大小,与所述缓存的缓存行的大小相同。The size of the storage space of the storage unit is the same as the size of the cache line of the cache.
可选的,所述备份单元510,包括:Optionally, the
可纠正错误确定模块513,用于从所述内存的所述存储单元读取数据时,若确定所述存储单元存在发生可纠正的错误的风险,则确定内存可纠正错误信息;所述内存可纠正错误信息用于确定所述存储单元是否存在发生不可纠正的错误的风险;The correctable error determination module 513 is configured to, when reading data from the storage unit of the memory, determine that the storage unit is at risk of having a correctable error, determine that the memory can correct the error information; the memory may Correcting error information is used to determine whether the storage unit is at risk of uncorrectable errors;
错误信息获取模块514,用于获取用于表征所述存储单元存在发生不可纠正的错误的风险的信息。The error
可选的,所述备份单元510具体用于:Optionally, the
将所述存储单元中的数据写入所述备份空间的第一备份地址以及第二备份地址;writing the data in the storage unit into the first backup address and the second backup address of the backup space;
确定所述存储单元所在的内存地址与所述第一备份地址对应,并确定所述第一备份地址与所述第二备份地址对应。It is determined that the memory address where the storage unit is located corresponds to the first backup address, and it is determined that the first backup address corresponds to the second backup address.
图7为本公开一示例性实施例示出的电子设备的结构图。FIG. 7 is a structural diagram of an electronic device according to an exemplary embodiment of the present disclosure.
如图7所示,本实施例提供的电子设备包括:As shown in FIG. 7 , the electronic device provided in this embodiment includes:
存储器71;
处理器72;以及
计算机程序;Computer program;
其中,所述计算机程序存储在所述存储器71中,并配置为由所述处理器72执行以实现如上所述的任一种对内存中的存储数据进行备份的方法。Wherein, the computer program is stored in the
本实施例还提供一种计算机可读存储介质,其上存储有计算机程序,This embodiment also provides a computer-readable storage medium on which a computer program is stored,
所述计算机程序被处理器执行以实现如上所述的任一种对内存中的存储数据进行备份的方法。The computer program is executed by the processor to implement any of the methods for backing up stored data in memory as described above.
本实施例还提供一种计算机程序,包括程序代码,当计算机运行所述计算机程序时,所述程序代码执行如上所述的任一种对内存中的存储数据进行备份的方法。This embodiment also provides a computer program, including program code. When the computer runs the computer program, the program code executes any of the above-mentioned methods for backing up stored data in the memory.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by program instructions related to hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps including the above method embodiments are executed; and the foregoing storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
最后应说明的是:以上各实施例仅用以说明本公开的技术方案,而非对其限制;尽管参照前述各实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本公开各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, but not to limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present disclosure. scope.
Claims (14)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210506772.7A CN114840364A (en) | 2022-05-07 | 2022-05-07 | Method and device for backing up storage data in memory and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210506772.7A CN114840364A (en) | 2022-05-07 | 2022-05-07 | Method and device for backing up storage data in memory and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114840364A true CN114840364A (en) | 2022-08-02 |
Family
ID=82569583
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210506772.7A Pending CN114840364A (en) | 2022-05-07 | 2022-05-07 | Method and device for backing up storage data in memory and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114840364A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024093299A1 (en) * | 2022-10-31 | 2024-05-10 | 华为技术有限公司 | Memory fault repairing method and apparatus |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102455979A (en) * | 2010-10-18 | 2012-05-16 | 英业达股份有限公司 | Data protection method for damaged memory cell |
CN109344094A (en) * | 2018-09-26 | 2019-02-15 | 郑州云海信息技术有限公司 | Address mapping relationship feedback method, apparatus, device and readable storage medium |
-
2022
- 2022-05-07 CN CN202210506772.7A patent/CN114840364A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102455979A (en) * | 2010-10-18 | 2012-05-16 | 英业达股份有限公司 | Data protection method for damaged memory cell |
CN109344094A (en) * | 2018-09-26 | 2019-02-15 | 郑州云海信息技术有限公司 | Address mapping relationship feedback method, apparatus, device and readable storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024093299A1 (en) * | 2022-10-31 | 2024-05-10 | 华为技术有限公司 | Memory fault repairing method and apparatus |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
AU2017228544B2 (en) | Nonvolatile media dirty region tracking | |
US8255742B2 (en) | Dynamically replicated memory | |
US8543863B2 (en) | Efficiency of hardware memory access using dynamically replicated memory | |
US9430329B2 (en) | Data integrity management in a data storage device | |
US9377960B2 (en) | System and method of using stripes for recovering data in a flash storage system | |
US10884850B2 (en) | Fault tolerant memory system | |
TW201535382A (en) | DRAM row sparing | |
US11314594B2 (en) | Method, device and computer program product for recovering data | |
US20120110278A1 (en) | Remapping of inoperable memory blocks | |
CN111522684A (en) | A method and device for simultaneously correcting soft and hard errors in phase change memory | |
US9626242B2 (en) | Memory device error history bit | |
US20040250028A1 (en) | Method and apparatus for data version checking | |
CN114840364A (en) | Method and device for backing up storage data in memory and electronic equipment | |
US7577804B2 (en) | Detecting data integrity | |
CN112119380A (en) | Parity record with bypass | |
CN114600073B (en) | Data reconstruction method, device and computing equipment applied to disk array system | |
US9128887B2 (en) | Using a buffer to replace failed memory cells in a memory component | |
WO2018076954A1 (en) | Data storage method, apparatus and system | |
CN111048141B (en) | Error processing method, device, equipment and computer readable storage medium | |
CN103092727B (en) | Data error-correcting method in flash storage medium and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |