Cache data protection method and device and storage equipment

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

CN120973204APending Publication Date: 2025-11-18MACROSAN TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511073709.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-18

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. The first power supply circuit powers the device, while the second power supply circuit is dedicated to the memory. When the external power supply fails, both power supplies are activated to ensure that memory data is written to non-volatile storage media. In case of insufficient power supply, the first power supply is cut off while the second power supply is maintained. The memory is divided into multiple cache partitions and tagged. After the external power supply is restored, the validity of the data is determined based on the tags.

Benefits of technology

It improves the reliability of cached data protection, reduces the probability of data loss, extends data retention time, ensures the storage system can quickly resume operation, and improves work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973204A_ABST
    Figure CN120973204A_ABST
Patent Text Reader

Abstract

The invention provides a cache data protection method and device and storage equipment. In the application, the power supply battery is divided into two paths to respectively supply power to the equipment mainboard and the equipment memory, the abnormity of the first power supply circuit for supplying power to the equipment does not influence the power supply of the second power supply circuit to the memory, and when the power failure of the external power supply is detected, the power supply battery is started to supply power; and when the power supply battery supplies power insufficiently, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained. Therefore, under the condition that the standby power supply unit is powered on, the internal memory is continuously powered on, even if CPU faults, controller mainboard faults and nonvolatile storage medium faults occur, cache data persistence cannot be completed due to insufficient power supply of a power supply battery and the like, the residual cache data in the internal memory cannot be instantly lost, the probability of cache data loss is reduced, and the reliability of the cache data is improved. Therefore, the protection effect of the cache data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data storage, and in particular to a cache data protection method and device and a storage device. BACKGROUND

[0002] In a storage system, a cache is set in the memory of a storage device. When processing data, the front-end service data is first written into the memory, and then the cache data in the memory is written into a non-volatile storage medium, which greatly improves the response speed and processing capacity of the storage system. However, the cache is a volatile storage, and once the external power supply is lost, the cache data will be lost instantly, affecting the data integrity and consistency of the storage system.

[0003] At present, in order to protect the cache data from being lost, a backup power supply battery is usually provided in the storage device to supply power to the storage device when the external power supply is lost, so as to write the cache data into the non-volatile storage medium.

[0004] However, in the above-mentioned manner, the cache data will still be lost when the storage device has an abnormality, such as CPU (Central Processing Unit) failure, controller mainboard failure, non-volatile storage medium failure, and lack of backup battery power, which cannot successfully complete the persistence, resulting in an unsatisfactory cache data protection effect. SUMMARY

[0005] Therefore, the embodiments of the present application provide a cache data protection method, device and storage device to improve the protection effect of the cache data and improve the reliability of the cache data protection.

[0006] The embodiments of the present application provide a cache data protection method, which is applied to a storage device; the storage device is internally configured with a backup power supply battery; the backup power supply battery supplies power to the device and the memory on the device in two paths, wherein the power supply to the device is as a first power supply circuit, and the power supply to the memory is as a second power supply circuit; the abnormality of 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; the method comprises the following steps:

[0007] When detecting that the external power supply is lost, the backup power supply battery supplies power to the device and the memory on the device in two paths; when the device is powered by the backup power supply battery, the cache data in the memory is stored into a designated non-volatile storage medium; when the backup power supply battery is insufficient, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained;

[0008] The cache data in different cache partitions is respectively assigned a tag; 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 cache data in the N cache partitions are used together to verify whether the cache data in the memory is valid; when the cache data in the memory is successfully written into the specified non-volatile storage medium, the tags carried by the cache data in each cache partition are cleared;

[0009] After the external power supply resumes power supply, whether the cache data in the memory is valid is determined based on the tag condition of the cache data in each cache partition in the memory; 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 to the memory for running; if it is determined that the cache data in the memory is valid, the cache data in the memory is directly read for running.

[0010] The embodiment of the application also provides a cache data protection device, which is applied to a storage device; the storage device is internally configured with a power supply battery; the power supply battery supplies power to the device and the memory on the device in two paths, wherein the first power supply circuit supplies power to the device, and the second power supply circuit supplies power to the memory; the abnormality of 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; the device comprises:

[0011] A power supply control module is configured to start the power supply battery to supply power to the device and the memory on the device in two paths when detecting that the external power supply is powered off; the cache data in the memory is stored into a specified non-volatile storage medium when the device is powered by the power supply battery; when the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained;

[0012] A first data processing module is configured to respectively assign a tag to the cache data 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 cache data in the N cache partitions are used together to verify whether the cache data in the memory is valid; when the cache data in the memory is successfully written into the specified non-volatile storage medium, the tags carried by the cache data in each cache partition are cleared;

[0013] A second data processing module is configured to determine whether the cache data in the memory is valid after the external power supply resumes power supply based on the tag condition of the cache data in each cache partition in the memory; 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 to the memory for running; if it is determined that the cache data in the memory is valid, the cache data in the memory is directly read for running.

[0014] The embodiment of the present application also provides a storage device, which comprises:

[0015] an internally configured power supply battery for supplying power to the device and the memory on the device in two paths respectively, wherein the power supply to the device is as a first power supply circuit and the power supply to the memory is as a second power supply circuit; the abnormal 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 supply control component for starting the power supply battery to supply power to the device and the memory on the device in two paths respectively when detecting power failure of an external power supply; cutting off the power supply of the first power supply circuit and maintaining the power supply of the second power supply circuit when the power supply of the power supply battery is insufficient;

[0017] a controller for:

[0018] controlling storage of cached data in the memory into a designated non-volatile storage medium when the power supply control component starts the power supply battery to supply power to the device and the memory on the device in two paths respectively;

[0019] allocating tags to cached data in different cache partitions respectively; 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 of the N cache partitions are used together to verify whether the cached data in the memory is valid; when the cached data in the memory is successfully written into the designated non-volatile storage medium completely, the tags carried by the cached data of each cache partition are cleared;

[0020] after the external power supply resumes power supply, judging whether the cached data in the memory is valid based on the tag condition of the cached data in each cache partition in the memory; if it is determined that the cached data in the memory is invalid, reading the previously stored cached data from the designated non-volatile storage medium to the memory for running; if it is determined that the cached data in the memory is valid, directly reading the cached data in the memory for running.

[0021] The embodiment of the present application also provides an electronic device, which comprises a processor and a memory for storing computer program instructions, and the computer program instructions make the processor execute the steps of the above method when being executed by the processor.

[0022] The embodiment of the present application also provides a machine readable storage medium, which stores computer program instructions, and the computer program instructions can implement the steps of the above method when being executed.

[0023] It can be seen from the above technical solutions that, in the embodiment, the power supply battery is divided into two paths to supply power to the device mainboard and the device memory respectively, the abnormality of the first power supply circuit for supplying power to the device does not affect the power supply of the second power supply circuit to the memory, when the external power supply is detected to be powered off, the power supply battery is started to supply power to the device and the memory on the device in two paths, and the cached data in the memory is started to be written into the non-volatile storage medium, when the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained. In this way, the memory is continuously powered in the case that the backup power supply unit has power, even if the CPU fails, the controller mainboard fails, the non-volatile storage medium fails, and the power supply battery is insufficient to complete the cache data persistence, and the like, the remaining cached data in the memory will not be lost instantaneously, the probability of loss of cached data is reduced, and the protection effect of cached data is improved, so as to determine the integrity of cached data.

[0024] Further, since the power supply battery only supplies power to the memory component, the power consumption is smaller than that in the related art, therefore, when the power supply battery is insufficient to successfully complete the persistence, the remaining time of the remaining cached data in the memory can be extended with relatively low power consumption and the same remaining power, thereby improving the protection effect of the cached data.

[0025] Further, by dividing the memory into N cache regions and labeling each cache region, it is determined whether the cached data in the memory is valid through the labels corresponding to the N cache regions after the external power supply is restored, thereby avoiding misjudgment, so as to accurately determine whether to read data from the memory or from the specified non-volatile storage medium, and then the storage device is quickly restored to operation, and the working efficiency of the storage system is improved. BRIEF DESCRIPTION OF DRAWINGS

[0026] Figure 1 A network architecture diagram of a storage system provided by the embodiment of the application is provided;

[0027] Figure 2 A flowchart of the method provided by the embodiment of the application is provided;

[0028] Figure 3 A flowchart of determining whether the power supply battery is insufficient is provided;

[0029] Figure 4 A flowchart of determining whether the cached data in the memory is valid is provided;

[0030] Figure 5 A structure diagram of the device provided by the embodiment of the application is provided;

[0031] Figure 6A structural diagram of a storage device provided by the embodiment of the present application is shown in the following figure;

[0032] Figure 7 A hardware structure schematic diagram of an electronic device provided by the embodiment of the present application is shown in the following figure. DETAILED DESCRIPTION

[0033] In order for those skilled in the art to better understand the technical solutions provided by the embodiment of the present application, and to make the above-mentioned purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the technical solutions in the embodiment of the present application are further described in detail below with reference to the drawings.

[0034] In order to facilitate the understanding of the present solution, before describing the present solution, the technical problems are described in combination with Figure 1 the network architecture diagram of a storage system shown in the following figure:

[0035] Referring to Figure 1 , Figure 1 A network architecture diagram of a storage system provided by the embodiment of the present application is shown in the following figure. As shown in the figure, Figure 1 the storage system is a centralized storage system, and the method provided by the embodiment of the present application is implemented on the basis of the network architecture. Specifically, the server receives read and write operations, and the storage device (also referred to as a head) writes the front-end business data into the memory when processing the data of the read and write operations, and then writes the cache data in the memory into the non-volatile storage medium (i.e. the disk array shown in Figure 1 When the storage device is normally working, it is powered by an external power supply. When the external power supply of the storage device is abnormal (for example, abnormal power failure of the computer room, power failure, etc.), the cache data in the memory will be lost instantly, affecting the data integrity and consistency of the storage system.

[0036] At present, in order to protect the cache data from being lost, a backup power supply is usually provided in the storage device to supply power to the storage device when the external power supply is powered off, so as to write the cache data into the non-volatile storage medium (also referred to as a backup disk). In this way, when the external power supply is restored, the cache data can be read from the hard disk to the memory when the storage device is started again, so as to ensure that the cache data will not be lost

[0037] However, the storage device may have some abnormalities, which will cause the device to fail to completely persist the data to the non-volatile storage medium, resulting in loss of cache data. Typical abnormalities include at least the following cases:

[0038] 1. After the external power supply is powered off, the CPU fails when persisting the cache data in the memory to the backup disk, and the CPU needs to be replaced to recover. The replacement of the CPU will inevitably cause the loss of cache 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 enhance 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 detecting the power failure of the external power supply, starting the power supply battery to supply power to the device and the memory on the device in two ways; when the device is powered by the power supply battery, start storing the cached data in the memory to the specified non-volatile storage medium; when the power supply battery is insufficient, cut off the power supply of the first power supply circuit, and maintain the power supply of the second power supply circuit.

[0050] In this step, as long as the power supply battery is started, the memory is always powered through the second power supply circuit, regardless of whether the power supply battery is sufficient. Even if the CPU fails, the controller mainboard fails, the backup disk fails, and the power supply battery is insufficient to complete the cache data persistence (that is, the power supply of the first power supply circuit is cut off), and the cached data in the memory fails to be successfully written to the backup disk, the remaining cached data in the memory will not be lost instantaneously.

[0051] When the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained, which can use the limited battery resources for the power supply of the second power supply circuit with relatively low power consumption, and prolong the saveable time of the remaining cached data in the memory under the same remaining power. Moreover, this adaptive switching from simultaneous power supply to separate power supply for the memory makes the protection strategy of cached data more flexible and can cope with more complex actual operating environments, improving the reliability of cached data protection.

[0052] As an embodiment, if no CPU failure, controller mainboard failure, backup disk failure, and power supply battery insufficient to complete cache data persistence (that is, the power supply of the first power supply circuit is cut off) occurs, and if it is determined that the cached data in the memory is successfully written to the backup disk, the power supply battery is turned off to turn off the device.

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

[0054] Whether the power supply battery is insufficient will be described in the form of a specific embodiment in the following, which will not be described here.

[0055] S202, respectively assigning 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 of the N cache partitions are collectively used to verify whether the cached data in the memory is valid; when the cached data in the memory is successfully written to the specified non-volatile storage medium, the tags carried by the cached data of each cache partition are cleared.

[0056] When the external power supply is powered off, the upper layer service no longer has new operations, at this time, the above-mentioned label can be used as a basis for judging whether the data needs to be read from the backup disk or the memory after the subsequent external power supply is restored, that is, as a basis for judging whether the cached data in the memory is valid after the subsequent external power supply is restored (if valid, read data from the memory, if invalid, read data from the backup disk).

[0057] The reason why it can be used as a basis is that: if the above-mentioned abnormal situation does not occur, the cached data in the memory is successfully written to the backup disk in its entirety, the target label has been cleared before the power supply is powered off, and the cached data of each cache partition does not carry a label. If the above-mentioned abnormal situation occurs, the cached data in the memory is not successfully written to the backup disk in its entirety, the label of the cached data of each cache partition is not cleared, and the cached data in the memory carries a label. Therefore, the label can be used as a basis for judging whether the cached data in the memory is valid after the external power supply is restored.

[0058] It should be noted that in the related art, when the external power supply of the present storage device is normally running, the cached data (also referred to as dirty data) in the memory that needs to be persisted but has not been persisted to the corresponding non-volatile storage medium will be marked with a dirty label. When it is written to the non-volatile storage medium indicated by the upper layer service operation, this dirty label will also be cleared. This process is similar to the related art, and will not be described in detail here. Here, the dirty label is different from the label marked on the cached data of each cache partition to indicate whether it is valid data, and should not be confused.

[0059] As for how each cache region is labeled and how to determine whether the cached data in the memory is valid after the external power supply is restored, it will be described later, and will not be described here.

[0060] S203, after the external power supply is restored, based on the label of the cached data of 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 to the memory for running.

[0061] In this embodiment set, the specific implementation manner of judging whether the cached data in the memory is valid will be described later in the form of specific embodiments, and will not be described here.

[0062] At this point, the process shown in the flowchart is completed. Figure 2 The flowchart shown in the figure.

[0063] By Figure 2As shown in the flow, in the embodiment, the power supply battery is divided into two paths to supply power to the device mainboard and the device memory respectively, the abnormality of the first power supply circuit for supplying power to the device does not affect the power supply of the second power supply circuit to the memory, when detecting power failure of the external power supply, the power supply battery is divided into two paths to supply power to the device and the memory on the device respectively, and the cached data in the memory is started to be written into the non-volatile storage medium, when the power supply battery is insufficient, the power supply of the first power supply circuit is cut off, and the power supply of the second power supply circuit is maintained. In this way, the memory is continuously powered in the case that the backup power supply unit has power, even if the CPU fails, the controller mainboard fails, the non-volatile storage medium fails, and the power supply battery is insufficient to complete the caching data persistence, and the like, the remaining cached data in the memory will not be lost instantaneously, the probability of losing cached data is reduced, and the protection effect of cached data is improved to determine the integrity of cached data.

[0064] Further, since the power supply battery only supplies power to the memory component, the power consumption is smaller than that in the related art, therefore, when the power supply power supply is insufficient to successfully complete the persistence, the remaining cached data in the memory can be saved for a longer time with relatively low power consumption and the same remaining power, thereby improving the protection effect of cached data.

[0065] Further, by dividing the memory into N cache regions and labeling each cache region, it is determined whether the cached data in the memory is valid through the labels corresponding to the N cache regions after the external power supply is restored, thereby avoiding misjudgment, and accurately determining whether to read data from the memory or the 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 determination of whether the power supply battery is insufficient will be described in detail below:

[0067] Referring to Figure 3 , Figure 3 The flowchart for determining whether the power supply battery is insufficient is provided for the embodiment of the application. As Figure 3 shown, the flow includes the following steps:

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

[0069] In this step, 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.

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

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

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

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

[0074] If the execution result of step S303 is no, then after a specified time interval, the above step S301 is returned to.

[0075] It should be noted that the above steps are executed before the power supply battery is powered off due to successful storage of all cache data in the memory to the backup disk, because once the power supply battery is powered off, the above steps cannot be executed.

[0076] In the embodiment, by the above manner, it is accurately determined that the power supply battery is insufficiently powered, so that when the power supply battery is insufficiently powered, the power supply of the first power supply circuit is cut off, so that the limited battery resources can be used for the power supply of the second power supply circuit with relatively low power consumption, and the remaining cache data in the memory can be stored for a longer time under the same remaining power.

[0077] The above determination of whether the power supply battery is insufficiently powered is described in detail.

[0078] The determination of whether the cache data in the memory is valid is described in detail as follows:

[0079] First, the specific form of the target tag is introduced:

[0080] As an embodiment, the specific implementation manner of tagging the cache data of each cache region can be that, for each cache partition, the cache data on the logical addresses (Logical Block Addressing, LBA) in the specified order in the cache partition is subjected to a specified operation (i.e., the cache data on the X1th to X2th logical addresses in the cache partition is subjected to a specified operation), and the obtained operation result is taken as the tag of the cache data of the cache partition, so that the cache data in the cache partition carries the tag, and optionally, the cache data on the logical addresses in the specified order in the cache partition carries the tag. That is, the tag is generated by which cache data in the cache partition, and the tag is carried in which data.

[0081] For example, the memory is divided into 3 cache partitions according to LBA, LBA1-LBA100, LBA101-LBA200, LBA201-LBA300 as 3 cache partitions, the cache data on the first-16th logical address in each cache partition is subjected to hash operation, the hash values calculated by the three cache partitions are taken as tags, and the cache data on the first-16th logical address in each of the three cache partitions carries the tags.

[0082] The reason for partition management of the cache data in the memory and tagging of different cache regions is to prevent misjudgment, because when the external power supply is restored, random numbers are generated in the system memory due to the running of the storage system, and if the cache data in the memory is tagged, it is easy to misjudge the validity of the cache data according to the random numbers, and the possibility of misjudgment of multiple cache partitions is very low. Therefore, the misjudgment rate is reduced, thereby improving the accuracy of judging whether the cache data is valid.

[0083] Further introduce how to judge whether the cache data in the memory is valid:

[0084] Referring to Figure 4 , Figure 4 The flowchart for judging whether the cache data in the memory is valid provided by the embodiment of the application. As shown in Figure 4 , the flowchart includes the following steps:

[0085] S401, judging whether the cache data of each cache partition carries a tag.

[0086] For example, according to the above example, the cache data of each cache partition carrying a tag means that the cache data on the first-16th logical address of the cache partition carries a tag.

[0087] If the execution result of step S401 is no, it is determined that the cache data in the memory is invalid. That is, if the cache data of each cache partition does not carry a tag, it is determined that the cache data in the memory is invalid.

[0088] For example, according to the above example, the cache data on the first 16 LBAs of the three cache partitions does not carry a tag, that is, the tag has been cleared, so it is determined that the cache data in the memory is invalid.

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

[0090] S402, judging whether the tag of the cache data of each cache partition passes the verification.

[0091] If the execution result of step S402 is yes, it is determined that the cache data in the memory is valid. That is, if the cache data of each cache partition carries a tag, and the tag of the cache data of each cache partition is verified, it is determined that the cache data in the memory is valid.

[0092] If the execution result of step S402 is no, it is determined that the cache data in the memory is invalid. That is, if the cache data of each cache partition carries a tag, and there is at least one cache partition whose cache data tag is not verified, it is determined that the cache data in the memory is invalid.

[0093] Here, the specific implementation of verifying the tag of the cache data of any cache partition is that: the cache data in the cache partition at the specified order of logical addresses is subjected to a specified operation. It is determined whether the obtained operation result matches the tag carried by the cache data of the cache partition. If yes, it is determined that the cache partition is verified, and if no, it is determined that the cache partition is not verified.

[0094] For example, based on the above example, for each cache partition, the cache data (i.e., the cache data at the first to sixteenth logical addresses) in the cache partition carrying the tag is subjected to the same hash operation as when the tag is labeled. The current obtained hash operation result is compared with the hash operation result represented by the tag. If they are the same, it is determined that the cache partition is verified, and if they are different, it is determined that the cache partition is not verified.

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

[0096] The above describes in detail whether the cache data in the memory is valid.

[0097] So far, the method provided in this embodiment is described, and the device provided in this embodiment is described below:

[0098] Referring to Figure 5 , Figure 5 The structure diagram of the device provided in this embodiment is shown. The device is applied to a storage device; the storage device is internally configured with a power supply battery; the power supply battery is divided into two paths to supply power to the device and the memory on the device, wherein the power supply to the device is as a first power supply circuit, and the power supply to the memory is as a second power supply circuit; the abnormality of 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. As shown in Figure 5 , the device 500 includes a power supply control module 501, a first data processing module 502, and a second data processing module 503.

[0099] The power supply control module 501 is configured to start the power supply battery to supply power to the device and the memory on the device in two paths when detecting that the external power supply is powered off; start storing the cached data in the memory to the designated non-volatile storage medium when the device is powered by the power supply battery; and cut off the power supply of the first power supply circuit and maintain the power supply of the second power supply circuit when the power supply battery is insufficiently powered.

[0100] The first data processing module 502 is configured to assign tags to the cached data located in different cache partitions, respectively; 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 of the N cache partitions are collectively used to verify whether the cached data in the memory is valid; and the tags carried by the cached data of each cache partition are cleared when the cached data in the memory is successfully written to the designated non-volatile storage medium.

[0101] The second data processing module 503 is configured to determine whether the cached data in the memory is valid based on the tag condition of the cached data in each cache partition in the memory after the external power supply is restored; read the previously stored cached data from the designated non-volatile storage medium to the memory for running if it is determined that the cached data in the memory is invalid; and directly read the cached data in the memory for running if it is determined that the cached data in the memory is valid.

[0102] As an embodiment, determining whether the power supply battery is insufficiently powered includes the following steps:

[0103] detecting 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;

[0104] if yes, it is determined that the power supply battery is insufficiently powered; and if no, then:

[0105] further detecting whether the current remaining power of the power supply battery is less than a set remaining power threshold; if yes, it is determined that the power supply battery is insufficiently powered; and if no, returning to the step of detecting whether the current power load of the power supply battery exceeds the set load threshold after a specified time interval.

[0106] As an embodiment, assigning tags to the cached data located in different cache partitions, respectively, includes:

[0107] for each cache partition, performing a specified operation on the cached data located in the specified order of logical addresses in the cache partition, and taking the obtained operation result as the tag of the cached data of the cache partition.

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

[0109] if the cache data of each cache partition does not carry the tag, it is determined that the cache data in the memory is invalid;

[0110] if the cache data of each cache partition carries the tag, and the tag of the cache data of each cache partition passes the verification, it is determined that the cache data in the memory is valid;

[0111] if the cache data of each cache partition carries the tag, and there is at least one cache partition whose cache data tag does not pass the verification, it is determined that the cache data in the memory is invalid.

[0112] As an embodiment, the verification of the tag of the cache data of any cache partition includes the following steps:

[0113] performing a specified operation on the cache data at the logical address in the specified order in the cache partition;

[0114] determining whether the obtained operation result matches the tag carried by the cache data of the cache partition;

[0115] if yes, it is determined that the cache partition passes the verification, and if no, it is determined that the cache partition does not pass the verification.

[0116] As an embodiment, the power supply control power supply is further used for:

[0117] when the power supply of the first power supply circuit is not cut off, when it is determined that the cache data in the memory is successfully written to the specified non-volatile storage medium, the power supply battery is turned off to turn off the device; wherein, before the power supply battery is turned off, the tag carried by the cache data of each cache partition has been cleared.

[0118] At this point, the structure description of the device shown in Figure 5 is completed.

[0119] Please refer to Figure 6 , Figure 6 the structural diagram of the storage device provided by the embodiments of the present application. As shown in Figure 6 , the device 600 includes a power supply battery 601, a power supply control component 602, a controller 603 and a memory 604.

[0120] The power supply battery is internally configured to supply power to the device and the memory on the device in two paths, wherein the power supply to the device as the first power supply circuit, and the power supply to the memory as the second power supply circuit; the abnormality of 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;

[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 tag 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, then the cache partition is determined to have passed the verification; otherwise, the cache partition is determined to have failed the verification.

[0139] When the controller performs tag verification on cached data for any cache partition, it is specifically used for:

[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 considered to have passed verification; otherwise, the cache partition is considered 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, the embodiments of the present application also provide a machine readable storage medium, wherein the machine readable storage medium stores a plurality of computer instructions, and the computer instructions can realize the method disclosed in the above examples of the present application when executed by a processor.

[0146] For example, the machine readable storage medium can be a RAM (Random Access Memory), a volatile memory, a non-volatile memory, a flash memory, a storage drive (such as a hard disk drive), a solid state drive, any type of storage disk (such as an optical disk, a DVD, etc.), or similar storage medium, or a combination thereof.

[0147] The above only describes the embodiments of the present application and is not intended to limit the present application. The present application can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the scope of claims of the present application.

Claims

1. A method for protecting cached data, characterized in that, 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 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.

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 tag for the cached data in that cache partition.

4. The method according to claim 1, characterized in that, The determination of 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.

5. The method according to claim 4, 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 considered to have passed verification; otherwise, the cache partition is considered to have failed verification.

6. 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.

7. 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.

8. The apparatus according to claim 7, 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, The determination of 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. 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, then the cache partition is determined to have passed the verification; otherwise, the cache partition is determined to have failed the verification. And / or, The power control power supply 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.

9. 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 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.

10. The storage device according to claim 9, 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, When the controller determines whether the cached data in memory is valid based on the tag status of each cache partition in the memory, it is specifically used for: 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. 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, then the cache partition is determined to have passed the verification; otherwise, the cache partition is determined to have failed the 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

  • Cache memory backup device

    JP1997160838A

  • Magnetic disk device and control method

    JP2006172355A

  • Storage subsystem

    US20160259571A1

  • Memory device cache synchronization

    US20240272806A1