Data protection method and device based on double-partition architecture and medium

By constructing a dual data partitioning structure and a sequential consistency synchronization mechanism, the data recovery problem of embedded systems under abnormal power outages is solved, thus achieving the security and reliability of user data.

CN121029485APending Publication Date: 2025-11-28SHENZHEN WATER WORLD SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511086888.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-04
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

Existing technologies cannot safely recover user data in the event of a sudden power outage in an embedded system. Hardware power failure detection increases costs, and software data backup areas are at risk of data synchronization issues, leading to unreliable or corrupted data.

Method used

A dual-data partition structure is constructed, and a sequentially consistent dual-data partition synchronization mechanism is adopted. After receiving the write command, the target data operation is executed in the dual data partition. After the system is powered on again, the target is detected, and an anomaly recovery strategy is executed based on the detection result.

Benefits of technology

It improves the security of user data in embedded systems under abnormal power outage scenarios, ensures the reliability and integrity of data recovery, and accurately locates and recovers abnormal files through the mutual verification and recovery strategy of dual data partitions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121029485A_ABST
    Figure CN121029485A_ABST
Patent Text Reader

Abstract

The invention discloses a data protection method based on a double-partition architecture. The method comprises the following steps: constructing a double-data-partition structure; after a write-in instruction is received, executing a target data operation in the dual-data partition structure based on a dual-data partition synchronization mechanism of sequence consistency; if it is monitored that the system is powered on again, target detection is conducted on the double-data partition, and a target detection result is obtained; and executing a corresponding exception recovery strategy based on the target detection result, according to the method and the device, the problem that the embedded system cannot safely recover the user data in a sudden abnormal power-off scene is solved, and the safety of the user data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of embedded system data protection, and in particular to a data protection method and device based on a dual-partition architecture and a medium. BACKGROUND

[0002] Many existing technologies increase the reliability of data by adding hardware power failure detection or constructing a software data backup area. However, hardware power failure detection increases costs, and a software data backup area also has the risk of data asynchronization. Therefore, in the scenario of instantaneous abnormal power failure, user data is unreliable or damaged, and the user data cannot be safely recovered. This problem needs to be solved urgently. SUMMARY

[0003] Therefore, the embodiments of the present application provide a data protection method based on a dual-partition architecture to solve the problem that an embedded system cannot safely recover user data in the scenario of sudden abnormal power failure.

[0004] The present application constructs a dual-data partition structure. After receiving a write instruction, a target data operation is performed in the dual-data partition structure based on a sequential consistency dual-data partition synchronization mechanism. If it is monitored that the system is powered on again, target detection is performed on the dual-data partition to obtain a target detection result. Based on the target detection result, a corresponding abnormal recovery strategy is executed. The present application solves the problem that an embedded system cannot safely recover user data in the scenario of sudden abnormal power failure, and improves the security of user data.

[0005] In a first aspect, the embodiments of the present application provide a data protection method based on a dual-partition architecture, which includes the following steps.

[0006] Constructing a dual-data partition structure;

[0007] After receiving a write instruction, a target data operation is performed in the dual-data partition structure based on a sequential consistency dual-data partition synchronization mechanism.

[0008] If it is monitored that the system is powered on again, target detection is performed on the dual-data partition to obtain a target detection result.

[0009] Based on the target detection result, a corresponding abnormal recovery strategy is executed.

[0010] Optionally, the step of constructing a dual-data partition structure includes the following steps.

[0011] The first partition is mounted with read-write permission. The first partition includes at least a first check file and a first data storage directory, and the first data storage directory includes a plurality of first data files.

[0012] mounting the second partition with read-write permissions; wherein the second partition contains at least a second check file and a second data storage directory, and the second data storage directory contains a plurality of second data files.

[0013] Optionally, after receiving the write instruction, based on the sequential consistency dual-data partition synchronization mechanism, the step of performing the target data operation in the dual-data partition structure comprises:

[0014] After receiving the target write instruction, first performing a first write operation on the first data file in the first partition, and second performing a first update operation on the first check file;

[0015] Thirdly, performing the second write operation on the second data file in the second partition, and finally performing the second update operation on the second check file;

[0016] Wherein, the write instruction contains a plurality of target write instructions.

[0017] Optionally, if the system is detected to be powered on again, the step of performing target detection on the dual-data partition to obtain a target detection result comprises:

[0018] If the system is detected to be powered on again, performing data integrity detection on the dual-data partition, if the result of the data integrity detection fails, performing a comparison positioning operation to obtain a target error file, and taking the target error file as the target detection result; or,

[0019] If the system is detected to be powered on again, performing data integrity detection on the dual-data partition, if the result of the data integrity detection fails, performing a flag positioning operation to obtain a target error file, and taking the target error file as the target detection result.

[0020] Optionally, if the system is detected to be powered on again, the step of performing data integrity detection on the dual-data partition, if the result of the data integrity detection fails, performing a comparison positioning operation to obtain a target error file comprises:

[0021] If the system is detected to be powered on again, performing data integrity detection on the first partition and the second partition;

[0022] If the data integrity detection of the first partition and / or the second partition fails, based on the first data file, the first check file, the second data file and the second check file, performing the comparison positioning operation to obtain the target error file of the data integrity detection failure.

[0023] Optionally, if the data integrity detection of the first partition and / or the second partition fails, the step of performing the comparison positioning operation based on the first data file, the first check file, and the second data file, the second check file, to obtain the target error file whose data integrity detection fails, comprises:

[0024] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition succeeds to be checked with the second check file, the first check file is compared with the second check file, and if the first check file is consistent with the second check file, the first data file is taken as a first target error file.

[0025] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition succeeds to be checked with the second check file, the first data file is compared with the second data file, and if the first data file is consistent with the second data file, the first check file is taken as a second target error file.

[0026] If the second data file of the second partition fails to be checked with the second check file and the first data file of the first partition succeeds to be checked with the first check file, the second check file is compared with the first check file, and if the second check file is consistent with the first check file, the second data file is taken as a third target error file.

[0027] If the second data file of the second partition fails to be checked with the second check file and the first data file of the first partition succeeds to be checked with the first check file, the second data file is compared with the first data file, and if the second data file is consistent with the first data file, the second check file is taken as a fourth target error file.

[0028] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition fails to be checked with the second check file, the first data file, the first check file, the second data file, and the second check file are all taken as a fifth target error file.

[0029] Optionally, if the system is detected to be powered on again, data integrity detection is performed on the dual data partition, and if the result of the data integrity detection exists failure, the step of performing a flag bit positioning operation to obtain a target error file comprises:

[0030] if a system re-power is monitored, performing data integrity detection on the first partition and the second partition;

[0031] if the data integrity detection of the first partition and / or the second partition fails, performing flag detection on the dual data partition;

[0032] if a first abnormal flag is obtained, taking the first data file as a first target error file; wherein the first abnormal flag is generated when a system abnormal power-off occurs while the system is performing the first write operation;

[0033] if a second abnormal flag is obtained, taking the first check file as a second target error file; wherein the second abnormal flag is generated when a system abnormal power-off occurs while the system is performing the first update operation;

[0034] if a third abnormal flag is obtained, taking the second data file as a third target error file; wherein the third abnormal flag is generated when a system abnormal power-off occurs while the system is performing the second write operation;

[0035] if a fourth abnormal flag is obtained, taking the second check file as a fourth target error file; wherein the fourth abnormal flag is generated when a system abnormal power-off occurs while the system is performing the second update operation.

[0036] Optionally, the step of executing a corresponding abnormal recovery strategy based on the target detection result comprises:

[0037] if the first data file is taken as the first target error file, copying the second data file into the first partition to overwrite the first data file;

[0038] if the first check file is taken as the second target error file, copying the second check file into the first partition to overwrite the first check file;

[0039] if the second data file is taken as the third target error file, copying the first data file into the second partition to overwrite the second data file;

[0040] if the second check file is taken as the fourth target error file, copying the first check file into the second partition to overwrite the second check file;

[0041] if the first data file, the first check file, the second data file and the second check file are all taken as fifth target error files, copying system default data into the first partition and the second partition to overwrite the first data file, the first check file, the second data file and the second check file.

[0042] In a second aspect, the embodiments of the present application further provide a data protection device based on a dual-partition architecture, the data protection device based on the dual-partition architecture comprising:

[0043] a construction module configured to construct a dual-data-partition structure;

[0044] an execution module configured to, after receiving a write instruction, execute a target data operation in the dual-data-partition structure based on a sequential consistency dual-data-partition synchronization mechanism;

[0045] a detection module configured to, if a system is detected to be powered on again, perform target detection on the dual-data-partition to obtain a target detection result;

[0046] a recovery module configured to execute a corresponding abnormal recovery strategy based on the target detection result.

[0047] In a third aspect, the embodiments of the present application provide a computer storage medium, the computer storage medium storing a data protection method based on a dual-partition architecture, the data protection method based on the dual-partition architecture comprising the steps of any of the data protection methods based on the dual-partition architecture.

[0048] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: a dual-data-partition structure is constructed; after receiving a write instruction, a target data operation is executed in the dual-data-partition structure based on a sequential consistency dual-data-partition synchronization mechanism; if a system is detected to be powered on again, target detection is performed on the dual-data-partition to obtain a target detection result; and a corresponding abnormal recovery strategy is executed based on the target detection result. By constructing a dual-data-partition structure of read-write permissions and setting a sequential consistency dual-partition synchronization mechanism, the files in the dual-data-partition execute target data operations according to the sequential consistency synchronization mechanism, so that the data in the dual-data-partition can be objects for comparison and verification with each other and the basis for data recovery, and when the system is powered on again, target detection is performed on the dual-data-partition to accurately locate a target abnormal file, different recovery strategies are executed according to different target abnormal files, and the data security of users is ensured. BRIEF DESCRIPTION OF DRAWINGS

[0049] Figure 1 The hardware architecture of the data protection method based on a dual-partition architecture involved in the embodiments of the present application;

[0050] Figure 2 The flowchart of the data protection method based on a dual-partition architecture of the present application;

[0051] Figure 3An execution schematic diagram of a double-data-partition synchronization mechanism based on sequential consistency in the present application;

[0052] Figure 4 A specific process schematic diagram of a data protection method based on a double-partition architecture in the present application;

[0053] Figure 5 A schematic diagram of a data protection apparatus based on a double-partition architecture in the present application. DETAILED DESCRIPTION

[0054] It should be understood that the specific embodiments described herein are merely intended to explain the present application and are not intended to limit the present application.

[0055] The main solution of the embodiment of the present application is: constructing a double-data-partition structure; after receiving a write instruction, executing a target data operation based on a double-data-partition synchronization mechanism based on sequential consistency; if a system abnormal power-off is monitored, performing target detection on the double-data-partition to obtain a target detection result; based on the target detection result, after re-powering, executing a corresponding abnormal recovery strategy; the present application solves the problem that an embedded system cannot safely recover user data in a sudden abnormal power-off scenario, and improves the security of user data.

[0056] In order to better understand the above technical solutions, the above technical solutions will be described in detail below in combination with the drawings in the specification and specific embodiments.

[0057] Referring to Figure 2 , Figure 2 A flow schematic diagram of a data protection method based on a double-partition architecture in the present application, the method comprising:

[0058] Step S110: constructing a double-data-partition structure;

[0059] The above double-data-partition structure is a design scheme of storage and data processing, which is usually used to improve reliability, implement redundant backup or support synchronous operation; the core idea is to divide data into two independent partitions, which can be a first partition and a second partition, and to realize data security, load balancing and reliable data recovery through a specific synchronization management mechanism.

[0060] Step S120: after receiving a write instruction, executing a target data operation in the double-data-partition structure based on a double-data-partition synchronization mechanism based on sequential consistency;

[0061] The write instruction is a basic operation command for storing data into a storage medium (such as memory, flash memory, hard disk) in a computer system; wherein, the core elements of the write instruction include a target address (a physical / logical address where data is to be written), data content (original data to be written or a data buffer pointer), a write length (data size), and a control flag (such as a cache strategy, atomicity, etc.);

[0062] The sequential consistency dual-data partition synchronization mechanism is a mechanism that needs to be executed according to a preset operation and sequence when a target data operation is performed in a dual-data partition, so as to ensure the reliability of data;

[0063] It should be particularly noted that "synchronization" in a computer refers to coordinating multiple processes, threads, devices, or systems to keep them consistent in time or execution sequence, so as to ensure correct data exchange, resource sharing, or task cooperation; in the embodiments of the present application, it refers to a synchronization mechanism that keeps consistent in execution sequence. The target data operation at least includes a write operation of a data file and an update operation of a check file;

[0064] Step S130: If it is monitored that the system is powered on again, target detection is performed on the dual-data partition, and a target detection result is obtained;

[0065] The system abnormal power-off is one of the major risks faced by an embedded system, which may cause data damage, file system crash, and even hardware damage; for example, power grid fluctuation, lightning interference, power failure, manual power-off, power module aging, and poor interface contact, etc.

[0066] The target detection can be data integrity detection and comparison positioning operation, or data integrity detection and flag bit positioning operation; wherein, the data integrity detection is a check detection on the data file and the check file of the partition itself; the comparison positioning operation is a comparison positioning between the data file or the check file of the dual-data partition; the flag bit positioning operation is a detection on an abnormal flag bit generated when the system is abnormally powered off, and the position of the target data operation;

[0067] Step S140: Based on the target detection result, a corresponding abnormal recovery strategy is executed.

[0068] The target detection result can be a result of mutual verification of the data file and the check file in the dual-data partition; or a result corresponding to a specific abnormal flag bit;

[0069] According to different target detection results, different abnormal recovery strategies are executed after the system is powered on again, so that user data is safely recovered.

[0070] In the embodiment, a dual data partition structure is constructed; after receiving a write instruction, a target data operation is performed based on a sequential consistency dual data partition synchronization mechanism; if a system abnormal power-off is monitored, target detection is performed on the dual data partition to obtain a target detection result; based on the target detection result, after re-powering, a corresponding abnormal recovery strategy is performed; by constructing the dual data partition structure of read-write permissions and setting the sequential consistency dual partition synchronization mechanism, the files in the dual data partition are synchronized in sequence, so that the data in the dual data partition can be compared and checked with each other, and serve as a basis for data recovery, so that when the system is re-powered, the target detection is performed on the dual data partition, the abnormal files can be accurately located, different recovery strategies are performed according to different abnormal files, and the data security of the user is ensured.

[0071] Optionally, the step of constructing the dual data partition structure comprises:

[0072] The first partition is mounted with read-write permissions; wherein the first partition at least contains a first check file and a first data storage directory, and the first data storage directory contains a plurality of first data files;

[0073] The second partition is mounted with read-write permissions; wherein the second partition at least contains a second check file and a second data storage directory, and the second data storage directory contains a plurality of second data files.

[0074] The read-write permission is a core security mechanism for controlling the access permission of users or programs to files, directories, memories and other resources in an embedded system, and contains three types of permissions, the read permission allows viewing the content (files, directories, etc.), the write permission allows adding, deleting and modifying the content (files, directories, etc.), and the execution permission allows running programs or files; in the embodiment, the write permission is mainly used, which is not limited herein;

[0075] Each partition at least contains a data storage directory, and the data storage directory contains a plurality of data files; each data file is checked to obtain a check result, and the check result is stored as a check file; the data check algorithm uses MD5, and can also be CRC32, SHA series, etc., which is not limited herein; in addition, in the embodiment, one data file can correspond to one check file, which is not limited herein.

[0076] In another embodiment, before the step of constructing the dual data partition structure, a read-only root file partition structure is constructed; the above-mentioned read-only root file can solidify the core control script (.sh) and the configuration file (.conf) in the read-only root file partition to prevent the key program from being tampered.

[0077] Optionally, after receiving the write instruction, the step of performing the target data operation in the dual data partition structure based on the sequential consistency dual data partition synchronization mechanism comprises:

[0078] After receiving the target write instruction, first, performing a first write operation on the first data file in the first partition, and second, performing a first update operation on the first check file;

[0079] Third, performing the second write operation on the second data file in the second partition, and fourth, performing the second update operation on the second check file;

[0080] Wherein, the write instruction contains a plurality of target write instructions.

[0081] The above write instruction contains a plurality of target write instructions, that is, the write instruction contains a first target write instruction, a second target write instruction, a third target write instruction, etc., arranged in the order of reception;

[0082] As shown in the following table: Figure 3 After receiving the first target write instruction, the write operation of the data file and the update operation of the check file are performed on the first partition and the second partition according to the preset order; Figure 3 A is the first partition and B is the second partition in the table;

[0083] When the second target write instruction is received, the write operation of the data file and the update operation of the check file are performed on the first partition and the second partition according to the above order, and when the third target write instruction is received, the write operation of the data file and the update operation of the check file are performed on the first partition and the second partition according to the above order;

[0084] Specifically, taking the dual data partition architecture of the Linux system as an example:

[0085] #Data writing process

[0086] echo $data > / userdataA / files / target #Write to the first partition

[0087] md5sum / userdataA / files / * > / userdataA / userdata.md5

[0088] rsync -a / userdataA / / userdataB / #Synchronize and copy to the second partition

[0089] fsync / userdataB / files / target #Force data to disk

[0090] In another embodiment, the target data operation can be parameter optimized for improving write performance and reliability; specifically, the Linux command is executed as follows:

[0091] mount -t ext4 -o data=writeback,noatime,barrier=1

[0092] In this embodiment, based on the sequential consistency of the dual data partition synchronization mechanism, the target data operation is executed, which can accurately locate the specific target error file when the system is abnormally powered off, ensure that the target error file can be accurately recovered, and ensure the safety of user data.

[0093] Optionally, if the system is detected to be powered on again, the target detection on the dual data partition is performed to obtain a target detection result, and the step includes:

[0094] If the system is detected to be powered on again, the data integrity of the dual data partition is detected, and if the result of the data integrity detection fails, a comparison positioning operation is performed to obtain a target error file, and the target error file is taken as the target detection result; or,

[0095] If the system is detected to be powered on again, the data integrity of the dual data partition is detected, and if the result of the data integrity detection fails, a flag positioning operation is performed to obtain a target error file, and the target error file is taken as the target detection result.

[0096] In this embodiment, the target detection method can be data integrity detection and comparison positioning operation or data integrity detection and flag positioning operation.

[0097] The above data integrity detection can be to check the data files and the check files of the partition itself, specifically, a check algorithm can be executed on the data files to obtain a check result, the check result is compared with the check result of the data file stored in the check file, if the comparison is consistent, the data integrity detection is successful; if the comparison is inconsistent, the data integrity detection fails.

[0098] The above comparison positioning operation can be to use the comparison relationship between the data files of the dual data partitions or the comparison relationship between the check files of the dual data partitions to perform positioning operation; for example, the data files of the first partition are compared with the data files of the second partition, the check files of the first partition are compared with the check files of the second partition, and the target detection result is obtained according to the comparison relationship; wherein, the comparison operation can be character-based comparison, which is not limited herein.

[0099] The flag positioning operation is for positioning the target error file according to detection of different abnormal flag bits, which are generated according to the current target data operation position when the system abnormally powers off. For example, when a first write operation is performed on the first data file, the system abnormally powers off, and a first abnormal flag bit is generated. When a first update operation is performed on the first check file, the system abnormally powers off, and a second abnormal flag bit is generated. When the second write operation is performed on the second data file, the system abnormally powers off, and a third abnormal flag bit is generated. When the second update operation is performed on the second check file, the system abnormally powers off, and a fourth abnormal flag bit is generated. Different abnormal flag bits correspond to different abnormal recovery strategies. The flag detection method does not need to be compared and checked, the speed of the target detection method is improved, and the abnormal recovery strategy can be executed more quickly.

[0100] Optionally, if it is monitored that the system is powered on again, data integrity detection is performed on the dual data partition, and if the result of the data integrity detection fails, a comparison positioning operation is performed to obtain a target error file, including:

[0101] If it is monitored that the system is powered on again, data integrity detection is performed on the first partition and the second partition.

[0102] If the data integrity detection of the first partition and / or the second partition fails, the comparison positioning operation is performed based on the first data file, the first check file, and the second data file, the second check file, to obtain the target error file whose data integrity detection fails.

[0103] The data integrity detection of the first partition and the second partition can be performed first on the first partition and then on the second partition, or simultaneously on the first partition and the second partition. In the above two modes, the data integrity detection of the first partition and the second partition needs to be performed before the corresponding abnormal recovery strategy is executed.

[0104] The comparison positioning operation based on the first data file, the first check file, and the second data file, the second check file, can be a comparison between the first data file and the second data file, and a comparison between the first check file and the second check file, and the target error file is positioned according to the comparison relationship.

[0105] Specifically, taking a Linux system dual data partition architecture as an example:

[0106]

[0107] In the embodiment, the target error file corresponding to the system abnormal power-off is accurately obtained by performing data integrity detection on the first partition and the second partition, so that the correctness of the abnormal recovery strategy is ensured, and the user data is safely recovered.

[0108] Optionally, if the data integrity detection of the first partition and / or the second partition fails, the comparison positioning operation is performed based on the first data file, the first check file, the second data file and the second check file, and the target file of the data integrity detection failure is obtained.

[0109] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition succeeds to be checked with the second check file, the first check file is compared with the second check file, if the first check file is consistent with the second check file, the first data file is taken as a first target error file.

[0110] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition succeeds to be checked with the second check file, the first data file is compared with the second data file, if the first data file is consistent with the second data file, the first check file is taken as a second target error file.

[0111] If the second data file of the second partition fails to be checked with the second check file and the first data file of the first partition succeeds to be checked with the first check file, the second check file is compared with the first check file, if the second check file is consistent with the first check file, the second data file is taken as a third target error file.

[0112] If the second data file of the second partition fails to be checked with the second check file and the first data file of the first partition succeeds to be checked with the first check file, the second data file is compared with the first data file, if the second data file is consistent with the first data file, the second check file is taken as a fourth target error file.

[0113] If the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition fails to be checked with the second check file, the first data file, the first check file, the second data file and the second check file are all taken as a fifth target error file.

[0114] The first data file and the first check file of the first partition are checked to detect the data integrity of the first partition. When the first data file and the first check file of the first partition fail to pass the check, the target error files (i.e., the first target error file and the second target error file) in the first data file and the first check file of the first partition are determined by using the correct data (the second data file and the second check file) in the second partition that passes the data integrity detection.

[0115] Similarly, the second data file and the second check file of the second partition are checked to detect the data integrity of the second partition. When the second data file and the second check file of the second partition fail to pass the check, the target error files (i.e., the third target error file and the fourth target error file) in the second data file and the second check file of the second partition are determined by using the correct data (the first data file and the first check file) in the first partition that passes the data integrity detection.

[0116] The first data file and the first check file of the first partition fail to pass the check, which means that the data integrity detection of the first partition fails. The first data file and the first check file of the first partition pass the check, which means that the data integrity detection of the first partition succeeds.

[0117] Similarly, the second data file and the second check file of the second partition fail to pass the check, which means that the data integrity detection of the second partition fails. The second data file and the second check file of the second partition pass the check, which means that the data integrity detection of the second partition succeeds.

[0118] As can be seen from the above description, "if the first data file and the first check file of the first partition fail to pass the check and the second data file and the second check file of the second partition pass the check" in the embodiment means that the data integrity detection of the first partition fails, and the data integrity detection of the second partition succeeds.

[0119] The specific process of checking the first data file and the first check file of the first partition is to execute a check algorithm on the first data file to obtain a check result, and compare the check result with a check result corresponding to the first data file stored in the first check file. If the comparison is consistent, the check succeeds. If the comparison is inconsistent, the check fails. In the embodiment, the check result corresponding to the first data file refers to a check result corresponding to the first data file that has been checked and stored before the current power-on. In addition, the check algorithm used to generate the check result is the same as the check algorithm used to generate the check result in the first check file. Similarly, the second partition is not described here.

[0120] However, when the data integrity check of the first partition and the second partition both fail, and the specific target error file cannot be confirmed, the data file and the check file in the first partition and the second partition are both taken as the fifth target error file;

[0121] In the case that the first data file of the first partition and the first check file fail to check, and the second data file of the second partition and the second check file fail to check, i.e. the data integrity check of the first partition and the second partition both fail, it can be some extreme system abnormal power-off situation, such as the machine suffers from a motor, causing the data integrity check of the first partition and the second partition both to fail.

[0122] In the embodiment, the corresponding target error file of the data integrity detection failure is obtained through the comparison relationship and the check relationship between the specific first data file, the first check file, and the second data file, the second check file. Different abnormal recovery strategies are executed according to different target error files, to ensure the safe recovery of user data.

[0123] Optionally, if the system is monitored to be powered on again, the data integrity of the dual data partition is detected, and if the result of the data integrity detection exists failure, the step of performing the flag bit positioning operation to obtain the target error file comprises:

[0124] If the system is monitored to be powered on again, the data integrity of the first partition and the second partition is detected.

[0125] If the data integrity detection of the first partition and / or the second partition fails, the flag bit detection of the dual data partition is performed.

[0126] If the first abnormal flag bit is obtained, the first data file is taken as the first target error file; wherein the first abnormal flag bit is generated when the system is performing the first write operation at the time of the system abnormal power-off;

[0127] If the second abnormal flag bit is obtained, the first check file is taken as the second target error file; wherein the second abnormal flag bit is generated when the system is performing the first update operation at the time of the system abnormal power-off;

[0128] If the third abnormal flag bit is obtained, the second data file is taken as the third target error file; wherein the third abnormal flag bit is generated when the system is performing the second write operation at the time of the system abnormal power-off;

[0129] If the fourth abnormal flag bit is obtained, the second check file is taken as the fourth target error file; wherein the fourth abnormal flag bit is generated when the system is performing the second update operation at the time of the system abnormal power-off.

[0130] The flag bit can be a binary flag bit, and according to the scenario of the application, a two-bit binary flag bit can be used to mark the above-mentioned situations; flag bit 00 represents the first exception flag bit; flag bit 01 represents the second exception flag bit; flag bit 10 represents the third exception flag bit; and flag bit 11 represents the fourth exception flag bit; when different exception flag bits are obtained, it represents that the system is performing different operations when the system is powered off abnormally; wherein the number of bits of the binary flag bit is not limited, and can be adjusted according to the specific scenario.

[0131] It should be particularly pointed out that if the data integrity detection of the first partition and the second partition both fail, but the above-mentioned exception flag bit is not detected, then the first data file, the first check file, and the second data file, and the second check file are all regarded as the fifth target error file.

[0132] The data integrity detection has been described in the foregoing, and will not be repeated here.

[0133] In the embodiment, by performing flag bit detection in the dual-data partition, different flag bits correspond to different exception recovery strategies, thereby ensuring the safe recovery of user data.

[0134] Optionally, the step of executing the corresponding exception recovery strategy based on the target detection result comprises:

[0135] If the first data file is the first target error file, the second data file is copied to the first partition to overwrite the first data file;

[0136] If the first check file is the second target error file, the second check file is copied to the first partition to overwrite the first check file;

[0137] If the second data file is the third target error file, the first data file is copied to the second partition to overwrite the second data file;

[0138] If the second check file is the fourth target error file, the first check file is copied to the second partition to overwrite the second check file;

[0139] If the first data file, the first check file, and the second data file, and the second check file are all the fifth target error file, system default data is copied to the first partition and the second partition to overwrite the first data file, the first check file, and the second data file, and the second check file.

[0140] In the embodiment of the present application, the covering generally refers to replacing the original target error file with the correct file content, so that the data in the first partition and the second partition is ensured to be safe and reliably recovered when the system is abnormally powered off.

[0141] As shown in the figure, it is a specific process diagram of the data protection method based on the dual-partition architecture, which is taken as a reference. Figure 4 The A area in the figure is the first partition in the embodiment of the present application, and the B area is the second partition in the embodiment of the present application. Figure 4

[0142] In the embodiment, for different target error files, the correct data in the first partition and the second partition is accurately covered, so that the system can be accurately recovered to the latest user data when the system is abnormally powered off, and the safe recovery of the user data is ensured.

[0143] The embodiment of the present application also provides a data protection device based on a dual-partition architecture, as shown in the figure. Figure 5 The data protection device based on the dual-partition architecture comprises:

[0144] The construction module 210 is configured to construct a dual-data partition structure.

[0145] The execution module 220 is configured to, after receiving a write instruction, execute a target data operation in the dual-data partition structure based on a sequential consistency dual-data partition synchronization mechanism.

[0146] The detection module 230 is configured to, if it is monitored that the system is powered on again, perform target detection on the dual-data partition to obtain a target detection result.

[0147] The recovery module 240 is configured to execute a corresponding abnormal recovery strategy based on the target detection result.

[0148] Optionally, the construction module 210 comprises:

[0149] The first mounting module is configured to mount the first partition with read-write permission; wherein the first partition at least comprises a first check file and a first data storage directory, and the first data storage directory comprises a plurality of first data files.

[0150] The second mounting module is configured to mount the second partition with read-write permission; wherein the second partition at least comprises a second check file and a second data storage directory, and the second data storage directory comprises a plurality of second data files.

[0151] Optionally, the execution module 220 comprises:

[0152] ​The first execution module is configured to, after receiving a target write instruction, first perform a first write operation on the first data file in the first partition, and second perform a first update operation on the first check file;

[0153] The second execution module is configured to, again perform the second write operation on the second data file in the second partition, and finally perform the second update operation on the second check file;

[0154] The write instruction comprises a plurality of target write instructions.

[0155] Optionally, the detection module 230 comprises:

[0156] The first detection module is configured to, if it is monitored that the system is powered on again, perform data integrity detection on the dual data partition, and if the result of the data integrity detection fails, perform a comparison positioning operation to obtain a target error file, and take the target error file as the target detection result; or

[0157] The second detection module is configured to, if it is monitored that the system is powered on again, perform data integrity detection on the dual data partition, and if the result of the data integrity detection fails, perform a flag positioning operation to obtain a target error file, and take the target error file as the target detection result.

[0158] Optionally, the first detection module comprises:

[0159] The detection judgment module is configured to, if it is monitored that the system is powered on again, perform data integrity detection on the first partition and the second partition.

[0160] The detection acquisition module is configured to, if the data integrity detection of the first partition and / or the second partition fails, perform the comparison positioning operation based on the first data file, the first check file, the second data file and the second check file, to obtain the target error file of the data integrity detection failure.

[0161] Optionally, the detection acquisition module comprises:

[0162] The first detection acquisition module is configured to, if the first data file of the first partition fails to be checked with the first check file and the second data file of the second partition succeeds to be checked with the second check file, compare the first check file with the second check file, and if the first check file is consistent with the second check file, take the first data file as a first target error file.

[0163] the second detection acquisition module is configured to compare the first data file and the second data file if the first data file of the first partition and the first check file fail to pass the check and the second data file of the second partition and the second check file pass the check, and if the first data file and the second data file are consistent, the first check file is taken as a second target error file;

[0164] the third detection acquisition module is configured to compare the second check file and the first check file if the second data file of the second partition and the second check file fail to pass the check and the first data file of the first partition and the first check file pass the check, and if the second check file and the first check file are consistent, the second data file is taken as a third target error file;

[0165] the fourth detection acquisition module is configured to compare the second data file and the first data file if the second data file of the second partition and the second check file fail to pass the check and the first data file of the first partition and the first check file pass the check, and if the second data file and the first data file are consistent, the second check file is taken as a fourth target error file;

[0166] the fifth detection acquisition module is configured to take the first data file, the first check file, the second data file and the second check file as a fifth target error file if the first data file of the first partition and the first check file fail to pass the check and the second data file of the second partition and the second check file fail to pass the check.

[0167] Optionally, the second detection module comprises:

[0168] the detection flag bit module is configured to perform data integrity detection on the first partition and the second partition if it is monitored that the system is powered on again, and perform flag bit detection on the dual-data partition if the data integrity detection on the first partition and / or the second partition fails;

[0169] the first detection flag bit module is configured to take the first data file as a first target error file if a first abnormal flag bit is obtained, wherein the first abnormal flag bit is generated when the system is performing the first write operation when the system is abnormally powered off;

[0170] the second detection flag bit module is configured to take the first check file as a second target error file if a second abnormal flag bit is obtained, wherein the second abnormal flag bit is generated when the system is performing the first update operation when the system is abnormally powered off;

[0171] A third detection flag bit module is configured to, if a third abnormal flag bit is obtained, take the second data file as a third target error file; wherein the third abnormal flag bit is generated when the system is performing the second write operation when the system is abnormally powered off.

[0172] A fourth detection flag bit module is configured to, if a fourth abnormal flag bit is obtained, take the second check file as a fourth target error file; wherein the fourth abnormal flag bit is generated when the system is performing the second update operation when the system is abnormally powered off.

[0173] Optionally, the recovery module comprises:

[0174] A first recovery module is configured to, if the first data file is taken as a first target error file, copy the second data file to the first partition to overwrite the first data file;

[0175] A second recovery module is configured to, if the first check file is taken as a second target error file, copy the second check file to the first partition to overwrite the first check file;

[0176] A third recovery module is configured to, if the second data file is taken as a third target error file, copy the first data file to the second partition to overwrite the second data file;

[0177] A fourth recovery module is configured to, if the second check file is taken as a fourth target error file, copy the first check file to the second partition to overwrite the second check file;

[0178] A fifth recovery module is configured to, if the first data file and the first check file and the second data file and the second check file are taken as a fifth target error file, copy system default data to the first partition and the second partition to overwrite the first data file, the first check file, the second data file and the second check file.

[0179] The embodiment of the present application also provides a computer storage medium, wherein a data protection method based on a dual-partition architecture is stored on the computer storage medium, and the data protection method based on the dual-partition architecture is executed by a processor to realize the steps of any one of the data protection methods based on the dual-partition architecture.

[0180] The embodiment of the present application also provides an electronic device 01 comprising the data protection method based on the dual-partition architecture as shown in the figure. Figure 1 The processor can execute any one of the data protection methods based on the dual-partition architecture.

[0181] In particular, the computer program comprises a processor 12 and a memory 11 and a data protection method based on a two-partition architecture stored on the memory 11 and executable on the processor 12,

[0182] It is to be noted that the terms "comprising", "including", or any other variants thereof, are intended to cover a non-exclusive inclusion, such that processes, methods, articles, or apparatuses that comprise a list of elements are not limited to those elements, but can include other elements not expressly listed or inherent to such processes, methods, articles, or apparatuses. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0183] From the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be realized by means of software and the necessary general hardware platform, of course, they can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) as described above, and includes a number of instructions for making a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present application.

[0184] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.

Claims

1. A data protection method based on a two-partition architecture, characterized in that, The method comprises: constructing a dual data partition structure; after receiving a write instruction, performing a target data operation in the dual data partition structure based on a sequential consistency dual data partition synchronization mechanism; if system power-on is monitored, performing target detection on the dual data partition to obtain a target detection result; based on the target detection result, performing a corresponding abnormal recovery strategy.

2. The data protection method based on a dual partition architecture as claimed in claim 1, characterized in that, The step of constructing a dual data partition structure comprises: mounting a first partition with read-write permission; wherein the first partition at least contains a first check file and a first data storage directory, and the first data storage directory contains a plurality of first data files; mounting a second partition with read-write permission; wherein the second partition at least contains a second check file and a second data storage directory, and the second data storage directory contains a plurality of second data files.

3. The data protection method based on a dual partition architecture as claimed in claim 2, characterized in that, The step of receiving a write instruction, and performing a target data operation in the dual data partition structure based on a sequential consistency dual data partition synchronization mechanism, comprises: after receiving a target write instruction, first performing a first write operation on the first data file in the first partition, and then performing a first update operation on the first check file; then performing a second write operation on the second data file in the second partition, and finally performing a second update operation on the second check file; wherein the write instruction contains a plurality of target write instructions.

4. The data protection method based on a dual partition architecture as claimed in claim 3, characterized by, The step of if system power-on is monitored, performing target detection on the dual data partition to obtain a target detection result, comprises: if system power-on is monitored, performing data integrity detection on the dual data partition, if the result of the data integrity detection fails, performing a comparison positioning operation to obtain a target error file, and taking the target error file as the target detection result; or if system power-on is monitored, performing data integrity detection on the dual data partition, if the result of the data integrity detection fails, performing a flag bit positioning operation to obtain a target error file, and taking the target error file as the target detection result.

5. The data protection method based on a dual partition architecture as claimed in claim 4, characterized by, The step of if system power-on is monitored, performing data integrity detection on the dual data partition, if the result of the data integrity detection fails, performing a comparison positioning operation to obtain a target error file, comprises: if system power-on is monitored, performing data integrity detection on the first partition and the second partition; if the data integrity detection of the first partition and / or the second partition fails, based on the first data file, the first check file, the second data file, and the second check file, performing the comparison positioning operation to obtain the target error file of the data integrity detection failure.

6. The data protection method based on a dual partition architecture as claimed in claim 5, characterized by, If the data integrity detection of the first partition and / or the second partition fails, performing the comparison positioning operation based on the first data file, the first check file, and the second data file, the second check file, to obtain the target error file of the data integrity detection failure, including: If the first data file of the first partition and the first check file fail to check, and the second data file of the second partition and the second check file pass the check, comparing the first check file with the second check file, if the first check file is consistent with the second check file, the first data file is taken as a first target error file; If the first data file of the first partition and the first check file fail to check, and the second data file of the second partition and the second check file pass the check, comparing the first data file with the second data file, if the first data file is consistent with the second data file, the first check file is taken as a second target error file; If the second data file of the second partition and the second check file fail to check, and the first data file of the first partition and the first check file pass the check, comparing the second check file with the first check file, if the second check file is consistent with the first check file, the second data file is taken as a third target error file; If the second data file of the second partition and the second check file fail to check, and the first data file of the first partition and the first check file pass the check, comparing the second data file with the first data file, if the second data file is consistent with the first data file, the second check file is taken as a fourth target error file; If the first data file of the first partition and the first check file fail to check, and the second data file of the second partition and the second check file fail to check, the first data file, the first check file, and the second data file, the second check file are all taken as a fifth target error file.

7. The data protection method based on a dual-zone architecture according to claim 4, wherein, If the system is detected to be powered on again, performing data integrity detection on the dual data partition, if the result of the data integrity detection exists failure, performing a flag bit positioning operation to obtain a target error file, including: If the system is detected to be powered on again, performing data integrity detection on the first partition and the second partition; If the data integrity detection of the first partition and / or the second partition fails, performing flag bit detection on the dual data partition; If a first abnormal flag bit is obtained, taking the first data file as a first target error file; wherein the first abnormal flag bit is generated when the system is performing the first write operation at the time of system abnormal power-off; if a second abnormal flag is obtained, the first check file is taken as a second target error file; the second abnormal flag is generated when the system is performing the first updating operation at the time of abnormal power-off of the system; if a third abnormal flag is obtained, the second data file is taken as a third target error file; the third abnormal flag is generated when the system is performing the second writing operation at the time of abnormal power-off of the system; if a fourth abnormal flag is obtained, the second check file is taken as a fourth target error file; the fourth abnormal flag is generated when the system is performing the second updating operation at the time of abnormal power-off of the system.

8. The data protection method based on a two-partition architecture according to claim 6 or 7, characterized in that, The step of executing a corresponding abnormal recovery strategy based on the target detection result comprises: if the first data file is taken as a first target error file, the second data file is copied to the first partition to replace the first data file; if the first check file is taken as a second target error file, the second check file is copied to the first partition to replace the first check file; if the second data file is taken as a third target error file, the first data file is copied to the second partition to replace the second data file; if the second check file is taken as a fourth target error file, the first check file is copied to the second partition to replace the second check file; if the first data file, the first check file, the second data file and the second check file are all taken as a fifth target error file, system default data is copied to the first partition and the second partition to replace the first data file, the first check file, the second data file and the second check file.

9. A data protection apparatus based on a two-partition architecture, characterized by, The data protection device based on the dual-partition architecture comprises: a construction module configured to construct a dual-data partition structure; an execution module configured to, after receiving a writing instruction, execute a target data operation in the dual-data partition structure based on a sequential consistency dual-data partition synchronization mechanism; a detection module configured to, if it is monitored that the system is re-powered, perform target detection on the dual-data partition to obtain a target detection result; a recovery module configured to execute a corresponding abnormal recovery strategy based on the target detection result.

10. A computer storage medium, characterized in that, The computer storage medium stores a data protection method program based on a dual-partition architecture, and the data protection method program based on the dual-partition architecture is executed by a processor to implement the steps of the data protection method based on the dual-partition architecture in any one of claims 1-8.