Multi-stream waste recycling methods and storage devices
By introducing a multi-stream management mechanism into the storage device, the problem of increasing write volume during garbage collection and wear equalization is solved, extending the device life and improving performance.
Patent Information
- Application Number
- CN201811566457.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-19
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2038-12-19
AI Technical Summary
The garbage collection and wear equalization process in existing storage devices leads to an increase in data writes, reducing storage device life and affecting performance.
By introducing a multi-stream management mechanism in the storage device, establish a binding relationship between the flow and the active chunks, write data to the corresponding stream, and dynamically adjust it according to the characteristics of the flow and the state of the chunks, reducing the additional write amount .
Effectively reduces the amount of additional writes generated by the garbage collection and wear equalization process, extends the life of the storage device, and improves performance.
Smart Images

Figure CN111338975B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to a storage device, and more particularly to a garbage collection method in a storage device supporting multiple streams and a storage device thereof. Background Art
[0002] Figure 1 The block diagram of the storage device is shown. The storage device 100 is coupled to the host to provide storage capacity for the host. The host and the storage device 100 can be coupled in a variety of ways, including but not limited to connecting the host and the solid-state storage device 100 through, for example, SATA (Serial Advanced Technology Attachment), SCSI (Small Computer System Interface), SAS (Serial Attached SCSI), IDE (Integrated Drive Electronics), USB (Universal Serial Bus), PCIE (Peripheral Component Interconnect Express, PCIe), NVMe (NVM Express), Ethernet, Fiber Channel, wireless communication network, etc. The host can be an information processing device that can communicate with the storage device in the above manner, such as a personal computer, a tablet computer, a server, a portable computer, a network switch, a router, a cellular phone, a personal digital assistant, etc. The storage device 100 includes an interface 110 , a control component 120 , one or more NVM chips 130 , and a DRAM (Dynamic Random Access Memory) 140 .
[0003] NAND flash memory, phase change memory, FeRAM (Ferroelectric RAM), MRAM (Magnetic Random Access Memory), RRAM (Resistive Random Access Memory), etc. are common NVMs.
[0004] The interface 110 may be adapted to exchange data with the host via, for example, SATA, IDE, USB, PCIE, NVMe, SAS, Ethernet, Fibre Channel, etc.
[0005] The control component 120 is used to control data transmission between the interface 110, the NVM chip 130 and the DRAM 140, and is also used for storage management, mapping of host logical addresses to physical addresses of the NVM chip, erase leveling, bad block management, etc. The control component 120 can be implemented in a variety of ways, such as software, hardware, firmware, or a combination thereof. For example, the control component 120 can be in the form of an FPGA (Field-programmable gate array), an ASIC (Application Specific Integrated Circuit), or a combination thereof. The control component 120 can also include a processor or a controller, in which software is executed to manipulate the hardware of the control component 120 to process IO (Input / Output) commands. The control component 120 can also be coupled to the DRAM 140 and can access data in the DRAM 140. The data of the FTL table and / or cached IO commands are stored in the DRAM.
[0006] The control component 120 includes a flash memory interface controller (or referred to as a media interface, a media interface controller, or a flash memory channel controller), which is coupled to the NVM chip 130 and issues commands to the NVM chip 130 in a manner that complies with the interface protocol of the NVM chip 130 to operate the NVM chip 130, and receives command execution results output from the NVM chip 130. Known NVM chip interface protocols include "Toggle", "ONFI", and the like.
[0007] A memory target is one or more logic units (LUNs) within a NAND flash memory package that share a chip enable (CE) signal. A NAND flash memory package includes one or more dies. Typically, a logic unit corresponds to a single die. A logic unit may include multiple planes. Multiple planes within a logic unit can be accessed in parallel, and multiple logic units within a NAND flash memory chip can execute commands and report status independently of each other. In the "Open NAND Flash Interface Specification (Revision 3.0)" available from http: / / www.micron.com / ~ / media / Documents / Products / Other%20Documents / ONFI3_0Gold.aspx, the meanings of target, logic unit (LUN), and plane are provided, which is part of the prior art.
[0008] Data is usually stored and read on NVM storage media by page. Data is erased by block. A block (also called a physical block) on an NVM storage medium contains multiple pages. A page on a storage medium (called a physical page) has a fixed size, such as 17664 bytes. A physical page can also have other sizes.
[0009] In a storage device, a Flash Translation Layer (FTL) is used to maintain mapping information from logical addresses to physical addresses. Logical addresses constitute the storage space of the storage device perceived by upper-layer software such as an operating system. A physical address is an address used to access a physical storage unit of a solid-state storage device. In the prior art, address mapping can also be implemented using an intermediate address form. For example, a logical address is mapped to an intermediate address, and then the intermediate address is further mapped to a physical address. Optionally, a host accessing the storage device provides an FTL.
[0010] The table structure storing the mapping information from the logical address to the physical address is called the FTL table. Usually, the data items of the FTL table record the address mapping relationship in the storage device in units of data pages.
[0011] Figure 2 A schematic diagram of a large block is shown. A large block includes physical blocks from each of a plurality of logical units (referred to as logical unit groups). Preferably, each logical unit provides a physical block for a large block. As an example, a large block is constructed on every 16 logical units (LUNs). Each large block includes 16 physical blocks from each of the 16 logical units (LUNs). Figure 2 In the example of , chunk 0 includes physical chunk 0 from each of the 16 logical units (LUNs), and chunk 1 includes physical chunk 1 from each logical unit (LUN). There are many other ways to structure chunks.
[0012] As an optional way, page stripes are constructed in large blocks, and physical pages with the same physical address in each logical unit (LUN) constitute a "page stripe". Figure 2 In , physical pages P0-0, P0-1, ... and P0-x constitute page stripe 0, where physical pages P0-0, P0-1, ... and P0-14 are used to store user data, and physical pages P0-x are used to store check data calculated based on all user data in the stripe. Similarly, Figure 2 In FIG. 2 , physical page P2-0, physical page P2-1, ... and physical page P2-x constitute page stripe 2. Optionally, the physical page for storing the check data may be located at any position in the page stripe.
[0013] When data is repeatedly written to a logical page, the corresponding relationship between the logical page address and the latest physical page address is recorded in the FTL table entry, and the data recorded in the physical page address that has been written but no longer referenced (for example, there is no record in the FTL table) becomes "garbage" (data). Data that has been written and referenced (for example, there is a record in the FTL table) is called valid data, and "garbage" is called dirty data. The physical block containing dirty data is called a "dirty physical block", and the physical block that has not been written with data is called a "free physical block".
[0014] Storage devices perform a garbage collection (GC) process to recycle invalid data.
[0015] Figure 3 A schematic diagram of the garbage collection process is shown. Data is written to physical block 0 and physical block 1. Physical pages 310, 312, 314, and 316 of physical block 0, which are indicated by grid boxes, have no records in the FTL table, and the data on them is dirty data. Physical pages 330, 332, 334, and 336 of physical block 0, which are indicated by blank boxes, have records in the FTL table, and the data on them is valid data. Physical pages 320, 322, 324, and 326 of physical block 1, which are indicated by grid boxes, have dirty data. Physical pages 344, 342, 346, and 348 of physical block 1, which are indicated by blank boxes, have valid data. Figure 3 In the figure, the data contained in the physical pages indicated by the grid are dirty data, while the data contained in the physical pages indicated by the blank boxes are valid data.
[0016] For garbage collection, dirty physical blocks (e.g., physical block 0 and physical block 1) are scanned, valid data therein is read out and written to free physical block 2, and changes in the physical page addresses of valid data are recorded in the FTL table. After all valid data of the physical blocks are moved to physical block 2, the scanned physical blocks 0 and physical blocks 1 are erased, so that physical blocks 0 and physical blocks 1 become free physical blocks.
[0017] Figure 4 A diagram showing the garbage collection method.
[0018] The dirty physical block set 410 includes dirty physical blocks of some or all NVM chips of the storage device. The free physical block set 420 includes free physical blocks of some or all NVM chips of the solid-state storage device.
[0019] To implement garbage collection, the "garbage collection" module 430 (for example, implemented in the control unit 120 or a CPU or controller therein) obtains dirty physical blocks from the dirty physical block set 410 and obtains free physical blocks from the free physical block set 420. The dirty physical blocks are scanned and valid data therein is written into the free physical blocks. After valid data in the obtained dirty physical blocks are moved to the free physical blocks, the dirty physical blocks are erased and the erased physical blocks are recorded in the free physical block set.
[0020] The dirty physical block set 410 and the free physical block set 420 may be linked lists, linear lists or other data structures for representing sets. The addresses of the physical blocks are recorded in the sets to access the physical blocks.
[0021] Optionally, garbage collection is performed in units of large blocks (instead of in units of physical blocks).
[0022] The storage device also performs a wear leveling operation so that each physical block of the storage device experiences substantially the same number of erasures during use, thereby reducing the adverse effect of the life exhaustion of individual physical blocks on the life of the storage device. Summary of the invention
[0023] Due to the implementation of garbage collection and wear leveling, data is repeatedly written to the NVM chip, which increases the amount of data written and reduces the life of the storage device. In addition, the process of writing data to the NVM occupies the read and write bandwidth of the storage device and affects the performance experienced by users. It is necessary to further improve the garbage collection and wear leveling process to reduce the additional write volume generated by the garbage collection and wear leveling process.
[0024] To achieve the above-mentioned purpose, according to the first aspect of the present application, a first garbage collection method according to the first aspect of the present application is provided, comprising: obtaining one or more streams, establishing a binding relationship between the streams and the active chunks; and writing the data in the streams into the active chunks corresponding to the same streams according to the binding relationship.
[0025] According to the first garbage collection method of the first aspect of the present application, the stream includes one or more user data streams and one or more GC streams, wherein the user data stream comes from data to be written by an IO command provided to a storage device, and the GC stream comes from data recovered from dirty blocks.
[0026] According to the second garbage collection method of the first aspect of the present application, a stream is allocated for data to be written by the IO command according to an address space accessed by the IO command or a feature of the IO command.
[0027] According to the second garbage collection method of the first aspect of the present application, when the storage space of the active large block is full, the active large block is set to a closed state, and a free large block is obtained as the active large block.
[0028] According to one of the first to fourth garbage collection methods of the first aspect of the present application, a static and / or dynamic binding relationship is maintained between the stream and the active chunk.
[0029] According to one of the first to fifth garbage collection methods of the first aspect of the present application, data is obtained from a specified stream based on a binding relationship between a stream and an active chunk, and a specified chunk is selected based on the stream to which the obtained data belongs, and the obtained data is written into the specified active chunk.
[0030] According to one of the first to fifth garbage collection methods of the first aspect of the present application, a specified active chunk is obtained, and a stream corresponding to the active chunk is selected based on a binding relationship between the stream and the active chunk, and data is obtained from the selected stream and written into the specified active chunk.
[0031] According to one of the first to seventh garbage collection methods of the first aspect of the present application, it further includes allocating data recovered from the dirty big block to different streams according to the characteristics of the dirty big block or the strategy for selecting the dirty big block.
[0032] According to the eighth garbage collection method of the first aspect of the present application, a first GC stream is allocated for data recovered from dirty chunks with the smallest number of erases, dirty chunks with the largest age, and dirty chunks with reliability warnings.
[0033] According to the eighth garbage collection method of the first aspect of the present application, a second GC stream is allocated for data collected from dirty chunks having the highest priority.
[0034] According to the eighth garbage collection method of the first aspect of the present application, the number of erasures is an average number of erasures or a total number of erasures of all physical blocks constituting the dirty large block.
[0035] According to the ninth garbage collection method of the first aspect of the present application, the age of a dirty block refers to the interval between the time when data is written thereto and the current time, or refers to the average value of the interval between the time when each piece of data recorded thereon is written thereto and the current time.
[0036] According to the tenth garbage collection method of the first aspect of the present application, the priority of the dirty block is a function of the number of erasures of the dirty block or the difference between the number of erasures of the dirty block and the average number of erasures of all dirty blocks in a set of dirty blocks and the amount of valid data in the dirty block.
[0037] According to the eighth garbage collection method of the first aspect of the present application, the strategy for selecting dirty large blocks includes, if the data of the free large blocks is greater than a threshold, selecting the dirty large block with the highest recycling priority.
[0038] According to the eighth garbage collection method of the first aspect of the present application, the strategy for selecting dirty large blocks includes selecting the dirty large block with the smallest number of erase times or selecting the dirty large block with the largest age if the difference between the maximum number of erase times and the average number of erase times of large blocks in the storage device is greater than a threshold, the difference between the maximum number of erase times and the minimum number of erase times is greater than a threshold and / or the difference between the average number of erase times and the minimum number of erase times is greater than a threshold.
[0039] According to one of the first to fifteenth garbage collection methods of the first aspect of the present application, in response to the active large block being full, a free large block is selected as a candidate large block or an active large block.
[0040] According to one of the first to sixteenth garbage collection methods of the first aspect of the present application, in response to a new free large block being released to a free large block set, if there is a free large block in the free large block set whose erase count is far from the average erase count, the free large block is used to replace the spare large block, or the free large block is used to replace the active large block to which data has not yet been written.
[0041] According to one of the first to seventeenth garbage collection methods of the first aspect of the present application, in response to a new free large block being released to a free large block set, if the number of erase times of the new free large block is far from the average number of erase times of the free large block, the new free large block is used to replace the spare large block, or the new free large block is used to replace the active large block that has not yet been written with data.
[0042] According to the eighteenth garbage collection method of the first aspect of the present application, if the number of erase times of the new free large block is much greater than the average erase times, the new free large block is used to replace the active large block or spare large block for carrying the user data stream to which data has not been written; or, if the number of erase times of the new free large block is much less than the average erase times, the new free large block is used to replace the active large block or spare large block for carrying the GC stream to which data has not been written.
[0043] According to one of the first to nineteenth garbage collection methods of the first aspect of the present application, in response to the time that the spare large block serves as the spare large block exceeding a threshold, a free large block is selected to replace the spare large block.
[0044] According to one of the sixteenth to twentieth garbage collection methods of the first aspect of the present application, a free large block with the smallest number of erase times is selected as the first active large block for carrying the user data stream.
[0045] According to one of the sixteenth to twenty-first garbage collection methods of the first aspect of the present application, a free large block with a write-erasure count closest to an average write-erasure count is selected as the second active large block for carrying the user data stream.
[0046] According to the twenty-first or twenty-second garbage collection method of the first aspect of the present application, the first active large block used to carry the user data stream is used to carry a relatively hot user data stream; and / or the second active large block used to carry the user data stream is used to carry a relatively cold user data stream.
[0047] According to one of the sixteenth to twentieth garbage collection methods of the first aspect of the present application, a free large block with the largest number of erasure times is selected as the first active large block for carrying the GC flow or the second active large block for carrying the GC flow.
[0048] According to one of the sixteenth to twentieth garbage collection methods of the first aspect of the present application, a free large block with the largest number of erase times is selected as the first active large block for carrying the GC flow.
[0049] According to the twenty-fifth garbage collection method of the first aspect of the present application, a free large block whose erase count is closest to the average erase count is selected as the second active large block for carrying the GC flow.
[0050] According to one of the sixteenth to twenty-sixth garbage collection methods of the first aspect of the present application, it further includes mapping one or more user data streams to the active chunk if the active chunk serves as the active chunk for too long.
[0051] According to one of the sixteenth to twenty-seventh garbage collection methods of the first aspect of the present application, it also includes mapping one or more user data streams to the active large block if the first active large block used to carry the GC stream or the second active large block used to carry the GC stream serves as the active large block for too long.
[0052] According to one of the first to twenty-eighth garbage collection methods of the first aspect of the present application, it also includes: controlling the proportion of data of each stream written into the NVM chip; or controlling the proportion of data of each stream written into the NVM chip within a specified time or unit time; or controlling the ratio of the amount of data written into the NVM chip by the GC stream and the user data stream within a specified time or unit time to not exceed a specified range.
[0053] According to the twenty-ninth garbage collection method of the first aspect of the present application, based on the number of free large blocks in the free large block set being less than a threshold, the data of the GC stream is allowed to be written into the NVM chip or the proportion of the data of the GC stream in the amount of data written into the NVM chip is increased.
[0054] According to the second aspect of the present application, a first storage device according to the second aspect of the present application is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements one of the above-mentioned garbage collection methods when executing the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For those skilled in the art, other drawings can also be obtained based on these drawings.
[0056] Figure 1 is a block diagram of a storage device;
[0057] Figure 2 It is a schematic diagram of a large block;
[0058] Figure 3 A schematic diagram of a garbage collection process in the prior art;
[0059] Figure 4 A schematic diagram of a garbage collection method in the prior art;
[0060] Figure 5 is a schematic diagram of a garbage data recovery process according to an embodiment of the present application;
[0061] Figure 6 is a schematic diagram of garbage data recovery according to another embodiment of the present application;
[0062] Figure 7 is a schematic diagram of garbage data recovery according to yet another embodiment of the present application;
[0063] Figure 8 A schematic diagram of garbage data recovery according to yet another embodiment of the present application is shown;
[0064] Fig. 9 A schematic diagram of garbage data recovery according to yet another embodiment of the present application is shown. DETAILED DESCRIPTION
[0065] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0066] Figure 5 It is a schematic diagram of garbage data recovery according to an embodiment of the present application.
[0067] According to an embodiment of the present application, data to be written to a storage device is marked as one or more streams. For example, Figure 5Four streams are shown, namely user data stream (S1), user data stream (S2), GC stream (Sg1) and GC stream (Sg2). The user data stream is the data to be written by the IO command provided to the storage device, and the GC stream is the data recovered from the dirty blocks during the garbage collection process.
[0068] The data is marked as different streams. For example, the IO command provided by the host to the storage device indicates the stream, the IO command is bound to the stream according to the address space or command space accessed by the IO command, the IO command is bound to the stream according to the characteristics of the IO command, etc. The Chinese patent application with application number 201811154584.2 and invention name “Automatic stream tracking for the evolution of multi-stream, open channel storage devices” provides a technical solution for binding IO commands to streams, and the Chinese patent application with application number 201811123110.1 and invention name “Intelligent data diversion and stream tracking for storage devices” also provides a technology for binding IO commands to streams. The full texts of the above two Chinese patent applications are incorporated herein by reference.
[0069] Data belonging to one or more streams to be written to the storage device is written into multiple chunks (referred to as active chunks). Figure 5 Four active chunks are shown, namely, chunk (U1), chunk (U2), chunk (GU1), and chunk (GU2). When the storage space of an active chunk is full, the active chunk is set to a closed state, and a new free chunk is acquired as an active chunk. For example, chunk (U1) and chunk (U2) are chunks used to carry user data streams, while chunk (GU1) and chunk (GU2) are chunks used to carry GC streams.
[0070] The <stream-chunk> mapping unit 510 binds the stream to the active chunk. The <stream-chunk> mapping unit 510 maintains a static and / or dynamic binding relationship between the stream and the active chunk.
[0071] As an example, the <stream-chunk> mapping unit 510 binds the user data stream to the chunk (U1) and / or the chunk (U2), and binds the GC stream to the chunk (GU1) and / or the chunk (GU2). Still as an example, the <stream-chunk> mapping unit 510 binds the user data stream (S1) representing hot data to the chunk (U1), and binds the user data stream (S2) representing cold data to the chunk (U2). As another example, the <stream-chunk> mapping unit 510 binds data reclaimed from dirty chunks storing cold data (GC stream (Sg1)) to the chunk (GU1), and binds data reclaimed from other dirty chunks (GC stream (Sg2)) to the chunk (GU2). Still optionally, the number of streams is different from the number of active chunks, one or more streams are bound to the same chunk, and / or one stream is bound to multiple chunks.
[0072] The write management unit 520 obtains data from the specified stream according to the binding relationship between the stream and the data obtained from the <stream-chunk> mapping unit 510, selects a specified chunk according to the stream to which the obtained data belongs, and instructs the media interface 530 to write the obtained data into the specified active chunk. Alternatively, the write management unit 520 obtains the specified active chunk, selects a stream corresponding to the active chunk according to the binding relationship between the stream and the data obtained from the <stream-chunk> mapping unit 510, obtains data from the stream, and writes it into the active chunk.
[0073] The dirty chunks that have completed the effective data recovery are erased and released as free chunks. The released free chunks are recorded in, for example, a free chunk set.
[0074] In response to, for example, the storage space of the active chunk being full, the active chunk is set to a closed state, and a free chunk is obtained from a free chunk set as an active chunk (chunk (U1), chunk (U2), chunk (GU1) and / or chunk (GU2)).
[0075] Figure 6 is a schematic diagram of garbage data recovery according to another embodiment of the present application.
[0076] There are multiple dirty big blocks in the dirty big block set. Dirty big blocks to be reclaimed by the garbage collection process are selected with multiple strategies (640). For example, strategy 642 indicates selecting dirty big blocks with the smallest number of erases, strategy 644 indicates selecting dirty big blocks with the largest age, strategy 646 indicates selecting dirty big blocks with reliability warnings, and strategy 648 indicates selecting dirty big blocks with the highest priority.
[0077] The reliability warning indicates that the data stored in the dirty block may be erroneous and need to be recycled. For example, an uncorrectable error occurs when reading data from one or more physical pages of the block, the number of times the data in the block is read exceeds a threshold, the time the data in the block is stored in the block exceeds a threshold, etc.
[0078] For a dirty block, its erase count is the average erase count or total erase count of all physical blocks that make up the dirty block. The age of a dirty block refers to the interval between the time when data is written to it and the current time, or the average value of the interval between the time when each piece of data recorded on it is written and the current time.
[0079] Optionally, a dirty block with a low number of erase times and a low amount of valid data (or a low percentage of valid data) has a high priority. For example, the priority is a function of the amount of valid data of the dirty block and the number of erase times of the dirty block. According to the number of erase times of the dirty block (or the difference between the number of erase times and the average number of erase times) and the amount of valid data, the priority P is obtained. Optionally, the priority (P) of the dirty block is a function of the number of erase times of the dirty block or the difference between the number of erase times of the dirty block and the average number of erase times of all dirty blocks in the dirty block set (denoted as ΔPE) and the amount of valid data of the dirty block (denoted as V), that is, P = f(ΔPE, V). In another example, P = f(PE, V) + r, where r is a random number.
[0080] Select one of the policies to select the dirty large block to be reclaimed. Set a flow for the valid data read from the dirty large block according to the policy for selecting the dirty large block. For example, set the data read from the dirty large block with the highest priority obtained according to policy 648 as the GC flow (Sg2), and set the data read from the dirty large block obtained according to other policies as the GC flow (Sg1).
[0081] For example, the strategy for selecting the block to be recycled is selected in turn from strategy 642, strategy 644 and strategy 646. As another example, each strategy has a different weight, and one of strategy 642, strategy 644 and strategy 646 is selected in a weighted round-robin manner.
[0082] Figure 7 is a schematic diagram of garbage data recovery according to yet another embodiment of the present application.
[0083] according to Figure 7 In an embodiment, for data written by a user IO command, the IO command is bound to a stream according to the characteristics of the IO command. For example, data to be written by an IO command accessing an address space with a high access frequency is bound to a user data stream (S1), and data to be written by an IO command accessing an address space with a low access frequency is bound to a user data stream (S2) (740). Valid data recovered from multiple dirty blocks is bound to different GC streams (Sg1 and / or Sg2) according to the characteristics of the dirty blocks from which the valid data comes or the selected strategy.
[0084] Select one of the strategies to select the dirty large block to be reclaimed. The strategy selection is also related to the occurrence of the specified condition. For example, in response to the number of free large blocks in the storage device (free large block set) being less than a threshold value (741), the dirty large block with the highest recycling priority is selected through strategy 742. For another example, in response to the difference between the maximum number of erases and the average number of erases of large blocks in the storage device being greater than a threshold value, the difference between the maximum number of erases and the minimum number of erases being greater than a threshold value, and / or the difference between the average number of erases and the minimum number of erases being greater than a threshold value (743), the dirty large block with the smallest number of erases is selected through strategy 744 and / or the dirty large block with the largest age is selected through strategy 745. For another example, the dirty large block for data reliability warning is selected through strategy 746.
[0085] It is also understandable that at the same time, there may be one or more strategies for selecting dirty chunks, so that the GC stream (Sg1) and the GC stream (Sg2) may not always have data to be written. Similarly, the user data stream (S1) and the user data stream (S2) may not always exist.
[0086] Figure 8 A schematic diagram of garbage data recovery according to yet another embodiment of the present application is shown.
[0087] The dirty chunks that have completed the effective data recovery are erased and released as free chunks. The released free chunks are recorded in, for example, the free chunk set 840.
[0088] An idle large block 842 is selected from the idle large block set 840 as a spare idle large block or an active large block. The spare idle large blocks or the active large blocks are set for different purposes. For example, large blocks (U1) and large blocks (U2) are large blocks used to carry user data streams, while large blocks (GU1) and large blocks (GU2) are large blocks used to carry GC streams. When selecting idle large blocks, different selection criteria are used according to different purposes. For example, in order to obtain an active large block (U1), an idle large block with the lowest number of erases is selected; in order to obtain an active large block (U2), an idle large block with a number of erases close to the average is selected; in order to obtain an active large block (GU1), an idle large block with the highest number of erases is selected; and in order to obtain an active large block (GU2), an idle large block with a number of erases close to the average is selected. As another example, in order to obtain an active large block (U1, U2), an idle large block with the lowest number of erases is selected, and in order to obtain an active large block (GU1, GU2), an idle large block with the highest number of erases is selected.
[0089] The spare chunks are selected using the same strategy as the free chunks. The spare chunks are classified into different types, for example, one type of spare free chunks is used as spare chunks for active chunks (U1, U2), while another type of spare free chunks is used as spare chunks for active chunks (GU1, GU2).
[0090] After the active chunk is full, the spare chunk can be immediately written with data as the active chunk without waiting for selecting a free chunk again.
[0091] In response to the active block being full, a free block is selected as a spare block or an active block (842). Further, in response to a new free block being released to the free block set, a check on the spare block and / or the active block is started (indicated by an arrow pointing from 835 to 842). In the check on the spare block and / or the active block, if there is a free block in the free block set whose erase count is far from the average erase count, the spare block is replaced with the free block (indicated by an arrow pointing from 846 to 840), or the active block to which data has not been written is replaced with the free block. Optionally, in response to a new free block being released to the free block set, if the erase count of the new free block is far from the free block with the average erase count, the spare block is replaced with the free block, or the active block to which data has not been written is replaced with the free block. It can be understood that if the number of erase times of the new free large block is much greater than the average erase times (for example, the difference is greater than a threshold value), the free large block is used to replace the active large block (U1 and / or U2) or the spare large block for carrying the user data stream that has not been written with data; if the number of erase times of the new free large block is much less than the average erase times (for example, the difference is less than a threshold value), the free large block is used to replace the active large block (GU1 and / or GU2) or the spare large block for carrying the GC stream that has not been written with data.
[0092] The <stream-large chunk> mapping unit 810 also checks whether the active large chunk has been active for too long. For example, if the large chunk (GU2) has been in existence for a long time due to lack of data from the GC stream, and the time exceeds the threshold, the <stream-large chunk> mapping unit 810 changes the mapping rule and maps one or more user data streams to the large chunk (GU2) to fill the large chunk (GU2) as soon as possible. When the active large chunk is filled, it is called "closing" the active large chunk (850).
[0093] Fig. 9 A schematic diagram of garbage data recovery according to yet another embodiment of the present application is shown.
[0094] An idle chunk (950) is selected from the idle chunk set 940 as a spare idle chunk or an active chunk. The spare idle chunks or active chunks are set for different purposes, for example, chunk (U1) and chunk (U2) are chunks for carrying user data streams, while chunk (GU1) and chunk (GU2) are chunks for carrying GC streams.
[0095] according to Fig. 9In the illustrated embodiment, free large blocks are selected at multiple times (951, 952, 953 and 954) and using multiple strategies (955, 956 and 957).
[0096] The timing of selecting a free block includes, for example, one or more of the active blocks are full, such as the active block (U1 or U2) is full (951) or the active block (GU1 or 2) is full (952), and a new free block is selected as the active block, or a spare block is used as the active block and a new free block is selected as the spare block. The timing of selecting a free block also includes, in response to a new free block being released (953) (added to the free block set), selecting a free block to replace the spare block or the active block that has not been written to data. The timing of selecting a free block also includes, the time when the spare block is used as the spare block is too long (954), such as exceeding a threshold, and selecting a free block to replace the spare block, so as to have the opportunity to select a spare block or an active block according to the updated status.
[0097] The strategy for selecting free large blocks includes, for example, selecting the free large blocks with the smallest number of erase times (955) for streams for hot data or for providing active large blocks (U1), selecting the free large blocks with the largest number of erase times for streams for cold data or for providing active large blocks (U2), selecting the free large blocks with the largest number of erase times (956) for GC streams or for providing active large blocks (GU1) / active large blocks (GU2), and / or selecting the free large blocks (957) whose erase times are far away from (too large or too small) the average erase times to promote wear leveling.
[0098] The <stream-large chunk> mapping unit 910 also checks whether the active large chunk has been active for too long (912). For example, if the active large chunk (GU2) has been in existence for a long time due to lack of data from the GC stream, and the time exceeds the threshold, the <stream-large chunk> mapping unit 910 changes the mapping rule and maps one or more user data streams to the large chunk (GU2) to fill the large chunk (GU2) as soon as possible. When the active large chunk is filled, it is called "closing" the active large chunk.
[0099] The write management unit 920 also controls whether the data of each stream is written to the NVM chip and / or the proportion of the amount (921). For example, the proportion of the amount of data written to the NVM chip by the GC stream in the specified time or unit time accounts for no more than 10% of the total amount of data written to the NVM chip; or, the ratio of the amount of data written to the NVM chip by the GC stream and the user data stream in the specified time or unit time is controlled not to exceed a specified range (922). Optionally, the write management unit 920 also allows the data of the GC stream to be written to the NVM chip or increases the proportion of the data of the GC stream in the amount of data written to the NVM chip based on the number of free blocks in the free block set being less than a threshold value (923). Optionally, the write management unit also controls the proportion of the data of each stream written to the NVM chip in the specified time or unit time, for example, limiting the ratio of the amount of data written to the NVM chip by the GC stream (Sg1) and the GC stream (Sg2) to not exceed a specified range.
[0100] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application. Obviously, those skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A garbage collection method, characterized in that: include: Get one or more streams and establish a binding relationship between the streams and the activity chunks; According to the binding relationship, write the data in the stream into the activity block corresponding to the same stream; The stream includes one or more user data streams and one or more GC streams, wherein the user data stream comes from data to be written by an IO command provided to the storage device, and the GC stream comes from data recovered from dirty large blocks; Among them, dirty large blocks to be collected by the garbage collection process are selected by multiple strategies. For valid data collected from multiple dirty large blocks, the data collected from the dirty large blocks are allocated to different GC streams according to the characteristics of the dirty large blocks from which the valid data comes or the strategies for selecting the dirty large blocks; Among them, various strategies include: The policy indicates selecting a dirty block with a minimum number of erases, the policy indicates selecting a dirty block with a maximum age, the policy indicates selecting a dirty block with a reliability warning, or the policy indicates selecting a dirty block with a highest priority.
2. The garbage collection method according to claim 1, characterized in that: in, A stream is allocated for data to be written by the IO command according to the address space accessed by the IO command or the characteristics of the IO command.
3. The garbage collection method according to claim 1, characterized in that: When the storage space of the active large block is full, the active large block is set to a closed state, and a free large block is obtained as the active large block.
4. The garbage collection method according to claim 1, characterized in that: Maintains static and / or dynamic binding relationships between streams and activity chunks.
5. The garbage collection method according to claim 4, characterized in that: According to the binding relationship between the stream and the active chunk, data is obtained from the specified stream, and a specified chunk is selected according to the stream to which the obtained data belongs, and the obtained data is written into the specified active chunk.
6. The garbage collection method according to claim 5, characterized in that: in, A specified activity block is obtained, and a stream corresponding to the activity block is selected according to a binding relationship between the stream and the activity block, and data is obtained from the selected stream and written into the specified activity block.
7. The garbage collection method according to claim 1, characterized in that: in, Allocating a first GC stream for data recovered from a dirty block with a minimum number of erases, a dirty block with a maximum age, and a dirty block with a reliability warning; The erase count is the average or total erase count of all physical blocks that make up the dirty chunk; The age of a dirty block refers to the interval between the time when data is written to it and the current time, or refers to the average value of the interval between the time when each piece of data recorded on it is written and the current time.
8. The garbage collection method according to claim 7, characterized in that: in, Allocate a second GC stream for data reclaimed from dirty chunks with the highest priority; The priority of the dirty block is a function of the number of erase times of the dirty block or the difference between the number of erase times of the dirty block and the average number of erase times of all dirty blocks in the dirty block set and the amount of valid data in the dirty block.
9. The garbage collection method according to claim 1, characterized in that: in, The strategy for selecting dirty large blocks includes selecting a dirty large block with the highest recycling priority if the data of the free large block is greater than a threshold.
10. The garbage collection method according to claim 1, characterized in that: in, The strategy for selecting dirty large blocks includes selecting the dirty large block with the smallest number of erase times or selecting the dirty large block with the largest age if the difference between the maximum number of erase times and the average number of erase times of large blocks in the storage device is greater than a threshold, the difference between the maximum number of erase times and the minimum number of erase times is greater than a threshold, and / or the difference between the average number of erase times and the minimum number of erase times is greater than a threshold.
11. The garbage collection method according to claim 1, characterized in that: In response to the active chunk being full, a free chunk is selected as a candidate chunk or an active chunk.
12. The garbage collection method according to claim 1, characterized in that: In response to a new free block being released to the free block set, if there is a free block in the free block set whose erase count is far from the average erase count, the free block is used to replace the spare block, or the free block is used to replace the active block to which data has not been written.
13. The garbage collection method according to any one of claims 1 to 12, characterized in that: in, In response to a new free block being released to the free block set, if the erasure count of the new free block is far from the free block with an average erasure count, the new free block is used to replace the spare block, or the new free block is used to replace the active block that has not been written with data.
14. The garbage collection method according to any one of claims 1 to 12, characterized in that: in, If the difference between the number of erase times of a new free large block and the average number of erase times is greater than a threshold, the new free large block is used to replace the active large block or spare large block for carrying the user data stream that has not yet been written with data; or, if the difference between the number of erase times of a new free large block and the average number of erase times is less than a threshold, the new free large block is used to replace the active large block or spare large block for carrying the GC stream that has not yet been written with data.
15. The garbage collection method according to claim 1, characterized in that: In response to the time that the spare chunk serves as the spare chunk exceeding a threshold, a free chunk is selected to replace the spare chunk.
16. The garbage collection method according to claim 13, characterized in that: in, The free chunk with the smallest number of erases and writes is selected as the first active chunk for carrying the user data stream.
17. The garbage collection method according to claim 16, characterized in that: in, The idle chunk with the erasure count closest to the average erasure count is selected as the second active chunk for carrying the user data stream.
18. The garbage collection method according to claim 13, characterized in that: in, The free large block with the largest number of erase and write times is selected as the first active large block for carrying the GC stream or the second active large block for carrying the GC stream.
19. The garbage collection method according to claim 13, characterized in that: in, The free chunk with the largest number of erases is selected as the first active chunk for carrying the GC flow.
20. The garbage collection method according to claim 13, characterized in that: in, The free chunk with the erase count closest to the average erase count is selected as the second active chunk for carrying the GC flow.
21. The garbage collection method according to claim 13, characterized in that: Among them, it also includes: If the active chunk remains active for too long, one or more user data streams are mapped to the active chunk.
22. The garbage collection method according to claim 13, characterized in that: Among them, it also includes: If the first active chunk for carrying the GC stream or the second active chunk for carrying the GC stream serves as an active chunk for too long, one or more user data streams are mapped to the active chunk.
23. The garbage collection method according to claim 1, characterized in that: Also includes: Control the ratio of each stream's data written into the NVM chip; Or control the proportion of data of each stream written into the NVM chip within a specified time or unit time; Or control the ratio of the amount of data written into the NVM chip by the GC flow and the user data flow within a specified time or unit time to not exceed a specified range.
24. The garbage collection method according to claim 23, characterized in that: in, According to the number of free large blocks in the free large block set being less than a threshold, the data of the GC stream is allowed to be written into the NVM chip or the proportion of the data of the GC stream in the amount of data written into the NVM chip is increased.
25. A storage device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the garbage collection method described in any one of claims 1 to 24 is implemented.
