Data storage method and storage device
By using reserved storage pages in the non-volatile memory module to store data and optimizing address mapping, the frequent garbage collection problem of commercial-grade SSD NAND is solved, and the read and write performance is improved.
Patent Information
- Application Number
- CN202510895901.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-17
AI Technical Summary
The particle quality of commercial-grade SSD NAND is not as good as that of enterprise-grade SSD, resulting in frequent garbage collection, wear leveling, read interference and data retention operations, leading to degraded read and write performance.
When a data write instruction is detected, the reserved storage page in the non-volatile memory module is used to store the data, and the valid page count value of the storage block is kept unchanged. The mapping relationship between the logical address and the physical address is updated through the address mapping table to optimize the garbage collection strategy.
This reduces the speed at which valid pages in storage blocks decrease, avoids frequent triggering of garbage collection, and improves read and write performance.
Smart Images

Figure CN120803352A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of memory, in particular to a data storage method and a storage device. BACKGROUND
[0002] The quality of commercial-grade SSD NAND (SSD (Solid State Drive) is closely related to NAND flash memory, which is the core storage medium of SSD) particles is often not as good as that of enterprise-grade SSD, so garbage collection, wear leveling, solving read interference, data retention and bad block management need more frequent operations.
[0003] The characteristics of the particles determine that the SSD will inevitably generate a lot of invalid data during use, and frequent garbage collection is required. After the SSD has been running for a period of time, the read-write efficiency of the SSD will be significantly degraded due to the need for more of the above operations. SUMMARY
[0004] Therefore, the purpose of the present application is to overcome the deficiencies in the prior art, and to provide a data storage method applied to a storage device configured with a non-volatile memory module, the non-volatile memory module comprising a plurality of storage blocks, each storage block of the non-volatile memory module being configured with an open storage page and a reserved storage page, the method comprising:
[0005] Upon detecting a data write instruction for a target logical address, in response to the target logical address having a mapped physical address, determining a target open storage page corresponding to the mapped physical address;
[0006] Selecting an idle target reserved storage page in a target storage block where the target open storage page is located;
[0007] Storing write data for the target logical address in the target reserved storage page, and keeping the valid page count value of the target storage block unchanged.
[0008] In an embodiment, the step of storing write data for the target open storage page in the target reserved storage page comprises:
[0009] Modifying the physical address corresponding to the target logical address in the address mapping table to the physical address corresponding to the target reserved storage page.
[0010] In an embodiment, the method further comprises:
[0011] Marking the target open storage page as invalid and the target reserved storage page as valid in a preset valid indication mapping table;
[0012] updating a reserved storage page usage number corresponding to the target storage block in the preset reserved storage page usage counting table.
[0013] In an embodiment, the method further comprises:
[0014] triggering garbage collection for the target storage block in response to the valid page counting value being less than a preset threshold.
[0015] In an embodiment, the method further comprises:
[0016] determining whether there is a non-idle reserved storage page in the target storage block according to a counting value in the preset reserved storage page usage counting table when triggering garbage collection for the target storage block; and
[0017] determining the non-idle reserved storage page based on the valid indication mapping table, and performing garbage collection on data in the non-idle reserved storage page first and then performing garbage collection on data in the open storage page.
[0018] In an embodiment, the method further comprises:
[0019] extracting a chain table of a target storage page in the target storage block from a preset storage page chain table storing a change chain of a storage page when overwriting data when detecting a data rollback instruction for the target storage page in the target storage block.
[0020] finding target rollback data corresponding to the data rollback instruction according to the chain table of the target storage page.
[0021] In an embodiment, the method further comprises:
[0022] locating valid cold data and valid hot data stored in the target storage block according to a chain table length of each storage page of the target storage block in the preset storage page chain table when the target storage block triggers garbage collection.
[0023] separately storing the valid cold data and the valid hot data when performing garbage collection.
[0024] In an embodiment, the method further comprises:
[0025] selecting a replacement reserved storage page to replace a bad storage page in the target storage block when detecting that there is the bad storage page in the target storage block.
[0026] recording a mapping relationship between the bad storage page and the replacement reserved storage page in a preset storage page mapping table or recording the mapping relationship between the bad storage page and the replacement reserved storage page in a metadata area of the target storage block.
[0027] In one embodiment, the method further comprises:
[0028] If the number of the reserved storage pages in the target storage block is less than a preset number threshold, the target storage block is marked as a non-rewritable storage block.
[0029] The present application also provides a device, comprising:
[0030] A connection interface for connecting to a host system;
[0031] a non-volatile memory module; and
[0032] a memory controller connected to the connection interface and the non-volatile memory module;
[0033] The memory controller is used to implement the above data storage method.
[0034] The embodiments of the present application have the following beneficial effects:
[0035] When a data write instruction to a target logical address is detected, the embodiment of the present application determines the target open storage page corresponding to the mapped physical address in response to the presence of a mapped physical address for the target logical address; selects an idle target reserved storage page from the target storage block of the target open storage page; stores the write data for the target logical address in the target reserved storage page, and maintains the valid page count value of the target storage block unchanged. By storing the write data in the reserved storage page, the valid page count value of the target storage block can be maintained unchanged, which slows down the rate at which the available capacity of the target storage block decreases, thereby avoiding frequent triggering of garbage collection and improving read and write performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] To more clearly illustrate the technical solution of this application, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of this application and should not be considered as limiting the scope of protection of this application. Those skilled in the art can also derive other relevant drawings based on these drawings without inventive effort.
[0037] Figure 1 This is a schematic diagram of the structure of the cache management device provided by this application;
[0038] Figure 2 This is a flow chart of the first embodiment provided by this application;
[0039] Figure 3 This is a schematic diagram of the storage page distribution in a storage block provided by this application;
[0040] Figure 4is a flowchart of a second embodiment provided by the present application;
[0041] Figure 5 is a flowchart of a third embodiment provided by the present application;
[0042] Figure 6 is a flowchart of a fourth embodiment provided by the present application;
[0043] Figure 7 is a flowchart of a fifth embodiment provided by the present application;
[0044] Figure 8 is a flowchart of a sixth embodiment provided by the present application;
[0045] Figure 9 is a flowchart of a seventh embodiment provided by the present application;
[0046] Figure 10 is a flowchart of a storage page mapping representation provided by the present application. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application.
[0048] The components of the embodiments of the present application generally described and illustrated in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0049] Hereinafter, the terms "include", "have", and their synonymous words used in various embodiments of the present application are only intended to indicate that specific features, numbers, steps, operations, elements, components, or combinations of the foregoing are present, and should not be understood as excluding the presence or possibility of adding one or more features, numbers, steps, operations, elements, components, or combinations of the foregoing.
[0050] In addition, the terms "first", "second", "third", and the like are only used to distinguish description, and cannot be understood as indicating or implying relative importance.
[0051] Unless specifically stated otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present application belong. The terminology used herein (e.g., the terminology used in the description of the figures) is for describing particular embodiments of the application only and is not intended to be limiting. Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present application belong. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
[0052] It can be understood that, as shown in Figure 1 The present application provides a storage device, comprising: a connection interface configured to be connected to a host system; a non-volatile memory module; a memory controller connected to the connection interface and the non-volatile memory module; wherein the memory controller is configured to perform the data storage method disclosed in the present application.
[0053] Specifically, the host system is electrically connected to the storage device through the connection interface to perform data access operations. The memory controller includes a processor (also referred to as a first processor), a data management circuit, a memory interface control circuit, and a buffer memory. The processor can be an integrated circuit chip with signal processing capability. The processor can be a general-purpose processor, including at least one of a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, a microprocessor, or any conventional processor, etc., which can implement or execute the disclosed methods, steps, and logic block diagrams in the embodiments of the present application.
[0054] It can be understood that the data storage method disclosed in the present application is applied to a storage device configured with a non-volatile memory module.
[0055] The non-volatile memory module includes a plurality of chips, each of which is further subdivided into a plurality of planes, and each plane contains a plurality of memory blocks. In addition, each memory block includes a plurality of memory pages, and each memory page contains a plurality of memory cells. It should be noted that the present disclosure is not limited to the size of each memory page and logical page.
[0056] In the embodiment, the open storage page and the reserved storage page are configured in each storage block. Specifically, the plurality of storage pages in each storage block are divided into the open storage page and the reserved storage page, wherein the open storage page is used to perform the write and read operations on data.
[0057] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments can be combined with each other without conflict.
[0058] Reference will be made to Figure 2 , Figure 2 The flowchart of the first embodiment of the present application is shown in the figure, and the method comprises the following steps:
[0059] In step S101, when detecting the data write instruction for the target logical address, in response to the existence of the mapped physical address of the target logical address, the target open storage page corresponding to the mapped physical address is determined.
[0060] It should be noted that the memory controller will establish an address mapping table to record the mapping information between the logical address and the physical address. In the conventional memory management, the memory controller usually establishes a logical-to-physical address mapping table and a physical-to-logical address mapping table, which are respectively used to find the physical unit (such as physical erase unit / physical block / storage block, physical programming unit / physical page / storage page) mapped by the logical unit (such as logical block / logical page), and find the logical unit mapped by the physical unit.
[0061] In the embodiment, when the memory controller detects the data write instruction for the target logical address, the address mapping table is queried to determine the mapped physical address corresponding to the target logical address, and the target open storage page corresponding to the mapped physical address is determined. Exemplarily, the data write instruction detected by the memory controller is the second data write instruction for the target logical address, at this time, the memory controller determines the mapped physical address of the last data write of the target logical address according to the mapping relationship of the target logical address in the address mapping table, and further determines the target open storage page corresponding to the mapped physical address.
[0062] In step S102, an idle target reserved storage page in the target storage block where the target open storage page is located is selected.
[0063] In the embodiment, after determining the target open storage page, the memory controller can determine the corresponding target storage block according to the target open storage page, and then select an idle target reserved storage page in the target storage block. It should be noted that the non-volatile memory module includes a plurality of storage blocks, each of which corresponds to a plurality of open storage pages. The non-volatile memory module can determine the corresponding target storage block according to the physical address of the target open storage page. The reserved storage page of each storage block is specially reserved for the open storage page in the storage block to replace the bad storage page in the storage block. The reserved storage page is not open to other storage blocks.
[0064] For example, as shown in Figure 3 , it is a storage page distribution diagram in a storage block. Page, page1 to page16 are open storage pages of the storage block, and page17 to page24 are reserved storage pages of the storage block. When the memory controller determines that the target open storage page is page1, an idle page is selected from page17 to page24. Figure 3 Step S103, storing the write data for the target logical address in the target reserved storage page.
[0065] In the embodiment, after determining the idle target reserved storage page, the memory controller stores the write data for the target logical address in the target reserved storage page. For example, as shown in
[0066] , when the memory controller determines that the target open storage page is page1 and the selected idle target reserved storage page is page17, the write data for the target logical address is stored in page17. Figure 3 Step S104, keeping the valid page count value of the target storage block unchanged.
[0067] In the embodiment, the memory controller counts the number of valid storage pages in each storage block as the valid page count value. The valid storage page is a storage page that can be used for data write and read operations in the current storage block. In the initial state, the open storage page is a valid storage page, and the reserved storage page is an invalid storage page. When the data in an open storage page is invalidated, the open storage page becomes an invalid storage page, and the open storage page cannot be used for data write and read operations.
[0068] The memory controller stores the write data for the target logical address in the target reserved storage page of the target storage block, replaces the target open storage page with the target reserved storage page, and keeps the valid page count value of the target storage block unchanged.
[0069]
[0070] The memory controller of the embodiment, upon detecting a data write instruction for a target logical address, in response to the target logical address existing a mapped physical address, determines a target open storage page corresponding to the mapped physical address; selects an idle target reserved storage page in a target storage block of the target open storage page; stores write data for the target logical address in the target reserved storage page, and keeps the valid page count value of the target storage block unchanged. By storing the write data in the reserved storage page, the speed of reducing the valid storage pages of the target storage block can be slowed down, and frequent triggering of garbage collection can be avoided, so as to improve the read-write performance.
[0071] Reference is made to Figure 4 , Figure 4 The flowchart of the second embodiment of the present application is shown, and the difference between the second embodiment and the first embodiment is that, after the step of storing write data for the target logical address in the target reserved storage page, the method comprises:
[0072] Step S201, modifying the physical address corresponding to the target logical address in the address mapping table to the physical address corresponding to the target reserved storage page.
[0073] In the embodiment, after the memory controller stores write data for the target logical address in the target reserved storage page, the memory controller modifies the mapped physical address corresponding to the target logical address in the address mapping table to the physical address corresponding to the target reserved storage page.
[0074] For example, when writing data to the target logical address for the first time, the memory controller stores the write data in the target open storage page page1, at this time, the physical address corresponding to the target logical address recorded in the address mapping table is the physical address corresponding to page1; when writing data to the target logical address for the second time, the memory controller stores the write data in the target reserved storage page page17, at this time, the physical address corresponding to the target logical address recorded in the address mapping table is modified from the physical address corresponding to page1 to the physical address corresponding to page17. It can be understood that when writing data to the target logical address for the third time, the memory controller stores the write data in the target reserved storage page page18, at this time, the physical address corresponding to the target logical address recorded in the address mapping table is modified from the physical address corresponding to page17 to the physical address corresponding to page18, and the subsequent physical address modification process in the address mapping table for writing data to the target logical address is similar, and will not be described here.
[0075] Step S202, marking the target open storage page in the preset valid indication mapping table as invalid, and marking the target reserved storage page as valid.
[0076] In this embodiment, the memory controller establishes a valid indication mapping table for each memory block, and the table records the availability of each memory page in the memory block. In the initial state, all open memory pages are marked as valid in the valid indication mapping table, and all reserved memory pages are marked as invalid. After the memory controller stores the write data for the target logical address in the target reserved memory page, it marks the target open memory page as invalid in the preset valid indication mapping table, and marks the target reserved memory page as valid. Exemplarily, the memory controller stores the write data in the target reserved memory page page17. At this time, the physical address corresponding to the target logical address recorded in the address mapping table is modified from the physical address corresponding to page1 to the physical address corresponding to page17. In the preset valid indication mapping table, page1 is marked as invalid, and page17 is marked as valid.
[0077] Step S203: Update the reserved storage page usage count corresponding to the target storage block in the preset reserved storage page usage count table.
[0078] In this embodiment, the memory controller establishes a reserved memory page usage count table to indicate the number of reserved memory pages used in each memory block. After storing the write data for the target logical address in the target reserved memory page, the reserved memory page usage count corresponding to the target memory block in the preset reserved memory page usage count table is updated. Exemplarily, if the memory controller stores the write data in the target reserved memory page page17, the reserved memory page usage count of the target memory block in the table is increased by 1. It should be noted that the reserved memory page usage count recorded in the reserved memory page usage count table can only increase and not decrease.
[0079] In this embodiment, after storing the write data for the target logical address in the target reserved memory page, the memory controller modifies the physical address corresponding to the target logical address in the address mapping table to the physical address corresponding to the target reserved memory page, marks the target open memory page as invalid in the preset validity indication mapping table, marks the reserved memory page as valid, and updates the reserved memory page usage count corresponding to the target memory block in the preset reserved memory page usage count table. This facilitates subsequent queries for other operations targeting the target logical address, avoids errors in other operations targeting the target logical address, and reduces the risk of abnormalities in the non-volatile memory module.
[0080] Please refer to Figure 5 , Figure 5 This is a flow chart of the third embodiment of the present application. The difference between the third embodiment and the first to second embodiments is that the method further includes:
[0081] Step S301, in response to the valid page count value being less than a preset threshold, triggering garbage collection for the target storage block.
[0082] In the embodiment, the memory controller, upon detecting a data write instruction for a target logical address, queries the address mapping table to determine a mapped physical address corresponding to the target logical address, and determines a target open storage page corresponding to the mapped physical address. After determining the target open storage page, the memory controller can determine a target storage block corresponding to the target open storage page, and then select an idle target reserved storage page in the target storage block. After determining the idle target reserved storage page, the memory controller stores the write data for the target logical address in the target reserved storage page. Since the memory controller stores the write data for the target logical address in the target reserved storage page of the target storage block, the valid page count value of the target storage block remains unchanged.
[0083] It can be understood that when the memory controller detects a data write instruction for a target logical address, there is no idle reserved storage page in the target storage block, and the write data for the target logical address is stored in an idle open storage page in the target storage block or an idle open storage page in another idle storage block, and the valid page count value of the target storage block is reduced by 1.
[0084] In addition, when the memory controller detects a data erase instruction for a target logical address, a target open storage page corresponding to the target logical address becomes an invalid storage page, and the valid page count value of a target storage block where the target open storage page is located is reduced by 1.
[0085] After a period of time, the memory controller detects that the valid page count value of the target storage block is less than a preset threshold, and then triggers garbage collection for the target storage block. The garbage collection refers to uniformly moving valid data in the target storage block to another storage block, and releasing the storage space of the target storage block for storing new data.
[0086] It can be understood that after triggering the garbage collection for the target storage block, the valid data in the target storage block can be directly moved; or the target storage block can be used as a storage block to be garbage collected, and when the number of storage blocks triggering garbage collection in the non-volatile storage module meets a preset number, the valid data in all storage blocks to be garbage collected is moved.
[0087] It should be noted that the memory controller can determine the valid page count value by querying a preset valid indication mapping table, wherein the valid page count value refers to the number of storage pages marked as valid in the valid indication mapping table in the target storage block.
[0088] The memory controller of the embodiment, when detecting a data write instruction for a target logical address, determines a target open storage page corresponding to a mapped physical address in response to the target logical address existing; selects an idle target reserved storage page in a target storage block of the target open storage page; stores write data for the target logical address in the target reserved storage page, and keeps the valid page count value of the target storage block unchanged; and when detecting that the valid page count value of the target storage block is less than a preset threshold, triggers garbage collection for the target storage block. By storing write data in a reserved storage page, the valid page count value of the target storage block can be kept unchanged, thereby avoiding frequent triggering of garbage collection, and improving read-write performance.
[0089] Please refer to Figure 6 , Figure 6 The flowchart of the fourth embodiment of the present application is shown in FIG. 4. The fourth embodiment is different from the first embodiment to the third embodiment in that the method further comprises:
[0090] Step S401, when triggering garbage collection of the target storage block, determining whether there is a non-idle reserved storage page in the target storage block according to the count value in the reserved storage page usage count table.
[0091] In the embodiment, the memory controller, when triggering garbage collection of the target storage block, determines whether there is a non-idle reserved storage page in the target storage block according to the count value in the reserved storage page usage count table. It can be understood that when all the reserved storage pages in the target storage block are not used, the count value in the reserved storage page usage count table is 0, and when the reserved storage pages in the target storage block are used, the count value in the reserved storage page usage count table is the number of the used reserved storage pages in the target storage block.
[0092] Step S402, determining the non-idle reserved storage page based on the valid indication mapping table, and performing garbage collection on the data in the non-idle reserved storage page first, and then performing garbage collection on the data in the open storage page.
[0093] In the embodiment, when the memory controller determines that there is a non-idle reserved storage page in the target storage block according to the count value in the reserved storage page usage count table, it determines which reserved storage pages are non-idle reserved storage pages based on the records of the valid indication mapping table, and performs garbage collection on the data in the non-idle reserved storage pages first, and then performs garbage collection on the data in the open storage pages. It can be understood that the valid indication mapping table stores the annotations of whether each open storage page in the target storage block is valid and whether each reserved storage page is valid, and each reserved storage page that is annotated as valid is a non-idle reserved storage page.
[0094] The memory controller of the embodiment first performs garbage collection on the data in the non-idle reserved storage page and then performs garbage collection on the data in the open storage page when triggering garbage collection on the target storage block and determining that the target storage block has non-idle reserved storage pages, so that the influence of discontinuous operations between the reserved storage page and the open storage page on the garbage collection speed can be avoided, and the operation efficiency is improved.
[0095] Please refer to Figure 7 , Figure 7 The flowchart of the fifth embodiment of the present application is shown, and the fifth embodiment is different from the first embodiment to the fourth embodiment in that the method further comprises:
[0096] In step S501, when detecting a data rollback instruction for a target storage page in the target storage block, a chain table of the target storage page is extracted from a preset storage page chain table, and the preset storage page chain table stores the change chain of the storage page during the rewriting process of the data.
[0097] In the embodiment, the memory controller establishes a storage page chain table for each storage block, and stores the change chain of the storage page during the rewriting process of the data in each open storage page in the target storage block. When detecting a data rollback instruction for a target storage page in the target storage block, the memory controller extracts the chain table of the target storage page from a preset storage page chain table. For example, the write data for the target logical address is stored in the open storage page page1 for the first time, stored in the reserved storage page page17 for the second time, and stored in the reserved storage page page18 for the third time, and the change chain of the storage page during the corresponding rewriting process is: page1→page17→page18.
[0098] In step S502, the target rollback data corresponding to the data rollback instruction is found according to the chain table of the target storage page.
[0099] In the embodiment, the memory controller finds the target rollback data corresponding to the data rollback instruction according to the chain table of the target storage page. Exemplarily, the target storage page is the open storage page page1, the corresponding chain table is: page1→page17→page18, and when the target rollback data corresponding to the data rollback instruction is the data of the second step, the memory controller takes the data stored in page17 as the target rollback data.
[0100] The memory controller of the embodiment, upon detecting a data rollback instruction for a target storage page in a target storage block, extracts a chain table of the target storage page from a chain table of the target storage block, and further determines the target rollback data corresponding to the data rollback instruction. Since the data rewriting of the present application is performed on the reserved storage pages in the same storage block, it can be avoided that the data is rewritten to the remaining storage blocks, and it is difficult to determine whether the source data is cleared, and it is difficult to implement data rollback, thereby ensuring the reliability of data rollback.
[0101] Reference is made to Figure 8 , Figure 8 The flowchart of the sixth embodiment of the present application is shown, and the sixth embodiment is different from the first to fifth embodiments in that the method further comprises:
[0102] In step S601, upon triggering garbage collection in the target storage block, the valid cold data and the valid hot data stored in the target storage block are located according to the chain table length of each storage page of the target storage block in the preset storage page chain table.
[0103] In the present embodiment, the memory controller, upon triggering garbage collection in the target storage block, locates the valid cold data and the valid hot data stored in the target storage block according to the chain table length of each storage page of the target storage block in the preset storage page chain table. It can be understood that the chain table length of each storage page corresponds to the rewriting frequency of the stored data, the longer the chain table length, the higher the rewriting frequency of the stored data, and the shorter the chain table length, the lower the rewriting frequency of the stored data. The memory controller compares the chain table length of each storage page with the chain table length threshold set in advance, and if the chain table length is greater than the chain table length threshold, it is determined that the stored data is valid hot data, and if the chain table length is not greater than the chain table length threshold, it is determined that the stored data is valid cold data.
[0104] In step S602, the valid cold data and the valid hot data are stored separately during garbage collection.
[0105] In the present embodiment, the memory controller stores the valid cold data and the valid hot data separately during garbage collection. It can be understood that the memory controller stores the valid hot data in other storage blocks for storing hot data, and stores the valid cold data in other storage blocks for storing cold data.
[0106] When garbage collection is triggered for a target memory block, the memory controller of this embodiment locates valid cold data and valid hot data stored in the target memory block based on the length of each memory page in a preset memory page linked list, and then stores the valid cold data and valid hot data separately. Separating and storing valid cold data and valid hot data in different memory blocks during garbage collection reduces write amplification during garbage collection.
[0107] Please refer to Figure 9 , Figure 9 This is a flow chart of the seventh embodiment of the present application. The difference between the seventh embodiment and the first to sixth embodiments is that the method further includes:
[0108] Step S701 : When it is detected that a bad memory page exists in the target memory block, a replacement reserved memory page is selected in the target memory block to replace the bad memory page.
[0109] In this embodiment, when the memory controller detects a bad memory page in the target memory block, it selects a replacement reserved memory page in the target memory block to replace the bad memory page. It is understandable that the memory controller obtains an idle reserved memory page from all reserved memory blocks in the target memory block as the replacement reserved memory page.
[0110] Step S702: Record the mapping relationship between the bad storage page and the replacement reserved storage page in a preset storage page mapping table, or record the mapping relationship between the bad storage page and the replacement reserved storage page in the metadata area of the target storage block.
[0111] In this embodiment, the memory controller records the mapping relationship between the bad memory page and the replacement reserved memory page in a preset memory page mapping table, or records the mapping relationship between the bad memory page and the replacement reserved memory page in the metadata area of the target memory block. Figure 10 As shown, the preset storage page mapping table includes each bad storage page in the target storage block and its corresponding replacement reserved storage page. When the open storage page page1 is detected as a bad storage page and the replacement reserved storage page is selected as page20, the bad storage page page1 and the corresponding replacement reserved storage page page20 are recorded in the storage page mapping table; when the open storage page page15 is detected as a bad storage page and the replacement reserved storage page is selected as page23, the bad storage page page15 and the corresponding replacement reserved storage page page23 are recorded in the storage page mapping table.
[0112] The memory controller of the embodiment selects a replacement reserved storage page in the target storage block to replace the bad storage page when detecting that the target storage block has the bad storage page, and generates a corresponding storage page mapping table. The bad page replacement across storage blocks is avoided, the mapping table complexity is reduced, and the adaptability of the non-volatile memory module deployed in a small-capacity random access memory is improved.
[0113] Further, if the number of the reserved storage pages in the target storage block is less than a preset number threshold, the target storage block is marked as a non-rewritable storage block. The free reserved storage pages are preferentially ensured to replace the bad storage pages in the target storage block, the target storage block is prevented from being unable to be used due to individual bad storage pages, and the service life of the storage block is prolonged.
[0114] In the embodiment, after the memory controller selects a replacement reserved storage page in the target storage block to replace the bad storage page, if it is determined that the number of the reserved storage pages in the target storage block is less than a preset number threshold (that is, the number of the bad storage pages in the target storage block reaches a certain number), the target storage block is marked as a non-rewritable storage block, and the target storage block is used to store cold data.
[0115] The non-volatile memory module of the embodiment marks the target storage block as a non-rewritable storage block when the number of the bad storage pages in the target storage block reaches a certain number, and the target storage block is used to store cold data, so that the utilization rate of the storage block can be improved.
[0116] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiment described above is only schematic, for example, the flowchart and structural diagram in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that, in the alternative implementation manner, the functions annotated in the block can also occur in the order different from that annotated in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can also be executed in reverse order, depending on the functions involved. It should also be noted that each block in the structural diagram and / or flowchart, and the combination of blocks in the structural diagram and / or flowchart, can be implemented by a dedicated hardware-based system which executes the specified function or action, or can be implemented by a combination of special hardware and computer instructions.
[0117] In addition, each functional module or unit in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0118] The functions, if implemented in the form of software functional modules and sold or used as independent products, can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application, in essence or the parts that contribute to the prior art, or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.
[0119] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application.
Claims
1. A data storage method, applied to a storage device equipped with a non-volatile memory module, wherein the non-volatile memory module includes a plurality of storage blocks, characterized in that: Each of the memory blocks of the non-volatile memory module is configured with an open memory page and a reserved memory page, and the method includes: When a data write instruction to a target logical address is detected, in response to a mapped physical address for the target logical address, determining a target open storage page corresponding to the mapped physical address; Selecting an idle target reserved storage page in the target storage block where the target open storage page is located; storing the write data for the target logical address in the target reserved memory page; and The valid page count value of the target storage block is kept unchanged.
2. The data storage method according to claim 1, wherein: After the step of storing the write data for the target logical address in the target reserved storage page, the method further includes: The physical address corresponding to the target logical address in the address mapping table is modified to the physical address corresponding to the target reserved storage page.
3. The data storage method according to claim 1, wherein: The method further comprises: Mark the target open storage page in the preset validity indication mapping table as invalid, and mark the target reserved storage page as valid; The reserved storage page usage count corresponding to the target storage block in the preset reserved storage page usage count table is updated.
4. The data storage method according to claim 1, wherein: The method further comprises: In response to the valid page count value being less than a preset threshold, garbage collection for the target storage block is triggered.
5. The data storage method according to claim 3, characterized in that: The method further comprises: When triggering garbage collection of the target storage block, determining whether there is a non-free reserved storage page in the target storage block according to the count value in the reserved storage page usage count table; and The non-idle reserved storage page is determined based on the valid indication mapping table, and garbage collection is first performed on the data in the non-idle reserved storage page, and then garbage collection is performed on the data in the open storage page.
6. The data storage method according to claim 1, wherein: The method further comprises: When a data rollback instruction for a target storage page in the target storage block is detected, a linked list of the target storage page is extracted from a preset storage page linked list, wherein the preset storage page linked list stores a change chain of storage pages when rewriting data; According to the linked list of the target storage page, the target rollback data corresponding to the data rollback instruction is searched.
7. The data storage method according to claim 6, characterized in that: The method further comprises: When garbage collection is triggered on the target storage block, locating valid cold data and valid hot data stored in the target storage block according to the linked list length of each storage page of the target storage block in the preset storage page linked list; The valid cold data and the valid hot data are stored separately when garbage collection is performed.
8. The data storage method according to claim 1, wherein: The method further comprises: When detecting that a bad memory page exists in the target memory block, selecting a replacement reserved memory page in the target memory block to replace the bad memory page; The mapping relationship between the bad storage page and the replacement reserved storage page is recorded in a preset storage page mapping table, or the mapping relationship between the bad storage page and the replacement reserved storage page is recorded in the metadata area of the target storage block.
9. The data storage method according to claim 8, characterized in that: The method further comprises: If the number of the reserved storage pages in the target storage block is less than a preset number threshold, the target storage block is marked as a non-rewritable storage block.
10. A storage device, characterized in that: include: A connection interface for connecting to a host system; non-volatile memory module; as well as a memory controller connected to the connection interface and the non-volatile memory module; The memory controller is configured to implement the data storage method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Data write-in method, memorizer control circuit unit and memorizer storage device
CN104793891A
Data writing method of nonvolatile memory, terminal and readable storage medium
CN112988611A
Data storage management method, NAND Flash controller and computer storage medium
CN113094295A
Method and apparatus for improving small write performance in a non-volatile memory
US20100095046A1
Cited By
Storage array control method, controller and storage device
CN121934787A