Cached data protection methods, devices, and storage equipment

By employing a dual-power supply circuit and a cache partition tagging mechanism, the problem of cache data loss during power outages in storage devices is solved, achieving more efficient data protection and system recovery.

CN120973204BActive Publication Date: 2026-11-17MACROSAN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511073709.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2026-11-17
Estimated Expiration
2045-07-31

AI Technical Summary

Technical Problem

In existing technologies, cached data is easily lost when the external power supply to the storage device fails, which affects data integrity and consistency. In particular, the cached data protection effect is not ideal when there is a CPU failure, a controller motherboard failure, a non-volatile storage medium failure, or insufficient power supply battery.

Method used

The system employs a dual-power supply circuit design. When the first power supply circuit experiences a power failure, it does not affect the second power supply circuit's power supply to the memory. This ensures that memory data is written to non-volatile storage media when the external power supply fails. Furthermore, the system determines the validity of the data by dividing the memory into cache partitions and tagging them. Once the external power supply is restored, the source of the read data is identified.

Benefits of technology

It improves the protection and reliability of cached data, reduces the probability of data loss, extends data retention time, and improves the efficiency and integrity of the storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973204B_ABST
    Figure CN120973204B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, and storage device for protecting cached data. In this application, the power supply battery is split into two circuits to power the device's motherboard and memory respectively. An anomaly in the first power supply circuit does not affect the power supply to the memory from the second power supply circuit. When an external power failure is detected, the power supply battery is activated, and the cached data in the memory begins to be written to a non-volatile storage medium. When the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained. Thus, the memory continues to have power as long as the backup power supply unit is available. Even in the event of CPU failure, controller motherboard failure, non-volatile storage medium failure, or insufficient power supply battery preventing cached data persistence, the remaining cached data in the memory will not be instantly lost, reducing the probability of cached data loss and thus improving the protection effect of cached data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage, and in particular to methods, apparatus, and storage devices for protecting cached data. Background Technology

[0002] In storage systems, a cache is set up in the memory of the storage device. When processing data, the front-end business data is first written to memory, and then the cached data in memory is written to non-volatile storage media. This greatly improves the response speed and processing capability of the storage system. However, the cache is volatile storage. Once the external power supply fails (power loss), the cached data will be lost instantly, affecting the data integrity and consistency of the storage system.

[0003] Currently, in order to protect cached data from loss, a backup power battery is usually set up in the storage device to power the storage device when the external power supply fails, so that the cached data can be written to the non-volatile storage medium.

[0004] However, in the above methods, if the storage device malfunctions, such as a Central Processing Unit (CPU) failure, a controller motherboard failure, a non-volatile storage medium failure, or a lack of backup battery power preventing successful persistence, the cached data will still be lost, resulting in unsatisfactory cached data protection. Summary of the Invention

[0005] In view of this, embodiments of this application provide a method, apparatus, and storage device for protecting cached data, so as to improve the protection effect of cached data and improve the reliability of cached data protection.

[0006] This application provides a cached data protection method applied to a storage device. The storage device is internally equipped with a power supply battery. The power supply battery supplies power to the device and its memory via two separate circuits. The circuit supplying power to the device is a first power supply circuit, and the circuit supplying power to the memory is a second power supply circuit. An abnormality in the power supply from the first power supply circuit to the device does not affect the power supply from the second power supply circuit to the memory. The method includes:

[0007] When an external power failure is detected, the power supply battery is activated to supply power to the device and the memory on the device in two separate circuits. When the device is powered by the power supply battery, it begins to store cached data in the memory into a designated non-volatile storage medium. When the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained.

[0008] Tags are assigned to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0009] After the external power supply is restored, based on the tag status of the cached data in each cache partition in the memory, it is determined whether the cached data in the memory is valid; if it is determined that the cached data in the memory is invalid, the previously stored cached data is read from the specified non-volatile storage medium and executed in the memory; if it is determined that the cached data in the memory is valid, the cached data in the memory is directly read and executed.

[0010] This application embodiment also provides a cached data protection device, which is applied to a storage device; the storage device is internally equipped with a power supply battery; the power supply battery is divided into two circuits to supply power to the device and the memory on the device respectively, wherein the circuit supplying power to the device is a first power supply circuit, and the circuit supplying power to the memory is a second power supply circuit; an abnormality in the power supply of the first power supply circuit to the device does not affect the power supply of the second power supply circuit to the memory; the device includes:

[0011] The power control module is used to activate the power supply battery to supply power to the device and the memory on the device in two separate circuits when an external power failure is detected; when the device is powered by the power supply battery, it starts to store cached data in the memory into a designated non-volatile storage medium; when the power supply battery is insufficient, it cuts off the power supply to the first power supply circuit and maintains the power supply to the second power supply circuit.

[0012] The first data processing module is used to assign tags to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0013] The second data processing module is used to determine whether the cached data in the memory is valid based on the tag status of the cached data in each cache partition in the memory after the external power supply is restored; if the cached data in the memory is determined to be invalid, the previously stored cached data is read from the specified non-volatile storage medium and executed in the memory; if the cached data in the memory is determined to be valid, the cached data in the memory is directly read and executed.

[0014] This application embodiment also provides a storage device, the device comprising:

[0015] The internally configured power supply battery is used to supply power to the device and the memory on the device in two separate circuits. The circuit that supplies power to the device is the first power supply circuit, and the circuit that supplies power to the memory is the second power supply circuit. An abnormality in the power supply of the first power supply circuit to the device does not affect the power supply of the second power supply circuit to the memory.

[0016] A power control component is used to activate the power supply battery to supply power to the device and the memory on the device in two separate circuits when an external power failure is detected; when the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained.

[0017] Controller, used for:

[0018] When the power control component activates the power supply battery to supply power to the device and the memory on the device in two separate circuits, it controls the storage of cached data in the memory to a designated non-volatile storage medium.

[0019] Tags are assigned to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0020] After the external power supply is restored, based on the tag status of the cached data in each cache partition in the memory, it is determined whether the cached data in the memory is valid; if it is determined that the cached data in the memory is invalid, the previously stored cached data is read from the specified non-volatile storage medium and executed in the memory; if it is determined that the cached data in the memory is valid, the cached data in the memory is directly read and executed.

[0021] This application also provides an electronic device, including: a processor and a memory for storing computer program instructions, which, when executed by the processor, cause the processor to perform the steps of the method described above.

[0022] This application also provides a machine-readable storage medium storing computer program instructions that, when executed, enable the implementation of the steps described above.

[0023] As can be seen from the above technical solution, in this embodiment, by splitting the power supply battery into two circuits to supply power to the device motherboard and the device memory respectively, an anomaly in the first power supply circuit supplying power to the device does not affect the power supply of the second power supply circuit to the memory. When an external power failure is detected, the power supply battery is activated to supply power to the device and the memory on the device separately, and the cached data in the memory begins to be written to the non-volatile storage medium. When the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained. In this way, the memory continues to have power as long as the backup power supply unit has power. Even in the event of CPU failure, controller motherboard failure, non-volatile storage medium failure, or insufficient power supply battery to complete the persistence of cached data, the remaining cached data in the memory will not be lost instantly, reducing the probability of cached data loss and thus improving the protection effect of cached data to ensure the integrity of cached data.

[0024] Furthermore, since the power supply battery in related technologies only powers the entire storage device and consumes less energy to power only the memory components, it can extend the retention time of the remaining cached data in memory with relatively low power consumption when the power supply battery is insufficient to successfully complete the persistence, thereby improving the protection effect of cached data.

[0025] Furthermore, by dividing the memory into N cache regions and labeling each cache region, the labels corresponding to the N cache regions can be used to jointly determine whether the cached data in the memory is valid after the external power supply is restored. This avoids misjudgment and accurately determines whether the data is read from memory or from a specified non-volatile storage medium, thereby enabling the storage device to quickly resume operation and improving the working efficiency of the storage system. Attached Figure Description

[0026] Figure 1 A network architecture diagram of the storage system provided in the embodiments of this application;

[0027] Figure 2 A flowchart illustrating the method provided in the embodiments of this application;

[0028] Figure 3 A schematic diagram illustrating the process for determining whether the power supply battery is insufficient, provided in an embodiment of this application;

[0029] Figure 4 This application provides a flowchart illustrating the process of determining whether cached data in memory is valid.

[0030] Figure 5 This is a schematic diagram of the device provided in the embodiments of this application;

[0031] Figure 6A structural diagram of a storage device provided in an embodiment of this application;

[0032] Figure 7 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0033] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of this application, and to make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the technical solutions in the embodiments of this application will be further described in detail below with reference to the accompanying drawings.

[0034] To facilitate understanding of this solution, before describing it, we will first consider... Figure 1 The network architecture diagram of the storage system shown illustrates the existing technical issues:

[0035] See Figure 1 , Figure 1 This is a network architecture diagram of the storage system provided in an embodiment of this application. Figure 1 As shown, this storage system is a centralized storage system, and the method provided in this application embodiment is implemented based on this network architecture. Specifically, when the server receives read and write operations, the storage device (also known as the head unit) first writes the front-end business data into memory, and then writes the cached data in memory into non-volatile storage medium (i.e., ...). Figure 1 The storage device (as shown in the disk array) relies on an external power supply for normal operation. If the external power supply fails (e.g., a power outage in the data center, a power failure), the cached data in memory will be instantly lost, affecting the data integrity and consistency of the storage system.

[0036] Currently, to protect cached data from loss, storage devices typically have a backup battery. When the external power supply fails, it powers the storage device and writes the cached data to non-volatile storage media (also known as a backup disk). Then, when the external power supply is restored and the storage device restarts, the cached data can be read from the hard drive into memory, ensuring that the cached data is not lost.

[0037] However, storage devices may experience anomalies that prevent them from fully persisting data to non-volatile storage media, leading to cached data loss. Typical anomalies include at least the following:

[0038] 1. After the external power supply fails, the CPU fails while the device is persistently storing cached data in the backup disk. The CPU needs to be replaced to recover, and replacing the CPU will inevitably lead to the loss of cached data.

[0039] 2. After the external power supply fails, the retention disk malfunctions, and the cached data in the memory cannot be written successfully. At this time, the persistence of the cached data in the memory fails, which will lead to the loss of the cached data.

[0040] 3. After the external power supply fails, the components on the motherboard of the storage device malfunction, causing the controller in the storage device to reset, which can also lead to the loss of cached data.

[0041] 4. Insufficient power supply to the storage device prevents data from being persisted. Power failure can lead to the loss of cached data.

[0042] In other words, if persistence fails, cached data will still be lost, resulting in inadequate cache data protection.

[0043] Based on this, embodiments of this application provide a method, apparatus, and storage device for protecting cached data, so as to improve the protection effect of cached data and improve the reliability of cached data protection.

[0044] The following is based on Figure 1 The network architecture shown below provides a detailed explanation of the methods provided in the embodiments of this application:

[0045] See Figure 2 , Figure 2 This is a flowchart illustrating the method provided in an embodiment of this application. The method is applied to a storage device. Figure 2 As shown, the process includes the following steps:

[0046] To implement the method provided in this application embodiment, the following improvements are made to the hardware of the storage device: the power supply circuit of the battery is divided into two circuits to supply power to the device and the memory on the device respectively. The circuit supplying power to the device is the first power supply circuit, and the circuit supplying power to the memory is the second power supply circuit. An abnormality in the power supply of the first power supply circuit to the device does not affect the power supply of the second power supply circuit to the memory.

[0047] The first power supply circuit powers the storage device. This can be connected to the motherboard within the storage device to power the entire device, or it can be connected to the controller within the storage device to power the controller. Powering the memory via the second power supply circuit only powers the memory itself. For ease of explanation, the following description will focus on powering the entire storage device via the first power supply circuit.

[0048] To implement the method provided in the embodiments of this application, the following improvements have been made to the software of the storage device (i.e., the program running in the controller and power control components of the storage device):

[0049] S201, when an external power failure is detected, the power supply battery is activated to supply power to the device and the memory on the device in two separate circuits; when the device is powered by the power supply battery, it begins to store cached data in the memory into a designated non-volatile storage medium; when the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained.

[0050] In this step, regardless of whether the power supply battery is sufficient, as long as the power supply battery is turned on, it will continuously supply power to the memory through the second power supply circuit. Even if there is a CPU failure, controller motherboard failure, backup disk failure, or insufficient power supply battery to complete the cache data persistence (that is, cutting off the power supply of the first power supply circuit), the cache data in the memory will not be lost instantly if it is not successfully written to the backup disk.

[0051] When the battery power supply is insufficient, the power supply to the first power supply circuit is cut off while the power supply to the second power supply circuit is maintained. This allows the limited battery resources to be used to power the second power supply circuit, which consumes relatively less power, thus extending the retention time of the remaining cached data in memory with the same amount of remaining power. Furthermore, this adaptive switching from simultaneous power supply to dedicated power supply to memory makes the cached data protection strategy more flexible, capable of handling more complex real-world operating environments, and improving the reliability of cached data protection.

[0052] As an example, if no CPU failure, controller motherboard failure, backup disk failure, or insufficient power supply from the power supply battery to complete the persistence of cached data (i.e., cutting off the power supply to the first power supply circuit) occurs, and it is determined that all cached data in memory has been successfully written to the backup disk, then the power supply battery is turned off to shut down the device.

[0053] It should be noted that if the cached data in memory is not successfully written to the backup disk and the power supply battery is not turned off, and the power supply battery is insufficient and cuts off the power supply to the first power supply circuit, then the cached data in memory cannot be successfully written to the backup disk.

[0054] The determination of whether the power supply battery is insufficient in this step will be explained in detail later with specific embodiments, and will not be repeated here.

[0055] S202, assign tags to cached data located in different cache partitions; memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in memory is valid; when all the cached data in memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0056] When the external power supply fails, the upper-layer services will no longer perform any new operations. At this time, the above-mentioned tags can be used as the basis for determining whether data should be read from the backup disk or memory after the external power supply is restored. In other words, they can be used as the basis for determining whether the cached data in memory is valid after the external power supply is restored (if valid, read data from memory; if invalid, read data from the backup disk).

[0057] The reason this can be used as a criterion is that: if the above-mentioned abnormal situation does not occur, all cached data in memory is successfully written to the backup disk, the target tag is cleared before the power supply is turned off, and the cached data in each cache partition does not carry the tag. If the above-mentioned abnormal situation occurs, the cached data in memory is not successfully written to the backup disk, the tags of the cached data in each cache partition are not cleared, and the cached data in memory carries the tag. Therefore, the tag can be used as a basis for determining whether the cached data in memory is valid after the external power supply is restored.

[0058] It should be noted that in related technologies, when the external power supply of this storage device is running normally, cached data in memory that needs to be persisted but has not been persisted to the corresponding non-volatile storage medium (also known as dirty data) will be tagged with a "dirty" label. When this data is written to the non-volatile storage medium indicated by the upper-layer business operation, this "dirty" label will be cleared. This process is similar to related technologies and will not be elaborated further here. It is important to note that the "dirty" label is different from the label tagged with the cached data in each cache partition, which indicates whether the data is valid; please do not confuse them.

[0059] The details of how to tag each cache region and how to determine whether the cached data in memory is valid after the external power supply is restored will be explained later and will not be elaborated here.

[0060] S203: After the external power supply is restored, the system determines whether the cached data in memory is valid based on the tag status of the cached data in each cache partition in memory. If the cached data in memory is determined to be invalid, the system reads the previously stored cached data from the specified non-volatile storage medium into memory for operation.

[0061] In this set of embodiments, the specific implementation of determining whether cached data in memory is valid will be described in detail in the following specific embodiments, and will not be repeated here.

[0062] This concludes the process. Figure 2 The process is shown below.

[0063] pass Figure 2As shown in the flowchart, in this embodiment, by splitting the power supply battery into two circuits to power the device motherboard and the device memory respectively, an anomaly in the first power supply circuit supplying the device does not affect the power supply of the second power supply circuit to the memory. When an external power failure is detected, the power supply battery is activated to power the device and the memory on the device separately, and the cached data in the memory begins to be written to the non-volatile storage medium. When the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, while the power supply of the second power supply circuit is maintained. In this way, the memory continues to have power as long as the backup power supply unit is powered. Even in the event of CPU failure, controller motherboard failure, non-volatile storage medium failure, or insufficient power supply battery to complete the persistence of cached data, the remaining cached data in the memory will not be lost instantly, reducing the probability of cached data loss and thus improving the protection effect of cached data to ensure the integrity of cached data.

[0064] Furthermore, since the power supply battery in related technologies only powers the entire storage device and consumes less energy to power only the memory components, it can extend the retention time of the remaining cached data in memory with relatively low power consumption when the power supply is insufficient and the persistence cannot be successfully completed, thereby improving the protection effect of cached data.

[0065] Furthermore, by dividing the memory into N cache regions and labeling each cache region, the labels corresponding to the N cache regions can be used to jointly determine whether the cached data in the memory is valid after the external power supply is restored. This avoids misjudgment and accurately determines whether the data is read from memory or from a specified non-volatile storage medium, thereby enabling the storage device to quickly resume operation and improving the working efficiency of the storage system.

[0066] The following section elaborates on how to determine if the power supply battery is insufficient:

[0067] See Figure 3 , Figure 3 This is a schematic diagram illustrating the process for determining whether the power supply battery is insufficient, as provided in an embodiment of this application. Figure 3 As shown, the process includes the following steps:

[0068] S301, detects whether the current power load of the power supply battery exceeds the set load threshold.

[0069] In this step, the current charge load of the power supply battery is determined based on the sum of the current charge load of the first power supply circuit and the current charge load of the second power supply circuit.

[0070] If the result of step S301 is yes, then it is determined that the power supply battery is insufficient.

[0071] If the result of step S301 is negative, then step S302 is executed.

[0072] S302, detect whether the current remaining power of the power supply battery is less than the set remaining power threshold.

[0073] If the result of step S302 is yes, then it is determined that the power supply battery is insufficient.

[0074] If the result of step S303 is negative, then after a specified time interval, return to step S301.

[0075] It should be noted that the above steps are performed before the power supply battery shuts down after all the cached data in memory has been successfully stored to the backup disk, because the above steps cannot be performed once the power supply battery is shut down.

[0076] In this embodiment, by means of the above method, it is accurately determined that the power supply battery is insufficient. When the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, so that the limited battery resources can be used to power the second power supply circuit with relatively low power consumption, thereby extending the storage time of the remaining cached data in the memory with the same amount of remaining power.

[0077] The above provides a detailed explanation of how to determine whether the power supply battery is insufficient.

[0078] The following section elaborates on determining whether cached data in memory is valid:

[0079] First, let's introduce the specific format for tagging targets:

[0080] As an example, the specific implementation of tagging cached data in each cache region can be as follows: For each cache partition, a specified operation is performed on the cached data located at logical block addresses (LBAs) in a specified order within that cache partition (that is, a specified operation is performed on the cached data at logical addresses X1 to X2 in that cache partition). Here, the specified operation includes at least a hash operation. The result of the operation is used as the tag for the cached data in that cache partition, so that the tag is carried by the cached data in that cache partition. Optionally, the tag is carried by the cached data located at logical addresses in the specified order within that cache partition. In other words, the tag is carried in the data based on which cached data in the cache partition is used to generate the tag.

[0081] For example, memory is divided into three cache partitions according to LBA: LBA1-LBA100, LBA101-LBA200, and LBA201-LBA300. The cached data at logical addresses 1-16 in each cache partition is hashed. The hash values ​​calculated for each of the three cache partitions are used as tags, and the cached data at logical addresses 1-16 in each of the three cache partitions carries these tags.

[0082] The reason for partitioning and labeling cached data in memory is to prevent false positives. When external power is restored, random numbers are generated in the system memory due to the operation of the storage system. If only one label is given to cached data in memory, it's easy to mistakenly determine the data's validity based on these random numbers. However, by labeling multiple cache partitions, the probability of all partitions being misjudged is very low. Therefore, reducing the false positive rate improves the accuracy of determining the validity of cached data.

[0083] Next, let's explain how to determine if cached data in memory is valid:

[0084] See Figure 4 , Figure 4 This is a schematic diagram illustrating the process for determining whether cached data in memory is valid, provided in an embodiment of this application. Figure 4 As shown, the process includes the following steps:

[0085] S401 determines whether the cached data in each cache partition carries a tag.

[0086] For example, continuing from the previous example, the cache data carrying tag for each cache partition refers to the cache data carrying tag on the 1st to 16th logical addresses of that cache partition.

[0087] If the result of step S401 is negative, then the cached data in memory is determined to be invalid. That is, if the cached data in each cache partition does not carry a tag, then the cached data in memory is determined to be invalid.

[0088] For example, continuing from the previous example, if the cached data in the first 16 LBAs of the three cache partitions does not carry tags, that is, the tags have been cleared, then the cached data in memory is determined to be invalid.

[0089] If the result of step S401 is yes, then step S402 is executed.

[0090] S402, determine whether the tags of the cached data in each cache partition have passed the verification.

[0091] If the result of step S402 is yes, then the cached data in memory is determined to be valid. That is, if the cached data in each cache partition carries a tag, and the tag of the cached data in each cache partition passes the verification, then the cached data in memory is determined to be valid.

[0092] If the result of step S402 is negative, then the cached data in memory is determined to be invalid. That is, if the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

[0093] Here, the specific implementation for verifying the tags of cached data in any cache partition is as follows: A specified operation is performed on the cached data located at logical addresses in a specified order within the cache partition. The result of the operation is then compared to the tags carried by the cached data in that cache partition. If the result matches, the cache partition passes the verification; otherwise, it fails the verification.

[0094] For example, continuing from the previous example, for each cache partition, perform the same hash operation as when tagging the cached data carrying the tag in the cache partition (that is, the cached data at the 1st to 16th logical addresses). Compare the hash operation result obtained now with the hash operation result represented by the tag. If the two are the same, it is determined that the cache partition has passed the verification. If the two are different, it is determined that the cache partition has failed the verification.

[0095] In this embodiment, the above method is used to determine whether to read data from memory or from the backup disk after the external power supply is restored.

[0096] The above provides a detailed explanation of how to determine whether cached data in memory is valid.

[0097] This concludes the description of the method provided in this embodiment. The apparatus provided in this application embodiment will now be described:

[0098] See Figure 5 , Figure 5 This is a schematic diagram of the device provided in an embodiment of this application. The device is applied to a storage device; a power supply battery is configured inside the storage device; the power supply battery is divided into two circuits to supply power to the device and the memory on the device respectively, wherein the circuit supplying power to the device is a first power supply circuit, and the circuit supplying power to the memory is a second power supply circuit; an abnormality in the power supply from the first power supply circuit to the device does not affect the power supply from the second power supply circuit to the memory. Figure 5 As shown, the device 500 includes: a power control module 501, a first data processing module 502, and a second data processing module 503.

[0099] The power control module 501 is used to start the power supply battery to supply power to the device and the memory on the device in two separate circuits when the external power supply is detected to be lost; when the device is powered by the power supply battery, it starts to store the cached data in the memory to the specified non-volatile storage medium; when the power supply battery is insufficient, it cuts off the power supply of the first power supply circuit and maintains the power supply of the second power supply circuit.

[0100] The first data processing module 502 is used to assign tags to cached data located in different cache partitions; memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in memory is valid; when all the cached data in memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0101] The second data processing module 503 is used to determine whether the cached data in memory is valid based on the tag status of the cached data in each cache partition in memory after the external power supply is restored; if the cached data in memory is determined to be invalid, the previously stored cached data is read from the specified non-volatile storage medium and executed in memory; if the cached data in memory is determined to be valid, the cached data in memory is read directly and executed.

[0102] As one example, determining whether the power supply battery is insufficient includes the following steps:

[0103] Detect whether the current charge load of the power supply battery exceeds a set load threshold; the current charge load of the power supply battery is determined based on the sum of the current charge load of the first power supply circuit and the current charge load of the second power supply circuit.

[0104] If yes, then the power supply battery is insufficient; if no, then:

[0105] Further check whether the current remaining power of the power supply battery is less than the set remaining power threshold. If so, it is determined that the power supply battery is insufficient; if not, after a specified time interval, return to the step of checking whether the current power load of the power supply battery exceeds the set load threshold.

[0106] As one example, assigning tags to cached data located in different cache partitions includes:

[0107] For each cache partition, perform a specified operation on the cached data located at logical addresses in a specified order within that cache partition, and use the result of the operation as the label for the cached data in that cache partition.

[0108] As an example, determining whether cached data in memory is valid based on the tag information of each cache partition in memory includes:

[0109] If none of the cached data in each cache partition carries a tag, then the cached data in memory is determined to be invalid.

[0110] If the cached data in each cache partition carries a tag, and the tags of the cached data in each cache partition pass the verification, then the cached data in memory is considered valid.

[0111] If the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

[0112] As one example, verifying the tag of cached data in any cache partition includes the following steps:

[0113] Perform specified operations on cached data located at logical addresses in a specified order within the cache partition;

[0114] Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition;

[0115] If yes, the cache partition is deemed to have passed verification; otherwise, the cache partition is deemed to have failed verification.

[0116] As one example, the power control power supply is further used for:

[0117] Without disconnecting the power supply to the first power supply circuit, and after confirming that all cached data in memory has been successfully written to the designated non-volatile storage medium, the power supply battery is turned off to shut down the device; prior to turning off the power supply battery, the tags carried by the cached data in each cache partition have been cleared.

[0118] This concludes the process. Figure 5 Structural description of the device shown.

[0119] Please see Figure 6 , Figure 6 This is a structural diagram of a storage device provided in an embodiment of this application. Figure 6 As shown, the device 600 includes: a power supply battery 601, a power control component 602, a controller 603, and a memory 604.

[0120] The internally configured power supply battery is used to supply power to the device and the memory on the device in two separate circuits. The circuit that supplies power to the device is the first power supply circuit, and the circuit that supplies power to the memory is the second power supply circuit. An abnormality in the power supply of the first power supply circuit to the device will not affect the power supply of the second power supply circuit to the memory.

[0121] The power control component is used to activate the power supply battery to supply power to the device and the memory on the device in two separate circuits when an external power failure is detected; when the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained.

[0122] Controller, used for:

[0123] Tags are assigned to cached data located in different cache partitions; memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in memory is valid; when all the cached data in memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared.

[0124] After the external power supply is restored, the system determines whether the cached data in memory is valid based on the tag status of the cached data in each cache partition in memory. If the cached data in memory is determined to be invalid, the system reads the previously stored cached data from the specified non-volatile storage medium into memory for execution. If the cached data in memory is determined to be valid, the system directly reads the cached data in memory for execution.

[0125] As one example, the power control component performs the following steps in determining whether the power supply battery is insufficient:

[0126] Detect whether the current charge load of the power supply battery exceeds a set load threshold; the current charge load of the power supply battery is determined based on the sum of the current charge load of the first power supply circuit and the current charge load of the second power supply circuit.

[0127] If yes, then the power supply battery is insufficient; if no, then:

[0128] Further check whether the current remaining power of the power supply battery is less than the set remaining power threshold. If so, it is determined that the power supply battery is insufficient; if not, after a specified time interval, return to the step of checking whether the current power load of the power supply battery exceeds the set load threshold.

[0129] As one example, when the controller assigns tags to cached data located in different cache partitions, it specifically performs the following:

[0130] For each cache partition, perform a specified operation on the cached data located at logical addresses in a specified order within that cache partition, and use the result of the operation as the label for the cached data in that cache partition.

[0131] As one example, when the controller determines whether the cached data in memory is valid based on the tag status of each cache partition in memory, it specifically performs the following:

[0132] If none of the cached data in each cache partition carries a tag, then the cached data in memory is determined to be invalid.

[0133] If the cached data in each cache partition carries a tag, and the tags of the cached data in each cache partition pass the verification, then the cached data in memory is considered valid.

[0134] If the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

[0135] In one embodiment, the controller, when performing the verification of the tag of cached data for any cache partition, specifically uses:

[0136] Perform specified operations on cached data located at logical addresses in a specified order within the cache partition;

[0137] Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition;

[0138] If yes, the cache partition is confirmed to have passed verification; otherwise, the cache partition is confirmed to have failed verification.

[0139] The controller is specifically used to: validate the tags of cached data in any cache partition

[0140] Perform specified operations on cached data located at logical addresses in a specified order within the cache partition;

[0141] Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition;

[0142] If yes, the cache partition is deemed to have passed verification; otherwise, the cache partition is deemed to have failed verification.

[0143] As an example, when the power control component determines that the power supply to the first power supply circuit has not been cut off and the tags carried by the cache data of each cache partition have been cleared, it turns off the power supply battery to shut down the device.

[0144] Please see Figure 7 , Figure 7 This is a structural diagram of an electronic device provided in an embodiment of this application. Figure 7 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.

[0145] Based on the same application concept as the above method, this application embodiment also provides a machine-readable storage medium storing a plurality of computer instructions, which, when executed by a processor, can implement the method disclosed in the above examples of this application.

[0146] For example, the aforementioned machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, etc. For instance, machine-readable storage media can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0147] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for protecting cached data, characterized by, This method is applied to a storage device; the storage device is internally equipped with a power supply battery; the power supply battery is divided into two circuits to supply power to the device and the memory on the device respectively, wherein the circuit supplying power to the device is a first power supply circuit, and the circuit supplying power to the memory is a second power supply circuit; an abnormality in the power supply from the first power supply circuit to the device does not affect the power supply from the second power supply circuit to the memory; the method includes: When an external power failure is detected, the power supply battery is activated to supply power to the device and the memory on the device in two separate circuits. When the device is powered by the power supply battery, it begins to store cached data in the memory into a designated non-volatile storage medium. When the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained. Tags are assigned to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared. After the external power supply is restored, based on the tag status of the cache data in each cache partition in the memory, it is determined whether the cache data in the memory is valid; if it is determined that the cache data in the memory is invalid, the previously stored cache data is read from the specified non-volatile storage medium and executed in memory; if it is determined that the cache data in the memory is valid, the cache data in the memory is directly read and executed. The step of determining whether the cached data in memory is valid based on the tag information of each cache partition in the memory includes: If none of the cached data in each cache partition carries a tag, then the cached data in memory is determined to be invalid. If the cached data in each cache partition carries a tag, and the tags of the cached data in each cache partition pass the verification, then the cached data in memory is determined to be valid. If the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

2. The method according to claim 1, characterized in that, Determining whether the power supply battery is insufficient includes the following steps: Detect whether the current power load of the power supply battery exceeds a set load threshold; the current power load of the power supply battery is determined based on the sum of the current power load of the first power supply circuit and the current power load of the second power supply circuit; If yes, then the power supply battery is insufficient; if no, then: Further detect whether the current remaining power of the power supply battery is less than the set remaining power threshold. If so, it is determined that the power supply battery is insufficient. If not, after a specified time interval, return to the step of detecting whether the current power load of the power supply battery exceeds the set load threshold.

3. The method according to claim 1, characterized in that, Assigning tags to cached data located in different cache partitions includes: For each cache partition, perform a specified operation on the cached data located at logical addresses in a specified order within that cache partition, and use the result of the operation as the label for the cached data in that cache partition.

4. The method according to claim 1, characterized in that, Verifying the tags of cached data in any cache partition includes the following steps: Perform specified operations on cached data located at logical addresses in a specified order within the cache partition; Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition; If yes, the cache partition is deemed to have passed verification; otherwise, the cache partition is deemed to have failed verification.

5. The method according to claim 1, characterized in that, The method further includes: Without disconnecting the power supply to the first power supply circuit, when it is determined that all cached data in memory has been successfully written to the designated non-volatile storage medium, the power supply battery is turned off to shut down the device; wherein, before turning off the power supply battery, the tags carried by the cached data in each cache partition have been cleared.

6. A cached data protection device, characterized in that, This device is applied to a storage device; the storage device is internally equipped with a power supply battery; the power supply battery supplies power to the device and the memory on the device respectively, wherein the power supply circuit supplying the device is a first power supply circuit, and the power supply circuit supplying the memory is a second power supply circuit; an abnormality in the power supply of the first power supply circuit to the device does not affect the power supply of the second power supply circuit to the memory; the device includes: The power control module is used to activate the power supply battery to supply power to the device and the memory on the device in two separate circuits when an external power failure is detected; when the device is powered by the power supply battery, it starts to store cached data in the memory into a designated non-volatile storage medium; when the power supply battery is insufficient, it cuts off the power supply to the first power supply circuit and maintains the power supply to the second power supply circuit. The first data processing module is used to assign tags to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared. The second data processing module is used to determine whether the cached data in the memory is valid based on the tag status of the cached data in each cache partition in the memory after the external power supply is restored; if the cached data in the memory is determined to be invalid, the previously stored cached data is read from the specified non-volatile storage medium and executed in the memory; if the cached data in the memory is determined to be valid, the cached data in the memory is directly read and executed. The step of determining whether the cached data in memory is valid based on the tag information of each cache partition in the memory includes: If none of the cached data in each cache partition carries a tag, then the cached data in memory is determined to be invalid. If the cached data in each cache partition carries a tag, and the tags of the cached data in each cache partition pass the verification, then the cached data in memory is determined to be valid. If the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

7. The apparatus according to claim 6, characterized in that, Determining whether the power supply battery is insufficient includes the following steps: Detect whether the current power load of the power supply battery exceeds a set load threshold; the current power load of the power supply battery is determined based on the sum of the current power load of the first power supply circuit and the current power load of the second power supply circuit; If yes, then the power supply battery is insufficient; if no, then: Further detect whether the current remaining power of the power supply battery is less than the set remaining power threshold. If so, it is determined that the power supply battery is insufficient. If not, after a specified time interval, return to the step of detecting whether the current power load of the power supply battery exceeds the set load threshold. And / or, Assigning tags to cached data located in different cache partitions includes: For each cache partition, perform a specified operation on the cached data located at logical addresses in a specified order within that cache partition, and use the result of the operation as the tag for the cached data in that cache partition. And / or, Verifying the tags of cached data in any cache partition includes the following steps: Perform specified operations on cached data located at logical addresses in a specified order within the cache partition; Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition; If yes, the cache partition is confirmed to have passed verification; otherwise, the cache partition is confirmed to have failed verification. And / or, The power control module is further used for: Without disconnecting the power supply to the first power supply circuit, when it is determined that all cached data in memory has been successfully written to the designated non-volatile storage medium, the power supply battery is turned off to shut down the device; wherein, before turning off the power supply battery, the tags carried by the cached data in each cache partition have been cleared.

8. A storage device, characterized in that, The device includes: The internally configured power supply battery is used to supply power to the device and the memory on the device in two separate circuits. The circuit that supplies power to the device is the first power supply circuit, and the circuit that supplies power to the memory is the second power supply circuit. An abnormality in the power supply of the first power supply circuit to the device does not affect the power supply of the second power supply circuit to the memory. A power control component is used to activate the power supply battery to supply power to the device and the memory on the device in two separate circuits when an external power failure is detected; when the power supply battery is insufficient, the power supply to the first power supply circuit is cut off, while the power supply to the second power supply circuit is maintained. Controller, used for: When the power control component activates the power supply battery to supply power to the device and the memory on the device in two separate circuits, it controls the storage of cached data in the memory to a designated non-volatile storage medium. Tags are assigned to cached data located in different cache partitions; the memory is divided into N cache partitions according to logical addresses; N is greater than or equal to 3; the tags carried by the cached data in the N cache partitions are used together to verify whether the cached data in the memory is valid; when all the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data in each cache partition are cleared. After the external power supply is restored, based on the tag status of the cache data in each cache partition in the memory, it is determined whether the cache data in the memory is valid; if it is determined that the cache data in the memory is invalid, the previously stored cache data is read from the specified non-volatile storage medium and executed in memory; if it is determined that the cache data in the memory is valid, the cache data in the memory is directly read and executed. The step of determining whether the cached data in memory is valid based on the tag information of each cache partition in the memory includes: If none of the cached data in each cache partition carries a tag, then the cached data in memory is determined to be invalid. If the cached data in each cache partition carries a tag, and the tags of the cached data in each cache partition pass the verification, then the cached data in memory is determined to be valid. If the cached data in each cache partition carries a tag, and the tag of the cached data in at least one cache partition fails the verification, then the cached data in memory is determined to be invalid.

9. The storage device according to claim 8, characterized in that, The power control component performs the following steps to determine whether the power supply battery is insufficient: Detect whether the current power load of the power supply battery exceeds a set load threshold; the current power load of the power supply battery is determined based on the sum of the current power load of the first power supply circuit and the current power load of the second power supply circuit; If yes, then the power supply battery is insufficient; if no, then: Further detect whether the current remaining power of the power supply battery is less than the set remaining power threshold. If so, it is determined that the power supply battery is insufficient. If not, after a specified time interval, return to the step of detecting whether the current power load of the power supply battery exceeds the set load threshold. And / or, When the controller performs the task of assigning tags to cached data located in different cache partitions, it is specifically used for: For each cache partition, perform a specified operation on the cached data located at logical addresses in a specified order within that cache partition, and use the result of the operation as the tag for the cached data in that cache partition. And / or, The controller is specifically used to: perform the verification of the tags of cached data in any cache partition. Perform specified operations on cached data located at logical addresses in a specified order within the cache partition; Determine whether the obtained calculation result matches the tag carried by the cached data of the cache partition; If yes, the cache partition is confirmed to have passed verification; otherwise, the cache partition is confirmed to have failed verification. And / or, When the power control component determines that the power supply to the first power supply circuit has not been cut off, and the tags carried by the cache data of each cache partition have been cleared, it shuts down the power supply battery to shut down the device.

Citation Information

Patent Citations

  • Power supply management method based on vehicle-mounted wireless terminal

    CN105109429A

  • Memory device cache synchronization

    US20240272806A1