Method for adjusting free physical block water level and storage device
Patent Information
- Application Number
- CN202310953508.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-07-31
AI Technical Summary
[0061]As can be seen, in at least one embodiment of this disclosure, by acquiring at least one physical block to be reclaimed, it is possible to scan whether there is valid data in each physical block to be reclaimed; then, based on the scan results, the current write mode is identified. For example, if there is no valid data in a preset number of physical blocks to be reclaimed in a continuous scan, the current write mode can be determined to be a sequential write mode, thereby realizing the pattern recognition of host write behavior. If the current write mode is identified as a sequential write mode, the written data will overwrite multiple consecutive logical blocks, causing the old physical blocks mapped by these logical blocks to become dirty physical blocks without valid data. Therefore, when the GC task reclaims these dirty physical blocks without valid data, it does not need to occupy free physical blocks to save the valid data in these dirty physical blocks (the valid data is zero). Therefore, in sequential write mode, raising the free physical block watermark to the first watermark, higher than the preset second watermark in random write mode, provides more free physical blocks for GC tasks and/or SWL tasks. Since GC tasks do not actually occupy these free physical blocks, they have no impact on sequential write tasks. Furthermore, these free physical blocks can be used by SWL tasks to reclaim cold data physical blocks. Since GC tasks generate free physical blocks, the consumption and generation of free physical blocks are balanced, resulting in no overall impact on sequential write tasks and improved write performance stability. Moreover, because GC tasks directly erase dirty physical blocks, compared to SWL tasks which need to first transfer valid data from cold data physical blocks before erasing them, GC tasks can generate free physical blocks more quickly, participating in write command processing and improving write command processing performance. Additionally, since SWL tasks can also generate free physical blocks by reclaiming cold data physical blocks, more free physical blocks can be provided for write command processing, improving write command processing performance and thus enhancing write performance stability.
Smart Images

Figure CN116974481B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of solid-state drive technology, specifically to a method for adjusting the free physical block water level and a storage device. Background Technology
[0002] With the development of hard drive technology, solid-state drives (SSDs) are gradually replacing hard disk drives (HDDs) to improve data storage stability and data retrieval efficiency.
[0003] Due to the unique characteristics of NAND flash memory in SSDs, which erase before writing, erase by block, and write by page, a certain amount of immediately usable free physical blocks need to be maintained to reclaim physical blocks containing written data, thus obtaining free physical blocks. The reclamation methods include garbage collection (GC) and static wear leveling (SWL) to reclaim cold data physical blocks.
[0004] To improve random write performance and increase over-provisioning (OP), the number of immediately available free physical blocks is typically kept at a low threshold (also known as the free physical block waterline) to reduce the impact of garbage collection (GC) tasks on write performance. When writing hot data sequentially within a small area of an SSD, the program / erase count (PE) of some physical blocks can become very high. To balance wear on the media, physical blocks containing cold data are reclaimed and released—this is known as static wear leveling (SWL). Since the proportion of valid data in the physical blocks containing cold data is relatively high, to minimize the impact on host write performance, the traditional approach in SSDs is for the control unit to reclaim cold data physical blocks at the lowest permissible rate, thus ensuring a relatively high host write speed. Before static wear leveling, the free physical block waterline determines the minimum rate of cold data reclamation; the higher the waterline, the faster the minimum reclamation rate, which in turn determines the extent of the decrease in host write performance. Therefore, there is a need to provide a method for adjusting the free physical block waterline to improve write performance stability. Summary of the Invention
[0005] At least one embodiment of this disclosure provides a method for adjusting the free physical block water level, a storage device, and a storage medium to improve write performance stability.
[0006] In a first aspect, embodiments of this disclosure propose a method for adjusting the water level of an idle physical block, including:
[0007] Obtain at least one physical block to be reclaimed;
[0008] Scan each physical block to be reclaimed to check for valid data;
[0009] Identify the current write mode based on the scan results;
[0010] If the current write mode is identified as sequential write mode, the free physical block water level is adjusted to the first water level, which is higher than the second water level preset in random write mode.
[0011] In some embodiments, identifying the current write mode based on the scan results includes:
[0012] If no valid data is found in a preset number of physical blocks to be reclaimed in a continuous scan, then the current write mode is determined to be sequential write mode.
[0013] In some embodiments, the method for adjusting the water level of the free physical block further includes:
[0014] If valid data is found in any physical block to be reclaimed, the current write mode is determined to be random write mode;
[0015] In random write mode, adjust the free physical block water level to the second water level.
[0016] In some embodiments, scanning each physical block to be reclaimed for valid data includes:
[0017] Scan the physical pages containing data within the physical blocks to be reclaimed;
[0018] Check the FTL table to see if there is a record of a physical page. The FTL table is used to record the mapping information from logical address to physical address.
[0019] If a record contains physical pages, then the data recorded in the physical pages is considered valid data.
[0020] In some embodiments, after scanning each physical block to be reclaimed for valid data, the method for adjusting the free physical block water level further includes:
[0021] Based on the scan results, maintain the value of the counting parameter corresponding to the sequential write mode, where the counting parameter represents the number of physical blocks to be reclaimed that are scanned continuously and do not contain valid data;
[0022] If no valid data is found in a preset number of physical blocks to be reclaimed, the current write mode is determined to be sequential write mode, including:
[0023] If the value of the counting parameter is greater than or equal to the preset quantity, then the current write mode is determined to be sequential write mode.
[0024] In some embodiments, based on the scan results, the value of the counting parameter corresponding to the sequential write mode is maintained, including:
[0025] For any physical block to be reclaimed, if the scan result shows that there is no valid data in the physical block to be reclaimed, the value of the count parameter is incremented by one; if the scan result shows that there is valid data in the physical block to be reclaimed, the value of the count parameter is cleared to zero.
[0026] In some embodiments, the method for adjusting the water level of the free physical block further includes:
[0027] If the value of the counting parameter is less than the preset number, then the current write mode is determined to be random write mode.
[0028] In some embodiments, the first water level is a fixed value or a dynamic value;
[0029] If the first water level is a dynamic value, then the effective data ratio is determined, where the effective data ratio is the proportion of the number of physical blocks to be recycled that have effective data to the total number of physical blocks to be recycled.
[0030] The first water level is determined based on the proportion of effective data, wherein the first water level is inversely correlated with the proportion of effective data; or, the first water level is determined based on the proportion of effective data, a preset minimum water level, and the proportion of historical effective data, wherein the first water level is positively correlated with the proportion of effective data.
[0031] In some embodiments, the difference between the first water level and the second water level is an adjustment value, which can be a fixed value or a dynamic value.
[0032] If the adjustment value is dynamic, then the effective data ratio is determined, where the effective data ratio is the proportion of the number of physical blocks to be recycled that have effective data to the total number of physical blocks to be recycled;
[0033] An adjustment value is determined based on the proportion of valid data, where the adjustment value is inversely correlated with the proportion of valid data; or,
[0034] The adjustment value is determined based on the proportion of effective data, the preset minimum water level, and the proportion of historical effective data. The adjustment value is positively correlated with the proportion of effective data.
[0035] In some embodiments, determining a first water level based on the proportion of valid data, a preset minimum water level, and the proportion of historical valid data includes:
[0036] The first water level line is adjusted at least once until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; where the target difference is the difference between the first water level line and the lowest water level line.
[0037] In some embodiments, the adjustment value is determined based on the proportion of valid data, a preset minimum water level, and the proportion of historical valid data, including:
[0038] The first water level is obtained by adjusting the second water level or the historical lowest water level at least once according to the adjustment value, until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein, the target difference is the difference between the first water level and the lowest water level.
[0039] In some embodiments, if the first water level is a dynamic value, then the first water level is determined to be less than or equal to a preset OP space.
[0040] In some embodiments, if the adjustment value is a dynamic value, then the first water level is determined to be less than or equal to a preset OP space.
[0041] In some embodiments, after scanning each physical block to be reclaimed for valid data, the method for adjusting the free physical block water level further includes:
[0042] Read valid data from the physical blocks to be reclaimed that contain valid data;
[0043] Write valid data to an empty physical block;
[0044] After writing is complete, erase all data in the physical block to be reclaimed that contains valid data, and obtain the corresponding free physical block.
[0045] In some embodiments, the method for adjusting the water level of the free physical block further includes:
[0046] If the idle physical block water level is adjusted to the first water level, then after erasing all data in the physical blocks to be reclaimed that contain valid data and obtaining the corresponding idle physical blocks, the idle physical blocks will be used as physical blocks in the candidate resource pool. The candidate resource pool is used to provide idle physical blocks to the resource pool corresponding to the idle physical block water level after the idle physical block water level is raised.
[0047] In some embodiments, the physical blocks to be recycled originate from at least one of the following physical blocks: dirty physical blocks targeted by garbage collection tasks, physical blocks that generate programming errors targeted by programming error recycling tasks, and cold data physical blocks targeted by static wear leveling tasks.
[0048] In some embodiments, the method for adjusting the water level of the free physical block further includes:
[0049] If any physical block generates a programming error, and it is necessary to close the physical block and reclaim the data in the physical block to an idle physical block, then after adjusting the water level of the idle physical block to the first water level, the programming error reclamation task is executed.
[0050] And / or,
[0051] If, when initiating a static wear leveling task, the effective data ratio of historically recovered dirty physical blocks is not zero and is less than the effective data ratio of cold physical blocks recovered by the static wear leveling task, then the idle physical block water level line is adjusted to the first water level line, and the static wear leveling task is executed.
[0052] Secondly, this disclosure also proposes an adjustment device for the water level of an idle physical block, comprising:
[0053] The acquisition unit is used to acquire at least one physical block to be reclaimed;
[0054] The scanning unit is used to scan each physical block to be reclaimed to see if there is any valid data.
[0055] The identification unit is used to identify the current write mode based on the scan results;
[0056] The adjustment unit is used to adjust the idle physical block water level to the first water level after the identification unit identifies the current write mode as sequential write mode. The first water level is higher than the preset second water level in random write mode.
[0057] Thirdly, embodiments of this disclosure also provide an electronic device, which includes a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the steps of the method for adjusting the free physical block water level as described in any embodiment of the first aspect.
[0058] Fourthly, embodiments of this disclosure also provide a storage device, wherein a control unit and an NVM chip are included, the control unit performing the steps of the method for adjusting the free physical block water level as described in any embodiment of the first aspect.
[0059] Fifthly, embodiments of this disclosure also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a program or instructions that cause a computer to perform the steps of the method for adjusting the free physical block water level as described in any embodiment of the first aspect.
[0060] In a sixth aspect, embodiments of this disclosure also provide a computer program product, wherein the computer program product includes a computer program stored in a computer-readable storage medium, and at least one processor of a computer reads from and executes the computer program from the computer-readable storage medium, causing the computer to perform the steps of the method for adjusting the free physical block water level as described in any embodiment of the first aspect.
[0061] As can be seen, in at least one embodiment of this disclosure, by acquiring at least one physical block to be reclaimed, it is possible to scan whether there is valid data in each physical block to be reclaimed; then, based on the scan results, the current write mode is identified. For example, if there is no valid data in a preset number of physical blocks to be reclaimed in a continuous scan, the current write mode can be determined to be a sequential write mode, thereby realizing the pattern recognition of host write behavior. If the current write mode is identified as a sequential write mode, the written data will overwrite multiple consecutive logical blocks, causing the old physical blocks mapped by these logical blocks to become dirty physical blocks without valid data. Therefore, when the GC task reclaims these dirty physical blocks without valid data, it does not need to occupy free physical blocks to save the valid data in these dirty physical blocks (the valid data is zero). Therefore, in sequential write mode, raising the free physical block watermark to the first watermark, higher than the preset second watermark in random write mode, provides more free physical blocks for GC tasks and / or SWL tasks. Since GC tasks do not actually occupy these free physical blocks, they have no impact on sequential write tasks. Furthermore, these free physical blocks can be used by SWL tasks to reclaim cold data physical blocks. Since GC tasks generate free physical blocks, the consumption and generation of free physical blocks are balanced, resulting in no overall impact on sequential write tasks and improved write performance stability. Moreover, because GC tasks directly erase dirty physical blocks, compared to SWL tasks which need to first transfer valid data from cold data physical blocks before erasing them, GC tasks can generate free physical blocks more quickly, participating in write command processing and improving write command processing performance. Additionally, since SWL tasks can also generate free physical blocks by reclaiming cold data physical blocks, more free physical blocks can be provided for write command processing, improving write command processing performance and thus enhancing write performance stability. Attached Figure Description
[0062] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings.
[0063] Figure 1 A schematic diagram of a storage device provided in an embodiment of this disclosure;
[0064] Figure 2 A large schematic diagram provided for an embodiment of this disclosure;
[0065] Figure 3 A schematic diagram illustrating a waste recycling method provided in this disclosure embodiment;
[0066] Figure 4 A flowchart of a waste recycling process provided in this disclosure embodiment;
[0067] Figure 5 A flowchart illustrating a method for adjusting the water level of an idle physical block, provided in an embodiment of this disclosure;
[0068] Figure 6 A schematic diagram of a write pattern recognition process provided in an embodiment of this disclosure;
[0069] Figure 7 This is a schematic diagram illustrating the performance distribution of sequential writes according to an embodiment of the present disclosure.
[0070] Figure 8 This is another schematic diagram of sequential write performance distribution provided by an embodiment of the present disclosure;
[0071] Figure 9 A schematic diagram of an adjustment device for the water level of an idle physical block provided in an embodiment of this disclosure;
[0072] Figure 10 This is an exemplary block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0073] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0074] The following detailed embodiments are provided to aid the reader in gaining a comprehensive understanding of the methods, apparatus, and / or systems described herein. However, various changes, modifications, and equivalents of the methods, apparatus, and / or systems described herein will become apparent upon understanding this disclosure. For example, the order of operations described herein is merely illustrative and is not limited to those orders set forth herein, but may be changed as will become clear upon understanding this disclosure, except for operations that must occur in a specific order. Furthermore, for the sake of clarity and conciseness, descriptions of features known upon understanding this disclosure may be omitted.
[0075] The features described herein may be implemented in different forms and should not be construed as being limited to the examples described herein. Rather, the examples described herein are provided merely to illustrate some of the many feasible ways of implementing the methods, apparatus, and / or systems described herein that will be clear upon understanding the disclosure of this application.
[0076] Throughout this specification, when a component is described as "connected to" or "attached to" another component, the component may be directly "connected to" or "attached to" the other component, or there may be one or more other components in between. Conversely, when an element is described as "directly connected to" or "directly attached to" another element, there may be no other elements in between. Similarly, similar expressions (e.g., "between" and "immediately between," and "adjacent to" and "closely adjacent to") should be interpreted in the same manner. As used herein, the term "and / or" includes any one of the relevant listed items or any combination of any two or more of the relevant listed items.
[0077] Although terms such as “first,” “second,” and “third” may be used herein to describe various components, assemblies, regions, layers, or parts, these components, assemblies, regions, layers, or parts are not limited by these terms. Rather, these terms are used only to distinguish one component, assembly, region, layer, or part from another. Therefore, without departing from the teaching of the examples described herein, the first component, first assembly, first region, first layer, or first part referred to as the first component, first assembly, first region, first layer, or first part may also be referred to as the second component, second assembly, second region, second layer, or second part.
[0078] The terminology used herein is for the purpose of describing various examples only and is not intended to limit disclosure. Unless the context clearly indicates otherwise, the singular form is intended to include the plural form as well. The terms “comprising,” “including,” and “having” indicate the presence of the features, quantities, operations, components, elements, and / or combinations thereof stated therein, but do not preclude the presence or addition of one or more other features, quantities, operations, components, elements, and / or combinations thereof.
[0079] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. Moreover, the terms "first," "second," and "third" used in this application do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.
[0080] Unless otherwise defined, all terms used herein (including technical and scientific terms) shall have the same meaning as understood based on the disclosure of this application and as commonly understood by one of ordinary skill in the art to which this disclosure pertains. Unless expressly defined herein, terms (such as those defined in a general dictionary) shall be interpreted as having the meaning consistent with their meaning in the context of the relevant art and in the disclosure of this application, and shall not be interpreted ideally or overly formally. The use of the term “may” herein with respect to examples or embodiments (e.g., regarding what an example or embodiment may include or implement) indicates the existence of at least one example or embodiment that includes or implements such a feature, while not all examples are limited thereto.
[0081] Solid State Disk (SSD) performance consistency refers to the stability of SSD performance, specifically, the limited fluctuations in performance metrics such as IOPS (IO operations per second) / BW (bandwidth). Better performance consistency leads to more stable user business performance and a better user experience. Different user data models have varying read / write pressures, requiring performance consistency to meet diverse read / write load scenarios. Many factors influence SSD performance consistency, such as the internal write arbitration strategy, backend NAND bandwidth allocation, and path control resource allocation. However, the most crucial factor is the SSD firmware's internal adjustment of the ratio between write tasks and garbage collection (GC) tasks to achieve dynamic performance balance. GC is a continuous background operation that reclaims free physical blocks. In low-pressure mixed read / write scenarios, user data pressure is low. If GC runs at full speed, the GC write speed is much faster than the host write speed, meaning the rate of free physical blocks provided exceeds the rate of free physical blocks consumed. This keeps the number of free physical blocks near a high level, hovering around the point where GC is either enabled or disabled. In this situation, the ratio of GC writes to Host writes is unbalanced, resulting in poor performance consistency of the solid-state drive.
[0082] Figure 1This is a schematic diagram of a storage device provided in an embodiment of this disclosure. The storage device 100 is coupled to a host and is used to provide storage capabilities to the host. The host and the storage device 100 can be coupled in various ways, including but not limited to, via 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), NVMe (NVM Express), Ethernet, Fibre Channel, wireless communication networks, etc. The host can be an information processing device capable of communicating with the storage device 100 in the above ways, such as a personal computer, tablet computer, server, laptop computer, network switch, router, cellular phone, personal digital assistant, etc. Storage device 100 includes interface 110, control unit 120, one or more NVM (Non-volatile Memory) chips 130 and DRAM (Dynamic Random Access Memory) 140.
[0083] NAND flash memory, phase change memory, FeRAM (Ferroelectric RAM), MRAM (Magnetic Random Access Memory), and RRAM (Resistive Random Access Memory) are common types of NVM.
[0084] Interface 110 is compatible with exchanging data with the host via methods such as SATA, IDE, USB, PCIe, NVMe, SAS, Ethernet, and Fibre Channel.
[0085] The control unit 120 is used to control data transfer between the interface 110, the NVM chip 130, and the DRAM 140. It is also used for memory management, mapping host logical addresses to NVM chip physical addresses, erase leveling, bad block management, etc. The control unit 120 can be implemented in various ways, including software, hardware, firmware, or a combination thereof. For example, the control unit 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 unit 120 may also include a processor or controller, in which software is executed to manipulate the hardware of the control unit 120 to process I / O (Input / Output) commands. The control unit 120 can also be coupled to the DRAM 140 and can access the data in the DRAM 140. The DRAM stores the FTL (Flash Translation Layer) table and / or caches the I / O command data.
[0086] The control unit 120 includes a flash interface controller (or media interface, media interface controller, flash channel controller), which is coupled to the NVM chip 130 and issues commands to the NVM chip 130 in accordance with the interface protocol of the NVM chip 130 to operate the NVM chip 130, and receives the command execution results output from the NVM chip 130. Known NVM chip interface protocols include "Toggle" and "ONFI".
[0087] 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, while multiple logic units within a NAND flash memory chip can execute commands and report status independently of each other.
[0088] Data is typically stored and retrieved in pages on NVM storage media. A block (also called a physical block) on an NVM storage medium contains multiple pages. A page on the storage medium (called a physical page) has a fixed size, such as 17664 bytes. Physical pages can also have other sizes.
[0089] In storage device 100, an FTL table is used to maintain mapping information from logical addresses to physical addresses. Logical addresses constitute the storage space of storage device 100 as perceived by upper-level software such as the operating system. Physical addresses are the addresses used to access the physical storage units of storage device 100. In existing technologies, address mapping can also be implemented using intermediate address formats. For example, a logical address can be mapped to an intermediate address, and then the intermediate address can be further mapped to a physical address. Optionally, the host accessing storage device 100 provides the FTL. The table structure storing the mapping information from logical addresses to physical addresses is called the FTL table. Typically, the data entries in the FTL table record the address mapping relationships in the storage device, in units of data pages. The FTL table is stored in DRAM 140 by control unit 120.
[0090] Figure 2 This is a schematic diagram of a large block provided for embodiments of the present disclosure. The large block comprises physical blocks from multiple logical units (referred to as logical unit groups). Preferably, each logical unit provides one physical block for the large block. As an example, large blocks are constructed over every 16 logical units (LUNs). Each large block comprises 16 physical blocks, each originating from one of the 16 logical units (LUNs). Figure 2 In the example, block 0 comprises physical block 0 from each logical unit (LUN), and block 1 comprises physical block 1 from each logical unit (LUN). There are also many other ways to construct blocks.
[0091] As an alternative approach, page stripes are constructed within large blocks, where physical pages with the same physical address within each logical unit (LUN) constitute a "page stripe". Figure 2 In this context, physical pages P0-0, P0-1, ..., and P0-x constitute page stripe 0. Physical pages P0-0, P0-1, ..., P0-14 are used to store user data, while physical pages P0-x are used to store checksum data calculated based on all user data within the stripe. Similarly, Figure 2 In this diagram, physical pages P2-0, P2-1, ..., and P2-x together form page stripe 2. Optionally, the physical page used to store the verification data can be located at any position within the page stripe.
[0092] When a logical page is repeatedly written to, the FTL (Framework Time Table) entry records the mapping between the logical page address and the latest physical page address. Data recorded at physical page addresses that have been written to but are no longer referenced (e.g., no record in the FTL) is called "garbage" data. Data that has been written to and referenced (e.g., has a record in the FTL) is called valid data, while "garbage" data is called dirty data. Physical blocks containing dirty data are called "dirty physical blocks," and physical blocks that have not been written to are called "free physical blocks." The storage device performs a garbage collection (GC) process to reclaim dirty data.
[0093] Storage in SSDs (e.g.) Figure 1 The NVM chip 130 in the SSD is organized in the form of physical blocks. Each physical block contains multiple physical pages, which are relatively small storage units. In an SSD, read and write operations can be performed at the physical page level; however, erase operations can only be performed at the physical block level. Erasing operations can take longer than read or write operations. To overwrite data stored in a physical block (i.e., replace old data with newer data), an erase operation on the entire physical block must be performed. To overwrite data in an SSD, the newer data is written to a free page in the SSD memory, rather than to the same page containing the old data. The page containing the old data is marked as an invalid page. Invalid pages remain invalid until the entire physical block containing the invalid page is erased.
[0094] During SSD operation, garbage collection (GC) is performed to maintain a free block pool. The free block pool contains physical blocks that can be used to write new data to. Free blocks are reclaimed from physical blocks that may contain both valid and invalid data. The garbage collection process first selects a target physical block for reclamation. Data in any valid pages (i.e., pages containing valid data) located within the target physical block is copied to another free physical block. The target physical block is then completely erased, becoming a free physical block in the free block pool.
[0095] Figure 3This is a schematic diagram of a waste recycling process provided in an embodiment of this disclosure. Physical blocks 0 and 1 are written with data. Physical pages 310, 312, 314, and 316 of physical block 0, 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, 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, indicated by grid boxes, contain dirty data. Physical pages 344, 342, 346, and 348 of physical block 1, indicated by blank boxes, contain valid data. Figure 3 In this context, physical pages indicated by grid lines contain dirty data, while physical pages indicated by blank boxes contain valid data.
[0096] To perform garbage collection, dirty physical blocks (e.g., physical block 0 and physical block 1) are scanned. Valid data is read from these blocks and written to free physical block 2. The changes in the physical page addresses of the valid data are also recorded in the FTL table. After all valid data in the dirty physical blocks is moved to physical block 2, the scanned physical blocks 0 and 1 are erased, thus making physical blocks 0 and 1 free physical blocks.
[0097] Figure 4 This is a flowchart illustrating a garbage collection process provided for an embodiment of this disclosure. The dirty physical block set 410 includes dirty physical blocks from some or all of the NVM chips in the storage device. The free physical block set 420 includes free physical blocks from some or all of the NVM chips in the storage device.
[0098] To implement garbage collection, garbage collection module 430 (e.g., implemented in control unit 120 or its CPU or controller) retrieves dirty physical blocks from dirty physical block set 410 and free physical blocks from free physical block set 420. It scans the dirty physical blocks and writes valid data from them to the free physical blocks. After all valid data in the retrieved dirty physical blocks has been 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.
[0099] The dirty physical block set 410 and the free physical block set 420 can be linked lists, linear lists, or other data structures used to represent sets. The addresses of physical blocks are recorded in the sets for accessing them.
[0100] Optionally, waste can be recycled in large blocks (instead of physical blocks).
[0101] The storage device also performs wear leveling to ensure that each physical block experiences roughly the same number of erases during use, thereby reducing the adverse impact of individual physical block depletion on the lifespan of the storage device.
[0102] SSDs typically provide over-provisioning (OP) space, meaning the actual physical storage capacity of the SSD is greater than the nominal logical address space provided to the host. The OP space is calculated as (Physical Capacity - Logical Capacity) / Logical Capacity. Garbage collection tasks use the additional physical storage space provided by OP as temporary working space.
[0103] Figure 5 This is a flowchart illustrating a method for adjusting the free physical block water level according to an embodiment of this disclosure. The executing entity of this method is an electronic device, including but not limited to storage devices (such as solid-state drives, flash memory devices, etc.), smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, servers, etc. The server can be a standalone server or a cluster of multiple servers, and can include locally located servers and cloud-based servers. The executing entity of this method can also be a control component of the storage device.
[0104] like Figure 5 As shown, the method for adjusting the water level of the idle physical block may include, but is not limited to, steps 501 to 504:
[0105] In step 501, at least one physical block to be recycled is obtained.
[0106] In this embodiment, the physical block to be reclaimed is a dirty physical block, which is a physical block containing dirty data. Dirty data is data recorded in the physical page address where data has been written but is no longer referenced (e.g., not recorded in the FTL table). The FTL table maintains mapping information from logical addresses to physical addresses. If a physical page address is not recorded in the FTL table, it indicates that the physical page address is not mapped to a logical page address. Since the logical page address is the storage space perceived by upper-level software such as the operating system, the data recorded in the physical page address is dirty data that the user cannot perceive and should be erased.
[0107] In this embodiment, the physical blocks to be reclaimed can be dirty physical blocks obtained from the dirty physical block set when the SSD performs garbage collection (GC) tasks. The dirty physical block set can be a linked list, a linear list, or other data structure used to represent a set. The addresses of the physical blocks are recorded in the set for accessing the physical blocks.
[0108] In step 502, each physical block to be recycled is scanned to check for valid data.
[0109] In this embodiment, for any physical block to be reclaimed, the physical pages containing data in the physical block to be reclaimed are scanned; then, the FTL table is checked to see if the physical page is recorded; if the physical page is recorded in the FTL table, the data recorded in the physical page is determined to be valid data, indicating that there is valid data in the physical block to be reclaimed; if the physical page address is not recorded in the FTL table, the data recorded in the physical page is determined to be dirty data.
[0110] For example, Figure 3 Physical block 0 shown is the physical block to be reclaimed. Physical pages 310, 312, 314, and 316 of physical block 0, indicated by the grid boxes, are not recorded in the FTL table; their data is dirty data. Physical pages 330, 332, 334, and 336 of physical block 0, indicated by the blank boxes, are recorded in the FTL table; their data is valid data. Therefore, scanning physical block 0 identifies physical pages 310, 312, 314, and 316, as well as 330, 332, 334, and 336, which contain data. Further, checking the FTL table for these physical pages reveals that since physical pages 330, 332, 334, and 336 are recorded in the FTL table, the data recorded in physical pages 330, 332, 334, and 336 is valid data, indicating the presence of valid data in physical block 0.
[0111] In step 503, the current write mode is identified based on the scan results.
[0112] In this embodiment, the SSD's write modes include sequential write mode and random write mode. Based on the scan results of whether there is valid data in each physical block to be reclaimed, it is possible to identify whether the current write mode is sequential write mode or random write mode.
[0113] In some embodiments, one way to identify the current write mode based on the scan results is as follows: if no valid data is found in a preset number of physical blocks to be reclaimed in a continuous scan, then the current write mode is determined to be a sequential write mode.
[0114] In this embodiment, considering that SSD write modes include sequential write mode and random write mode, in sequential write mode, the written data will overwrite multiple consecutive Logical Block Addresses (LBAs), causing the old physical blocks mapped by these LBAs to become dirty physical blocks without valid data. For example, in sequential write mode, SSDs typically perform large-capacity file writes, such as large-capacity file copying, video editing, etc., which will overwrite the data in multiple consecutive LBAs (i.e., replace the old data with the newer data), causing the data in the old physical blocks mapped by these LBAs to become dirty data, without valid data. Therefore, a preset threshold is set to determine whether the current write mode is sequential write mode. If no valid data is found in any of the preset number of physical blocks to be reclaimed, the data stored in these physical blocks to be reclaimed is dirty data, indicating that the current write mode is sequential write mode. If valid data is found in any physical block to be reclaimed, the current write mode is determined to be random write mode.
[0115] For example, if the preset number of consecutive scans is 10, and no valid data is found in any of the 10 physical blocks to be reclaimed, it means that the current write mode is sequential write mode; if no valid data is found in any of the 3 physical blocks to be reclaimed, but valid data is found in the 4th physical block to be reclaimed, it means that the current write mode is not sequential write mode (that is, the current write mode is random write mode).
[0116] It should be noted that in other embodiments of this disclosure, other methods can be used to identify whether the write mode is random write mode or sequential write mode, while the method of counting sequential writes in this embodiment is simpler, more direct, and easier to implement.
[0117] In step 504, if the current write mode is identified as sequential write mode, the idle physical block water level is adjusted to the first water level, which is higher than the second water level preset in random write mode.
[0118] In this embodiment, in sequential write mode, since the written data overwrites multiple consecutive logical blocks, the old physical blocks mapped to these logical blocks become dirty physical blocks without valid data. Therefore, when the GC task reclaims these dirty physical blocks without valid data, it does not need to occupy free physical blocks to save the valid data in these dirty physical blocks (the valid data is zero). Therefore, in sequential write mode, raising the free physical block watermark to the first watermark, which is higher than the second watermark preset in random write mode, can provide more free physical blocks for GC tasks and / or SWL tasks. Since the GC task does not actually occupy these free physical blocks, it has no impact on the sequential write task. Moreover, these free physical blocks can be used for SWL tasks to reclaim cold data physical blocks, while the GC task generates free physical blocks, so that the consumption and generation of free physical blocks can be balanced, and overall there is no impact on the sequential write task, thus improving write performance stability.
[0119] It should be noted that the free physical block waterline is the threshold number of free physical blocks that can be used in the reserved space (i.e., OP space) of the solid-state storage device.
[0120] However, when the write mode is determined to be not sequential (i.e., the current write mode is random write), the physical blocks reclaimed by the GC task may contain valid data. The reclamation process needs to occupy free physical blocks to accommodate the valid data in the blocks to be reclaimed. If more free physical blocks are used for the GC task, it will affect the write task. For example, the GC task consumes system bandwidth, leading to a decrease in actual write bandwidth, thus affecting write performance stability. Therefore, in random write mode, lowering the free physical block watermark to a second watermark allows more free physical blocks to be used for write tasks, improving the processing performance of write commands and thus enhancing write performance stability.
[0121] As can be seen, the embodiments of this disclosure can realize pattern recognition of host write behavior, and then automatically adjust the idle physical block waterline to improve write performance stability. Specifically, by acquiring at least one physical block to be reclaimed, it is possible to scan whether there is valid data in each physical block to be reclaimed; then, based on the scanning results, the current write mode is identified. For example, if there is no valid data in a preset number of physical blocks to be reclaimed in a continuous scan, the current write mode can be determined to be a sequential write mode, thus realizing pattern recognition of host write behavior. If the current write mode is identified as a sequential write mode, the idle physical block waterline is raised to a first waterline, which is higher than the preset second waterline in the random write mode. This provides more idle physical blocks for GC tasks and / or SWL tasks. Since the GC task reclaims dirty physical blocks without valid data, it does not need to occupy idle physical blocks. Therefore, the provided idle physical blocks are used for the SWL task to reclaim cold data physical blocks, while the GC task generates idle physical blocks, so that the consumption and generation of idle physical blocks are balanced, which has no impact on the write task and improves write performance stability. Furthermore, because GC tasks directly erase dirty physical blocks, compared to SWL tasks which require transferring valid data from cold physical blocks before erasing them, GC tasks can generate free physical blocks more quickly, enabling them to participate in write tasks and improving write command processing performance. In addition, since SWL tasks can also generate free physical blocks from cold physical blocks, more free physical blocks can be provided for write command processing, further improving write command performance and thus enhancing write performance stability.
[0122] Based on the above embodiments, after scanning whether there is valid data in each physical block to be reclaimed in step 502, a GC task can be executed. The GC process is described as follows:
[0123] Read the valid data from the physical block to be reclaimed that contains valid data; write the valid data to the free physical block; after writing is complete, erase all data in the physical block to be reclaimed that contains valid data to obtain the corresponding free physical block.
[0124] In this embodiment, valid data is written to a free physical block, which is located in the reserved space (OP) provided by the SSD. Since upper-level software such as the operating system cannot perceive the OP space, the user will not be aware that the free physical block is used for GC tasks. It should be noted that the free physical blocks contained in the OP space can be fixed physical blocks or dynamically partitioned physical blocks.
[0125] In some embodiments, after adjusting the idle physical block water level to the first water level in step 504, that is, after raising the idle physical block water level, all data in the physical blocks to be reclaimed containing valid data is erased during the GC process. After obtaining the corresponding idle physical blocks, the idle physical blocks are used as physical blocks in the candidate resource pool. The candidate resource pool is used to provide idle physical blocks to the resource pool corresponding to the idle physical block water level after the idle physical block water level is raised.
[0126] In this embodiment, since the GC task reclaims dirty physical blocks without valid data in sequential write mode, there is no need to occupy free physical blocks to store the valid data in these dirty physical blocks (the valid data is zero). Therefore, the GC task is more efficient than the SWL task in reclaiming cold data physical blocks. Thus, the free physical blocks obtained by the GC task from erasing dirty physical blocks are used as free physical blocks introduced to raise the free physical block water level, thereby efficiently raising the free physical block water level.
[0127] Based on the above embodiments, after scanning for valid data in each physical block to be reclaimed in step 502, the value of the counting parameter corresponding to the sequential write mode is maintained based on the scan results. The counting parameter represents the number of consecutively scanned physical blocks to be reclaimed that do not contain valid data. Based on the value of the counting parameter corresponding to the sequential write mode... Figure 6 This is a schematic diagram of a write pattern recognition process provided in an embodiment of the present disclosure, such as... Figure 6 As shown, including but not limited to the following steps 601 to 606:
[0128] In step 601, for any physical block to be recycled, scan whether there is valid data in the physical block to be recycled; if the scan result is that there is no valid data in the physical block to be recycled, then proceed to step 602; if the scan result is that there is valid data in the physical block to be recycled, then proceed to step 603.
[0129] In step 602, the value of the count parameter is incremented by one, and step 604 is executed.
[0130] In step 603, the value of the counting parameter is cleared to zero, and step 604 is executed.
[0131] In step 604, it is determined whether the value of the counting parameter is greater than or equal to the preset quantity; if so, step 605 is executed; otherwise, step 606 is executed.
[0132] In step 605, the current write mode is determined to be sequential write mode.
[0133] In step 606, the current write mode is determined to be random write mode.
[0134] In this embodiment, since the counting parameter represents the number of continuously scanned physical blocks to be reclaimed that do not contain valid data, when the value of the counting parameter accumulates to a preset number, it indicates that the SSD's write mode has changed from random write mode to sequential write mode. In sequential write mode, the physical blocks to be reclaimed will be continuously scanned. If there is still no valid data in the physical blocks to be reclaimed, the value of the counting parameter will continue to accumulate. That is, the value of the counting parameter will be greater than the preset number. However, as long as valid data is found in a physical block to be reclaimed, the sequential write mode will be exited and the SSD will enter random write mode. In order to monitor whether it will re-enter sequential write mode, it is necessary to recount. Therefore, the value of the counting parameter is cleared to zero, and the value of the counting parameter is accumulated from zero again until the value of the counting parameter accumulates to a preset number, at which point it will re-enter sequential write mode.
[0135] It should be noted that in sequential write mode, the system continuously monitors whether to exit or re-enter sequential write mode, at preset intervals, or based on response requirements. This allows for timely responses to changes in write mode and adaptive adjustments to the water level, thereby improving write performance stability.
[0136] Based on the above embodiments, in step 504, if the current write mode is identified as sequential write mode, the idle physical block water level line is adjusted to the first water level line, which is a fixed value or a dynamic value.
[0137] If the first water level is a fixed value, those skilled in the art can configure the specific value of the fixed value based on actual needs so that the first water level is higher than the second water level preset in the random write mode. This embodiment does not limit the specific value of the fixed value.
[0138] If the first water level is a dynamic value, then the effective data ratio is determined, where the effective data ratio is the proportion of the number of physical blocks to be recycled that contain effective data to the total number of physical blocks to be recycled; furthermore, the first water level is determined using the following two methods:
[0139] Method 1: Determine the first water level line based on the proportion of effective data, wherein the first water level line is inversely correlated with the proportion of effective data.
[0140] In this embodiment, the lower the proportion of valid data, the higher the determined first water level; conversely, the higher the proportion of valid data, the lower the determined first water level. This embodiment does not limit the specific inverse correlation between the first water level and the proportion of valid data; those skilled in the art can configure a specific inverse correlation according to actual needs.
[0141] Method 2: Determine the first water level based on the proportion of effective data, the preset minimum water level, and the proportion of historical effective data. The first water level is positively correlated with the proportion of effective data.
[0142] In this embodiment, the preset minimum water level can be the second water level in random write mode, or it can be lower than the second water level in random write mode. In this embodiment, the first water level is adjusted at least once until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein, the target difference is the difference between the first water level and the minimum water level.
[0143] That is, based on the condition that (the proportion of effective data / the target difference) is equal to or converges to the proportion of historical effective data, the first water level is determined.
[0144] It should be noted that if the first water level is a dynamic value, it needs to be less than or equal to the preset OP space. Otherwise, if the first water level is higher than the OP space, the user will perceive that some physical blocks are occupied (these physical blocks are used for GC tasks or SWL tasks, so they are displayed as occupied). More seriously, physical blocks that exceed the OP space should be used for write tasks, but are used by GC tasks, which reduces the efficiency of write task processing, reduces write performance, and thus reduces the stability of write performance.
[0145] Based on the above embodiments, in step 504, if the current write mode is identified as sequential write mode, the idle physical block water level line is adjusted to the first water level line. The difference between the first water level line and the second water level line under random write mode is the adjustment value, wherein the adjustment value is a fixed value or a dynamic value.
[0146] If the adjustment value is a fixed value, those skilled in the art can configure the specific value of the fixed value based on actual needs so that the first water level is higher than the second water level preset in the random write mode. This embodiment does not limit the specific value of the fixed value.
[0147] If the adjustment value is dynamic, then the effective data ratio is determined, where the effective data ratio is the proportion of the number of physical blocks to be reclaimed that contain effective data to the total number of physical blocks to be reclaimed; furthermore, the adjustment value is determined using the following two methods:
[0148] Method 1: Determine the adjustment value based on the proportion of valid data, where the adjustment value is inversely correlated with the proportion of valid data.
[0149] In this embodiment, the lower the proportion of valid data, the higher the determined adjustment value; conversely, the higher the proportion of valid data, the lower the determined adjustment value. This embodiment does not limit the specific inverse correlation between the adjustment value and the proportion of valid data; those skilled in the art can configure a specific inverse correlation according to actual needs.
[0150] Method 2: Determine the adjustment value based on the proportion of effective data, the preset minimum water level, and the proportion of historical effective data. The adjustment value is positively correlated with the proportion of effective data.
[0151] In this embodiment, the preset minimum water level can be the second water level in random write mode, or it can be lower than the second water level in random write mode. In this embodiment, the first water level is obtained by adjusting the second water level or the historical minimum water level at least once according to the adjustment value, until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein, the target difference is the difference between the first water level and the minimum water level.
[0152] It should be noted that if the adjustment value is dynamic, the first water level (i.e., the water level obtained after adjusting the second water level according to the adjustment value) needs to be less than or equal to the preset OP space. Otherwise, once the first water level is higher than the OP space, the user will perceive that some physical blocks are occupied (these physical blocks are used for GC tasks or SWL tasks, so they are displayed as occupied). More seriously, physical blocks that exceed the OP space should be used for write tasks, but are used by GC tasks, which reduces the efficiency of write task processing, reduces write performance, and thus reduces the stability of write performance.
[0153] Based on the above embodiments, the physical blocks to be recycled come from at least one of the following physical blocks: dirty physical blocks targeted by garbage collection tasks, physical blocks that generate programming errors targeted by programming error collection tasks, and cold data physical blocks targeted by static wear leveling (SWL) tasks.
[0154] If any physical block generates a programming error, requiring the physical block to be closed and its data reclaimed to an idle physical block, the idle physical block watermark is directly adjusted to the first watermark, and then the programming error reclamation task is executed. Raising the idle physical block watermark to the first watermark increases the number of idle physical blocks available for the programming error reclamation task, improving the efficiency of reclamating the physical block that generated the programming error. This allows for faster acquisition of idle physical blocks produced by the programming error reclamation task, which can then be used for write tasks, improving the processing performance of write commands and consequently enhancing the stability of write command processing performance.
[0155] If, when initiating a static wear leveling task, the proportion of valid data in historically recovered dirty physical blocks is not zero but less than the proportion of valid data in cold physical blocks recovered by the static wear leveling task, then the idle physical block waterline is directly adjusted to the first waterline, and the static wear leveling task is executed. Raising the idle physical block waterline to the first waterline provides more idle physical blocks for the static wear leveling task, improving its efficiency and allowing for faster acquisition of idle physical blocks for write tasks, thus improving write command processing performance and consequently, the stability of write command processing performance.
[0156] The method for adjusting the free physical block waterline disclosed in the above embodiments can effectively improve the stability of host write performance in long-term, small-range sequential write scenarios. Here, "small range" refers to the SSD capacity; for example, for SSDs with capacities of 7.68T, 3.84T, or 1.92T, the small range is 10G. For other capacities of SSDs, those skilled in the art can determine the value of the small range based on the SSD capacity. Taking the stability test of sequential write performance when triggering Static Wear Leveling (SWL) as an example, sequential writes are performed to a 10G logical block address (LBA) range. Before implementing the free physical block waterline adjustment method provided in this embodiment, the sequential write performance distribution is as follows: Figure 7 As shown, Figure 7 The horizontal axis represents time, and the vertical axis represents sequential write performance (or bandwidth), in bytes per second (Byte / s). The horizontal line represents the average sequential write performance (which is statistically estimated to be 85% of the optimal write performance). Therefore, Figure 7 In practice, sequential write performance is below average. After implementing the method for adjusting the free physical block waterline provided in this embodiment, the sequential write performance distribution is as follows: Figure 8 As shown, sequential write performance is generally above average, thus improving write performance stability.
[0157] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art will understand that the embodiments of this disclosure are not limited to the described order of actions, because according to the embodiments of this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art will understand that the embodiments described in the specification are all optional embodiments.
[0158] Figure 9 This diagram illustrates a device for adjusting the free physical block water level according to an embodiment of this disclosure. This device can be applied to electronic devices, including but not limited to solid-state drives, smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, and servers. The server can be a standalone server or a cluster of multiple servers, and can include locally located servers and cloud-based servers. The device for adjusting the free physical block water level provided in this disclosure can execute the processing flow provided in various embodiments of the free physical block water level adjustment method, such as... Figure 9 As shown, the adjustment device for the water level of the idle physical block includes, but is not limited to: an acquisition unit 91, a scanning unit 92, an identification unit 93, and an adjustment unit 94. The functions of each unit are described below:
[0159] Acquisition unit 91 is used to acquire at least one physical block to be recycled;
[0160] Scanning unit 92 is used to scan each physical block to be reclaimed for valid data;
[0161] Identification unit 93 is used to identify the current write mode based on the scan results;
[0162] The adjustment unit 94 is used to adjust the idle physical block water level line to the first water level line after the identification unit 93 identifies the current write mode as sequential write mode. The first water level line is higher than the second water level line preset in random write mode.
[0163] In some embodiments, the identification unit 93 is used to determine that the current write mode is a sequential write mode after the scanning unit 92 has continuously scanned a preset number of physical blocks to be recycled and found that there is no valid data.
[0164] In some embodiments, the identification unit 93 is further configured to determine that the current write mode is a random write mode after the scanning unit detects that there is valid data in any physical block to be reclaimed;
[0165] Adjustment unit 94 is also used to adjust the free physical block water level to the second water level in random write mode.
[0166] In some embodiments, the scanning unit 92 is configured to:
[0167] Scan the physical pages containing data within the physical blocks to be reclaimed;
[0168] Check the FTL table to see if there is a record of a physical page. The FTL table is used to record the mapping information from logical address to physical address.
[0169] If a record contains physical pages, then the data recorded in the physical pages is considered valid data.
[0170] In some embodiments, the device for adjusting the free physical block water level line further includes a counting unit for maintaining the value of the counting parameter corresponding to the sequential write mode based on the scanning result of the scanning unit 92, wherein the counting parameter represents the number of continuously scanned physical blocks to be reclaimed that do not contain valid data;
[0171] The identification unit 93 is used to determine that the current write mode is sequential write mode after the value of the counting parameter maintained by the counting unit is greater than or equal to a preset number.
[0172] In some embodiments, the counting unit is used for:
[0173] For any physical block to be recycled, if the scanning result of the scanning unit 92 is that there is no valid data in the physical block to be recycled, the value of the counting parameter is incremented by one; if the scanning result of the scanning unit 92 is that there is valid data in the physical block to be recycled, the value of the counting parameter is cleared to zero.
[0174] In some embodiments, the identification unit 93 is further configured to determine that the current write mode is a random write mode after the value of the counting parameter maintained by the counting unit is less than a preset number.
[0175] In some embodiments, the first water level is a fixed value or a dynamic value;
[0176] If the first water level is a dynamic value, the adjustment device for the water level of the idle physical block also includes a water level determination unit, used for:
[0177] Determine the effective data ratio, where the effective data ratio is the proportion of the number of physical blocks to be reclaimed that contain effective data to the total number of physical blocks to be reclaimed;
[0178] The first water level is determined based on the proportion of effective data, wherein the first water level is inversely correlated with the proportion of effective data; or, the first water level is determined based on the proportion of effective data, a preset minimum water level, and the proportion of historical effective data, wherein the first water level is positively correlated with the proportion of effective data.
[0179] In some embodiments, the water level determination unit determines a first water level based on the proportion of valid data, a preset minimum water level, and the proportion of historical valid data, including:
[0180] The first water level line is adjusted at least once until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; where the target difference is the difference between the first water level line and the lowest water level line.
[0181] In some embodiments, if the first water level is a dynamic value, then the first water level is determined to be less than or equal to a preset OP space.
[0182] In some embodiments, the difference between the first water level line and the second water level line is an adjustment value, which can be a fixed value or a dynamic value.
[0183] If the adjustment value is dynamic, the adjustment device for the water level of the idle physical block also includes an adjustment value determination unit, used for:
[0184] Determine the effective data ratio, where the effective data ratio is the proportion of the number of physical blocks to be reclaimed that contain effective data to the total number of physical blocks to be reclaimed;
[0185] The adjustment value is determined based on the proportion of valid data, wherein the adjustment value is inversely correlated with the proportion of valid data; or, the adjustment value is determined based on the proportion of valid data, a preset minimum water level, and the proportion of historical valid data, wherein the adjustment value is positively correlated with the proportion of valid data.
[0186] In some embodiments, the adjustment value determining unit determines the adjustment value based on the proportion of valid data, a preset minimum water level, and the proportion of historical valid data, including:
[0187] The first water level is obtained by adjusting the second water level or the historical lowest water level at least once according to the adjustment value, until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein, the target difference is the difference between the first water level and the lowest water level.
[0188] In some embodiments, if the adjustment value is a dynamic value, then the first water level is determined to be less than or equal to a preset OP space.
[0189] In some embodiments, the device for adjusting the water level of the idle physical block further includes a recycling unit for:
[0190] After scanning unit 92 scans each physical block to be reclaimed to see if there is valid data, it reads the valid data in the physical block to be reclaimed that contains valid data.
[0191] Write valid data to an empty physical block;
[0192] After writing is complete, erase all data in the physical block to be reclaimed that contains valid data, and obtain the corresponding free physical block.
[0193] In some embodiments, the adjustment unit 94 is further configured to adjust the idle physical block water level to the first water level, and after the recycling unit erases all data in the physical block to be recycled containing valid data to obtain the corresponding idle physical block, use the idle physical block as a physical block in the candidate resource pool. The candidate resource pool is configured to provide idle physical blocks to the resource pool corresponding to the idle physical block water level after the idle physical block water level is raised.
[0194] In some embodiments, the physical blocks to be recycled originate from at least one of the following physical blocks: dirty physical blocks targeted by garbage collection tasks, physical blocks that generate programming errors targeted by programming error recycling tasks, and cold data physical blocks targeted by static wear leveling tasks.
[0195] In some embodiments, the device for adjusting the water level of the free physical block further includes an execution unit for:
[0196] If any physical block generates a programming error, and it is necessary to close the physical block and reclaim the data in the physical block to the idle physical block, then after the adjustment unit 94 adjusts the water level of the idle physical block to the first water level, the programming error reclamation task is executed.
[0197] And / or,
[0198] If, when initiating a static wear leveling task, the effective data ratio of historically recovered dirty physical blocks is not zero and is less than the effective data ratio of cold data physical blocks recovered by the static wear leveling task, then the water level line of the idle physical blocks is adjusted to the first water level line in the adjustment unit 94, and the static wear leveling task is executed.
[0199] As can be seen, in at least one embodiment of the idle physical block water level adjustment device disclosed herein, the host write behavior pattern recognition can be realized, thereby automatically adjusting the idle physical block water level to improve write performance stability. Specifically, by acquiring at least one physical block to be reclaimed, it is possible to scan whether there is valid data in each physical block to be reclaimed; then, based on the scanning results, the current write mode is identified. For example, if there is no valid data in a preset number of physical blocks to be reclaimed in a continuous scan, the current write mode can be determined to be a sequential write mode, thus realizing the pattern recognition of host write behavior. If the current write mode is identified as a sequential write mode, the idle physical block water level is raised to a first water level, which is higher than the preset second water level in the random write mode. This provides more idle physical blocks for GC tasks and / or SWL tasks. Since the GC task reclaims dirty physical blocks without valid data, it does not need to occupy idle physical blocks. Therefore, the provided idle physical blocks are used for the SWL task to reclaim cold data physical blocks, while the GC task generates idle physical blocks, thus balancing the consumption and generation of idle physical blocks, having no impact on the write task, and improving write performance stability. Furthermore, because GC tasks directly erase dirty physical blocks, compared to SWL tasks which require transferring valid data from cold physical blocks before erasing them, GC tasks can generate free physical blocks more quickly, enabling them to participate in write tasks and improving write command processing performance. In addition, since SWL tasks can also generate free physical blocks from cold physical blocks, more free physical blocks can be provided for write command processing, further improving write command performance and thus enhancing write performance stability.
[0200] In this embodiment of the disclosure, a storage device (or solid-state storage device, etc.) is provided, including: a memory and a controller. The controller executes a method for adjusting the free physical block water level in any of the above method embodiments, wherein the memory may be an NVM (Non-Volatile Memory) chip.
[0201] Figure 10This is an exemplary block diagram of an electronic device provided in an embodiment of this disclosure. Figure 10 As shown, the electronic device includes: a memory 1001, a processor 1002, and a computer program stored on the memory 1001. It is understood that the memory 1001 in this embodiment may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
[0202] In some implementations, memory 1001 stores elements such as executable modules or data structures, or subsets thereof, or extended sets thereof: operating systems and applications.
[0203] The operating system includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic tasks and handle hardware-based tasks. The application programs include various applications, such as media players and browsers, used to implement various application tasks. The program implementing the method for adjusting the free physical block water level provided in this embodiment can be included in the application programs.
[0204] In this embodiment of the disclosure, at least one processor 1002 executes the steps of the various embodiments of the method for adjusting the free physical block water level provided in this disclosure by calling a program or instruction stored in at least one memory 1001, specifically, a program or instruction stored in an application.
[0205] The method for adjusting the free physical block water level provided in this disclosure can be applied to, or implemented by, the processor 1002. The processor 1002 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the hardware of the processor 1002 or by instructions in software form. The processor 1002 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor.
[0206] The steps of the method for adjusting the free physical block water level provided in this disclosure can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 1001, and processor 1002 reads the information in memory 1001 and combines it with hardware to complete the steps of the method.
[0207] This disclosure also proposes a computer-readable storage medium storing a program or instructions that cause a computer to perform steps, such as those in the embodiments of the method for adjusting the free physical block water level, which will not be repeated here to avoid repetition. The computer-readable storage medium can be a non-transitory computer-readable storage medium.
[0208] This disclosure also proposes a computer program product comprising a computer program stored in a computer-readable storage medium, which may be a non-transitory computer-readable storage medium. At least one processor of a computer reads and executes the computer program from the computer-readable storage medium, causing the computer to perform steps as described in various embodiments of the method for adjusting the free physical block waterline; these steps will not be repeated here to avoid repetition.
[0209] The apparatus or device embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate, and the components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0210] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions for a computer device (which may be a personal computer, server, or network device, etc.) to execute the various embodiments or some parts of the embodiments.
[0211] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above. For the sake of brevity, they are not provided in detail; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for adjusting the water level of an idle physical block, comprising: Obtain at least one physical block to be reclaimed; Scan each of the physical blocks to be reclaimed to check for valid data; Identify the current write mode based on the scan results; SSD write modes include sequential write mode and random write mode. The current write mode is identified as sequential write mode or random write mode based on the scan results of whether there is valid data in each physical block to be reclaimed. If no valid data is found in a preset number of physical blocks to be reclaimed in a continuous scan, then the current write mode is determined to be sequential write mode. If valid data is found in any physical block to be reclaimed, the current write mode is determined to be random write mode; If the current write mode is identified as sequential write mode, the free physical block water level is adjusted to the first water level. The first water level is higher than the second water level preset in random write mode, which can provide more free physical blocks for GC tasks and / or SWL tasks. Free physical blocks are used for SWL tasks to reclaim cold data physical blocks, while GC tasks generate free physical blocks, so that the consumption of free physical blocks and the generation of free physical blocks can be balanced. The free physical block waterline is the threshold number of usable free physical blocks in the reserved space of a solid-state storage device.
2. The method according to claim 1, wherein, The method further includes: In the random write mode, the idle physical block water level is adjusted to the second water level.
3. The method according to any one of claims 1 to 2, wherein, The scanning of each of the physical blocks to be reclaimed to check for valid data includes: Scan the physical pages containing data in the physical block to be recycled; The physical page is checked in the FTL table to see if it is recorded. The FTL table is used to record mapping information from logical address to physical address. If the physical page is recorded, then the data recorded in the physical page is determined to be valid data.
4. The method according to claim 1, wherein, After scanning each of the physical blocks to be reclaimed for valid data, the method further includes: Based on the scan results, maintain the value of the counting parameter corresponding to the sequential write mode, wherein the counting parameter represents the number of physical blocks to be reclaimed that are continuously scanned and do not contain valid data; If no valid data is found in a preset number of physical blocks to be reclaimed in a continuous scan, then the current write mode is determined to be a sequential write mode, including: If the value of the counting parameter is greater than or equal to the preset quantity, then the current write mode is determined to be sequential write mode.
5. The method according to claim 4, wherein, The process of maintaining the value of the counting parameter corresponding to the sequential write mode based on the scan results includes: For any of the physical blocks to be recycled, if the scan result indicates that there is no valid data in the physical block to be recycled, the value of the counting parameter is incremented by one; if the scan result indicates that there is valid data in the physical block to be recycled, the value of the counting parameter is cleared to zero.
6. The method according to claim 4, wherein, The method further includes: If the value of the counting parameter is less than the preset number, then the current write mode is determined to be a random write mode.
7. The method according to claim 1, wherein, The first water level can be a fixed value or a dynamic value; If the first water level is a dynamic value, then the effective data ratio is determined, wherein the effective data ratio is the ratio of the number of physical blocks to be recycled with effective data to the total number of physical blocks to be recycled; Based on the proportion of effective data, the first water level is determined, wherein the first water level is inversely correlated with the proportion of effective data; or... Based on the effective data ratio, the preset minimum water level, and the historical effective data ratio, the first water level is determined, wherein the first water level is positively correlated with the effective data ratio.
8. The method according to claim 1, wherein, The difference between the first water level line and the second water level line is an adjustment value, which can be a fixed value or a dynamic value. If the adjustment value is a dynamic value, then the effective data ratio is determined, wherein the effective data ratio is the ratio of the number of physical blocks to be recycled that have effective data to the total number of physical blocks to be recycled; Based on the effective data ratio, the adjustment value is determined, wherein the adjustment value is inversely correlated with the effective data ratio; or, The adjustment value is determined based on the effective data ratio, the preset minimum water level, and the historical effective data ratio, wherein the adjustment value is positively correlated with the effective data ratio.
9. The method according to claim 7, wherein, The step of determining the first water level based on the effective data ratio, the preset minimum water level line, and the historical effective data ratio includes: The first water level is adjusted at least once until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein the target difference is the difference between the first water level and the lowest water level.
10. The method according to claim 8, wherein, The step of determining the adjustment value based on the effective data ratio, the preset minimum water level, and the historical effective data ratio includes: The first water level is obtained by adjusting the second water level or the historical lowest water level at least once according to the adjustment value, until the ratio between the effective data ratio and the target difference converges to or equals the historical effective data ratio; wherein the target difference is the difference between the first water level and the lowest water level.
11. The method according to claim 7, wherein, If the first water level is a dynamic value, then the first water level is determined to be less than or equal to the preset OP space.
12. The method according to claim 8, wherein, If the adjustment value is dynamic, then the first water level is determined to be less than or equal to the preset OP space.
13. The method according to any one of claims 1 to 2, wherein, After scanning each of the physical blocks to be reclaimed for valid data, the method further includes: Read valid data from the physical blocks to be reclaimed that contain valid data; Write the valid data into an idle physical block; After writing is complete, all data in the physical block containing valid data to be reclaimed is erased to obtain the corresponding free physical block.
14. The method according to claim 13, wherein, The method further includes: If the idle physical block water level is adjusted to the first water level, then after erasing all data in the physical block to be recycled containing valid data to obtain the corresponding idle physical block, the idle physical block is used as a physical block in the candidate resource pool. The candidate resource pool is used to provide idle physical blocks to the resource pool corresponding to the idle physical block water level after the idle physical block water level is raised.
15. The method according to claim 1, wherein, The physical blocks to be recycled originate from at least one of the following physical blocks: dirty physical blocks targeted by garbage collection tasks, physical blocks that generate programming errors targeted by programming error collection tasks, and cold data physical blocks targeted by static wear leveling tasks.
16. The method according to claim 15, wherein, The method further includes: If any physical block generates a programming error, and it is necessary to close the physical block and reclaim the data in the physical block to an idle physical block, then after adjusting the water level of the idle physical block to the first water level, the programming error reclamation task is executed. And / or, If, when the static wear leveling task is initiated, the effective data ratio of the historically recovered dirty physical blocks is not zero and is less than the effective data ratio of the cold data physical blocks recovered by the static wear leveling task, then the static wear leveling task is executed after adjusting the idle physical block water level line to the first water level line.
17. An adjustment device for the water level of an idle physical block, used to implement the adjustment method as described in any one of claims 1-16, comprising: The acquisition unit is used to acquire at least one physical block to be reclaimed; The scanning unit is used to scan each of the physical blocks to be recycled to see if there is valid data. The identification unit is used to identify the current write mode based on the scan results; The adjustment unit is used to adjust the idle physical block water level line to the first water level line after the identification unit identifies the current write mode as sequential write mode. The first water level line is higher than the preset second water level line in random write mode.
18. A storage device, wherein, include: The control unit and the NVM chip, the control unit performing the steps of the method for adjusting the water level of the free physical block as described in any one of claims 1 to 16.
19. An electronic device, wherein, The device includes a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the steps of the method for adjusting the free physical block water level as described in any one of claims 1 to 16.
20. A computer-readable storage medium, wherein, The computer-readable storage medium stores a program or instructions that cause a computer to perform the steps of the method for adjusting the water level of an idle physical block as described in any one of claims 1 to 16.
Citation Information
Patent Citations
Solid state storage device and data programming method of same
CN106802867A
Method and equipment for managing hard disks in storage equipment
CN115202569A