Storage device and control method thereof

By using address mapping and anti-mapping tables in flash memory storage devices, combined with encoding and decoding units, the problem of physical address changes and data loss caused by logical address editing is solved, efficient garbage collection and data error correction are achieved, and the storage device is improved data reliability.

CN118426706BActive Publication Date: 2024-09-06合肥康芯威存储技术有限公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410881456.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-06
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

During the life cycle of a flash storage device, frequent editing of logical addresses leads to changes in physical addresses, resulting in loss of valid data and retention of invalid data, reducing the reliability of data storage, especially data loss caused by unclear distinctions during the garbage collection process. .

Method used

By storing the address mapping table and the address de-mapping table in the flash memory particles, the main controller calls the control firmware to perform the recycling error correction process during garbage collection, using the encoding unit, valid data counting unit and decoding unit to ensure that the data is transferred to new storage blocks and records the number of valid data, with a higher priority than garbage collection and host read and write instructions, ensuring synchronous detection and error correction of data.

Benefits of technology

It achieves efficient garbage collection when the storage device space is insufficient, improves host read and write efficiency, and improves the fault tolerance rate of garbage collection when garbage collection and valid data detection are performed simultaneously to prevent valid data from being erased, thereby improving Data storage reliability of storage devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426706B
    Figure CN118426706B
Patent Text Reader

Abstract

The present invention provides a storage device and a control method thereof, comprising: a plurality of flash memory particles and a main controller, when the garbage collection process of the flash memory particles fails, the main controller calls the control firmware and executes the recycling error correction process; wherein the control firmware comprises: an encoding unit, the encoding object of the encoding unit is the first type of user data and the address inverse mapping table of the first type of user data, and the output result of the encoding unit is the second type of user data, wherein the storage data of the flash memory particles is the second type of user data, and the data read and written by the host is the first type of user data; a valid data counting unit, used to store the number of valid data of each storage block in the flash memory particles; and a decoding unit, the decoding object of the decoding unit is the second type of user data. The present invention provides a storage device and a control method thereof, which can improve the data storage reliability of the storage device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a storage device and a control method thereof. Background Art

[0002] Flash memory is widely used in a variety of storage devices because it is not easily volatile when power is off. Data written into the flash memory has an address mapping relationship, where the address mapping relationship refers to the association between the logical address and the physical address of the written data. In a storage device using flash memory as the storage medium, the address mapping relationship of the written data is stored in the form of an address mapping table.

[0003] In a storage device that uses flash memory as the storage medium, the same logical address will be edited multiple times during the life cycle of the storage device, so the physical address corresponding to a logical address will change. After the logical address is re-edited, the original corresponding physical address will become invalid, so the data stored in the corresponding physical address will also become invalid data. In the garbage collection process (GC) of the storage device, due to the inability to distinguish between valid data and invalid data, it is very likely that valid data will be lost while invalid data will be retained, resulting in reduced data storage reliability of the storage device. Summary of the invention

[0004] An object of the present invention is to provide a storage device and a control method thereof, which can improve the data storage reliability of the storage device.

[0005] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:

[0006] The present invention provides a storage device, comprising:

[0007] A plurality of flash memory particles, each of which stores an address mapping table and an address inverse mapping table, wherein the address mapping table stores a mapping relationship between a data logical address and a data physical address, and the address inverse mapping table stores a mapping relationship between a data physical address and a data logical address; and

[0008] A main controller, electrically connected to the flash memory particles and the host, and when an error occurs in the garbage collection process of the flash memory particles, the main controller calls the control firmware and executes a recycling error correction process;

[0009] The control firmware includes:

[0010] an encoding unit, wherein an encoding object of the encoding unit is first-category user data and an address inverse mapping table of the first-category user data, and an output result of the encoding unit is second-category user data, wherein the storage data of the flash memory particles is the second-category user data, and the data read and written by the host is the first-category user data;

[0011] A valid data counting unit, storing the number of valid data of each storage block in the flash memory particle; and

[0012] A decoding unit, wherein a decoding object of the decoding unit is the second category of user data.

[0013] In an embodiment of the present invention, the number of valid data is the number of storage pages storing valid data in the storage block.

[0014] In an embodiment of the present invention, the control firmware includes an address allocation unit, and the address allocation unit stores the remaining storage capacity of the plurality of storage blocks.

[0015] In one embodiment of the present invention, the control firmware includes a garbage collection unit. When the remaining storage capacity of the flash memory particle is less than a preset threshold, the garbage collection unit starts a garbage collection process and uses the storage block with the least amount of valid data as a recycled block.

[0016] In one embodiment of the present invention, the sign of the garbage collection process error is that the number of valid data in the storage block is greater than zero when the garbage collection process ends.

[0017] In one embodiment of the present invention, the second type of user data has a first physical address, a second physical address and a third physical address, wherein the first physical address is the physical address where the second type of user data is stored, the second physical address is the physical address stored in the address mapping table, and the third physical address is the physical address stored in the address de-mapping table obtained after decoding the second type of user data. When the first physical address and the second physical address are consistent or the first physical address and the third physical address are consistent, the second type of user data is valid data.

[0018] In one embodiment of the present invention, during the garbage collection transfer process, the data transferred to the new storage block is the new second-category user data, in which the first-category user data remains unchanged, and the address inverse mapping table is a new address inverse mapping table.

[0019] The present invention provides a control method for a storage device, based on the storage device as described above, comprising the following steps:

[0020] When executing a write command from the host, an address mapping table and an address reverse mapping table are formed according to the logical address and the physical address of the first type of user data, and the address mapping table and the address reverse mapping table are stored in the flash memory particles, wherein the address mapping table stores a mapping relationship between the data logical address and the data physical address, and the address reverse mapping table stores a mapping relationship between the data physical address and the data logical address;

[0021] Encoding the first category of user data and the address inverse mapping table of the first category of user data, synthesizing the second category of user data, and storing the second category of user data in the flash memory particles;

[0022] In the reading and writing process of the second type of user data, the number of valid data in each storage block in the flash memory particle is recorded;

[0023] When the remaining storage capacity of the flash memory particles is insufficient, the main controller enables a garbage collection process; and

[0024] When the garbage collection process of the flash memory particles fails, the main controller calls the control firmware and executes the recycling error correction process.

[0025] In one embodiment of the present invention, the steps of executing the recovery error correction process include:

[0026] sequentially reading the second type of user data of the recycled blocks, and decoding the second type of user data to obtain a third physical address of the second type of user data;

[0027] comparing the third physical address with the first physical address of the second type of user data, and if the third physical address is consistent with the first physical address, transferring the second type of user data to a new storage block; and

[0028] The recycled block is traversed until the number of valid data in the recycled block is reset to zero.

[0029] In one embodiment of the present invention, the priority of the recovery and error correction process is higher than the garbage collection process and the read and write instructions of the host.

[0030] As described above, the present invention provides a storage device and a control method thereof, which can not only perform garbage collection in a timely and efficient manner when the storage device space is insufficient to free up sufficient storage space and improve the host reading and writing efficiency, but also improve the fault tolerance of garbage collection when garbage collection and valid data detection are performed simultaneously to avoid valid data from being erased, thereby improving the data storage reliability of the storage device.

[0031] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0033] Figure 1 FIG. 4 is a schematic diagram of the structure of a storage device in an embodiment of the present invention.

[0034] Figure 2 FIG. 4 is a schematic diagram of the structure of a flash memory particle in an embodiment of the present invention.

[0035] Figure 3 The figure is a schematic diagram of the mapping relationship between the logical address and the physical address in one embodiment of the present invention.

[0036] Figure 4 Schematic diagram of an address mapping table and an address de-mapping table in an embodiment of the present invention.

[0037] Figure 5 FIG. 1 is a schematic diagram of the structure of the control firmware in one embodiment of the present invention.

[0038] Figure 6 The flowchart of the control method of the storage device in one embodiment of the present invention.

[0039] In the figure: 10, storage device; 20, main controller; 201, microprocessor; 202, host interface controller; 203, cache controller; 204, buffer; 205, flash memory controller; 206, error correction module; 30, flash memory particles; 301, storage blocks; 302, storage pages; 310, address mapping table; 320, address reverse mapping table; 40, memory; 50, control firmware; 501, encoding unit; 502, decoding unit; 503, address allocation unit; 504, valid data counting unit; 505, garbage collection unit; 60, host; 701, first type of user data; 702, second type of user data. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0041] The user data written into the storage device includes a logical address and a physical address, wherein the physical address is the storage location of the user data in the storage device. While writing the user data, an address mapping relationship is established between the logical address and the physical address of the user data, so that when the user data is retrieved, the physical address of the user data can be quickly found according to the address mapping relationship. Among them, the address mapping relationship of the user data can be stored in a specific position of the storage device in the form of a linked list. In this embodiment, the linked list of the address mapping relationship of the user data is set as an address mapping table. The memory provided by the present invention is a flash memory or a storage device including a flash memory, such as an SM flash card, a CF card, a multimedia card (Multi MediaCard, MMC), a secure digital card (Secure Digital Card, SD card), a memory stick and a micro hard disk, etc. Specifically, in the present invention, the storage medium of the storage device is a NAND flash memory.

[0042] See also Figure 1As shown, in one embodiment of the present invention, the present invention provides a storage device 10, which includes a main controller 20, a flash memory particle 30 and a memory 40. The main controller 20 and the flash memory particle 30 can be packaged into a storage set. In this embodiment, the main controller 20 includes a microprocessor 201, a host interface controller 202, a cache controller 203, a buffer 204 and a flash memory controller 205, and an error correction module 206. The microprocessor 201 is a reduced instruction system computer (RISC), and is specifically an ARM processor. The microprocessor 201 is electrically connected to the host interface controller 202, the cache controller 203 and the flash memory controller 205. The host interface controller 202 is electrically connected to the host 60 through an interface to receive instructions and data from the host 60 and feedback data from the main controller 20. The connection interface between the host 60 and the main controller 20 can be a SATA hard disk, a high-speed serial computer expansion bus interface (Peripheral Component Interconnect express, PCIe), and a SAS interface. The cache controller 203 is electrically connected to the memory 40 and the buffer 204 to control the transfer and storage of data. In this embodiment, the flash memory controller 205 is electrically connected to the error correction module 206 to correct the data read out of the flash memory particles 30 during the reading process of the flash memory particles 30. The error correction module 206 can perform error checking and correction on the flash memory particles 30. The memory 40 can be a read-only memory (ROM). The control firmware 50 is stored in the memory 40, and the control firmware 50 is burned into the memory 40. In the control process of the storage device 10, the microprocessor 201 can read and call the control firmware 50 to execute part of the control process of the storage device 10.

[0043] See also Figure 1 and Figure 2 As shown, in one embodiment of the present invention, the buffer 204 may be a static random access memory (SRAM). The storage device 10 includes one or more flash memory particles 30. The buffer 204 forms a cache area of ​​the storage device 10, and the plurality of flash memory particles 30 form a flash memory area of ​​the storage device 10. In this embodiment, the flash memory particles 30 are NAND flash memories. Figure 2As shown, the flash memory particle 30 includes a plurality of storage blocks 301. In the present embodiment, the storage block 301 is a physical block of a NAND flash memory, and each storage block 301 has a unique device number. The storage block 301 includes a plurality of storage units 302, and the storage unit 302 is a physical page of a NAND flash memory. When writing user data, the user data has a certain logical address, and the user data is written to the flash memory area in a random write or sequential write manner. The user data is written into the storage page 302, and the storage page 302 is used as a unit, and the logical address of the user data corresponds to the physical address of multiple storage pages 302. If new user data is to be written to the storage block 301, and the storage block 301 is already partially or fully occupied, the storage block 301 must be erased and then the user data is written. It should be noted that the written data is in units of the storage page 302, and the erased data is in units of the storage block 301.

[0044] See also Figures 1 to 4 As shown, in one embodiment of the present invention, the user data stored in the flash memory particle 30 includes valid data and invalid data. Valid data refers to data in which the physical address and the logical address in the address mapping table 310 are corresponding. Invalid data refers to data for which there is no corresponding address mapping table 310 or the physical address and the logical address in the address mapping table 310 do not correspond. In the use process of the storage device 10, the physical address of the same logical address is changeable. For example, at the beginning, the physical address corresponding to the user data of the logical address LOG1 is MAC1. Subsequently, the user data is edited, and the physical address corresponding to the user data of the logical address LOG1 is changed to MAC2. Then the stored data in the physical address MAC1 will become invalid data. After the physical address is changed, the address mapping table 310 of the user data and the number of valid data in the storage block 301 are modified accordingly. It should be noted that the process of modifying the address mapping table 310 and the number of valid data and editing the user data may not necessarily occur in sequence. According to the control methods of different storage devices 10, if the editing of user data is completed, the invalid address mapping table 310 is immediately deleted and the corresponding invalid data is deleted, which will greatly slow down the normal working process of the storage device 10. In the working process of the storage device 10, the operation priority settings of different storage devices 10 are different. For example, in this embodiment, the read and write commands of the host 60 are the first priority to avoid data loss. The adjustment of the address mapping table 310 is the second priority to avoid the invalidation of valid data. Adjusting the valid data mark and the garbage collection process is the third priority. Among them, adjusting the valid data mark and the garbage collection process can be performed simultaneously. In other embodiments of the present invention, due to different control methods of the storage device 10, the priorities of multiple storage operations can be set, and are not limited to the storage operations mentioned in this embodiment.

[0045] See also Figure 1 and Figure 2 , Figure 4 As shown, in one embodiment of the present invention, the data in the storage block 301 includes valid data and invalid data. The number of valid data is measured by the number of storage pages 302. For example, a storage block 301 has 16 storage pages 302, and the storage block 301 is full. Then the maximum number of valid data in the storage block 301 is 16, and the minimum number of valid data is 0. According to the number of valid data, the garbage collection process can be executed in time for the storage block 301 that needs to be recovered the most. In this embodiment, whenever the user data is edited, the number of valid data in the storage block 301 can be adjusted synchronously while the address mapping table 310 of the user data is changed, so as to ensure that the garbage collection process can be enabled in time according to the number of valid data. In other embodiments of the present invention, a valid data update cycle can also be set, and whenever the cycle ends, the existing address mapping table 310 is read to update the number of valid data in the storage block 301 in the storage device 10 once. It should be noted that for different storage devices 10, the cycle setting of data update can be different.

[0046] See also Figure 1 and Figure 2As shown, in one embodiment of the present invention, the garbage collection process can occur at any time of the storage device 10. In this embodiment, when the storage space of the storage device 10 is insufficient, the garbage collection process is the first priority. Specifically, at this time, the host 60 issues a data write instruction to the flash memory particle 30, and the storage space of the storage device 10 is insufficient to support data writing, then the garbage collection process is the first priority. At this time, when the host 60 issues a data read instruction to the flash memory particle 30, even if the storage space of the storage device 10 is insufficient at this time, the data read instruction of the host 60 is still the first priority operation of the main controller 20. After completing the data read instruction, the garbage collection process is executed again to free up enough space in the storage device 10 for the next data writing. Among them, the main controller 20 sets a storage capacity threshold. When the storage margin of the storage device 10 is less than the storage capacity threshold, the storage space of the storage device 10 is insufficient at this time, and the garbage collection process is ready to start. In the garbage collection process, the storage block 301 with the least number of valid data is used as the source block, and the storage block 301 with the largest remaining space is used as the target block. The target block may be a blank storage block 301 or a storage block 301 storing data. In this embodiment, the valid data in the source block is transferred to the target block, thereby completing the process of garbage collection. After the valid data is transferred to the target block, the source block is cleared and the source block is restored to a blank storage block 301. When the storage device 10 is ready to perform garbage collection, the storage device 10 begins to check and record the valid data and invalid data of each storage block 301. In the process of checking and recording the valid data and invalid data of each storage block 301, the garbage collection process is also carried out synchronously.

[0047] See also Figures 1 to 4 As shown, in one embodiment of the present invention, the address mapping table 310 is checked to confirm whether the current stored data is valid data. Figure 3As shown, for example, the storage block 301 includes n storage pages 302, wherein the physical addresses of the n storage pages 302 are MAC1, MAC1 to MACn. In the step of checking the address mapping table 310, the address mapping table 310 located in the cache area is directly read, or the address mapping table 310 in the flash memory area is read into the cache area, and then the address mapping table 310 located in the cache area is read. In this embodiment, the storage data of the physical address MAC1, the physical address MAC1 to the physical address MACn are read in sequence, and the address mapping table 310 is searched corresponding to the logical address of the storage data. When the physical address of the storage data in the address mapping table 310 is consistent with the currently read physical address, the storage data is valid data. When the physical address of the storage data in the address mapping table 310 is different from the currently read physical address, the storage data is invalid data. Specifically, the logical address of the storage data in the physical address MAC1 is obtained, for example, the logical address of the data stored in MAC1 is LOG6. In the actual address mapping table 310, the physical address corresponding to the data with the logical address LOG6 is MAC6. The data stored in the physical address MAC1 is invalid data. For another example, the logical address of the data stored in MAC1 is LOG1. In the actual address mapping table 310, the physical address corresponding to the data with the logical address LOG1 is MAC1. Then the data stored in the physical address MAC1 is valid data. The storage page 302 in the storage block 301 is traversed and read to confirm the number of valid data in the storage block 301. It should be noted that the steps of checking and confirming the valid data are performed synchronously with the garbage collection process. Therefore, if the garbage collection process is fast, the valid data that has not been checked may be cleared before the valid data check is completed, causing data storage abnormality.

[0048] See also Figures 1 to 4As shown, in another embodiment of the present invention, the address mapping table 310 is stored in the cache area, and when the refresh cycle is reached, the address mapping table 310 is transferred to the flash memory area. In this embodiment, the address mapping table 310 has a search direction, and specifically is the logical address LOGx to the physical address MACx. For example, when searching for user data a, the address mapping table 310 is searched according to the logical address LOGa of the user data a, and the physical address of the user data A is found to be MACa, and the storage data is read from the physical address MACa, thereby reading the user data a. In this embodiment, an address inverse mapping table 320 is set, and the address inverse mapping table 320 is stored in the flash memory area. The address inverse mapping table 320 has a search direction, and specifically is the physical address MACx to the logical address LOGx. For example, when searching for data of the storage block 301, the user data of the physical address MACb is read, and the logical address of the user data is found according to the address inverse mapping table 320. For example, in the address inverse mapping table 320, the logical address of the user data is LOGb. In this embodiment, by comparing the actual logical address of the user data with the recorded logical address, it is determined whether the user data is valid data. Specifically, if the logical address of the user data is consistent with the logical address of the address demapping table 320, the user data is valid data. If the logical address of the user data is different from the logical address of the address demapping table 320, the user data is invalid data. In this embodiment, in the step of searching for valid data, the number of valid data of the storage block 301 starts at 0. If the storage data of the storage page 302 is valid data, the number of valid data of the storage block 301 is increased by one. If the storage data of the storage page 302 is invalid data, the number of valid data of the storage block 301 remains unchanged. In other embodiments of the present invention, the number of valid data of the storage block 301 may also be the number of storage pages 302. For example, if the storage block 301 has 16 storage pages 302, the number of valid data is 16. If the storage data of the storage page 302 is valid data, the number of valid data of the storage block 301 remains unchanged. If the storage data of the storage page 302 is invalid data, the number of valid data of the storage block 301 is reduced by one. It should be noted that in the control process of the storage device 10, the address mapping table 310 and the address de-mapping table 320 may have abnormal situations, such as loss. In the process of checking valid data and invalid data, valid data may be judged as invalid data, resulting in data loss.

[0049] See also Figures 1 to 4As shown, in one embodiment of the present invention, the control firmware 50 includes an encoding unit 501 and a decoding unit 502. In this embodiment, the storage data written into the storage device 10 includes a first type of user data 701 and a second type of user data 702. The first type of user data 701 is storage data that has not been encoded, and the second type of user data 702 is storage data processed by the encoding unit 501. The encoding unit 501 encodes the first type of data 701 and the address reverse mapping table 320, so that the first type of data 701 and the address reverse mapping table 320 are integrated into the same data, that is, the second type of user data 702. Specifically, the encoding unit 501 stores an encoding key for encrypting the first type of user data 701 and the address reverse mapping table 320. It should be noted that the present invention does not limit the encoding algorithm type of the encoding unit 501. In this embodiment, for example, the first type of user data 701 and the address reverse mapping table 320 are encrypted by Huffman lossless compression encoding to obtain the second type of user data 702. In this embodiment, the decoding unit 502 stores a key KEY value, and is capable of decoding the second type of user data 702 to obtain the first type of user data 701 and the address inverse mapping table 320 .

[0050] See also Figures 1 to 4 As shown, in one embodiment of the present invention, the second type of user data 702 is stored in the flash memory particle 30. In this embodiment, in the process of encoding and synthesizing the second type of user data 702, the address inverse mapping table 320 used includes the mapping relationship between the physical address and the logical address of the first type of user data 701. If an abnormal power failure or an error in the garbage collection process occurs, resulting in some valid data being abnormally identified as invalid data, the second type of user data 702 is directly decoded to obtain the address inverse mapping table 320 of the user data.

[0051] See also Figures 1 to 4 As shown, in one embodiment of the present invention, when the host 60 needs to read out user data, the address mapping table 310 is queried according to the logical address of the user data, the main controller 20 finds the physical address of the user data, and then reads out the second type of user data 702 from the corresponding physical address, the decoding unit 502 decodes the second type of user data 702 to obtain the first type of user data 701, and the host 60 reads out the decoded first type of user data 701.

[0052] See also Figures 1 to 4As shown, in one embodiment of the present invention, the control firmware 50 includes an address allocation unit 503 and a valid data counting unit 504. When the host 60 writes data to the storage device 10, the address allocation unit 503 obtains the still blank storage page 302 in the flash memory particle 30, arranges the physical address to be written for the data to be written, and forms an address mapping table 310 of the first type of user data 701. According to the address mapping table 310, the address allocation unit 503 forms an address reverse mapping table 320 of the first type of user data 701, and sends the address reverse mapping table 320 to the encoding unit 502. The encoding unit 502 encodes and encrypts the first type of user data 701 and the address reverse mapping table 320 to form the second type of user data 702. Among them, after the first type of user data 701 is written, the number of valid data of the corresponding storage block 301 is recorded by the valid data counting unit 504. Specifically, after the first type of user data 701 is written, the number of valid data of the corresponding storage block 301 is increased by one.

[0053] See also Figures 1 to 4 As shown, in one embodiment of the present invention, when the host 60 edits the user data, after reading out the first type of user data 701, the first type of user data 701 is changed, and the first type of user data 701 is rewritten into the flash memory particle 30. Wherein, the data of the first type of user data 701 is rewritten, and the physical address is changed. The address allocation unit 503 adjusts the physical address for the edited first type of user data 701, and forms a new address mapping table 310 and a new address inverse mapping table 320. The edited first type of user data 701 and the new address inverse mapping table 320 are encoded and encrypted by the encoding unit 501 to obtain new second type of user data 702, and the new second type of user data 702 is written into the corresponding physical address. In this embodiment, in the process of editing the first type of user data 701, if a new address inverse mapping table 320 is generated, when the new second type of user data 702 is written, the user data stored in the old physical address becomes invalid data. In this embodiment, the user data stored in the old physical address is no longer encrypted, but is directly stored in the flash memory particle 30 in the form of the first type of user data 701. Therefore, the valid data is stored in the form of the second type of user data 702, and the invalid data is stored in the form of the first type of user data 701. In the process of garbage collection, it is possible to quickly and clearly determine which data is invalid data.

[0054] See also Figures 1 to 4As shown, in one embodiment of the present invention, when the host 60 edits the user data, if the first type of user data 701 is edited, the valid data counting unit 504 reduces the number of valid data of the storage block 301 corresponding to the old physical address by one. After the new second type of user data 702 is written, the valid data counting unit 504 increases the number of valid data of the storage block 301 corresponding to the new physical address by one. In this embodiment, during the editing process of the first type of user data 701, after the second type of user data 702 to be edited is read from the physical address, the second type of user data 702 is decoded and decomposed into the first type of user data 701 and the address inverse mapping table 320. After the first type of user data 701 is edited, the originally invalid address inverse mapping table 320 can be deleted. It should be noted that in this embodiment, while the address inverse mapping table 320 is encrypted and integrated in the second type of user data 702, it can also be stored separately in the cache area or the flash memory area. In the garbage collection process, the address inverse mapping table 320 stored in the cache area or the flash memory area is checked first.

[0055] See also Figures 1 to 5 As shown, in one embodiment of the present invention, the control firmware 50 includes a garbage collection unit 505. The garbage collection unit 505 is used to execute a garbage collection process. In the garbage collection process, the garbage collection unit 505 recycles valid data and removes invalid data. When the storage space of the storage device 10 is insufficient, the garbage collection process is started. The garbage collection process recycles at least one storage block 301 until the storage margin of the storage device 10 is greater than the capacity threshold. It should be noted that the present invention does not limit the capacity threshold, nor does it limit the number of storage blocks 301 recovered in the garbage collection process.

[0056] See also Figures 1 to 5 As shown, the present invention provides a control method for a storage device 10, and the control method for the storage device 10 includes steps S10 to S70.

[0057] Step S10: In the garbage collection process, the second type of user data 702 in the source block is read in sequence, wherein the source block is a storage block with the least amount of valid data, and the physical address of the second type of user data 702 is the first physical address.

[0058] Step S20: read the address mapping table of the second type of user data 702, obtain the physical address in the address mapping table, and use it as the second physical address.

[0059] Step S30: If the first physical address and the second physical address are consistent, the second type of user data 702 is valid data, the second type of user data 702 is re-encoded, and the second type of user data 702 is transferred to a new storage block.

[0060] Step S40: If valid data is still stored in the source block after the garbage collection process is completed, the system reports an error and starts a recycling error correction process.

[0061] Step S50: In the recovery error correction process, the second type of user data 702 in the source block is read in sequence, and the second type of user data 702 is decoded to obtain the first type of user data 701 and the address inverse mapping table.

[0062] Step S60: Use the physical address in the address demapping table as the third physical address. When the third physical address is consistent with the first physical address, the first type of user data 701 is valid data. Encode the first type of user data 701 and transfer it to a new storage block.

[0063] Step S70: traverse the source block in the recovery and error correction process until the number of valid data in the source block is reset to zero, and then end the recovery and error correction process.

[0064] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S10, in the garbage collection process, the source block and the target block are first obtained. The source block is the storage block 301 with the least number of valid data, and the target block is the storage block 301 with the largest remaining capacity. When there is a blank storage block 301 in the flash memory particle 30, the blank storage block 301 is preferentially set as the target block. In the garbage collection process, the valid data of the source block is transferred to the target block. The data stored in the source block is the second type of user data 702. In step S10, the second type of user data 702 in the source block can be read in sequence according to the address numbering order of the storage page 302 in the source block. The physical address of the second type of user data 702 is set to the first physical address. Specifically, the first physical address is the address of the storage page 302 from which the second type of user data 702 is read.

[0065] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S20, according to the logical address of the second type of user data 702, the address mapping table 310 is queried to obtain the physical address in the address mapping table 310 as the second physical address. Specifically, the second physical address is the address data recorded in the address mapping table 310. The second physical address may be the same as the first physical address, or may be different from the first physical address. In step S30, the first physical address and the second physical address are compared. If the first physical address and the second physical address are different, the second type of user data 702 currently read out is invalid data. If the first physical address and the second physical address are the same, the second type of user data 702 currently read out is valid data. The processing step for invalid data is to continue reading the storage data of the next storage page 302.

[0066] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S30, the processing step for valid data is to decode the second type of user data 702 currently read out to obtain the first type of user data 701 and the address inverse mapping table 320. In this embodiment, since the first type of user data 701 is to be moved to other physical addresses, the read address inverse mapping table 320 is invalid. The decoded address inverse mapping table 320 is retained, and firstly a new physical address is allocated to the decoded first type of user data 701 by the address allocation unit 503, and a new address inverse mapping table 320 is generated according to the new physical address and the logical address of the first type of user data 701. Then, the first type of user data 701 and the new address inverse mapping table 320 are integrated together by the encoding unit 501 to form new second type of user data 702. Then, the new second type of user data 702 is transferred to the allocated physical address. It should be noted that in this embodiment, a step of preferentially allocating physical addresses is provided to avoid that the address inverse mapping table 320 of the first type of user data 701 has not been encoded when power failure occurs. In another embodiment of the present invention, the first type of user data 701 may be written into a new physical address, and while forming a new address mapping table 310, a new address inverse mapping table 320 is also formed. Then, the first type of user data 701 and the new address inverse mapping table 320 are encoded to obtain the second type of user data 702, and the second type of user data 702 is used to overwrite the first type of user data 701.

[0067] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S30, in the garbage collection process, the transfer of valid data is a copy transfer. Because the original valid data is transferred, the physical address in the address mapping table 310 of the valid data originally stored in the source block becomes invalid, so the original valid data in the source block will become invalid data after the transfer. In this embodiment, each time the valid data is transferred, the number of valid data in the source block is adjusted accordingly. Specifically, after the valid data is transferred, the number of valid data in the source block is reduced by one.

[0068] See also Figures 1 to 6As shown, in one embodiment of the present invention, in step S40, the method of starting the error reporting includes that the number of valid data is not cleared after the garbage collection process ends. If the number of valid data is updated once each time the stored data is edited, the reliability of the number of valid data is high. Therefore, in the embodiment, before the control method starts, the reliability of the number of valid data records is usually evaluated. In the case where the reliability of the number of valid data is high, the number of valid data can be used as a reference to evaluate whether the garbage collection process is finished, whether there is an error, etc. In other embodiments of the present invention, the update frequency of the number of valid data may not be set according to the number of edits, and is not limited to being set to a fixed period update or updating the number of valid data after several data edits. Therefore, the number of valid data can be used as a first reference. When transferring valid data, when the amount of valid data is known, the amount of valid data can be used as a second reference to start the system error reporting in an abnormal state. It should be noted that while the present invention uses the number of valid data as the first reference, it does not exclude other means that can trigger the system error reporting. Any signal that causes the garbage collection process to report an error can trigger the system error reporting, and then trigger the control method of the storage device 10 provided by the present application. For example, after an abnormal power failure occurs, the garbage collection process is forced to be interrupted. After re-entering the garbage collection process, it is found that part of the address mapping table 310 or the address de-mapping table 320 is lost.

[0069] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S40, when the system reports an error, the recovery error correction process is started. In this embodiment, when the recovery error correction process is started, the error correction flag is set. The error correction flag can be a global variable, and the present invention is not limited to this. The error correction flag does not disappear with the abnormal power failure, so after powering on again, first check whether the error correction flag is set. If the error correction flag is set, the recovery error correction process continues. If the error correction flag is not set, the task is executed according to the instruction of the main controller 20 or the host 60. It should be noted that in an abnormal state, the recovery error correction process is started. At this time, the read and write commands are stopped, and the recovery error correction is the first priority task. Because the abnormal state is not frequent, the impact on the storage task is small.

[0070] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S50, in the recovery error correction process, the second type of user data 702 in the source block is read in sequence. It should be noted that the recovery error correction process is performed after the garbage collection process. After the garbage collection process, the stored data in the source block is determined to be invalid data. In this embodiment, in step S50, in the recovery error correction process, the second type of user data 702 is read, and the second type of user data 702 is decoded to obtain the first type of user data 701 and the address inverse mapping table 320 corresponding to the first type of user data 701.

[0071] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S60, the physical address in the decoded address demapping table 320 is used as the third physical address. The third physical address is compared with the first physical address. If the third physical address is consistent with the first physical address, the first type of user data 701 is valid data. The valid data is transferred to the target block. A new physical address is assigned to the first type of user data 701, and a new address demapping table 320 is formed. Then, the first type of user data 701 and the address demapping table 320 are integrated to form a new second type of user data 702, and the second type of user data 702 is stored at a predetermined physical address. If the third physical address is inconsistent with the first physical address, the first type of user data 701 is invalid data. In step S60, no processing is performed on the invalid data, and the second type of user data 702 of the next storage page 302 is continued to be read until the second type of user data 702 in the source block is traversed. It should be noted that each time valid data is transferred, the number of valid data is reduced by one.

[0072] See also Figures 1 to 6 As shown, in one embodiment of the present invention, in step S70, after traversing the second type of user data 702 in the source block, if the number of valid data is cleared to zero, the recovery error correction process is terminated. In another embodiment of the present invention, before traversing the source block, the number of valid data has been cleared to zero, then the recovery error correction process can be directly terminated, or the source block can be continuously read until the storage data of the source block is traversed. In step S70, if the number of valid data is cleared to zero, the recovery error correction process is terminated.

[0073] The embodiments of the present invention disclosed above are only used to help illustrate the present invention. The embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.

Claims

1. A storage device, characterized in that: include: A plurality of flash memory particles, wherein the flash memory particles store an address mapping table and an address inverse mapping table, wherein the address mapping table stores a mapping relationship between a data logical address and a data physical address, and the address inverse mapping table stores a mapping relationship between a data physical address and a data logical address; as well as A main controller, electrically connected to the flash memory particles and the host, and when an error occurs in the garbage collection process of the flash memory particles, the main controller calls the control firmware and executes a recycling error correction process; The control firmware includes: an encoding unit, wherein an encoding object of the encoding unit is first-category user data and an address inverse mapping table of the first-category user data, and an output result of the encoding unit is second-category user data, wherein the storage data of the flash memory particles is the second-category user data, and the data read and written by the host is the first-category user data; A valid data counting unit, storing the number of valid data of each storage block in the flash memory particle; and a decoding unit, wherein a decoding object of the decoding unit is the second category of user data; The second type of user data has a first physical address, a second physical address and a third physical address, wherein the first physical address is the physical address where the second type of user data is stored, the second physical address is the physical address stored in the address mapping table, and the third physical address is the physical address stored in the address de-mapping table obtained after decoding the second type of user data. When the first physical address and the second physical address are consistent or the first physical address and the third physical address are consistent, the second type of user data is valid data.

2. A storage device according to claim 1, characterized in that: The number of valid data is the number of storage pages storing valid data in the storage block.

3. A storage device according to claim 1, characterized in that: The control firmware includes an address allocation unit, in which remaining storage capacities of a plurality of the storage blocks are stored.

4. A storage device according to claim 3, characterized in that: The control firmware includes a garbage collection unit. When the remaining storage capacity of the flash memory particle is less than a preset threshold, the garbage collection unit starts a garbage collection process and uses the storage block with the least number of valid data as a recycled block.

5. A storage device according to claim 4, characterized in that: The sign that the garbage collection process is wrong is that the number of valid data in the storage block is greater than zero when the garbage collection process ends.

6. A storage device according to claim 1, characterized in that: In the garbage collection transfer process, the data transferred to the new storage block is the new second-category user data, in which the first-category user data remains unchanged, and the address inverse mapping table is the new address inverse mapping table.

7. A method for controlling a storage device, based on the storage device according to claim 1, characterized in that: The following steps are involved: When executing a write command from the host, an address mapping table and an address reverse mapping table are formed according to the logical address and the physical address of the first type of user data, and the address mapping table and the address reverse mapping table are stored in the flash memory particles, wherein the address mapping table stores a mapping relationship between the data logical address and the data physical address, and the address reverse mapping table stores a mapping relationship between the data physical address and the data logical address; Encoding the first category of user data and the address inverse mapping table of the first category of user data, synthesizing the second category of user data, and storing the second category of user data in the flash memory particles; In the reading and writing process of the second type of user data, the number of valid data in each storage block in the flash memory particle is recorded; When the remaining storage capacity of the flash memory particles is insufficient, the main controller enables a garbage collection process; and When the garbage collection process of the flash memory particles fails, the main controller calls the control firmware and executes the recycling error correction process.

8. The method for controlling a storage device according to claim 7, characterized in that: The steps of executing the recovery error correction process include: sequentially reading the second type of user data of the recycled blocks, and decoding the second type of user data to obtain a third physical address of the second type of user data; comparing the third physical address with the first physical address of the second type of user data, and if the third physical address is consistent with the first physical address, transferring the second type of user data to a new storage block; and The recycled block is traversed until the number of valid data in the recycled block is reset to zero.

9. The method for controlling a storage device according to claim 7, characterized in that: The priority of the recovery error correction process is higher than the garbage collection process and the read and write instructions of the host.

Citation Information

Patent Citations

  • Abnormity processing method and device for garbage collection, computer equipment and storage medium

    CN114327277A

  • Garbage collection system and method applied to flash memory storage controller

    CN115391237A

  • Memory system and operating method thereof

    US20180059937A1

  • Host-resident translation layer validity check techniques

    US20200201784A1

  • Method and system of resource-saving metadata update and verification in garbage collection

    US20220156183A1