A storage device and a fault handling method thereof
By monitoring the power-on time interval in the storage device and setting it as a pseudo single-layer storage unit, the problem of long garbage collection processing time after the storage device is powered off is solved, rapid disk recognition and system entry are achieved, and the performance and life of the device are improved. .
Patent Information
- Application Number
- CN202410939487.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-15
AI Technical Summary
When the storage device is continuously powered off and on, the garbage collection processing time is too long, resulting in the failure to successfully recognize the disk and enter the system.
By introducing a main controller into the storage device, the power-on time interval is monitored, and when the time interval is less than or equal to the threshold, the block is set to a pseudo single-layer storage unit, and preset values or invalid data are written to avoid garbage collection operations. , ensuring fast recovery and data consistency.
This enables the storage device to quickly recognize the disk and enter the system after a power outage, improving performance and service life.
Smart Images

Figure CN118484150B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of static storage technology, and in particular to a storage device and a fault processing method thereof. Background Art
[0002] Memory chips are the specific application of the concept of embedded system chips in the storage industry. Both system chips and memory chips embed software in a single chip to achieve multi-function, high performance and support for multiple protocols, multiple hardware and different applications. Memory chips are widely used in computers, mobile devices, the Internet of Things and other fields to store various data, such as operating systems, applications, music, videos, photos, etc.
[0003] In the case where the storage device is continuously powered off and on, the garbage collection processing time of the storage device is too long, which may cause the storage device to fail to successfully recognize the disk and enter the system. Therefore, there is room for improvement. Summary of the invention
[0004] The present invention provides a storage device and a fault processing method thereof, so as to solve the technical problem that the storage device cannot successfully recognize a disk and enter a system when the storage device is continuously powered off and powered on.
[0005] The present invention provides a storage device, comprising:
[0006] A flash memory, comprising a plurality of blocks for storing host data, wherein the plurality of blocks are multi-layer storage unit types, and a plurality of idle blocks form an idle block pool;
[0007] A main controller, electrically connected to the flash memory, and configured to monitor a time interval between two adjacent power-ons of the storage device and compare the time interval with a time threshold;
[0008] Wherein, when the time interval is less than or equal to the time threshold, the main controller selects a number of the blocks in the free block pool and sets them as pseudo single-layer storage unit blocks, and the use performance of the pseudo single-layer storage unit blocks is the same as the use performance of blocks of the single-layer storage unit type;
[0009] The main controller stores the host data and a data mapping table associated with the host data in the pseudo single-layer storage unit.
[0010] In one embodiment of the present invention, the main controller is used to cause a power outage during the process of storing the host data and the data mapping table in the pseudo single-layer storage unit, and when the storage device is powered on again, write a preset value or invalid data in the pseudo single-layer storage unit where the storage is not completed, so as to avoid performing a garbage collection operation.
[0011] In one embodiment of the present invention, the main controller records the number of abnormal power failure data recovery times, and when the time interval is less than or equal to the time threshold and the storage device is powered on again for data recovery, the main controller updates the number of abnormal power failure data recovery times.
[0012] In one embodiment of the present invention, the main controller is used to store the host data and a data mapping table associated with the host data in the block when the time interval is greater than a time threshold.
[0013] In one embodiment of the present invention, the main controller is used to set the usage performance of the pseudo single-layer storage unit block to be the same as the usage performance of a multi-layer storage unit type block when the time interval is greater than a time threshold, and store the host data and a data mapping table associated with the host data in the pseudo single-layer storage unit.
[0014] In one embodiment of the present invention, the main controller is used to form a static block pool with multiple pseudo single-layer storage unit blocks, and when the storage space of the static block pool is used up, select several blocks from the free block pool again and divide them into the static block pool.
[0015] The present invention also provides a storage device failure processing method, comprising:
[0016] Receiving host data, and storing the host data in a plurality of blocks of the flash memory, and forming a plurality of idle blocks into an idle block pool, wherein the plurality of blocks are multi-layer storage unit types;
[0017] Monitoring a time interval between two consecutive power-ons of a storage device, and comparing the time interval with a time threshold;
[0018] When the time interval is less than or equal to the time threshold, a number of the blocks are selected from the free block pool and set as pseudo single-layer storage unit blocks, wherein the use performance of the pseudo single-layer storage unit blocks is the same as the use performance of blocks of the single-layer storage unit type;
[0019] The host data and a data mapping table associated with the host data are stored in the pseudo single-layer storage unit.
[0020] In one embodiment of the present invention, after the step of storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit, the method further comprises:
[0021] When a power failure occurs during the process of storing the host data and the data mapping table in the pseudo single-layer storage unit, and when the storage device is powered on again, a preset value or invalid data is written in the pseudo single-layer storage unit where storage is not completed to avoid performing a garbage collection operation.
[0022] In one embodiment of the present invention, after the step of storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit, the method further comprises:
[0023] When the time interval is greater than the time threshold, the host data and a data mapping table associated with the host data are stored in the block.
[0024] In one embodiment of the present invention, after the step of storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit, the method further comprises:
[0025] When the time interval is greater than the time threshold, setting the usage performance of the pseudo single-layer storage unit block to be the same as the usage performance of a multi-layer storage unit type block;
[0026] The host data and a data mapping table associated with the host data are stored in the pseudo single-layer storage unit.
[0027] Beneficial effects of the present invention: A storage device and a fault handling method thereof proposed by the present invention can enable the storage device to quickly complete disk recognition and enter the system when the storage device is continuously powered off and powered on, thereby further improving the performance and service life of the storage device. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 A schematic diagram of the structure of a storage device provided in one embodiment of the present invention.
[0030] Figure 2 A schematic diagram of the composition of a free block pool provided in one embodiment of the present invention.
[0031] Figure 3 A schematic diagram of the migration of a free block pool and a static block pool provided by an embodiment of the present invention.
[0032] Figure 4 A schematic diagram of the division of the free block pool and the static block pool provided by an embodiment of the present invention.
[0033] Figure 5 A schematic diagram of the steps of a storage device failure processing method provided by an embodiment of the present invention.
[0034] Figure 6 An embodiment of the present invention provides Figure 5 Schematic diagram of steps after step S40 in FIG.
[0035] Description of Figure Numbers
[0036] 10. Host; 20. Storage device; 30. Main controller; 40. Flash memory; 41. Block; 42. Page; 401. Free block pool; 402. Static block pool; 410. Data mapping block; 411. Host block; 412. Garbage collection block. DETAILED DESCRIPTION
[0037] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0038] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0039] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0040] See also Figures 1 to 6The present invention proposes a storage device and a fault handling method thereof, which can be applied to storage devices 20 such as eMMC (Embedded Multi Media Card), SSD (Solid State Disk), and UFS (Univeral Flash Storage). The present invention solves the problem of long garbage collection processing time of the storage device 20 when the storage device 20 is continuously powered off and powered on, and enables the storage device 20 to quickly complete disk recognition and enter the system, thereby further improving the performance and service life of the storage device 20. The following is a detailed description through specific embodiments.
[0041] See also Figure 1 In one embodiment of the present invention, a storage device 20 is provided, and a bus interface is provided on the storage device 20, and the storage device 20 is electrically connected to the host 10 through the bus interface. The host 10 can write host data and send instructions to the storage device 20, and the host data refers to the application data written by the host 10, or the host 10 can read host data and receive instructions from the storage device 20. The host 10 can be a communication device such as a personal computer (PC, Personal Computer), a tablet computer (Pad), a mobile phone (Cell Phone), etc.
[0042] See also Figure 1 In one embodiment of the present invention, the storage device 20 may include a main controller 30 and a flash memory 40. Among them, a flash memory interface is provided on the main controller 30, and the main controller 30 and the flash memory 40 are electrically connected through the flash memory interface. The main controller 30 is mainly used to operate and manage the flash memory 40, and the main controller 30 also provides functions such as cache, memory array and interleave. The main controller 30 can control many functions of the flash memory 40, such as bad fast management, wear leveling, error checking and correction (ECC, Error Checking and Correcting), etc. The main controller 30 can greatly improve the read, write and move operation performance of the host data in the flash memory 40.
[0043] See also Figure 1 and Figure 2 In one embodiment of the present invention, in the storage device 20, the flash memory 40 is a non-volatile memory, which is usually used to store host data and system programs. The flash memory 40 may include a plurality of blocks 41, and the blocks 41 may be used to store a data mapping table and host data written by the host 10. A block 41 may also include a plurality of pages 42.
[0044] Specifically, the storage particles on the multiple blocks 41 are of a multi-layer storage cell type, where the multi-layer storage cell type is compared to the single-layer storage cell (SLC, Single Level Cell) type. For example, the multi-layer storage cell may be a double-layer storage cell (MLC, Multi Level Cell), a three-layer storage cell (TLC, Trinary Level Cell), a four-layer storage cell (QLC, Quad Level Cell) or a five-layer storage cell (PLC, Penta level cell) that has not yet been released. As a storage method in this embodiment, the multi-layer storage cell can store multi-bit information, increase the storage capacity, and has a lower cost and moderate performance.
[0045] Specifically, Figure 2 As shown, a free block pool 401 can be formed by multiple free blocks 41, and multiple free blocks 41 in the free block pool 401 are unused blocks 41, and host data can be written to multiple free blocks 41 in the free block pool 401. According to the functional division, the free block pool 401 may include a data mapping block 410, a host block 411 and a garbage collection block 412. Among them, the data mapping block 410 is represented as a block 41 for storing a data mapping table, and the data mapping table stores the mapping information of the logical address and the physical address of the host data. The host block 411 is represented as a block 41 for storing host data. The garbage collection block 412 is represented as a block 41 that needs to be garbage collected.
[0046] See also Figure 1 and Figure 2 In one embodiment of the present invention, the main controller 30 can monitor the time interval between two adjacent power-ons of the storage device 20, and compare the time interval with the time threshold to determine whether the storage device 20 is in a continuous power-off and power-on situation. The time threshold is a non-zero constant. The function of the time threshold is to compare with the time interval to determine the numerical value of the time interval. For example, after the storage device 20 is powered on for the first time to enter the system, the first power-on time is recorded and updated to the storage snapshot. The function of the storage snapshot is to perform online data backup and recovery. When the storage device 20 is powered on next time, the first power-on time can be read and the time interval between the two power-ons can be calculated. The time threshold can be set to 2 minutes. When the time interval is less than or equal to 2 minutes, it means that the storage device 20 has been powered on, powered off, and powered on again within 2 minutes, which can indicate that the storage device 20 is in a continuous power-off and power-on state.
[0047] Specifically, for example, if the storage device 20 suddenly loses power, and if garbage collection is in progress or data mapping table update is not completed, then this part of the data may be in an inconsistent state, causing the storage device 20 to be unable to normally identify and load data, thereby affecting the system startup and data reading. Therefore, after the storage device 20 is powered on again, the main controller 30 will perform a recovery operation to complete the unfinished garbage collection process and repair the data mapping table. Only after ensuring the consistency and integrity of all data can the storage device 20 be normally identified and the data therein allowed to be accessed.
[0048] Specifically, if the storage device 20 is in a state of continuous power-off and power-on, the storage device 20 cannot successfully complete each attempt to perform garbage collection. Each time the garbage collection process starts, a power outage occurs again, resulting in the need to restart the garbage collection process from the point where the power was last cut off when the power is turned on next time. When the storage device 20 is in a state of continuous power-off and power-on, a lot of time will be spent on garbage collection, thereby extending the storage device startup time, and even causing the storage device 20 to fail to successfully recognize the disk and enter the system.
[0049] See also Figure 1 and Figure 2 In one embodiment of the present invention, the main controller 30 selects a number of blocks 41 from the free block pool 401 based on the comparison result of the time interval and the time threshold, and records them as pseudo single-layer flash memory cell blocks (pSLC, pseudo Single Level Cell), and sets the usage performance of the pseudo single-layer flash memory cell blocks to be the same as the usage performance of the blocks 41 of the single-layer flash memory cell (SLC, Single Level Cell) type.
[0050] Specifically, after selecting a number of blocks 41 from the free block pool 401 and recording them as pseudo single-layer flash memory cell blocks, the physical structure of the blocks 41 is not changed. Instead, for multi-layer storage cells such as double-layer storage cells (MLC, Multi Level Cell), three-layer storage cells (TLC, Trinary Level Cell), and four-layer storage cells (QLC, Quad Level Cell), the multi-layer storage cells are switched to single-bit mode. The single-bit mode is that the multi-layer storage cell stores only one bit of information, instead of the original storage of multiple bits of information, which can improve the writing and reading speeds.
[0051] Specifically, within the storage device 20, the integrity of the data mapping table and other key metadata is critical to normal operation. When using a single-layer storage unit to write the data mapping table or other key metadata, even if the metadata is not completely written during the power failure, due to the characteristics of the single-layer storage unit, the remaining portion is regarded as an invalid or unknown state, rather than an error state.
[0052] Specifically, the performance of the pseudo-single-layer flash memory cell block is set to be the same as the performance of the block 41 of the single-layer flash memory cell type. When the storage device 20 is in a continuous power-off and power-on state, in the power-on data recovery stage, when the main controller 30 finds through inspection that the pseudo-single-layer flash memory cell block for which metadata writing has not been completed, it will choose to fill dummy (virtual) data to replace the uncertain data content. The dummy data can be a preset value or invalid data. After continuing to write the preset value or invalid data to these pseudo-single-layer flash memory cell blocks, these pseudo-single-layer flash memory cell blocks can be quickly marked as valid and continue to be used, thereby eliminating the need to perform complex garbage collection processing to clean up and organize metadata. This embodiment can simplify the recovery process and avoid the time required to wait for garbage collection to complete, thereby speeding up the startup speed and disk recognition time of the storage device 20 after power failure, and improving the stability and responsiveness of the storage device 20.
[0053] See also Figure 1 and Figure 2 In one embodiment of the present invention, the main controller 30 is used to store the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit when the time interval is less than or equal to the time threshold.
[0054] Specifically, for the case where the time interval of the storage device 20 is less than or equal to the time threshold, it may be the time interval between two adjacent power-ons, that is, the storage device 20 is powered on, powered off, and then powered on again. In other embodiments, it is also possible that the storage device 20 is powered off more than once, and is powered on again after the power off. It can be considered that as long as the time interval between two adjacent power-ons is less than or equal to the time threshold, it can be determined that the storage device 20 has been continuously powered off and powered on. In the case where the time interval is less than or equal to the time threshold, that is, when the storage device 20 is continuously powered off and powered on, the host data and the data mapping table associated with the host data are stored in the pseudo single-layer storage unit, so that when the storage device 20 is powered on to restore data, the startup speed and disk recognition time of the storage device 20 can be accelerated.
[0055] See also Figure 1 and Figure 2 In one embodiment of the present invention, the main controller 30 is used to cause a power outage during the process of storing host data and a data mapping table in a pseudo-single-layer storage unit, and when the storage device 20 is powered on again, write a preset value or invalid data in the pseudo-single-layer storage unit where the storage is not completed, so as to avoid performing a garbage collection operation.
[0056] Specifically, when a power failure occurs during the process of storing the host data and the data mapping table in the pseudo single-layer storage unit, and when the storage device 20 is powered on again, it is necessary to perform data recovery processing on the storage device 20. In the case where the host data and the data mapping table associated with the host data are stored in the pseudo single-layer storage unit, when the storage device 20 performs data recovery processing, after continuing to write preset values or invalid data to these pseudo single-layer flash memory unit blocks, these pseudo single-layer flash memory unit blocks can be quickly marked as valid and continue to be used, thereby eliminating the need to perform complex garbage collection processing to clean up and organize metadata.
[0057] See also Figure 1 and Figure 2 In one embodiment of the present invention, a data recovery register is provided in the main controller 30, and the data recovery register records the number of abnormal power off data recovery (SPOR, Software Power Off Recovery). When the time interval is less than or equal to the time threshold and the storage device 20 is powered on again for data recovery, the data recovery register updates the number of abnormal power off data recovery.
[0058] Specifically, the number of abnormal power-off data recovery times reflects the data recovery status of the storage device 20 after power-off and power-on, that is, the increase in the number of abnormal power-off data recovery times indicates that the storage device 20 needs to perform data recovery after power-on. If the storage device 20 is powered off normally, then the storage device 20 does not need to perform data recovery processing after the next normal power-on. In this embodiment, when the time interval is greater than the time threshold, the storage device 20 is not continuously powered on and off. When the time interval is greater than the time threshold, an abnormal power-off of the storage device 20 may also occur. Whether it is an abnormal power-off can be considered in combination with the actual situation. In this embodiment, the case where the time interval is greater than the time threshold is taken as an example of a normal power-off of the storage device 20.
[0059] Specifically, when the time interval of the storage device 20 is less than or equal to the time threshold and the number of abnormal power-off data recovery times is greater, the host data and the data mapping table associated with the host data can be stored in the pseudo single-layer storage unit. That is, when the storage device 20 is in a state of continuous power-off and power-on, and the increase in the number of abnormal power-off data recovery times indicates that the storage device 20 needs to perform data recovery after power-on, then the host data and the data mapping table associated with the host data can be stored in the pseudo single-layer storage unit, which can avoid performing a garbage collection operation after the storage device 20 is powered on again.
[0060] See also Figure 1 and Figure 2In one embodiment of the present invention, the main controller 30 is used to store the host data and the data mapping table associated with the host data in the block 41 when the time interval is greater than the time threshold.
[0061] Specifically, when the time interval of the storage device 20 is greater than the time threshold, it indicates that the storage device 20 is not in a continuous power-off and power-on state. At this time, the host data and the data mapping table associated with the host data can be stored in block 41, that is, the host data and the data mapping table are stored in block 41 in the free block pool 401 according to the normal process.
[0062] See also Figure 1 and Figure 2 In one embodiment of the present invention, the main controller 30 is used to set the usage performance of the pseudo single-layer storage unit block to be the same as the usage performance of the multi-layer storage unit type block when the time interval is greater than the time threshold, and store the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit.
[0063] Specifically, since several blocks 41 are selected from the free block pool 401, they are recorded as pseudo single-layer storage unit blocks. The reason for selecting multiple pseudo single-layer storage unit blocks is to take into account the situation that if the storage device 20 is continuously powered on and off, in order to avoid the storage device 20 taking too long to perform garbage collection operations after it is powered on again, resulting in the storage device 20 being unable to successfully recognize the disk and enter the system. However, if the storage device 20 is not in a continuous power-off and power-on state, then multiple pseudo single-layer storage unit blocks have not been used, and wear leveling operations may occur.
[0064] Therefore, in order to avoid possible wear leveling operations, when the time interval of the storage device 20 is greater than the time threshold, it indicates that the storage device 20 is not in a continuous power-off and power-on state. The performance of the pseudo-single-layer storage unit block is set to be the same as the performance of the multi-layer storage unit type block, and the host data and the data mapping table associated with the host data are stored in the pseudo-single-layer storage unit. That is, the pseudo-single-layer storage unit block maintains its original performance, that is, the multi-layer storage unit stores multi-bit information, and the number of storage bits remains the same as the number of storage unit layers. For example, a double-layer storage unit stores two bits of information, and a triple-layer storage unit stores three bits of information.
[0065] See also Figure 1 , Figure 2 , Figure 3 and Figure 4 In one embodiment of the present invention, the main controller 30 is used to form a static block pool 402 with multiple pseudo single-layer storage unit blocks, and when the storage space of the static block pool 402 is used up, a number of blocks 41 are selected from the free block pool 401 again and divided into the static block pool 402.
[0066] Specifically, Figure 3 and Figure 4 As shown, multiple pseudo single-layer storage unit blocks are formed into a static block pool 402, and the static block pool 402 is used to distinguish from the free block pool 401. In practice, the static block pool 402 and the free block pool 401 are both a number of blocks 41 on the flash memory 40. The free block pool 401 and the static block pool 402 are marked on the flash memory 40 so that the host data and the data mapping table associated with the host data are stored in the free block pool 401 or the static block pool 402 correspondingly when the storage device 20 is in different states such as normal power off or continuous power off and power on.
[0067] Specifically, when the storage space of the static block pool 402 is used up, several blocks 41 may be selected from the free block pool 401 again and divided into the static block pool 402. Selecting several blocks 41 from the free block pool 401 and dividing them into the static block pool 402 can leave a margin of storage space in the static block pool 402, which can be used to prevent the storage device 20 from being continuously powered on and off, resulting in the problem that the storage device 20 cannot successfully recognize the disk and enter the system.
[0068] See also Figure 5 In one embodiment of the present invention, a method for handling storage device failure is proposed, which may include the following steps.
[0069] Step S10, receiving host data, and storing the host data in a plurality of blocks of the flash memory, and forming a plurality of free blocks into a free block pool, wherein the plurality of blocks are multi-layer storage unit types.
[0070] Step S20: monitor the time interval between two consecutive power-ons of the storage device, and compare the time interval with a time threshold.
[0071] Step S30, when the time interval is less than or equal to the time threshold, select several blocks from the free block pool and set them as pseudo single-layer storage unit blocks, wherein the performance of the pseudo single-layer storage unit blocks is the same as the performance of single-layer storage unit type blocks.
[0072] Step S40: storing the host data and a data mapping table associated with the host data in a pseudo single-layer storage unit.
[0073] The following is a detailed description through specific embodiments.
[0074] Step S10, receiving host data, and storing the host data in a plurality of blocks of the flash memory, and forming a plurality of free blocks into a free block pool, wherein the plurality of blocks are multi-layer storage unit types.
[0075] In one embodiment of the present invention, the storage particles on the multiple blocks 41 are of a multi-layer storage cell type, where the multi-layer storage cell type is compared to the single-layer storage cell (SLC, Single Level Cell) type. For example, the multi-layer storage cell may be a double-layer storage cell (MLC, Multi Level Cell), a three-layer storage cell (TLC, Trinary Level Cell), a four-layer storage cell (QLC, Quad Level Cell) or a five-layer storage cell (PLC, Penta level cell) that has not yet been released. As a storage method in this embodiment, the multi-layer storage cell can store multi-bit information, increase the storage capacity, and has a lower cost and moderate performance.
[0076] Step S20: monitor the time interval between two consecutive power-ons of the storage device, and compare the time interval with a time threshold.
[0077] In one embodiment of the present invention, the time interval between two adjacent power-ons of the storage device 20 can be monitored, and the time interval can be compared with a time threshold to determine whether the storage device 20 is in a continuous power-off and power-on situation. For example, after the storage device 20 is powered on for the first time to enter the system, the first power-on time is recorded and updated to the storage snapshot. The function of the storage snapshot is to perform online data backup and recovery. When the storage device 20 is powered on next time, the first power-on time can be read, and the time interval between the two power-ons can be calculated. The time threshold can be set to 2 minutes. When the time interval is less than or equal to 2 minutes, it means that the storage device 20 has been powered on, powered off, and powered on again within 2 minutes, which can indicate that the storage device 20 is in a continuous power-off and power-on state.
[0078] Step S30, when the time interval is less than or equal to the time threshold, select several blocks from the free block pool and set them as pseudo single-layer storage unit blocks, wherein the performance of the pseudo single-layer storage unit blocks is the same as the performance of single-layer storage unit type blocks.
[0079] In one embodiment of the present invention, after selecting a number of blocks 41 from the free block pool 401 and recording them as pseudo single-layer flash memory cell blocks, the physical structure of the blocks 41 is not changed. Instead, for multi-layer storage cells such as double-layer storage cells (MLC, MultiLevel Cell), three-layer storage cells (TLC, Trinary Level Cell), and four-layer storage cells (QLC, Quad Level Cell), the multi-layer storage cells are switched to a single-bit mode, which is a multi-layer storage cell that stores only one bit of information, rather than the original storage of multiple bits of information, which can improve the writing and reading speeds.
[0080] Step S40: storing the host data and a data mapping table associated with the host data in a pseudo single-layer storage unit.
[0081] In one embodiment of the present invention, the performance of the pseudo-single-layer flash memory cell block is set to be the same as the performance of the block 41 of the single-layer flash memory cell type, and the host data and the data mapping table associated with the host data are stored in the pseudo-single-layer storage unit. When the storage device 20 is in a continuous power-off and power-on state, in the power-on data recovery stage, when the main controller 30 finds that the pseudo-single-layer flash memory cell block that has not completed the metadata writing through inspection, it will choose to fill dummy (virtual) data to replace the uncertain data content. The dummy data can be a preset value or invalid data. By continuing to write the preset value or invalid data to these pseudo-single-layer flash memory cell blocks, these pseudo-single-layer flash memory cell blocks can be quickly marked as valid and continue to be used, thereby eliminating the need to perform complex garbage collection processing to clean up and organize metadata.
[0082] In one embodiment of the present invention, after step S40, a power outage may occur during the process of storing the host data and the data mapping table in the pseudo-single-layer storage unit, and when the storage device 20 is powered on again, a preset value or invalid data is written in the pseudo-single-layer storage unit where the storage is not completed to avoid performing a garbage collection operation.
[0083] Specifically, when the storage device 20 is powered on and data needs to be restored, when the host data and the data mapping table are stored in the pseudo single-layer storage unit, dummy data can be filled in the blank page 42 in the pseudo single-layer storage unit to replace the uncertain data content. The dummy data can be a preset value or invalid data. After the preset value or invalid data continues to be written to these pseudo single-layer flash memory cell blocks, these pseudo single-layer flash memory cell blocks can be quickly marked as valid and continue to be used, thereby eliminating the need to perform complex garbage collection processing to clean up and organize metadata.
[0084] See also Figure 6 In one embodiment of the present invention, step S40 may include step S510, step S520 and step S530. Step S510 may be represented as storing the host data and the data mapping table associated with the host data in the block 41 of the free block pool 401 when the time interval of the storage device 20 is greater than the time threshold.
[0085] Specifically, when the time interval of the storage device 20 is greater than the time threshold, it indicates that the storage device 20 is not in a continuous power-off and power-on state. At this time, the host data and the data mapping table associated with the host data can be stored in block 41, that is, the host data and the data mapping table are stored in block 41 in the free block pool 401 according to the normal process.
[0086] Step S520 may be represented as setting the performance of the pseudo single-layer storage unit block to be the same as the performance of the multi-layer storage unit type block when the time interval of the storage device 20 is greater than the time threshold. Step S530 may be represented as storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit.
[0087] Specifically, in order to avoid possible wear leveling operations, when the time interval of the storage device 20 is greater than the time threshold, it indicates that the storage device 20 is not in a continuous power-off and power-on state. The performance of the pseudo-single-layer storage unit block is set to be the same as the performance of the multi-layer storage unit type block, and the host data and the data mapping table associated with the host data are stored in the pseudo-single-layer storage unit. That is, the pseudo-single-layer storage unit block maintains its original performance, that is, the multi-layer storage unit stores multi-bit information, and the number of storage bits remains the same as the number of storage unit layers. For example, a double-layer storage unit stores two bits of information, and a triple-layer storage unit stores three bits of information.
[0088] In summary, the present invention provides a storage device and a fault handling method thereof, which can solve the problem of long garbage collection processing time of the storage device when the storage device is continuously powered off and powered on. The present invention can enable the storage device to quickly complete disk recognition and enter the system, thereby further improving the performance and service life of the storage device.
[0089] The flow chart and block diagram in the accompanying drawings illustrate the possible implementation architecture, function and operation of the method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
Claims
1. A storage device, characterized in that: include: A flash memory, comprising a plurality of blocks for storing host data, wherein the plurality of blocks are multi-layer storage unit types, and a plurality of idle blocks form an idle block pool; A main controller, electrically connected to the flash memory, and configured to monitor a time interval between two adjacent power-ons of the storage device and compare the time interval with a time threshold; Wherein, when the time interval is less than or equal to the time threshold, the main controller selects a number of the blocks in the free block pool and sets them as pseudo single-layer storage unit blocks, and the use performance of the pseudo single-layer storage unit blocks is the same as the use performance of blocks of the single-layer storage unit type; The main controller stores the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit; The main controller is used to cause a power outage during the process of storing the host data and the data mapping table in the pseudo single-layer storage unit, and when the storage device is powered on again, write a preset value or invalid data in the pseudo single-layer storage unit where the storage is not completed to avoid performing a garbage collection operation.
2. The storage device according to claim 1, characterized in that The main controller records the number of abnormal power failure data recovery times. When the time interval is less than or equal to the time threshold and the storage device is powered on again to recover data, the main controller updates the number of abnormal power failure data recovery times.
3. The storage device according to claim 1, characterized in that: The main controller is used for storing the host data and a data mapping table associated with the host data in the block when the time interval is greater than a time threshold.
4. The storage device according to claim 1, characterized in that: The main controller is used to set the usage performance of the pseudo single-layer storage unit block to be the same as the usage performance of a multi-layer storage unit type block when the time interval is greater than a time threshold, and store the host data and a data mapping table associated with the host data in the pseudo single-layer storage unit.
5. The storage device according to claim 1, characterized in that: The main controller is used to form a static block pool with the plurality of pseudo single-layer storage unit blocks, and when the storage space of the static block pool is used up, select a number of the blocks from the free block pool again and divide them into the static block pool.
6. A method for handling storage device failure, characterized in that: include: Receiving host data, and storing the host data in a plurality of blocks of the flash memory, and forming a plurality of idle blocks into an idle block pool, wherein the plurality of blocks are multi-layer storage unit types; Monitoring a time interval between two consecutive power-ons of a storage device, and comparing the time interval with a time threshold; When the time interval is less than or equal to the time threshold, a number of the blocks are selected from the free block pool and set as pseudo single-layer storage unit blocks, wherein the use performance of the pseudo single-layer storage unit blocks is the same as the use performance of blocks of the single-layer storage unit type; storing host data and a data mapping table associated with the host data in the pseudo single-layer storage unit; When a power failure occurs during the process of storing the host data and the data mapping table in the pseudo single-layer storage unit, and when the storage device is powered on again, a preset value or invalid data is written in the pseudo single-layer storage unit where storage is not completed to avoid performing a garbage collection operation.
7. The storage device failure processing method according to claim 6, characterized in that: After the step of storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit, the method further comprises: When the time interval is greater than the time threshold, the host data and a data mapping table associated with the host data are stored in the block.
8. The storage device failure handling method according to claim 6, characterized in that: After the step of storing the host data and the data mapping table associated with the host data in the pseudo single-layer storage unit, the method further comprises: When the time interval is greater than the time threshold, setting the usage performance of the pseudo single-layer storage unit block to be the same as the usage performance of a multi-layer storage unit type block; The host data and a data mapping table associated with the host data are stored in the pseudo single-layer storage unit.
