Data management method and storage device

By coordinating the host system and the storage device to execute the data integration program in the non-volatile memory module, the problem of not considering the efficiency and performance of the host system in the existing technology is solved, the write amplification coefficient and the load of the storage device are reduced, and the overall efficiency is improved. and efficiency and storage device performance.

CN118331510BActive Publication Date: 2024-08-27HEFEI KAIMENG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410764362.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-08-27
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

The existing garbage collection method of non-volatile memory modules does not consider the efficiency and performance of the host system, and the write amplification factor is too large, resulting in an overload of the storage device.

Method used

The storage device and the host system work together to query and update the mapping table by sending preparatory host data merging instructions. The host system executes the data merging program to reduce valid data and reduce the write amplification factor, and is executed by the memory controller according to the mapping table. Install data consolidation program.

Benefits of technology

It effectively reduces the load and write amplification coefficient of the storage device, improves the response speed and service life of the storage device, avoids invalid data movement, and improves the efficiency of the consolidation program.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118331510B
    Figure CN118331510B
Patent Text Reader

Abstract

The present invention provides a data management method and a storage device, which is used in a host system and includes: when the number of free physical units of the storage device is less than a predetermined threshold, sending a preparatory host data consolidation instruction to the storage device; receiving a mapping table sent by the storage device, the mapping table indicating the source physical units used for the host data consolidation program; issuing corresponding programmed instructions to the storage device according to the attributes of the valid data in the source physical unit to reduce the valid data in the source physical unit, and thereby updating the mapping table; and transmitting the updated mapping table to the storage device for executing the device data consolidation program. In this way, the efficiency of the data consolidation program can be improved and inefficient data movement can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a memory management technology, and in particular to a data management method and a storage device. Background Art

[0002] Non-volatile memory modules (such as flash memory modules) have the advantages of non-volatile data storage, low power consumption and fast data access. Generally speaking, some idle physical units are configured by default in the non-volatile memory module to receive and store data from the host system. However, in the process of writing data to the non-volatile memory module, the number of idle physical units will gradually decrease. In order to prevent the number of idle physical units from returning to zero, garbage collection is generally performed in the background during the storage of data from the host system to release new idle physical units for subsequent use. Existing garbage collection is performed on the device side. This method does not take into account the efficiency and performance of the host system, nor does it take into account the load on the device side and the problem of excessive write amplification. Summary of the invention

[0003] The present invention provides a data management method and a storage device, which can cooperate with a host system to execute a data consolidation program, reduce the load of the device and reduce the write amplification factor. An embodiment of the present invention proposes a data management method for a host system. The host system is electrically connected to the storage device, and the storage device includes a memory module, and the memory module includes a plurality of physical units. This data management method includes: when the number of idle physical units of the storage device is less than a predetermined threshold, sending a preliminary host data consolidation instruction to the storage device; receiving a mapping table sent by the storage device, the mapping table indicating the source physical unit for the host data consolidation program; issuing corresponding programmed instructions to the storage device according to the attributes of the valid data in the source physical unit to reduce the valid data in the source physical unit, and thereby updating the mapping table to obtain a second mapping table; and transmitting the second mapping table to the storage device for executing the device data consolidation program.

[0004] From another perspective, an embodiment of the present invention proposes a data management method for a storage device, wherein the storage device includes a memory module, and the memory module includes a plurality of physical units. The data management method includes: selecting a source physical unit from a plurality of physical units in response to a prepared host data consolidation instruction of a host system; querying a mapping table according to a physical address of the source physical unit, and transmitting the mapping table corresponding to the source physical unit to the host system to execute a host data consolidation program; receiving a response to a programmed instruction from the host system, performing a corresponding programmed operation on the data corresponding to the programmed instruction; and after receiving an updated mapping table sent by the host system, executing a device data consolidation program according to the updated mapping table.

[0005] From another perspective, an embodiment of the present invention proposes a storage device, including a connection interface unit, a memory module and a memory controller. The connection interface unit is used to connect to a host system. The memory module includes a plurality of physical units. The memory controller is connected to the connection interface unit and the memory module to perform a plurality of steps: in response to a host data consolidation instruction of the host system, a source physical unit from a plurality of physical units is selected; a mapping table is queried according to a physical address of the source physical unit, and a mapping table corresponding to the source physical unit is transmitted to the host system to execute a host data consolidation program; a programmed instruction is received in response to the programmed instruction from the host system, and a corresponding programmed operation is executed corresponding to the programmed instruction; and after receiving an updated mapping table sent by the host system, a device data consolidation program is executed according to the updated mapping table. BRIEF DESCRIPTION OF THE DRAWINGS

[0006] Figure 1 is a schematic diagram of a storage device according to an embodiment of the present invention;

[0007] Figure 2 is a schematic diagram of a management memory module according to an embodiment of the present invention;

[0008] Figure 3 is a schematic diagram showing communication between a host system and a storage device according to an embodiment;

[0009] Figure 4 is a schematic diagram showing a mapping table according to an embodiment;

[0010] Figure 5 is a schematic diagram showing a host system issuing an update instruction according to an embodiment;

[0011] Figure 6 is a schematic diagram showing a host system issuing a delete command according to an embodiment;

[0012] Figure 7 is a schematic diagram showing an instruction queue according to an embodiment;

[0013] Figure 8 is a schematic diagram showing an updated mapping table according to an embodiment;

[0014] Fig. 9 is a flow chart showing a data management method for a host system according to an embodiment;

[0015] Fig.10 is a flow chart showing a data management method for a storage device according to an embodiment. DETAILED DESCRIPTION

[0016] Reference will now be made in detail to exemplary embodiments of the present invention, examples of which are illustrated in the accompanying drawings. Whenever possible, the same reference numerals are used in the drawings and the description to refer to the same or like parts.

[0017] Figure 1 is a schematic diagram of a storage device according to an embodiment of the present invention. Figure 1 The data storage system includes a storage device 10 and a host system 11. The host system 11 can be any type of computer system, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, an industrial computer, a game console, a server or a vehicle-mounted computer, etc., and the type of the host system 11 is not limited thereto.

[0018] The storage device 10 is connected to the host system 11 and is used to store data from the host system 11. For example, the storage device 10 may include a solid state drive, a USB flash drive, a memory card, or other types of non-volatile storage devices. The host system 11 may communicate with the storage device 10 through an embedded Multi-Media Card (embedded Multi-Media Card, eMMC), a universal flash memory (Universal FlashStorage, UFS), a fast peripheral component interconnect (Peripheral Component Interconnect Express, PCIExpress), a fast non-volatile memory (Non-Volatile Memory Express, NVM express), a serial advanced technology attachment (Serial Advanced Technology Attachment, SATA), a universal serial bus (Universal Serial Bus, USB) or other types of connection interface standards. Therefore, the host system 11 can store data to the storage device 10 and / or read data from the storage device 10.

[0019] The storage device 10 includes a connection interface unit 101, a memory module 102, and a memory controller 103. The connection interface unit 101 is used to connect the storage device 10 to the host system 11. For example, the connection interface unit 101 can support connection interface standards such as eMMC, UFS, PCI Express, NVM express, SATA, PCI Express, or USB. The storage device 10 can communicate with the host system 11 (e.g., exchange signals and / or data) via the connection interface unit 101.

[0020] The memory module 102 is used to store data. The memory module 102 may include one or more rewritable non-volatile memory modules. Each rewritable non-volatile memory module may include one or more memory cell arrays. The memory cells in the memory cell array store data in the form of voltage. For example, the memory module 102 may include a single level cell (SLC) NAND flash memory module, a multi level cell (MLC) NAND flash memory module, a triple level cell (TLC) NAND flash memory module, a quad level cell (QLC) NAND flash memory module and / or other memory modules having the same or similar characteristics.

[0021] The memory controller 103 is connected to the connection interface unit 101 and the memory module 102. The memory controller 103 can be regarded as the control core of the memory device 10 and is used to control the memory device 10. For example, the memory controller 103 can be responsible for controlling and / or managing the entire or partial operation of the memory device 10. For example, the memory controller 103 may include a central processing unit (CPU), or other programmable general-purpose or special-purpose microprocessors, digital signal processors (DSP), programmable controllers, application specific integrated circuits (ASIC), programmable logic devices (PLD) or other similar devices or combinations of these devices. In one embodiment, the memory controller 103 includes a flash memory controller.

[0022] In one embodiment, the memory controller 103 may further include a buffer memory, a power management circuit, an encoding circuit, a decoding circuit and / or various other types of circuit modules, which are not limited by the present invention. The buffer memory is used to cache data. The power management circuit is used to manage the power of the storage device 10. The encoding circuit is used to encode the data to be stored in the memory module 102 to generate an error correction code (and / or an error checking code). The decoding circuit is used to decode the data read from the memory module 102 to correct possible errors in the read data. For example, the encoding circuit and / or the decoding circuit may use various encoding / decoding algorithms such as Low Density Parity Check Code (LDPC code), BCH code, Reed-Solomon code (RS code), Exclusive OR (XOR) code, etc. to encode and decode data.

[0023] The memory module 102 may receive a command sequence from the memory controller 103 and access the storage unit according to the command sequence. For example, when data is to be stored, the memory controller 103 may send a write command sequence to the memory module 102 to instruct the memory module 102 to store the data in a specific storage unit. When data is to be read, the memory controller 103 may send a read command sequence to the memory module 102 to instruct the memory module 102 to read data from a specific storage unit. When data is to be deleted, the memory controller 103 may send an erase command sequence to the memory module 102 to instruct the memory module 102 to erase the data stored in the specific storage unit. In addition, the memory controller 103 may also send other types of command sequences to the memory module 102 to instruct the memory module 102 to perform corresponding operations, which is not limited by the present invention.

[0024] Figure 2 FIG. 1 is a schematic diagram of a management memory module according to an embodiment of the present invention. Figure 1 and Figure 2 The memory module 102 includes a plurality of physical units 201 ( 1 ) to 201 (B). Each physical unit includes a plurality of storage cells and is used for non-volatile storage of data.

[0025] In one embodiment, a physical unit may include multiple physical sectors. For example, the data capacity of a physical sector may be 512 bytes (Bytes, B), and a physical unit may include 8 physical sectors. However, the data capacity of a physical sector and / or the total number of physical sectors included in a physical unit may be adjusted according to practical needs, and the present invention is not limited thereto. In one embodiment, a physical unit may be regarded as a physical page. For example, the data capacity of a physical page may be 4 kilobytes (4KB), and the present invention is not limited thereto.

[0026] In one embodiment, a physical page is the minimum unit for synchronously writing data in the memory module 102. For example, when a programming operation is performed on a physical page to write data to the physical page, multiple memory cells in the physical page can be synchronously programmed to store corresponding data. For example, when programming a physical page, a write voltage can be applied to the physical page to change the threshold voltage of at least some of the memory cells in the physical page. The threshold voltage of each memory cell can reflect the bit data stored in the memory cell.

[0027] In one embodiment, the memory module 102 may include a plurality of physical blocks. Each physical block may include a plurality of physical cells. In particular, a plurality of physical cells (e.g., physical pages) in the same physical block may be erased synchronously. For example, when erasing a physical block, an erase voltage may be applied to a plurality of physical pages in the physical block to change the threshold voltage of at least a portion of the memory cells in these physical pages and clear the bit data stored in each memory cell in these physical pages. In one embodiment, a physical cell may be regarded as a physical block.

[0028] In one embodiment, the memory controller 103 may logically associate the physical units 201(1)-201(A) with the data area 21 and associate the physical units 201(A+1)-201(B) with the spare area 22. The physical units 201(1)-201(A) in the data area 21 are used to store data (also referred to as user data) from the host system 11. For example, each physical unit in the data area 21 may store valid data and / or invalid data. In addition, the physical units 201(A+1)-201(B) in the spare area 22 do not store data, and these physical units are also referred to as spare physical units.

[0029] In one embodiment, if a physical unit does not store valid data, the physical unit can be associated with the idle area 22. In one embodiment, the idle area 22 is also called a free pool. In addition, the physical unit associated with the idle area 22 can be erased to clear the data in the physical unit.

[0030] In one embodiment, when data (i.e., user data) from the host system 11 needs to be stored, the memory controller 103 may select one or more physical units from the idle area 22 and instruct the memory module 102 to store the data from the host system 11 into the selected physical units. At the same time, the selected physical units may be associated with the data area 21.

[0031] In one embodiment, the memory controller 103 may configure a plurality of logical units 230(1)-230(C) to map the physical units 201(1)-201(A) in the data area 21. For example, a logical unit may correspond to a logical block address (LBA) or other logical management unit (e.g., a logical page). A logical unit may be mapped to one or more physical units in the data area 21.

[0032] In one embodiment, if a physical unit is currently mapped by any logical unit, the memory controller 103 may determine that the data currently stored in the physical unit includes valid data. Conversely, if a physical unit is not currently mapped by any logical unit, the memory controller 103 may determine that the physical unit does not currently store any valid data (and / or the data in the physical unit are all invalid data).

[0033] In one embodiment, the memory controller 103 may record the mapping relationship between the logical unit and the physical unit in a logical-to-physical mapping table. When receiving an access instruction (such as a read instruction, a write instruction, a delete instruction, or other types of instructions) from the host system 11, the memory controller 103 may instruct the memory module 102 to perform a corresponding operation behavior according to the information in the logical-to-physical mapping table.

[0034] The memory controller 103 may perform a data consolidation procedure as required, which is also called a garbage collection procedure. When performing the data consolidation procedure, the memory controller 103 may select at least one physical unit from the data area 21 as a source physical unit and select at least one physical unit from the idle area 22 as a target physical unit. The memory controller 103 may copy the valid data stored in the source physical unit to the target physical unit. After the valid data stored in the source physical unit is copied to the target physical unit, all the data in the source physical unit will be marked as invalid and the source physical unit may be divided into the idle area 22. In addition, the physical unit divided into the idle area 22 may be erased to clear the data stored in the physical unit. In one embodiment, the operation of re-dividing a physical unit from the data area 21 to the idle area 22 is also called releasing a physical unit. That is, during the start of the data consolidation procedure, one or more physical units may be gradually released and the total number of physical units belonging to the idle area 22 may be gradually increased. Particularly, in this embodiment, the memory controller 103 cooperates with the host system 11 to execute a data consolidation program. The program executed by the memory controller 103 is called a device data consolidation program, and the program executed by the host system 11 is called a host data consolidation program.

[0035] Figure 3 1 is a schematic diagram showing the communication between the host system and the storage device according to an embodiment. In the following disclosure, when describing the communication between the host system 11 and the memory controller 103 (e.g., transmitting a data), it is also equivalent to describing the communication between the host system 11 and the storage device 10. In addition, when describing the host system 11 transmitting data to the memory controller 103, it is also equivalent to the memory controller 103 receiving data from the host system 11.

[0036] First, in operation 301, the host system 11 sends a query instruction to the memory controller 103 at a default frequency to query the device status. In operation 302, in response to the query instruction, the memory controller 103 replies the device status to the host system 11. This device status includes, for example, the number of free physical units in the idle area 22, the number of valid data in the physical units in the data area 21, and other information. The host system 11 can determine whether to initiate a host data consolidation program based on the device status. For example, when the number of free physical units in the idle area 22 is less than a predetermined threshold, it is determined that the host data consolidation program can be executed. The host data consolidation program is to pre-organize the valid data to improve the efficiency of garbage collection on the device side. If the host data consolidation program and the device data consolidation program are performed simultaneously, the same data will be repeatedly moved, or deleted immediately after being moved, resulting in a higher write amplification factor (WAF). Therefore, when the host system 11 determines that the host data consolidation program can be executed, the host system 11 issues a preparatory host data consolidation instruction to the memory controller 103 in operation 303. The preparatory host data consolidation instruction is to restrict the memory controller 103 from starting the device data consolidation program. After receiving the preparatory host data consolidation instruction, the memory controller 103 will not start the device data consolidation program.

[0037] In addition, after receiving the preparation host data consolidation instruction, the memory controller 103 selects multiple source physical units from the data area 21, for example, the physical unit with less valid data can be preferentially selected as the source physical unit. The memory controller 103 can determine the physical address of the physical unit according to the physical unit, query the logical address in the logical physical mapping table according to the physical address, and obtain the mapping table corresponding to the source physical unit. Figure 4 is a schematic diagram showing a mapping table according to an embodiment, please refer to Figure 3 and Figure 4 The mapping table 400 records the logical address of the logical unit and the physical address of the corresponding physical unit. Figure 4 In the example, "L50", "L51" and the like are used to represent logical addresses, which are, for example, logical block addresses. Figure 4 In the example, "P0", "P1" and the like are used to represent physical addresses, such as physical block addresses (PBA). In this example, the logical unit with address L50 is mapped to the physical unit with address P0, and so on.

[0038] In operation 304, the host system 11 issues a mapping table request to the memory controller 103. In response to this request, in operation 305, the memory controller 103 transmits a mapping table 400 to the host system 11. This mapping table 400 indicates the source physical unit used for the host data consolidation program, including the mapping relationship between the physical address and the logical address of the source physical unit. Next, the host system 11 executes the host data consolidation program 306, in which the host system issues a programmed instruction to the memory controller 103 according to the attributes of the valid data in the source physical unit to reduce the amount of valid data in the source physical unit, and thereby updates the mapping table 400. The attributes of the valid data may include information such as the content of the valid data, whether it is periodically updated, whether it is about to be deleted, and whether it is about to be updated. The host system 11 can perform flexible data management based on the attributes of valid data. For example, when a piece of data is about to be updated, there is no need to execute the device data consolidation program, which can avoid duplicate data movement. Or when a piece of data is about to be deleted, there is no need to execute the device data consolidation program. Since this information can only be obtained on the host system 11 side, after adding the collaborative operation of the host system 11, the inefficient data movement can be reduced and the efficiency of the data consolidation program can be improved.

[0039] For example, Figure 5 FIG. 1 is a schematic diagram showing a host system issuing an update instruction according to an embodiment. Figure 5 , assuming that the physical unit 201(1) is the selected source physical unit, in which the valid data 501 is stored, the host system 11 can know the logical unit mapped by the physical unit 201(1) from the above mapping table, and further can know the content of the valid data 501, whether it is periodic update data and other properties. For example, the valid data 501 stores data obtained by a sensor. This sensor will re-obtain data at a certain period of time, so the host system 11 will update this data at a certain period of time. Such data is called periodic update data. Whenever the sensor obtains new data, the host system 11 will add the corresponding update instruction to a schedule and issue an update instruction to the memory controller 103 according to the schedule. When the valid data 501 is periodic update data, the host system 11 will issue an update instruction in advance to update the valid data 501 (advance the original schedule), and the new data will be stored in another physical unit. The space originally storing the valid data 501 will store invalid data, that is, the amount of valid data in the physical unit 201(1) is reduced. After the update instruction is executed, there is no valid data in the physical unit 201 ( 1 ), so the physical unit 201 ( 1 ) can be released.

[0040] Figure 6 FIG. 1 is a schematic diagram showing a host system issuing a delete command according to an embodiment. Figure 6 , assuming that the physical unit 201 (2) is the selected source physical unit, which stores the valid data 601, the host system 11 can know the logical unit mapped by the physical unit 201 (2) from the mapping table, and then can know the content of the valid data 601, whether it is deletable data and other properties. For example, the valid data 601 is some temporary data about the system, but due to timeliness, the valid data 601 is no longer needed, that is, the valid data 601 is deletable data. When the valid data 601 is deletable data, the host system 11 will issue a deletion command to delete the valid data 601. After executing the deletion command, the physical unit 201 (2) no longer stores valid data and can be released. Through such a deletion command, it is equivalent to the host system 11 executing the host data consolidation program according to the properties of the valid data 601. The advantage of the host system 11 issuing the deletion command is to prevent the valid data 601 from being moved to other physical units due to the device data consolidation program before being deleted.

[0041] Figure 7 FIG. 1 is a schematic diagram showing an instruction queue according to an embodiment. Figure 7 The host system 11 is provided with an instruction queue 710, which includes a plurality of instructions 711-714 waiting to be executed. Figure 7 The instructions on the right side will be executed first. That is, instruction 714 will be executed first, followed by instructions 713, 712, and 711. Figure 7 The numbers in each instruction 711 to 714 refer to the corresponding logical addresses. For example, instruction 714 is a read instruction, which is used to read the logical unit with the logical address "L23"; instruction 713 is a read instruction, which is used to read the logical unit with the logical address "L41"; instruction 712 is a change instruction, which is used to change the logical unit with the logical address "L50"; instruction 714 is a change instruction, which is used to change the logical unit with the logical address "L23". The change instruction includes an update instruction or a delete instruction, which is used to update or delete the data stored in the corresponding logical unit.

[0042] Please refer to Figure 4 and Figure 7For the logical unit (also called the first logical unit) recorded in the mapping table 400, the host system 11 will determine whether the command queue 710 contains a change command for the first logical unit. If so, the change command can be executed in advance. Since the corresponding valid data will be updated or deleted, there is a chance to release another physical unit. However, if there is a read command to be executed before the change command, the change command cannot be executed in advance, which will affect the result of the read command. For example, the logical address "L50" also corresponds to the change command 712 in the mapping table 400, and the logical address "L23" is in the mapping table 400 and corresponds to the change command 711. If the command queue 710 has a change command corresponding to the first logical unit, it is then determined whether there is a read command in the command queue 710 that is also ordered before the change command and corresponds to the first logical unit. For example, the read command 714 and the change command 711 both correspond to the logical unit with the logical address "L23", and the read command 714 is ordered before the change command 711. On the other hand, there is no read command corresponding to the same logical unit before the change command 712. If there is no read instruction in the instruction queue 710 that corresponds to the same logical unit before the change instruction, the order position of the instruction in the instruction queue 710 can be changed in advance; if the instruction queue 710 contains a read instruction that corresponds to the same logical unit before the change instruction, the order position of the instruction in the instruction queue 710 will not be changed in advance. For example, the order position of instruction 712 in the instruction queue 710 can be changed in advance, but the order position of instruction 711 in the instruction queue 710 will not be changed in advance. After the order position is changed, an instruction queue 720 will be formed, in which the order position of the change instruction 712 is advanced. Early execution of the change instruction 712 will not affect other read instructions, and there is a chance to release a physical unit.

[0043] After the host system 11 completes the host data consolidation procedure, the mapping table 400 is updated accordingly. For example, Figure 8 is a schematic diagram showing an updated mapping table according to an embodiment. Figure 8In this example, some of the physical units will not store valid data due to the execution of the above-mentioned delete command or update command, so these physical units do not need to perform the subsequent device data consolidation procedure. For example, the mapping table 400 is divided into segments 801~803, wherein the physical units in segment 801 do not store valid data due to the execution of the update command, and the physical units in segment 802 do not store valid data due to the delete command. The host system 11 deletes the physical units (and corresponding logical units) in segments 801 and 802 and leaves segment 803, thereby updating the mapping table 400. Finally, the host system 11 returns the updated mapping table 400 to the memory controller 103, that is, only transmits segment 803 to the memory controller 103.

[0044] In one embodiment, the mapping relationship between the logical unit and the physical unit is included in the update instruction or delete instruction issued by the host system 11. Therefore, after receiving such an update instruction or delete instruction, the memory controller 103 can directly execute the corresponding operation without querying the logic-to-physical mapping table.

[0045] In one embodiment, in the remaining fragment 803 of the mapping table 400, the sorting position of the logical units (physical units) represents the order in which they are executed by the device data consolidation program. The host system 11 can adjust the sorting position of the logical units (physical units) in the mapping table 400 according to the information it has. For example, the host system 11 can obtain the update frequency of the valid data in the source physical unit in the fragment 803. For example, some data is updated once a minute, and some data is updated once an hour. The host system 11 can know the update frequency of these valid data based on the information in the application program or operating system it runs. Next, the host system 11 can adjust the sorting position of the source physical unit in the mapping table 400 according to the update frequency. For example, the logical unit (physical unit) with a lower update frequency will be set in a higher priority sorting position, and the logical unit (physical unit) with a higher update frequency will be set in a lagging sorting position.

[0046] In one embodiment, the host system 11 may also be configured to execute the device data consolidation procedure only when the update frequency is less than or equal to a threshold. In other words, if the update frequency of valid data of a source physical unit in the segment 803 is greater than the threshold, the host system 11 will remove the source physical unit and the corresponding logical unit from the mapping table 400.

[0047] Please refer to Figure 3After the host system 11 executes the system data consolidation program 306 and transmits the updated mapping table to the memory controller 103, in operation 307, the host system 11 issues an end host data consolidation instruction to the memory controller 103. The end host data consolidation instruction is used to instruct the memory controller 103 to stop transmitting the mapping table to the host system 11 and resume the device data consolidation program. After receiving the end host data consolidation instruction, the memory controller 103 will stop transmitting the mapping table to the host system 11 and resume the device data consolidation program. It is worth noting that if the host data consolidation instruction is not received, the memory controller 103 will continue to select source physical units, generate a mapping table, and then transmit the mapping table to the host system, that is, the operations 304, 305 and the host data consolidation program 306 included in the program 310 will be repeated.

[0048] After the device data consolidation procedure is restored, the memory controller 103 will execute the device data consolidation procedure according to the updated mapping table 400, that is, select the source physical unit with a higher ranking from the updated mapping table, and move the valid data therein to the target physical unit, thereby releasing the source physical unit. In the above embodiment, the host system 11 has set the logical unit (physical unit) with a lower update frequency in a higher priority ranking position in the mapping table. Therefore, after the memory controller 103 receives the updated mapping table 400, it will preferentially execute the device data consolidation procedure for the source physical unit with a lower update frequency, so as to avoid the data consolidation procedure being executed after a piece of data is frequently updated, which will cause inefficient data movement.

[0049] In the above embodiment, the data consolidation procedure is initiated by the host system 11, but in other embodiments, the data consolidation procedure may also be initiated by the memory controller 103. For example, the memory controller 103 may determine the number of physical units in the idle area 22, and if the number is too small, such as less than a threshold, an instruction may be sent to the host system 11 to request the host system 11 to execute the host data consolidation procedure.

[0050] Fig. 9 is a flow chart showing a data management method for a host system according to an embodiment. Fig. 9, steps 901 to 904 are executed by the host system 11. In step 901, when the number of free physical units of the storage device is less than a predetermined threshold, a preparatory host data consolidation instruction is sent to the storage device. In step 902, a mapping table sent by the storage device is received, and the mapping table indicates the source physical units used for the host data consolidation program. In step 903, a corresponding programmed instruction is issued to the storage device according to the attributes of the valid data in the source physical unit to reduce the valid data in the source physical unit, and thereby the mapping table is updated to obtain a second mapping table. In step 904, the obtained second mapping table is transmitted to the storage device for executing the device data consolidation program. Fig. 9 Each step has been described in detail above and will not be repeated here. Fig. 9 Each step can be implemented as a circuit or a code, and the present invention is not limited thereto. Fig. 9 Each step of can be performed independently or in combination with the above embodiment. Fig. 9 Other steps may be added between, before or after the steps in the process.

[0051] Fig.10 is a flow chart showing a data management method for a storage device according to an embodiment. Fig.10 , steps 1001~1007 are executed by the memory controller 103. In step 1001, a query instruction is received from the host system. In step 1002, in response to the query instruction, the device status corresponding to the storage device is replied to the host system. In step 1003, a preliminary host data consolidation instruction is received from the host system. In step 1004, a source entity unit from a plurality of entity units is selected. In step 1005, a mapping table is queried according to the physical address of the source entity unit, and the mapping table corresponding to the source entity unit is transmitted to the host system. In step 1006, in response to the programmed instruction from the host system, a corresponding programmed operation is performed on the data corresponding to the programmed instruction. In step 1007, the updated mapping table is accepted from the host system, thereby executing the device data consolidation program. Fig.10 Each step has been described in detail above and will not be repeated here. Fig.10 Each step can be implemented as a circuit or a code, and the present invention is not limited thereto. Fig.10 Each step of can be performed independently or in combination with the above embodiment. Fig.10 Other steps may be added between, before or after the steps in the process.

[0052] The data management method and storage device proposed above are to execute the data consolidation program together with the host system. The host system can flexibly execute the update instruction or the delete instruction according to the attributes of the valid data, or adjust the order of data consolidation according to the update frequency. In this way, inefficient data movement can be avoided and the write amplification factor can be reduced. In addition, these practices also hand over some decisions to the host system, which can reduce the load of the storage device. For these reasons, the response speed, performance and service life of the storage device can be improved, and the resources of the memory module can be used more efficiently.

[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data management method, characterized in that: Used in a host system, the host system is electrically connected to a storage device, the storage device includes a memory module, the memory module includes a plurality of physical units, and the data management method includes: When the number of free physical units of the storage device is less than a predetermined threshold, sending a preparatory host data consolidation instruction to the storage device; receiving a mapping table sent by the storage device, the mapping table indicating a source physical unit for a host data consolidation procedure; According to the attributes of the valid data in the source physical unit, a corresponding programming instruction is issued to the storage device to reduce the valid data in the source physical unit, wherein When the valid data is periodically updated data, an update instruction is issued in advance to the storage device to update the valid data. When the valid data is deletable data, issuing a deletion instruction to the storage device to delete the valid data; and thereby updating the mapping table to obtain a second mapping table; and The second mapping table is transmitted to the storage device for executing a device data consolidation procedure.

2. The data management method according to claim 1, characterized in that: Also includes: Before sending the preliminary host data consolidation instruction, sending a query instruction to the storage device at a preset frequency to obtain the device status of the storage device; as well as A device status is received from the storage device, wherein the device status includes the number of free physical units of the storage device.

3. The data management method according to claim 2, characterized in that: Also includes: After transmitting the second mapping table to the storage device, the host system issues an end host data consolidation instruction to the storage device, wherein the end host data consolidation instruction is used to instruct the storage device to stop transmitting the mapping table to the host system and resume the device data consolidation procedure.

4. The data management method according to claim 1, characterized in that: The step of the host system issuing the instruction to the storage device according to the attribute of the valid data in the source entity unit comprises: For the first logical unit recorded in the mapping table, determining whether the command queue of the host system includes a change command corresponding to the first logical unit, wherein the change command includes an update command or a delete command; If the instruction queue includes the change instruction corresponding to the first logical unit, determining whether there is a read instruction corresponding to the first logical unit in the instruction queue that is ordered before the change instruction; and If there is no read instruction corresponding to the first logic unit sorted before the change instruction in the instruction queue, the sorting position of the change instruction in the instruction queue is advanced.

5. The data management method according to claim 1, characterized in that: Also includes: Obtaining the update frequency of the valid data in the source entity unit; as well as The sorting position of the source physical unit in the mapping table is adjusted according to the update frequency, wherein the sorting position of the source physical unit with a smaller update frequency is given priority.

6. The data management method according to claim 5, characterized in that: Also includes: If the update frequency of the valid data of a first source physical unit among the source physical units is greater than a threshold, the first source physical unit and the corresponding logic unit are removed from the mapping table.

7. A data management method, characterized in that: Used in a storage device, the storage device is electrically connected to a host system, the storage device includes a memory module, the memory module includes a plurality of physical units, and the data management method includes: In response to a preliminary host data consolidation instruction of the host system, selecting a source physical unit from the plurality of physical units; Searching a mapping table according to the physical address of the source physical unit, and transmitting the mapping table corresponding to the source physical unit to the host system to execute a host data consolidation program; In response to a programmed instruction from the host system, a corresponding programmed operation is performed on the data corresponding to the programmed instruction; wherein In response to the programmed instruction being an update instruction, performing an update operation on the data corresponding to the update instruction, In response to the programmed instruction being a delete instruction, performing a delete operation on the data corresponding to the delete instruction; and After receiving the updated mapping table sent by the host system, a device data consolidation procedure is executed according to the updated mapping table.

8. The data management method according to claim 7, characterized in that: Also includes: Receiving a query instruction from the host system; In response to the query instruction, the current device status is sent to the host system, wherein the device status includes the current number of idle physical units.

9. The data management method according to claim 7, characterized in that: Also includes: After receiving the standby host data consolidation instruction, the device data consolidation program is not started.

10. The data management method according to claim 8, characterized in that: Also includes: receiving an end host data consolidation instruction from the host system; In response to the end host data consolidation instruction, the transmission of the mapping table to the host system is stopped and the device data consolidation procedure is resumed.

11. The data management method according to claim 7, characterized in that: The step of accepting the updated mapping table from the host system and executing the device data consolidation procedure comprises: The device data consolidation procedure is executed according to the sorting positions of the source physical units in the mapping table, wherein the source physical units with a lower update frequency are preferentially executed with the device data consolidation procedure.

12. A storage device, characterized in that: include: A connection interface unit for connecting to a host system; A memory module, comprising a plurality of physical units; as well as A memory controller, connected to the connection interface unit and the memory module, is used to perform a plurality of steps: In response to a preliminary host data consolidation instruction of the host system, selecting a source physical unit from the plurality of physical units; Querying a mapping table according to the physical address of the source physical unit, and transmitting the mapping table corresponding to the source physical unit to the host system to execute a host data consolidation program; In response to a programmed instruction from the host system, performing a corresponding programmed operation on data corresponding to the programmed instruction; in In response to the programmed instruction being an update instruction, performing an update operation on the data corresponding to the update instruction, In response to the programmed instruction being a delete instruction, performing a delete operation on the data corresponding to the delete instruction; as well as After receiving the updated mapping table sent by the host system, a device data consolidation procedure is executed according to the updated mapping table.

13. The storage device according to claim 12, characterized in that: The multiple steps also include: Receiving a query instruction from the host system; In response to the query instruction, the current device status is sent to the host system, wherein the device status includes the current number of idle physical units.

14. The storage device according to claim 12, characterized in that: The multiple steps also include: After receiving the standby host data consolidation instruction, the device data consolidation procedure is not started.

15. The storage device according to claim 12, characterized in that: The multiple steps also include: receiving an end host data consolidation instruction from the host system; and After receiving the end host data consolidation instruction, the transmission of the mapping table to the host system is stopped and the device data consolidation procedure is resumed.

16. The storage device according to claim 12, characterized in that: The step of accepting the updated mapping table from the host system and executing the device data consolidation procedure comprises: The device data consolidation procedure is executed according to the sorting positions of the source physical units in the mapping table, wherein the source physical units with a lower update frequency are preferentially executed with the device data consolidation procedure.