SSD power-off reconstruction method, device, electronic device and medium
By storing safe power-off reconstruction parameters in the SSD and judging the content of the protection block during power-on, the problem of prolonged SSD power-off reconstruction time is solved, enabling fast power-on and avoiding platform incompatibility, ensuring data integrity.
Patent Information
- Application Number
- CN202411009024.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-26
AI Technical Summary
After the SSD frequently receives safe shutdown or hibernation commands, the power outage and rebuild time are prolonged, resulting in incompatibility with the host platform.
When the SSD receives the safe power-off command, the safe power-off reconstruction parameters are stored in the fast power-on page, and the content of the protection block is determined during power-on. If it is the content of the fast power-on page, it is restored to the P2L block and L2P Block and cache information table are reconstructed; if the content of the power-on page is invalid, reconstruction is performed based on the cache information table.
It improves the power-on reconstruction time of SSD, avoids compatibility issues with other platforms, and ensures data integrity and consistency.
Smart Images

Figure CN118567574B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of solid state drives, and in particular to a method, device, electronic device and medium for power-off reconstruction of an SSD. Background Art
[0002] When an SSD (Solid State Drive) receives a safe shutdown command or a hibernation command, some application computers or service platforms require the SSD to restart quickly, otherwise it will cause incompatibility between the SSD and the host platform. There are many actions to search for flash memory pages in the prior art. When safe shutdown commands or hibernation commands are frequently issued to the SSD, when the SSD power-on reconstruction time is prolonged, it will cause incompatibility with the platform. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present application provide a SSD power-off reconstruction method, device, electronic device and medium.
[0004] In a first aspect, an embodiment of the present application provides a method for powering off and rebuilding an SSD, the method comprising:
[0005] When the SSD receives a safe power-off command, it stores the safe power-off reconstruction parameters in the fast power-on page;
[0006] Writing the content of the fast power-on page into a protection block, wherein the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page;
[0007] When the SSD is powered on, determining whether the content last written into the protection block is the content of the fast power-on page;
[0008] If the last content written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD is a safe power-off;
[0009] The content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt respectively, and the SSD is rebuilt.
[0010] In one embodiment, the safe power-off reconstruction parameters include: parameters of the P2L block, parameters of the L2P block, and information of the cache information table;
[0011] The restoring the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt respectively, and rebuilding the SSD includes:
[0012] Determine a first storage location in the fast power-on page for storing parameters of the P2L block, a second storage location for parameters of the L2P block, and a third storage location for information of the cache information table;
[0013] Reading the parameters of the P2L block from the fast power-on page according to the first storage location, and copying the parameters of the P2L block to the memory of the P2L block to be rebuilt;
[0014] reading the parameters of the L2P block from the fast power-on page according to the second storage location, and copying the parameters of the L2P block to the memory of the L2P block to be rebuilt;
[0015] The information of the cache information table is read from the fast power-on page according to the third storage location, and the information of the cache information table is copied to the cache information table to be rebuilt.
[0016] In one embodiment, after the safe power-off reconstruction parameters are stored in the fast power-on page, the method further includes:
[0017] If the SSD receives a data content modification command, an additional information recording command, or a flash memory particle content writing command, the content of the invalid power-on page is written into the protection block.
[0018] In one implementation, after writing the content of the invalid power-on page into the protection block, the method further includes:
[0019] When the SSD is powered on, determining whether the content last written into the protection block is the content of the invalid power-on page;
[0020] If the content last written into the protection block is the content of the invalid power-on page, it is determined that the last power-off of the SSD is not a safe power-off, and the cache information table last written is found from the protection block;
[0021] The SSD is rebuilt according to the cache information table.
[0022] In one implementation, the rebuilding of the SSD according to the cache information table includes:
[0023] Acquire active blocks and L2P blocks according to the cache information table;
[0024] Searching backwards in sequence according to the first page of the active block, when a page with correct content is found, obtaining the parameters of the corresponding P2L block;
[0025] Arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block;
[0026] Writing the parameters of the sorted P2L block into the memory of the P2L block to be reconstructed;
[0027] According to the L2P block, searching is performed from the current written page of the L2P block in sequence, and stopping when the first blank page is found, and the parameters of the L2P block are rebuilt on the first blank page.
[0028] In one implementation, the arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block includes:
[0029] Collecting P2L entries in the P2L block;
[0030] The validity of each of the P2L entries is verified to obtain a valid P2L entry, and the valid P2L entries are sorted according to the order of the logical addresses to obtain the parameters of the sorted P2L block.
[0031] In a second aspect, an embodiment of the present application provides an SSD power-off reconstruction device, the SSD power-off reconstruction device comprising:
[0032] The receiving module is used to store the safe power-off reconstruction parameters into the fast power-on page when the SSD receives the safe power-off command;
[0033] A writing module, used for writing the content of the fast power-on page into a protection block, wherein the protection block is used for storing the content of the fast power-on page and the content of the invalid power-on page;
[0034] A first judgment module, used for judging whether the content last written into the protection block is the content of the fast power-on page when the SSD is powered on;
[0035] A second judgment module is used to determine that the last power-off of the SSD is a safe power-off if the content last written into the protection block is the content of the fast power-on page;
[0036] The reconstruction module is used to restore the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, so as to rebuild the SSD.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the SSD power-off reconstruction method provided in the first aspect is executed.
[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when running on a processor, executes the SSD power-off reconstruction method provided in the first aspect.
[0039] The SSD power-off reconstruction method provided by the present application is as follows: when the SSD receives a safe power-off command, the safe power-off reconstruction parameters are stored in the fast power-on page; the content of the fast power-on page is written into the protection block, and the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page; when the SSD is powered on, it is determined whether the content last written into the protection block is the content of the fast power-on page; if the content last written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD was a safe power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, to rebuild the SSD. In this way, by storing the safe power-off reconstruction parameters in the fast power-on page; writing the content of the fast power-on page into the protection block, when it is determined that the last power-off of the SSD was a safe power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, the SSD power-on reconstruction time is improved, and the compatibility problem of the SSD with other platforms is avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present application and should not be regarded as limiting the scope of protection of the present application. In each of the drawings, similar components are numbered similarly.
[0041] Figure 1 A schematic diagram of a process of an SSD power-off reconstruction method provided in an embodiment of the present application is shown;
[0042] Figure 2 Another schematic diagram of the process of the SSD power-off reconstruction method provided by the embodiment of the present application is shown;
[0043] Figure 3 A schematic diagram of the structure of an SSD power-off reconstruction device provided in an embodiment of the present application is shown;
[0044] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown.
[0045] Icons: 300 - SSD power-off reconstruction device; 301 - receiving module; 302 - writing module; 303 - first judgment module; 304 - second judgment module; 305 - reconstruction module; 400 - electronic device; 401 - transceiver; 402 - processor; 403 - memory. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0047] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0048] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present application, are intended only to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations of the foregoing items.
[0049] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0050] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0051] Example 1
[0052] An embodiment of the present application provides a method for power-off reconstruction of an SSD.
[0053] See also Figure 1 The SSD power-off reconstruction method includes steps S101 to S105:
[0054] Step S101, when the SSD receives a safe power-off command, it stores safe power-off reconstruction parameters in a fast power-on page.
[0055] In this embodiment, the safe power-off reconstruction parameters are the P2L (Physical to Logical, physical address to logical address mapping) parameters, the L2P (Logical to Physical, logical address to physical address block mapping) parameters and the contents of the cache information table integrated into the contents of the fast power-on page; when the SSD receives a safe power-off command or ps4 (power state 4, power-saving sleep mechanism), the safe power-off reconstruction parameters required after power-on are saved to the fast power-on page.
[0056] Step S102: writing the content of the fast power-on page into a protection block, wherein the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page.
[0057] In this embodiment, whenever the SSD (Solid State Drive) receives a safe power-off command or a sleep command, the parameters of the P2L block, the parameters of the L2P block and the contents of the cache information table required after power-on are integrated into the contents of the fast power-on page, and then the contents of the fast power-on page are written into the protection block.
[0058] Step S103, when the SSD is powered on, determining whether the content last written into the protection block is the content of the fast power-on page.
[0059] In this embodiment, since the SSD writes corresponding parameters or contents into the protection block according to each command received, it is necessary to determine whether the contents of the latest written protection block are fast power-on pages.
[0060] Step S104: If the content last written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD is a safe power-off.
[0061] In this embodiment, in the SSD, the protection block is used to record the information of the last safe power-off. When the SSD is shut down normally or enters the power-saving sleep mode, the system will ensure that the latest data is correctly written to the protection block. This block usually contains information about the last successfully written data block so that it can be restored from it when the SSD is restarted to ensure the integrity and consistency of the data.
[0062] Step S105 , respectively restoring the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, and rebuilding the SSD.
[0063] In this embodiment, the P2L block is responsible for mapping the physical block address to the logical block address. During the reconstruction process, the system extracts information related to the P2L mapping from the fast power-on page and restores it to the P2L block to be rebuilt. This ensures that after reconstruction, the SSD can correctly map the logical block address to the corresponding physical block address. The L2P block is responsible for mapping the logical block address to the physical block address. Similar to the P2L block, the system extracts information related to the L2P mapping from the fast power-on page and restores it to the L2P block to be rebuilt. This ensures that after reconstruction, the SSD can correctly convert the logical block address to the physical block address, so that it can correctly read and write data; the cache information table contains many parameters, including: which block is currently receiving data, how many pages have been written to this block; how many valid 4k data are there in each block.
[0064] See also Figure 2 , step S105 includes steps S1051-S1054:
[0065] Step S1051, determining a first storage location in the fast power-on page for storing parameters of the P2L block, a second storage location for storing parameters of the L2P block, and a third storage location for storing information of the cache information table.
[0066] Step S1052: read the parameters of the P2L block from the fast power-on page according to the first storage location, and copy the parameters of the P2L block to the memory of the P2L block to be rebuilt.
[0067] Step S1053: read the parameters of the L2P block from the fast power-on page according to the second storage location, and copy the parameters of the L2P block to the memory of the L2P block to be rebuilt.
[0068] Step S1054: reading the information of the cache information table from the fast power-on page according to the third storage location, and copying the information of the cache information table to the cache information table to be rebuilt.
[0069] In this embodiment, for example, in the fast power-on page, positions 0~0x3FFF store the P2L block, and positions 0x4000~0x23FFF store the cache information table. The contents of positions 0~0x3FFF are copied to the P2L block to be rebuilt, and the contents of positions 0x4000~0x23FFF are copied to the cache information table to be rebuilt, which can save SSD reconstruction time and achieve the purpose of fast power-on.
[0070] In one embodiment, step S101 includes the following contents:
[0071] If the SSD receives a data content modification command, an additional information recording command, or a flash memory particle content writing command, the content of the invalid power-on page is written into the protection block.
[0072] In this embodiment, when the SSD receives a data content modification command or an additional information recording command or a flash memory content write command, a Flash (Flash Memory) write operation will be performed, and the content in the invalid power-on page will be saved to the protection block.
[0073] In one implementation, when the SSD is powered on, it is determined whether the content last written into the protection block is the content of the invalid power-on page.
[0074] If the content last written into the protection block is the content of the invalid power-on page, it is determined that the last power-off of the SSD was not a safe power-off, and the cache information table last written is found from the protection block.
[0075] The SSD is rebuilt according to the cache information table.
[0076] In this embodiment, when the SSD is powered on, it is determined that the last written content is the content of the invalid power-on page. If the last written content is the content of the invalid power-on page, it is determined that the last power-off of the SSD was not a safe power-off; that is, when the SSD receives a safe power-off command or a sleep command, the P2L parameters, L2P parameters and cache information table (CacheInfo table) that need to be rebuilt after power-on are restored. Table) is saved to the fast power-on page. If the SSD is powered off after being saved to the fast power-on page, when the SSD is powered on again, it only needs to determine whether the last content written to the protection block is the content in the fast power-on page. If so, the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt for fast reconstruction; if the SSD receives other commands after being saved to the fast power-on page, such as a write command, at this time, the write command is stored in the invalid power-on page, and then the content of the invalid power-on page is written to the protection block. At this time, the content in the invalid power-on page replaces the content in the fast power-on page. At this time, after the SSD is powered on, it is determined whether the last content written to the protection block is the content in the invalid power-on page. If it is the content in the invalid power-on page, the SSD is rebuilt according to the cache information table.
[0077] In one implementation, the active block and the L2P block are acquired according to the cache information table.
[0078] Search is performed sequentially from the first page of the active block, and when a page with correct content is found, the parameters of the corresponding P2L block are obtained.
[0079] Arrange the parameters of the P2L block to obtain arranged parameters of the P2L block.
[0080] The parameters of the sorted P2L block are written into the memory of the P2L block to be reconstructed.
[0081] According to the L2P block, searching is performed from the current written page of the L2P block in sequence, and stopping when the first blank page is found, and the parameters of the L2P block are rebuilt on the first blank page.
[0082] In this embodiment, reconstruction is performed based on the cache information table. Specifically, the content written on each page is checked from the protection block, and the cache information table written last is found. The parameters of the active block and the L2P block are obtained based on the cache information table, wherein the active block is used to record the content written to the host data. Then, the search is performed from the first page of the active block in sequence. When the correct content is found, the corresponding P2L parameters are obtained. The P2L parameters are then sorted and written into the P2L block to be reconstructed. In the L2P block, the search is performed from the current page of the L2P block in sequence. When the first blank page is found, the parameters of the L2P block are reconstructed on the first blank page.
[0083] In one embodiment, the P2L entries in the P2L block are collected.
[0084] The validity of each of the P2L entries is verified to obtain a valid P2L entry, and the valid P2L entries are sorted according to the order of the logical addresses to obtain the parameters of the sorted P2L block.
[0085] In this embodiment, the parameters of the P2L block are sorted. Specifically, the SSD needs to collect all P2L entries. Verifying the validity of the P2L entries mainly involves checking ECC (Error Checking and Correcting). After obtaining the valid P2L entries, the corresponding logical address is extracted from each valid P2L entry. The logical address usually refers to a field in the P2L entry, which indicates the location of the logical page in the memory or address space. The extracted logical addresses are sorted using bubble sort, insertion sort, quick sort, merge sort, etc.
[0086] The SSD power-off reconstruction method provided in this embodiment, when the SSD receives a safe power-off command, stores the safe power-off reconstruction parameters in the fast power-on page; writes the content of the fast power-on page into the protection block, the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page; when the SSD is powered on, it is determined whether the content last written to the protection block is the content of the fast power-on page; if the content last written to the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD was a safe power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, to reconstruct the SSD, by storing the safe power-off reconstruction parameters in the fast power-on page; writes the content of the fast power-on page into the protection block, when it is determined that the last power-off of the SSD was a safe power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, to improve the power-on reconstruction time of the SSD, achieve the purpose of fast power-on, and avoid the compatibility problem of the SSD with other platforms.
[0087] Example 2
[0088] In addition, an embodiment of the present application provides an SSD power-off reconstruction device, which is applied to electronic equipment.
[0089] like Figure 3 As shown, the SSD power-off reconstruction device 300 includes:
[0090] The receiving module 301 is used to store the safe power-off reconstruction parameters into the fast power-on page when the SSD receives the safe power-off command;
[0091] A writing module 302, used for writing the content of the fast power-on page into a protection block, where the protection block is used for storing the content of the fast power-on page and the content of the invalid power-on page;
[0092] A first judgment module 303 is used to judge whether the content last written into the protection block is the content of the fast power-on page when the SSD is powered on;
[0093] A second judgment module 304 is configured to determine that the last power-off of the SSD is a safety power-off if the content last written into the protection block is the content of the fast power-on page;
[0094] The reconstruction module 305 is used to restore the content in the fast power-on page to the P2L block to be reconstructed, the L2P block to be reconstructed and the cache information table to be reconstructed, so as to reconstruct the SSD.
[0095] The SSD power-off reconstruction device 300 provided in this embodiment can implement the SSD power-off reconstruction method provided in Embodiment 1, and will not be described again here to avoid repetition.
[0096] The SSD power-off reconstruction device provided in the present embodiment stores the safety power-off reconstruction parameters into the fast power-on page when the SSD receives the safety power-off command; writes the content of the fast power-on page into the protection block, the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page; when the SSD is powered on, it is determined whether the content last written into the protection block is the content of the fast power-on page; if the content last written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD is a safety power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, respectively, to reconstruct the SSD, by storing the safety power-off reconstruction parameters into the fast power-on page; writes the content of the fast power-on page into the protection block, when it is determined that the last power-off of the SSD is a safety power-off; the content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, respectively, to improve the power-on reconstruction time of the SSD, achieve the purpose of fast power-on, and avoid the compatibility problem of the SSD with other platforms.
[0097] Example 3
[0098] In addition, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, the SSD power-off reconstruction method provided in Embodiment 1 is executed.
[0099] For details, see Figure 4 , the electronic device 400 includes: a transceiver 401, a bus interface and a processor 402, the processor 402 is used to: when the SSD receives a safe power-off command, store the safe power-off reconstruction parameters in a fast power-on page;
[0100] Writing the content of the fast power-on page into a protection block, wherein the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page;
[0101] When the SSD is powered on, determining whether the content last written into the protection block is the content of the fast power-on page;
[0102] If the last content written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD is a safe power-off;
[0103] The content in the fast power-on page is restored to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt respectively, and the SSD is rebuilt.
[0104] In one embodiment, the processor 402 is further configured to: restore the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, to rebuild the SSD, including:
[0105] Determine a first storage location in the fast power-on page for storing parameters of the P2L block, a second storage location for parameters of the L2P block, and a third storage location for information of the cache information table;
[0106] Reading the parameters of the P2L block from the fast power-on page according to the first storage location, and copying the parameters of the P2L block to the memory of the P2L block to be rebuilt;
[0107] reading the parameters of the L2P block from the fast power-on page according to the second storage location, and copying the parameters of the L2P block to the memory of the L2P block to be rebuilt;
[0108] The information of the cache information table is read from the fast power-on page according to the third storage location, and the information of the cache information table is copied to the cache information table to be rebuilt.
[0109] In one embodiment, the processor 402 is further configured to: write the content of the invalid power-on page into the protection block if the SSD receives a data content modification command or an additional message recording command or a flash memory particle content write command.
[0110] In one implementation, the processor 402 is further configured to: when the SSD is powered on, determine whether the content last written into the protection block is the content of the invalid power-on page;
[0111] If the content last written into the protection block is the content of the invalid power-on page, it is determined that the last power-off of the SSD is not a safe power-off, and the cache information table last written is found from the protection block;
[0112] The SSD is rebuilt according to the cache information table.
[0113] In one implementation, the processor 402 is further configured to: obtain active blocks and L2P blocks according to the cache information table;
[0114] Searching backwards in sequence according to the first page of the active block, when a page with correct content is found, obtaining the parameters of the corresponding P2L block;
[0115] Arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block;
[0116] Writing the parameters of the sorted P2L block into the memory of the P2L block to be reconstructed;
[0117] According to the L2P block, searching is performed from the current written page of the L2P block in sequence, and stopping when the first blank page is found, and the parameters of the L2P block are rebuilt on the first blank page.
[0118] In one embodiment, the processor 402 is further configured to: collect P2L entries in the P2L block;
[0119] The validity of each of the P2L entries is verified to obtain a valid P2L entry, and the valid P2L entries are sorted according to the order of the logical addresses to obtain the parameters of the sorted P2L block.
[0120] In the embodiment of the present application, the electronic device 400 further includes a memory 403. Figure 4 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking various circuits of one or more processors represented by processor 402 and memory represented by memory 403. The bus architecture may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 401 may be a plurality of components, i.e., including a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. The processor 402 is responsible for managing the bus architecture and general processing, and the memory 403 may store data used by the processor 402 when performing operations.
[0121] The electronic device 400 provided in the embodiment of the present application can execute the steps of the SSD power-off reconstruction method provided in the above method embodiment 1, and will not be described again here to avoid repetition.
[0122] The electronic device provided by the present embodiment stores the safe power-off reconstruction parameters into the fast power-on page when the SSD receives the safe power-off command; writes the content of the fast power-on page into the protection block, the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page; when the SSD is powered on, determines whether the content last written into the protection block is the content of the fast power-on page; if the content last written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD was a safe power-off; restores the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, respectively, and rebuilds the SSD, by storing the safe power-off reconstruction parameters into the fast power-on page; writes the content of the fast power-on page into the protection block, when it is determined that the last power-off of the SSD was a safe power-off; restores the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, respectively, to improve the power-on reconstruction time of the SSD, achieve the purpose of fast power-on, and avoid the compatibility problem of the SSD with other platforms.
[0123] Example 4
[0124] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the SSD power-off reconstruction method provided in Example 1 is implemented.
[0125] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0126] The computer-readable storage medium provided in this embodiment can implement the SSD power-off reconstruction method provided in Example 1, and will not be described again here to avoid repetition.
[0127] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.
[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0129] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for rebuilding an SSD after power failure, characterized in that: The method comprises: When the SSD receives a safe power-off command, it stores the safe power-off reconstruction parameters in the fast power-on page; Writing the content of the fast power-on page into a protection block, wherein the protection block is used to store the content of the fast power-on page and the content of the invalid power-on page; When the SSD is powered on, determining whether the content last written into the protection block is the content of the fast power-on page; If the last content written into the protection block is the content of the fast power-on page, it is determined that the last power-off of the SSD is a safe power-off; Restore the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt, and the cache information table to be rebuilt, respectively, and rebuild the SSD; After writing the content of the invalid power-on page into the protection block, the method further includes: When the SSD is powered on, determining whether the content last written into the protection block is the content of the invalid power-on page; If the content last written into the protection block is the content of the invalid power-on page, it is determined that the last power-off of the SSD is not a safe power-off, and the cache information table last written is found from the protection block; Acquire active blocks and L2P blocks according to the cache information table; Searching backwards in sequence according to the first page of the active block, when a page with correct content is found, obtaining the parameters of the corresponding P2L block; Arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block; Writing the parameters of the sorted P2L block into the memory of the P2L block to be reconstructed; According to the L2P block, searching is performed from the current written page of the L2P block in sequence, and stopping when the first blank page is found, and the parameters of the L2P block are rebuilt on the first blank page.
2. The SSD power-off reconstruction method according to claim 1, characterized in that: The safe power-off reconstruction parameters include: parameters of the P2L block, parameters of the L2P block, and information of the cache information table; The restoring the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt respectively, and rebuilding the SSD includes: Determine a first storage location in the fast power-on page for storing parameters of the P2L block, a second storage location for parameters of the L2P block, and a third storage location for information of the cache information table; Reading the parameters of the P2L block from the fast power-on page according to the first storage location, and copying the parameters of the P2L block to the memory of the P2L block to be rebuilt; reading the parameters of the L2P block from the fast power-on page according to the second storage location, and copying the parameters of the L2P block to the memory of the L2P block to be rebuilt; The information of the cache information table is read from the fast power-on page according to the third storage location, and the information of the cache information table is copied to the cache information table to be rebuilt.
3. The SSD power-off reconstruction method according to claim 2, characterized in that: After the safe power-off reconstruction parameters are stored in the fast power-on page, the method further includes: If the SSD receives a data content modification command, an additional information recording command, or a flash memory particle content writing command, the content of the invalid power-on page is written into the protection block.
4. The SSD power-off reconstruction method according to claim 1, characterized in that: Arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block includes: Collecting P2L entries in the P2L block; The validity of each of the P2L entries is verified to obtain a valid P2L entry, and the valid P2L entries are sorted according to the order of the logical addresses to obtain the parameters of the sorted P2L block.
5. A SSD power-off reconstruction device, characterized in that: The device comprises: The receiving module is used to store the safe power-off reconstruction parameters into the fast power-on page when the SSD receives the safe power-off command; A writing module, used for writing the content of the fast power-on page into a protection block, wherein the protection block is used for storing the content of the fast power-on page and the content of the invalid power-on page; A first judgment module, used for judging whether the content last written into the protection block is the content of the fast power-on page when the SSD is powered on; A second judgment module is used to determine that the last power-off of the SSD is a safe power-off if the content last written into the protection block is the content of the fast power-on page; A reconstruction module, used to restore the content in the fast power-on page to the P2L block to be rebuilt, the L2P block to be rebuilt and the cache information table to be rebuilt, respectively, to rebuild the SSD; After writing the content of the invalid power-on page into the protection block, the method further includes: When the SSD is powered on, determining whether the content last written into the protection block is the content of the invalid power-on page; If the content last written into the protection block is the content of the invalid power-on page, it is determined that the last power-off of the SSD is not a safe power-off, and the cache information table last written is found from the protection block; Acquire active blocks and L2P blocks according to the cache information table; Searching backwards in sequence according to the first page of the active block, when a page with correct content is found, obtaining the parameters of the corresponding P2L block; Arranging the parameters of the P2L block to obtain the arranged parameters of the P2L block; Writing the parameters of the sorted P2L block into the memory of the P2L block to be reconstructed; According to the L2P block, searching is performed from the current written page of the L2P block in sequence, and stopping when the first blank page is found, and the parameters of the L2P block are rebuilt on the first blank page.
6. The SSD power-off reconstruction device according to claim 5, characterized in that: The reconstruction module is further used to determine a first storage location in the fast power-on page for storing parameters of the P2L block, a second storage location for parameters of the L2P block, and a third storage location for information of the cache information table; Reading the parameters of the P2L block from the fast power-on page according to the first storage location, and copying the parameters of the P2L block to the memory of the P2L block to be rebuilt; reading the parameters of the L2P block from the fast power-on page according to the second storage location, and copying the parameters of the L2P block to the memory of the L2P block to be rebuilt; The information of the cache information table is read from the fast power-on page according to the third storage location, and the information of the cache information table is copied to the cache information table to be rebuilt.
7. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program, the SSD power-off reconstruction method according to any one of claims 1 to 4 is executed.
8. A computer-readable storage medium, characterized in that: The computer program is stored therein, and when the computer program is run on a processor, the SSD power-off reconstruction method according to any one of claims 1 to 4 is executed.
Citation Information
Patent Citations
SSD power failure recovery test method and system and control machine
CN112466377A
Solid state disk, data recovery method thereof and terminal equipment
CN112988467A
Power-on reconstruction method and device and solid state disk
CN113296694A
Solid state disk and mapping table management method thereof
CN115878033A
Data recovery method and device for solid state disk and electronic equipment
CN117389798A
