Search

US-12625619-B2 - Memory management method, memory storage device and memory control circuit unit

US12625619B2US 12625619 B2US12625619 B2US 12625619B2US-12625619-B2

Abstract

A memory management method is provided for a rewritable non-volatile memory module. The method includes: initiating a data merging operation; selecting a source physical unit and a target physical unit from the rewritable non-volatile memory module to perform the data merging operation; determining whether to create a backup table corresponding to a logical-to-physical mapping table; if it is determined to create the backup table, copying first data located at a first physical address in the source physical unit to a second physical address in the target physical unit, and recording the second physical address in the backup table; and determining whether to update the second physical address to the logical-to-physical mapping table based on information in the backup table.

Inventors

  • Yen Chen Yeh

Assignees

  • PHISON ELECTRONICS CORP.

Dates

Publication Date
20260512
Application Date
20241023
Priority Date
20240909

Claims (20)

  1. 1 . A memory management method for a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module comprises a plurality of physical units, and the memory management method comprises: initiating a data merging operation; selecting a source physical unit and a target physical unit from the rewritable non-volatile memory module to perform the data merging operation; determining whether to create a backup table corresponding to a logical-to-physical mapping table, wherein the logical-to-physical mapping table comprises mapping relationships between a plurality of logical addresses and a plurality of physical addresses; if it is determined that the backup table is created, copying first data located at a first physical address in the source physical unit to a second physical address in the target physical unit, and recording the second physical address in the backup table; determining whether to update the second physical address to the logical-to-physical mapping table according to information in the backup table, wherein the logical-to-physical mapping table records a first logical address mapped to the first physical address; and if it is determined not to create the backup table, copying the first data located at the first physical address in the source physical unit to the second physical address in the target physical unit, and recording that the second physical address is mapped to the first logical address in a physical-to-logical mapping table, and after performing the data merging operation, updating the logical-to-physical mapping table according to the physical-to-logical mapping table such that the first logical address is mapped to the second physical address in the logical-to-physical mapping table.
  2. 2 . The memory management method according to claim 1 , wherein the backup table also records the first physical address and a first logical address mapped to the first physical address, and the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the information in the backup table comprises: after performing the data merging operation, obtaining a third physical address mapped by the first logical address from the logical-to-physical mapping table; and determining whether to update the second physical address to the logical-to-physical mapping table according to a comparison result between the first physical address and the third physical address.
  3. 3 . The memory management method according to claim 2 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address comprises: if the third physical address is located in the source physical unit and the third physical address is greater than the first physical address, not updating the second physical address to the logical-to-physical mapping table.
  4. 4 . The memory management method according to claim 3 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address further comprises: if the third physical address is located in the source physical unit and the third physical address is less than or equal to the first physical address, updating the second physical address to the logical-to-physical mapping table such that the first logical address is mapped to the second physical address.
  5. 5 . The memory management method according to claim 4 , further comprising: if the third physical address is not located in the source physical unit, not updating the second physical address to the logical-to-physical mapping table.
  6. 6 . The memory management method according to claim 1 , further comprising: writing second data from a host system to a first physical unit among the physical units, wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit is the same as the first physical unit, determining to create the backup table; otherwise, not creating the backup table.
  7. 7 . The memory management method according to claim 1 , wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit is an active physical unit or the source physical unit has not been closed, determining to create the backup table.
  8. 8 . The memory management method according to claim 1 , wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit has a corresponding physical-to-logical mapping table, determining not to create the backup table.
  9. 9 . A memory storage device, comprising: a connection interface unit configured to be coupled to a host system; a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module comprises a plurality of physical units; and a memory control circuit unit coupled to the connection interface unit and the rewritable non-volatile memory module, wherein the memory control circuit unit is configured to perform a plurality of steps: initiating a data merging operation; selecting a source physical unit and a target physical unit from the rewritable non-volatile memory module to perform the data merging operation; determining whether to create a backup table corresponding to a logical-to-physical mapping table, wherein the logical-to-physical mapping table comprises mapping relationships between a plurality of logical addresses and a plurality of physical addresses; if it is determined that the backup table is created, copying first data located at a first physical address in the source physical unit to a second physical address in the target physical unit, and recording the second physical address in the backup table; determining whether to update the second physical address to the logical-to-physical mapping table according to information in the backup table, wherein the logical-to-physical mapping table records a first logical address mapped to the first physical address; and if it is determined not to create the backup table, copying the first data located at the first physical address in the source physical unit to the second physical address in the target physical unit, and recording that the second physical address is mapped to the first logical address in a physical-to-logical mapping table, and after performing the data merging operation, updating the logical-to-physical mapping table according to the physical-to-logical mapping table such that the first logical address is mapped to the second physical address in the logical-to-physical mapping table.
  10. 10 . The memory storage device according to claim 9 , wherein the backup table also records the first physical address and a first logical address mapped to the first physical address, and the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the information in the backup table comprises: after performing the data merging operation, obtaining a third physical address mapped by the first logical address from the logical-to-physical mapping table; and determining whether to update the second physical address to the logical-to-physical mapping table according to a comparison result between the first physical address and the third physical address.
  11. 11 . The memory storage device according to claim 10 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address comprises: if the third physical address is located in the source physical unit and the third physical address is greater than the first physical address, not updating the second physical address to the logical-to-physical mapping table.
  12. 12 . The memory storage device according to claim 11 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address further comprises: if the third physical address is located in the source physical unit and the third physical address is less than or equal to the first physical address, updating the second physical address to the logical-to-physical mapping table such that the first logical address is mapped to the second physical address.
  13. 13 . The memory storage device according to claim 12 , wherein the steps further comprise: if the third physical address is not located in the source physical unit, not updating the second physical address to the logical-to-physical mapping table.
  14. 14 . The memory storage device according to claim 9 , wherein the steps further comprise: writing second data from the host system to a first physical unit among the physical units, wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit is the same as the first physical unit, determining to create the backup table; otherwise, not creating the backup table.
  15. 15 . The memory storage device according to claim 9 , wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit is an active physical unit or the source physical unit has not been closed, determining to create the backup table.
  16. 16 . The memory storage device according to claim 9 , wherein the step of determining whether to create the backup table corresponding to the logical-to-physical mapping table comprises: if the source physical unit has a corresponding physical-to-logical mapping table, determining not to create the backup table.
  17. 17 . A memory control circuit unit configured to control a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module comprises a plurality of physical units, and the memory control circuit unit comprises: a host interface configured to be coupled to a host system; a memory interface configured to be coupled to the rewritable non-volatile memory module; a memory management circuit coupled to the host interface and the memory interface, wherein the memory management circuit is configured to perform a plurality of steps: initiating a data merging operation; selecting a source physical unit and a target physical unit from the rewritable non-volatile memory module to perform the data merging operation; determining whether to create a backup table corresponding to a logical-to-physical mapping table, wherein the logical-to-physical mapping table comprises mapping relationships between a plurality of logical addresses and a plurality of physical addresses; if it is determined that the backup table is created, copying first data located at a first physical address in the source physical unit to a second physical address in the target physical unit, and recording the second physical address in the backup table; determining whether to update the second physical address to the logical-to-physical mapping table according to information in the backup table, wherein the logical-to-physical mapping table records a first logical address mapped to the first physical address; and if it is determined not to create the backup table, copying the first data located at the first physical address in the source physical unit to the second physical address in the target physical unit, and recording that the second physical address is mapped to the first logical address in a physical-to-logical mapping table, and after performing the data merging operation, updating the logical-to-physical mapping table according to the physical-to-logical mapping table such that the first logical address is mapped to the second physical address in the logical-to-physical mapping table.
  18. 18 . The memory control circuit unit according to claim 17 , wherein the backup table also records the first physical address and a first logical address mapped to the first physical address, and the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the information in the backup table comprises: after performing the data merging operation, obtaining a third physical address mapped by the first logical address from the logical-to-physical mapping table; and determining whether to update the second physical address to the logical-to-physical mapping table according to a comparison result between the first physical address and the third physical address.
  19. 19 . The memory control circuit unit according to claim 18 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address comprises: if the third physical address is located in the source physical unit and the third physical address is greater than the first physical address, not updating the second physical address to the logical-to-physical mapping table.
  20. 20 . The memory control circuit unit according to claim 19 , wherein the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address further comprises: if the third physical address is located in the source physical unit and the third physical address is less than or equal to the first physical address, updating the second physical address to the logical-to-physical mapping table such that the first logical address is mapped to the second physical address.

Description

CROSS-REFERENCE TO RELATED APPLICATION This application claims the priority benefit of Taiwan application serial no. 113134092, filed on Sep. 9, 2024. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification. BACKGROUND Technical Field The disclosure relates to a memory management method, and particularly relates to a method, a memory storage device, and a memory control circuit unit for updating a logical-to-physical mapping table after a data merging operation. Description of Related Art Portable electronic devices such as mobile phones and notebook computers have grown rapidly in recent years, resulting in a rapid increase in consumer demand for storage media. Since rewritable non-volatile memory modules (such as flash memory) have the characteristics of non-volatile data, power saving, small size, and no mechanical structure, it is very suitable to be built into various portable electronic devices as exemplified above. The controller of the rewritable non-volatile memory module may establish a logical-to-physical mapping table to manage the mapping relationships between logical addresses and physical addresses. When the host system writes data, the logical-to-physical mapping table is updated to reflect the new mapping relationship. In addition, the controller may also create a physical-to-logical mapping table. When transferring valid data, the mapping relationship will first be recorded in the physical-to-logical mapping table, and then the mapping relationship will be updated to the logical-to-physical mapping table. However, if valid data is transferred while the host system is writing data, it may not be possible to determine that those mapping relationships are correct. SUMMARY In order to solve the above problems, embodiments of the disclosure propose a memory management method, a memory storage device, and a memory control circuit unit, wherein a backup table of a logical-to-physical mapping table will be established. During a data merging operation, a mapping relationship will be recorded in the backup table first, and then it will be determined whether to update the logical-to-physical mapping table, so as to ensure that the correct mapping relationship is updated. Embodiments of the disclosure provide a memory management method for a rewritable non-volatile memory module, wherein the rewritable non-volatile memory module includes a plurality of physical units. The memory management method includes: initiating a data merging operation; selecting a source physical unit and a target physical unit from the rewritable non-volatile memory module to perform the data merging operation; determining whether to create a backup table corresponding to a logical-to-physical mapping table, wherein the logical-to-physical mapping table contains mapping relationships between a plurality of logical addresses and a plurality of physical addresses; if it is determined to create the backup table, copying first data located at a first physical address in the source physical unit to a second physical address in the target physical unit, and recording the second physical address in the backup table; and determining whether to update the second physical address to the logical-to-physical mapping table based on information in the backup table. In an embodiment, the backup table also records the first physical address and a first logical address mapped to the first physical address. The step of determining whether to update the second physical address to the logical-to-physical mapping table according to the information in the backup table includes: after completing the data merging operation, obtaining a third physical address mapped by the first logical address from the logical-to-physical mapping table; and determining whether to update the second physical address to the logical-to-physical mapping table according to a comparison result between the first physical address and the third physical address. In an embodiment, the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address includes: if the third physical address is located in the source physical unit and the third physical address is greater than the first physical address, not updating the second physical address to the logical-to-physical mapping table. In an embodiment, the step of determining whether to update the second physical address to the logical-to-physical mapping table according to the comparison result between the first physical address and the third physical address also includes: if the third physical address is located in the source physical unit and the third physical address is less than or equal to the first physical address, updating the second physical address to the logical-to-physical mapping table, so that th