Metadata loss prevention method and apparatus, readable storage medium, and electronic device

By obtaining metadata write instructions from the EMMC firmware, traversing data blocks, and determining their correctness, the problem of metadata loss was solved, and the integrity and stability of metadata were achieved.

CN114637702BActive Publication Date: 2025-11-25BIWIN STORAGE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210151916.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2025-11-25
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

Existing technologies cannot effectively guarantee the integrity and correctness of metadata in EMMC firmware, resulting in a high risk of metadata loss and affecting firmware stability.

Method used

By obtaining the metadata write command, the system data blocks are traversed to determine the correctness of the metadata. If the metadata is incorrect, it is erased and a new target data block is selected until the metadata is completely saved. The array subscript is used to determine the completion of the traversal, and low-level formatting is performed when the metadata cannot be completely saved.

Benefits of technology

It improves the integrity of metadata storage, reduces the risk of metadata loss, and ensures the stability of EMMC firmware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114637702B_ABST
    Figure CN114637702B_ABST
Patent Text Reader

Abstract

The application discloses a metadata loss prevention method and device, a readable storage medium and an electronic device. After a system obtains a metadata writing instruction, corresponding metadata is written into a target data block according to the metadata writing instruction. When it is detected that the metadata in the target data block is not completely saved, the target data block storing the metadata is erased, a new target data block is obtained again to save the metadata, and the completeness of the metadata is detected again until the metadata is completely saved in the data block, so that the metadata written in the data block is complete metadata, loss of the metadata is avoided, and the completeness of metadata saving is improved and the risk of metadata loss is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of memory, in particular to a metadata loss prevention method and device, readable storage medium and electronic equipment. BACKGROUND

[0002] In the development of EMMC (Embedded Multi Media Card) firmware, metadata is the key data for recording and ensuring the normal operation of the entire firmware. However, the current metadata saving is a relatively simple saving process. It cannot ensure the integrity and correctness of the metadata when saving the metadata. Moreover, when the saved metadata is abnormal, the abnormal metadata cannot be processed or repaired in time. Therefore, it is impossible to effectively avoid the loss of metadata, which leads to the fact that the EMMC firmware cannot effectively save complete metadata, and the stability of the EMMC firmware in the process of use and development is not high. SUMMARY

[0003] The technical problem to be solved by the present application is to provide a metadata loss prevention method and device, readable storage medium and electronic equipment, to improve the integrity of metadata saving and reduce the risk of metadata loss.

[0004] To solve the above technical problems, the technical scheme adopted by the present application is:

[0005] A metadata loss prevention method, comprising the steps of:

[0006] acquiring a metadata write instruction;

[0007] sequentially traversing all data blocks in the system, and when a target data block is traversed, writing the metadata into the target data block according to the metadata write instruction;

[0008] judging whether the metadata is correct, if not, erasing the metadata in the target data block and continuing to traverse, if yes, exiting the traversal.

[0009] To solve the above technical problems, another technical scheme adopted by the present application is:

[0010] A metadata loss prevention device, comprising:

[0011] an acquisition module for acquiring a metadata write instruction;

[0012] a traversal module for sequentially traversing all data blocks in the system, and when a target data block is traversed, writing the metadata into the target data block according to the metadata write instruction;

[0013] A judging module is configured to judge whether the metadata is correct, if not, erase the metadata in the target data block and continue the traversal, and if yes, exit the traversal.

[0014] To solve the above technical problems, another technical solution adopted by the present application is:

[0015] A computer readable storage medium has a computer program stored thereon, and the computer program, when executed by a processor, implements each step of the metadata loss prevention method.

[0016] To solve the above technical problems, another technical solution adopted by the present application is:

[0017] An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements each step of the metadata loss prevention method when executing the computer program.

[0018] The present application has the beneficial effects that: after the system obtains the metadata writing instruction, the corresponding metadata is written into the target data block according to the metadata writing instruction, when it is detected that the metadata in the target data block is not completely saved, the target data block storing the metadata is erased, and then a new target data block is obtained for saving the metadata, and the completeness of the metadata is detected again until the data block completely saves the metadata, so that the metadata written into the data block is complete metadata, avoiding the loss of metadata, and improving the completeness of metadata saving and reducing the risk of metadata loss. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 The step flow chart of the metadata loss prevention method in the embodiment of the present application is shown.

[0020] Figure 2 The structural schematic diagram of the metadata loss prevention device in the embodiment of the present application is shown.

[0021] Figure 3 The structural schematic diagram of the electronic device in the embodiment of the present application is shown.

[0022] Figure 4 Another step flow chart of the metadata loss prevention method in the embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] To explain the technical content, the achieved purposes and effects of the present application in detail, the following will be explained in combination with the embodiments and the drawings.

[0024] Please refer to Figure 1 A metadata loss prevention method includes the following steps:

[0025] acquire a metadata write instruction;

[0026] sequentially traverse all data blocks in the system, when a target data block is traversed, write the metadata into the target data block according to the metadata write instruction;

[0027] determine whether the metadata is correct, if not, erase the metadata in the target data block and continue to traverse, if yes, exit the traversal.

[0028] From the above description, the beneficial effects of the present application are that: after the system acquires the metadata write instruction, the corresponding metadata is written into the target data block according to the metadata write instruction, when it is detected that the metadata in the target data block is not completely saved, the target data block storing the metadata is erased, and then a new target data block is acquired for saving the metadata, and the integrity of the metadata is detected again until the data block completely saves the metadata, so as to ensure that the metadata written into the data block is complete metadata, avoid the loss of metadata, and realize the improvement of the integrity of the metadata saving and the reduction of the risk of metadata loss.

[0029] Further, the data blocks are stored in the system in the form of an array;

[0030] The metadata write instruction further comprises:

[0031] acquire the array subscript corresponding to the target data block;

[0032] determine whether the traversal of all data blocks is completed according to the array subscript.

[0033] From the above description, by storing the data blocks in the system in the form of an array, it is more convenient to acquire the data blocks, and at the same time, the array subscript corresponding to the target data block is acquired when the metadata is written into the target data block, so that whether the traversal of all data blocks is completed can be conveniently determined through the array subscript corresponding to the target data block, the traversal efficiency is improved, and the accuracy of determining the traversal process is also improved.

[0034] Further, the determination of whether the traversal of all data blocks is completed according to the array subscript comprises:

[0035] acquire the array subscript corresponding to the target data block in which the first written metadata is incomplete, and obtain a first block index value;

[0036] when the metadata written in the traversed target data block is incomplete, erase the metadata in the target data block, record the array subscript corresponding to the target data block, and obtain a second block index value;

[0037] determining whether the first block index value and the second block index value are same, if yes, the traversal of all data blocks is completed.

[0038] As can be seen from the above description, by erasing the metadata in the target data block in which the first metadata saving fails during the traversal of the data blocks, recording the array index corresponding to the target data block as the first block index value, and taking the array index of the target data block in the subsequent traversal process as the second block index value, and by comparing the first block index value with the second block index value, it can be quickly determined whether the traversal of all data blocks in the system is completed.

[0039] Further, it further comprises:

[0040] When the metadata written by the target data block is complete, the first block index value is restored to the default value.

[0041] As can be seen from the above description, when the target data block saves the metadata completely, the first block index value is restored to the default value, and when the target data block is traversed again and the metadata is incomplete, the first block index value is recorded again, so that it can be determined whether the first block index value is the default value and further whether there is incomplete metadata to be saved, thereby realizing the processing and improving the integrity of the metadata saving.

[0042] Further, after the array index is used to determine whether the traversal of all data blocks is completed, it further comprises:

[0043] Low formatting is performed on all the target data blocks in the system.

[0044] As can be seen from the above description, when the traversal of all data blocks in the system is completed, but the metadata cannot be saved completely and correctly in the data blocks, low formatting is performed on all the data blocks in the system, and all the data blocks are reset, so that the data blocks after low formatting can be used again, thereby improving the stability of the system.

[0045] Further, before the metadata is determined to be correct, it further comprises:

[0046] It is determined whether there is an old data block in the system in which the metadata is saved, if yes, the old data block is erased, and the target data block in which the metadata is currently stored is retained.

[0047] As can be seen from the above description, by determining whether there is a different data block in the system in which the same metadata is stored, and erasing the metadata in the old data block in which the metadata is stored, it is avoided that the system abnormity occurs.

[0048] Further, the metadata write instruction comprises a write address and write data amount information;

[0049] The writing of the metadata into the target data block according to the metadata write instruction comprises:

[0050] The writing of the metadata into the target data block according to the write address and write data amount information.

[0051] From the above description, the metadata is written into the target data block through the write address and write data amount information contained in the write instruction, so that the metadata can be accurately written into the corresponding data block, and the integrity of the metadata can be judged through the data amount and other information in the subsequent metadata integrity judgment process, thereby enhancing the correctness of the metadata and reducing the incompleteness of the metadata.

[0052] Please refer to Figure 2 Another embodiment of the present application provides a metadata loss prevention device, comprising:

[0053] An acquisition module is configured to acquire a metadata write instruction;

[0054] A traversal module is configured to sequentially traverse all data blocks in a system, and when a target data block is reached, the metadata is written into the target data block according to the metadata write instruction;

[0055] A judgment module is configured to judge whether the metadata is correct, and if not, the metadata in the target data block is erased and the traversal is continued; if yes, the traversal is exited.

[0056] Another embodiment of the present application provides a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement each step of the metadata loss prevention method.

[0057] Please refer to Figure 3 Another embodiment of the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements each step of the metadata loss prevention method when executing the computer program.

[0058] The metadata loss prevention method, device, computer readable storage medium and electronic device can be applied to metadata storage of various types of storage devices, especially metadata storage of EMMC storage devices, which will be described in detail in the following specific embodiments.

[0059] Please refer to Figure 1 and Figure 4 A metadata loss prevention method comprises the following steps:

[0060] S1, obtaining a metadata write instruction; the metadata write instruction comprises information such as a write address and a write data amount;

[0061] S2, sequentially traversing all data blocks in the system, when a target data block is traversed, the metadata is written into the target data block according to the metadata write instruction; specifically, the metadata is written into the target data block according to the address corresponding to the write instruction; wherein the traversal refers to finding data blocks by adding 1 to the subscript to realize the traversal function on the EMMC, and the EMMC itself does not have the above-mentioned traversal function;

[0062] S3, judging whether there is an old data block in the system that saves the metadata, if yes, erasing the old data block and keeping the target data block that currently stores the metadata.

[0063] S4, judging whether the metadata is correct, if no, erasing the metadata in the target data block and continuing to traverse; if yes, exiting the traversal;

[0064] Wherein, the data blocks are stored in the system in the form of an array, according to the total capacity and the life to calculate how many data blocks are needed, and form a data block group; in S2, the metadata is written into the target data block according to the write address and the write data amount information, and the array subscript corresponding to the target data block is also written into the target data block; after the metadata is written and saved, it is judged whether the metadata is correct through a read-back operation; when it is found that the metadata is incorrect data, the integrity of the metadata is checked; and whether the traversal of all data blocks is completed is judged according to the array subscript;

[0065] In step S2, whether the traversal of all data blocks is completed is judged according to the array subscript, which is specifically as follows:

[0066] S21, obtaining the array subscript corresponding to the first target data block in which the metadata is not complete after being written, obtaining a first block number value; for example, if the array subscript corresponding to the current target data block is 8, the metadata in the data blocks before the target data block is complete after being written, and the metadata is not complete after being written into the target data block, then the target data block is the first target data block in which the metadata is not complete after being written, and the first block number value A=8 of the current block is recorded;

[0067] S22, when the metadata written by the target data block traversed is incomplete, after erasing the metadata in the target data block, record the array subscript corresponding to the target data block to obtain a second block index value; if the array subscript corresponding to the target data block currently traversed is 9, record the second block index value B=9 of the current block, and if the array subscript corresponding to the target data block currently traversed is 11, record the second block index value B=11 of the current block;

[0068] Or when the metadata written by the target data block traversed is complete, restore the first block index value to a default value, and only record the second block index value; for example, restore the first block index value to the default value 0xFF, indicating that the current target data block successfully saves the metadata;

[0069] S33, judge whether the first block index value and the second block index value are the same, if yes, the traversal of all data blocks is completed; for example, when the first block index value A=8 and the second block index value B=9 / 11, the first block index value and the second block index value are not equal at present, indicating that the traversal of all data blocks is not completed; for another example, when the first block index value A=8 and the second block index value B=8, the first block index value and the second block index value are equal at present, indicating that the traversal of all data blocks is completed;

[0070] In an optional embodiment, after step S33, there is further a step S34 of low formatting all the target data blocks in the system; the low formatting includes low-level formatting and a production flow; by low formatting all the data blocks in the system, all the data blocks are reset, so that the system firmware can normally run, thereby enabling the data blocks after low formatting to be used again, and improving the system stability.

[0071] Embodiment two

[0072] Please refer to Figure 2 A metadata loss prevention device, comprising:

[0073] An acquisition module, configured to acquire a metadata writing instruction;

[0074] A traversal module, configured to traverse all data blocks in the system one by one, and when a target data block is traversed, write the metadata into the target data block according to the metadata writing instruction;

[0075] A judgment module, configured to, if no, erase the metadata in the target data block and continue the traversal; and if yes, exit the traversal.

[0076] Embodiment three

[0077] A computer readable storage medium, having stored thereon a computer program, which when executed by a processor implements each step of a metadata loss prevention method as described in Embodiment One.

[0078] Embodiment Four

[0079] Please refer to Figure 3 An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements each step of a metadata loss prevention method as described in Embodiment One when executing the computer program.

[0080] In summary, the present application provides a metadata loss prevention method, device, readable storage medium and electronic device, after the system obtains a metadata write instruction, the corresponding metadata is written into the target data block according to the metadata write instruction, and then it is checked whether there is a data block that saves the same metadata, if there is, the old data block is erased, and further it is judged whether the currently saved metadata is correct, if not, it is detected whether the metadata is saved completely, when it is detected that the metadata in the target data block is not completely saved, the target data block that saves the metadata is erased, and then a new target data block is obtained for saving metadata, and the completeness of the metadata is detected again, until the data block completely saves the metadata, so that the metadata written into the data block is complete metadata, avoiding the loss of metadata, realizing improving the completeness of metadata saving and reducing the risk of metadata loss; and when all data blocks cannot completely save the metadata, the data blocks in the system are low formatted, so that the firmware can normally run after low formatting.

[0081] In the above embodiments provided in the present application, it should be understood that the disclosed method, device, computer readable storage medium and electronic device can be implemented in other ways. For example, the above-described device embodiments are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of components or modules can be combined or integrated into another device, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed components can be indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.

[0082] The components described as separate components may or may not be physically separate, and the components shown as components may or may not be physical modules, i.e. they can be located in one place or distributed on multiple network modules. Some or all components can be selected to achieve the purpose of the present embodiment scheme according to actual needs.

[0083] In addition, each functional module in each embodiment of the present application can be integrated in one processing module, or each component can be physically present separately, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module.

[0084] When the integrated module is realized in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application or the entire or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.

[0085] It should be noted that, for each method embodiment described above, in order to simplify the description, each method embodiment is described as a combination of a series of actions, but those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0086] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0087] The above is only an embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent transformation made by using the content of the specification and drawings, or direct or indirect application in related technical fields, is also included in the patent protection scope of the present application.

Claims

1. A metadata loss prevention method, characterized by, The method comprises the steps of: obtaining a metadata write instruction; sequentially traversing all data blocks in the system, and when a target data block is traversed, writing the metadata into the target data block according to the metadata write instruction; judging whether the metadata is correct, if not, erasing the metadata in the target data block and continuing the traversal, if yes, exiting the traversal; the data blocks are stored in the system in the form of an array; the step of writing the metadata into the target data block according to the metadata write instruction further comprises: obtaining an array subscript corresponding to the target data block; judging whether the traversal of all data blocks is completed according to the array subscript; the step of judging whether the traversal of all data blocks is completed according to the array subscript comprises: obtaining an array subscript corresponding to a target data block in which the first written metadata is incomplete, to obtain a first block index value; when the metadata written in the target data block traversed is incorrect, recording the array subscript corresponding to the target data block after erasing the metadata in the target data block, to obtain a second block index value; if the metadata written in the target data block is correct, recording the array subscript corresponding to the target data block, to obtain a second block value; judging whether the first block index value and the second block index value are the same, if yes, the traversal of all data blocks is completed.

2. The metadata loss prevention method of claim 1, wherein, the method further comprises: when the metadata written in the target data block traversed is correct, restoring the first block index value to a default value.

3. The metadata loss prevention method of claim 1, wherein, after the step of judging whether the traversal of all data blocks is completed according to the array subscript, the method further comprises: if the traversal of all data blocks is completed, performing a low formatting on all target data blocks in the system.

4. The metadata loss prevention method of claim 1, wherein, before the step of judging whether the metadata is correct, the method further comprises: judging whether there is an old data block in the system in which the metadata is saved, if yes, erasing the old data block and retaining the target data block in which the metadata is currently stored.

5. The metadata loss prevention method of claim 1, wherein, the metadata write instruction comprises write address and write data amount information; the step of writing the metadata into the target data block according to the metadata write instruction comprises: writing the metadata into the target data block according to the write address and write data amount information.

6. A metadata loss-prevention apparatus characterized by comprising: The method comprises the steps of: obtaining a metadata write instruction; sequentially traversing all data blocks in the system, and when a target data block is traversed, writing the metadata into the target data block according to the metadata write instruction; judging whether the metadata is correct, if not, erasing the metadata in the target data block and continuing the traversal, if yes, exiting the traversal; wherein the data blocks are stored in the system in the form of an array; the step of writing the metadata into the target data block according to the metadata write instruction further comprises: obtaining an array subscript corresponding to the target data block; judging whether the traversal of all data blocks is completed according to the array subscript; the step of judging whether the traversal of all data blocks is completed according to the array subscript comprises: obtaining an array subscript corresponding to a target data block in which the first written metadata is incomplete, to obtain a first block index value; when the metadata written in the target data block traversed is incorrect, recording the array subscript corresponding to the target data block after erasing the metadata in the target data block, to obtain a second block index value; if the metadata written in the target data block is correct, recording the array subscript corresponding to the target data block, to obtain a second block value; judging whether the first block index value and the second block index value are the same, if yes, the traversal of all data blocks is completed. When the metadata written by the target data block being traversed is incorrect, after erasing the metadata in the target data block, the array subscript corresponding to the target data block is recorded to obtain a second block index value; If the metadata written by the target data block is correct, the array subscript corresponding to the target data block is recorded to obtain a second block index value; If the first block index value and the second block index value are the same, it is determined that the traversal of all data blocks is completed.

7. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement each step of the metadata loss prevention method according to any one of claims 1-5.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement each step of the metadata loss prevention method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Data storage method, apparatus and device

    CN111666046A