Storage block writing method, ssd controller, storage block replacement method and device
Patent Information
- Application Number
- CN202210852330.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-20
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-07-20
AI Technical Summary
如果超级块中坏存储块数量超过一定阈值就不能再使用,会导致SSD整体可用的存储空间损失,进而使得写入性能降低
[0018]在本发明实施例的方案中,通过存储块在存储块序列中的块地址实现了坏存储块的替换,使得能够将数据写入到替换存储块中,避免了数据写入到坏存储块中,从而提高了写入性能,此外,替换正向表和替换反向表反映了替换存储块的块地址和坏存储块的块地址彼此的映射关系,通过这样的映射关系,兼容了传统地址映射表的更新逻辑和传统有效页计数的更新逻辑,无需过多改变传统写入过程的配置。
Smart Images

Figure CN117476057B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a storage block writing method, an SSD controller, a storage block replacement method and apparatus. Background Technology
[0002] Solid-state drives (SSDs), such as those using flash memory, sometimes contain bad blocks, such as original bad blocks and growing bad blocks. Original bad blocks are those that were identified as bad during the manufacturing process of the SSD. Growing bad blocks are those that, while passing the initial manufacturing test, gradually become bad as the SSD wears down with use.
[0003] Bad blocks prevent normal reading and writing of data. Bad blocks need to be detected promptly to prevent subsequent data writing and thus data loss. If the number of bad blocks in the superblock exceeds a certain threshold, it can no longer be used, leading to a loss of overall usable storage space on the SSD and consequently reducing write performance. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a data writing method, an SSD controller, a storage block configuration method, and a device to at least partially solve the above-mentioned problems.
[0005] According to a first aspect of the present invention, a method for writing a memory block is provided, comprising: obtaining a write operation command for a memory block in a memory, the memory including a plurality of memory blocks ordered in an array; querying a replacement forward table to determine the block address of a replacement memory block to replace a current bad memory block, as the current write block address of the write operation command, the replacement forward table indicating a mapping from the block address of the replacement memory block to the block address of the bad memory block in a memory block sequence; updating a previous address mapping table to a current address mapping table based on the current write block address; querying a replacement reverse table to determine the block address of the current bad memory block based on the current write block address, the replacement reverse table indicating a mapping from the block address of the bad memory block to the block address of the replacement memory block in the memory block sequence; and updating the effective page count of the block address of the current bad memory block.
[0006] In another implementation of the present invention, the method further includes: when the previously written block address in the previous address mapping table indicates a replacement storage block, querying the replacement reverse table to determine the block address of the previously bad storage block replaced by the previously written block address; and updating the valid page count of the block address of the previously bad storage block.
[0007] In another implementation of the present invention, the method further includes: updating the valid page count of the previously written block address when the previously written block address in the previous address mapping table does not indicate a replacement storage block.
[0008] In another implementation of the present invention, the method further includes: determining the current allocated block address according to a write operation command; and starting to query the replacement forward table when the current allocated block address indicates the current bad storage block.
[0009] In another implementation of the present invention, the method further includes: when the current allocated block address does not indicate the current bad memory block, updating the previous address mapping table to the current address mapping table based on the current allocated block address, and updating the valid page count of the current allocated block address.
[0010] In another implementation of the present invention, the method further includes: querying the availability status of the storage block at the currently allocated block address; and when the availability status indicates that the storage block at the currently allocated block address is unavailable, determining the storage block at the currently allocated block address as the currently bad storage block.
[0011] In another implementation of the present invention, the method further includes: when the available state indicates that the storage block at the current allocated block address is available, determining that the current allocated block address does not indicate the current bad storage block.
[0012] According to a second aspect of the present invention, a storage block replacement method is provided, comprising: replacing a bad storage block in a second address range with a replacement storage block in a first address range of a storage block sequence, wherein the first address range and the second address range do not have the same block address; generating a replacement reverse table based on the block address of the bad storage block in the storage block sequence; and generating a replacement forward table based on the block address of the replacement storage block in the storage block sequence.
[0013] In another implementation of the present invention, the method further includes: determining the proportion of bad storage blocks corresponding to the second address range in the storage block sequence; the step of replacing the bad storage blocks of the second address range with replacement storage blocks of the first address range in the storage block sequence includes: when the proportion of bad storage blocks exceeds a preset threshold, replacing the bad storage blocks of the second address range with replacement storage blocks of the first address range in the storage block sequence, so that the proportion of bad storage blocks after replacement does not exceed the preset threshold.
[0014] In another implementation of the present invention, replacing a bad storage block in the second address range with a replacement storage block in the first address range of the storage block sequence includes: determining a storage block whose sequence position indicated by the block address follows the bad storage block as a replacement storage block; and swapping the block address of the replacement storage block with the block address of the bad storage block until the block address of the replacement storage block is within the second address range and the block address of the bad storage block is within the first address range.
[0015] According to a third aspect of the present invention, an SSD controller is provided, comprising: a storage unit storing a replacement forward table and a replacement reverse table, the replacement forward table indicating a mapping from the block address of a replacement storage block to the block address of a bad storage block in a storage block sequence, and the replacement reverse table indicating a mapping from the block address of a bad storage block to the block address of a replacement storage block in the storage block sequence; an acquisition unit acquiring a write operation command for a storage block in a memory, the memory including a plurality of storage blocks ordered in an array; a first query unit querying the replacement forward table to determine the block address of the replacement storage block that replaces the current bad storage block, as the current write block address of the write operation command; a first update unit updating a previous address mapping table to a current address mapping table based on the current write block address; a second query unit querying the replacement reverse table based on the current write block address to determine the block address of the current bad storage block; and a second update unit updating the effective page count of the block address of the current bad storage block.
[0016] In another implementation of the present invention, the first query unit and the second query unit are configured as a query circuit, which is used to perform queries on the replacement forward table and the replacement reverse table.
[0017] According to a fourth aspect of the present invention, a storage block replacement apparatus is provided, comprising: a replacement module for replacing a bad storage block in a second address range with a replacement storage block in a first address range of a storage block sequence, wherein the first address range and the second address range do not have the same block address; a first generation module for generating a replacement reverse table based on the block address of the bad storage block in the storage block sequence; and a second generation module for generating a replacement forward table based on the block address of the replacement storage block in the storage block sequence.
[0018] In the embodiment of the present invention, the replacement of bad storage blocks is achieved by using the block address of the storage block in the storage block sequence, which enables data to be written to the replacement storage block and avoids writing data to bad storage blocks, thereby improving write performance. In addition, the replacement forward table and the replacement reverse table reflect the mapping relationship between the block address of the replacement storage block and the block address of the bad storage block. Through such a mapping relationship, the update logic of the traditional address mapping table and the update logic of the traditional effective page count are compatible, without having to make too many changes to the configuration of the traditional write process. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, 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 recorded in the embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0020] Figure 1A This is a schematic structural diagram of a solid-state drive based on an example.
[0021] Figure 1B for Figure 1A A schematic diagram of the read / write architecture of a solid-state drive.
[0022] Figure 2A This is a flowchart of the steps of a storage block writing method according to an embodiment of the present invention.
[0023] Figure 2B for Figure 2A A schematic diagram of the storage block replacement rules in the embodiment.
[0024] Figure 2C for Figure 2B A diagram illustrating the forward and reverse replacement tables to which the storage block replacement rules apply.
[0025] Figure 3 According to Figure 2A A flowchart illustrating the steps of a storage block write process in one embodiment.
[0026] Figure 4 According to Figure 3 A flowchart illustrating the steps of a bad storage block lookup process.
[0027] Figure 5 According to Figure 3 The flowchart illustrates the steps of the effective page count update process in the example.
[0028] Figure 6 This is a flowchart illustrating the steps of a storage block replacement method according to an embodiment of the present invention.
[0029] Figure 7A for Figure 6 A schematic diagram of the storage block replacement rules in an embodiment.
[0030] Figure 7B for Figure 6 A schematic diagram of a specific example of an embodiment.
[0031] Figure 8 This is a structural block diagram of an SSD controller according to another embodiment of the present invention.
[0032] Figure 9 This is a structural block diagram of a memory block replacement device according to another embodiment of the present invention. Detailed Implementation
[0033] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and thoroughly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art should fall within the protection scope of the present invention.
[0034] The specific implementation of the embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0035] Figure 1A A schematic structural diagram of a solid-state drive 100 is shown. The solid-state drive 100 includes an SSD controller 104, persistent memory 106, and non-volatile memory 108.
[0036] SSD controller 104 includes host interface circuitry 102, persistent memory controller circuitry 110, non-volatile block addressable memory controller circuitry 112, processor 122, firmware 140, hardware auxiliary circuitry 116, and static random access memory 130. SSD controller 104 may be included in a field-programmable gate array (FPGA) or application-specific integrated circuit (ASIC).
[0037] The host system can communicate with the solid-state drive 100 via a high-speed serial computer expansion bus 120 (e.g., a peripheral component rapid interconnect (PCIe) bus). Host interface circuitry 102 manages the communication via the PCIe bus. In this embodiment, the host system uses the Non-Volatile Memory Rapid (NVMe) standard protocol to communicate via the PCIe bus. The NVMe standard protocol defines a register-level interface for the host software to communicate with the solid-state drive (SSD) 100 via the PCIe bus.
[0038] The NVM Quick Interface allows host software to communicate with the solid-state drive 100 via a high-speed serial computer expansion bus 120 based on a paired commit and complete queue mechanism. A commit queue (SQ) 144 and a complete queue (CQ) 142 are allocated in memory. The commit queue 144 is a fixed-slot-size circular buffer used by the host software to submit commands for execution by the SSD controller 104. The complete queue 142 is a fixed-slot-size circular buffer used to publish the status of completed commands.
[0039] The NVMe command set is used for paired commit and complete queues. The host software inserts commands from the NVMe command set into commit queue 144 for execution by SSD controller 104. SSD controller 104 inserts complete commands into the associated complete queue 142.
[0040] A portion of the static random access memory 130 is allocated as an L2P table cache 132 to store a portion of the persistent memory (PM) L2P table 118 stored in persistent memory 106. Another portion of the static random access memory 130 is allocated as a VPC cache 134 to store data transferred via the high-speed serial computer expansion bus 120. In this embodiment, the static random access memory 130 is one million or several million bytes (MB).
[0041] Another portion of the static random access memory 130 is allocated as a physical-to-logical (P2L) table 136. Both the L2L table cache 132 and the physical-to-logical (P2L) table 136 store the physical block addresses corresponding to the logical block addresses in the block-addressable non-volatile memory of the solid-state drive. Entries in the P2L table 136 are static (not updated after being written to). Entries in the L2L table cache 132 are dynamically updated.
[0042] The L2P address table (also known as the L2P table or L2P table) is stored in byte-addressable volatile memory (e.g., dynamic random access memory (DRAM) or synchronous dynamic random access memory (SDRAM)). The L2P table is stored in byte-addressable volatile memory to accelerate the reading of physical block addresses from the L2P table, thereby accessing physical blocks in block-addressable non-volatile memory (e.g., NAND flash memory) within the solid-state drive (SSD). The byte-addressable volatile memory used to store the L2P table may be located within the SSD or communicatively coupled to a host machine.
[0043] The L2P table can be stored in a host memory buffer, such as a portion of the system DRAM. Each time an L2P table is written to (updated) in the host memory buffer, an L2P table stored in block-addressable non-volatile memory (B2P) on the solid-state drive (SSD) is simultaneously written. The performance of writing to the L2P table is based on the longest write time, i.e., the time taken to write to either the B2P buffer or the host memory buffer.
[0044] L2P tables can be stored in byte-addressable volatile memory within a solid-state drive (SSD). However, the size of the L2P table depends on the user capacity of the SSD (e.g., approximately one megabyte (MB) per billion bytes (GB)). An increase in the non-volatile memory (also known as user capacity) within the SSD requires a corresponding increase in byte-addressable volatile memory to store the L2P table.
[0045] Static Random Access Memory 130 is volatile memory. Volatile memory is memory whose state (and therefore the data stored therein) is uncertain when the device is powered off. SRAM is a type of volatile memory that uses latching circuitry to store each bit. SRAM is often used as cache memory because, compared to Dynamic Random Access Memory (DRAM), data stored in SRAM does not need to be refreshed periodically.
[0046] Persistent memory 106 and non-volatile memory 108 are non-volatile memories. A non-volatile memory (NVM) device is a memory whose state remains determined even when the device is powered off. In one embodiment, non-volatile memory 108 is NAND flash memory, or more specifically, multi-threshold NAND flash memory (e.g., single-cell (“SLC”), multi-cell (“MLC”), three-cell (“TLC”), four-cell (“QLC”), five-cell (“PLC”), or some other NAND flash memory).
[0047] The non-volatile memory 108 includes at least one non-volatile memory die, such as a NAND flash memory die. Typically, data is written (striped) across many NAND flash memory dies in an SSD to optimize write bandwidth. The non-volatile memory on the non-volatile memory die includes multiple blocks, where each block includes multiple pages. Each of the multiple pages is used to store data and associated metadata. In an embodiment, the non-volatile memory die has 2048 blocks, each block has 64 pages, and each page can store 2048 bytes of data and 64 bytes of metadata.
[0048] Persistent memory 106 is byte-addressable, write-in-place nonvolatile memory. Examples of byte-addressable, write-in-place nonvolatile memory devices include three-dimensional crosspoint memory devices, single-level or multi-level phase-change memory (PCM) or phase-change memory with switches (PCMS), Intel Optane, nonvolatile memory devices using chalcogenide phase-change materials (e.g., chalcogenide glasses), including metal oxide-based, oxygen vacancy-based resistive memory and bridged random access memory (CBRAM), nanowire memory, ferroelectric random access memory (FeRAM, FRAM), magnetoresistive random access memory (MRAM) incorporating memristor technology, spin-transfer torque (STT) MRAM, spintronic junction-based devices, magnetic tunnel junction (MTJ)-based devices, DW (domain wall) and SOT (spin-orbit transfer)-based devices, thyristor-based memory devices, or any combination of the above, or other memories.
[0049] Hardware auxiliary circuitry 116 manages data transfer between persistent memory 106 and non-volatile memory 108. A portion of persistent memory 106 is allocated to store PM L2P table 118. A portion of non-volatile memory 108 is used to store master L2P table 148. The size of PM L2P table 118 depends on the capacity of non-volatile memory 108 based on a 1:1000 ratio; for example, PM L2P table 118 in persistent memory 106 is one megabyte (MB) per billion bytes (GB) of non-volatile memory 108. PM L2P table 118 is a copy of master L2P table 148. Both PM L2P table 118 and master L2P table 148 are stored in non-volatile memory and are periodically synchronized during operation of solid-state drive 100.
[0050] The remaining portion of persistent storage 106 can be used to store PM L2P table 118, user data, persistent storage metadata, and host metadata. In this embodiment, approximately 5% of the persistent storage is used to store PM L2P table 118, approximately 5% is used to store persistent storage / host metadata, and approximately 90% is used to store user data.
[0051] In this embodiment, the user data stored in persistent memory 106 may include frequently accessed user data, operating system files, and executable programs. Frequently accessed user data may be referred to as "hot" user data. Infrequently accessed data (also referred to as "cold" user data) may be stored in non-volatile memory 108. Persistent memory 106 may be referred to as "accelerator memory" because the read latency of persistent memory 106 is less than the read latency of non-volatile memory 108.
[0052] In other embodiments, persistent memory 106 may be SLC NAND, and block-addressable non-volatile memory 108 may be NAND with more than one bit per cell (e.g., MLC, TLC, QLC, PLC NAND). SLC NAND has a faster read latency than NAND with more than one bit per cell.
[0053] The non-volatile block addressable memory controller circuit 112 in the SSD controller 104 queues and processes commands (e.g., read, write (“programming”), and erase commands for user data stored in the non-volatile memory 108).
[0054] Solid State Drive 100 does not include Dynamic Random Access Memory (DRAM) and can be referred to as a DRAM-free solid state drive.
[0055] Figure 1B It shows Figure 1A This is a schematic diagram of an example read / write architecture for a solid-state drive (SSD). The SSD in this example includes NAND flash memory as non-volatile memory 108 and an SSD controller 104. The SSD controller 104 controls data writing and the corresponding write locations, as well as data reading and the corresponding read locations. The data storage locations are recorded in an L2P table within the controller, and the L2P table is stored in an L2P table cache 132.
[0056] The NAND flash memory 108 is used to store data and includes flash memory cells 20. Each NAND flash memory cell 20 consists of multiple blocks, which are numbered from 0 to n. Blocks with the same number in the NAND flash memory cell 20 are called super blocks. The write operation characteristic of NAND flash memory is that it is written in units of pages and erased in units of storage blocks.
[0057] Each time data is written, the SSD controller 104 writes data in units of superblocks, filling each superblock before writing the next superblock. The SSD controller 104 is configured with a Valid Page Count (VPC) table to record the amount of valid data within the corresponding superblock, which is used for subsequent garbage collection of the SSD. The VPC table is stored in the VPC table cache 134, and the superblock's ordinal number is also referred to as the block address in various embodiments of this invention.
[0058] The performance of a superblock is positively correlated with the number of storage blocks within it. During SSD usage, bad storage blocks gradually accumulate. Using a superblock containing bad storage blocks leads to a decrease in the overall performance of the SSD. If the number of bad storage blocks in a superblock exceeds a certain threshold, it can no longer be used, resulting in a loss of usable storage space and consequently reduced write performance. Therefore, this invention provides a solution to improve the write performance of solid-state drives.
[0059] Figure 2A This is a flowchart illustrating the steps of a storage block writing method according to an embodiment of the present invention. The storage block writing method of this embodiment can be executed by an SSD controller, for example... Figure 1A and Figure 1B The SSD controller 104 in the middle.
[0060] The storage block writing method in this embodiment includes:
[0061] S210: Obtain a write operation command for a block of memory, which comprises multiple blocks of memory arranged in an array.
[0062] For example, an array of memory blocks can be an array of memory blocks formed based on multiple dies and multiple block addresses.
[0063] S220: Query the replacement forward table to determine the block address of the replacement block to replace the current bad block, which is used as the current write block address of the write operation command. The replacement forward table indicates the mapping from the block address of the replacement block to the block address of the bad block in the block sequence.
[0064] For example, the replacement forward table can be queried based on the block identifier of the current bad storage block. The block identifier of the current bad storage block is recorded when the current storage block is confirmed to be bad, and at the same time, the replacement forward table query is executed.
[0065] S230: Update the previous address mapping table to the current address mapping table based on the current write block address.
[0066] For example, if the current write block address is used to write target data, which could be data written to an existing previous logical address, when updating the previous address mapping table to the current address mapping table, the mapping between the previous logical address and the previous write block address can be corrected to the mapping between the previous logical address and the current write block address. Simultaneously, the previous address mapping table is invalidated, awaiting garbage collection (GC) on a block-by-block basis. Alternatively, the address mapping table can be updated for data written to the currently allocated logical address; in this case, a mapping between the allocated logical address and the current write block address is established.
[0067] S240: Based on the current write block address, query the replacement reverse table to determine the block address of the current bad storage block. The replacement reverse table indicates the mapping from the block address of the bad storage block to the block address of the replacement storage block in the storage block sequence.
[0068] For example, by determining the block address of the current bad block, the current bad block can be located again. If the block address of the current bad block is found in the replacement reverse table, it means that the current bad block has been replaced. When performing valid page counting, the block address of the current bad block needs to be recorded to ensure compatibility with the valid page counting logic of the traditional write process.
[0069] S250: Update the valid page count of the block address of the current bad block.
[0070] For example, increment the valid page count of the block address of the current bad memory block by 1.
[0071] It should be understood that, in this embodiment of the invention, the SSD controller 104 may be configured with a replacement table cache for storing a forward replacement table and a reverse replacement table. Queries of the forward and reverse replacement tables can be executed through query logic in the replacement table cache. Alternatively, the query logic for the forward replacement table can be configured in the L2P table cache 132, and the query logic for the reverse replacement table can be configured in the VPC table cache 134. Alternatively, queries of the forward and reverse replacement tables can be configured as query circuitry within the SSD controller 104.
[0072] like Figure 2B As shown, the NAND flash memory cell 20 includes M+1 dies 0-M, and each die includes multiple storage blocks. Blocks with the same storage block identifier belong to the same superblock. The superblock identifier indicates the block address (physical address of the storage block). The physical address for writing data also includes the page address, and correspondingly, the page address under the block address is written.
[0073] Furthermore, the bad memory blocks that appear will be irregularly distributed in the NAND flash memory cells 20, for example, Figure 2B The blocks shown in bold are bad blocks. Generally, when the proportion of bad blocks in a superblock exceeds a preset threshold, it will greatly affect the read and write performance of the solid-state drive. Therefore, bad blocks can be replaced with replacement blocks (good blocks that can read and write data normally) based on different block addresses, thereby reducing the proportion of bad blocks and making them relatively concentrated in a smaller number of superblocks. More preferably, bad blocks are relatively concentrated in superblocks with later write orders.
[0074] In one example, a bad memory block can be replaced by a replacement memory block belonging to the same die. For instance, a bad memory block written earlier can be replaced with a replacement memory block written later in the write order. Figure 2B As shown, in die 1, Block 4 is replaced by Block 4, and in die 2, Block 1 is replaced by Block 4.
[0075] It should be understood that since bad memory blocks in NAND flash memory cannot be physically moved, the replacement process described in this invention refers to logically performing memory block replacement by replacing the forward table and the reverse table. The following will combine... Figure 2C This describes the configuration and replacement principle for replacing forward tables and reverse tables.
[0076] As shown in the example diagram on the left of 2C, in a die, Block2 is replaced by Block4, Block1 is replaced by Block n, and Block0 is replaced by Block n+1. Accordingly, Table 01 shows the forward replacement table for mapping bad block indices to replacement blocks. Table 02 shows the reverse replacement table for mapping replacement block indices to bad blocks. Without loss of generality, the forward replacement table indicates the mapping from the block address of a replacement block to the block address of a bad block in the block sequence, and the reverse replacement table indicates the mapping from the block address of a bad block to the block address of a replacement block in the block sequence.
[0077] In the embodiment of the present invention, the replacement of bad storage blocks is achieved by using the block address of the storage block in the storage block sequence, which enables data to be written to the replacement storage block and avoids writing data to bad storage blocks, thereby improving write performance. In addition, the replacement forward table and the replacement reverse table reflect the mapping relationship between the block address of the replacement storage block and the block address of the bad storage block. Through such a mapping relationship, it is compatible with traditional write processes such as updating the address mapping table and valid page count, without having to make too many changes to the configuration of traditional write processes.
[0078] As an example, Figure 3 The specific steps of the storage block writing process according to an embodiment of the present invention are shown:
[0079] S310: Obtain the write operation command, and then execute S320. For example, after obtaining the write operation command, determine the current allocated block address based on the write operation command, and when the current allocated block address indicates the current bad storage block, start querying the replacement forward table.
[0080] S320: Determine whether the bad storage block has been replaced. If yes, proceed to S330; otherwise, proceed to S350. That is, query the availability status of the storage block at the currently allocated block address. If the availability status indicates that the storage block at the currently allocated block address is unavailable, determine that the storage block at the currently allocated block address is the current bad storage block. Alternatively, if the availability status indicates that the storage block at the currently allocated block address is available, determine that the current allocated block address does not indicate the current bad storage block.
[0081] S330: Query the replacement forward table, and then execute S340. Specifically, the replacement forward table indicates the mapping from the block address of the replacement storage block to the block address of the bad storage block in the storage block sequence. Querying the replacement forward table yields the block address of the replacement storage block, which is used as the current write address.
[0082] S340: Allocate the current write block address, and then execute S350. For example, after obtaining the current write block address, you can allocate the current write block address and construct a current address mapping table for the current write address.
[0083] S350: Update the address mapping table, and then execute S360. Specifically, the current write block address is used to write the target data. The target data can be data written to an existing previous logical address. When updating the previous address mapping table to the current address mapping table, the mapping between the previous logical address and the previous write block address can be corrected to the mapping between the previous logical address and the current write block address.
[0084] S360: Determine whether the previously written block address indicates a replacement storage block. If yes, proceed to S370; otherwise, proceed to S380. More generally, in the storage block write method, the availability status of the storage block at the currently allocated block address is queried. If the availability status indicates that the storage block at the currently allocated block address is unavailable, the storage block at the currently allocated block address is determined to be the current bad storage block. Alternatively, if the availability status indicates that the storage block at the currently allocated block address is available, it is determined that the current allocated block address does not indicate the current bad storage block.
[0085] S370: Query the replacement reverse table, and then execute S380. Specifically, the replacement reverse table indicates the mapping from the block address of the bad storage block in the storage block sequence to the block address of the replacement storage block. Based on the previous logical address in the previous mapping table (in one example, the previous logical address is the same as the current logical address), the replacement reverse table is queried to obtain the previously written address.
[0086] S380: Update the valid page count of the previously written block address, and then execute S390. For example, if the previously written block address indicates that the storage block has not been replaced, decrement the VPC of the previously written block address by 1. If the previously written block address indicates that the storage block has been replaced, look up the replacement inversion table based on the previously written block address to obtain the block address of the previously bad storage block, and decrement the VPC of the block address of the previously bad storage block by 1 accordingly.
[0087] S390: Update the valid page count for the current write block address. For example, if the current write block address indicates that the storage block has not been replaced, increment the VPC of the current write block address by 1. If the current write block address indicates that the storage block needs to be replaced, look up the replacement inversion table based on the current write block address to obtain the block address of the current bad storage block, and accordingly increment the VPC of the current bad storage block address by 1.
[0088] It should be understood that the order of steps S380 and S390 can be parallel or interchanged.
[0089] For example, as Figure 3 Part of the storage block write process Figure 4 The steps of the bad block lookup process are shown below:
[0090] S410: Query based on the allocated block address, then execute S420. For example, after obtaining a write operation command, determine the current allocated block address based on the write operation command. The current allocated block address can be allocated based on the order of block addresses in flash memory, or it can be allocated considering wear leveling (WL) block address allocation. More generally, determine the current allocated block address based on the write operation command, and then, if the current allocated block address indicates a currently bad memory block, begin querying the replacement forward table.
[0091] S420: Query the storage block availability status table to determine if the storage block is available. If it is unavailable, proceed to S430; if it is available, proceed to S440. Specifically, the storage block availability status table indicates the mapping between the block identifier and the availability status of a storage block. For example, the availability status can be represented by bits, such as 1 indicating availability and 0 indicating unavailability. Querying the storage block availability status table improves the efficiency of determining the availability status of a storage block. More generally, in the storage block write method, the availability status of the storage block at the currently allocated block address is queried. If the availability status indicates that the storage block at the currently allocated block address is unavailable, the storage block at the currently allocated block address is determined to be the current bad storage block. Alternatively, if the availability status indicates that the storage block at the currently allocated block address is available, it is determined that the current allocated block address does not indicate the current bad storage block.
[0092] S430: Query and replace the forward table, then execute S420.
[0093] S440: Returns the allocated block address, which serves as the current write block address for the write operation command. For example, after obtaining the current write block address, you can allocate the current write block address and construct a current address mapping table for the current write address.
[0094] S450: Determine if the bad storage block is valid. If yes, proceed to S460; otherwise, proceed to S470. For example, invalid means the bad storage block has not been replaced. In this case, to improve the reliability of write operations, it is not advisable to perform write operations. Valid means the bad storage block has been replaced by a replacement storage block, so it can be directly written to the replacement storage block.
[0095] S460: Return the block address of the replacement storage block as the current write block address for the write operation command, and then execute S420. For example, after obtaining the current write block address, the current write block address can be allocated, and a current address mapping table of the current write address can be constructed.
[0096] S470: Return an invalid memory block response and determine the address of the next allocated block. For example, the current allocated block address can be updated based on the address of the next allocated block, and execution can continue to S410.
[0097] It should be understood that S410-S470 correspond to Figure 3 The S320 and S330 in it.
[0098] For example, as Figure 3 Part of the storage block write process Figure 5 The steps of the valid page count update process are shown:
[0099] S501: Start valid page counting, then execute S502. Specifically, after the current address mapping table is updated, proceed to the valid page counting for the corresponding block address (the superblock identifier).
[0100] S502: Obtain the logical address and the current block address, then execute S503. Specifically, the current block address can be the currently allocated block address, or it can be the currently written block address obtained by querying and replacing the forward table. After the current address mapping table is updated, the logical address and the current block address in the current address mapping table can be obtained. At this time, the logical address in the current address mapping table is the same as the logical address in the previous address mapping table before the update.
[0101] S503: Query the previous address mapping table based on the logical address to obtain the address of the previously written block, and then execute S504. Specifically, although the previous address mapping table has been updated, it can still be stored in the L2P table cache, and can be deleted after the effective page count is completed.
[0102] S504: Query and replace the reverse table based on the previously written block address, and then execute S502.
[0103] S505: Determine if the address of the previously written block is in the replacement reverse table. If yes, execute S506; otherwise, execute S507.
[0104] S506: Update the valid page count of the block address of the previously bad storage block, and then execute S508. That is, when the previously written block address indicates that a storage block should be replaced, the replacement reverse table is queried based on the previously written block address to obtain the block address of the previously bad storage block. Accordingly, the VPC of the block address of the previously bad storage block is decremented by 1, thereby further compatibility with the valid page count logic of the traditional write process.
[0105] S507: Update the valid page count of the previously written block address, and then execute S508. That is, when the previously written block address indicates that the storage block has not been replaced, decrement the VPC of the previously written block address by 1, thereby further ensuring compatibility with the valid page count logic of the traditional write process.
[0106] S508: Query the replacement reverse table based on the current write block address, and then execute S509.
[0107] S509: Determine if the current block address is in the replacement reverse table. If yes, execute S510; otherwise, execute S511.
[0108] S510: Update the valid page count of the block address of the currently written bad storage block. That is, when the current write block address indicates that a storage block needs to be replaced, the replacement reverse table is queried based on the current write block address to obtain the block address of the current bad storage block. Accordingly, the VPC of the current bad storage block address is incremented by 1, thereby further compatibility with the valid page count logic of the traditional write process.
[0109] S511: Update the valid page count for the currently allocated block address. In other words, when the current write block address indicates that a storage block has not been replaced, increment the VPC of the current write block address by 1, thus further ensuring compatibility with the valid page count logic of traditional write processes.
[0110] It should be understood that S501-S511 correspond to Figure 3 S360-S390. S504-S507 and S508-S511 can be executed in parallel or interchangeably. If S504 is executed first, the previous address mapping table can be deleted after S507 or S506 is completed.
[0111] The following will combine Figure 6Another embodiment of the storage block replacement method of the present invention is described. This storage block replacement method can be generated by an SSD controller based on a storage block availability status table, and includes:
[0112] S610: Replace the bad memory block in the second address range with the replacement memory block in the first address range of the memory block sequence, wherein the first address range and the second address range do not have the same block address.
[0113] S620: Generate a replacement reverse table based on the block address of the bad storage block in the storage block sequence.
[0114] S630: Generate a replacement forward list based on the block address of the replacement storage block in the storage block sequence.
[0115] In the storage block replacement method of this embodiment, the generated replacement forward table and replacement reverse table reflect the mapping relationship between the block address of the replacement storage block and the block address of the bad storage block. Through such a mapping relationship, the update logic of the traditional address mapping table and the update logic of the traditional effective page count are compatible, without having to make too many changes to the configuration of the traditional write process.
[0116] In other examples, to replace a bad block in the second address range with a replacement block in the first address range of the memory block sequence, a memory block whose sequence position indicated by its block address follows the bad block can be identified as the replacement block. Then, the block address of the replacement block is swapped with the block address of the bad block until the block address of the replacement block is in the second address range and the block address of the bad block is in the first address range. This example simplifies the memory block replacement logic and improves the efficiency of memory block replacement when implemented with hardware circuitry.
[0117] like Figure 7A As shown, in the memory block sequence, memory block M-1 can be used as an example of the second address range, and memory block M can be used as an example of the first address range. For example, memory blocks 2 and 6 can be replaced by memory blocks M and N in the second address range. Through such replacement, bad memory blocks are more concentrated in the first address range after memory block M.
[0118] In other examples, the proportion of bad blocks corresponding to the second address range in the block sequence can also be determined. Accordingly, as an example of replacing bad blocks in the second address range with replacement blocks from the first address range in the block sequence, when the proportion of bad blocks exceeds a preset threshold, replacement blocks from the first address range in the block sequence can be used to replace bad blocks in the second address range, ensuring that the proportion of bad blocks after replacement does not exceed the preset threshold. This results in bad blocks being distributed across fewer block addresses, improving write performance. Further, as... Figure 7B As shown, the storage block replacement process may include the following steps:
[0119] S710: When a bad storage block is generated in the available storage blocks, the available storage block resource pool 71 adds the block address of the bad storage block to the bad storage block resource pool 72. The bad storage block resource pool 72 is used to store at least one block address.
[0120] S720: In the bad storage block resource pool 72, the proportion of bad storage blocks in the block addresses is counted. Whenever the proportion exceeds a preset threshold, the block address of the bad storage block is added to the bad storage block replacement resource pool 73. The bad storage block replacement resource pool 73 is used to store at least one block address.
[0121] S730: The bad storage block replacement resource pool 73 adds the block addresses of bad storage blocks to the bad storage block replacement module 74 according to the prediction order, and performs storage block replacement. The bad storage block replacement module 74 stores the storage block sequence, and generates a replacement forward table and a replacement reverse table when performing storage block replacement.
[0122] S740: After the bad storage block replacement module 74 completes the storage block replacement, it outputs the block address of the replacement storage block to the available storage block resource pool 71.
[0123] Figure 8 This is a structural block diagram of an SSD controller according to another embodiment of the present invention. The SSD controller in this embodiment may be... Figure 1A and Figure 1B The SSD controller 104 in the middle includes:
[0124] Storage unit 810 stores a replacement forward table and a replacement reverse table, the replacement forward table indicating the mapping from the block address of a replacement storage block to the block address of a bad storage block in the storage block sequence, and the replacement reverse table indicating the mapping from the block address of a bad storage block to the block address of a replacement storage block in the storage block sequence.
[0125] The acquisition unit 820 acquires write operation commands for storage blocks in a memory, which includes multiple storage blocks arranged in an array. For example, the memory may be NAND flash memory managed by an SSD controller.
[0126] The first query unit 830 queries the replacement forward table to determine the block address of the replacement storage block to replace the current bad storage block, which is then used as the current write block address of the write operation command.
[0127] The first update unit 840 updates the previous address mapping table to the current address mapping table based on the current write block address.
[0128] The second query unit 850 queries the replacement reverse table based on the current write block address to determine the block address of the current bad storage block.
[0129] The second update unit 860 updates the valid page count of the block address of the currently bad storage block.
[0130] In the embodiment of the present invention, the replacement of bad storage blocks is achieved by using the block address of the storage block in the storage block sequence, which enables data to be written to the replacement storage block and avoids writing data to bad storage blocks, thereby improving write performance. In addition, the replacement forward table and the replacement reverse table reflect the mapping relationship between the block address of the replacement storage block and the block address of the bad storage block. Through such a mapping relationship, the update logic of the traditional address mapping table and the update logic of the traditional effective page count are compatible, without having to make too many changes to the configuration of the traditional write process.
[0131] In other examples, the first query unit and the second query unit are configured as a query circuit for performing queries on the replacement forward table and the replacement reverse table.
[0132] In other examples, the second update unit is also configured to: when the previously written block address in the previous address mapping table indicates a replacement storage block, query the replacement reverse table to determine the block address of the previously bad storage block replaced by the previously written block address, and then update the valid page count of the block address of the previously bad storage block.
[0133] In other examples, the second update unit is also used to update the valid page count of the previously written block address when the previously written block address in the previous address mapping table does not indicate a replacement storage block.
[0134] In other examples, the first query unit is also configured to: determine the current allocated block address based on the write operation command, and then, when the current allocated block address indicates the current bad storage block, begin querying the replacement forward table.
[0135] In other examples, the second update unit is also configured to: update the previous address mapping table to the current address mapping table based on the current allocated block address when the current allocated block address does not indicate the current bad storage block, and update the valid page count of the current allocated block address.
[0136] In other examples, the SSD controller further includes a third query unit that queries the availability status of the storage block at the currently allocated block address, and then, when the availability status indicates that the storage block at the currently allocated block address is unavailable, determines the storage block at the currently allocated block address as the currently bad storage block.
[0137] In other examples, the third query unit is also configured to: determine that the current allocated block address does not indicate the current bad storage block when the availability status indicates that the storage block at the current allocated block address is available.
[0138] The SSD controller in this embodiment is used to implement the corresponding methods in the foregoing method embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. Furthermore, the functional implementation of each module in the device of this embodiment can be referred to the description of the corresponding part in the foregoing method embodiments, which will also not be repeated here.
[0139] Figure 9 This is a structural block diagram of a memory block replacement apparatus according to another embodiment of the present invention. The memory block replacement apparatus of this embodiment corresponds to a memory block replacement method and includes:
[0140] Replacement module 910 replaces bad memory blocks in the second address range with replacement memory blocks in the first address range of the memory block sequence, wherein the first address range and the second address range do not have the same block address.
[0141] The first generation module 920 generates a replacement reverse table based on the block address of the bad storage block in the storage block sequence.
[0142] The second generation module 930 generates a replacement forward table based on the block address of the replacement storage block in the storage block sequence.
[0143] In the storage block replacement method of this embodiment, the generated replacement forward table and replacement reverse table reflect the mapping relationship between the block address of the replacement storage block and the block address of the bad storage block. Through such a mapping relationship, the update logic of the traditional address mapping table and the update logic of the traditional effective page count are compatible, without having to make too many changes to the configuration of the traditional write process.
[0144] In other examples, the replacement module is also used to: determine the proportion of bad storage blocks corresponding to the second address range in the storage block sequence, and then, when the proportion of bad storage blocks exceeds a preset threshold, use the replacement storage blocks of the first address range in the storage block sequence to replace the bad storage blocks of the second address range, so that the proportion of bad storage blocks after replacement does not exceed the preset threshold.
[0145] In other examples, the replacement module is specifically used to: determine a storage block whose sequence position indicated by the block address follows the bad storage block as a replacement storage block; and swap the block address of the replacement storage block with the block address of the bad storage block until the block address of the replacement storage block is within the second block address range and the block address of the bad storage block is within the first block address range.
[0146] The storage block replacement device of this embodiment is used to implement the corresponding methods in the foregoing method embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. Furthermore, the functional implementation of each module in the device of this embodiment can be referred to the description of the corresponding part in the foregoing method embodiments, which will also not be repeated here.
[0147] Furthermore, the specific implementation of each step in the program can be found in the corresponding descriptions of the steps and units in the above method embodiments, and will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0148] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of the present invention can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0149] The methods described above according to embodiments of the present invention can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code originally stored on a remote recording medium or a non-transitory machine-readable medium and subsequently stored on a local recording medium, downloaded via a network. Thus, the methods described herein can be processed by software stored on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods described herein. Furthermore, when a general-purpose computer accesses code used to implement the methods shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for executing the methods shown herein.
[0150] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the embodiments of the present invention.
[0151] The above embodiments are only used to illustrate the embodiments of the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of the present invention, and the patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A method for writing a storage block, comprising: Obtain a write operation command for a storage block in a memory, the memory comprising multiple storage blocks ordered in an array; The replacement forward table is queried to determine the block address of the replacement storage block that replaces the current bad storage block, which is used as the current write block address of the write operation command. The replacement forward table indicates the mapping from the block address of the replacement storage block to the block address of the bad storage block in the storage block sequence. Based on the current write block address, update the previous address mapping table to the current address mapping table; Based on the current write block address, the replacement reverse table is queried to determine the block address of the current bad storage block. The replacement reverse table indicates the mapping from the block address of the bad storage block to the block address of the replacement storage block in the storage block sequence. Update the valid page count of the block address of the currently bad storage block.
2. The method according to claim 1, wherein, The method further includes: When the previously written block address in the previous address mapping table indicates a replacement storage block, the replacement inversion table is queried to determine the block address of the previously bad storage block that was replaced by the previously written block address; Update the valid page count of the block address of the previously bad storage block.
3. The method according to claim 1, wherein, The method further includes: If the address of the previously written block in the previous address mapping table does not indicate a replacement storage block, update the valid page count of the previously written block address.
4. The method according to claim 1, wherein, The method further includes: The address of the currently allocated block is determined based on the write operation command; When the current allocated block address indicates the current bad storage block, the replacement forward table is queried.
5. The method according to claim 4, wherein, The method further includes: When the current allocated block address does not indicate the current bad memory block, the previous address mapping table is updated to the current address mapping table based on the current allocated block address, and the valid page count of the current allocated block address is updated.
6. The method according to claim 4, wherein, The method further includes: Query the availability status of the storage block at the currently allocated block address; When the available status indicates that the storage block at the currently allocated block address is unavailable, the storage block at the currently allocated block address is determined to be the currently bad storage block.
7. The method according to claim 6, wherein, The method further includes: When the available status indicates that the storage block at the current allocated block address is available, it is determined that the current allocated block address does not indicate the current bad storage block.
8. A method for replacing a storage block, comprising: A bad memory block in the second address range is replaced by a replacement memory block in the first address range of the memory block sequence, wherein the first address range and the second address range do not have the same block address; A replacement reverse table is generated based on the block address of the bad storage block in the storage block sequence; A replacement forward list is generated based on the block address of the replacement storage block in the storage block sequence. Wherein, the replacement reverse table and the replacement forward table are the replacement reverse table and the replacement forward table in the storage block writing method according to any one of claims 1-7.
9. The method according to claim 8, wherein, The method further includes: Determine the proportion of bad memory blocks corresponding to the second block address range in the memory block sequence; The step of replacing a bad memory block in the second address range with a replacement memory block in the first address range of the memory block sequence includes: When the proportion of bad storage blocks exceeds a preset threshold, the bad storage blocks in the second address range are replaced by replacement storage blocks in the first address range of the storage block sequence, so that the proportion of bad storage blocks after replacement does not exceed the preset threshold.
10. The method according to claim 8, wherein, The step of replacing bad memory blocks in the second address range with replacement memory blocks in the first address range of the memory block sequence includes: The block address indicates the sequence position of the memory block following the bad memory block, which is then used as the replacement memory block; The block address of the replacement storage block is swapped with the block address of the bad storage block until the block address of the replacement storage block is within the second block address range and the block address of the bad storage block is within the first block address range.
11. An SSD controller, comprising: A storage unit stores a forward replacement table and a reverse replacement table, wherein the forward replacement table indicates a mapping from the block address of a replacement storage block to the block address of a bad storage block in a storage block sequence, and the reverse replacement table indicates a mapping from the block address of a bad storage block to the block address of a replacement storage block in the storage block sequence. The acquisition unit is responsible for writing operation commands to storage blocks in a memory, wherein the memory includes multiple storage blocks sorted in an array. The first query unit queries the replacement forward table to determine the block address of the replacement storage block that replaces the current bad storage block, and uses it as the current write block address of the write operation command. The first update unit updates the previous address mapping table to the current address mapping table based on the current write block address; The second query unit queries the replacement reverse table based on the current write block address to determine the block address of the current bad storage block; The second update unit updates the valid page count of the block address of the currently bad storage block.
12. The SSD controller according to claim 11, wherein, The first query unit and the second query unit are configured as a query circuit, which is used to perform queries on the replacement forward table and the replacement reverse table.
13. A memory block replacement device, comprising: The replacement module replaces the bad memory block in the second address range with the replacement memory block in the first address range of the memory block sequence, wherein the first address range and the second address range do not have the same block address; The first generation module generates a replacement reverse table based on the block address of the bad storage block in the storage block sequence; The second generation module generates a replacement forward table based on the block address of the replacement storage block in the storage block sequence; Wherein, the replacement reverse table and the replacement forward table are the replacement reverse table and the replacement forward table in the storage block writing method according to any one of claims 1-7.
Citation Information
Patent Citations
Memory system
CN101681299A
Bad block management method and system for NAND Flash memory
CN110795044A