Method and device for selecting failed data block and electronic equipment
By calculating the number of valid data pages, the number of erase/write cycles, and the timestamp of failed data blocks, the failed data block with the smallest value is selected as the recycling target, which solves the problem of uneven wear in traditional methods and ensures the capacity and lifespan of solid-state drives.
Patent Information
- Application Number
- CN202211362810.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-02
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-11-02
AI Technical Summary
Traditional methods ignore the number of block erases and writes and the update frequency when selecting SSD data blocks for recycling, resulting in uneven wear and reduced SSD disk capacity.
By obtaining the number of valid data pages, the number of erase/write cycles, and the timestamps of multiple failed data blocks, the running result of each failed data block is calculated, and the failed data block with the smallest value is selected as the recycling target, taking into account wear leveling and the age of the data.
This effectively avoids the problem of uneven wear of data blocks, ensuring the capacity and lifespan of the solid-state drive.
Smart Images

Figure CN115657955B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a selection method and device of failed data blocks and electronic equipment. BACKGROUND
[0002] At present, due to the inherent characteristics of NAND Flash (non-volatile random access storage medium), there may be some failed pages in each block during the use of the SSD (solid state disk), and the failed pages cannot be individually programmed to store data. The traditional method generally uses a greedy algorithm to select a recycling target block, and usually selects a block with the smallest valid page as a recycling block. This method only focuses on recycling efficiency, and ignores the block erase count and block update frequency, which can cause uneven block wear and tear, and some blocks can be written through, reducing the capacity of the SSD disk. SUMMARY
[0003] The purpose of the present application is to provide a selection method and device of failed data blocks and electronic equipment to avoid uneven data block wear and tear, thereby ensuring the capacity of the solid state disk.
[0004] The present application provides a selection method of failed data blocks, which comprises:
[0005] Obtaining a plurality of failed data blocks and corresponding running parameter values of each failed data block; wherein the running parameter values include: the number of valid data pages, the erase count, and the timestamp;
[0006] Based on the running parameter values, the running results corresponding to each failed data block are calculated;
[0007] The failed data block corresponding to the smallest numerical running result is determined as the target failed data block.
[0008] Further, the step of obtaining a plurality of failed data blocks and corresponding running parameter values of each failed data block comprises:
[0009] Obtaining a plurality of initial data blocks; wherein each initial data block includes a predetermined number of data pages, each data page is used to store user data; each data page is a valid data page or an invalid data page;
[0010] Judging whether there are failed data blocks in the plurality of initial data blocks; wherein all data pages in each failed data block store user data, and each failed data block includes at least one valid data page and at least one invalid data page;
[0011] If there are failed data blocks in the plurality of initial data blocks, the number of failed data blocks is determined;
[0012] If the number of failed data blocks is greater than 1, the running parameter value corresponding to each failed data block is obtained.
[0013] Further, the method further comprises:
[0014] selecting a target valid data block from the plurality of initial data blocks; wherein all data pages in the target valid data block do not store user data;
[0015] migrating the user data stored in all valid data pages in the target failed data block to the data pages of the target valid data block in the plurality of initial data blocks.
[0016] Further, the step of obtaining the running parameter value corresponding to each failed data block comprises:
[0017] obtaining a preset first record table, a second record table and a third record table; wherein the first record table is used to record the number of valid data pages in each failed data block; the second record table is used to record the number of erase-write times of each failed data block; and the third record table is used to record the time stamp corresponding to the last time of writing user data in each failed data block;
[0018] Based on the first record table, the second record table and the third record table, the number of valid data pages, the number of erase-write times and the time stamp corresponding to each failed data block are obtained.
[0019] Further, the running result corresponding to each failed data block is determined by the following formula:
[0020]
[0021] Wherein, Nice i is the running result corresponding to the i-th failed data block; u i is the ratio of the number of valid data pages of the i-th failed data block to the preset number of data pages, Seq(i) is the time stamp of the i-th failed data block, and N_PEC(i) is the number of erase-write times of the i-th failed data block.
[0022] The application provides a selecting device for failed data blocks, which comprises:
[0023] The obtaining module is used to obtain a plurality of failed data blocks and the running parameter value corresponding to each failed data block; wherein the running parameter value comprises: the number of valid data pages, the number of erase-write times, and the time stamp;
[0024] The calculation module is used to calculate the running result corresponding to each failed data block based on the running parameter value;
[0025] The selecting module is configured to determine the failed data block corresponding to the running result with the minimum value as the target failed data block.
[0026] Further, the obtaining module is further configured to:
[0027] obtain a plurality of initial data blocks; each initial data block includes a preset number of data pages, each data page is configured to store user data; each data page is a valid data page or an invalid data page;
[0028] determine whether there is a failed data block in the plurality of initial data blocks; each failed data block stores user data in all data pages, and each failed data block includes at least one valid data page and at least one invalid data page;
[0029] if there is a failed data block in the plurality of initial data blocks, determine the number of failed data blocks;
[0030] if the number of failed data blocks is greater than 1, obtain the running parameter value corresponding to each failed data block.
[0031] Further, the device further comprises a migration module, and the migration module is configured to:
[0032] select a target valid data block from the plurality of initial data blocks; all data pages in the target valid data block do not store user data;
[0033] migrate the user data stored in all valid data pages in the target failed data block to the data pages of the target valid data block in the plurality of initial data blocks.
[0034] The electronic device provided by the application includes a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method of any one of the above.
[0035] The computer readable storage medium provided by the application stores computer executable instructions, and when the computer executable instructions are called and executed by the processor, the computer executable instructions prompt the processor to implement the method of any one of the above.
[0036] The application provides a selection method and device of a failed data block and electronic equipment, wherein a plurality of failed data blocks and corresponding running parameter values of each failed data block are acquired, the running parameter values include the number of valid data pages, the number of erasing times and a timestamp, the running result corresponding to each failed data block is calculated based on the running parameter values, and the failed data block corresponding to the running result with the minimum value is determined as a target failed data block. In this way, the number of valid data pages, the number of erasing times and the update frequency of the plurality of failed data blocks are comprehensively considered to determine the failed data block, so that the problem of uneven wear can be avoided and the capacity of the solid state disk is ensured. BRIEF DESCRIPTION OF DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the specific embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.
[0038] Figure 1 A flowchart of a selection method of a failed data block provided by an embodiment of the present application;
[0039] Figure 2 A flowchart of another selection method of a failed data block provided by an embodiment of the present application;
[0040] Figure 3 A schematic diagram of a first record table, a second record table and a third record table provided by an embodiment of the present application;
[0041] Figure 4 A schematic diagram of a selection method of a failed data block according to a Nice value provided by an embodiment of the present application;
[0042] Figure 5 A schematic diagram of migration of user data stored in a valid data page provided by an embodiment of the present application;
[0043] Figure 6 A flowchart of a selection method of a failed data block provided by an embodiment of the present application;
[0044] Figure 7 A structural schematic diagram of a selection device of a failed data block provided by an embodiment of the present application;
[0045] Figure 8 A structural schematic diagram of an electronic equipment provided by an embodiment of the present application. DETAILED DESCRIPTION
[0046] The technical solutions of the present application will be described clearly and completely in connection with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative labor fall within the scope of the present application.
[0047] At present, NAND Flash needs to be erased before performing program, and the unit of the erase operation is a block (containing a plurality of pages), and the minimum unit of the program is a page, and the data in the block does not support rewrite. When updating data, new data is written to a new page, and the page where the old data is located is marked as invalid. Due to such characteristics of NAND Flash, during the use of the SSD, there may be some invalid pages in each block, and the invalid pages cannot be individually programmed to store data.
[0048] To this end, the conventional method can generally use a greedy algorithm to select a recycling target block, and usually selects a block with the smallest valid page as a recycling block. This method only focuses on recycling efficiency, and ignores the block erase times and the block update frequency, which can cause uneven block wear, a certain block being written through, and reduced SSD disk capacity. Based on this, the present application provides a method for selecting a failed data block, a device and an electronic equipment.
[0049] To facilitate the understanding of the present embodiment, first, a method for selecting a failed data block disclosed by the present embodiment is described in detail, as shown in the method includes the following steps: Figure 1
[0050] In step S102, a plurality of failed data blocks and corresponding running parameter values of each failed data block are obtained, wherein the running parameter values include: the number of valid data pages, the erase times, and the time stamp.
[0051] In the process of writing user data to the solid state disk, invalid data blocks can be generated at any time, and the number of invalid data blocks generated can be one or more. The invalid data blocks contain invalid user data and newly written valid user data. Since the memory of the solid state disk is limited, when there is invalid user data, an erase operation is needed to release more memory resources. However, the unit of the erase operation is a whole data block, so the valid user data will also be erased, resulting in the loss of user data. In order to avoid this situation, a GC garbage collector can be used to recover all valid user data in the invalid data blocks. If there is only one invalid data block, the GC garbage collector can be used to recover all valid user data in the invalid data block. However, if there are multiple invalid data blocks, the running parameter values of each invalid data block need to be selected.
[0052] Each invalid data block has a corresponding number of valid data pages, erase times, and a timestamp. The number of valid data pages in the invalid data block can be one or more, and is used to store valid user data. The erase times can be understood as the number of times the data in the invalid data block is erased. The timestamp corresponding to the invalid data block can be understood as the timestamp of the last time user data is written in the invalid data block. In actual implementation, if there are multiple invalid data blocks, the number of valid data pages, erase times, and timestamps corresponding to each invalid data block need to be obtained first.
[0053] Step S104, based on the running parameter values, calculate the running result corresponding to each invalid data block.
[0054] Step S106, determine the invalid data block corresponding to the smallest value of the running result as the target invalid data block.
[0055] In the process of implementation, after step S102, the number of valid data pages, erase times, and timestamps corresponding to each invalid data block are calculated to obtain the running result corresponding to each invalid data block. Then, the invalid data block corresponding to the smallest value of the running result is determined as the invalid data block to be recovered by the garbage collector. The erase times and the number of valid data pages of the invalid data block corresponding to the smallest value of the running result are both small, and the user data stored is relatively new.
[0056] The selecting method of the invalid data block, by acquiring a plurality of invalid data blocks and the running parameter values corresponding to each invalid data block, wherein the running parameter values include the number of valid data pages, the number of erasing times, and the time stamp; based on the running parameter values, calculating the running results corresponding to each invalid data block; and determining the invalid data block corresponding to the running result with the smallest value as the target invalid data block. In this way, by comprehensively considering the number of valid data pages, the number of erasing times, and the update frequency of the plurality of invalid data blocks, the invalid data block is determined, which can avoid the problem of uneven wear and tear and ensure the capacity of the solid state disk.
[0057] The embodiment of the present application also provides another selecting method of invalid data block, which is based on the above-mentioned embodiment method, as shown in the following formula: Figure 2 The method comprises the following steps:
[0058] In step S202, a plurality of initial data blocks are acquired; wherein each initial data block comprises a preset number of data pages, and each data page is used for storing user data; and each data page is a valid data page or an invalid data page.
[0059] In the specific implementation process, there are a plurality of initial data blocks in the solid state disk, each initial data block has a fixed number of data pages, for example, 5, 6, etc., and the user can directly write the user data into these data pages for storage, wherein the data page storing the newly written user data of the user is a valid data page, and the data page storing the previously written user data of the user is an invalid data page.
[0060] In step S204, it is judged whether there is an invalid data block in the plurality of initial data blocks; wherein all the data pages in each invalid data block store user data, and each invalid data block comprises at least one valid data page and at least one invalid data page.
[0061] In the specific implementation process, if all the data pages of an initial data block store user data, and among these data pages, there is at least one invalid data page storing the previously written user data of the user and one valid data page storing the newly written user data of the user, the initial data block is determined as an invalid data block.
[0062] Specifically, assuming that there are 7 data pages in an initial data block, if all of the 7 data pages are not written with user data, or none of the 7 data pages is written with user data, the initial data block does not participate in recycling. If all of the 7 data pages are written with user data, but all of the user data is valid or all of the user data is invalid, the initial data block also does not participate in recycling. When all of the user data is valid, no processing is performed. When all of the user data is invalid, the initial data block is directly erased. Only when all of the 7 data pages are written with user data, and at least 1 or at most 6 of the data pages are written with old user data, or at most 5 or at least 1 of the data pages are written with new user data, the initial data block (equivalent to the invalid data block) can participate in recycling.
[0063] In step S206, if there are invalid data blocks in the plurality of initial data blocks, the number of the invalid data blocks is determined.
[0064] In step S208, if the number of the invalid data blocks is greater than 1, the running parameter value corresponding to each invalid data block is obtained.
[0065] In the implementation process, if there are a plurality of initial data blocks that can participate in recycling, the running parameter values of the plurality of initial data blocks that can participate in recycling are obtained, the running result corresponding to each initial data block that can participate in recycling is calculated according to the obtained running parameter values, the initial data block that can participate in recycling and that has the minimum running result value (equivalent to a target invalid data block) is found, and the initial data block is recycled.
[0066] Specifically, the running parameter values of the plurality of initial data blocks that can participate in recycling can be obtained through the following steps one to two:
[0067] In step one, a preset first record table, a second record table, and a third record table are obtained. The first record table is used to record the number of valid data pages in each invalid data block. The second record table is used to record the number of erase-write times of each invalid data block. The third record table is used to record the time stamp corresponding to the last time when user data is written in each invalid data block.
[0068] In the actual implementation, refer to, for example, Figure 3A first record table, a second record table and a third record table are shown, the first record table, the second record table and the third record table are generally resident in RAM and are dynamically updated, specifically, in the solid state disk, a VC table (the first record table) is maintained for all initial data blocks for storing user data, the VC table records the valid data amount (the number of valid data pages) of each block, for example, VC_0 represents the number of valid data pages in the data block block0; a PEC table (the second record table) is maintained for all blocks for storing user data, the PEC table records the PE (erasing and writing) times of each block, for example, PEC_0 represents the erasing and writing times of the data block block0; a Seq table (the third record table) is maintained for all blocks for storing user data, the Seq table records the update order of each block, each block only has one Seq value, after all pages in the current block are filled, the Seq value of the next block is increased by 1, for example, Seq_0 represents the time stamp corresponding to the last time when user data is written in the data block block0.
[0069] Step two: based on the first record table, the second record table and the third record table, the number of valid data pages, the erasing and writing times and the time stamp corresponding to each invalid data block are obtained.
[0070] In actual implementation, according to the recorded data in the first record table, the second record table and the third record table, the number of valid data pages, the erasing and writing times and the time stamp of each invalid data block can be directly obtained.
[0071] Step S210, based on the running parameter value, the running result corresponding to each invalid data block is calculated.
[0072] Specifically, the running result corresponding to each invalid data block can be calculated by the following calculation formula:
[0073]
[0074] Wherein, Nice i is the running result corresponding to the i th invalid data block; u i is the ratio of the number of valid data pages of the i th invalid data block to the preset number of data pages, Seq(i) is the time stamp of the i th invalid data block, and N_PEC(i) is the erasing and writing times of the i th invalid data block.
[0075] The first part of the formula emphasizes the recovery efficiency of the GC, the fewer the effective pages, the greater the chance of being selected. The second part emphasizes the age of the data in the block, the newer the data in each block, the greater the chance of being selected. The third part emphasizes wear leveling, the smaller the PEC, the greater the chance of being selected, and finally the block with the smallest Nice value is selected from all the full blocks as the target of recovery.
[0076] Step S212, the invalid data block corresponding to the smallest numerical result is determined as the target invalid data block.
[0077] Suppose there are six invalid data blocks, each with 26 data pages, and the VC (number of effective data pages), PEC (number of erasing and writing), Seq (timestamp), and Nicei (running result) corresponding to the six invalid data blocks are as shown in Table 1. Figure 4
[0078] If the traditional method is used, the block with the smallest VC, i.e., block 0, should be selected as the target of recovery, but the PEC of block 0 is already significantly higher than that of other blocks, which will cause uneven wear. According to the method of the present application, the block with the smallest running result, i.e., block 2, can be selected as the target of recovery first, followed by block 1, block 3, and then block 0.
[0079] When the greedy algorithm selects the recovery block, the block with the smallest effective page is selected as the recovery block, and the effective page is migrated to a new block. This method only focuses on recovery efficiency, but ignores the number of erasing and writing of the block and the update frequency of the block, which will cause uneven wear of the block, the block is written through, and the capacity of the SSD disk is reduced.
[0080] In view of the defects of the traditional greedy algorithm, the present application aims to accurately select the target invalid data block for recovery, combines the advantages of the greedy algorithm, and takes into account the number of erasing and writing of each invalid data block, and considers the degree of wear of the target block and the degree of newness of the data in the block, i.e., the recovery efficiency of the input block, the number of erasing and writing, and the timestamp of the block. The Nice value of the block is calculated, the block with the smallest Nice value is selected as the target block for recovery, the problem of uneven wear is improved, and blocks with small VC and storing new data, i.e., hot data blocks, are preferred to be selected, which can reduce the write amplification of the SSD.
[0081] Step S214, selecting a target valid data block from a plurality of initial data blocks; wherein all data pages in the target valid data block do not store user data
[0082] Step S216, migrating the user data stored in all valid data pages in the target invalid data block to the data pages of the target valid data block in the plurality of initial data blocks.
[0083] In actual implementation, the data in all valid pages in the target invalid data block can be migrated to a new block (target valid data block) by GC, so that all pages in the target invalid data block become invalid, the erase operation does not cause data loss, and more pages are released for storing data.
[0084] Specifically, referring to Figure 5 Fig. 1 shows a user data migration diagram in a valid data page, block x is a recycling target (target invalid data block), block y is a migration target block (target valid data block), block x valid pages 1, 3, 7, 9, and 14 are migrated to block y, and all pages in block x are marked as free and can be used to store other data.
[0085] In order to better understand the above embodiment, referring to Figure 6 Fig. 2 shows a flowchart for selecting an invalid data block, when selecting a recycling block (invalid data block), the first step is to determine whether the GC starting condition (whether there is an invalid data block) is met, if the condition is met, the block with the smallest Nice is selected as the recycling target block, the data in the recycling target block is migrated to a new block, and the recycling target block is released.
[0086] After the condition for starting the method is met, a suitable target is selected from the blocks that have been written full as a recycling target, and the recycling efficiency, wear degree, and data age of the block are comprehensively considered to improve the GC efficiency, improve the life of the entire SSD, and migrate the data in all valid pages in the block to a new block by GC, so that all pages in the original block become invalid, the erase operation does not cause data loss, and more pages are released for storing data.
[0087] The embodiment of the application also provides a device for selecting an invalid data block, as shown in Figure 7 The device comprises: an acquisition module 30, configured to acquire a plurality of invalid data blocks and a corresponding running parameter value of each invalid data block, wherein the running parameter value comprises: the number of valid data pages, the number of erase times, and a timestamp; a calculation module 31, configured to calculate a running result corresponding to each invalid data block based on the running parameter value; and a selection module 32, configured to determine the invalid data block corresponding to the running result with the smallest value as a target invalid data block.
[0088] The selecting device of the above invalid data block obtains a plurality of invalid data blocks and a corresponding running parameter value of each invalid data block, wherein the running parameter value includes the number of valid data pages, the number of erasing and writing, and the time stamp; based on the running parameter value, the running result corresponding to each invalid data block is calculated; and the invalid data block corresponding to the running result with the smallest value is determined as the target invalid data block. The device can avoid the problem of uneven wear and tear and ensure the capacity of the solid state disk by comprehensively considering the number of valid data pages, the number of erasing and writing, and the update frequency of the plurality of invalid data blocks when determining the invalid data block.
[0089] Further, the obtaining module is further configured to: obtain a plurality of initial data blocks; each initial data block includes a preset number of data pages, each data page is configured to store user data; each data page is a valid data page or an invalid data page; determine whether there is an invalid data block in the plurality of initial data blocks; wherein all data pages in each invalid data block store user data, and each invalid data block includes at least one valid data page and at least one invalid data page; if there is an invalid data block in the plurality of initial data blocks, determine the number of invalid data blocks; if the number of invalid data blocks is greater than 1, obtain the running parameter value corresponding to each invalid data block.
[0090] Further, the device further comprises a migration module, the migration module is configured to: select a target valid data block from the plurality of initial data blocks; wherein all data pages in the target valid data block do not store user data; migrate the user data stored in all valid data pages in the target invalid data block to the data pages in the target valid data block in the plurality of initial data blocks.
[0091] Further, the obtaining module is further configured to: obtain a preset first record table, a second record table and a third record table; the first record table is configured to record the number of valid data pages in each invalid data block; the second record table is configured to record the number of erasing and writing of each invalid data block; and the third record table is configured to record the time stamp corresponding to the last time of writing user data in each invalid data block; based on the first record table, the second record table and the third record table, obtain the number of valid data pages, the number of erasing and writing and the time stamp corresponding to each invalid data block.
[0092] Further, the running result corresponding to each invalid data block is determined by the following formula:
[0093]
[0094] Wherein, Nice i is the running result corresponding to the i th invalid data block; u iN(i) is the ratio of the number of valid data pages of the i-th failed data block to the preset number of data pages, Seq(i) is the time stamp of the i-th failed data block, and N_PEC(i) is the number of erasing and writing of the i-th failed data block.
[0095] The selecting device for the failed data block provided in the embodiments of the present application has the same implementation principle and technical effects as the foregoing selecting method for the failed data block, and the selecting device for the failed data block can refer to the corresponding content in the foregoing selecting method for the failed data block.
[0096] The embodiments of the present application further provide an electronic device, as shown in Figure 8 The electronic device includes a processor 130 and a memory 131, the memory 131 stores machine executable instructions capable of being executed by the processor 130, and the processor 130 executes the machine executable instructions to implement the foregoing method.
[0097] Further, Figure 8 The electronic device as shown further includes a bus 132 and a communication interface 133, and the processor 130, the communication interface 133 and the memory 131 are connected through the bus 132.
[0098] The memory 131 can include a high-speed random access memory (RAM) and can also include a non-volatile memory, for example, at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 133 (which can be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used. The bus 132 can be an ISA bus, a PCI bus or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 8 Only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0099] The processor 130 can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit of hardware in the processor 130 or the instruction in the form of software. The processor 130 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block disclosed in the embodiment of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiment of the present application can be directly embodied as a hardware decoding processor for execution, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the storage 131, and the processor 130 reads the information in the storage 131 and combines the hardware to complete the steps of the method of the above embodiment.
[0100] The embodiment of the present application further provides a computer readable storage medium, the computer readable storage medium stores computer executable instructions, when the computer executable instructions are called and executed by a processor, the computer executable instructions cause the processor to implement the above method, and the specific implementation can be referred to the method embodiment, and will not be repeated here.
[0101] The method for selecting the invalid data block, the device and the electronic equipment provided by the embodiment of the present application include a computer readable storage medium storing program codes, the instructions included in the program codes can be used to execute the method described in the foregoing method embodiment, and the specific implementation can be referred to the method embodiment, and will not be repeated here.
[0102] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the present application that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0103] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for selecting a failed data block, characterized in that, The method comprises: obtaining a plurality of invalid data blocks and corresponding operating parameter values of each of the invalid data blocks; wherein the operating parameter values comprise: the number of valid data pages, the number of erasing times, and a timestamp; based on the operating parameter values, calculating the operating result corresponding to each of the invalid data blocks; determining the invalid data block corresponding to the operating result with the smallest value as a target invalid data block; wherein the operating result corresponding to each of the invalid data blocks is determined by the following formula: ; Wherein, Nice i is the running result corresponding to the ith failed data block; u i is the ratio of the number of valid data pages of the ith failed data block to the preset number of data pages, Seq(i) is the timestamp of the ith failed data block, and N_PEC(i) is the number of erasing and writing of the ith failed data block.
2. The method of claim 1, wherein, the step of obtaining a plurality of invalid data blocks and corresponding operating parameter values of each of the invalid data blocks comprises: obtaining a plurality of initial data blocks; wherein each of the initial data blocks comprises a preset number of data pages, each of the data pages is used to store user data; and each of the data pages is a valid data page or an invalid data page; determining whether the invalid data blocks exist in the plurality of initial data blocks; wherein all of the data pages in each of the invalid data blocks store the user data, and each of the invalid data blocks comprises at least one valid data page and at least one invalid data page; if the invalid data blocks exist in the plurality of initial data blocks, determining the number of the invalid data blocks; if the number of the invalid data blocks is greater than 1, obtaining the operating parameter values corresponding to each of the invalid data blocks.
3. The method of claim 2, wherein, The method further comprises: selecting a target valid data block from the plurality of initial data blocks; wherein all of the data pages in the target valid data block do not store user data; migrating the user data stored in all of the valid data pages in the target invalid data block to the data pages of the target valid data block in the plurality of initial data blocks.
4. The method of claim 2, wherein, The step of obtaining the operating parameter values corresponding to each of the invalid data blocks comprises: obtaining a preset first record table, a second record table, and a third record table; wherein the first record table is used to record the number of valid data pages in each of the invalid data blocks; the second record table is used to record the number of erasing times of each of the invalid data blocks; and the third record table is used to record the corresponding timestamp when the last user data is written in each of the invalid data blocks; based on the first record table, the second record table, and the third record table, obtaining the number of valid data pages, the number of erasing times, and the timestamp corresponding to each of the invalid data blocks.
5. An apparatus for selecting a failed data block, the apparatus comprising: The device comprises: an obtaining module, configured to obtain a plurality of invalid data blocks and corresponding operating parameter values of each of the invalid data blocks; wherein the operating parameter values comprise: the number of valid data pages, the number of erasing times, and a timestamp; a calculating module, configured to calculate the operating result corresponding to each of the invalid data blocks based on the operating parameter values; a selecting module, configured to determine the invalid data block corresponding to the operating result with the smallest value as a target invalid data block; wherein the operating result corresponding to each of the invalid data blocks is determined by the following formula: ; Wherein, Nice i is the running result corresponding to the ith failed data block; u i is the ratio of the number of valid data pages of the ith failed data block to the preset number of data pages, Seq(i) is the timestamp of the ith failed data block, and N_PEC(i) is the number of erasing and writing of the ith failed data block.
6. The apparatus of claim 5, wherein, the obtaining module is further configured to: obtain a plurality of initial data blocks; wherein each of the initial data blocks comprises a preset number of data pages, each of the data pages is used to store user data; and each of the data pages is a valid data page or an invalid data page; determining whether the invalid data blocks exist in the plurality of initial data blocks; wherein all of the data pages in each of the invalid data blocks store the user data, and each of the invalid data blocks comprises at least one valid data page and at least one invalid data page; if the invalid data blocks exist in the plurality of initial data blocks, determining the number of the invalid data blocks; if the number of the invalid data blocks is greater than 1, obtaining a running parameter value corresponding to each of the invalid data blocks.
7. The apparatus of claim 6, wherein, The device further comprises a migration module, which is configured to: select a target valid data block from the plurality of initial data blocks; wherein all of the data pages in the target valid data block do not store user data; migrate the user data stored in all of the valid data pages in the target invalid data block to the data pages in the target valid data block in the plurality of initial data blocks.
8. An electronic device, comprising: The electronic device comprises a processor and a memory, the memory stores computer executable instructions capable of being executed by the processor, and the processor executes the computer executable instructions to implement the method in any one of claims 1 to 4.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and when the computer executable instructions are called and executed by the processor, the computer executable instructions cause the processor to implement the method in any one of claims 1 to 4.
Citation Information
Patent Citations
Garbage collection method and device and nonvolatile storage equipment
CN111159059A
Intelligent garbage collection method and device compatible with NVMe solid state disk
CN112463057A