A data storage method, product, device and medium based on hard disk
By switching to the target storage mode with a small storage unit layer when the solid-state drive reaches its end of life, the problem of poor stability and security of the SSD storage unit at the end of life is solved, extending the service life of the hard disk and improving data security sex.
Patent Information
- Application Number
- CN202411721810.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-28
AI Technical Summary
When the storage units of solid-state drives reach the end of their life, they lead to poor stability and security, and there is a risk of data loss.
By obtaining the current number of erases in the current storage mode of the hard disk, determining its remaining life, and when the life ends, converting the storage mode to the target storage mode. The number of storage unit layers in the target storage mode is smaller than the current mode, extending the hard disk's Service life.
It extends the usage time and value of solid-state drives as storage devices, improves storage stability and security, and avoids the risk of data loss.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a data storage method, product, device and medium based on a hard disk. Background Art
[0002] As flash memory particles in solid-state drives are updated, different numbers of storage unit layers correspond to different types of flash memory storage units.
[0003] Different types of storage units have different service lives. The larger the number of storage unit layers, the shorter its service life. For example, a storage unit that uses a triple-level cell (TLC) mode to store data is considered to have reached the end of its life after reaching the erase limit. If it continues to store data, the corresponding storage stability will be poor, and there may even be a risk of data loss, reducing data security.
[0004] Therefore, how to improve the stability and security of data storage is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0005] The purpose of the present invention is to provide a hard disk-based data storage method, product, device and medium to solve the problem of poor stability and security caused by storage at the end of the storage unit's life.
[0006] In order to solve the above technical problems, the present invention provides a data storage method based on a hard disk, comprising:
[0007] Obtaining a current number of erase / write times corresponding to a current storage mode of the hard disk; and determining a remaining life of the hard disk in the current storage mode based on the current number of erase / write times;
[0008] When the remaining life of the hard disk in the current storage mode is in the end-of-life state, determining the target storage mode according to the number of storage unit layers of the current storage mode; wherein the number of storage unit layers of the target storage mode is less than the number of storage unit layers of the current storage mode;
[0009] The current storage mode is converted into the target storage mode to store data according to the erasing and writing times of the target storage mode.
[0010] On the one hand, determining the remaining life of the hard disk in the current storage mode based on the current number of erase and write times includes:
[0011] Obtain the erase and write times threshold and hard disk health status parameters corresponding to the current storage mode;
[0012] When the health status parameter of the hard disk is characterized as an unhealthy state, the remaining life of the hard disk in the current storage mode is determined according to the relationship between the current erasure number and the erasure number threshold.
[0013] On the other hand, determining the target storage mode according to the number of storage unit layers of the current storage mode includes:
[0014] Obtaining storage unit layers corresponding to the remaining storage modes except the current storage mode, and sorting the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes;
[0015] The last storage mode in the sorted storage modes is selected as the target storage mode.
[0016] On the other hand, determining the target storage mode according to the number of storage unit layers of the current storage mode includes:
[0017] Obtaining a first remaining erasure count threshold corresponding to the current storage mode and an unhealthy state of the hard disk; wherein the unhealthy state includes a sub-healthy state and a non-sub-healthy state;
[0018] Determine the current remaining number of erasure times according to the current number of erasure times and the threshold number of erasure times;
[0019] Obtaining storage unit layers corresponding to the remaining storage modes except the current storage mode, and sorting the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes;
[0020] Determine whether the current remaining erase / write times is greater than the first remaining erase / write times threshold, and the unhealthy state of the hard disk is a sub-healthy state;
[0021] If yes, then selecting the next storage mode after the current storage mode from the sorted storage modes as the target storage mode;
[0022] If not, the last storage mode in the sorted storage modes is selected as the target storage mode.
[0023] On the other hand, converting the current storage mode to the target storage mode includes:
[0024] Acquire a system data block and a user data block of the hard disk; and reallocate the system data block and the user data block respectively;
[0025] The allocated system data block is configured with a capacity parameter of a hard disk; and a system storage space is allocated according to the capacity parameter of the hard disk; an attribute parameter of the hard disk is obtained; and the attribute parameter of the hard disk is stored in a preset storage area;
[0026] Initiate erasing storage units corresponding to the current storage mode and the target storage mode respectively;
[0027] Writing the attribute parameters of the preset storage area back to the system data area;
[0028] The simulated power-on is started, and the remaining number of erase / write times corresponding to the target storage mode is determined according to the current number of erase / write times and the critical number of erase / write times of the target storage mode, so as to complete the conversion of the target storage mode.
[0029] On the other hand, determining the remaining number of erase / write times corresponding to the target storage mode according to the current number of erase / write times and the critical number of erase / write times of the target storage mode includes:
[0030] Obtaining a critical erasure count of the target storage mode, an erasure count threshold of the current storage mode, and a current erasure count corresponding to the current storage mode corresponding to a second erasure count in the target storage mode;
[0031] Subtracting the critical erasure number of the target storage mode from the second erasure number to obtain a third erasure number;
[0032] Dividing the erasure number threshold of the current storage mode by the third erasure number to determine a first ratio;
[0033] The current erasing and writing times of the current storage mode are multiplied by the first ratio to obtain the remaining erasing and writing times corresponding to the target storage mode.
[0034] On the other hand, configuring the capacity parameters of the hard disk with the allocated system data blocks includes:
[0035] Acquire a first system capacity of the hard disk before conversion, wherein the first system capacity of the hard disk is the sum of the capacities of storage units corresponding to the target storage mode and the current storage mode respectively;
[0036] Processing the capacity of the storage unit in the current storage mode according to the number of storage unit layers in the current storage mode and the number of storage unit layers in the target storage mode in the first system capacity to determine the second system capacity of the hard disk after conversion;
[0037] Determine the second user capacity of the hard disk after conversion according to the relationship between the first user capacity of the hard disk before conversion and the actual user capacity;
[0038] Determine the size of the mapping table from the logical address to the physical address of the hard disk after conversion according to the second user capacity of the hard disk after conversion;
[0039] Determining the number of bits of the flash memory block bitmap table of the hard disk after conversion according to a previously preset number of bits of the bitmap table of the hard disk before conversion;
[0040] The second system capacity of the hard disk after conversion, the second user capacity of the hard disk after conversion, the size of the mapping table from the logical address to the physical address of the hard disk after conversion, and the number of bits of the flash memory block bitmap table of the hard disk after conversion are used as capacity parameters of the hard disk for configuration processing in the allocated system data block.
[0041] On the other hand, allocating system storage space according to the capacity parameter of the hard disk includes:
[0042] Acquire a first storage space for storing hard disk identification information corresponding to the system storage space of the hard disk after conversion; allocate the capacity parameter of the hard disk to the first storage space;
[0043] The process of determining the space size of the first storage space includes:
[0044] Obtaining the current space size of the first storage interval of the hard disk before conversion, the first system capacity of the hard disk before conversion, the second system capacity of the hard disk after conversion, and the capacity of a corresponding single storage unit in the target storage mode;
[0045] Determine the calculated space size of the first storage interval according to the current space size of the first storage interval of the hard disk before the conversion, the first system capacity of the hard disk before the conversion, the second system capacity of the hard disk after the conversion, and the corresponding single storage unit capacity in the target storage mode; obtain the data structure size in the first storage interval of the hard disk before the conversion;
[0046] Determine the critical allocation space of the first storage interval according to the data structure size and the corresponding single storage unit capacity under the target storage mode;
[0047] The space size of the first storage space is determined according to the calculated space size of the first storage interval and the critical allocated space of the first storage interval.
[0048] On the other hand, after writing the attribute parameters of the preset storage area back to the system data area and before starting the simulated power-on, the method further includes:
[0049] Initiate a simulated power-off to clear temporary data on the hard disk;
[0050] The completion flag is set to facilitate entering the step of starting the simulated power-on.
[0051] On the other hand, the power-on simulation includes:
[0052] Before the hard disk is initialized, the storage mode of the hard disk is set to the target storage mode;
[0053] Performing erase and write operations on all blocks of the hard disk in sequence;
[0054] The blocks where the erase / write operation fails are recorded and marked as bad blocks.
[0055] On the other hand, the process of determining that the remaining life of the hard disk in the current storage mode is in the end-of-life state includes:
[0056] When the current number of erasures and writes exceeds the threshold number of erasures and writes, it is determined that the remaining life of the hard disk in the current storage mode is in an end-of-life state.
[0057] On the other hand, when the remaining life of the hard disk in the current storage mode is in the end-of-life state, the method further includes:
[0058] Send warning information;
[0059] A conversion command interface is provided, and a read-only flag bit in the current storage mode is set to stop the processing of input and output commands.
[0060] In order to solve the above technical problem, the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the hard disk-based data storage method when executed by a processor.
[0061] In order to solve the above technical problems, the present invention further provides a data storage device based on a hard disk, comprising:
[0062] Memory for storing computer programs;
[0063] A processor is used to implement the steps of the hard disk-based data storage method when executing the computer program.
[0064] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the hard disk-based data storage method are implemented.
[0065] The beneficial effects of the present invention are that, on the one hand, the remaining life of the hard disk in the current storage mode is determined based on the current number of erases and writes. When the remaining life of the hard disk in the current storage mode is in the end-of-life state, that is, at the end of the life, considering that the hybrid storage of the hard disk corresponds to different storage modes in the design or application process, the number of storage unit layers smaller than the number of storage unit layers of the current storage mode is determined according to the number of storage unit layers of the current storage mode to determine the target storage mode. By determining that it can be converted to a target storage mode with a smaller number of storage unit layers when the solid-state hard disk reaches the end of its life, the life cycle is extended. The higher the number of storage unit layers, the smaller the corresponding service life. When the corresponding service life in the storage mode with a higher number of storage unit layers reaches the life limit, there is still a certain life in the storage mode correspondingly mapped to the storage mode with a smaller number of storage unit layers, and the life limit of the storage mode with a smaller number of storage unit layers has not been reached. Therefore, when the end-of-life period in the current storage mode is reached, the current storage mode is not continued to be used, but a target storage mode with a smaller number of storage unit layers than the current storage mode is determined. On the other hand, the current storage mode is converted to the target storage mode to map the remaining life of the hard disk in the current storage mode to the life in the target storage mode to continue data storage, thereby extending the use time and value of the hard disk as a storage device, restoring the corresponding storage function, improving storage stability and security, and avoiding the risk of data loss.
[0066] Secondly, when the hard disk is in an unhealthy state, the remaining life of the hard disk in the current storage mode is determined based on the relationship between the current number of erases and writes and the erase number threshold, and the accuracy of the remaining life determination process is improved through reference to different parameters. By selecting the last storage mode as the target storage mode in the sorted storage mode, the use time and use value of the solid-state hard disk as a storage device can be extended to a greater extent. Based on the comparison of the two parameters of the unhealthy state of the hard disk and the remaining number of erases and writes as reference data, the target storage mode is selected in the sorted storage mode, and the writing speed of the writing scene is considered, which also takes into account the extension of the use time of the storage device, and the writing speed is improved. Before simulating power-on, simulate power-off is performed first to clear the temporary data of the hard disk. At the same time, a flag is set to notify the simulated power-on of the power-on recovery action, improve the accuracy of the simulated power-on time, and ensure the cleanliness of the hard disk before the simulated power-on. The initialization process of simulated power-on ensures that the conversion mark corresponding to the target storage mode and the bad block scanning mark step are operated normally before the real storage function is performed. The conversion process of converting the current storage mode to the target storage mode makes it possible to convert to the target storage mode at the end of its life, extend the use time and value of the storage device, and allocate and store system data, user data, capacity parameters of the hard disk, attribute parameters, etc. to ensure the accuracy of the operation state of the disk corresponding to the converted target storage mode. The process of determining the remaining number of erase and write times corresponding to the converted target storage mode is based on the fact that when the number of erase and write times of the storage unit of the current storage mode reaches the upper limit and enters the end of its life, the number of erase and write times recalculated after switching is calculated through the conversion process to ensure the normal operation of the number of erase and write times in the target storage mode. The process of determining the recalculation of system configuration data is to facilitate configuration processing according to the current system configuration data in the allocated system data block, pre-calculate, save calculation time in subsequent storage processes, and improve storage efficiency. The process of determining the size of the first storage space is to facilitate allocating the capacity parameters of the hard disk to the first storage space. By calculating the size of the first storage space, the maximum value is selected from the calculation space size and the critical allocation space to ensure that there is enough storage space to store the capacity parameters of the hard disk. The corresponding operation process of the host is to start the conversion process and lock the solid-state hard disk, which corresponds to the preparatory work before the conversion process to ensure that the conversion of the storage mode is completed smoothly.
[0067] In addition, the present invention also provides a computer program product, a device and a medium, which have the same beneficial effects as the above-mentioned hard disk-based data storage method. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0069] Figure 1 A flowchart of a hard disk-based data storage method provided by an embodiment of the present invention;
[0070] Figure 2 A schematic diagram of a hard disk storage unit distribution provided by an embodiment of the present invention;
[0071] Figure 3 A schematic diagram of a storage mode conversion process provided by an embodiment of the present invention;
[0072] Figure 4 A structural diagram of a hard disk-based data storage device provided by an embodiment of the present invention;
[0073] Figure 5 A structural diagram of a hard disk-based data storage device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0075] The core of the present invention is to provide a hard disk-based data storage method, product, device and medium to solve the problem of poor stability and security caused by storage at the end of the storage unit's life.
[0076] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0077] Solid-state drives are hard drives made of solid-state electronic memory arrays. They usually consist of three major parts, namely the solid-state drive (SSD) controller, the flash memory array that stores data, and the cache. They are one of the key components of modern computer storage systems. Compared with traditional mechanical hard drives, solid-state drives based on non-volatile flash memory (NAND) provide faster read and write speeds and lower read and write delays, especially with the replacement of flash memory particles, from single-level cells (SLC), double-level cells (MLC) to TLC (triple-level cells), and quad-level cells (QLC), the cost per bit is getting lower and lower. However, NAND flash memory has an obvious limitation, that is, each storage unit needs to be erased before writing new data, and the number of erase cycles of each physical block is limited. For each additional bit of storage, the number of erase cycles that the storage unit can withstand is reduced by an order of magnitude. For example, SLC flash memory only stores one bit in a cell, and the corresponding SLC storage unit can have a service life of more than 10,000 times; TLC flash memory can store three bits in a cell, and the service life of a TLC storage unit is only about 1,000 times. If the storage unit continues to be used in TLC mode after reaching the erase limit, the stability will be greatly reduced, and there may even be a risk of data loss. As a storage device with high security requirements, the SSD will be considered to have reached the end of its life and cannot be used any longer, resulting in a waste of resources.
[0078] Currently, there are two common ways to extend the life of a hard disk. One is to reduce the number of erasures of a single storage unit through capacity redundancy, wear leveling and other methods, but these methods can only extend the life cycle of the entire SSD by minimizing the waste of the service life of each storage unit; the other is to allocate fixed storage units to store data that needs to be updated frequently in SLC storage mode by utilizing the characteristic differences between SLC and TLC. However, most storage units still operate according to the highest storage bit number. In this case, the judgment of the life cycle of the disk still depends on the use of the TLC storage unit. The data storage method based on a hard disk provided by the present invention can solve the above technical problems.
[0079] Figure 1 A flowchart of a hard disk-based data storage method provided by an embodiment of the present invention, such as Figure 1 As shown, the method includes:
[0080] S11: Obtaining the current number of erasures and writes corresponding to the current storage mode of the hard disk; and determining the remaining life of the hard disk in the current storage mode based on the current number of erasures and writes;
[0081] S12: when the remaining life of the hard disk in the current storage mode is in the end-of-life state, determining the target storage mode according to the number of storage unit layers in the current storage mode;
[0082] The number of storage unit layers of the target storage mode is less than the number of storage unit layers of the current storage mode;
[0083] S13: Convert the current storage mode to the target storage mode to store data according to the number of erase and write times of the target storage mode.
[0084] Specifically, the storage mode of the hard disk, as mentioned in the previous paragraph, corresponds to multiple storage modes, which can be single-layer storage unit (SLC), double-layer storage unit (MLC) to triple-layer storage unit (TLC), quadruple-layer storage unit (QLC), etc. There will be multiple hybrid storage modes in the storage mode of the hard disk, two or more situations, which are not limited here. The current storage mode of the hard disk in this embodiment can be any one of the hybrid storage modes. It should be noted that there are two application scenarios in this embodiment. One is the multiple storage modes that have been stored in the storage system, that is, the products after leaving the factory. The other is that in the research and development or testing stage, the manufacturer conducts tests based on different storage modes to facilitate the pre-installation of hybrid storage modes based on subsequent test results. The above two scenarios are applicable.
[0085] Combined with the first application scenario, in the actual use process of the user, in order to increase the write rate, a storage mode with more storage unit layers will be used for the user, such as three-layer storage unit (TLC) or four-layer storage unit (QLC). In this embodiment, according to the current write count corresponding to the current storage mode, the current write count here is the write count corresponding to the data storage performed in the current storage mode. It can be understood that the hard disk will correspond to a variety of hybrid storage modes, and system data (such as metadata, etc.) may be saved in the remaining storage modes except the current storage mode, which is not available for user use. Combined with the second application scenario, in the actual test process, the current erase and write count of the current storage mode under test is determined.
[0086] Based on the current number of erase and write times, the remaining life of the hard disk in the current storage mode is determined. It should be noted here that the life status of the hard disk can not only be reflected by the number of erase and write times, but also its health can be judged by the operation status of the hard disk, the statistics of the amount of read and write data, the NAND consumption, the error records and the number statistics, or the percentage of use, etc. On this basis, if it is determined by other parameters that the remaining life of the hard disk in the current storage mode has reached the limit, this embodiment mainly solves the end of life caused by the number of erase and write times reaching the upper limit, so it is necessary to compare the current number of erase and write times with a certain threshold relationship to determine whether the end of life is caused by the number of erase and write times reaching the upper limit.
[0087] In step S12, when the remaining life of the hard disk in the current storage mode is in the end-of-life state (End Of Life, EOL), it is necessary to determine the target storage mode according to the number of storage unit layers of the current storage mode. First, how to be in the end-of-life state can be compared by comparing the remaining life with a certain threshold. Since this embodiment only focuses on the number of erases and writes of the storage mode, when the number of erases and writes corresponding to the remaining life reaches a certain threshold, it represents the end-of-life state. The end-of-life state can also be judged based on the combination of the erase number parameter and other parameters (such as the total write capacity, the daily write volume of the disk, etc.), which are all possible and are not limited here. Regarding the end-of-life state, it is actually the end of the life, and writing can continue, but there is a risk of data loss when writing based on the current storage mode, and the security is poor. Therefore, at this time, it is necessary to determine the target storage mode according to the number of storage unit layers of the current storage mode.
[0088] In combination with the first scenario described above, among the multiple storage modes pre-stored in the hard disk, a storage unit layer number lower than the storage unit layer number of the current storage mode is selected from the multiple storage modes, so that the storage mode corresponding to the selected storage unit layer number is used as the target storage mode. If there are only two storage modes (TLC and MLC) in the hard disk, and the current storage mode is TLC, the corresponding target storage mode is MLC. If there are more than two storage modes in the hard disk, it is necessary to select according to the current storage mode and the remaining storage modes. It can be done in one step to directly determine the storage mode with the least number of storage unit layers as the target storage mode. It can also be set through the application scenario. If a higher write rate is required, only the storage mode with the number of storage unit layers smaller than the current storage mode can be used as the target storage mode. When the remaining life determined by the number of erases and writes corresponding to the selected target storage mode is in the end-of-life state, the action of step S12 can be continued until the remaining life of the storage mode with the least number of storage unit layers is in the end-of-life state, and the storage mode conversion is stopped. At present, the premise of the current storage mode here is not the storage mode with the least number of storage unit layers, so that a storage mode with a smaller number of storage unit layers than the current storage mode can be found during the determination process.
[0089] If the manufacturer determines which storage mode to use as the storage mode of the subsequent storage system during the installation test, it is necessary to determine the target storage mode in the storage mode with a smaller number of storage unit layers than the current storage mode. At the same time, the test is combined with the task requirements that may be encountered in the storage system to select the corresponding target storage mode. It is also possible to first select the storage mode corresponding to the number of storage unit layers that is one level smaller than the number of storage unit layers of the current storage mode as the target storage mode through the implementation example in the previous paragraph, and then test it step by step. It is also possible to use the storage unit layers that are smaller than the number of storage unit layers of the current storage mode as the target storage mode and convert them one by one. Such parallel operations can be used to view the storage effect and life span corresponding to the test, and finally the target storage mode with better effect and the current storage mode are used as the pre-installed storage mode of the subsequent storage system.
[0090] In step S13, based on the determined target storage mode, the current storage mode is converted to the target storage mode. The conversion process here needs to take into account the calculation of capacity, the reallocation of the user data space and the system data space corresponding to the storage space, and the conversion of the corresponding erase and write times during the conversion process. It should be noted that the conversion process of the erase and write times in this embodiment is based on the erase and write times of the current storage mode that have been used, and how many erase and write times can be used for data storage under the converted target storage mode. The specific conversion process needs to map and determine the erase and write times between the current storage mode and the target storage mode. This embodiment does not make specific restrictions and can be set according to actual conditions.
[0091] An embodiment of the present invention provides a data storage method based on a hard disk, which obtains the current number of erasures and writes corresponding to the current storage mode of the hard disk; and determines the remaining life of the hard disk in the current storage mode based on the current number of erasures and writes; when the remaining life of the hard disk in the current storage mode is in the end-of-life state, determines the target storage mode according to the number of storage unit layers of the current storage mode; wherein the number of storage unit layers of the target storage mode is less than the number of storage unit layers of the current storage mode; and converts the current storage mode to the target storage mode to store data according to the number of erasures and writes of the target storage mode. On the one hand, the remaining life of the hard disk in the current storage mode is determined based on the current number of erasures and writes. When the remaining life of the hard disk in the current storage mode is in the end-of-life state, that is, at the end of life, considering that the hybrid storage of the hard disk corresponds to different storage modes during the design or application process, the number of storage unit layers smaller than the number of storage unit layers of the current storage mode is determined according to the number of storage unit layers of the current storage mode to determine the target storage mode. By determining that the target storage mode with a smaller number of storage unit layers can be converted to when the solid-state hard disk reaches the end of its life, the life cycle can be extended. The higher the number of storage unit layers, the shorter the corresponding service life. When the corresponding service life in the storage mode with a higher number of storage unit layers reaches the life limit, the corresponding storage mode mapped to the storage mode with a smaller number of storage unit layers still has a certain life, and the life limit of the storage mode with a smaller number of storage unit layers has not been reached. Therefore, when the end of the life in the current storage mode is reached, the current storage mode is not continued to be used, but a target storage mode with a smaller number of storage unit layers than the current storage mode is determined. On the other hand, the current storage mode is converted to the target storage mode to continue data storage corresponding to the remaining life of the hard disk in the current storage mode mapped to the life in the target storage mode, thereby extending the use time and use value of the hard disk as a storage device, restoring the corresponding storage function, improving the stability and security of storage, and avoiding the risk of data loss.
[0092] In some embodiments, determining the remaining life of the hard disk in the current storage mode based on the current number of erase and write times includes:
[0093] Get the corresponding erase / write times threshold and hard disk health status parameters under the current storage mode;
[0094] When the health status parameter of the hard disk indicates an unhealthy state, the remaining life of the hard disk in the current storage mode is determined according to the relationship between the current erase and write times and the erase and write times threshold.
[0095] Specifically, the threshold value of the number of erase and write times corresponding to the current storage mode is here to ensure the upper limit of the number of erase and write times of the current storage mode. The health status parameter of the hard disk corresponds to the current state of the hard disk in an unhealthy state or a healthy state. When the life reaches a certain period, its corresponding health status parameter is also a certain guaranteed parameter. Therefore, when the health status parameter of the hard disk is characterized as an unhealthy state, the remaining life of the hard disk in the current storage mode is determined according to the relationship between the current number of erase and write times and the threshold value of the number of erase and write times. It should be noted that the determination of the health status parameter of the hard disk can be determined based on the other parameter information of the hard disk. The specific determination process can be based on the different parameters reaching the corresponding thresholds as the basis for determination. It can also be that most of the parameters of the different parameters reach the corresponding thresholds as the basis for determination. The corresponding health status parameters can also be determined by the weight coefficient, which is not limited here and can be set according to actual conditions.
[0096] This embodiment provides a method for determining the remaining life of the hard disk in the current storage mode based on the relationship between the current number of erase and write times and an erase and write time threshold when the hard disk is in an unhealthy state, and improves the accuracy of the remaining life determination process by referring to different parameters.
[0097] In some embodiments, the process of determining that the remaining life of the hard disk in the current storage mode is in the end-of-life state includes:
[0098] When the current number of erase and write times exceeds the erase and write times threshold, it is determined that the remaining life of the hard disk in the current storage mode is in a life-end state.
[0099] Specifically, when the current number of erasures exceeds the erasure threshold, it is determined that the remaining life of the hard disk in the current storage mode is in an end-of-life state.
[0100] This embodiment provides a method for determining the end-of-life state when the current number of erase and write times exceeds a threshold number of erase and write times, thereby simplifying the determination process and improving the efficiency of determining the end-of-life state.
[0101] In some embodiments, determining the target storage mode according to the number of storage unit layers of the current storage mode includes:
[0102] Obtain storage unit layers corresponding to the remaining storage modes except the current storage mode, and sort the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes;
[0103] The last storage mode among the sorted storage modes is selected as the target storage mode.
[0104] It should be noted that the target storage mode is determined according to the number of storage unit layers of the current storage mode, and here it is necessary to obtain the storage unit layers corresponding to the remaining storage modes. Combining the above different scenarios, one is to obtain the remaining storage modes under the storage system in the hard disk to which the current storage mode belongs, and the other is to obtain the remaining storage modes except the current storage mode in all existing storage modes. Sort the number of storage unit layers of each storage mode in order from large to small to obtain the sorted storage mode, and select the last storage mode in the sorted storage mode as the target storage mode in a one-step manner.
[0105] In this embodiment, the last storage mode is selected as the target storage mode from the sorted storage modes, so that the use time and use value of the solid state drive as a storage device can be extended to a greater extent.
[0106] In some other embodiments, determining the target storage mode according to the number of storage unit layers of the current storage mode includes:
[0107] Obtaining a first remaining erase / write times threshold value corresponding to the current storage mode and an unhealthy state of the hard disk; wherein the unhealthy state includes a sub-healthy state and a non-sub-healthy state;
[0108] Determine the current remaining number of erase times according to the current number of erase times and the erase times threshold;
[0109] Obtain storage unit layers corresponding to the remaining storage modes except the current storage mode, and sort the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes;
[0110] Determine whether the current remaining erase / write times is greater than a first remaining erase / write times threshold, and the unhealthy state of the hard disk is a sub-healthy state;
[0111] If yes, then select the next storage mode after the current storage mode in the sorted storage modes as the target storage mode;
[0112] If not, the last storage mode in the sorted storage modes is selected as the target storage mode.
[0113] Specifically, in addition to considering extending the usage time of the storage device at the end of its life, the write speed also needs to be considered. Therefore, the first remaining erase and write times threshold and the unhealthy state of the hard disk corresponding to the current storage mode are obtained. It should be noted here that the unhealthy state of the hard disk includes a sub-healthy state and a non-sub-healthy state. The sub-healthy state is an intermediate state in which a certain amount of data is allowed to be written when the hard disk reaches the end of its life. The non-sub-healthy state is a hard disk state in which subsequent data cannot be written when the hard disk reaches the end of its life. The first remaining erase and write times threshold corresponds to the threshold range under the remaining erase and write times.
[0114] The current remaining number of erase and write times is determined according to the current number of erase and write times and the erase and write times threshold, where the current remaining number of erase and write times is obtained by subtracting the current number of erase and write times from the erase and write times threshold. The sorted storage mode is determined by sorting the number of storage unit layers in order from large to small. When the current remaining number of erase and write times is greater than the first remaining number of erase and write times threshold, and the unhealthy state of the hard disk is a sub-healthy state, it means that the use time of the storage device can also be extended while taking into account the write speed. Therefore, in the sorted storage mode, the next storage mode after the current storage mode is selected as the target storage mode. If the current remaining number of erase and write times is less than or equal to the first remaining number of erase and write times threshold, or if the unhealthy state of the hard disk is a non-sub-healthy state, only extending the use time of the storage device can be considered, so the last storage mode is selected as the target storage mode in the sorted storage mode.
[0115] This embodiment provides two parameters based on the unhealthy state of the hard disk and the remaining number of erase and write times as reference data for comparison, and selects a target storage mode from the sorted storage modes, taking into account the writing speed of the writing scenario, thereby improving the writing speed while extending the use time of the storage device.
[0116] In some embodiments, converting the current storage mode to the target storage mode includes:
[0117] Obtaining the system data blocks and user data blocks of the hard disk; reallocating the system data blocks and user data blocks respectively;
[0118] The allocated system data blocks are configured with capacity parameters of the hard disk; and system storage space is allocated according to the capacity parameters of the hard disk; attribute parameters of the hard disk are obtained; and the attribute parameters of the hard disk are stored in a preset storage area;
[0119] Start erasing the storage units corresponding to the current storage mode and the target storage mode respectively;
[0120] Write the attribute parameters of the preset storage area back to the system data area;
[0121] Start the simulated power-on, and determine the remaining erase / write times corresponding to the target storage mode according to the current erase / write times and the critical erase / write times of the target storage mode, so as to complete the conversion of the target storage mode.
[0122] Specifically, during the conversion process, the storage location and space size of the data required for the operation of the solid-state drive stored in the flash memory of the remaining storage modes need to be reallocated in the new target storage mode. The reallocation process includes the allocation of system data blocks and user data blocks as well as hard disk capacity parameters and attribute parameters. Perform erase and simulate power-off operations. Simulate the first power-on operation to retrieve and restore the key data that needs to be stored in the flash memory.
[0123] During the reallocation process, it is necessary to reallocate system data blocks and user data blocks, recalculate system configuration data, and reallocate system data area space and attribute parameters.
[0124] The allocated system data blocks are configured with the capacity parameters of the hard disk, the capacity change of the current disk is calculated, and the system data area size is reallocated to the storage space. The attribute parameters of the hard disk, including the partition disk inherent data, inheritable data and recalculated data, are stored in the preset storage area, so that the attribute parameters of the preset storage area can be read back after subsequent conversion.
[0125] Start the erasing process, and perform the erasing operation on each storage unit according to the corresponding storage mode, that is, the storage unit corresponding to each storage mode is erased according to the storage mode to which it belongs, to ensure that all storage units are completely erased, so as to achieve permanent deletion of data in the hard disk flash memory. After erasing, write the attribute parameters of the preset storage area back to the system data area. Start the simulated power-on, and recalculate the number of erase and write times for storing user data in the target storage mode. The calculation process needs to determine the remaining erase and write times corresponding to the target storage mode based on the current erase and write times in the current storage mode and the critical erase and write times of the target storage mode, and perform subsequent data erase based on the remaining erase and write times of the target storage mode, and then the conversion of the target storage mode is completed.
[0126] In some embodiments, after writing the attribute parameters of the preset storage area back to the system data area and before starting the simulated power-on, the method further includes:
[0127] Start a simulated power-off to clear temporary data on the hard disk;
[0128] Set the completion flag to facilitate the process of starting the simulated power-on.
[0129] Specifically, before starting the simulated power-on, first simulate the normal power-off process, mainly clear all temporary data, and set the completion flag to start the subsequent simulated power-on.
[0130] Before the simulated power-on provided in this embodiment, a simulated power-off is performed to clear temporary data on the hard disk. At the same time, a flag is set to notify the simulated power-on of the power-on recovery action, thereby improving the accuracy of the simulated power-on time and ensuring the cleanliness of the hard disk before the simulated power-on.
[0131] In some implementations, simulating power-on includes:
[0132] Before initializing the hard disk, set the storage mode of the hard disk to the target storage mode;
[0133] Perform erase and write operations on all blocks of the hard disk in sequence;
[0134] The blocks where the erase / write operation fails are recorded and marked as bad blocks.
[0135] Specifically, before the hard disk is initialized, the storage mode of the hard disk needs to be set to the target storage mode, and erase, read, and write operations are performed on all blocks of the hard disk in sequence, and the blocks that fail the operation are marked as bad blocks, so as to perform a normal simulated power-on process.
[0136] The simulated power-on initialization process provided in this embodiment ensures that the conversion mark corresponding to the target storage mode and the bad block scanning mark steps operate normally before the actual storage function is performed.
[0137] The conversion process for converting the current storage mode to the target storage mode provided in this embodiment enables conversion to the target storage mode at the end of its life, thereby extending the service life and use value of the storage device. At the same time, system data, user data, capacity parameters, attribute parameters, etc. of the hard disk are allocated and stored to ensure the accuracy of the operating status of the disk corresponding to the converted target storage mode.
[0138] In some embodiments, determining the remaining number of erase / write times corresponding to the target storage mode according to the current number of erase / write times and the critical number of erase / write times of the target storage mode includes:
[0139] Obtaining the critical erasure times of the target storage mode, the erasure times threshold of the current storage mode, and the current erasure times corresponding to the current storage mode corresponding to the second erasure times in the target storage mode;
[0140] Subtracting the critical erasure number of the target storage mode from the second erasure number to obtain a third erasure number;
[0141] Dividing the erasure number threshold of the current storage mode by the third erasure number to determine a first ratio;
[0142] The current erasing and writing times of the current storage mode are multiplied by the first ratio to obtain the remaining erasing and writing times corresponding to the target storage mode.
[0143] Specifically, the critical erasure times of the target storage mode are obtained, the erasure times threshold of the current storage mode and the current erasure times are mapped to the second erasure times of the target storage mode. The proportional coefficient of the mapping relationship here can be set according to actual conditions or calculated, and is not limited here.
[0144] Subtract the critical erase number from the second erase number to obtain the third erase number, divide the erase number threshold of the current storage mode by the third erase number to determine the first ratio; multiply the current erase number of the current storage mode by the first ratio to obtain the remaining erase number corresponding to the target storage mode.
[0145] The specific formula is as follows:
[0146] ;
[0147] Among them, P T is the erasure number threshold of the current storage mode, Ps is the critical erasure number of the target storage mode; P0 is the erasure number of the current storage mode that can still ensure data accuracy after the current erasure number reaches the erasure number threshold and switches to the target storage mode, that is, the current erasure number corresponding to the current storage mode corresponds to the second erasure number under the target storage mode; the third erasure number is Ps-P0, and the first ratio is , P1 is the current erase and write count of the current storage mode, and PE is the remaining erase and write count corresponding to the target storage mode.
[0148] The present embodiment provides a process for determining the remaining number of erase and write times corresponding to the converted target storage mode. When the number of erase and write times of the storage unit in the current storage mode reaches an upper limit and reaches the end of its life, the number of erase and write times after switching is calculated through a conversion process to ensure the normal operation of the erase and write times in the target storage mode.
[0149] In some embodiments, configuring the capacity parameters of the hard disk with the allocated system data blocks includes:
[0150] Acquire a first system capacity of the hard disk before conversion, wherein the first system capacity of the hard disk is the sum of the capacities of storage units corresponding to the target storage mode and the current storage mode respectively;
[0151] Processing the capacity of the storage unit in the current storage mode according to the number of storage unit layers in the current storage mode and the number of storage unit layers in the target storage mode in the first system capacity to determine the second system capacity of the hard disk after conversion;
[0152] Determine the second user capacity of the hard disk after conversion according to the relationship between the first user capacity of the hard disk before conversion and the actual user capacity;
[0153] Determine the size of the mapping table from the logical address to the physical address of the hard disk after conversion according to the second user capacity of the hard disk after conversion;
[0154] Determine the number of bits of the flash memory block bitmap table of the hard disk after conversion according to the previously preset number of bits of the bitmap table of the hard disk before conversion;
[0155] The second system capacity of the converted hard disk, the second user capacity of the converted hard disk, the size of the mapping table from the logical address to the physical address of the converted hard disk, and the number of bits of the flash block bitmap table of the converted hard disk are used as capacity parameters of the hard disk for configuration processing in the allocated system data block.
[0156] Specifically, the first system capacity of the hard disk before conversion, that is, the first system capacity of the hard disk corresponding to the current storage mode, is the sum of the capacities of the storage units corresponding to the target storage mode and the current storage mode, respectively. The TLC storage mode is used as the current storage mode, and the SLC storage mode is used as the target storage mode. The first system capacity of the hard disk before conversion = the total capacity of the SLC storage unit + the total capacity of the TLC storage unit. The capacity of the storage unit in the current storage mode is processed according to the number of storage unit layers in the current storage mode and the number of storage unit layers in the target storage mode in the first system capacity to obtain the second system capacity of the hard disk after conversion. Taking the SLC storage mode and the TLC storage mode as examples, the solid-state hard disk uses TLC flash memory particles to greatly increase the amount of stored data and reduce the unit bit cost. However, in this case, the life cycle of the solid-state hard disk is subject to the number of erases and writes of the TLC flash memory particles. Therefore, the solid-state hard disk that reaches the EOL state due to the life of the TLC flash memory is reused. The solid-state hard disk that uses TLC as the main working mode and reaches the end of its life due to the number of erases of the TLC flash memory is reset to the SLC mode. The second system capacity of the hard disk after conversion = total capacity of SLC storage units + total capacity of TLC storage units / 3. It should be noted that the 3 here is based on the storage characteristics of TLC storage units and SLC storage units. After conversion, the capacity of TLC storage units is 1 / 3 of the original.
[0157] The system capacity of the hard disk is composed of TLC storage units and SLC storage units. The capacity of the SLC storage unit corresponds to the system capacity, and the capacity of the TLC storage unit corresponds to the user capacity. Figure 2 A schematic diagram of a hard disk storage unit distribution provided by an embodiment of the present invention, such as Figure 2 As shown in the figure, there are non-volatile memory (NOR Flash), single-layer storage cell (SLC) and triple-layer storage cell (TLC). Non-volatile memory (NOR Flash) is used to store important system data that does not need to be updated frequently, such as bad block table, PE table, etc. Single-layer storage cell (SLC) is used to store system data that needs to be updated frequently, that is, metadata, such as identify data, superblock data, smart log data, etc. Triple-layer storage cell (TLC) is used to store user data, that is, storage space provided to users.
[0158] The first user capacity of the hard disk before conversion, taking TLC and SLC storage modes as an example, that is, the user capacity before conversion = the total capacity of the TLC storage unit; the second user capacity of the hard disk after conversion = the total capacity of the TLC storage unit / 4. It should be noted that the 4 here is based on the fact that the user capacity provided by the solid-state drive is generally a power of 2, such as 2T, 4T, 8T, etc., and the minimum value greater than 3 is taken, that is, 4.
[0159] The size of the logical to physical mapping table (L2P) of the hard disk after conversion is determined according to the second user capacity of the hard disk after conversion, that is, the size of the L2P table after conversion = the user capacity after conversion / 4KB = the size of the L2P table before conversion / 4. The size of the L2P table is directly related to the storage capacity, so the 4 here also has a corresponding modification.
[0160] The number of bits in the flash block bitmap table of the hard disk after conversion is determined according to the preset number of bits in the bitmap table of the hard disk before conversion, that is, the number of bits in the valid flash page bitmap table of the flash block after conversion = ((number of bits before conversion / 4+31) / 32)*32.
[0161] The determination process of recalculating system configuration data provided in this embodiment facilitates configuration processing according to current system configuration data in the allocated system data block, pre-calculates, saves calculation time in subsequent storage processes, and improves storage efficiency.
[0162] In some embodiments, allocating system storage space according to the capacity parameter of the hard disk includes:
[0163] Acquire a first storage space for storing hard disk identification information corresponding to the system storage space of the converted hard disk; allocate the capacity parameter of the hard disk to the first storage space;
[0164] The process of determining the space size of the first storage space includes:
[0165] Obtain the current space size of the first storage interval of the hard disk before conversion, the first system capacity of the hard disk before conversion, the second system capacity of the hard disk after conversion, and the corresponding single storage unit capacity in the target storage mode;
[0166] Determine the calculated space size of the first storage interval according to the current space size of the first storage interval of the hard disk before conversion, the first system capacity of the hard disk before conversion, the second system capacity of the hard disk after conversion, and the corresponding single storage unit capacity in the target storage mode;
[0167] Obtain the size of the data structure in the first storage interval of the hard disk before conversion;
[0168] Determine the critical allocation space of the first storage interval according to the data structure size and the corresponding single storage unit capacity under the target storage mode;
[0169] The space size of the first storage space is determined according to the calculated space size of the first storage interval and the critical allocated space of the first storage interval.
[0170] Specifically, the capacity transformation of the current disk is calculated, and the system data area (first storage space) is reallocated according to the capacity of the solid state hard disk after conversion and the size of each system data area. Taking the Identify data area (identification data area) as an example, the space size of the first storage space is determined as follows: the calculated space size of the first storage interval is obtained by multiplying the current space size of the first storage interval of the hard disk before conversion by the first system capacity of the hard disk before conversion, dividing it by the second system capacity of the hard disk after conversion, and then adding it to the capacity of a single storage unit in the target storage mode and subtracting 1. The resulting data is divided by the capacity of a single storage unit in the target storage mode. The formula is: Identify data area calculation space = ((Identify information area current space * SSD capacity after conversion) / SSD capacity before conversion + SLC single storage unit capacity – 1) / SLC single storage unit capacity.
[0171] The process of determining the critical allocation space of the first storage area is based on the sum of the data structure size in the first storage interval of the hard disk before conversion and the capacity of a single storage unit in the target storage mode, subtracting 1 and dividing the resulting data by the capacity of a single storage unit in the target storage mode, that is, the formula is: Identify data area minimum allocation space = (Identify data structure size + SLC single storage unit capacity – 1) / SLC single storage unit capacity.
[0172] The space size of the first storage space is determined according to the calculated space size of the first storage interval and the critical allocated space of the first storage interval. By comparing the sizes of the two data, the largest data is selected as the space size of the first storage space. That is, the formula is: Identify data area allocated space = max (Identify data area calculated space, Identify data area minimum allocated space).
[0173] In addition, other data areas corresponding to the first storage space are also applicable, such as a superblock data area (superblock data area) and the like.
[0174] The present embodiment provides a process for determining the size of the first storage space so as to allocate the capacity parameters of the hard disk to the first storage space. By calculating the size of the first storage space and selecting the maximum value between the calculated space size and the critical allocated space, it is ensured that there is sufficient storage space to store the capacity parameters of the hard disk.
[0175] In some embodiments, the attribute parameters corresponding to the hard disk at least include the partition disk inherent data, inheritable data and recalculated data; the storage process of the attribute parameters of the hard disk includes:
[0176] Read the partition disk's inherent data and inheritable data from the system data area;
[0177] The read partition disk inherent data, inheritable data and recalculated data are saved to a preset storage area so as to be written to the corresponding system data area in the converted target storage mode after simulated power-on.
[0178] Specifically, the inherent data of the partitioned disk includes important product data and other data that remain unchanged before and after the conversion; the inheritable data includes smart log (log of self-monitoring, analysis and reporting technology), default feature value (characteristic value) and other data that can be directly inherited and used before and after the conversion; the recalculated data includes PE table, L2P table and other data that are closely related to the capacity of the solid-state drive and must be recalculated after the conversion.
[0179] The present embodiment provides for temporarily storing the attribute parameters of the hard disk in a preset storage area, so as to facilitate rewriting after subsequent simulated power-on, thereby ensuring that the operating state of the hard disk in the converted target storage mode is correct.
[0180] In some embodiments, when the remaining life of the hard disk in the current storage mode is in the end-of-life state, the method further includes:
[0181] Send warning information;
[0182] Provides a conversion command interface and sets the read-only flag in the current storage mode to stop the processing of input and output commands.
[0183] Figure 3 A schematic diagram of a storage mode conversion process provided by an embodiment of the present invention, such as Figure 3 As shown, first determine the operating status of the SSD and the cause of EOL. If it meets the prerequisite of converting to SLC storage mode to extend the service life, reallocate the storage space of the data currently stored in the SLC NAND area, and erase all data in the NAND flash. After power-on, use it as a new SLC SSD, reacquire the necessary data and store it in the newly allocated storage unit. It includes five modules, namely conversion process control module, life monitoring module, data reallocation module, power-off erase module and power-on recovery module.
[0184] Conversion process control module: interacts with users and other modules, records the conversion process status, and controls the entire TLC to SLC SSD conversion process.
[0185] Life monitoring module: By monitoring the hard disk operation status, determine whether the hard disk has reached the EOL state and determine the cause of the EOL state.
[0186] Data reallocation module: after entering the conversion process, reallocates the storage location and space size of the data stored in the SLC flash memory necessary for the operation of the solid-state drive in the new storage mode.
[0187] Power-off erase module: performs erase and simulates power-off operations.
[0188] Power-on recovery module: simulates the first power-on operation, re-acquires and recovers the key data that needs to be stored in the flash memory.
[0189] A complete process of converting a TLC SSD that has entered EOL status to an SLC SSD to restore its storage function.
[0190] The life monitoring module monitors the operating status of the SSD in real time, and determines the remaining life and health of the hard disk in TLC mode of the SSD through statistics on the amount of read and write data, NAND consumption, error records and number statistics, and percentage of use. If it is detected that the SSD enters the EOL state because the number of erase and write times of the TLC storage unit has reached the upper limit, the process control module is notified.
[0191] After receiving the notification from the life monitoring module, the process control module first sends an alarm message to the host, notifying that the current SSD has reached the end of its life and cannot be used in the current way, and provides a conversion command interface for the host to actively start the conversion process. At the same time, the read-only flag is set to stop all input and output (IO) command processing.
[0192] If a conversion command is received from the host, the SLC conversion process is started, first the SSD is locked, and all operations on the SSD flash memory are prohibited except for the conversion-related modules, and all host commands are blocked. Then the data reallocation module is notified.
[0193] In this embodiment, when the remaining life of the hard disk in the current storage mode is in the end-of-life state, an alarm message is sent to the host, and the current storage mode cannot be used any longer. It is necessary to provide a conversion command interface. When the disk reaches the end of its life, it is not considered. The other is that the conversion process operates the NAND flash memory, which is used by the host to actively start the conversion process, set the read-only flag, ensure that the disk is read-only, and stop IO command processing at the same time.
[0194] The operation process corresponding to the host provided in this embodiment is to start the conversion process and lock the solid-state hard disk, which corresponds to the preparatory work before the conversion process to ensure that the conversion of the storage mode is completed smoothly.
[0195] In the subsequent data reallocation module, corresponding to the reallocation of system data blocks and user data blocks, the bad block table and PE table are scanned to obtain all currently available data blocks, and the continuous available data block area is sorted out as the system data block candidate area. According to the garbage collection scheme, wear leveling algorithm and user type, the system data block allocation ratio is calculated, and the system data block retention frequency is determined to ensure that the system data blocks and user data blocks reach the end of life at the same time to reduce resource waste. Allocate system data blocks and user data blocks and keep records.
[0196] Recalculate system configuration data, reallocate system data area space, and divide disk-specific data, inheritable data, and recalculate data.
[0197] The process control module notifies the power-off erase module, and the power-off erase module performs the following actions:
[0198] a. Start the erasing process and perform the erasing operation on each storage unit according to its corresponding operation mode, that is, the TLC storage unit is erased in TLC mode, and the SLC storage unit is erased in SLC mode, ensuring that all storage units are completely erased, realizing permanent deletion of data in the SSD flash memory, and erasing the bad block table.
[0199] b. Write inherent data and inheritable data back to the system data area.
[0200] c. Simulate a normal power-off process, including clearing all temporary data.
[0201] d. Set the completion flag and notify the process control module.
[0202] The process control module notifies the power-on recovery module to simulate the execution of the first power-on process.
[0203] a. Set all NAND FLASH to SLC mode before full charge capacity (FCC) initialization.
[0204] b. Scan bad blocks, perform erase, read and write operations on all blocks in sequence, and mark the blocks where the operations fail as bad blocks.
[0205] c. Read the PE table and recalculate the erase count of each block used to store user data (running in TLC mode before conversion) as follows.
[0206] d. According to the current disk capacity, initialize all data that needs to be recalculated and write it to the system data area.
[0207] At this point, the solid-state drive that is in EOL state because the number of TLC storage unit erases has reached the upper limit can restore its safe and stable storage function by switching to SLC storage mode.
[0208] The above describes in detail various embodiments corresponding to the hard disk-based data storage method. On this basis, the present invention also discloses a hard disk-based data storage device corresponding to the above method. Figure 4 The structure diagram of a hard disk-based data storage device provided by an embodiment of the present invention. Figure 4 As shown, hard disk-based data storage devices include:
[0209] The acquisition module 11 is used to acquire the current number of erasures and writes corresponding to the current storage mode of the hard disk; and determine the remaining life of the hard disk in the current storage mode based on the current number of erasures and writes;
[0210] A determination module 12 is used to determine a target storage mode according to the number of storage unit layers of the current storage mode when the remaining life of the hard disk in the current storage mode is in the end-of-life state; wherein the number of storage unit layers of the target storage mode is less than the number of storage unit layers of the current storage mode;
[0211] The conversion module 13 is used to convert the current storage mode into a target storage mode so as to store data according to the erasing and writing times of the target storage mode.
[0212] Since the embodiments of the device part correspond to the above embodiments, please refer to the description of the embodiments of the method part for the embodiments of the device part, and will not be repeated here.
[0213] For an introduction to a hard disk-based data storage device provided by the present invention, please refer to the above method embodiment, and the present invention will not be repeated here. It has the same beneficial effects as the above hard disk-based data storage method.
[0214] Figure 5 A structural diagram of a hard disk-based data storage device provided by an embodiment of the present invention, such as Figure 5 As shown, the device comprises:
[0215] A memory 21, used for storing computer programs;
[0216] The processor 22 is used to implement the steps of the hard disk-based data storage method when executing the computer program.
[0217] The hard disk-based data storage device provided in this embodiment may include, but is not limited to, a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0218] Among them, the processor 22 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 22 may be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 22 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 22 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 22 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0219] The memory 21 may include one or more computer-readable storage media, which may be non-transitory. The memory 21 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 21 is at least used to store the following computer program 211, wherein, after the computer program is loaded and executed by the processor 22, it can implement the relevant steps of the hard disk-based data storage method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 21 may also include an operating system 212 and data 213, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 212 may include Windows, Unix, Linux, etc. Data 213 may include, but is not limited to, data involved in the hard disk-based data storage method, etc.
[0220] In some embodiments, the hard disk-based data storage device may further include a display screen 23 , an input / output interface 24 , a communication interface 25 , a power supply 26 , and a communication bus 27 .
[0221] Those skilled in the art can understand that Figure 5 The structure shown in the figure does not constitute a limitation on the hard disk-based data storage device, and may include more or fewer components than shown in the figure.
[0222] The processor 22 implements the hard disk-based data storage method provided by any of the above embodiments by calling the instructions stored in the memory 21 .
[0223] For an introduction to a hard disk-based data storage device provided by the present invention, please refer to the above method embodiment, and the present invention will not be repeated here. It has the same beneficial effects as the above hard disk-based data storage method.
[0224] Furthermore, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by the processor 22, the steps of the hard disk-based data storage method are implemented.
[0225] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0226] For an introduction to a computer-readable storage medium provided by the present invention, please refer to the above method embodiment, which will not be described in detail herein. It has the same beneficial effects as the above hard disk-based data storage method.
[0227] Furthermore, the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the hard disk-based data storage method when executed by a processor.
[0228] For an introduction to a computer program product provided by the present invention, please refer to the above method embodiment, which will not be described in detail herein. It has the same beneficial effects as the above hard disk-based data storage method.
[0229] The above is a detailed introduction to a hard disk-based data storage method, product, device and medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
[0230] It should also be noted that, in this specification, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device 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 device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A data storage method based on a hard disk, characterized in that: include: Get the current number of erase and write times corresponding to the current storage mode of the hard disk; and determining the remaining life of the hard disk in the current storage mode based on the current number of erase and write times; When the remaining life of the hard disk in the current storage mode is in the end-of-life state, determining the target storage mode according to the number of storage unit layers of the current storage mode; wherein the number of storage unit layers of the target storage mode is less than the number of storage unit layers of the current storage mode; Converting the current storage mode to the target storage mode to store data according to the number of erasures and writes of the target storage mode; The step of converting the current storage mode to the target storage mode includes: Acquire a system data block and a user data block of the hard disk; and reallocate the system data block and the user data block respectively; The allocated system data block is configured with a capacity parameter of a hard disk; and a system storage space is allocated according to the capacity parameter of the hard disk; an attribute parameter of the hard disk is obtained; and the attribute parameter of the hard disk is stored in a preset storage area; Initiate erasing storage units corresponding to the current storage mode and the target storage mode respectively; Writing the attribute parameters of the preset storage area back to the system data area; The simulated power-on is started, and the remaining number of erase / write times corresponding to the target storage mode is determined according to the current number of erase / write times and the critical number of erase / write times of the target storage mode, so as to complete the conversion of the target storage mode.
2. The hard disk-based data storage method according to claim 1, characterized in that: Determining the remaining life of the hard disk in the current storage mode based on the current number of erase and write times includes: Obtain the erase and write times threshold and hard disk health status parameters corresponding to the current storage mode; When the health status parameter of the hard disk is characterized as an unhealthy state, the remaining life of the hard disk in the current storage mode is determined according to the relationship between the current erasure number and the erasure number threshold.
3. The hard disk-based data storage method according to claim 2, characterized in that: Determining a target storage mode according to the number of storage unit layers of the current storage mode includes: Obtaining storage unit layers corresponding to the remaining storage modes except the current storage mode, and sorting the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes; The last storage mode in the sorted storage modes is selected as the target storage mode.
4. The hard disk-based data storage method according to claim 2, characterized in that: Determining a target storage mode according to the number of storage unit layers of the current storage mode includes: Obtaining a first remaining erasure count threshold corresponding to the current storage mode and an unhealthy state of the hard disk; wherein the unhealthy state includes a sub-healthy state and a non-sub-healthy state; Determine the current remaining number of erasure times according to the current number of erasure times and the threshold number of erasure times; Obtaining storage unit layers corresponding to the remaining storage modes except the current storage mode, and sorting the number of storage unit layers of each storage mode in descending order to obtain sorted storage modes; Determine whether the current remaining erase / write times is greater than the first remaining erase / write times threshold, and the unhealthy state of the hard disk is a sub-healthy state; If yes, then selecting the next storage mode after the current storage mode from the sorted storage modes as the target storage mode; If not, the last storage mode in the sorted storage modes is selected as the target storage mode.
5. The hard disk-based data storage method according to claim 1, characterized in that: Determining the remaining number of erase / write times corresponding to the target storage mode according to the current number of erase / write times and the critical number of erase / write times of the target storage mode includes: Obtaining a critical erasure count of the target storage mode, an erasure count threshold of the current storage mode, and a current erasure count corresponding to the current storage mode corresponding to a second erasure count in the target storage mode; Subtracting the critical erasure number of the target storage mode from the second erasure number to obtain a third erasure number; Dividing the erasure number threshold of the current storage mode by the third erasure number to determine a first ratio; The current erasing and writing times of the current storage mode are multiplied by the first ratio to obtain the remaining erasing and writing times corresponding to the target storage mode.
6. The hard disk-based data storage method according to claim 1, characterized in that: The allocated system data blocks are configured with capacity parameters of the hard disk, including: Acquire a first system capacity of the hard disk before conversion, wherein the first system capacity of the hard disk is the sum of the capacities of storage units corresponding to the target storage mode and the current storage mode respectively; Processing the capacity of the storage unit in the current storage mode according to the number of storage unit layers in the current storage mode and the number of storage unit layers in the target storage mode in the first system capacity to determine the second system capacity of the hard disk after conversion; Determine the second user capacity of the hard disk after conversion according to the relationship between the first user capacity of the hard disk before conversion and the actual user capacity; Determine the size of the mapping table from the logical address to the physical address of the hard disk after conversion according to the second user capacity of the hard disk after conversion; Determining the number of bits of the flash memory block bitmap table of the hard disk after conversion according to a previously preset number of bits of the bitmap table of the hard disk before conversion; The second system capacity of the hard disk after conversion, the second user capacity of the hard disk after conversion, the size of the mapping table from the logical address to the physical address of the hard disk after conversion, and the number of bits of the flash memory block bitmap table of the hard disk after conversion are used as capacity parameters of the hard disk for configuration processing in the allocated system data block.
7. The hard disk-based data storage method according to claim 1, characterized in that: Allocating system storage space according to the capacity parameter of the hard disk includes: Acquire a first storage space for storing hard disk identification information corresponding to the system storage space of the hard disk after conversion; allocate the capacity parameter of the hard disk to the first storage space; The process of determining the space size of the first storage space includes: Obtaining the current space size of the first storage interval of the hard disk before conversion, the first system capacity of the hard disk before conversion, the second system capacity of the hard disk after conversion, and the capacity of a corresponding single storage unit in the target storage mode; Determine the calculated space size of the first storage interval according to the current space size of the first storage interval of the hard disk before the conversion, the first system capacity of the hard disk before the conversion, the second system capacity of the hard disk after the conversion, and the corresponding single storage unit capacity in the target storage mode; obtain the data structure size in the first storage interval of the hard disk before the conversion; Determine the critical allocation space of the first storage interval according to the data structure size and the corresponding single storage unit capacity under the target storage mode; The space size of the first storage space is determined according to the calculated space size of the first storage interval and the critical allocated space of the first storage interval.
8. The hard disk-based data storage method according to claim 1, characterized in that: After writing the attribute parameters of the preset storage area back to the system data area and before starting the simulated power-on, the method further includes: Initiate a simulated power-off to clear temporary data on the hard disk; The completion flag is set to facilitate entering the step of starting the simulated power-on.
9. The hard disk-based data storage method according to claim 8, characterized in that: The power-on simulation includes: Before the hard disk is initialized, the storage mode of the hard disk is set to the target storage mode; Performing erase and write operations on all blocks of the hard disk in sequence; The blocks where the erase / write operation fails are recorded and marked as bad blocks.
10. The hard disk-based data storage method according to claim 2, characterized in that: The process of determining that the remaining life of the hard disk in the current storage mode is in an end-of-life state includes: When the current number of erasures and writes exceeds the threshold number of erasures and writes, it is determined that the remaining life of the hard disk in the current storage mode is in an end-of-life state.
11. The hard disk-based data storage method according to claim 10, characterized in that: When the remaining life of the hard disk in the current storage mode is in the end-of-life state, the method further includes: Send warning information; A conversion command interface is provided, and a read-only flag bit in the current storage mode is set to stop the processing of input and output commands.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the hard disk-based data storage method according to any one of claims 1 to 11 are implemented.
13. A data storage device based on a hard disk, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the hard disk-based data storage method as described in any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the hard disk-based data storage method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Data writing method and device of solid state disk, electronic equipment and storage medium
CN118466849A