Data migration method and device, electronic equipment and storage medium
By adding checksums and transport identifiers during data migration, the problem of multiple accesses to the original storage partition during data migration is solved, thus simplifying the process and ensuring data integrity.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ECOFLOW INC
- Filing Date
- 2023-03-29
- Publication Date
- 2026-07-21
AI Technical Summary
In existing technologies, data migration requires multiple accesses to the original storage partition to handle data anomalies, resulting in cumbersome procedures and the potential for data anomalies.
During the data migration process, a checksum and a transport identifier are added to the original data and written to the second and third partitions. During initialization, the data integrity is verified by the checksum. If the verification fails and the transport identifier is carried, the data is copied from the third partition to the second partition.
It reduces the number of accesses to the original storage partition, simplifies the data migration process, lowers the probability of data anomalies, and ensures data integrity through real-time verification.
Smart Images

Figure CN116301654B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage technology, and in particular to a data migration method, apparatus, electronic device and storage medium. Background Technology
[0002] In practical applications, it is often necessary to write raw data from one storage partition to another. If the data written to the original storage partition becomes corrupted, the original storage partition must be accessed again to retrieve the original data. However, accessing the original storage partition multiple times is cumbersome and may lead to data corruption in the original storage partition. Summary of the Invention
[0003] In view of the above, it is necessary to provide a data migration method, apparatus, device and storage medium to solve the technical problem that when the stored data is abnormal after data migration, it is necessary to access the original flash memory partition corresponding to the data multiple times.
[0004] A first aspect of this application provides a data migration method applied in an electronic device. The method includes: acquiring raw data in a first partition and calculating a checksum of the raw data; adding the checksum and a transfer identifier to the raw data to obtain first data; determining a second partition and a third partition; writing the first data into the second partition and the third partition; responding to a received data initialization command, reading second data stored in the second partition and verifying the second data according to the checksum in the second data; if the second data verification fails and the second data carries the transfer identifier, then copying the third data stored in the third partition to the second partition.
[0005] As can be seen from the above technical solutions, in this embodiment, by adding a check value and a transfer identifier to the original data in the first partition, the first data obtained is written to the second and third partitions. The first data written to the second partition is called the second data, and the first data written to the third partition is called the third data. This allows the first data to be backed up in the third partition. If the second data in the second partition becomes abnormal, the presence of a transfer identifier in the second data indicates that the data has been written to both the second and third partitions. The third data can then be directly obtained from the third partition without having to access the first partition again to obtain the original data. This reduces the number of times the first partition is accessed, simplifies the data migration process, and eliminates the need for repeated erasure and write operations on the second and third partitions. Furthermore, by adding a check value to the original data, the data can be verified each time an initialization operation is performed after the data is migrated to a new partition. This allows for timely determination of whether the data is abnormal, thereby reducing the occurrence of using abnormal data.
[0006] A second aspect of this application provides a data migration apparatus, the data migration apparatus comprising: The data calculation module is used to obtain the raw data in the first partition and calculate the check value of the raw data; The data processing module is used to add the check value and the transport identifier to the original data to obtain the first data; The storage partitioning module is used to determine the second and third partitions; A data writing module is used to write the first data into the second partition and the third partition; The data verification module is used to respond to the received data initialization command, read the second data stored in the second partition, and verify the second data according to the verification value in the second data; The data copying module is used to copy the third data stored in the third partition to the second partition if the second data verification fails and the second data carries the transfer identifier.
[0007] A third aspect of this application provides an electronic device, the electronic device comprising: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the data migration method.
[0008] A fourth aspect of this application provides a computer-readable storage medium storing computer-readable instructions that are executed by a processor in an electronic device to implement the data migration method. Attached Figure Description
[0009] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0010] Figure 2 This is a flowchart of a data migration method provided in an embodiment of this application.
[0011] Figure 3 This is a flowchart of a data migration method provided in an embodiment of this application.
[0012] Figure 4 This is a detailed flowchart of a method for copying third data stored in a third partition to a second partition, provided in an embodiment of this application.
[0013] Figure 5 This is a detailed flowchart of a method for determining the second and third partitions provided in an embodiment of this application.
[0014] Figure 6 This is a flowchart of a data migration method provided in an embodiment of this application.
[0015] Figure 7 This is a schematic diagram of the structure of a data migration device provided in an embodiment of this application.
[0016] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0017] In the following description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, words such as "exemplary," "or," and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary," "or," and "for example" is intended to present the relevant concepts in a concrete manner.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this application's specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. It should be understood that, unless otherwise stated, " / " in this application means "or". For example, A / B can mean A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. "At least one" means one or more. "More than one" means two or more. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, and a, b, and c. It should be understood that the order of steps shown in the flowcharts herein can be changed, and some can be omitted.
[0019] This application provides a data migration method that reduces the number of times the original storage partition corresponding to the data is accessed when the stored data is abnormal, thereby simplifying the data migration process and eliminating the need for repeated erase and write operations on the new partition after migration.
[0020] The data migration method provided in this application can be applied to electronic devices. The aforementioned electronic devices include memory devices that store electronic information using storage technologies such as flash memory. These memory devices can provide storage functions for the electronic devices and may include one or more types of memory devices such as USB flash drives, CF cards, SM cards, SD / MMC cards, Memory Sticks, XD cards, MS cards, TF cards, and PCIe flash cards. The electronic devices can access the memory devices to obtain the data stored therein. Typically, electronic devices use databases to manage the data in the memory devices. The electronic devices may be energy storage devices, solar trackers, lawnmowers, mobile phones, tablets, desktop computers, laptops, etc. This application does not impose any special limitations on the specific form of the electronic devices.
[0021] To better understand the data migration method provided in the embodiments of this application, the implementation methods of the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0022] Figure 1 This is a schematic diagram of the structure of a memory in an electronic device according to an embodiment of this application. Figure 1 As shown, an electronic device may include one or more memories 10, and each memory 10 includes at least three storage partitions, such as a first partition 110, a second partition 120, and a third partition 130. In other embodiments, the first partition 110 may belong to a different memory than the second partition 120 and the third partition 130. In this embodiment, the data stored in the first partition 110 is raw data, which may be important data required for the normal use or operation of the electronic device corresponding to the memory 10, or data generated during the operation of the electronic device; no limitation is made here. In practical applications, there may be situations where it is necessary to migrate the raw data in the first partition to other partitions in the memory 10, such as when the database managing the raw data malfunctions, or when it is necessary to transfer the raw data to a new memory.
[0023] Other storage partitions in memory 10 can access the original data stored in the first partition 110 by accessing the first partition 110. For example, the second partition 120 can access the original data stored in the first partition 110 by accessing the first partition 110. The data stored in the second partition 120 is referred to as second data. The second partition 120 can be an accessible area provided by memory 10 to the outside, and other external electronic devices can access the second partition 120 to obtain the second data stored in the second partition 120. The third partition 130 can serve as a backup partition for backing up data. For example, the third partition 130 can back up the second data stored in the second partition 120. The data stored in the third partition 130 can be referred to as third data.
[0024] Figure 1 This is merely an example of an electronic device and does not constitute a limitation. In other embodiments, the memory 10 in the electronic device may include more partitions than those shown in the figure, and this application does not limit this.
[0025] Figure 2 This is a flowchart of a data migration method provided in an embodiment of this application. Figure 2 The method shown is applied to electronic devices, such as... Figure 1 The electronic device shown is illustrated. Depending on the specific requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0026] Step 210: Obtain the original data in the first partition and calculate the check value of the original data.
[0027] The first partition is used to store data within the electronic device. For example, the first partition can be used to store data acquired by the electronic device or data generated by the electronic device during operation. The data stored in the first partition is called raw data.
[0028] Checksums can be used to verify data to prove its accuracy and completeness. In one embodiment, the checksum can verify the original data or the data after it has been transferred from the original data. For example, the data after the original data has been transferred is called second data, and the checksum can be used to verify the second data.
[0029] In one embodiment of this application, the check value of the original data can be calculated using Cyclic Redundancy Check (CRC). In other embodiments of this application, other methods can be used to calculate the check value of the original data, such as parity check, Hamming check, etc. This application does not limit the method used to calculate the check value in any way.
[0030] Step 220: Add a checksum and a transport identifier to the original data to obtain the first data.
[0031] In one embodiment of this application, a checksum migration identifier is added to the original data before it needs to be migrated to another partition. The checksum is calculated from the original data in step 210. The migration identifier indicates that the original data is stored in two different partitions. When a migration identifier is detected, it indicates that the data has been migrated to another partition or is data obtained from another partition. For example, before the original data needs to be migrated to another partition, a migration identifier is added to the original data. By detecting the migration identifier in the migrated partition, it can be determined whether the original data has been migrated to that partition, thereby avoiding repeated migration of the same data.
[0032] In one embodiment of this application, the original partition (i.e., the first partition storing the original data) corresponding to the data can be determined based on the transport identifier. The transport identifier carries an identifier indicating the original partition corresponding to the data. For example, if data A in partition A is obtained from partition B, then the transport identifier on data A can indicate that the source of data A is partition B.
[0033] In this embodiment, the first data is the original data with a checksum and a transfer identifier added. The checksum and transfer identifier in the first data do not affect the data content contained within it. The data content in the first data is the same as the data content in the original data.
[0034] Step 230: Determine the second and third partitions.
[0035] The second partition and the first partition can be different storage partitions of the same memory in an electronic device, or new partitions in different memory, used for storing data. For example, the second partition can store the first data obtained after processing the original data.
[0036] The third partition serves as a backup partition for the second partition. Both can reside in the same storage device and are used to back up data stored in the second partition. When data is stored in the second partition, backups can be performed in the third partition; that is, when data X is stored in the second partition, data X will also be stored in the third partition. It's understandable that data in the backup partition is typically not used when accessing data, reducing the possibility of errors in the backup partition. Because the third partition is a backup partition for the second partition, data in the second partition has a corresponding data in the third partition. If the data in the second partition remains unchanged, the data content in the second partition is identical to the corresponding data content in the third partition. However, it's understandable that if the data in the second partition is changed or corrupted, the data content will differ from the corresponding data content in the third partition.
[0037] The second and third partitions can be set to the same or different sizes. The second and third partitions can be determined according to a preset size. For specific implementation methods regarding determining the second and third partitions, please refer to the following section. Figure 5 Related descriptions.
[0038] Step 240: Write the first data to the second and third partitions.
[0039] After the first data is written to the second partition, it is called the second data. After the first data is written to the third partition, it is called the third data. When the second data remains unchanged, the data content of the first data, the second data, and the third data are all identical.
[0040] In one embodiment of this application, the electronic device can simultaneously write the first data to both the second and third partitions. The above embodiments can simultaneously achieve data storage and data backup.
[0041] In another embodiment of this application, the electronic device may also write the first data to the second partition and the third partition sequentially. This application does not limit this.
[0042] Step 250: In response to the received data initialization command, read the second data stored in the second partition.
[0043] Data initialization instructions are used to control electronic devices to perform data initialization operations. In one embodiment of this application, the data initialization instruction is automatically triggered when the electronic device is powered on. In another embodiment of this application, the electronic device may also trigger the data initialization instruction based on user operation. This application does not impose any limitations on the triggering of the data initialization instruction.
[0044] In one embodiment of this application, the data initialization operation is used to verify the second data. If the verification value obtained by the verification is consistent with the verification value carried on the second data, it indicates that the second data can be used normally, and the data initialization is completed.
[0045] Step 260: Verify the second data based on the verification value in the second data.
[0046] The electronic device verifies the second data based on the check value in the second data to determine whether the second data is the required data, that is, to determine whether the data content of the second data is consistent with the data content of the original data.
[0047] In one embodiment of this application, the electronic device can determine the current verification value of the second data according to the verification method for determining the verification value in the second data; determine whether the currently calculated verification value of the second data is consistent with the verification value in the second data; if the current verification value of the second data is consistent with the verification value in the second data, determine that the second data verification is successful; if the current verification value of the second data is inconsistent with the verification value in the second data, determine that the second data verification is unsuccessful.
[0048] In one embodiment of this application, if the second data verification is successful, the data initialization operation is completed based on the second data. If the second data verification is successful, the electronic device determines that the data content of the second data is consistent with the data content of the original data from the first partition, and completes the data initialization operation corresponding to this initialization instruction.
[0049] Step 270: If the second data verification fails and the second data carries a transfer identifier, then copy the third data stored in the third partition to the second partition.
[0050] In one embodiment of this application, if the second data verification fails, it indicates that the second data is abnormal. The current second data is inconsistent with its corresponding original data, that is, the data content of the current second data is inconsistent with the data content of the first data.
[0051] If the second data verification fails, the electronic device can detect whether the second data carries a transfer identifier. When the second data carries a transfer identifier, the electronic device can determine that the second data had a corresponding backup data at the time of storage, namely the third data stored in the third partition. Since the third data in the third partition is also obtained from the first data, the third data is copied to the second partition to replace the current second data, avoiding directly obtaining the original data from the first partition.
[0052] In one embodiment of this application, if the second data verification fails, the second data stored in the second partition is deleted. This can be achieved by erasing the second partition.
[0053] In one embodiment of this application, the third data is copied to the second partition to obtain the updated second data. Based on the updated second data in the second partition, the data initialization operation corresponding to this initialization instruction is completed.
[0054] For specific implementation details on copying the third data stored in the third partition to the second partition, please refer to the following text. Figure 4 Related descriptions.
[0055] The method provided in the above embodiments, by adding a checksum and a transfer identifier to the original data in the first partition, obtains first data, which is then written to the second and third partitions. The first data, after being written to the second partition, is called second data, and the first data, after being written to the third partition, is called third data. This allows the first data to be backed up in the third partition. If the second data in the second partition subsequently becomes abnormal, the presence of a transfer identifier in the second data indicates that the data has been written to both the second and third partitions. The third data can then be directly retrieved from the third partition without needing to access the first partition again to obtain the original data. This reduces the number of times the first partition is accessed, thereby lowering the probability of the first partition becoming abnormal and simplifying the data migration process. Furthermore, it eliminates the need for repeated erasure and write operations on the second and third partitions. Moreover, by adding a checksum to the original data, after the data is migrated to a new partition, the second data stored in the second partition can be verified based on the checksum during each initialization operation, promptly determining whether the second data is abnormal, thus reducing the occurrence of using abnormal second data.
[0056] Figure 3 This is a flowchart of a data migration method provided in one embodiment of this application, applied to an electronic device. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0057] Step 310: Obtain the original data in the first partition and calculate the check value of the original data.
[0058] Step 320: Add a check value and a transport identifier to the original data to obtain the first data.
[0059] Step 330: Identify the second partition and the backup partition (third partition).
[0060] Step 340: Write the first data to the second and third partitions.
[0061] Step 350: In response to the received data initialization command, read the second data stored in the second partition.
[0062] Step 360: Verify the second data based on the verification value in the second data.
[0063] For some specific implementation details regarding steps 310 to 360, please refer to the above description. Figure 2 The relevant descriptions of steps 210 to 260.
[0064] Step 370: If the second data verification fails and the second data does not carry a transfer identifier, then delete the second data stored in the second partition and the third data stored in the third partition.
[0065] When the second data does not carry a transfer identifier, the electronic device determines that the second data stored in the second partition is abnormal and does not correspond to the required original data. For example, after the first data was written to the second partition, other users rewrote the data in the second partition. Or, for example, the electronic device did not previously copy the first data to the second and third partitions. In this case, it is impossible to determine whether the third data in the third partition is reliable; therefore, the electronic device can directly delete the second data stored in the second partition and the third data stored in the third partition. The procedure for executing the second data if verification fails and the second data carries a transfer identifier will be discussed below. Figure 4 The process shown is explained below.
[0066] After step 370, the process proceeds to step 310, where the electronic device returns to retrieve the original data from the first partition and calculates the checksum of the original data. In some embodiments of this application, the electronic device will continue to execute subsequent steps to redetermine the second data and complete the current data initialization operation based on the redetermined second data, i.e., continue execution. Figure 3 Steps 310 to 360.
[0067] The method provided in the above embodiments can determine that the currently stored second and third data are abnormal when the second data verification fails and the second data does not carry a migration identifier. It can then re-acquire the original data and store it to obtain new second and third data, thereby completing the current data initialization operation. This allows the data migration operation to be re-executed when it is determined that the migrated data is abnormal, avoiding the need to repeatedly migrate data from the first partition each time.
[0068] Figure 4 This is a detailed flowchart of a method for copying third data stored in a third partition to a second partition, according to an embodiment of this application, and applied to an electronic device. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements.
[0069] Step 410: If the second data verification fails and the second data carries a transfer identifier, then obtain the third data stored in the third partition.
[0070] In some embodiments of this application, the third data stored in the third partition can be obtained based on the transport identifier carried by the second data. For example, the access path of the third partition can be determined based on the transport identifier carried by the second data, and the third data stored in the third partition can be obtained based on the determined access path.
[0071] Step 420: Verify the third data based on the verification value in the third data.
[0072] The electronic device verifies the third data based on the checksum in the third data to determine whether the third data has changed compared to the data at storage, that is, to determine whether the data content of the third data is consistent with the data content of the first data. Since the data content of the first data is consistent with the data content of the original data, this step can also be used to determine whether the data content of the third data is consistent with the data content of the original data.
[0073] In one embodiment of this application, the electronic device can determine the current verification value of the third data according to the verification algorithm used to determine the verification value in the third data; if the current verification value of the third data is consistent with the verification value in the third data, the verification of the third data is determined to be successful; if the current verification value of the third data is inconsistent with the verification value in the third data, the verification of the third data is determined to be unsuccessful.
[0074] Step 430: Determine whether the third data has been successfully verified.
[0075] If the third data verification is successful, proceed to step 440, which copies the third data stored in the third partition to the second partition.
[0076] If the third data verification is successful, the electronic device can determine that the third data has not changed and is the data corresponding to the first data, and then copy the third data stored in the third partition to the second partition.
[0077] If the third data verification fails, the electronic device can execute step 450 to delete the second data stored in the second partition and the third data stored in the third partition. In one embodiment of this application, after deleting the second data stored in the second partition and the third data stored in the third partition, the electronic device can return to the step of retrieving the original data in the first partition, that is, execute the following... Figure 3 Step 310 shown can also be as follows: Figure 2 Step 210 is shown.
[0078] In the above embodiment, the third data is further verified before being copied to the second partition, and the third data is copied to the second partition only after successful verification. This can avoid the situation where the third data is copied to the second partition if it is incorrect, and further ensure the accuracy and integrity of the data in the second partition.
[0079] The method provided in the above embodiments can delete the second data stored in the second partition and the third data stored in the third partition after the third data verification fails, re-acquire the original data and store it to obtain new second and third data, thereby completing the data initialization operation. This allows the data migration operation to be re-executed when it is determined that the migrated data is abnormal, avoiding repeated data transfer.
[0080] Figure 5 This is a detailed flowchart of a method for determining a second and third partition according to an embodiment of this application, applied to an electronic device. The order of steps in this flowchart can be changed, and some steps can be omitted, depending on different requirements.
[0081] Step 510: Determine the space required for the first data.
[0082] In one embodiment of this application, the space required by the first data can be determined based on the amount of first data; alternatively, the space required by the first data can be determined based on the space occupied by the original data. For example, the space required by the check value and the transport identifier can be added to the space occupied by the original data to obtain the space required by the first data.
[0083] Step 520: Determine the second and third partitions based on the space required by the first data.
[0084] The size of the second and third partitions is greater than or equal to the space required by the first data. The size of the second partition can be the same as or different from that of the third partition; no restrictions are imposed here.
[0085] The method provided in the above embodiments can accurately determine the memory size required by the second and third partitions, avoiding the situation where the second or third partition cannot store the first data due to insufficient space, thereby further ensuring the success rate of data migration.
[0086] Figure 6 This is a flowchart of a data migration method provided in one embodiment of this application, applied to an electronic device. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0087] Step 610: Obtain the raw data from the first partition.
[0088] For some specific implementation details of step 610, please refer to the above description. Figure 2 The relevant description of step 210.
[0089] Step 620: If it fails to retrieve the original data from the first partition, retrieve the original data from the server and calculate the checksum of the original data.
[0090] If retrieving the original data from the first partition fails, the electronic device or the electronic device containing the electronic device can communicate with a server. The server can be a database or other device providing storage functionality. In some embodiments, the server stores the original data from the first partition. In other embodiments, the server may also store general data to ensure that the original data can be replaced with general data obtained from the server when the original data cannot be retrieved, thereby ensuring the normal operation of the electronic device.
[0091] For specific implementation methods for calculating the checksum of the original data, please refer to the above section. Figure 2 The relevant description of step 220.
[0092] Step 630: Add a checksum and a transport identifier to the original data to obtain the first data.
[0093] Step 640: Determine the second and third partitions.
[0094] Step 650: Write the first data to the second and third partitions.
[0095] Step 660: In response to the received data initialization command, read the second data stored in the second partition.
[0096] Step 670: Verify the second data based on the check value in the second data.
[0097] Step 680: If the second data verification fails and the second data carries a transfer identifier, then copy the third data stored in the third partition to the second partition.
[0098] For details regarding steps 630 to 680, please refer to the above text. Figure 2 The relevant descriptions of steps 220 to 270.
[0099] The method provided in the above embodiments can retrieve the original data from the server when the electronic device fails to obtain the original data from the first partition. After adding a checksum and a transfer identifier to the original data, the resulting first data is written to the second and third partitions. The first data written to the second partition is called the second data, and the first data written to the third partition is called the third data. This allows the first data to be backed up in the third partition. If the second data in the second partition becomes abnormal, the third data can be directly retrieved from the third partition without needing to access the first partition again to obtain the original data, reducing the number of accesses to the first partition and thus lowering the probability of the first partition becoming abnormal. Furthermore, by adding a checksum to the original data, the second data stored in the second partition can be verified during each data initialization operation, allowing for timely determination of whether the second data is abnormal, thereby reducing the occurrence of using abnormal second data. Simultaneously, when the second data becomes abnormal, the added transfer identifier can accurately determine whether the third data corresponding to the second data exists in the third partition, improving the accuracy of determining the third data and thus increasing the efficiency of copying the third data to the second partition.
[0100] Figure 7 This is a schematic diagram of the structure of a data migration apparatus provided in one embodiment of this application. In some embodiments, the data migration apparatus 70 may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the data migration apparatus 70 may be stored in the memory of an electronic device and executed by at least one processor to perform the data migration methods described in the various embodiments above.
[0101] In this embodiment, the data migration device 70 can be divided into multiple functional modules according to the functions it performs. These multiple functional modules may include: a data calculation module 701, a data processing module 702, a storage partitioning module 703, a data writing module 704, a data verification module 705, and a data copying module 706. The term "module" in this application refers to a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory. In the embodiments of this application, the limitations of the data migration device 70 can be found in the above-described limitations of the data migration method, and will not be repeated in detail here.
[0102] Data calculation module 701 is used to obtain the original data in the first partition and calculate the check value of the original data; The data processing module 702 is used to add check values and transport identifiers to the raw data to obtain the first data; Storage partitioning module 703 is used to determine the second and third partitions; The data writing module 704 is used to write the first data to the second and third partitions; The data verification module 705 is used to respond to the received data initialization command, read the second data stored in the second partition, and verify the second data according to the verification value in the second data; The data copying module 706 is used to copy the third data stored in the third partition to the second partition if the second data verification fails and the second data carries a transfer identifier.
[0103] It is understood that the module division described above is a logical functional division, and there may be other division methods in actual implementation. Furthermore, the functional modules in the various embodiments of this application can be integrated into the same processing unit, or each module can exist physically separately, or two or more modules can be integrated into the same unit. The integrated modules described above can be implemented in hardware or in a combination of hardware and software functional modules.
[0104] In this embodiment, some specific implementation methods for the functions of each module / unit can be found in the relevant descriptions of the data migration methods in the multiple embodiments described above, and will not be repeated here.
[0105] As can be seen from the above technical solutions, the data migration device can write the first data (after adding a checksum and a transport identifier to the original data in the first partition) to the second and third partitions. The first data written to the second partition is called the second data, and the first data written to the third partition is called the third data. This allows the first data to be backed up in the third partition. If the second data in the second partition becomes abnormal, the third data can be directly retrieved from the third partition without needing to access the first partition again to obtain the original data, reducing the number of accesses to the first partition and thus lowering the probability of the first partition becoming abnormal. Furthermore, by adding a checksum to the original data, the second data stored in the second partition can be verified during each data initialization operation, allowing for timely determination of whether the second data is abnormal, thereby reducing the occurrence of using abnormal second data. Simultaneously, when the second data becomes abnormal, the added transport identifier can accurately determine whether the third data corresponding to the second data exists in the third partition, improving the accuracy of determining the third data and thus increasing the efficiency of copying the third data to the second partition.
[0106] Please see Figure 8 , Figure 8 This is a schematic block diagram of the structure of an electronic device provided in an embodiment of this application.
[0107] The network in which electronic device 100 is located includes, but is not limited to, the Internet, wide area network, metropolitan area network, local area network, and virtual private network (VPN).
[0108] like Figure 8 As shown, the electronic device 100 includes a communication interface 801, a memory 802, a processor 803, an input / output (I / O) interface 804, and a bus 805. The processor 803 is coupled to the communication interface 801, the memory 802, and the I / O interface 804 via the bus 805.
[0109] The communication interface 801 is used for communication. The communication interface 801 can be an existing interface on the electronic device 100 or a newly created interface on the electronic device 100. The communication interface 801 can be a network interface, such as a Wireless Local Area Network (WLAN) interface, a cellular network communication interface, or a combination thereof.
[0110] The memory 802 can be used to store operating systems and computer programs. For example, the memory 802 stores the program corresponding to the data migration method described above.
[0111] It should be understood that the memory 802 may include a program storage area and a data storage area. The program storage area may be used to store the operating system, application programs required by at least one method (such as data migration methods), etc.; the data storage area may store data created based on the use of the electronic device 30, etc. Furthermore, the memory 802 may include volatile memory, and may also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other storage devices.
[0112] Processor 803 provides computing and control capabilities to support the operation of the entire computer device. For example, processor 803 is used to execute computer programs stored in memory 802 to implement the steps in the data migration method described above, for example... Figure 2 to Figure 6 The steps in the process.
[0113] It should be understood that processor 803 is a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.
[0114] I / O interface 804 is used to provide a channel for user input or output. For example, I / O interface 804 can be used to connect various input and output devices (mouse, keyboard or 3D touch device, etc.) and displays, so that users can enter information or visualize information.
[0115] Bus 805 is used at least to provide a channel for communication between communication interface 801, memory 802, processor 803 and I / O interface 804 in electronic device 100.
[0116] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0117] In one embodiment, the data migration method is applied to an electronic device 100. When the processor 803 executes a computer program stored in the memory 802 to implement the data migration method, the following steps are performed: Retrieve the original data from the first partition and calculate the checksum of the original data; Add a checksum and a transport identifier to the original data to obtain the first data. Determine the second and third partitions; Write the first data to the second and third partitions; In response to the received data initialization command, read the second data stored in the second partition and verify the second data according to the check value in the second data; If the second data verification fails, and the second data carries a transfer identifier, then the third data stored in the third partition will be copied to the second partition.
[0118] Specifically, the processor 803's specific implementation method for the above instructions can be found in the description of the relevant steps in the aforementioned data migration method embodiment, and will not be repeated here.
[0119] This application also provides a computer-readable storage medium storing a computer program, the computer program including program instructions, and the method implemented when the program instructions are executed can be referred to various embodiments of the data migration method of this application.
[0120] The computer-readable storage medium can be an internal storage unit of the electronic device described in the foregoing embodiments, such as a hard disk or memory of the electronic device. Alternatively, the computer-readable storage medium can be an external electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., mounted on the electronic device.
[0121] Furthermore, the computer-readable storage medium may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system, at least one application program required for a function, etc.; and the data storage area may store data created based on the use of the electronic device, etc.
[0122] The electronic device and computer-readable storage medium provided in the foregoing embodiments, by adding a checksum and a transfer identifier to the original data in the first partition, obtains first data, which is then written to the second and third partitions. The first data, after being written to the second partition, is called second data, and after being written to the third partition, it is called third data. This allows the first data to be backed up in the third partition. If the second data in the second partition subsequently becomes abnormal, the third data can be directly retrieved from the third partition without needing to access the first partition again to obtain the original data, reducing the number of accesses to the first partition and thus lowering the probability of the first partition becoming abnormal. Furthermore, by adding a checksum to the original data, the second data stored in the second partition can be verified based on the checksum during each data initialization operation, allowing for timely determination of whether the second data is abnormal, thereby reducing the occurrence of using abnormal second data. Simultaneously, when the second data becomes abnormal, the added transfer identifier can accurately determine whether the third data corresponding to the second data exists in the third partition, improving the accuracy of determining the third data and thus increasing the efficiency of copying the third data to the second partition.
[0123] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0124] It should also be understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. It should be noted that, herein, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0125] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The above descriptions are merely specific implementations of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data migration method, applied in electronic devices, characterized in that, The method includes: Obtain the original data in the first partition and calculate the check value of the original data; Add the check value and the transfer identifier to the original data to obtain the first data, wherein the transfer identifier is used to indicate that the original data is stored in two different partitions; Determine the second and third partitions; Write the first data into the second partition and the third partition; In response to the received data initialization command, the system reads the second data stored in the second partition and verifies the second data based on the checksum in the second data. If the second data verification fails, and the second data carries the transfer identifier, then the third data stored in the third partition is copied to the second partition.
2. The data migration method as described in claim 1, characterized in that, After verifying the second data based on the check value in the second data, the method further includes: If the second data is successfully verified, the data initialization operation is completed based on the second data.
3. The data migration method as described in claim 1, characterized in that, If the second data verification fails, and the second data carries the transfer identifier, then copying the third data stored in the third partition to the second partition includes: If the second data verification fails, and the second data carries the transport identifier, then the third data stored in the third partition is obtained; The third data is verified based on the verification value in the third data. If the third data verification is successful, the third data stored in the third partition will be copied to the second partition.
4. The data migration method as described in claim 3, characterized in that, After verifying the third data based on the check value in the third data, the method further includes: If the third data verification fails, delete the second data stored in the second partition and the third data stored in the third partition, and return to the step of obtaining the original data in the first partition.
5. The data migration method as described in claim 1, characterized in that, The method further includes: If the second data verification fails and the second data does not carry the transport identifier, then delete the second data stored in the second partition and the third data stored in the third partition, and return to the step of obtaining the original data in the first partition.
6. The data migration method according to any one of claims 1 to 5, characterized in that, The method further includes: When the original data cannot be obtained from the first partition, the original data is obtained from the server, and the checksum of the original data is calculated.
7. The data migration method as described in claim 1, characterized in that, The determination of the second and third partitions includes: Determine the space required for the first data; The second and third partitions are determined based on the space required by the first data, and the space size of the second partition and the space size of the third partition are both greater than or equal to the space required by the first data.
8. A data migration device, characterized in that, The data migration device includes: The data calculation module is used to obtain the raw data in the first partition and calculate the check value of the raw data; The data processing module is used to add the check value and the transfer identifier to the original data to obtain the first data, wherein the transfer identifier is used to indicate that the original data is stored in two different partitions; The storage partitioning module is used to determine the second and third partitions; A data writing module is used to write the first data into the second partition and the third partition; The data verification module is used to respond to the received data initialization command, read the second data stored in the second partition, and verify the second data according to the verification value in the second data; The data copying module is used to copy the third data stored in the third partition to the second partition if the second data verification fails and the second data carries the transfer identifier.
9. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the data migration method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions that are executed by a processor in an electronic device to implement the data migration method as described in any one of claims 1 to 7.