Memory management method, controller, storage system, and computer program product

By dividing the logical address space into coarse-grained and fine-grained logical ranges, monitoring read/write activity and idle time, identifying and compressing cold data, the problem of insufficient storage capacity utilization in full-disk encryption scenarios is solved, and efficient cold data management is achieved.

CN123157136APending Publication Date: 2026-11-24HEFEI KAIMENG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611352745.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-02
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In scenarios involving full-disk encryption or file-level encryption, storage devices struggle to effectively identify and compress cold data, resulting in insufficient capacity gains. Furthermore, existing methods are ill-suited to handle the continuous growth of logical address space in embedded memory controllers with limited memory budgets.

Method used

By dividing the logical address space into two levels of logical ranges, coarse-grained and fine-grained, the system continuously monitors read/write activity and idle time, identifies data that has not been written for a long time and has no hotspots, and compresses and writes it back by the host system before encryption.

Benefits of technology

Effectively identifying and compressing cold data reduces the memory overhead of storage devices, improves capacity utilization, and avoids the need for direct compression of encrypted data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157136A_ABST
    Figure CN123157136A_ABST
Patent Text Reader

Abstract

This disclosure provides a memory management method, a memory controller, a memory system, and a computer program product. The method divides the logical address space into multiple coarse-grained logical ranges, each corresponding to multiple fine-grained logical ranges, and continuously monitors the read / write activity and inactivity duration of each coarse-grained logical range; determines whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and inactivity duration meeting preset conditions, analyzes whether there are hot spots in the corresponding multiple fine-grained logical ranges; and in response to a target coarse-grained logical range not being written to after a predetermined stable period since meeting the preset conditions, and multiple fine-grained logical ranges not being identified as hot spots, the data within it is identified as cold data. Thus, the memory device identifies cold data with limited memory overhead and can export the cold data identification results for the host to compress and write back before encryption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data storage technology, and in particular to a memory management technology in which a storage device identifies cold data on the device side and exports the cold determination result to the host system in scenarios of full disk encryption or file-based encryption, so that the host system can perform compression and write-back before encryption. A memory management method, a memory controller, a storage system, and a computer program product are also disclosed. Background Technology

[0002] Mobile and embedded devices widely employ full-disk encryption (FDE) and file-based encryption (FBE) in their storage devices. In this disclosure, full-disk encryption can include volume-level or block-level encryption, while file-based encryption can also be referred to as file-by-file encryption. The storage device lies below the encryption layer, receiving and storing encrypted ciphertext data. Since the statistical characteristics of the ciphertext are close to a random distribution, the compression ratio and deduplication hit rate are close to zero. Therefore, existing practices of transparently compressing or deduplicating data within the storage device are unlikely to yield significant capacity gains in encrypted scenarios.

[0003] On the other hand, terminal devices often store large amounts of unmodified read-only data, such as system images, application resource packages, audio, video, and photo archives, map tiles, and model weights. If this data can be compressed before entering the encryption layer, its storage capacity and the amount of data written can be reduced. However, this requires the side holding the plaintext to know which logical address ranges contain data that has not been modified for a long time. In current practices, storage devices record timestamps for each logical block and use these timestamps to determine if a block has not been written to for an extended period. However, the capacity of the logical address space continues to grow, and the resident memory required for each logical block's timestamp increases linearly with the capacity, which is difficult for embedded memory controllers with limited memory budgets to handle. Furthermore, one-time sequential reads such as backups, scans, and index rebuilds may traverse large logical address ranges within a short period. When sampling statistics are used for read events, relying solely on read / write activity and inactivity time may not be sufficient to reflect sequential reads, allowing logical address ranges currently being read to still be considered as cold data candidates. Summary of the Invention

[0004] In view of this, the present disclosure provides a memory management method, a memory controller, a memory system, and a computer program product. By dividing the logical address space into two levels, coarse-grained logical range and fine-grained logical range, and residently monitoring read / write activity and inactivity time, the coarse-grained logical range is not recently written to and meets preset conditions before analyzing whether there are hot spots in the corresponding fine-grained logical range. The condition for determining cold data is that it has not been written to after a predetermined stable time and there are no hot spots. In this way, data that has not been modified for a long time can be identified under limited resident memory overhead, and the host system holding plaintext can perform compression and write-back on the data before encryption.

[0005] According to a first aspect of this disclosure, a memory management method is provided, applied to a storage device. The method includes: dividing a logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and continuously monitoring the read / write activity and idle time of each coarse-grained logical range; determining whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and idle time meeting preset conditions, analyzing whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to a target coarse-grained logical range not being written to after a predetermined stable time since meeting the preset conditions, and multiple fine-grained logical ranges not being identified as hot spots, identifying the data within the target coarse-grained logical range as cold data.

[0006] According to a second aspect of this disclosure, a memory controller is provided, suitable for a storage device configured with a memory module, comprising: a memory interface control circuit for electrically connecting to the memory module; and a processor electrically connected to the memory interface control circuit, wherein the processor is configured to: divide a logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and continuously monitor the read / write activity and idle time of each coarse-grained logical range; determine whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and idle time meeting preset conditions, analyze whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to a target coarse-grained logical range not being written to after a predetermined stable time since meeting the preset conditions, and the multiple fine-grained logical ranges not being determined as hot spots, determine the data within the target coarse-grained logical range as cold data.

[0007] According to a third aspect of this disclosure, a storage system is provided, comprising: a host system; and a storage device connected to the host system, wherein the storage device is configured to: divide a logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and residently monitor the read / write activity and inactivity duration of each coarse-grained logical range; determine whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and inactivity duration meeting preset conditions, analyze whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to the target coarse-grained logical range self-satisfying preset conditions... If, after a predetermined stable period, the data has not been written and multiple fine-grained logical ranges have not been identified as hotspots, the data within the target coarse-grained logical range is identified as cold data. The coarse-grained logical range storing the cold data is then exported as a cold alert message. The host system is configured to: retrieve the cold alert message from the storage device via a read buffer command; determine the logical address range of the target cold data based on the cold alert message; read the plaintext data corresponding to the target cold data based on the logical address range and compress the plaintext data before encryption; and send the compressed data back to the storage device. The storage device is also configured to: write back the compressed data sent back by the host system.

[0008] According to a fourth aspect of this disclosure, a computer program product is provided, including a computer program that, when loaded and executed by a memory controller of a storage device, causes the memory controller to perform: dividing a logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and residently monitoring the read / write activity and idle time of each coarse-grained logical range; determining whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and idle time meeting preset conditions, analyzing whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to a target coarse-grained logical range not being written to after a predetermined stable time since meeting the preset conditions, and multiple fine-grained logical ranges not being identified as hot spots, identifying the data within the target coarse-grained logical range as cold data.

[0009] Based on the above, the memory management method, memory controller, memory system, and computer program product provided in this disclosure divide the logical address space into two levels: coarse-grained logical ranges and fine-grained logical ranges. The coarse-grained logical range is used as the unit for resident monitoring of read / write activity and inactivity duration. This makes the number of records required for resident monitoring related to the number of coarse-grained logical ranges, eliminating the need to maintain time information or access status for each logical block in the logical address space. Activity records for fine-grained logical ranges are only activated as needed after the coarse-grained logical range has not been recently written to and its read / write activity and inactivity duration meet preset conditions. This allows fine-grained observation to focus on coarse-grained logical ranges that have entered a candidate state, without needing to residently maintain fine-grained activity records for the entire logical address space. Using recent write activity as a prerequisite for entering the candidate state excludes coarse-grained logical ranges that have indeed been recently written to. Using sequential access metrics as a negative factor in cold data scoring reduces the likelihood that coarse-grained logical ranges undergoing sequential reads will meet preset conditions. Using a predetermined stabilization period as further confirmation between the candidate state and the cold data state avoids immediately classifying coarse-grained logical ranges as cold data upon meeting preset conditions, and reserves confirmation time for subsequent write events and local hotspots. Data within a target coarse-grained logical range is only classified as cold data if it has not been written to after a predetermined stabilization period since meeting preset conditions, and if none of its corresponding fine-grained logical ranges have been classified as hotspots. This reduces the likelihood of classifying recently written, sequentially read, or locally accessed data as cold data. The resulting cold data classification result can be exported as a cold alert message and provided to the host system. The host system can then determine the logical address range of the target cold data based on the cold alert message, obtain the corresponding plaintext data, compress it before encryption, and then send the compressed data back to the storage device for write-back. Therefore, compression can be applied to plaintext data before encryption, without requiring the storage device to directly compress the encrypted data. Attached Figure Description

[0010] Figure 1 This is a block diagram illustrating a host system and storage device according to an embodiment of the present disclosure;

[0011] Figure 2 This is a main flowchart of a memory management method according to embodiments of the present disclosure;

[0012] Figure 3 This is a schematic diagram illustrating a two-level granular structure of coarse-grained logic range and fine-grained logic range according to an embodiment of the present disclosure.

[0013] Figure 4A A flowchart illustrating the coarse-grained logical range of record writes according to embodiments of this disclosure;

[0014] Figure 4B This is a flowchart illustrating a query to determine whether a coarse-grained logical range has been recently written, according to embodiments of this disclosure.

[0015] Figure 5 This is a flowchart illustrating the determination of whether a hotspot exists within a fine-grained logic range, as shown in embodiments of this disclosure.

[0016] Figure 6 The diagram shows the state transition between cold score and hysteresis according to embodiments of this disclosure;

[0017] Figure 7 This is a timing diagram illustrating the interaction between the storage device and the host system according to embodiments of the present disclosure;

[0018] Figure 8 This is a schematic diagram of the data structure for a cold notification message according to an embodiment of the present disclosure. Detailed Implementation

[0019] Reference will now be made in detail to exemplary embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings. Wherever possible, the same component reference numerals are used in the drawings and description to denote the same or similar parts.

[0020] Figure 1 This is a block diagram illustrating a host system and storage device according to embodiments of the present disclosure. Please refer to... Figure 1 The host system 10 is, for example, a mobile phone, tablet computer, laptop computer, personal computer, or server. The host system 10 includes a processor 110 (also called a second processor), host memory 120 (also called host RAM), and a data transfer interface circuit 130. In this embodiment, the processor 110 is electrically connected to the host memory 120 and the data transfer interface circuit 130. In another embodiment, the processor 110, host memory 120, and data transfer interface circuit 130 are electrically connected to each other via a system bus. In this embodiment, the processor 110, host memory 120, and data transfer interface circuit 130 may be located on the motherboard of the host system 10.

[0021] The storage device 20 includes a memory controller 210, a memory module 220 (also known as a rewritable non-volatile memory module), and a connection interface circuit 230. The memory controller 210 includes a data management circuit 212, a processor 211 (also known as a first processor), a buffer memory 214, and a memory interface control circuit 213.

[0022] In this embodiment, the host system 10 is electrically connected to the connection interface circuit 230 of the storage device 20 through the data transmission interface circuit 130 to perform data access operations. For example, the host system 10 can store data to the storage device 20 or read data from the storage device 20 via the data transmission interface circuit 130.

[0023] In this embodiment, the number of data transmission interface circuits 130 can be one or more. Through the data transmission interface circuits 130, the motherboard can be electrically connected to the storage device 20 via wired or wireless means. The storage device 20 can be, for example, an embedded storage device, a solid-state drive (SSD), a USB flash drive, or a memory card. The embedded storage device can be, for example, a storage device conforming to the Universal Flash Storage (UFS) specification or a storage device conforming to the embedded MultiMediaCard (eMMC) specification. The storage device 20 can also be, for example, a wireless storage device, such as a Near Field Communication (NFC) storage device, a WiFi storage device, a Bluetooth storage device, or a Bluetooth Low Energy storage device (e.g., iBeacon), or other storage devices based on various wireless communication technologies. Furthermore, the motherboard can also be electrically connected via the system bus to various I / O devices such as a Global Positioning System (GPS) module, a network interface card, a wireless transmission device, a keyboard, a screen, and a speaker.

[0024] In this embodiment, the data transmission interface circuit 130 and the connection interface circuit 230 are interface circuits compatible with the Peripheral Component Interconnect Express (PCI Express) standard. Furthermore, data transmission between the data transmission interface circuit 130 and the connection interface circuit 230 utilizes the Non-Volatile Memory Express (NVMe) communication protocol. In another embodiment, the data transmission interface circuit 130 and the connection interface circuit 230 are interface circuits compatible with the general flash memory specification. In this case, the host system 10 and the storage device 20 can utilize the Small Computer System Interface (SCSI) command set for data and control information transmission. In yet another embodiment, the data transmission interface circuit 130 and the connection interface circuit 230 are interface circuits compatible with the embedded multimedia card specification.

[0025] In another embodiment, the connection interface circuit 230 may be packaged in a chip with the memory controller 210, or the connection interface circuit 230 may be disposed outside a chip including the memory controller 210.

[0026] In this embodiment, the host memory 120 is used to temporarily store instructions or data executed by the processor 110. In this embodiment, the host memory 120 may be Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), etc. However, it should be understood that this disclosure is not limited to this, and the host memory 120 may also be other suitable memories.

[0027] The memory controller 210 is used to execute multiple logic gates or control instructions implemented in hardware or firmware, and to perform operations such as writing, reading and erasing data in the memory module 220 according to the instructions of the host system 10, and to execute the memory management method provided in this disclosure.

[0028] More specifically, the processor 211 in the memory controller 210 is hardware with computing capabilities, used to control the overall operation of the memory controller 210. Specifically, the processor 211 is configured with multiple control instructions or program codes, and these control instructions or program codes are executed when the storage device 20 is running to perform operations such as writing, reading, and erasing data.

[0029] Furthermore, the processor 211 is configured to execute the memory management method provided in this disclosure. Specifically, the processor 211 divides the logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and continuously monitors the read / write activity and idle time of each coarse-grained logical range; the processor 211 determines whether the multiple coarse-grained logical ranges have been recently written to; in response to the target coarse-grained logical range not being recently written to and its read / write activity and idle time meeting preset conditions, the processor 211 analyzes whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to the target coarse-grained logical range not being written to after a predetermined stable time since meeting the preset conditions, and multiple fine-grained logical ranges not being identified as hot spots, the processor 211 identifies the data in the target coarse-grained logical range as cold data. The read / write events monitored by the processor 211 originate from access requests issued by the host system 10 via the data transmission interface circuit 130 and the connection interface circuit 230, while the actual data access to the memory module 220 is performed via the memory interface control circuit 213.

[0030] It is worth mentioning that, in this embodiment, the processor 110 and the processor 211 are, for example, a central processing unit (CPU), a microprocessor, or other programmable processing units, a digital signal processor (DSP), a programmable controller, an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or other similar circuit components, and this disclosure is not limited thereto.

[0031] In this embodiment, as described above, the memory controller 210 further includes a data management circuit 212, a buffer memory 214, and a memory interface control circuit 213. It should be noted that the operations performed by each component of the memory controller 210 can also be considered as operations performed by the memory controller 210 itself, and the operations performed by the memory controller 210 can also be considered as operations performed by the storage device 20.

[0032] The data management circuit 212 is electrically connected to the connection interface circuit 230 and the processor 211 to receive instructions from the processor 211 for data transmission. For example, data is read from the host system 10 (e.g., host memory 120) via the connection interface circuit 230, and the read data is written to the memory module 220 via the processor 211 and the memory interface control circuit 213. Alternatively, a read operation is performed according to a read instruction from the host system 10, data is read from one or more physical units of the memory module 220 via the memory interface control circuit 213, and the read data is transmitted to the host system 10 via the processor 211, the data management circuit 212, and the connection interface circuit 230. In one embodiment, the data management circuit 212 is also used to receive instructions from the processor 211, respond to the read buffer command issued by the host system 10, transmit the cold prompt information exported by the processor 211 to the host system 10 via the connection interface circuit 230; and receive the compressed data returned by the host system 10 after compressing the plaintext data corresponding to the target cold data before encryption, so that the processor 211 can write it back to the memory module 220 via the memory interface control circuit 213.

[0033] In another embodiment, the data management circuit 212 may also be integrated into the processor 211. The memory interface control circuit 213 is electrically connected to the processor 211 and the memory module 220 to receive instructions from the processor 211 and cooperate with the data management circuit 212 to perform write (also known as programming) operations, read operations, or erase operations on the memory module 220.

[0034] Furthermore, data to be written to memory module 220 is converted into a format acceptable to memory module 220 via memory interface control circuit 213. Specifically, if processor 211 needs to access memory module 220, processor 211 transmits a corresponding instruction sequence to memory interface control circuit 213 to instruct memory interface control circuit 213 to perform the corresponding operation. For example, these instruction sequences may include write instruction sequences indicating the writing of data, read instruction sequences indicating the reading of data, erase instruction sequences indicating the erasure of data, and corresponding instruction sequences for indicating various memory operations. These instruction sequences may include one or more signals, or data on the bus. These signals or data may include instruction codes or program codes. For example, a read instruction sequence may include information such as the read identification code, memory address, and physical address.

[0035] Furthermore, the memory controller 210 establishes a Logical to Physical Address Mapping Table and a Physical to Logical Address Mapping Table to record the mapping relationship between the logical addresses of logical units (e.g., logical blocks, logical pages) and the physical addresses of physical units (e.g., physical erase units or physical blocks, physical pages) configured for the memory module 220. In other words, the memory controller 210 can use the Logical to Physical Address Mapping Table to find the physical unit mapped to a logical unit (e.g., find the physical page mapped to a logical page; find the physical address mapped to a logical address), and the memory controller 210 can use the Physical to Logical Address Mapping Table to find the logical unit mapped to a physical unit (e.g., find the logical page mapped to a physical page; find the logical address mapped to a physical address).

[0036] In this embodiment, the multiple coarse-grained logical ranges and their corresponding multiple fine-grained logical ranges divided by the processor 211 constitute a two-level granularity partitioning based on the aforementioned logical address space. Their mapping relationship from logical address to physical address recorded in the logic-to-physical address mapping table is independent of each other: the two-level granularity partitioning is used to handle hot / cold address determination, while the logic-to-physical address mapping table is used to handle address translation. The granularity relationship, partitioning method, and indexing method of the two-level granularity partitioning will be discussed later. Figure 3 The embodiments are described below.

[0037] Buffer memory 214 is electrically connected to data management circuit 212 and processor 211, and is used to temporarily store data and instructions from host system 10, data from memory module 220, and various system data for managing storage device 20. In this embodiment, buffer memory 214 is also used to store write detectors, fine-grained activity log tables, cold scoring status, and cold alert information required by this disclosure.

[0038] The write detector is a record structure used to record write events occurring in the coarse-grained logic range and to determine whether the coarse-grained logic range has been recently written to. It can be, for example, a probabilistic filter, a bitmap, or a time information record, and this disclosure is not limited to these. The fine-grained activity log table records the access status of each fine-grained logic range within the coarse-grained logic range that is in a candidate state. The cold score is a value determined by the processor 211 based on a weighted average of the inactivity time and read / write activity of the coarse-grained logic range, and can be further adjusted according to a sequential access index in appropriate embodiments for comparison by the processor 211 with an entry threshold or exit threshold. The cold determination state represents the discrete state of the coarse-grained logic range in the cold data determination process, and may include a non-cold state, a candidate state, and a cold data state. The cold scoring status record is a data record maintained for each coarse-grained logical range. It stores information required for cold scoring calculation, such as read activity statistics, write activity statistics, and the tier to which the inactivity period belongs, as well as the current cold judgment status of that coarse-grained logical range. The processor 211 can calculate or update the corresponding cold score based on the information in the cold scoring status record when performing cold data judgment. Cold alert information is used to record coarse-grained logical ranges that have been determined to store cold data and is available for reading by the host system 10. The data organization methods, capacity configurations, and update mechanisms of the above structures will be discussed in subsequent sections. Figure 4A , Figure 4B , Figure 5 , Figure 6 and Figure 8 The embodiments are described separately; the reading interaction between the cold prompt information and the host system 10 will be discussed in subsequent corresponding embodiments. Figure 7 The embodiments are described below.

[0039] The memory module 220 is electrically connected to the memory interface control circuit 213 and is used to store user data sent by the host system 10. In this disclosure, the logical address space configured for the memory module 220 is the object of the processor 211 to perform two-level granularity partitioning and cold / hot data determination; the plaintext data corresponding to the user data stored in the memory module 220 and determined to be cold data is the object of compression performed by the host system 10 before encryption; the memory module 220 also serves as the object for writing back the compressed data returned by the host system 10.

[0040] In one embodiment, the memory cell structure of the memory module 220 can be understood as a multi-layered physical organization architecture. Specifically, the memory module 220 includes multiple chips, each chip has multiple planes, and each plane includes multiple physical blocks, each physical block consisting of multiple physical pages. It should be noted that this disclosure is not limited to the specific size of each physical page and logical page.

[0041] Based on the above Figure 1The block diagram shown illustrates the host system and storage device. The storage device uses the processor in its memory controller as the execution entity. Based on the write detector, fine-grained activity log table, and cold scoring status maintained by the buffer memory, it continuously monitors the read / write activity and idle time of the coarse-grained and fine-grained logical ranges divided in the logical address space. It then exports the determined cold data as cold prompt information and provides it to the host system via the connection interface circuit. This allows the memory controller to identify cold data and prompt the host system with the location of the cold data without compressing the ciphertext. The host system performs compression before encryption and sends back the compressed data. The storage device then writes back the sent data.

[0042] Reference Figure 2 In one embodiment, the processor 211 of the memory controller 210 executes the memory management method provided in this disclosure, which includes steps S210 to S260. The logical address space partitioning in step S210 does not need to be repeated in each decision round, while the monitoring of read / write activity and idle time for each coarse-grained logical range is performed continuously during the operation of the storage device 20. Steps S220 to S260 constitute a cold data determination process that can be executed round by round. The cold data determination process can, for example, be periodically executed by the processor 211 for all or a portion of multiple coarse-grained logical ranges, with each execution constituting one decision round. Figure 2 The start and end in S210 indicate the start and end of a cold data determination process, and do not indicate the cessation of resident monitoring in step S210. In the cold data determination process, processor 211 can execute backward or return to the determination entry of step S220 according to the determination results of each determination step.

[0043] In step S210, the processor 211 divides the logical address space into multiple coarse-grained logical ranges, each corresponding to multiple fine-grained logical ranges, and continuously monitors the read / write activity and idle time of each coarse-grained logical range. Specifically, in one embodiment, the size of the coarse-grained logical range can be, for example, 32MB or 64MB, and the size of the fine-grained logical range can be, for example, 2MB to 8MB. Taking a logical address space capacity of 256GB, converted according to 1GB equals 1024MB, and a coarse-grained logical range size of 32MB as an example, the logical address space can be divided into 8192 coarse-grained logical ranges.

[0044] Processor 211 maintains a cold rating status record for each coarse-grained logic range to record the read / write activity and inactivity duration of the corresponding coarse-grained logic range. The cold rating status record, along with the write detector required for recent write determination and the fine-grained activity record table used by the coarse-grained logic range in the candidate state, are stored in buffer memory 214. The total capacity occupied by these three components is, for example, approximately 32KB for the cold rating status record, approximately 32KB for the write detector, and approximately 8KB for the fine-grained activity record table, for a total base capacity of approximately 72KB. This base capacity estimate does not include the fields required for continuous access span tracking.

[0045] The consecutive access span is used to determine the sequential access metric for the coarse-grained logic range. The sequential access metric is used to identify the sequential scan of the coarse-grained logic range, thereby preventing the coarse-grained logic range from being misjudged as meeting preset conditions due to sequential scans. The determination methods for consecutive access span and sequential access metric will be discussed later. Figure 3 The embodiments described above are examples of capacity, granularity, and record structure, which can be adjusted according to the capacity of the logical address space and the resource configuration of the storage device 20. The structural relationship and indexing method of the two-level granularity division will also be discussed later. Figure 3 The embodiments are described below.

[0046] In step S220, processor 211 determines whether multiple coarse-grained logical ranges have been recently written to. This determination can be performed separately for each of the multiple coarse-grained logical ranges processed in this determination round. For a coarse-grained logical range currently determined to have been recently written to, processor 211 does not include it in the subsequent cold data determination of this round and returns to the determination entry point of step S220 to continue determining another coarse-grained logical range to be processed, or to re-determine the coarse-grained logical range in a subsequent determination round. For a coarse-grained logical range currently determined not to have been recently written to, processor 211 uses it as the target coarse-grained logical range, and the process proceeds to step S230.

[0047] Specifically, the processor 211 can, for example, use a write detector to record the coarse-grained logical range where a write has occurred, and in step S220, query the write detector to obtain a determination result as to whether the current coarse-grained logical range has been recently written to. The recording method and time window rotation method of the write detector will be discussed later. Figure 4A The implementation details the query method for the write detector and the method for determining whether something has been recently written to, which will be discussed later. Figure 4B The embodiments are described below.

[0048] In step S230, processor 211 determines whether the read / write activity and idle time of the target coarse-grained logic range meet preset conditions. If the determination result of step S230 is negative, the target coarse-grained logic range does not yet enter the candidate state, and the process returns to the determination entry of step S220 to continue determining another coarse-grained logic range to be processed, or to re-determine the target coarse-grained logic range in a subsequent determination round. If the determination result of step S230 is positive, the target coarse-grained logic range enters the candidate state, and the process proceeds to step S240.

[0049] Specifically, the preset conditions could be, for example, a "cold score" determined by weighting inactivity time, read activity, and write activity with corresponding weights to reach the entry threshold. The longer the inactivity time, the higher the cold score; the higher the read activity or write activity, the lower the cold score. The calculation method for the cold score, the hysteresis mechanism formed by the entry and exit thresholds, and the transition methods between different cold judgment states will be discussed in subsequent sections. Figure 6 The embodiments are described below.

[0050] In step S240, the processor 211, in response to the fact that the target coarse-grained logic range has not been written to recently and its read / write activity and inactivity time meet preset conditions, analyzes whether there are hotspots among the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range. Specifically, in one embodiment, the processor 211 can enable fine-grained activity recording for the target coarse-grained logic range that has entered the candidate state, to record the access status of each fine-grained logic range within the target coarse-grained logic range during the observation period, and determine whether each fine-grained logic range is a hotspot based on the fine-grained activity recording. The carrier structure, capacity configuration, recording method, and hotspot criteria of the fine-grained activity recording will be discussed later. Figure 5 The embodiments are described below.

[0051] In step S250, processor 211 determines whether the target coarse-grained logic range has not been written after a predetermined stabilization period since the preset conditions were met, and whether all the fine-grained logic ranges corresponding to the target coarse-grained logic range have not been identified as hotspots. If all of the above conditions are not met or any one of the conditions is not met, the determination result of step S250 is negative, and the process returns to the determination entry point of step S220; if all of the above conditions are met, the process proceeds to step S260.

[0052] It should be noted that the process return step S220 does not automatically indicate that the target coarse-grained logical range has exited the candidate state. Whether the target coarse-grained logical range maintains its candidate state or reverts to a non-cold state depends on its write activity, cold score, and hotspot judgment results. For example, if the target coarse-grained logical range is written to while in the candidate state, or its cold score meets the conditions for exiting the candidate state, the processor 211 can remove its candidate state, causing it to revert to a non-cold state. If the target coarse-grained logical range fails to enter the cold data state only because it contains a fine-grained logical range that has been judged as a hotspot, and has not yet met the conditions for exiting the candidate state, the target coarse-grained logical range can still maintain its candidate state and be judged again in subsequent judgment rounds. Related state transition methods will be discussed later. Figure 6 The embodiments are described below.

[0053] In one embodiment, the predetermined stabilization period can be, for example, 48 to 72 hours. The purpose of the predetermined stabilization period is to ensure that the target coarse-grained logic range remains unwritten for a certain period after meeting the preset conditions, thus preventing it from being immediately classified as cold data upon entering the candidate state. Once a coarse-grained logic range in the candidate state is written to, it can be removed from the candidate state and revert to a non-cold state. Therefore, even if the predetermined stabilization period is longer than the time span covered by the write detector, writes occurring within the predetermined stabilization period will still cause the target coarse-grained logic range to exit the candidate state without proceeding to step S260.

[0054] The predetermined stabilization period is used as an example and can be adjusted according to the operating conditions of the storage device 20. The predetermined stabilization period and the observation period in step S240 are two different durations for different purposes. The predetermined stabilization period is used to confirm whether the target coarse-grained logic range as a whole is continuously in a write-inactive state, while the observation period is used to observe the local access status of each fine-grained logic range within the target coarse-grained logic range.

[0055] In step S260, the processor 211 determines the data within the target coarse-grained logic range as cold data if the target coarse-grained logic range has not been written after a predetermined stable period since the preset conditions have been met, and multiple fine-grained logic ranges have not been identified as hotspots.

[0056] Furthermore, the processor 211 can derive a coarse-grained logical range of the stored cold data into cold alert information, which the host system 10 uses to determine the logical address range corresponding to the target cold data, and compress the plaintext data corresponding to the target cold data before encryption. The host system 10 can re-encrypt the compressed data and send it back to the storage device 20, which then writes the returned data back to the non-volatile memory 220. The data structure of the cold alert information will be discussed later. Figure 8In the embodiments described, the reading and interaction process of the cold alert information between the storage device 20 and the host system 10, as well as the compression and write-back process of the host system 10, will be discussed in subsequent corresponding... Figure 7 The embodiments are described below.

[0057] Furthermore, if a coarse-grained logical range that has been identified as cold data is subsequently written to, or if its cold score meets the conditions for exiting the cold data state, the processor 211 can remove the cold data determination for the coarse-grained logical range and update the corresponding cold warning information. The path for removing the cold data determination and the corresponding state transition method will be discussed later. Figure 6 The embodiments are described below.

[0058] It should be noted that the three branches—"yes" in step S220, "no" in step S230, and "no" in step S250—all indicate that the cold data determination process returns to the judgment entry point of step S220, rather than returning to step S210. The logical address space partitioning in step S210 does not need to be re-executed in each determination round, while the monitoring of read / write activity and idle time for each coarse-grained logical range is continuously performed during the operation of the storage device 20. Steps S220 to S260 constitute a round-by-round cold data determination process. After returning to step S220, the processor 211 can continue to determine another coarse-grained logical range to be processed, or re-determine previously failed coarse-grained logical ranges in subsequent determination rounds.

[0059] Specifically, if the judgment result of step S220 is "yes," it means that the current coarse-grained logical range has recently been written to, and therefore will not be included in the subsequent cold data judgment in this round. If the judgment result of step S230 is "no," it means that although the current coarse-grained logical range has not been written to recently, its read / write activity and inactivity time have not yet met the preset conditions, and therefore it has not yet entered the candidate state. If the judgment result of step S250 is "no," it means that the target coarse-grained logical range has not simultaneously met the conditions of not being written to after a predetermined stable time and that none of the fine-grained logical ranges have been judged as hotspots.

[0060] The return step S220 of the cold data determination process is a different matter from the cold determination state transition of the target coarse-grained logical range. Whether the target coarse-grained logical range exits the candidate state can be determined based on the occurrence of a write operation, the cold score meeting the exit condition, or other state transition conditions. If the target coarse-grained logical range fails to enter the cold data state only due to the existence of hotspots, and has not yet met the conditions for exiting the candidate state, then the target coarse-grained logical range can remain in the candidate state and be judged again in subsequent determination rounds.

[0061] For example, suppose the logical address space of storage device 20 is divided into coarse-grained units of 32MB, one of which stores a system image, and the system image has not been written to in recent days. Processor 211 queries the write detector in step S220 but fails to find a match, thus determining that the coarse-grained logical range has not been written to recently. In step S230, processor 211 obtains that the inactivity time of the coarse-grained logical range has reached several days, and its read / write activity is low, thus determining that the coarse-grained logical range meets preset conditions and enters the candidate state.

[0062] In step S240, processor 211 enables fine-grained activity recording for the coarse-grained logical range to observe the access status of each fine-grained logical range within it during the observation period. After 48 hours have passed since the coarse-grained logical range met the preset conditions, in step S250, processor 211 confirms that the coarse-grained logical range has not been written to within 48 hours, and that none of the fine-grained logical ranges within it have been identified as hotspots. Therefore, in step S260, the data within the coarse-grained logical range is identified as cold data.

[0063] Conversely, if the coarse-grained logical range is written within 48 hours due to an application update, the processor 211 removes the candidate state of the coarse-grained logical range, returning it to a non-cold state. The judgment result of step S250 is negative, and the coarse-grained logical range is not judged as cold data. The processor 211 can re-determine whether the coarse-grained logical range meets the cold data judgment condition in subsequent judgment rounds.

[0064] Based on the above Figure 2 The main flow of the memory management method shown involves the memory controller first continuously monitoring read / write activity and idle time in units of coarse-grained logical ranges. Then, it progressively converges through three levels of screening: whether the data has been recently written to, whether the read / write activity and idle time meet preset conditions, and whether the data has not been written to after a predetermined stabilization period and is not identified as a hotspot in any of the fine-grained logical ranges. Only then is data within the coarse-grained logical ranges classified as cold data. Thus, fine-grained observation can be limited to coarse-grained logical ranges that have passed the first two levels of screening and entered the candidate state, without needing to continuously maintain fine-grained activity records for all coarse-grained logical ranges in the logical address space. Coarse-grained logical ranges that have not yet passed any level of screening are temporarily excluded from cold data determination. This reduces the storage resources occupied by fine-grained activity records while decreasing the likelihood of data that has recently been written to, has high read / write activity, or contains local hotspots being classified as cold data.

[0065] Reference Figure 3 In one embodiment, Figure 3 This illustrates a two-level granularity structure of the logical address space. The processor 211 divides the logical address space into multiple coarse-grained logical ranges 310 arranged sequentially along the logical address order. Figure 3The upper part is represented by a coarse-grained logical range 310 located in the middle. The boxes and ellipses on the left and right sides of the coarse-grained logical range 310 represent other coarse-grained logical ranges 310 arranged in the logical address space along the logical address order.

[0066] As shown by arrow A31, the coarse-grained logic range 310 in the middle is enlarged and expanded to... Figure 3 The following shows multiple fine-grained logic ranges of 320. Figure 3 The two guide lines extending downwards from the lower left and lower right corners of the coarse-grained logic range 310 indicate that the multiple fine-grained logic ranges 320 below correspond to the coarse-grained logic range 310 as a whole. Figure 3 The fine-grained logic range 320 located in the middle is represented below. The boxes and ellipses on the left and right sides of the fine-grained logic range 320 represent other fine-grained logic ranges 320 arranged in logical address order within the coarse-grained logic range 310.

[0067] Specifically, the identifier of the coarse-grained logical range 310 and the index of the fine-grained logical range 320 can be pre-established or calculated based on the logical address. Taking the calculation based on the logical address as an example, the logical address, the size of the coarse-grained logical range 310, and the size of the fine-grained logical range 320 can be converted into the same logical address unit. The processor 211 can determine the identifier of the coarse-grained logical range 310 to which the logical address belongs based on the integer quotient obtained by dividing the logical address by the number of logical address units contained in the coarse-grained logical range 310, and determine the offset of the logical address within the coarse-grained logical range 310 based on the corresponding remainder. The processor 211 can also determine the index of the fine-grained logical range 320 to which the logical address belongs based on the integer quotient obtained by dividing the offset by the number of logical address units contained in the fine-grained logical range 320.

[0068] When the number of logical address units contained in the coarse-grained logical range 310 is a power of 2, the processor 211 can also obtain the identifier of the coarse-grained logical range 310 to which the logical address belongs by shifting the logical address to the right by a predetermined number of bits. The predetermined number of bits is determined by the size of the coarse-grained logical range 310 and the unit of the logical address. Similarly, when the number of logical address units contained in the fine-grained logical range 320 is a power of 2, the processor 211 can determine the index of the fine-grained logical range 320 by shifting the logical address based on the offset of the logical address within the coarse-grained logical range 310. In the implementation that calculates the identifier and index based on the logical address, the processor 211 does not need to maintain an additional logical address mapping table for each fine-grained logical range 320.

[0069] In this embodiment, the size of the coarse-grained logic range 310 can be, for example, 32MB, and the size of the fine-grained logic range 320 can be, for example, 2MB, 4MB, or 8MB. When the size of the coarse-grained logic range 310 is 32MB, each coarse-grained logic range 310 can correspond to 16 fine-grained logic ranges 320 of size 2MB, 8 fine-grained logic ranges 320 of size 4MB, or 4 fine-grained logic ranges 320 of size 8MB. Taking a fine-grained logic range 320 of size 4MB as an example, each coarse-grained logic range 310 corresponds to 8 fine-grained logic ranges 320. The size of the coarse-grained logic range 310 can also be, for example, 64MB; in this case, when the sizes of the fine-grained logic ranges 320 are 2MB, 4MB, or 8MB, each coarse-grained logic range 310 can correspond to 32, 16, or 8 fine-grained logic ranges 320, respectively. The granularity and corresponding quantity mentioned above are examples and can be selected based on the capacity of storage device 20, logical address units, and resource configuration of memory controller 210.

[0070] It should be noted that the logical division relationship and indexing rules of the fine-grained logical range 320 remain valid during the operation of the storage device 20, allowing the processor 211 to determine the continuous access span and sequential access indicators of each coarse-grained logical range 310. The fine-grained activity record used to record the access status of each fine-grained logical range 320 can be activated only when the corresponding coarse-grained logical range 310 enters the candidate state, and reclaimed when the corresponding coarse-grained logical range 310 exits the candidate state.

[0071] In the implementation that uses an index to calculate fine-grained logical ranges 320 based on logical addresses, it is not necessary to maintain a resident index mapping table for all fine-grained logical ranges 320 in the logical address space. Only when one or more coarse-grained logical ranges 310 are in a candidate state is it necessary to create or enable corresponding fine-grained activity records for them. Therefore, the linear increase in the number of fine-grained activity records used to determine local hotspots with the capacity of the logical address space in relation to the number of fine-grained logical ranges 320 can be avoided. The carrier structure, capacity configuration, recording method, and eviction method of fine-grained activity records will be discussed later. Figure 5 The embodiments are described below.

[0072] Based on the above Figure 3The two-level granularity structure shown allows the processor 211 to use a coarse-grained logical range 310 as the unit for resident monitoring of read / write activity and idle time, and a fine-grained logical range 320 as the unit for determining continuous access span, sequential access indicators, and local hotspots. Thus, while maintaining fine-grained analysis capabilities, fine-grained activity records can be limited to the coarse-grained logical range 310 that has entered the candidate state, without needing to continuously maintain access records for the entire fine-grained logical range 320 in the logical address space.

[0073] In this embodiment, the processor 211 determines the continuous access span of the coarse-grained logic range based on the continuous access of adjacent fine-grained logic ranges among multiple fine-grained logic ranges corresponding to the coarse-grained logic range, and determines the sequential access index of the coarse-grained logic range based on the continuous access span. When determining whether the read / write activity and idle time meet preset conditions, the processor 211 also makes a judgment based on the sequential access index to suppress the coarse-grained logic range from being mistakenly determined to meet the preset conditions due to sequential scanning.

[0074] Specifically, in one embodiment, a sequential scan of the storage device 20 can sequentially traverse multiple fine-grained logic ranges 320 within a coarse-grained logic range 310 within a short period of time, or even cover all fine-grained logic ranges 320 within the coarse-grained logic range 310. The read activity statistic in read / write activity can be updated, for example, in response to a read event with a predetermined sampling probability; therefore, the increase in read activity statistic caused by a sequential scan may be limited. Without further identification of the sequential scan, the coarse-grained logic range 310 being sequentially read may still be mistakenly determined to meet preset conditions.

[0075] Sequential scanning can be a large-scale continuous read, such as from continuous playback of media files, data backup, or data integrity checks. If a coarse-grained logical range 310 is mistakenly identified as cold data during such a sequential scan, subsequent target data read, compression, and write-back operations on the coarse-grained logical range 310 may compete with foreground read / write requests for access resources of the storage device 20, thereby increasing the response latency of foreground read / write requests.

[0076] The aforementioned consecutive access span can be determined as follows: In response to the current access to the coarse-grained logic range 310 hitting the next fine-grained logic range 320 hit by the previous access, the processor 211 increments the consecutive access span; if the current access does not hit the next fine-grained logic range 320 hit by the previous access, the consecutive access span is reset to 1. The sequential access index is the ratio of the consecutive access span to the number of fine-grained logic ranges 320 corresponding to the coarse-grained logic range 310, and the sequential access index does not exceed a predetermined upper limit.

[0077] The sequential access index can be determined according to the following formula:

[0078]

[0079] in, For sequential access metrics with a coarse-grained logical range of 310, This represents the span of consecutive accesses within the coarse-grained logic range 310, specifically the number of times the fine-grained logic range 320 is hit sequentially during the current consecutive access process. This represents the number of fine-grained logic ranges 320 corresponding to the coarse-grained logic range 310. This is a predetermined upper limit, and can be, for example, 1.0. Sequential access metrics. The value range is 0 to .

[0080] The processor 211 can maintain the index and corresponding consecutive access span of the fine-grained logical range 320 hit by the previous access for each coarse-grained logical range 310, and store the index, consecutive access span, and cold score status record together in the buffer memory 214. Each coarse-grained logical range 310 corresponds to one index and consecutive access span, therefore the index and consecutive access span are fields not yet included in the aforementioned basic capacity estimation. The method of incorporating the sequential access index into the preset condition judgment and its relationship with the cold score will be addressed in subsequent corresponding... Figure 6 The embodiments are described below.

[0081] The following numerical example illustrates the update process of consecutive access span and sequential access metrics. Assume a coarse-grained logical range of 310 corresponds to eight fine-grained logical ranges of 320, and a predetermined upper limit is set. The value is 1.0. For ease of illustration, in this numerical example, the access location is represented by the logical block offset relative to the starting logical address of the coarse-grained logical range 310, and it is assumed that each fine-grained logical range 320 covers 1000 consecutive logical blocks. The 1000 logical blocks are merely an example value used to illustrate the calculation of indexing and sequential access indicators, and do not limit the actual capacity of the fine-grained logical range 320 when expressed in MB.

[0082] In the numerical examples above, the first fine-grained logic range 320 corresponds to a relative logic block offset of 0 to 999, the second fine-grained logic range 320 corresponds to a relative logic block offset of 1000 to 1999, and so on for the remaining fine-grained logic ranges 320, with the eighth fine-grained logic range 320 corresponding to a relative logic block offset of 7000 to 7999.

[0083] The host system 10 sequentially issues seven read accesses to the coarse-grained logical range 310. The logical block offsets of each read access relative to the starting logical address of the coarse-grained logical range 310 are 10, 1100, 2100, 3100, 4100, 5100, and 6100, respectively. Therefore, the seven read accesses sequentially hit the 1st, 2nd, 3rd, 4th, 5th, 6th, and 7th fine-grained logical range 320 within the coarse-grained logical range 310.

[0084] During the first read access, processor 211 sets the consecutive access span to 1. Each subsequent read access hits the next fine-grained logic range 320 hit by the previous read access, thus the consecutive access span is incremented sequentially. The update process of the consecutive access span and sequential access index during the seven read accesses is shown in Table 1.

[0085] Table 1

[0086]

[0087] As shown in Table 1, the sequential access index after each read access is the ratio of the updated consecutive access span to the number of fine-grained logic ranges 320 (8), and it increases from 0.125 to 0.875 as adjacent fine-grained logic ranges 320 are hit consecutively.

[0088] When the 8th fine-grained logic range 320 is subsequently hit, for example, if the relative logic block offset of this read access is 7100, the consecutive access span is accumulated to 8. The ratio of this span to the number of fine-grained logic ranges 320 (8) is 1.0, which reaches the predetermined upper limit. Even if the ratio calculated subsequently exceeds 1.0, the sequential access index remains at the predetermined upper limit of 1.0. A sequential access index of 1.0 indicates that a coarse-grained logic range 310 recently experienced a consecutive sequential access covering the entire fine-grained logic range 320.

[0089] Conversely, if the fine-grained logical range 320 hit by this read access is not the next fine-grained logical range 320 hit by the previous read access, for example, directly accessing the 7th fine-grained logical range 320 from the 4th fine-grained logical range 320, then the processor 211 will reset the consecutive access span to 1, and the sequential access index will drop back to 0.125.

[0090] Based on the above Figure 3 The two-level granularity structure shown, with coarse-grained logic range and fine-grained logic range, allows the memory controller 210 to use the coarse-grained logic range 310 as the unit for resident monitoring of read / write activity and idle time, and the fine-grained logic range 320 as the unit for determining continuous access span, sequential access indicators, and local access status.

[0091] Therefore, the resident access records used for cold data determination can be maintained primarily at the level of coarse-grained logical ranges 310, without needing to continuously maintain access count records for all fine-grained logical ranges 320 in the logical address space. Furthermore, by determining sequential access indicators based on consecutive accesses of adjacent fine-grained logical ranges 320, consecutive accesses caused by sequential scanning can be identified, reducing the possibility that a logical address range being sequentially read might be mistakenly determined to meet preset conditions.

[0092] Reference Figure 4A In one embodiment, Figure 4A This illustrates the recording method and time window rotation method of the write detector, i.e., the aforementioned correspondence. Figure 2 In the embodiment, the maintenance process of the write detector queried in step S220 includes steps S411 to S414. Steps S411 and S412 correspond to the write record executed in response to the write event, and steps S413 and S414 correspond to the expiration judgment and rotation of the time window. Figure 4A This illustrates the typical write event handling path when there are no unprocessed expired rotation events in the current time window. The process executes steps S411 to S413 sequentially, and terminates via step S414 or directly based on the judgment result of step S413. Alternatively, processor 211 can also independently execute steps S413 and S414 in response to timer or periodic maintenance events, ensuring timely rotation of the time window even when no write events occur for an extended period.

[0093] In step S411, the processor 211 detects a write event to a coarse-grained logical range. Specifically, the write event may be generated, for example, in response to a write command issued by the host system 10 to the storage device 20, and the logical address corresponding to the write command is located within the coarse-grained logical range. The processor 211 can calculate the identifier of the coarse-grained logical range to which the logical address belongs based on the logical address, the size of the coarse-grained logical range, and the logical address units. When the number of logical address units contained in the coarse-grained logical range is a power of 2, the processor 211 can also obtain the identifier by right-shifting the logical address by a predetermined number of bits, as described above. Figure 3 As illustrated in the embodiments.

[0094] Upon receiving a write event, if the processor 211 determines that the current time has passed the expiration point of the current time window and the corresponding window rotation has not yet been completed, the processor 211 can first execute the expiration judgment and rotation corresponding to steps S413 and S414, and then process the write event as a write event within the newly started current time window. This avoids write events arriving after the window boundary from being recorded in an already ended time window. Figure 4AThe sequence of steps shown corresponds to the case where there is no pending rotation as described above, or the time of the write event still falls within the current time window.

[0095] In step S412, the processor 211 records the identifier of the coarse-grained logical range in which the write occurred to the first filter in the write detector corresponding to the current time window. Specifically, in this embodiment, the write detector includes a first filter and a second filter, wherein the first filter corresponds to the current time window and the second filter corresponds to the previous time window. The first filter and the second filter can be stored in the buffer memory 214 and can both be initialized to empty when they are first used.

[0096] The first filter and the second filter are both Bloom filters, and each of the first filter and the second filter has a predetermined storage capacity. A Bloom filter is the aforementioned equivalent. Figure 1 This is one type of probabilistic filter in the embodiments. The predetermined storage capacity may be, for example, 16KB, the length of the current time window may be, for example, 24 hours, and the number of hash functions used to record or query the identifier of a coarse-grained logical range may be, for example, 6. The above capacity, window length, and number of hash functions are examples and can be selected based on the capacity of the logical address space, the number of coarse-grained logical ranges to be recorded, and the target false positive rate.

[0097] The processor 211 can input the identifiers of the coarse-grained logical ranges into multiple hash functions to obtain multiple positions in the bit array of the first filter, and set the bits of the multiple positions to 1. The Bloom filter does not need to directly store the complete identifiers of each coarse-grained logical range, but records multiple hash mapping results of the identifiers through the bit array, thereby recording the coarse-grained logical ranges that have been written within the current time window with a predetermined storage capacity.

[0098] In step S413, the processor 211 determines whether the current time window has expired. Whether the current time window has expired can be determined, for example, by whether the elapsed time since the start time of the current time window has reached the predetermined time window length. If the determination result of step S413 is negative, the recording processing of this write event is completed and the process ends; if the determination result of step S413 is positive, the process proceeds to step S414.

[0099] The determination in step S413 can be performed during the processing of a write event, or it can be performed independently by the processor 211 in response to a timer or periodic maintenance event. The latter does not require the prior execution of steps S411 and S412. Its purpose is to ensure that even if no write event occurs within a time window, step S414 can still be triggered after the time window expires, so as to prevent the time range represented by the first filter and the second filter from stopping due to the lack of write events.

[0100] In step S414, in response to the expiration of the current time window, the processor 211 updates the second filter in the detector corresponding to the previous time window with the content of the first filter, and clears the first filter. Specifically, the processor 211 can overwrite the original content of the second filter with the current content of the first filter, so that the second filter saves the write records within the just-ended time window, and the cleared first filter is used to record write events within the newly started current time window.

[0101] If multiple complete time windows have elapsed during window maintenance, the processor 211 can repeatedly perform the corresponding rotation based on the number of complete time windows elapsed. For example, if no write event is recorded within a complete time window, the empty window corresponds to an empty second filter after rotation; if no write event is recorded within two or more consecutive complete time windows, both the first and second filters can eventually be updated to empty. This prevents write records earlier than the previous time window from being retained due to a long period without write events.

[0102] When window rotation is executed based on the expiration time of the time window, the first filter stores the write records within the current time window, and the second filter stores the write records within the previous time window. The historical time span represented by the first and second filters is a complete previous time window plus the portion already elapsed in the current time window, and therefore can be between approximately one time window length and approximately two time window lengths. Any write event, from the time it is recorded in the first filter, can be queried through either the first or second filter for at least approximately one time window length, and at most for approximately two time window lengths.

[0103] Taking a 24-hour time window as an example, the historical time span corresponding to different query points of the write detector can be approximately 24 to 48 hours. Write records earlier than the previous time window are cleared as the window rotates. The query method for whether the coarse-grained logical range hits at least one of the first and second filters, and the method for determining whether the coarse-grained logical range has been recently written based on the query results, will be addressed in subsequent sections. Figure 4B The embodiments are described below.

[0104] Because Bloom filters use a probabilistic recording structure, they may falsely report a coarse-grained logical range that has not actually been recorded as a hit, resulting in false positives. If an identifier for a coarse-grained logical range has already been recorded in the first or second filter, and the corresponding record has not been cleared due to time window rotation, querying the identifier will not produce false negatives. In other words, Bloom filters will not miss recorded writes that are still within the coverage of the current or previous time window; write records earlier than the previous time window are cleared according to the predetermined window rotation mechanism and are not within the time range for recent write determination.

[0105] In terms of its application for cold data determination, a false positive result only conservatively classifies a small number of coarse-grained logical ranges that have not actually been recently written as cold data, thus temporarily excluding them from the current round of cold data determination. This prevents coarse-grained logical ranges that are still within the coverage of two time windows and have already been recorded from being classified as not recently written. Therefore, the false positives of the Bloom filter tend to make cold data determination more conservative, preventing recently written data from being mistakenly classified as cold data due to false positives.

[0106] Assuming the mapping results of each hash function are approximately uniform and independent, and the bit array of the Bloom filter is empty before the start of recording, the false positive rate of a single Bloom filter can be approximately calculated using the following formula:

[0107]

[0108] Where p is the false positive rate of a single Bloom filter, m is the number of bits in the bit array of the Bloom filter, k is the number of hash functions, and n is the number of different coarse-grained logical ranges recorded to the Bloom filter within a time window.

[0109] Since the processor 211 determines whether a coarse-grained logical range has been recently written to based on whether it hits at least one of the first and second filters, the false alarm probability of a joint query using two filters differs from the false positive rate of a single filter. If the false positive rates of the first and second filters are p_1 and p_2 respectively, the false alarm probability of the joint query is no greater than the sum of p_1 and p_2. When the two filters have the same false positive rate p and their false alarm events can be approximated as independent, the false alarm probability of the joint query can be approximately expressed as... When p is small, the false positive probability of the combined query is approximately 2p. Therefore, the following values ​​are the false positive rates of a single filter; the false positive probability of a combined query with two filters can be determined separately based on the above relationship.

[0110] As can be seen from the aforementioned approximate calculation method for the false positive rate, under the same conditions of the number of hash functions and the number of different coarse-grained logical ranges being recorded, the larger the predetermined storage capacity and the more bits in the bit group, the lower the false positive rate. Therefore, the predetermined storage capacity of a single filter can be selected based on the number of coarse-grained logical ranges divided into logical address spaces, the number of different coarse-grained logical ranges expected to be written within a time window, and the acceptable false positive rate.

[0111] Assuming each filter has a predetermined storage capacity of 16KB, and 1KB equals 1024 bytes, the corresponding bit depth m is 131072 bits, the number of hash functions k is 6, and the logical address space is as described above. Figure 2 The example shown is divided into 8192 coarse-grained logic ranges. If 4096 different coarse-grained logic ranges are written within a time window, i.e., n is 4096, substituting the above value into the false positive rate approximation calculation method, the false positive rate of a single filter is approximately 0.0025%.

[0112] Furthermore, to evaluate the capacity of a single filter under extreme write loads, assuming 8192 different coarse-grained logical range identifiers are recorded to the filter within a time window (n = 8192), the theoretical false positive rate calculated for a query identifier that has not been recorded is approximately 0.0935%, meaning the theoretical false positive rate of a single filter does not exceed 0.1%. It should be noted that when the logical address space includes only 8192 coarse-grained logical ranges and all coarse-grained logical ranges have been recorded, there are no actually unrecorded valid coarse-grained logical ranges available for querying. Therefore, 0.0935% primarily represents the theoretical load level of the filter when inserting 8192 different identifiers, rather than indicating that actual false positives will necessarily occur at this point.

[0113] If both the first and second filters are at the theoretical load levels mentioned above, and their respective false positive rates are approximately 0.0935%, then the upper bound of the false positive probability for a joint query using both filters is approximately 0.187%. If the false positive events of the two filters can be approximated as independent, the false positive probability of the joint query is approximately 0.1869%. False positives from the joint query will still only conservatively treat the corresponding coarse-grained logical range as recently written data, and will not be included in the current round of cold data judgment.

[0114] For capacity comparison, if the predetermined storage capacity of each filter is 8KB, and 1KB equals 1024 bytes, the corresponding bit depth m is 65536 bits, and the number of hash functions k remains 6. Then, under the theoretical load of recording 8192 different identifiers to a single filter, the false positive rate of a single filter is approximately 2.16%. Therefore, all other things being equal, the 16KB filter has a lower false positive rate than the 8KB filter. The above-mentioned capacity, number of hash functions, number of coarse-grained logical ranges, and false positive rate are examples and can be selected differently based on the capacity of the storage device 20, the write load, and the acceptable level of false positives.

[0115] In another embodiment, the predetermined storage capacity and time window length of the first filter and the second filter can also be selected based on the expected write load of the storage device 20. Specifically, as can be seen from the aforementioned approximate calculation method for the false positive rate, under the same conditions, the more different coarse-grained logic ranges are recorded within a single time window, the higher the false positive rate.

[0116] In application scenarios with frequent expected write events or long time windows, a large number of different coarse-grained logical ranges may be recorded within a single time window. Therefore, a larger predetermined storage capacity can be selected, or a shorter time window can be chosen to reduce the number of different coarse-grained logical ranges recorded within a single time window and maintain the false positive rate within a predetermined range. In application scenarios with sparse expected write events, a smaller predetermined storage capacity can be selected to reduce the occupation of the buffer memory 214, or a longer time window can be selected to reduce the number of window rotations.

[0117] The predetermined storage capacity and time window length can be determined, for example, during the design phase of storage device 20 based on the expected write load of the target application scenario and configured by firmware parameters. The above selection method is only an example; the first filter and the second filter can also adopt a predetermined fixed storage capacity and a fixed time window length.

[0118] Based on the above Figure 4A The recording method, time window rotation method, and Bloom filter capacity configuration shown in the diagram enable the memory controller 210 to record recently written coarse-grained logic ranges using two Bloom filters corresponding to the current and previous time windows. When a time window expires, the controller retains the write records from the two most recent time windows through rotation. Therefore, the memory controller 210 does not need to maintain write time information for each logic block individually, thus providing a basis for determining whether a coarse-grained logic range has been recently written to for cold data identification. False positives generated by the Bloom filter only temporarily delay the inclusion of some coarse-grained logic ranges that have not actually been recently written into the cold data identification process, thereby maintaining a conservative approach to recent write determination.

[0119] Reference Figure 4B In one embodiment, Figure 4B This illustrates how a query write detector determines whether a coarse-grained logical range has been recently written, as described above. Figure 2 In the embodiment, the query and judgment methods used in step S220 include steps S421 to S423. The query can be performed in the same manner for each coarse-grained logical range. Figure 4B Let's take one of the coarse-grained logical ranges as an example. The process starts by executing step S421, and then proceeds to step S422 or step S423 based on the result of step S421. After steps S422 and S423 are completed, the current query process ends.

[0120] In step S421, the processor 211 determines whether the currently received coarse-grained logical range of the query hits at least one of the first filter and the second filter. Specifically, the processor 211 uses the method described above. Figure 4A In the embodiments, the same multiple hash functions are used to record the identifier of the coarse-grained logical range, mapping the identifier of the currently queried coarse-grained logical range to multiple positions in the bit array of the first filter.

[0121] If all bits of the identifier mapped in the first filter are 1, the processor 211 determines that the coarse-grained logic range hits the first filter; if at least one bit of the multiple positions is 0, the processor 211 determines that the coarse-grained logic range does not hit the first filter. The processor 211 uses the same method to query the second filter to determine whether the coarse-grained logic range hits the second filter.

[0122] If the coarse-grained logic range hits at least one of the first filter and the second filter, the result of step S421 is yes, and the process proceeds to step S422. If the coarse-grained logic range does not hit either the first filter or the second filter, the result of step S421 is no, and the process proceeds to step S423. The queries of the first filter and the second filter can be executed sequentially or in parallel by the processor 211; this disclosure is not limited thereto.

[0123] In step S422, the processor 211 determines that the coarse-grained logic range has been recently written in response to the coarse-grained logic range hitting at least one of the first filter and the second filter. Hitting the first filter may indicate that the identifier of the coarse-grained logic range may have been recorded in the current time window, and hitting the second filter may indicate that the identifier of the coarse-grained logic range may have been recorded in the previous time window.

[0124] In the absence of false positives, a hit indicates that a recorded write event has occurred within the historical timeframe currently covered by both the first and second filters. The historical timeframe includes a complete previous time window and the portion already elapsed within the current time window, and can be, for example, approximately one to two time window lengths. For example, with a 24-hour time window, the historical timeframe could be approximately 24 to 48 hours.

[0125] Since the first and second filters can use Bloom filters, false positives can also occur. Coarse-grained logical ranges that were not actually recorded or written within the current or previous time window may be considered a hit because multiple positions mapped to their identifiers happen to be 1. A false positive simply means that the corresponding coarse-grained logical range is conservatively considered to have been recently written and is temporarily excluded from subsequent cold data checks in this round; it does not cause recently recorded writes to be ignored.

[0126] In the aforementioned correspondence Figure 2 In step S220 of the embodiment, coarse-grained logical ranges determined to have been recently written are not included in the subsequent cold data determination in this round. The processor 211 may continue to query another coarse-grained logical range to be processed, or re-query the coarse-grained logical range in a subsequent determination round.

[0127] In step S423, in response to the coarse-grained logic range failing to hit both the first and second filters, the processor 211 determines that the coarse-grained logic range has not been written to recently. Specifically, failing the first filter indicates that at least one bit is 0 in one of the multiple positions mapped to the identifier of the coarse-grained logic range in the first filter; failing the second filter indicates that at least one bit is 0 in one of the multiple positions mapped to the identifier in the second filter.

[0128] For coarse-grained logical ranges of identifiers that have been recorded to the first or second filter using the same multiple hash functions, and whose corresponding records have not yet been cleared due to time window rotation, the Bloom filter will not produce false negatives. Therefore, in each write event, the aforementioned correspondence will be applied. Figure 4A If the implementation is recorded normally, and neither the first nor the second filter is hit, it means that no write events have been recorded within the historical time range currently covered by the two filters.

[0129] It should be noted that if a write event occurs earlier than the previous time window, the corresponding record can be cleared as the time window rotates, and therefore no longer falls within the time range covered by the recent write judgment. Therefore, the recent non-write judgment made in step S423 refers to the time range covered by the first filter and the second filter at the current query time, rather than indicating that the coarse-grained logical range has never been written since the storage device 20 started operating.

[0130] In the aforementioned correspondence Figure 2 In step S220 of the embodiment, the coarse-grained logic range that has been determined not to have been written recently can be used as the target coarse-grained logic range, and the process proceeds to step S230 to further determine whether its read / write activity and idle time meet the preset conditions.

[0131] The queries in steps S421 to S423 can also be executed periodically while the target coarse-grained logical range is in a candidate state to help determine whether the target coarse-grained logical range has not been written to continuously. A single execution of steps S421 to S423 only indicates whether there are recorded writes within the historical time range jointly covered by the first filter and the second filter at the query time point, and cannot indicate that no writes have occurred within the entire predetermined stable period longer than the historical time range.

[0132] To confirm that the target coarse-grained logical range has not been written to after a predetermined stabilization period since the preset conditions were met, the processor 211 can combine periodic queries of the write detector during the candidate state period with immediate processing of write events that hit the target coarse-grained logical range. If a recent write to the target coarse-grained logical range is detected during the candidate state period, or a write event hitting the target coarse-grained logical range is directly detected, the processor 211 can remove the candidate state of the target coarse-grained logical range, preventing it from entering the cold data state. Thus, even if the predetermined stabilization period is longer than the historical time range covered by the first and second filters at a single query point, the continuous maintenance of the candidate state across multiple query points can still confirm that the target coarse-grained logical range has not experienced a write event that would cause it to exit the candidate state within the predetermined stabilization period.

[0133] Assume there are 6 hash functions. Processor 211 maps an identifier of a coarse-grained logical range to 6 positions in the bit array of the first filter, where at least one position has a bit of 0, therefore the coarse-grained logical range does not hit the first filter. Processor 211 then uses the same 6 hash functions to map the identifier to 6 positions in the bit array of the second filter, and all 6 positions have a bit of 1, therefore the coarse-grained logical range hits the second filter.

[0134] Since the coarse-grained logic range hits at least one of the first and second filters, the determination result of step S421 is yes, and the process proceeds to step S422, where the processor 211 determines that the coarse-grained logic range has been recently written. In the absence of false positives, this situation may correspond to, for example, a previously recorded write event occurring in the coarse-grained logic range within a previous time window, but no new recorded write event occurring in the current time window.

[0135] Conversely, if at least one bit in the six positions mapped to the coarse-grained logic range identifier in the first filter is 0, and at least one bit in the six positions mapped to the second filter is also 0, then the coarse-grained logic range fails to hit either the first or second filter. If the result of step S421 is negative, the process proceeds to step S423, where the processor 211 determines that the coarse-grained logic range has not been written to recently.

[0136] Based on the above Figure 4B The query and judgment process shown involves the memory controller querying two Bloom filters corresponding to the current and previous time windows using the same multiple hash functions. This allows it to obtain a judgment result indicating whether a coarse-grained logical range has been recently written to, and then compare it with... Figure 4A The write records and time window rotation shown together constitute the operation mode of the write detector. Therefore, without maintaining write time information for each logic block separately, coarse-grained logic ranges that may have been written to within the current or previous time window can be temporarily excluded from cold data determination. False positives generated by the Bloom filter only make the cold data determination more conservative, thereby reducing the possibility of classifying recently written data as cold data.

[0137] Reference Figure 5 In one embodiment, Figure 5 This illustrates the method for analyzing whether hotspots exist within multiple fine-grained logic ranges corresponding to the coarse-grained logic range of the target, i.e., the aforementioned correspondence. Figure 2 One specific implementation of step S240 in the embodiments. Figure 5 The illustrated process includes steps S510 to S560, along with an explanation of the carrier structure, capacity configuration, observation period, and hotspot criteria for fine-grained activity recording. The process begins with step S510, proceeds to step S520 after the corresponding observation period, and then enters step S540 or S550 based on the judgment in step S530. After step S540 or S550 is completed, the process proceeds to step S560. If step S560 determines that the entire fine-grained logic range has not yet been processed, the process returns to step S520 to process the next fine-grained logic range; if the entire fine-grained logic range has been processed, the process ends.

[0138] In step S510, processor 211 enables fine-grained activity recording for the target coarse-grained logical range to record the access status of each of the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range. At the start of an observation period, processor 211 can clear old entries corresponding to the target coarse-grained logical range in previous observation periods, or reset the write and read counts in the corresponding entries, so that the counts used for this hotspot determination correspond to the current observation period.

[0139] Fine-grained activity records are stored in a record table. The record table has a predetermined capacity and is shared by multiple coarse-grained logical ranges where fine-grained activity recording is enabled. Each entry in the record table includes at least the identifier of the corresponding coarse-grained logical range and the identifier of the corresponding fine-grained logical range. The record table can be the aforementioned corresponding... Figure 1 In the embodiment, a fine-grained activity record table is stored in buffer memory 214.

[0140] During the observation period, in response to a read or write access to a fine-grained logic range within the target coarse-grained logic range, the processor 211 queries the record table for entries corresponding to the coarse-grained and fine-grained logic ranges. If a corresponding entry already exists in the record table, the processor 211 updates the read or write count in the entry; if no corresponding entry exists, the processor 211 allocates an entry, records the identifier of the corresponding coarse-grained logic range and the identifier of the fine-grained logic range, and initializes the corresponding read or write count based on this access.

[0141] Each entry in the record table may also include write and read counts for the corresponding fine-grained logical range within the current observation period. Entries may also include recent access information for managing entries, or this information may be maintained in a replacement management structure associated with the record table. The predetermined capacity of the record table may be, for example, 1024 entries, each entry may be, for example, 8 bytes, thus occupying approximately 8KB; the record table may also include, for example, 512 entries, occupying approximately 4KB. In the embodiment where each entry is 8 bytes, the identifiers of the coarse-grained logical range, the fine-grained logical range, the write count, and the read count may be stored using fixed-length fields or compact encoding, depending on the required number of bits. The specific field width and arrangement may be adjusted according to the size of the logical address space, the granularity configuration, and the counting range.

[0142] During the current observation period, processor 211 can mark entries belonging to the observation period and with valid access counts as non-replaceable. Based on recent access information, processor 211 can prioritize the reclamation of entries whose observation period has ended, whose corresponding coarse-grained logical range has exited the candidate state, or whose counts have been processed. This prevents an entry still within the current observation period from losing its accumulated write or read counts due to replacement.

[0143] Because the record table is shared by multiple coarse-grained logical ranges that have enabled fine-grained activity recording, the processor 211 does not need to configure a separate record table with a fixed maximum capacity for each coarse-grained logical range entering the candidate state, nor does it need to maintain a resident access count for all fine-grained logical ranges in the logical address space. The target coarse-grained logical range is in the aforementioned corresponding... Figure 2 In step S230 of the embodiment, when entering the candidate state, the processor 211 can start an observation period for it and enable the corresponding fine-grained activity recording; when the target coarse-grained logical range exits the candidate state, the processor 211 can reclaim the entry corresponding to the target coarse-grained logical range.

[0144] If the target coarse-grained logical range remains in a candidate state after completing an observation period and needs to continue hotspot observation in subsequent decision rounds, the processor 211 can reclaim the entries corresponding to the target coarse-grained logical range in the previous observation period or reset the write count and read count in the corresponding entries before starting the next observation period. Thus, the access counts used for each hotspot determination can correspond to their respective observation periods, instead of indefinitely accumulating the access counts from previous observation periods into subsequent observation periods.

[0145] In step S520, the processor 211 processes each of the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range one by one. Each round of processing may select one of the unprocessed fine-grained logic ranges as the current processing target. Steps S520 to S560 may be executed, for example, after the current observation period ends. The observation period is used to observe local access within the target coarse-grained logic range and may be, for example, 24 to 48 hours. The specific length of the observation period can be selected based on the access mode of the storage device 20, a predetermined read threshold, and the required hotspot detection sensitivity.

[0146] In step S530, the processor 211 determines whether the write count of the currently processed fine-grained logic range during the observation period is greater than zero, or whether its read count has reached a predetermined read threshold. The write count and read count can be recorded by the corresponding entries of the fine-grained logic range in the record table. If no entries have been assigned to the fine-grained logic range during the current observation period, and no entries have been replaced or lost due to insufficient capacity, it indicates that the fine-grained logic range has not been accessed during the current observation period, and its write count and read count can be considered zero.

[0147] If a fine-grained logical range previously had a corresponding entry during the current observation period, but the entry could not be fully preserved due to capacity management, the processor 211 will not simply treat the fine-grained logical range as having zero write and read counts. Instead, it will process it according to the preservation strategy described later to avoid missing hotspots due to lost access records. The predetermined read threshold can be selected based on the access mode, the length of the observation period, and the definition of read hotspots.

[0148] If the judgment result of step S530 is yes, that is, the write count of the currently processed fine-grained logic range during the observation period is greater than zero, or its read count reaches the predetermined read threshold, then the process proceeds to step S540. If the judgment result of step S530 is no, that is, the write count of the fine-grained logic range during the observation period is zero, and its read count has not reached the predetermined read threshold, then the process proceeds to step S550.

[0149] In step S540, processor 211 determines the currently processed fine-grained logic range as a hotspot. In step S550, processor 211 determines the currently processed fine-grained logic range as a non-hotspot. The processing in steps S520 to S560 is used to determine a fine-grained logic range as a hotspot for each of the multiple fine-grained logic ranges in response to the fine-grained activity record recording a write count greater than zero or a read count reaching a predetermined read threshold during the observation period.

[0150] A write count greater than zero indicates that the corresponding fine-grained logical range has been written to at least once during the observation period. A read count reaching a predetermined read threshold indicates that the fine-grained logical range has experienced read accesses reaching the predetermined read threshold during the observation period. Either condition being true indicates that the data within the fine-grained logical range still has local access activity. Fine-grained logical ranges determined to be non-hotspots are those for which no writes were recorded during the current observation period, and whose read count did not reach the predetermined read threshold.

[0151] It should be noted that writes occurring in the candidate state can also be handled according to subsequent correspondences. Figure 6 In this embodiment, the target coarse-grained logical range is removed from the candidate state. If a write event has already caused the target coarse-grained logical range to be removed from the candidate state, the target coarse-grained logical range will no longer enter the cold data state based on the current hotspot detection result. The hotspot criterion of a write count greater than zero and the state exit caused by writing in the candidate state are conservative mechanisms to prevent corresponding data from being judged as cold data from both the local activity record and state transition levels; the two can be used in combination.

[0152] In step S560, processor 211 determines whether all fine-grained logic ranges corresponding to the target coarse-grained logic range have been processed. If the determination result of step S560 is negative, the process returns to step S520, and processor 211 selects and processes the next unprocessed fine-grained logic range; if the determination result of step S560 is positive, the current hotspot detection process ends.

[0153] Through the above-described step-by-step processing, processor 211 determines, based on the fine-grained activity records, whether there are hot spots among the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range. If any fine-grained logic range is determined to be a hot spot in step S540, it indicates that a hot spot exists among the multiple fine-grained logic ranges. Only when none of the multiple fine-grained logic ranges are determined to be hot spots, and other cold data determination conditions are also met, can the data within the target coarse-grained logic range be processed through the aforementioned corresponding... Figure 2 In the embodiment, step S260 is determined to be cold data. If at least one hot spot exists among multiple fine-grained logic ranges, the target coarse-grained logic range is not determined to store cold data in this round. The calculation method of the cold score, the hysteresis mechanism composed of the entry threshold and the exit threshold, and the transition between cold determination states will be discussed in subsequent corresponding... Figure 6 The embodiments are described below.

[0154] Assume a target coarse-grained logic range corresponds to 8 fine-grained logic ranges, the observation period is 48 hours, and the predetermined read threshold is 5 times. At the end of the observation period, the processor 211 checks the write count and read count of each fine-grained logic range during the current observation period through steps S520 to S560.

[0155] For example, the write count of the first fine-grained logic range is 1, therefore its write count is greater than zero, and it is determined to be a hotspot in step S540. The write count of the second fine-grained logic range is 0 and its read count is 3, therefore its read count has not reached the predetermined read threshold, and it is determined to be a non-hotspot in step S550. The write count of the third fine-grained logic range is 0 and its read count is 6, therefore its read count has reached the predetermined read threshold, and it is determined to be a hotspot in step S540. The write counts of the remaining fine-grained logic ranges are all 0, and their read counts have not reached the predetermined read threshold, therefore they are all determined to be non-hotspots in step S550.

[0156] Since some of the fine-grained logical ranges corresponding to the target coarse-grained logical range are identified as hotspots, the target coarse-grained logical range is not identified as cold data in this round. Conversely, if the write counts of all eight fine-grained logical ranges are 0 and the read counts have not reached the predetermined read threshold, then there are no hotspots among the multiple fine-grained logical ranges, and the target coarse-grained logical range can be identified as cold data when other cold data identification conditions are also met.

[0157] In another embodiment, when the capacity of the record table is insufficient and there are no entries that have ended or can be directly recycled, the processor 211 may adopt a method of delaying the activation of fine-grained activity recording or conservatively marking the observation results to avoid the loss of the write count and read count accumulated during the current observation period due to the replacement of entries.

[0158] As a handling method, processor 211 may delay enabling fine-grained activity recording for newly entered coarse-grained logical ranges until an entry is available for allocation in the recording table. When this method is used, the observation period for newly entered coarse-grained logical ranges may be calculated from the time the fine-grained activity recording is actually enabled, so that the coarse-grained logical range is not determined to be stored cold data until a complete observation period is completed.

[0159] As an alternative approach, when an entry still within the current observation period must be replaced, processor 211 can record an incomplete observation flag or a conservative hotspot flag for the target coarse-grained logical range to which the entry belongs before replacing the entry. During subsequent execution of steps S520 to S560, processor 211, in response to the incomplete observation flag or conservative hotspot flag, treats the target coarse-grained logical range as having a hotspot, or directly prevents the target coarse-grained logical range from entering the cold data state in this round.

[0160] The aforementioned delayed activation and conservative marking methods both tend to be conservative in addressing the consequences of insufficient capacity. This means that the point at which a coarse-grained logical range is determined to be cold data may be delayed, rather than treating already accessed fine-grained logical ranges as unaccessed ranges simply because active records have been replaced. These two methods can be used individually or in combination, and this disclosure is not limited thereto.

[0161] Based on the above Figure 5 The hotspot detection process shown describes how the memory controller 210 can carry the corresponding fine-grained activity records in a record table that is limited in capacity and shared by multiple coarse-grained logic ranges with enabled fine-grained activity records. After the observation period ends, it determines whether each fine-grained logic range is a hotspot based on the write count and read count.

[0162] Therefore, without configuring resident access count records according to the total number of all fine-grained logical ranges in the logical address space, the storage capacity occupied by fine-grained activity records can be limited to a predetermined capacity range. Furthermore, the target coarse-grained logical range is only allowed to enter subsequent cold data determination if none of the fine-grained logical ranges corresponding to it are determined to be hotspots, thereby reducing the possibility of classifying data containing localized access activity as cold data as a whole.

[0163] Reference Figure 6In one embodiment, Figure 6 This illustrates the transitions between cold decision states. Cold decision states include the non-cold state ST61, the candidate state ST62, and the cold data state ST63. Figure 6 The transitions between cold decision states, A61 to A65, are also shown. This embodiment also describes the calculation method of the cold score and the hysteresis mechanism consisting of an entry threshold and an exit threshold. The processor 211 can maintain a cold score state record for each coarse-grained logic range and store the current cold decision state of each coarse-grained logic range and the information required for cold score calculation in the buffer memory 214. When performing cold data decision, the processor 211 can calculate or update the cold score of the corresponding coarse-grained logic range based on the information.

[0164] The non-cold state ST61 indicates that the coarse-grained logical range is neither in a candidate state nor in a cold data state. Coarse-grained logical ranges in the non-cold state ST61 may include those that have not yet met preset conditions, as well as those that have been regressed from the candidate state ST62 or the cold data state ST63. The candidate state ST62 indicates that the coarse-grained logical range has not been written to recently, and its read / write activity and inactivity time have met preset conditions. The processor 211 is performing further confirmation of the coarse-grained logical range for a predetermined stabilization time and for local hot spots. The cold data state ST63 indicates that the data within the coarse-grained logical range has met the condition that it has not been written to after a predetermined stabilization time since meeting the preset conditions, and that multiple fine-grained logical ranges within it have not been identified as hot spots, and has been identified as cold data.

[0165] In this embodiment, the preset conditions include: reaching an entry threshold based on a cold score determined by weighting the inactivity time and read / write activity with corresponding weights, wherein a longer inactivity time results in a higher cold score, and higher read / write activity results in a lower cold score. The processor 211 can also process the aforementioned corresponding... Figure 3 In the embodiments, the sequential access metric is incorporated as a negative factor into the cold score to reduce the cold score of the coarse-grained logic range where sequential scans are taking place.

[0166] The cold rating can be determined using the following formula:

[0167]

[0168] in, For cold scoring within a coarse-grained logic range, The scoring value is determined based on the tier to which the inactivity period of the coarse-grained logical range belongs. R is the current read activity statistic for the coarse-grained logical range, and W is the current write activity statistic for the coarse-grained logical range. For the aforementioned correspondence Figure 3In the embodiments, the sequential access index, α, β, γ, and δ, are the weights corresponding to the idle time, read activity statistics, write activity statistics, and sequential access index, respectively. The read activity statistics R and write activity statistics W are the current values ​​obtained according to the read activity statistics update formula and write activity statistics update formula described later, respectively.

[0169] In the implementation where the read activity statistic R and write activity statistic W are encoded using fixed-point coding, the R and W used in the cold score calculation can be values ​​obtained by interpreting the corresponding fixed-point coded values ​​according to a predetermined scaling relationship. For example, the corresponding fixed-point code may include an integer part and a fractional part, and its specific bit allocation and scaling ratio can be configured according to the numerical range and precision required for the cold score.

[0170] The weights α, β, γ, and δ can be configured based on the access pattern and cold data judgment sensitivity of the storage device 20, and can be, for example, 4, 120, 500, and 5 respectively. The above cold scoring formula and weight values ​​are examples. In other embodiments, the processor 211 may also employ other weighting methods that can increase the cold score when the idle time increases and decrease the cold score when the read / write activity or sequential access index increases.

[0171] The scoring values ​​for the tiered resting time are shown in Table 2. Table 2 shows a set of examples with tier numbers 0 to 7. The specific boundaries of each time interval can be determined by the processor 211 according to pre-set timing rules. The processor 211 can convert each time interval into a uniform timing unit and determine the scoring value based on the corresponding tier boundaries.

[0172] Table 2

[0173]

[0174] As shown in Table 2, the longer the write-free duration, the higher the score. The processor 211 can determine the current class of each coarse-grained logical range based on the elapsed time since the most recent write event. As the write-free duration increases, the processor 211 can update the coarse-grained logical range to the class corresponding to the longer write-free duration; when a write occurs in the coarse-grained logical range, the processor 211 recalculates its write-free duration and updates the class to which the idle time belongs to the corresponding starting class.

[0175] In the implementation where the resting time is represented by a 4-digit value, the 4-digit value can provide 16 different codes. Table 2 only shows one set of scoring methods for the tier numbers 0 to 7. Other codes can be reserved or used to represent other unwritten duration intervals and their corresponding scores. This embodiment does not limit the specific time intervals and scores corresponding to other codes.

[0176] The longer the settling time, the better. The higher the corresponding score, the greater the positive contribution to the cold score. Higher read activity statistics (R) and write activity statistics (W) result in a greater negative contribution to the cold score. (Sequential access metrics) The cold score is also included in the negative terms. Therefore, when a coarse-grained logic range undergoes a sequential scan that spans multiple adjacent fine-grained logic ranges, its cold score decreases, thereby reducing the likelihood that the coarse-grained logic range will meet the preset conditions during the sequential scan.

[0177] The time intervals, scores, and cold score weights shown in Table 2 are adjustable examples and can be selected based on the target application scenario of storage device 20, access load, and required cold data judgment sensitivity. The number of idle time intervals, time boundaries, and scores can also be configured in other ways, and this disclosure is not limited to the examples shown in Table 2.

[0178] Processor 211 can periodically calculate or update the cold scores of each coarse-grained logic range. To reduce the processing burden caused by traversing the entire logic address space in one operation, processor 211 can select a portion of multiple coarse-grained logic ranges for processing in each calculation cycle, with the processing proportion each time being, for example, 1% to 2% of the total coarse-grained logic ranges. Processor 211 can select different coarse-grained logic ranges in turn in multiple calculation cycles based on the scan cursor, round information, or a predetermined traversal order, so that each coarse-grained logic range can be covered in multiple calculation cycles. The above-mentioned processing proportion of 1% to 2% is only an example and can be adjusted according to the available processing resources of processor 211, the cold score update frequency, and the total number of coarse-grained logic ranges.

[0179] Furthermore, read / write activity includes write activity statistics and read activity statistics. Write activity statistics are updated in response to write events to a coarse-grained logical range, and read activity statistics are updated with a predetermined sampling probability in response to read events to a coarse-grained logical range. Each of the write activity statistics and read activity statistics accumulates the contribution of the current event upon update, and the previously accumulated portion decays by a predetermined proportion.

[0180] Specifically, the predetermined sampling probability can be, for example, approximately 1 / 64, meaning that the processor 211 updates the read activity statistics value once every 64 read events on average, to reduce the statistical overhead on the read path. The write activity statistics value and the read activity statistics value can, for example, each use 8-bit fixed-point encoding, where a portion of the bits can be used to represent the decimal part. The number of decimal places and scaling of the fixed-point encoding can be configured according to the numerical range required for cold score calculation.

[0181] Active statistics can be updated using, for example, the following formula:

[0182]

[0183] in, This represents the write activity statistics following this write event. This represents the write activity statistics prior to this write event. This is the predetermined write activity decay parameter. The accumulated 1s in the formula represent the contribution of this write event. This indicates the amount of decay deducted from the previously accumulated portion during this update.

[0184] Read activity statistics can be updated, for example, according to the following formula:

[0185]

[0186] in, These are the read activity statistics following the occurrence of the sampled read events. This represents the read activity statistics prior to the occurrence of the sampled read event. This is the predetermined read activity decay parameter. The accumulated 1 in the formula represents the contribution of the current sampled read event. This indicates the amount of decay deducted from the previously accumulated portion during this update.

[0187] In implementations that employ integer arithmetic or fixed-point arithmetic, and This can be achieved by shifting the corresponding values ​​to the right. Position and Bit acquisition. Parameters and parameters The value can be selected based on the response speed to changes in read / write activity. Parameter or parameter The larger the value, the smaller the percentage deducted from the previously accumulated portion with each update, and the longer the contribution of historical events is retained.

[0188] The above formulas describe the event-triggered updates of write activity statistics and read activity statistics when a write event or a sampled read event occurs. In this embodiment, the decay in the formula is performed as the corresponding statistics are updated, and does not mean that it will automatically decay over time separately when the corresponding event does not occur.

[0189] Furthermore, the cold scoring status record for each coarse-grained logic range can, for example, adopt a compact 4-byte structure. The determination status representing the non-cold state ST61, candidate state ST62, and cold data state ST63 can, for example, occupy 2 bits, with the remaining values ​​in those 2 bits reserved; write activity statistics and read activity statistics can each occupy 8 bits; the tier to which the idle time belongs can, for example, occupy 4 bits; the remaining 10 bits can be reserved. The above field widths and arrangements are examples and can be adjusted according to the resource configuration and numerical precision requirements of the memory controller 210.

[0190] As indicated by arrow A61, the coarse-grained logic range in the non-cold state ST61, if it has not been recently written to and the cold score reaches the entry threshold, migrates to the candidate state ST62. The entry threshold could be, for example, 100. This migration corresponds to the aforementioned... Figure 2 The embodiments of steps S220 and S230. The processor 211 may also, when the coarse-grained logic range transitions to candidate state ST62, record the point in time when the coarse-grained logic range meets preset conditions, using this as the starting point for a predetermined stable duration, and enable the aforementioned corresponding function for the coarse-grained logic range. Figure 5 Fine-grained activity recording in the embodiments.

[0191] As indicated by arrow A62, a target coarse-grained logic range in candidate state ST62, if it has not been written to after a predetermined stabilization period since meeting preset conditions, and none of its multiple fine-grained logic ranges have been identified as hotspots, migrates to cold data state ST63. The predetermined stabilization period can be, for example, 48 to 72 hours. This migration corresponds to the aforementioned... Figure 2 Steps S250 and S260 in the embodiments.

[0192] As indicated by arrow A63, processor 211, in response to a previously satisfied coarse-grained logic range having a cold score below an exit threshold, re-determines the coarse-grained logic range as not satisfying the preset conditions, where the entry threshold is higher than the exit threshold. The exit threshold could be, for example, 60. When the cold score of the coarse-grained logic range in candidate state ST62 is lower than the exit threshold, it transitions to non-cold state ST61 via arrow A63.

[0193] When a write occurs to a coarse-grained logic range in candidate state ST62, the coarse-grained logic range no longer meets the prerequisite of not being recently written to. The processor 211 removes it from the candidate state, causing it to migrate to the non-cold state ST61 in the retreat direction indicated by arrow A63. The write event also updates the write activity statistics according to the aforementioned formula and recalculates the inactivity time. Figure 6 Arrow A63 uniformly indicates the migration direction from candidate state ST62 back to non-cold state ST61.

[0194] The entry threshold being higher than the exit threshold constitutes a hysteresis mechanism. The coarse-grained logic range in the non-cold state ST61 migrates to the candidate state ST62 only when the cold score reaches the entry threshold; the coarse-grained logic range already in the candidate state ST62 only migrates to the non-cold state ST61 due to the change in the cold score when it falls below the exit threshold. Therefore, when the cold score is not lower than the exit threshold but lower than the entry threshold, changes in the cold score alone will not trigger a round-trip migration between the non-cold state ST61 and the candidate state ST62, thereby reducing the repeated entry and exit of the coarse-grained logic range into and out of the candidate state near the threshold.

[0195] If the coarse-grained logic range of candidate state ST62 is not lower than the exit threshold, it can still be migrated to cold data state ST63 via arrow A62 if the other conditions are met.

[0196] In one scenario, a coarse-grained logic range is not written to during candidate state ST62 but is continuously read. If the continuous reading causes the read count of one of the fine-grained logic ranges to reach a predetermined read threshold and be identified as a hotspot, and the cold score of the coarse-grained logic range is still not lower than the exit threshold, then the coarse-grained logic range does not meet the conditions for migrating to the cold data state ST63, but it also does not yet meet the conditions for migrating to the non-cold state ST61 via arrow A63. Therefore, it remains in candidate state ST62 and can be judged again in subsequent observation periods or judgment rounds. If the continuous reading also causes the cold score of the coarse-grained logic range to fall below the exit threshold, then the coarse-grained logic range is migrated to the non-cold state ST61 via arrow A63.

[0197] The coarse-grained logic range of ST63, which is in the cold data state, can be de-identified as cold data via arrow A64 or arrow A65 and migrated to the non-cold state ST61.

[0198] As indicated by arrow A64, in response to a write event hitting a coarse-grained logic range storing cold data, processor 211 removes the cold data determination for the data within the coarse-grained logic range and migrates the coarse-grained logic range to a non-cold state ST61. This path allows processor 211 to immediately remove the cold data determination when a write event occurs.

[0199] As indicated by arrow A65, processor 211 periodically checks whether a coarse-grained logical range storing cold data has been recently written to, and declassifies the data within that recently written coarse-grained logical range as cold data. Processor 211 may employ the aforementioned corresponding... Figure 4B In the embodiments, the query method performs periodic checks, and can check a portion of the coarse-grained logic range of ST63 in the cold data state in each check cycle, and alternately cover each coarse-grained logic range of ST63 in the cold data state in multiple check cycles.

[0200] The immediate release path indicated by arrow A64 and the periodic check release path indicated by arrow A65 complement each other. The write event processing path can immediately release the cold data determination when a write occurs, while the periodic check path can reconfirm, based on the write detector, whether there are recent write records in the coarse-grained logical range of ST63 in the cold data state.

[0201] The coarse-grained logic range that previously met the preset conditions may also include the coarse-grained logic range in the cold data state ST63. When the cold score of the coarse-grained logic range in the cold data state ST63 is lower than the exit threshold, the processor 211 can re-determine that the coarse-grained logic range does not meet the preset conditions, release its cold data determination, and migrate it to the non-cold state ST61. This migration is an alternative release condition to the write event immediate release path indicated by arrow A64 and the periodic check release path indicated by arrow A65. For the sake of simplicity, Figure 6 The arrows indicating that the coarse-grained logic range in the cold data state ST63 migrates to the non-cold state ST61 due to the cold score falling below the exit threshold are not shown separately.

[0202] The following numerical example illustrates the cold scoring and hysteresis mechanism. Assume weights α, β, γ, and δ are 4, 120, 500, and 5 respectively, with an entry threshold of 100 and an exit threshold of 60. A coarse-grained logical range of write-free duration falls into category 5 in Table 2, and the score is... The value is 45; the read activity statistic R, interpreted according to the predetermined fixed-point scaling relationship, is 0.1, the write activity statistic W is 0, and the sequential access metric is... It is 0.125.

[0203] Substituting the above values ​​into the cold scoring formula, the cold score for the coarse-grained logic range is 4 multiplied by 45, minus 120 multiplied by 0.1, minus 500 multiplied by 0, and then minus 5 multiplied by 0.125, which is 180 minus 12 and then minus 0.625, resulting in a cold score of 167.375, which can be approximated as 167.4. The cold score reaches the entry threshold of 100. Therefore, provided the coarse-grained logic range has not been written to recently, it migrates from the non-cold state ST61 to the candidate state ST62 via arrow A61.

[0204] Subsequently, assuming the coarse-grained logic range is continuously read, the read activity statistic R, interpreted according to the predetermined fixed-point scaling relationship, increases to 1, while other parameters remain unchanged. At this point, the cold score is 180 minus 120 minus 0.625, resulting in a cold score of 59.375, which can be approximated as 59.4. The cold score is below the exit threshold 60; therefore, the coarse-grained logic range migrates from candidate state ST62 to non-cold state ST61 via arrow A63.

[0205] Conversely, if the read / write activity of the coarse-grained logical range during the candidate state ST62 does not cause its cold score to fall below the exit threshold, and the coarse-grained logical range has not been written to after a predetermined stable period since the preset conditions are met, and none of its multiple fine-grained logical ranges are identified as hotspots, then the coarse-grained logical range will be migrated to the cold data state ST63 via arrow A62.

[0206] Based on the above Figure 6 As shown in the state transition diagram, the memory controller 210 can reduce the repeated state changes of the coarse-grained logic range due to the fluctuation of cold scores near the threshold through a hysteresis mechanism composed of entry and exit thresholds. The transition from candidate state ST62 to cold data state ST63 also needs to undergo further confirmation through a predetermined stabilization period and local hot spot judgment, so that the cold data determination is completed only when multiple conditions are met.

[0207] In addition, the coarse-grained logical range of candidates ST62 or cold data ST63 can be migrated to non-cold state ST61 in response to write events, periodic recent write checks, or when the cold score is lower than the exit threshold. This removes the candidate state or cold data determination when the corresponding data is accessed again, reducing the possibility that data that is still in use will continue to be determined as cold data.

[0208] Reference Figure 7 In one embodiment, Figure 7 This diagram illustrates the interaction timing between storage device 20 and host system 10 regarding cold alert information. The participants in the interaction timing include host system 10, processor 211 of memory controller 210, and memory module 220, and sequentially include stages S71, S72, S73, and S74. Stage S71 is the cold alert export stage, stage S72 is the cold alert retrieval stage, stage S73 is the plaintext location and reading stage, and stage S74 is the compressed data return and write-back stage. The interaction timing is as described above. Figure 1 In this embodiment, the export and acquisition of cold prompt information, and the process of the host system 10 performing compression and write-back based on the cold prompt information are presented in one way.

[0209] In stage S71, processor 211 performs the export of cold hint information. In step S711, processor 211 exports the coarse-grained logical range of stored cold data as cold hint information, so that host system 10 can compress and write back the target cold data before encryption based on the cold hint information. The cold hint information is maintained in a versioned incremental manner and includes round information and content version information.

[0210] Specifically, processor 211 will be via the aforementioned corresponding Figure 6 In this embodiment, a coarse-grained logical range determined to store cold data is recorded in cold alert information. The cold alert information can be stored in buffer memory 214. Processor 211 can update the content version information when a coarse-grained logical range is newly determined to store cold data, a previous cold data determination is revoked, or the content of the cold alert record undergoes other changes. Processor 211 can also update the round information as the cold data determination round or the cold alert derivation round progresses.

[0211] The round information identifies the cold data judgment round or cold prompt export round corresponding to the generation of the cold prompt information, while the content version information identifies the version of the cold prompt information content. The content version information can be updated only when the content of the cold prompt information changes. Therefore, even if the round information changes as the cold data judgment round or cold prompt export round progresses, the content version information can remain unchanged as long as the content of the cold prompt information does not change.

[0212] The host system 10 can save previously acquired round information and content version information, and compare newly acquired round information and content version information with the saved information. If the content version information has not changed, the host system 10 can continue to use the previously acquired cold suggestion records without having to repeatedly acquire unchanged cold suggestion records. If the content version information has changed, the host system 10 can acquire the cold suggestion record corresponding to the new content version and update the cold suggestion information saved on the host system 10 side with the acquired cold suggestion record. Thus, cold suggestion information can be acquired in a version-aware incremental manner based on round information and content version information. The field structure of the cold suggestion information will be discussed later. Figure 8 The embodiments are described below.

[0213] In step S72, the host system 10 retrieves the cold alert information. In step S721, the host system 10 sends a read buffer command to the processor 211 to obtain the cold alert header information and the cold alert record. In step S722, in response to the read buffer command, the processor 211 returns the corresponding cold alert information to the host system 10.

[0214] The read buffer command can be, for example, the READ BUFFER command of the SCSI protocol, with an opcode of, for example, 0x3C, and can be used on storage devices 20 employing a UFS interface. The read buffer command can use a vendor-defined pattern and distinguish cold message header information from cold message records using different buffer identifiers.

[0215] For example, buffer identifier 0x90 can be used to retrieve cold message header information, and buffer identifier 0x91 can be used to retrieve cold message records. Buffer identifiers 0x90 and 0x91 are only example values, and the actual values ​​can be agreed upon in advance by the host system 10 and the storage device 20.

[0216] The host system 10 can first send a read buffer command with the buffer identifier corresponding to the cold alert header information, and obtain the cold alert header information including round information, content version information, granularity parameters, and the number of valid records. The host system 10 determines whether it is necessary to further obtain cold alert records based on the round information and content version information, and can determine the amount of data of the cold alert records to be read based on the number of valid records and the length of each cold alert record.

[0217] When host system 10 needs to obtain cold alert records, it can send a read buffer command using the buffer identifier corresponding to the cold alert record. If the amount of data allowed to be read in a single read buffer command is insufficient to obtain all cold alert records, host system 10 can obtain cold alert records page by page through multiple read buffer commands.

[0218] In one implementation, the host system 10 can specify the starting position of the current read using the buffer offset in the read buffer command, and specify the amount of data requested using the allocated length. The processor 211 retrieves the corresponding portion of the cold hint record from the cold hint information based on the buffer offset and the allocated length, and returns the cold hint record to the host system 10. The host system 10 can sequentially change the buffer offset until all cold hint records indicated by the number of valid records are retrieved.

[0219] Paged fetching means that host system 10 can retrieve different parts of the cold alert record through multiple read buffer commands. Versioned incremental fetching means that host system 10 can determine whether the content of the cold alert information has changed based on round information and content version information, and avoid repeatedly fetching the cold alert record when the content has not changed. The amount of data read in a single session can be, for example, tens of bytes to thousands of bytes, and the specific amount of data can be determined based on the configuration of host system 10, storage device 20, and transmission protocol.

[0220] In stage S73, the host system 10 locates and reads the plaintext data corresponding to the target cold data. In step S731, the host system 10 determines the logical address range of the target cold data based on the cold hint information. Specifically, the host system 10 can calculate the starting position and range length of the target cold data based on the granularity parameter indicating the size of the coarse-grained logical range in the cold hint header information, and the starting range index and the number of consecutive ranges recorded in the cold hint record.

[0221] The starting byte offset of the target cold data can be determined by multiplying the starting range index by the granularity parameter, and the byte length of the target cold data can be determined by multiplying the number of consecutive ranges by the granularity parameter. When the logical address is represented by a logical block address, the host system 10 can also convert the starting byte offset and byte length into the starting logical block address and the number of logical blocks, respectively, based on the number of bytes in each logical block.

[0222] In step S732, the host system 10 sends a request to the processor 211 to read the target cold data based on the determined logical address range. In step S733, the processor 211, in response to the read request, reads the target cold data from the memory module 220. In step S734, the memory module 220 returns the read target cold data to the processor 211. In step S735, the processor 211 returns the read target cold data to the host system 10.

[0223] In step S736, the host system 10 obtains the plaintext data corresponding to the target cold data. Specifically, since the storage device 20 is located below the encryption processing layer of the host system 10, the target cold data processed and returned by the memory module 220 and the processor 211 can be in encrypted form. After receiving the target cold data, the host system 10 can obtain the plaintext data corresponding to the target cold data according to the encryption method adopted by the host system 10, through the corresponding encryption processing layer, file reading path, or other plaintext data acquisition path on the host system 10 side.

[0224] In scenarios employing volume-level or block-level encryption, the host system 10 can process the read target cold data through the corresponding volume encryption or block encryption processing layer to obtain the corresponding plaintext data above the encryption processing layer. In scenarios employing file-by-file encryption, the host system 10 can locate the corresponding file object and encryption context based on a logical address range, and obtain the corresponding plaintext data through the corresponding file read path. The optional methods for locating file objects and encryption contexts in file-by-file encryption scenarios will be further explained in subsequent embodiments.

[0225] In step S737, the host system 10 compresses the plaintext data before it undergoes the corresponding encryption process. Thus, the compression process applies to the plaintext data that has not yet been re-encrypted, rather than to the encrypted data stored in the storage device 20.

[0226] Steps S732 to S737 above correspond to: the host system 10 reads the target cold data according to the logical address range, obtains the plaintext data corresponding to the target cold data, and compresses the plaintext data before encryption.

[0227] In step S74, the compressed data is sent back and written back. In step S741, the host system 10 re-encrypts the compressed data and sends the re-encrypted compressed data back to the processor 211. In step S742, the processor 211 writes the compressed data sent back by the host system 10 into the memory module 220.

[0228] Figure 7 The term "compressed data" indicates that the data content has been compressed. When the compressed data is transmitted from the host system 10 to the storage device 20, and written from the storage device 20 to the memory module 220, the compressed data may be in a data format that has been re-encrypted by the host system 10.

[0229] The type of compression algorithm, the length of the compressed data, the management information of the compressed data, and the correspondence between the compressed data and the original logical address range can be configured according to the data management method of the host system 10. This disclosure does not limit the specific compression algorithm and corresponding data management format adopted by the host system 10.

[0230] The following numerical example illustrates the conversion of logical address ranges. Assume the granularity parameter in the cold alert header is 32MB, the starting range index obtained by host system 10 from the cold alert record is 100, and the number of consecutive ranges is 3. Using the conversion that 1MB equals 2^20 bytes, the starting byte offset of the target cold data is 100 multiplied by 32MB, which is the byte offset corresponding to 3200MB. The byte length of the target cold data is 3 multiplied by 32MB, which is 96MB.

[0231] If each logical block is 4KB in size, then the starting logical block address corresponding to the starting byte offset is 819200, and the 96MB byte length corresponds to 24576 logical blocks. The host system 10 obtains the target cold data through steps S732 to S735 based on the starting logical block address and the number of logical blocks, obtains the plaintext data corresponding to the target cold data in step S736, and compresses the plaintext data before encryption in step S737.

[0232] The host system 10 re-encrypts the compressed data and sends the re-encrypted compressed data back to the processor 211 via step S741. The processor 211 then writes the compressed data into the memory module 220 via step S742.

[0233] Subsequently, when the host system 10 sends a read buffer command again, it can first obtain the cold alert header information. If the content version information in the cold alert header information is the same as the content version information previously saved by the host system 10, the host system 10 does not need to re-obtain the unchanged cold alert record. If the content version information has changed, the host system 10 can obtain the cold alert record corresponding to the new content version page by page according to the new number of valid records and the corresponding buffer offset, and update the cold alert information saved on the host system 10 side accordingly.

[0234] In another embodiment, the method by which the host system 10 obtains the plaintext data corresponding to the target cold data based on the logical address range determined in step S731 may vary depending on the encryption method adopted by the host system 10.

[0235] In scenarios employing volume-level or block-level encryption, plaintext data resides above the corresponding volume encryption or block encryption layer. The host system 10 can retrieve the plaintext data based on a defined logical address range above the encryption layer. In this scenario, the host system 10 does not need to first locate the file object corresponding to the logical address range in order to obtain the plaintext data. The specific software processing layer and data interface can be configured according to the implementation of the host system 10.

[0236] In scenarios where file-based encryption is used, encryption is performed on a per-file-object basis. To obtain the plaintext data corresponding to the target cold data, the host system 10 can first locate the file object and encryption context corresponding to the logical address range, and then obtain the plaintext data through the corresponding file read path.

[0237] In one implementation, the host system 10 may use its existing forward mapping from file objects to logical addresses to intersect the logical address range corresponding to each file object with the logical address range indicated by the cold hint information to determine the file objects and their corresponding encryption contexts in which at least some data is located within the logical address range.

[0238] In another implementation, the host system 10 can establish a mapping relationship between logical address ranges, file objects, and encryption contexts, and based on the mapping relationship, reverse locate the corresponding file object and encryption context from the logical address range indicated by the cold message.

[0239] In another implementation, the host system 10 can use the existing reverse mapping information in the file system to locate the corresponding file object from the logical address range and obtain the encryption context corresponding to the file object.

[0240] The host system 10 can establish mapping relationships only for the logical address range indicated by the cold alert message, without having to pre-establish mapping relationships for the entire logical address space. Thus, the scope of establishing and maintaining mapping relationships can be limited to the logical address range indicated by the cold alert message.

[0241] The host system 10 can also update the mapping relationship in response to changes in the content version of the cold alert information. For example, when a logical address range is added to the cold alert record corresponding to the new content version, the host system 10 can establish a corresponding mapping relationship for the logical address range; when the new content version no longer includes a previously indicated logical address range, the host system 10 can delete, invalidate, or update the mapping relationship corresponding to the logical address range without having to re-establish the unaffected mapping relationship.

[0242] The above methods for obtaining plaintext data are all optional implementations on the host system 10 side, and can be selected according to the operating system, file system and encryption method of the host system 10.

[0243] In another embodiment, reading the cold alert information is an optional operation for the host system 10. Even if the host system 10 does not read the cold alert information, or fails to read the cold alert information, the storage device 20 can still process the read and write requests issued by the host system 10 according to the original data read and write path.

[0244] Whether or not the cold alert message is read does not affect the storage device 20's provision of basic data read and write services. The host system 10 can decide whether to enable the reading of the cold alert message and subsequent compression and write-back processing based on system load, power supply status, temperature status, or other operating strategies.

[0245] When the cold alert read or compressed write-back function on the host system 10 side is disabled, the storage device 20 can continue to perform cold data identification and maintain cold alert information, and can also pause the corresponding cold alert export according to the system configuration, without changing the basic data read and write path of the storage device 20. Therefore, the cold alert interaction and compressed write-back mechanism can be enabled or disabled by the host system 10.

[0246] Based on the above Figure 7 The interaction sequence shown illustrates that the storage device can provide the identified cold data to the host system via cold alert information. The host system determines the logical address range of the target cold data based on the cold alert information, reads the target cold data, obtains the corresponding plaintext data, compresses the plaintext data before encryption, and then sends the re-encrypted and compressed data back to the storage device for write-back. Thus, the compression process is applied to the plaintext data before encryption, avoiding direct compression of the encrypted data, and the storage device does not perform compression processing. The storage device is primarily responsible for cold data identification, cold alert information maintenance, reading the target cold data, and writing back the compressed data; the compression process is performed by the host system.

[0247] For example, depending on the content type and compressibility of the target cold data, the net compression gain could range from 10% to 25%. This range is merely an example and can vary depending on the data content, the compression algorithm used, the amount of compression management information required, and the actual system configuration. Reducing the amount of data that needs to be saved and written also lowers the corresponding storage and write burden, and helps reduce the power consumption of storage devices and improve their energy efficiency.

[0248] Reference Figure 8 In one embodiment, Figure 8The logical data structure of the cold alert message 810 is shown. The cold alert message 810 includes cold alert header information 811 and at least one cold alert record 812. The cold alert header information 811 includes seven fields: identifier code, protocol version, granularity parameter, round information, content version information, number of valid records, and verification information. Each cold alert record 812 includes four fields: starting range index, number of consecutive ranges, status, and reserved fields.

[0249] Figure 8 Two cold alert records 812 are shown, and below them, ellipses indicate that other cold alert records 812 may exist. The actual number of cold alert records 812 is determined based on the distribution and continuity of the coarse-grained logical ranges that are determined to store cold data. Figure 8 The data structure shown is the one described above. Figure 7 In this embodiment, the host system 10 expands the cold message header information and cold message record fields obtained by the read buffer command.

[0250] It should be noted that, Figure 8 This indicates the logical relationship between the cold message header information 811 and the cold message record 812 within the cold message information 810, and does not require that the cold message header information 811 and the cold message record 812 be stored contiguously in the same physical buffer. The processor 211 can store the cold message header information 811 and the cold message record 812 in different logical buffers, and the host system 10 can read the cold message header information 811 and the cold message record 812 respectively through different buffer identifiers.

[0251] The cold alert header information 811 includes granularity parameters representing the size of the coarse-grained logical range, round information, content version information, number of valid records, and verification information. Each cold alert record 812 includes the starting range index and the number of consecutive ranges for a coarse-grained logical range storing cold data. The identifier code, protocol version, status, and reserved fields are example fields further configured in addition to the fields mentioned above.

[0252] Regarding the cold alert header information 811, the identification code is used by the host system 10 to identify that the read data is the cold alert information 810. The identification code may be represented by, for example, a 32-bit numerical value, and may be set to an identification value pre-agreed upon by the host system 10 and the storage device 20.

[0253] The protocol version indicates the protocol version used by the data structure of the cold alert message 810. The protocol version can be represented, for example, by an 8-bit value, so that the host system 10 can interpret the fields in the cold alert header message 811 and the cold alert record 812 according to the corresponding protocol version. When the data structure or field definitions of the cold alert message 810 undergo compatibility changes, the corresponding data structure can be distinguished by updating the protocol version.

[0254] The granularity parameter represents the size of a coarse-grained logical range. The granularity parameter can, for example, be an 8-bit value expressed in MB. When the coarse-grained logical range is 32 MB, the value of the granularity parameter can be, for example, 32; when the coarse-grained logical range is 64 MB, the value of the granularity parameter can be, for example, 64. The host system 10 can determine the logical address range of the corresponding cold data based on the granularity parameter, the starting range index of the cold hint record 812, and the number of consecutive ranges.

[0255] The round information indicates the cold data determination round or cold prompt derivation round corresponding to the generation or update of the cold prompt information 810. The round information can be represented, for example, using a 32-bit numerical value. The processor 211 can update the round information as the cold data determination round or cold prompt derivation round progresses, so that the host system 10 can identify the round corresponding to the acquired cold prompt information 810.

[0256] The content version information indicates the current version of the cold alert information 810. The content version information can be represented, for example, using a 32-bit numerical value. The processor 211 can update the content version information when a coarse-grained logical range is newly determined to store cold data, a previous cold data determination is lifted, or the content of the cold alert record 812 undergoes other changes. The host system 10 can compare the currently acquired content version information with the previously saved content version information to determine whether the content of the cold alert record 812 has changed.

[0257] The number of valid records represents the number of valid cold alert records 812 in the current cold alert information 810, and can be represented, for example, as a 32-bit value. It should be noted that the number of valid records represents the number of entries in the cold alert records 812, and is not necessarily equal to the total number of coarse-grained logical ranges represented as storing cold data. Since one cold alert record 812 can represent multiple consecutive coarse-grained logical ranges, the total number of coarse-grained logical ranges represented as storing cold data can be determined based on the sum of the number of consecutive ranges in each cold alert record 812.

[0258] The host system 10 can determine the total amount of data in the cold alert records 812 to be read based on the number of valid records and the length of each cold alert record 812, and further determine the number of reads required to read all valid cold alert records 812 via the read buffer command.

[0259] The verification information is used to verify the integrity of the cold message header information 811. The verification information may, for example, be represented by a 32-bit numerical value, and may be, for example, a cyclic redundancy check value calculated based on other fields in the cold message header information 811 besides the verification information itself. After obtaining the cold message header information 811, the host system 10 can recalculate the check value using the same verification method and compare the recalculated check value with the verification information to determine whether an error occurred in the cold message header information 811 during storage or transmission.

[0260] Each cold hint record (812) represents a coarse-grained logical range of contiguous stored cold data. The starting range index represents the index of the first coarse-grained logical range in the contiguous range and can be represented, for example, as a 32-bit value. The index can, for example, start with the first coarse-grained logical range in the logical address space as index 0, and increment sequentially in the logical address direction.

[0261] The number of consecutive ranges represents the number of consecutive coarse-grained logical ranges represented by the cold hint record 812, and can be represented, for example, by a 16-bit value. The number of consecutive ranges is at least 1. When multiple coarse-grained logical ranges determined to store cold data have consecutive range indices, the processor 211 can merge the multiple coarse-grained logical ranges into a single cold hint record 812, with the starting range index representing the first coarse-grained logical range, and the number of consecutive ranges representing the total number of the multiple consecutive coarse-grained logical ranges.

[0262] The status indicates the current determination status of the corresponding continuous range in the cold alert information 810, and can be represented, for example, by an 8-bit numerical value. In this embodiment, the valid cold alert record 812 recorded in the cold alert information 810 is used to represent a coarse-grained logical range that has been determined to be storing cold data, so the status can use a predetermined value representing the cold data status. Other values ​​of the status field can be reserved values, and this disclosure does not limit the specific use of other values.

[0263] Reserved fields can be used for byte alignment or for subsequent expansion, and can be represented, for example, using 8-bit values. Based on a field configuration of 32 bits for the starting range index, 16 bits for the number of consecutive ranges, 8 bits for the status, and 8 bits for the reserved fields, each cold alert record 812 comprises 64 bits and can be represented using 8 bytes. The above field widths and order are examples and can be adjusted according to the protocol design and the resource configuration of the storage device 20.

[0264] When two or more coarse-grained logical ranges are both determined to store cold data, and their range indices are consecutive, the processor 211 can use a single cold hint record 812 to represent the consecutive ranges, without needing to create a separate cold hint record 812 for each coarse-grained logical range. If there is a coarse-grained logical range that is not determined to store cold data between two coarse-grained logical ranges, the processor 211 can use different cold hint records 812 to represent the two non-consecutive ranges respectively.

[0265] Therefore, the number of cold alert records 812 required for the cold alert information 810 is mainly determined by the number of consecutive segments of the cold data range, rather than directly by the number of all cold coarse-grained logical ranges. The more continuous the distribution of cold data, the more likely multiple coarse-grained logical ranges can be merged into the same cold alert record 812.

[0266] The following follows the correspondence mentioned above. Figure 7 The following embodiment illustrates a numerical example of the cold alert information 810. Assume the granularity parameter in the cold alert header information 811 is 32, meaning a coarse-grained logical range is 32MB, and the number of valid records is 1. A valid cold alert record 812 has a starting range index of 100, a consecutive range of 3, and a status that is a predetermined value indicating a cold data status.

[0267] Cold hint record 812 indicates that data within three consecutive coarse-grained logical ranges starting from index 100 is determined to be stored as cold data. Using the logical address space starting point as byte offset 0, and converting 1MB to 2^20 bytes, the starting byte offset of the consecutive range is 100 multiplied by 32MB, which is the byte offset corresponding to 3200MB; the byte length of the consecutive range is 3 multiplied by 32MB, which is 96MB. Therefore, cold hint record 812 represents a logical address range of 96MB in length starting from the position corresponding to 3200MB, and the byte interval of this logical address range can be represented as from 3200MB to before 3296MB.

[0268] If each logical block is 4KB in size, then the starting logical block address corresponding to the starting byte offset is 819200, and the 96MB byte length corresponds to 24576 logical blocks. Therefore, the host system 10 can determine the starting logical block address 819200 and the number of logical blocks 24576 based on the cold hint record 812, and read the corresponding target cold data accordingly.

[0269] In the numerical example above, the number of valid records is 1, but a cold hint record 812 represents 3 consecutive coarse-grained logic ranges. Therefore, the number of valid records represents the number of entries in the cold hint record 812, while the total number of represented cold coarse-grained logic ranges can be greater than the number of valid records.

[0270] A cold alert record 812 can be represented using 8 bytes. The total data size of the cold alert header information 811 and the fields of a single cold alert record 812 can be tens of bytes, not including control information attached by read buffer commands or transmission protocols, and is within the aforementioned corresponding... Figure 7 The examples of the data volume read in a single instance are within the range of implementation examples.

[0271] When the number of cold alert records 812 represented by the number of valid records is large, and the amount of data allowed by a single read buffer command is insufficient to obtain all valid cold alert records 812, the host system 10 can obtain the cold alert records 812 in pages through multiple read buffer commands.

[0272] Specifically, host system 10 can determine the number of cold hint records 812 included in each read based on the number of valid records, the length of each cold hint record 812, and the allocation length allowed for a single read. Host system 10 can also specify the starting position of this read through the buffer offset in the read buffer command, and specify the amount of data requested in this read through the allocation length. Processor 211 returns the corresponding portion of cold hint records 812 based on the buffer offset and the allocation length.

[0273] The host system 10 can accumulate the number of cold prompt records 812 that have been acquired after each acquisition of a page of cold prompt records 812, and continue to send read buffer commands with subsequent buffer offsets until the number of accumulated cold prompt records 812 reaches the number of valid records recorded in the cold prompt header information 811.

[0274] When host system 10 obtains the cold alert header information 811 again, it can compare the content version information therein with the previously saved content version information. If the content version information has not changed, host system 10 can continue to use the previously obtained cold alert record 812 without having to repeatedly read all the unchanged cold alert records 812. If the content version information has changed, host system 10 can obtain the cold alert record 812 corresponding to the new content version page by page according to the new number of valid records and the corresponding buffer offset.

[0275] Based on the above Figure 8 The data structure for cold alert information, as shown, provides a centralized header that centrally displays the information needed to identify cold alerts, interpret fields, determine content versions, and count the number of records to be read. Cold alert records can be represented by merging multiple consecutive coarse-grained logical ranges using a starting range index and the number of consecutive ranges. This reduces the number of cold alert records required to represent consecutive cold data ranges, allows the host system to retrieve cold alert records paginated based on the number of valid records, and avoids repeatedly retrieving unchanged cold alert records based on round information and content version information.

[0276] It should be noted that the numerical values, thresholds, parameter ranges, field configurations, and condition settings mentioned in the above embodiments are all exemplary and not intended to limit this disclosure. Specifically, the size of the coarse-grained and fine-grained logical ranges, the number of fine-grained logical ranges corresponding to each coarse-grained logical range, the predetermined upper limit of the sequential access index, the predetermined storage capacity of the first filter and the second filter, the number of hash functions, the length of the time window, the predetermined capacity and number of entries of the record table, the length of the observation period, the predetermined read threshold, the predetermined sampling probability, the decay ratio when updating the read / write active statistics, the weights of the cold score, the entry threshold, the exit threshold, the grading and scoring of the idle time, the predetermined stable time, the period of periodic checks, the opcode, mode, buffer identifier, buffer offset and allocation length of the read buffer command, and the width, arrangement order, encoding method and value of each field in the cold prompt information can all be adjusted according to the capacity of the storage device, the resource configuration of the memory controller, the target application scenario, the access load and the needs of the host system. The aforementioned parameters can also be adjusted in combination. For example, the storage capacity and number of hash functions of the filter can be selected based on the number of coarse-grained logical ranges expected to be recorded within the time window, or a predetermined reading threshold can be selected based on the length of the observation period.

[0277] In another embodiment, this disclosure also provides a computer program product, which includes a computer program. When the computer program is loaded and executed by the memory controller of a storage device, the memory controller performs the following: dividing the logical address space into multiple coarse-grained logical ranges, each coarse-grained logical range corresponding to multiple fine-grained logical ranges, and residently monitoring the read / write activity and inactivity duration of each coarse-grained logical range; determining whether the multiple coarse-grained logical ranges have been recently written to; in response to a target coarse-grained logical range not being recently written to and its read / write activity and inactivity duration meeting preset conditions, analyzing whether there are hot spots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and in response to a target coarse-grained logical range not being written to after a predetermined stable time since meeting the preset conditions, and multiple fine-grained logical ranges not being identified as hot spots, identifying the data within the target coarse-grained logical range as cold data. The computer program can be stored in a non-transitory computer-readable storage medium. Non-transitory computer-readable storage media include, for example, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, or other physical storage media capable of storing computer programs.

[0278] Based on the above, the memory management method, memory controller, memory system, and computer program product provided in this disclosure form a two-level granularity cold data determination structure by using a coarse-grained logical range as the resident monitoring unit and, after the coarse-grained logical range meets preset conditions, using its corresponding fine-grained logical range as the local observation unit. Recent write judgment can exclude coarse-grained logical ranges that have recently been written to; sequential access indicators can suppress the influence of sequential scans on cold data determination; the hysteresis constituted by cold score, entry threshold, and exit threshold can reduce repeated changes in the determination state near the threshold; and predetermined stabilization time and hotspot detection provide further confirmation of candidate coarse-grained logical ranges.

[0279] Therefore, a target coarse-grained logical range is only considered cold data if it has not been written to recently, its read / write activity and inactivity time meet preset conditions, it has not been written to after a predetermined stable period, and there are no local hot spots. This reduces the possibility of classifying data that is still actively accessed as cold data. Regarding record resources, it is not necessary to configure resident activity records for all fine-grained logical ranges in the logical address space; the resident state is maintained on a coarse-grained logical range basis, while fine-grained activity records are shared by multiple coarse-grained logical ranges with enabled fine-grained activity records in a record table of predetermined capacity. This limits the record capacity required for fine-grained observation to the configured capacity range.

[0280] Furthermore, the coarse-grained logical range of stored cold data is exported as versioned incremental cold hint information and provided to the host via read buffer commands. This allows the host to avoid repeatedly retrieving unchanged cold hint records based on round information and content version information, and to describe continuous cold data ranges with fewer records using a starting range index and the number of consecutive ranges. In file-based encryption scenarios, the host can also establish a mapping relationship between logical address ranges, file objects, and encryption contexts only for the logical address range indicated by the cold hint information, and incrementally update the mapping relationship in response to updates to the cold hint information, thereby limiting the establishment and maintenance of the mapping relationship to the logical address range indicated by the cold hint information. The host determines the logical address range of the target cold data based on the cold hint information, obtains the plaintext data corresponding to the target cold data, compresses it before encryption, and then sends the compressed data back to the storage device for write-back. This allows the compression process to apply to the plaintext data before encryption, without the storage device directly compressing the encrypted data. Since the amount of data to be saved and written is reduced after compression, the corresponding storage and write burden is also reduced, and it helps to reduce the power consumption of the storage device and improve the energy efficiency ratio of the device.

[0281] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this disclosure.

Claims

1. A memory management method applied to a memory device, characterized in that, The method includes: The logical address space is divided into multiple coarse-grained logical ranges, each of which corresponds to multiple fine-grained logical ranges. The read / write activity and idle time of each coarse-grained logical range are constantly monitored. Determine whether the multiple coarse-grained logical ranges have been recently written to; In response to the fact that the target coarse-grained logical range has not been written to recently, and the read / write activity and inactivity time meet preset conditions, the system analyzes whether there are hotspots in the multiple fine-grained logical ranges corresponding to the target coarse-grained logical range; and If the target coarse-grained logical range has not been written after a predetermined stable period since the preset condition was met, and none of the multiple fine-grained logical ranges have been identified as hotspots, the data within the target coarse-grained logical range is identified as cold data.

2. The memory management method according to claim 1, characterized in that, The method further includes: Based on consecutive accesses to adjacent fine-grained logic ranges within a plurality of fine-grained logic ranges corresponding to the coarse-grained logic range, the consecutive access span of the coarse-grained logic range is determined; and The sequential access index of the coarse-grained logical range is determined based on the continuous access span; When determining whether the read / write activity and the idle time meet the preset conditions, the sequential access index is also used to suppress the sequential scanning from causing the coarse-grained logic range to be mistakenly determined to meet the preset conditions.

3. The memory management method according to claim 2, characterized in that, The step of determining the continuous access span of the coarse-grained logic range based on continuous accesses of adjacent fine-grained logic ranges among multiple fine-grained logic ranges corresponding to the coarse-grained logic range includes: In response to the current access hitting the next fine-grained logical range of the fine-grained logical range hit by the previous access, the consecutive access span is incremented; otherwise, the consecutive access span is reset. The sequential access metric is the ratio of the consecutive access span to the number of multiple fine-grained logic ranges corresponding to the coarse-grained logic range, and the sequential access metric does not exceed a predetermined upper limit.

4. The memory management method according to claim 1, characterized in that, The step of analyzing whether there are hotspots in multiple fine-grained logical ranges corresponding to the target coarse-grained logical range in response to the target coarse-grained logical range not being recently written to and its read / write activity and inactivity time meeting preset conditions includes: Enable fine-grained activity logging for the target coarse-grained logical range to record access to each of the multiple fine-grained logical ranges; and Based on the fine-grained activity records, determine whether there are hotspots within the multiple fine-grained logical ranges.

5. The memory management method according to claim 4, characterized in that, The fine-grained activity records are recorded in a record table. The record table has a predetermined capacity, is shared by multiple coarse-grained logical ranges that have enabled fine-grained activity recording, and each entry in the record table includes at least an identifier of the corresponding coarse-grained logical range and an identifier of the corresponding fine-grained logical range.

6. The memory management method according to claim 4, characterized in that, The step of determining whether there are hotspots in the plurality of fine-grained logical ranges based on the fine-grained activity records includes: For each of the plurality of fine-grained logic ranges, in response to the fine-grained activity record recording that the write count of the fine-grained logic range during the observation period is greater than zero or the read count reaches a predetermined read threshold, the fine-grained logic range is determined to be a hotspot.

7. The memory management method according to claim 1, characterized in that, The step of determining whether the plurality of coarse-grained logical ranges have been recently written to includes: The identifier of the coarse-grained logical range in which the write occurred is recorded in the first filter of the write detector corresponding to the current time window; In response to the expiration of the current time window, the second filter in the write detector corresponding to the previous time window is updated with the content of the first filter, and the first filter is cleared; and In response to the coarse-grained logic range hitting at least one of the first filter and the second filter, it is determined that the coarse-grained logic range was recently written.

8. The memory management method according to claim 7, characterized in that, The first filter and the second filter are both Bloom filters, and the storage capacity of the first filter and the second filter is a predetermined storage capacity.

9. The memory management method according to claim 1, characterized in that, The preset conditions include: The entry threshold is reached when the cold score is determined by weighting the inactivity time and read / write activity with corresponding weights. The longer the inactivity period, the higher the cold score; and the higher the read / write activity, the lower the cold score.

10. The memory management method according to claim 9, characterized in that, The method further includes: If the cold score of a previously satisfied coarse-grained logic range falls below an exit threshold, the coarse-grained logic range is re-evaluated as not satisfying the preset conditions. The entry threshold is higher than the exit threshold.

11. The memory management method according to claim 1, characterized in that, The method further includes: In response to a write event hitting a coarse-grained logical range storing cold data, the cold data determination for data within the coarse-grained logical range is lifted; and Periodically check whether the coarse-grained logical range of stored cold data has been recently written, and remove the cold data determination for the data in the recently written coarse-grained logical range.

12. The memory management method according to claim 1, characterized in that, The read / write activity includes write activity statistics and read activity statistics. The write activity statistics are updated in response to write events to the coarse-grained logical range, and the read activity statistics are updated with a predetermined sampling probability in response to read events to the coarse-grained logical range. Furthermore, each of the write activity statistics and the read activity statistics is added to the contribution of the current event during the update, and the previously accumulated portion is decayed according to a predetermined ratio.

13. The memory management method according to claim 1, characterized in that, The method further includes: The coarse-grained logical range of stored cold data is exported as cold alert information, which the host uses to compress the target cold data and write it back before encryption. The cold notification information is maintained in a versioned incremental manner, and the cold notification information includes round information and content version information.

14. The memory management method according to claim 13, characterized in that, The cold alert information includes cold alert header information and at least one cold alert record. The cold notification header information includes granularity parameters representing the size of the coarse-grained logical range, the round information, the content version information, the number of valid records, and verification information. Each of the cold alert records includes a starting range index for a coarse-grained logical range of consecutive stored cold data and a number of consecutive ranges.

15. The memory management method according to claim 14, characterized in that, The method further includes: In response to a read buffer command issued by the host, the cold alert information is provided to the host. The host obtains the cold alert header information and the cold alert record in pages using different buffer identifiers through the read buffer command, and the host obtains the cold alert information incrementally based on the round information and the content version information.

16. A memory controller suitable for a storage device configured with a memory module, characterized in that, include: A memory interface control circuit is used to electrically connect to the memory module; as well as A processor, electrically connected to the memory interface control circuit, wherein the processor is configured to: The logical address space is divided into multiple coarse-grained logical ranges, each of which corresponds to multiple fine-grained logical ranges. The read / write activity and idle time of each coarse-grained logical range are constantly monitored. Determine whether the multiple coarse-grained logical ranges have been recently written to; In response to the fact that the target coarse-grained logic range has not been written to recently and its read / write activity and idle time meet preset conditions, analyze whether there are hot spots in the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range; as well as If the target coarse-grained logical range has not been written for a predetermined stable period of time since the preset condition was met, and none of the multiple fine-grained logical ranges have been identified as hotspots, the data within the target coarse-grained logical range is identified as cold data.

17. A storage system, characterized in that, include: Host system; as well as Storage device, connected to the host system, The storage device is configured to: The logical address space is divided into multiple coarse-grained logical ranges, each of which corresponds to multiple fine-grained logical ranges. The read / write activity and idle time of each coarse-grained logical range are constantly monitored. Determine whether the multiple coarse-grained logical ranges have been recently written to; In response to the fact that the target coarse-grained logic range has not been written to recently and its read / write activity and idle time meet preset conditions, analyze whether there are hot spots in the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range; If the target coarse-grained logical range has not been written for a predetermined stable period of time since the preset condition was met, and none of the multiple fine-grained logical ranges have been identified as hotspots, the data within the target coarse-grained logical range is identified as cold data. as well as Export the coarse-grained logical range of stored cold data as a cold alert message. The host system is configured to: The cold alert information is retrieved from the storage device using a read buffer command; The logical address range of the target cold data is determined based on the cold alert information; Read the plaintext data corresponding to the target cold data according to the logical address range, and compress the plaintext data before encryption; as well as The compressed data is then sent back to the storage device. The storage device is further configured to write back the compressed data transmitted back by the host system.

18. The storage system according to claim 17, characterized in that, The host system is also configured to handle file-based encryption scenarios: Establish a mapping relationship between logical address ranges, file objects, and encryption contexts; and Based on the mapping relationship, the corresponding file object and the encryption context are located from the determined logical address range.

19. The storage system according to claim 18, characterized in that, The host system is also configured to: The mapping relationship is established only for the logical address range indicated by the cold alert information; and In response to the update of the cold alert information, the mapping relationship is incrementally updated.

20. A computer program product, comprising a computer program, characterized in that, When the computer program is loaded and executed by the memory controller of the storage device, the memory controller performs the following: The logical address space is divided into multiple coarse-grained logical ranges, each of which corresponds to multiple fine-grained logical ranges. The read / write activity and idle time of each coarse-grained logical range are constantly monitored. Determine whether the multiple coarse-grained logical ranges have been recently written to; In response to the fact that the target coarse-grained logic range has not been written to recently and its read / write activity and idle time meet preset conditions, analyze whether there are hot spots in the multiple fine-grained logic ranges corresponding to the target coarse-grained logic range; as well as If the target coarse-grained logical range has not been written for a predetermined stable period of time since the preset condition was met, and none of the multiple fine-grained logical ranges have been identified as hotspots, the data within the target coarse-grained logical range is identified as cold data.