CN-122019421-A - Power-down protection method and equipment for solid state disk and storage medium
Abstract
The application discloses a power-down protection method, equipment and a storage medium of a solid state disk, and relates to the technical field of data processing, wherein the method comprises the steps of acquiring mirror image data of a cache emergency data area when the solid state disk is detected to be in a pre-power-down state; and deleting redundant fields of data in a common data area of a cache according to a preset minimum writing protocol, and writing the obtained necessary data into the pre-allocation protection block. The technical problems that data are easy to lose and writing efficiency is low when the solid state disk falls off an electric field are solved.
Inventors
- TANG JIANBO
- HU XIAOJUN
- Huang Lvhuai
- YE WEI
Assignees
- 得一微电子股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260109
Claims (10)
- 1. The power-down protection method for the solid state disk is characterized by comprising the following steps of: when the solid state disk is detected to be in a pre-power-down state, mirror image data of a cache emergency data area are obtained; writing the mirror image data into a pre-allocated protection block of the flash memory based on a preset interface; And deleting redundant fields of data in the cache common data area according to a preset minimum writing protocol, and writing the obtained necessary data into the pre-allocation protection block.
- 2. The method for protecting the solid state disk from power failure of claim 1, wherein before the step of obtaining the mirrored data of the cache emergency data area when the solid state disk is detected to be in the pre-power-failure state, the method for protecting the solid state disk from power failure further comprises: acquiring a power supply voltage of the preset interface, and comparing the power supply voltage with a preset voltage threshold; And when the power supply voltage is smaller than or equal to the voltage threshold, determining that the solid state disk is in the pre-power-down state.
- 3. The method for protecting a solid state disk from power failure according to claim 1, wherein the step of deleting the redundant control field of the data in the common data area of the cache according to the preset minimum write-in protocol and writing the obtained necessary data into the pre-allocation protection block comprises the steps of: acquiring the minimized writing protocol, and determining a redundant field list and a necessary data list according to the minimized writing protocol; Splitting the data of the common data area into field units based on a preset field offset and a field length; Traversing the field units, marking the fields in the redundant field list as redundant fields, and marking the field units in the necessary data reservation list as the necessary data; writing the necessary data into the pre-allocation protection block.
- 4. The method for protecting a solid state disk from power failure according to claim 3, wherein traversing the field unit, marking the field in the redundant field list as a redundant field, and marking the field unit in the necessary data retention list as the necessary data comprises: Acquiring the relative offset range of the field in the data block in the redundant field list and the necessary data list to obtain the position characteristic; Comparing the actual offset range of the field unit with the position feature, comparing the actual intercepting length of the field unit with the length feature, and comparing the type mark of the field unit with the type feature; when the comparison results are that all the field units are matched with the redundant field characteristics, judging that the field units are the redundant fields; And when the comparison results are all matched with the necessary field characteristics, judging the field units as the necessary data.
- 5. The method for protecting a solid state disk from power failure in accordance with claim 3, wherein said step of writing said necessary data into said pre-allocated protection block comprises: Acquiring a reduced verification code generation rule in the minimized writing protocol, and determining the algorithm type and length constraint of the reduced verification code; If the original check code is not matched with the algorithm type or the length constraint, generating the simplified check code based on the simplified check code generation rule and the necessary data; and writing the simplified verification code and the necessary data into the pre-allocation protection block.
- 6. The method for protecting the solid state disk from power failure of claim 1, wherein before the step of obtaining the mirrored data of the cache emergency data area when the solid state disk is detected to be in the pre-power-failure state, the method for protecting the solid state disk from power failure further comprises: Acquiring the block capacity of the erased state based on a preset period, and if the block capacity is smaller than a preset capacity threshold value, performing data erasure; And when the solid state disk is detected to be in an idle state, acquiring and erasing data of the block to be erased.
- 7. The method for protecting the solid state disk from power failure in accordance with claim 1, wherein after the step of deleting redundant fields of data in a cache normal data area and writing the obtained necessary data into the pre-allocation protection block according to a preset minimum write protocol, the method for protecting the solid state disk from power failure further comprises: when the power supply voltage is detected to be greater than or equal to the power-on voltage threshold value and lasting for a preset time period, acquiring the power-on flag bit and the current count value of the power-on counter; if the power-on flag bit is in a power-on state and the current count value is greater than the historical count value, confirming that the solid state disk is in a power-on state again; And checking the data integrity of the data in the pre-allocation protection block.
- 8. The method for protecting a solid state disk from power failure of claim 7, wherein the step of verifying the data integrity of the data in the pre-allocated protection block comprises: Comparing the emergency data with mirror image data corresponding to the emergency data, and if the emergency data are consistent, determining that the emergency data are complete data; If the emergency data are inconsistent with the mirror image data, generating a first check code based on a preset first check algorithm and the emergency data, and comparing the first check code with an initial check code of the emergency data; when the first check code is inconsistent with the initial check code of the emergency data, determining that the data is missing; generating a second check code based on a preset second check algorithm and common data, and comparing the second check code with an initial check code of the common data; and when the second check code is inconsistent with the initial check code of the common data, determining that the data is missing.
- 9. A power-down protection device for a solid state disk, characterized in that the device comprises a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the power-down protection method for a solid state disk according to any one of claims 1 to 8.
- 10. A storage medium, characterized in that the storage medium is a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the power-down protection method of a solid state disk according to any one of claims 1 to 8.
Description
Power-down protection method and equipment for solid state disk and storage medium Technical Field The application relates to the technical field of data processing, in particular to a power failure protection method of a solid state disk. Background The Solid State Disk (SSD) is powered down due to factors such as external power interruption, hardware faults or environmental interference, when the power supply is abnormally interrupted, the capacitor provides short-term power for the SSD through quick discharging, information such as user data and a mapping table in a cache can be written into the flash memory in an emergency mode before power failure, meanwhile, the SSD utilizes reserved redundant flash memory blocks as temporary storage spaces to receive the data, occupied available capacity of users is avoided, and after the power supply is restored, the data are recombined through firmware to restore integrity and consistency. However, the capacitor energy storage scheme has the problems of high cost and shortened service life of the capacitor due to the influence of high-voltage environment, and the expansion of the redundant block can improve the data security, but can directly reduce the actual available storage space of the SSD, and can cause the write amplification effect due to frequent writing into the redundant area, thereby accelerating the abrasion of the flash memory. The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present application and is not intended to represent an admission that the foregoing is prior art. Disclosure of Invention The application mainly aims to provide a power-down protection method for a solid state disk, and aims to solve the technical problems that data are easy to lose and writing efficiency is low under the power-down field of the solid state disk. In order to solve the above problems, the present application provides a power-down protection method for a solid state disk, where the power-down protection method for a solid state disk includes: when the solid state disk is detected to be in a pre-power-down state, mirror image data of a cache emergency data area are obtained; writing the mirror image data into a pre-allocated protection block of the flash memory based on a preset interface; And deleting redundant fields of data in the cache common data area according to a preset minimum writing protocol, and writing the obtained necessary data into the pre-allocation protection block. In an embodiment, before the step of obtaining the mirrored data of the buffer emergency data area when the solid state disk is detected to be in the pre-power-down state, the power-down protection method of the solid state disk further includes: acquiring a power supply voltage of the preset interface, and comparing the power supply voltage with a preset voltage threshold; And when the power supply voltage is smaller than or equal to the voltage threshold, determining that the solid state disk is in the pre-power-down state. In an embodiment, the step of deleting the redundant control field of the data in the common data area according to the preset minimum write-in protocol, and writing the obtained necessary data into the pre-allocation protection block includes: acquiring the minimized writing protocol, and determining a redundant field list and a necessary data list according to the minimized writing protocol; Splitting the data of the common data area into field units based on a preset field offset and a field length; Traversing the field units, marking the fields in the redundant field list as redundant fields, and marking the field units in the necessary data reservation list as the necessary data; writing the necessary data into the pre-allocation protection block. In one embodiment, the step of traversing the field units, marking the fields in the redundant field list as redundant fields, and marking the field units in the necessary data retention list as the necessary data includes: Acquiring the relative offset range of the field in the data block in the redundant field list and the necessary data list to obtain the position characteristic; Comparing the actual offset range of the field unit with the position feature, comparing the actual intercepting length of the field unit with the length feature, and comparing the type mark of the field unit with the type feature; when the comparison results are that all the field units are matched with the redundant field characteristics, judging that the field units are the redundant fields; And when the comparison result is that all the field characteristics are matched with the necessary field characteristics, judging the field unit as the necessary data. In one embodiment, the step of writing the necessary data to the pre-allocated protection block comprises: Acquiring a reduced verification code generation rule in the minimized writing protocol, and determining the al