Method for identifying and processing read command, fragmented data arrangement method and storage device

By using the command to read address space attributes to identify and back up valid data in storage devices, the problem of data waste during backup in existing technologies is solved, achieving efficient data backup and device optimization.

CN121455853APending Publication Date: 2026-02-03CHENGDU STARBLAZE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511605018.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2021-03-30
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Existing storage devices require copying all data during backup, resulting in wasted time, energy, and data transfer bandwidth, especially in the absence of a file system.

Method used

By using the address space attribute command, valid data can be identified and only valid data can be backed up, reducing the amount of backup data and optimizing the functionality of the storage device by utilizing the address space attribute table.

Benefits of technology

Without a file system, the amount of backup data is reduced, saving time, energy, and data transfer bandwidth, thus improving the backup efficiency of storage devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121455853A_ABST
    Figure CN121455853A_ABST
Patent Text Reader

Abstract

The invention provides a method for identifying and processing a read command, a fragmented data arrangement method and a storage device. The method for identifying whether the read command belongs to the sequence flow is applied to the storage device and comprises the steps that a control component obtains a first read command sent by a host; in response to the first read command, the control component judges whether the first read command belongs to a sequence flow read command or not according to a first address space indicated by the first read command; if yes, the control component obtains the random degree of the first address space from the address space attribute table; and the control component judges whether the first read command belongs to a sequence flow read command or not again according to the random degree of the first address space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to storage technology, and in particular to a method for identifying and processing read commands, a method for defragmenting fragmented data, and a storage device. Background Technology

[0002] Figure 1 A block diagram of a storage device is shown. Storage device 102 is coupled to a host computer to provide storage capabilities. The host computer and storage device 102 can be coupled in various ways, including but not limited to connections via SATA (Serial Advanced Technology Attachment), SCSI (Small Computer System Interface), SAS (Serial Attached SCSI), IDE (Integrated Drive Electronics), USB (Universal Serial Bus), PCIe (Peripheral Component Interconnect Express), NVMe (NVM Express), Ethernet, Fibre Channel, and wireless communication networks. The host computer can be an information processing device capable of communicating with the storage device via the above methods, such as a personal computer, tablet computer, server, laptop computer, network switch, router, cellular phone, or personal digital assistant. Storage device 102 includes interface 103, control unit 104, one or more NVM chips 105, and DRAM (Dynamic Random Access Memory) 110.

[0003] Common types of NVMs include NAND flash memory, phase-change memory, FeRAM (Ferroelectric RAM), MRAM (Magnetic Random Access Memory), RRAM (Resistive Random Access Memory), and XPoint memory.

[0004] Interface 103 is compatible with exchanging data with the host via methods such as SATA, IDE, USB, PCIe, NVMe, SAS, Ethernet, and Fibre Channel.

[0005] The control unit 104 is used to control data transfer between the interface 103, the NVM chip 105, and the DRAM 110. It is also used for memory management, host logical address to flash physical address mapping, erase leveling, bad block management, etc. The control unit 104 can be implemented in various ways, including software, hardware, firmware, or a combination thereof. For example, the control unit 104 can be in the form of an FPGA (Field-programmable gate array), an ASIC (Application Specific Integrated Circuit), or a combination thereof. The control unit 104 may also include a processor or controller, in which software executes to manipulate the hardware of the control unit 104 to process I / O (Input / Output) commands. The control unit 104 can also be coupled to the DRAM 110 and access the data in the DRAM 110. FTL tables and / or cached I / O command data can be stored in the DRAM.

[0006] The control unit 104 includes a flash interface controller (or media interface controller, flash channel controller), which is coupled to the NVM chip 105 and issues commands to the NVM chip 105 in accordance with the interface protocol of the NVM chip 105 to operate the NVM chip 105, and receives the command execution results output from the NVM chip 105. Known NVM chip interface protocols include "Toggle", "ONFI", etc.

[0007] In storage devices, the FTL (Flash Translation Layer) is used to maintain the mapping information from logical addresses to physical addresses. Logical addresses constitute the storage space of the storage device as perceived by upper-layer software such as the operating system. Physical addresses are the addresses used to access the physical storage units of the storage device. In related technologies, intermediate address formats can also be used for address mapping. For example, a logical address can be mapped to an intermediate address, and then the intermediate address can be further mapped to a physical address. In these cases, the read / write commands received by the storage device indicate the logical address.

[0008] A table structure that stores mapping information from logical addresses to physical addresses is called an L2P table (Logical Address To Physical Address) (also known as an FTL table). The L2P table is important metadata in storage devices. Typically, L2P table entries (also called L2P entries) record the address mapping relationships within the storage device, on a per-data-page basis.

[0009] For some storage devices, the FTL (File Transfer Table) is provided by the host coupled to the storage device. The host's memory stores the L2P table, and the host's CPU executes the FTL software. In other cases, a storage management unit positioned between the host and the storage device provides the FTL. In these situations, the read / write commands received by the storage device indicate the physical address.

[0010] Commands provided by the host to the storage device may access the logical address space corresponding to one or more L2P entries. The control unit may also modify the format of commands received from interface 103 (e.g., split commands according to the size of the logical address space corresponding to L2P entries) and process the modified commands. For clarity, the commands provided by the host to the storage device are referred to herein as I / O commands.

[0011] Figure 2 A schematic diagram of an L2P table in the prior art is shown.

[0012] like Figure 2 As shown, the L2P table includes multiple L2P entries, each storing an NVM data frame address. The NVM data frame address is the physical address within the NVM chip. For example, L2P entry 0 stores NVM data frame address 0. The entries in the L2P table are sorted in ascending order of logical address, such as LBA 0 for L2P entry 0, LBA 1 for L2P entry 1, LBA 2 for L2P entry 2, and so on.

[0013] Figure 3 A block diagram of a control component in the prior art is shown.

[0014] The host accesses the storage device using I / O commands that conform to the storage protocol. The control unit generates one or more storage commands based on the I / O commands from the host and provides them to the media interface controller. The media interface controller generates storage media access commands (e.g., programming commands, read commands, erase commands) that conform to the NVM chip's interface protocol based on the storage commands. The control unit also tracks the completion of all storage commands generated from a single I / O command and indicates the processing results of the I / O commands to the host.

[0015] See Figure 3The control components include, for example, a host interface, a host command processing unit, a storage command processing unit, a media interface controller, and a storage media management unit. The host interface receives I / O commands from the host and generates storage commands, which are then provided to the storage command processing unit. A storage command may access a storage space of the same size, such as 4KB. The data unit recorded in the NVM chip corresponding to the data accessed by a storage command is called a data frame. A physical page records one or more data frames. For example, if the size of a physical page is 17664 bytes and the size of a data frame is 4KB, then one physical page can store four data frames. Summary of the Invention

[0016] Backup or image creation of storage devices is a common requirement. Typically, there are two methods for backing up storage devices. One is to use a file system to accurately obtain the valid data from the storage device and back it up. This method involves backing up a small amount of data but strictly requires the use of a file system. The second method, without a file system, backs up the data corresponding to every address in the entire address space of the storage device. This results in a large amount of invalid data being copied, wasting significant time, energy, and data transfer bandwidth. This application's embodiment, through the read address space attribute command, enables the backup of storage devices without copying all data in the storage device, even without a file system. This significantly reduces the amount of data to be backed up, as well as the time, energy, and data transfer bandwidth required for backup.

[0017] The read address space attribute command provided in the embodiments of this application can be used not only for storage backup, but also for various other purposes such as storage device defragmentation, sequential stream detection, and address space attribute table copying. The read address space command also serves as an architectural interface for storage devices, enriching their functionality and facilitating their use.

[0018] According to a first aspect of this application, a method for obtaining address space attributes according to the first aspect of this application is provided, applied to a host, comprising: sending a read address space attribute command to a control component, the read address space attribute command being used to read at least one attribute of an address or a segment of an address space; and receiving first data fed back by the control component, the first data corresponding to at least one attribute indicated by the read address space attribute command.

[0019] According to the first method for obtaining address space attributes according to the first aspect of this application, a second method for obtaining address space attributes according to the first aspect of this application is provided, wherein the attributes include valid elements, percentage of valid elements, size of continuous data blocks, randomness, and time variation values ​​of each attribute.

[0020] According to the first or second method for obtaining address space attributes according to the first aspect of this application, a third method for obtaining address space attributes according to the first aspect of this application is provided, wherein the address indicated by the read address space attribute command is a logical address.

[0021] According to the first method for obtaining address space attributes according to the first aspect of this application, a fourth method for obtaining address space attributes according to the first aspect of this application is provided, wherein the first data is part or all of an address space attribute table; or, the first data is at least one attribute required by the read address space attribute command.

[0022] According to the fourth method for obtaining address space attributes according to the first aspect of this application, a fifth method for obtaining address space attributes according to the first aspect of this application is provided. If the first data is part or all of an address space attribute table, the address space attribute table represents whether each address in the address space corresponds to a valid element. The method further includes: processing the first data to obtain the at least one attribute.

[0023] According to a second aspect of this application, a method for obtaining address space attributes according to the second aspect of this application is provided, applied to a control component, comprising: receiving a read address space attribute command sent by a host, the read address space attribute command being used to read at least one attribute of an address or a segment of address space; accessing an address space attribute table according to the read address space attribute command to obtain first data, the first data corresponding to at least one attribute indicated by the read address space attribute command, the address space attribute table representing whether each address in the address space corresponds to a valid element; and feeding back the first data to the host.

[0024] According to the first method for obtaining address space attributes according to the second aspect of this application, a second method for obtaining address space attributes according to the second aspect of this application is provided, wherein the attributes include valid elements, percentage of valid elements, size of continuous data blocks, randomness, and time variation values ​​of each attribute.

[0025] According to the first or second method for obtaining address space attributes according to the second aspect of this application, a third method for obtaining address space attributes according to the second aspect of this application is provided, wherein the address indicated by the read address space attribute command is a logical address.

[0026] According to one of the first to third methods for obtaining address space attributes according to the second aspect of this application, a fourth method for obtaining address space attributes according to the second aspect of this application is provided, the method further comprising: in response to the read address space attribute command, obtaining a first address index according to the address carried by the read address space attribute command; and obtaining the first data from the address space attribute table according to the first address index, wherein the first data is part or all of the address space attribute table.

[0027] According to the fourth method for obtaining address space attributes according to the second aspect of this application, a fifth method for obtaining address space attributes according to the second aspect of this application is provided, which obtains the first data from the address space attribute table, including: reading second data from the address space attribute table; compressing the second data to obtain the first data.

[0028] According to the first method for obtaining address space attributes according to the second aspect of this application, a sixth method for obtaining address space attributes according to the second aspect of this application is provided, the method further comprising: in response to the read address space attribute command, obtaining a first address index according to the address carried by the read address space attribute command; reading a plurality of valid elements from the address space attribute table according to the first address index; and processing the plurality of valid elements according to the attributes indicated by the read address space attribute command to obtain the first data, wherein the first data is the attribute required by the read address space attribute command.

[0029] According to a third aspect of this application, a data backup method for a first storage device according to the third aspect of this application is provided, comprising: obtaining third data using a read address space attribute command, wherein the third data is part or all of an address space attribute table, the address space attribute table characterizing whether each address in the address space corresponds to a valid element; accessing the first storage device according to a first plurality of logical addresses corresponding to valid elements in the third data, to read a first plurality of data to be backed up from the first storage device, wherein the first plurality of data to be backed up corresponds to the first plurality of logical addresses; and writing the first plurality of data to be backed up into a second storage device to obtain backup data; wherein each valid element corresponds to a logical address, and the method of obtaining the third data using the read address space attribute command is implemented using any one of the methods described in the first aspect above.

[0030] According to the data backup method for a first storage device according to the third aspect of this application, a data backup method for a second storage device according to the third aspect of this application is provided, wherein writing the data to be backed up into the second storage device includes: writing the data to be backed up into the second storage device according to the correspondence between valid elements and logical addresses, so that the correspondence between backup data and logical addresses in the second storage device is the same as the correspondence between valid elements and logical addresses.

[0031] According to a fourth aspect of this application, a method for obtaining a first address space attribute according to the fourth aspect of this application is provided, comprising: a host sending a first read address space attribute command to a control unit, the first read address space attribute command being used to read at least one attribute of an address or a segment of an address space; in response to the first read address space attribute command, the control unit accessing an address space attribute table to obtain first data, the address space attribute table representing whether each address in the address space corresponds to a valid element; and the control unit feeding back the first data to the host, the first data corresponding to at least one attribute indicated by the first read address space attribute command.

[0032] According to the method for obtaining a first address space attribute according to the fourth aspect of this application, a method for obtaining a second address space attribute according to the fourth aspect of this application is provided. When the first read address space attribute command indicates that the randomness of the first address space is to be obtained, the method includes: in response to the first read address space attribute command, the control component obtains a second address space in the first address space whose randomness is greater than a preset threshold; the control component obtains valid elements in the second address space; the control component marks the second address space according to the valid elements in the second address space; and the control component feeds back the address corresponding to the marked second address space to the host.

[0033] According to the method for obtaining a first address space attribute according to the fourth aspect of this application, a method for obtaining a third address space attribute according to the fourth aspect of this application is provided. When the first read address space attribute command instructs the acquisition of the address space attribute table, the method further includes: in response to the first read address space attribute command, the control unit feeds back the address space attribute table to the host; and the host stores the address space attribute table.

[0034] According to a fifth aspect of this application, a method for accessing a first storage device according to the fifth aspect of this application is provided, the storage device including an address space attribute table, the method comprising: a host sending a first access command to a control unit, the first access command including a read command and a write command; the control unit processing the first access command according to the address space attribute table; or, the control unit adjusting the address space attribute table according to the first access command.

[0035] According to the first storage device access method of the fifth aspect of this application, a second storage device access method according to the fifth aspect of this application is provided, wherein when the first access command is a write command, the control unit writes data to the storage medium according to the write command and modifies the address space attribute table.

[0036] According to the access method of the second storage device according to the fifth aspect of this application, an access method of the third storage device according to the fifth aspect of this application is provided, wherein the control unit writes data to the storage medium according to the write command and modifies the address space attribute table, including: the control unit allocates a physical address for the data to be written, the physical address corresponding to a second logical address, and the write command indicating the second logical address; the control unit updates the L2P table according to the second logical address and the physical address; the control unit writes the data to be written to the storage space corresponding to the physical address; and the control unit modifies the address space attribute table according to the second logical address.

[0037] According to the access method of the third storage device according to the fifth aspect of this application, an access method of the fourth storage device according to the fifth aspect of this application is provided, wherein the control component modifies the address space attribute table according to the second logical address, including: the control component modifying the value of at least one element in the address space attribute table corresponding to the second logical address, so that the second logical address in the modified address space attribute table is a valid element; and / or, the control component modifying at least one attribute in the address space attribute table.

[0038] According to one of the access methods for the first to fourth storage devices according to the fifth aspect of this application, an access method for the fifth storage device according to the fifth aspect of this application is provided. When the first access command is a first read command, the method includes: the host sending the first read command to the control unit; in response to the first read command, the control unit determining whether the first read command belongs to a sequential stream read command based on a third address space indicated by the read command; if yes, the control unit obtaining the randomness of the third address space; and the control unit again determining whether the first read command belongs to a sequential stream read command based on the randomness of the third address space.

[0039] According to the fifth storage device access method of the fifth aspect of this application, a sixth storage device access method according to the fifth aspect of this application is provided, wherein the control component determines again whether the first read command belongs to a sequential stream read command based on the randomness of the third address space, including: the control component determining whether the randomness of the third address space is greater than a preset threshold; if yes, the control component marks the first read command as not belonging to a sequential stream read command.

[0040] According to the access method of the fifth or sixth storage device according to the fifth aspect of this application, an access method of the seventh storage device according to the fifth aspect of this application is provided, wherein when either determination result is negative, the control unit marks the first read command as belonging to a sequential stream read command.

[0041] According to the access method of the first storage device of the fifth aspect of this application, an access method of the eighth storage device according to the fifth aspect of this application is provided. When the first access command is a second read command, the method includes: the host sending the second read command to the control unit; in response to the second read command, the control unit determining whether the third address space indicated by the read command commands a first cache; if yes, the control unit obtaining first read data from the first cache; and the control unit feeding back the first read data to the host.

[0042] According to the method for accessing an eighth storage device according to the fifth aspect of this application, a method for accessing a ninth storage device according to the fifth aspect of this application is provided. When no, the control unit obtains second read data from the storage medium and moves the second read data to a second cache; the control unit feeds back the second read data to the host.

[0043] According to the method for accessing an eighth storage device according to the fifth aspect of this application, a method for accessing a tenth storage device according to the fifth aspect of this application is provided, wherein the control component further acquires the randomness change of the third address space; the control component determines whether the randomness change is greater than a preset threshold; when the randomness change is greater than the preset threshold, the control component feeds back the second read data to the host and then releases the second cache.

[0044] According to the method for accessing the eighth storage device according to the fifth aspect of this application, an eleventh storage device according to the fifth aspect of this application is provided, wherein when the randomness change is less than a preset threshold, the control component feeds back the second read data to the host and then retains the second cache.

[0045] According to a sixth aspect of this application, a first storage system according to the sixth aspect of this application is provided, comprising a host, a control unit, and a storage medium; wherein the control unit maintains an L2P table and an address space attribute table, the address space attribute table characterizing whether each address in the address space corresponds to a valid element; the storage system performs the method as described in any one of the first to fifth aspects above. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.

[0047] Figure 1 A block diagram of a storage device in the prior art; Figure 2 This is a schematic diagram of an L2P table in the prior art; Figure 3 A block diagram of a control component in the prior art; Figure 4 A schematic diagram of the read address space attribute command provided in an embodiment of this application; Figure 5A A schematic diagram of an L2P table provided in an embodiment of this application; Figure 5B A flowchart of a method for obtaining address space attributes provided in an embodiment of this application; Figure 5C A schematic diagram of a bitmap corresponding to an L2P table provided in an embodiment of this application; Figure 6A A block diagram of the control component provided in an embodiment of this application; Figure 6B A flowchart illustrating the method for updating the address space attribute table is shown. Figure 7A A flowchart illustrating a method for processing read commands provided in an embodiment of this application; Figure 7B A flowchart illustrating the method for processing write commands provided in this application embodiment; Figure 8 A flowchart illustrating the data backup method provided in this application embodiment; Figure 9 A flowchart of the fragmented data organization method provided in the embodiments of this application; Figure 10 A flowchart illustrating the address space attribute table backup method provided in this application embodiment; Figure 11A flowchart illustrating yet another method for processing read commands provided in an embodiment of this application; Figure 12 A flowchart of another method for processing read commands provided in an embodiment of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0049] It should be understood that the terms "first," "second," "third," and "fourth," etc., used in the claims, specification, and drawings of this application are used to distinguish different objects, rather than to describe a specific order. The terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.

[0050] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0051] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection."

[0052] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0053] Figure 4 A schematic diagram illustrating the read address space attribute command provided in an embodiment of this application is shown.

[0054] like Figure 4 As shown, embodiments of this application provide various commands for reading address space attributes (in...). Figure 4 The text refers to commands for reading address space attributes, with each command indicating the address space range and attribute type.

[0055] The address space range indicated by the "Read Address Space Attributes" command specifies the range of the storage device's address space from which the command seeks to retrieve its attributes. For example, if the storage device's address space is the LBA space, with a complete range from LBA0 to LBA 2000, then the entire address space range is LBA 0-LBA2000. The address range indicated by the "Read Address Space Attributes" command can be part or all of this entire space, such as LBA 0-LBA 1000 or LBA 101-LBA 1520. Specific flags can also be used to represent the entire address space.

[0056] The attribute type indicated by the "Read Address Space Attributes" command specifies the category of the attribute corresponding to the address space range that the command wants to retrieve. Attributes include valid elements (addresses in the address space containing valid data), valid element percentage, contiguous data block size (the number of consecutive addresses in the address space containing valid data), randomness (the degree of randomness in the distribution of addresses in the address space containing valid data), and the time variation values ​​of the aforementioned attributes. The attribute type is the information in the "Read Address Space Attributes" command indicating the category of the attribute to be retrieved. For example, the attribute category for valid elements is 1, the attribute category for valid element percentage is 2, the attribute category for contiguous data block size is 3, and the attribute category for randomness is 4. The time variation values ​​of each attribute include the time variation values ​​for valid elements, valid element percentage, contiguous data block size, and randomness, etc. The attribute type for the time variation value of valid elements is 51, the attribute type for the time variation value of valid element percentage is 52, the attribute type for the time variation value of contiguous data block size is 53, and the attribute type for the time variation value of randomness is 54.

[0057] Optionally, in this application, a valid element refers to an L2P entry corresponding to the address space from which its attributes are to be obtained, which records either a valid address or a valid element identifier. A valid element identifier indicates that the logical address corresponding to the entry stores valid data, and is neither blank nor garbage data that has undergone garbage collection.

[0058] Figure 5A A schematic diagram of an L2P table provided in an embodiment of this application is shown.

[0059] like Figure 5A As shown, the L2P table includes 6 L2P entries, namely L2P entry 0, L2P entry 1, ..., L2P entry 5. Figure 5AThe area within the dashed box represents the address index. This indicates that the address index is not necessarily stored as data within the L2P entry. Since each L2P entry corresponds one-to-one with a logical address, the logical address serves as the index for that L2P entry. For example, if L2P entries 0-5 correspond to logical addresses LBA 0-5 respectively, then logical address LBA 3 is the index for L2P entry 3. In this embodiment, each entry in the L2P table stores the NVM data frame address, including valid and invalid addresses. For example, the NVM data frame address 5 stored in L2P entry 5 is the physical address of the NVM. Accessing NVM data frame address 5 allows the reading of data stored at that physical address. In this embodiment, an invalid address can optionally be a physical address or a specific identifier indicating an invalid address (e.g., N / A), but accessing an invalid address will not retrieve data. For example, accessing the physical address stored in L2P entry 4 will result in an error and prevent data reading. In this embodiment, the invalid address can be any physical address in the NVM, with one physical address pre-defined as invalid. For example, if physical address 0 or physical address 100 is set to an invalid address, then accessing physical address 0 or physical address 100 will not allow writing or reading data. Furthermore, the L2P table will also be updated after the mapping relationship between logical addresses and physical addresses changes. For instance, after writing data to the physical address corresponding to logical address LBA 0, the invalid address stored in L2P entry 0 of the L2P table will be modified to a valid address; similarly, after executing a do-allocation command on logical address LBA 2, the valid address stored in L2P entry 2 of the L2P table will be modified to an invalid address.

[0060] Figure 5B A flowchart illustrating a method for obtaining address space attributes provided in an embodiment of this application is shown.

[0061] As an example Figure 5B The `read address space attribute` command indicates that the attribute type being read is a valid element, and the address space indicated by the `read address space attribute` command is determined by, for example... Figure 5A The L2P table shown below illustrates this. The following description assumes the read address space attribute command is sent by the host and received by the control unit, illustrating this point. Figure 5B The process.

[0062] Step 510: Received the command to read address space attributes.

[0063] Step 520: Index L2P table entries based on address indexes. After receiving the read address attribute command, the control unit obtains the address space range indicated by the read address space attribute command. Each logical address within the address space range can be used as an address index to access the L2P table. For example, if the control unit obtains the address range as LBA 21-LBA50, then the control unit retrieves 30 entries from LBA 21 to LBA50 in the L2P table. Furthermore, the control unit retrieves one entry from the L2P table at a time based on one address index.

[0064] Step 530: Determine if the address recorded in the L2P table entry is valid. Continuing with the previous example, specifically, the control unit checks each of the 30 corresponding L2P entries from logical addresses LBA 21 to LBA 50 in the L2P table to see if the address recorded in these 30 entries is valid. Specifically, the control unit performs this check once for each entry.

[0065] If the result is negative, return to step 520 to continue determining whether the address recorded in the next L2P entry is valid. If the result is positive, execute step 540 to mark the bitmap of the corresponding address space with the address used. Figure 5C A schematic diagram illustrating a bitmap provided in an embodiment of this application is shown. See also... Figure 5C This bitmap includes valid element information corresponding to six addresses: LBA0, LBA2, LBA3, and LBA5. Specifically, LBA0, LBA2, LBA3, and LBA5 correspond to valid elements, while LBA1 and LBA4 correspond to invalid elements; alternatively, LBA0, LBA2, LBA3, and LBA5 correspond to invalid elements, while LBA1 and LBA4 correspond to valid elements.

[0066] The generated bitmap consists of multiple bits, each corresponding to an element of the address space range indicated by the read address space attribute command. For example, for the address space range of logical addresses LBA 21 to LBA 50, the generated bitmap consists of 30 bits, with each bit's value sequentially indicating one of the logical addresses within that address space range.

[0067] Optionally, before executing step 540, the bitmap records either all valid elements or all invalid elements. For example, before executing step 540, the bitmap records either all 0s or all 1s. Or, for example, the bitmap before executing step 540 might be... Figure 5C "101101" shown.

[0068] Optionally, during step 540, each execution of step 540 modifies one bit in the bitmap. After executing step 540, the process returns to step 520, and steps 520-540 are executed repeatedly until the bitmap corresponding to the address range is updated. In other embodiments, during step 540, multiple or all bits in the bitmap corresponding to the address range are updated. After executing step 540, step 550 is then executed.

[0069] Step 550: Respond to the read address space attribute command with a bitmap corresponding to the address space. After obtaining the latest bitmap corresponding to the address range, the control unit sends the bitmap back to the host as a response to the read address space attribute command.

[0070] In this embodiment, the host sends a read address space attribute command to the control unit. Upon receiving the read address space attribute command, the control unit generates a bitmap based on the L2P table and uses the bitmap as a response to the read address space attribute command.

[0071] Another embodiment of this application provides a further method for obtaining address space attributes, applied to a host, comprising: sending a read address space attribute command to a control unit, the read address space attribute command being used to obtain at least one attribute of an address or a segment of address space; receiving first data fed back by the control unit, the first data corresponding to at least one attribute indicated by the read address space attribute command. Optionally, the attributes in this embodiment include valid elements, valid element ratio, continuous data block size, randomness, and time variation values ​​of each attribute. Optionally, the address indicated by the read address space attribute command or the address carried by the read address space attribute command is a logical address or a physical address.

[0072] For example, the `read address space attributes` command is used to obtain the size of a contiguous data block starting at LBA 52, or the size of the largest contiguous data block within a specified address space range. Another example is using the `read address space attributes` command to obtain the percentage of valid elements and the randomness within the range LBA 52-LBA 103. Yet another example is using the `read address space attributes` command to obtain the change in the randomness of valid elements within the LBA 128-256 range over time within a first time period.

[0073] In an optional implementation, the control unit provides an address space attribute table to facilitate the processing of read address space attribute commands. The control unit generates and maintains the address space attribute table, which may be as shown in Tables 1 and 2. The first data is part or all of the address space attribute table; or, the first data is at least one attribute required by the read address space attribute command. In this embodiment, the first data fed back by the control unit may be the address space attribute table, a part (one or more entries) of the address space attribute table, or the first data may be an attribute obtained from the address space attribute table. Optionally, the method by which the control unit generates the address space attribute table can be referred to in the previous embodiment. Figure 5B The method shown involves the control unit generating an address space attribute table upon receiving an instruction to read the address space attributes. Alternatively, the control unit is configured to pre-generate and continuously maintain the address space attribute table. For example, the control unit of a storage device generates the address space attribute table before the storage device leaves the factory and updates the address space attribute table upon receiving an access command (read command and / or write command). Further optionally, the control unit updates the address space attribute table upon receiving an instruction to read the address space attribute table.

[0074] Table 1

[0075] Table 1 illustrates an address space attribute table. The address space attribute table in Table 1 includes multiple entries, each indexed by an LBA, and each entry is, for example, 1 bit in size.

[0076] Table 1 records whether the address indices LBA 100-LBA 107 correspond to valid elements. Taking "1" as valid as an example, Table 1 indicates that there are 4 logical addresses storing valid elements.

[0077] In one implementation, the control unit retrieves the entry corresponding to the address index in the address space attribute table based on the address index of the read address space attribute command. Alternatively, the control unit retrieves the address space attribute table (all entries) corresponding to the address index of the read address space attribute command. For example, if the read address space attribute command indicates the retrieval of valid elements in the range LBA 102-LBA 105, the control unit retrieves the four entries corresponding to LBA 102-LBA 105 in Table 1 and sends these four entries back to the host. As another example, if the read address space attribute command indicates the retrieval of valid elements in the range LBA 100-LBA 107, the control unit retrieves all entries in Table 1 and sends these eight entries back to the host. Yet another example, if the read address space attribute command indicates the retrieval of valid elements in the range LBA 102-LBA 105, the control unit parses the address index of the read address space attribute command as belonging to Table 1, thereby retrieving all entries from Table 1 and sending these eight entries back to the host.

[0078] In another implementation, when the first data is at least one attribute required by the read address space attribute command, the control unit obtains the required at least one attribute according to the address space attribute table. For example, if the read address space attribute command instructs the acquisition of valid elements and randomness corresponding to LBA100-LBA107, the control unit reads all entries in the address space attribute table in Table 1 to obtain the valid elements required by the read address space attribute command. The control unit calculates the randomness according to all entries in Table 1, thereby obtaining the randomness. The method of calculating the randomness can be found in the prior art and is not limited here. The control unit feeds back the acquired valid elements and randomness to the host as a response to the read address space attribute command.

[0079] Table 2

[0080] Table 2 shows another address space attribute table. As shown in Table 2, in addition to the valid elements corresponding to LBA 108-LBA115, Table 2 also includes three attributes: the size of the corresponding contiguous data block and the percentage of valid elements.

[0081] In one implementation, when the first data is part or all of the address space attribute table, the control unit retrieves the entry in the address space attribute table corresponding to the address index of the read address space attribute command. Alternatively, the control unit retrieves the address space attribute table (all entries) corresponding to the address index of the read address space attribute command. When the address space attribute table is, for example, the address space attribute table in Table 2, the control unit responds to the read address space attribute command by reading part or all of the entries in the address space attribute table as feedback. The method for reading the entries can be found in the description of the above embodiments and will not be elaborated here.

[0082] In another implementation, when the first data is at least one attribute required by the read address space attribute command, the control unit obtains the required at least one attribute according to the address space attribute table. When the address space attribute table is, for example, the address space attribute table in Table 2, the control unit can directly read at least one attribute from the address space attribute table. For example, the control unit reads that the size of the consecutive data blocks in LBA 108-LBA 114 is "1113" or "3" (the maximum number of consecutive data blocks within that LBA range).

[0083] Furthermore, if the first data is part or all of the address space attribute table, and the address space attribute table represents whether each address in the address space corresponds to a valid element (i.e., the address space attribute table is as shown in Table 1), then after receiving the first data, the host processes the first data to obtain at least one attribute.

[0084] Figure 6A A block diagram of a control component is shown. Figure 6A The control unit includes a host interface, a host command processing unit, a storage command processing unit, a media interface controller, and a storage media management unit. The media interface controller is coupled to the NVM chip, and the control unit receives read address space attribute commands sent by the host through the host interface. The host command processing unit parses the read address space attribute commands and generates commands suitable for the storage command processing unit. In response to receiving a command, the storage command processing unit either operates the media interface controller to access the NVM chip or operates the storage media management unit to maintain the L2P table and the address space attribute table. In this embodiment, the storage media management unit maintains both the L2P table and the address space attribute table.

[0085] This application provides another method for obtaining address space attributes, applied to a control component, comprising: receiving a read address space attribute command sent by a host, the read address space attribute command being used to read at least one attribute of an address or a segment of address space; accessing an address space attribute table according to the read address space attribute command to obtain first data, the first data corresponding to at least one attribute indicated by the read address space attribute command, the address space attribute table representing whether each address in the address space corresponds to a valid element; and feeding back the first data to the host.

[0086] Optionally, the address indicated by the read address space attributes command is a logical address.

[0087] Optionally, in response to a read address space attribute command, a first address index is obtained based on the address carried by the read address space attribute command. Based on the first address index, first data is obtained from the address space attribute table, where the first data is part or all of the address space attribute table. In this embodiment, the address indicated by the read address space attribute command is the address index of the address space attribute table, which is the logical address. Alternatively, the address indicated by the read address space attribute command may not be the address index of the address space attribute table; in this case, the control unit still needs to obtain the address index based on the address carried by the command.

[0088] Optionally, the control unit reads second data from the address space attribute table; that is, the second data is an entry in the address space attribute table. The control unit compresses the second data to obtain the first data, which is the compressed data obtained from the address space attribute table entries. This further reduces the amount of data that the control unit sends back to the host, thereby reducing data transmission time. In some cases, compressing the second data is beneficial. For example, when the number of 0s and 1s in the address space attribute table is significantly unbalanced, compression can significantly reduce the data size. Again, as an example, when the number of 0s and 1s in the second data is significantly unbalanced (e.g., the number of 0s is significantly less than 1s), transmitting only the data containing 0s and their positions (indexes) in the address space attribute table can also significantly reduce the size of the data to be transmitted.

[0089] In other embodiments, in response to a read address space attribute command, the control unit obtains a first address index based on the address carried by the read address space attribute command. The control unit then reads several valid elements from the address space attribute table based on the first address index. The control unit processes these valid elements according to the attributes indicated by the read address space attribute command to obtain first data, where the first data represents the attributes required by the read address space attribute command. The method of obtaining the address index in this embodiment can be found in the description of the above embodiments and will not be elaborated here. In this embodiment, the control unit does not directly return entries from the address space attribute table or the data recorded in the address space attribute table; instead, it processes the valid elements to obtain the first data, thereby reducing the load on the host.

[0090] Figure 6B A flowchart illustrating the method for updating the address space attribute table is provided.

[0091] Step 610: Receive an update address space attribute command. In this embodiment, the update address space attribute command instructs the control unit to update the address space attribute table.

[0092] Step 620: Obtain one or more logical address ranges indicated by the update address space attribute command. After receiving the update address space attribute command, the control unit parses the command to obtain at least one logical address range. It should be noted that a logical address range includes one or more logical addresses.

[0093] Step 630: Update the entries in the address space attribute table corresponding to (one or more) logical addresses. The control unit updates the entries in the address space attribute table corresponding to at least one logical address range. In this embodiment, the update address space attribute command does not necessarily indicate the update value of the entry. For example, when the address space attribute table is the address space attribute table shown in Table 1, since the recorded entry value is 0 or 1, the control unit only needs to adjust the entry to be updated between these two values.

[0094] Optionally, in step 640, the entries in the L2P table corresponding to one or more logical addresses are cleared or set to a specified value. In this embodiment, after maintaining the address space attribute table, the control unit also updates the L2P table, which includes clearing the entries or modifying them to a specified value. The specified value is the physical address.

[0095] By using the update address space attribute command, the host can indicate to the storage device that one or more logical address ranges of attributes are invalid.

[0096] According to embodiments of this application, due to the existence of the address space attribute table, entries in the L2P table may not reflect the attributes of the latest logical address space. For example, see also... Figure 6B After step 630 is completed but before step 640 is completed, the address space attribute table has been updated, but the L2P table has not yet been updated. At this point, some data recorded in the L2P table is outdated. Therefore, to correctly process read commands, the read command processing procedure needs to be adjusted. See also... Figure 7A .

[0097] Figure 7A A flowchart illustrating a method for processing read commands according to an embodiment of this application is shown. The following describes the execution of the control unit. Figure 7A The process will be described using the example of [the process described in the original text].

[0098] Step 710, Read command received. The control unit receives a read command sent by the host, which instructs the control unit to access the NVM chip and read data.

[0099] Step 712: Determine whether the read logical address corresponds to a valid element. For example, the control unit reads the "valid element" attribute from the address space attribute table. For example, the control unit accesses the address space attribute table based on LBA 512-LBA 520 to determine whether LBA 512-LBA 520 correspond to a valid element. If the determination result is negative, proceed to step 714. If the determination result is positive, proceed to step 716. Optionally, in this embodiment, the determination of whether the logical address is valid is performed using the address space attribute table. In this embodiment, by determining whether the logical address is valid in advance, cases corresponding to invalid physical addresses or without corresponding physical addresses are excluded, thereby reducing the probability of data reading failure or data reading errors, thus reducing the time required to read data, and also avoiding errors introduced by inconsistencies between the address space attribute table and the L2P table.

[0100] Step 714: Respond to the read command with, for example, all zeros or a specified value. Using all zeros as a response to the read command not only ensures smooth processing of the read command but also informs the host that a certain LBA cannot currently read valid data.

[0101] For example, the logical addresses carried by the read command are LBA 512-LBA 520. In step 712, if LBA 512 is found to be invalid while other LBAs are valid, then step 714 is executed for LBA 512, and step 716 is executed for other valid LBAs to complete the processing of the read command.

[0102] Step 716: Query the L2P table to obtain the physical address corresponding to the logical address to be read. If the judgment result is yes, the control unit queries the L2P table according to each valid LBA in LBA 512-LBA 520 to obtain the physical address corresponding to the valid LBA.

[0103] Step 718: Read data from the physical address as a response to the read command. The control unit accesses the NVM chip based on the obtained physical address and reads the data.

[0104] The control unit feeds back the read data to the host as a response to the read command.

[0105] Figure 7B A flowchart illustrating a method for processing write commands according to an embodiment of this application is shown. The following describes the execution of the control unit. Figure 7B The process will be described using the example of [the process described in the original text].

[0106] Step 720, Write command received. The control unit receives the write command sent by the host.

[0107] Step 722: Allocate a physical address for the write command and update the L2P table. The control unit obtains the write command instruction or the logical address it carries, and allocates a physical address for that logical address. After allocating a physical address for the logical address, the control unit needs to maintain the L2P table, thereby updating the L2P table according to the correspondence between the logical address and the allocated physical address.

[0108] Step 724: Write data to the physical address and send back a write command processing completion message. The control unit accesses the NVM chip based on the physical address, writes the data to that physical address, and sends a write command processing completion message back to the host.

[0109] Step 726: Update the address space attribute table. In this embodiment, the control unit also updates the address space attribute table according to the correspondence between logical addresses and physical addresses. In response to a write command writing data to, for example, LBA 100, the attributes of the address space indicated by LBA 100 are valid. In response to writing data to LBA 100 again, the attributes of the address space indicated by LBA 100 remain valid.

[0110] The read address space attribute command and optional address space attribute table provided in the embodiments of this application enhance the processing capabilities of the storage device. In some applications, this can significantly enhance processing capabilities or reduce processing complexity. Combined with... Figures 8 to 12 It provides several application commands for reading address space attributes, as well as examples of optional address space attribute tables.

[0111] Figure 8 This document illustrates a flowchart of a method for backing up or creating an image of a storage device, as provided in an embodiment of this application. Backing up or creating an image of a storage device requires not only acquiring all (valid) data recorded in the storage device, but also writing the corresponding data to a new storage device at the same addresses as the valid data's locations (addresses) within the storage device. According to an embodiment of this application, by using the read address space attribute command, all addresses (logical addresses) containing valid data in the storage device can be easily and quickly acquired. Then, data is read from these addresses and written to the new storage device at the same addresses to complete the data backup. This data backup also achieves the creation of an image of the storage device. Although the created image does not include data corresponding to invalid addresses in the original storage device, the created image is semantically equivalent to the original storage device because invalid data will not and should not be accessed again.

[0112] Step 810: Use the read address space attributes command to obtain all valid elements of the complete address space of the storage device.

[0113] Step 820: Read data from the storage device according to the logical addresses corresponding to all valid elements.

[0114] Step 830: Write the read data to the same logical address of the backup storage device.

[0115] The following description uses a control component as an example. Figure 8 The process in the middle.

[0116] To perform data backup, the host first issues a read address space attribute command to the storage device, specifying the accessed address range as the complete address space of the storage device. After receiving the read address space attribute command, the control unit obtains all valid elements of the storage device's complete address space according to the command's instructions. Optionally, the control unit traverses the L2P table to obtain all valid elements of the storage device's address space. Still optionally, the control unit obtains all valid elements of the address space by reading the address space attribute table.

[0117] Understandably, the valid elements of a storage device's address space are not the same as the valid space used by the file system managing that address space. Rather, the set of valid elements in the storage device's address space is a superset of the valid space used by the corresponding file system. The file system may delete some address space elements, but this "deletion" operation may not be known to the storage device. This data, deleted by the "host" but not garbage collected, also belongs to the "all valid elements of the complete address space" in this application. Even so, the total number of valid elements in the address space obtained through the read address space attribute command can still generally be smaller than the total number of elements in the storage device's complete address space, thereby reducing the amount of data that needs to be read from the storage device and moved to a new storage device during data backup.

[0118] According to one implementation, the control unit uses a read address space attribute command to obtain third data. This third data is part or all of an address space attribute table, which indicates whether each address in the address space corresponds to a valid element. The third data obtained by the control unit corresponds to the address of a valid element. The control unit further accesses the storage device based on multiple logical addresses corresponding to the third data, thereby reading all the data to be backed up. The control unit writes all the data to be backed up into a second storage device, thus completing the data backup. In this embodiment, the data written to the backup storage device, i.e., the data in the second storage device, has the same logical address as the data in the first storage device.

[0119] Optionally, the control unit writes the data to be backed up into the second storage device according to the correspondence between valid elements and logical addresses, so that the correspondence between the backup data and logical addresses in the second storage device is the same as the correspondence between the valid elements and logical addresses.

[0120] This application provides another method for backing up or creating a mirror of a storage device, comprising: a host sending a first read address space attribute command to a control unit, the first read address space attribute command being used to read valid elements of the complete address space of the storage device. In response to the first read address space attribute command, the control unit feeds back first data to the host, the first data indicating all valid addresses in the complete address space of the storage device. The first data may be in the form of, for example, the entire address space attribute table, or a compressed address space attribute table, or a bitmap generated based on the L2P field indicating whether each address in the address space is valid, or a set of valid addresses. The host obtains all valid addresses in the complete address space of the storage device to be backed up based on the address data. The host then reads the data corresponding to the valid addresses from the storage device based on all valid addresses in the complete address space of the storage device to be backed up, and writes the data to a new storage device according to the valid addresses and their corresponding data, thereby making the new storage device a backup or mirror of the original storage device.

[0121] According to embodiments of this application, the read address space attribute command is also used to identify fragmentation of the storage device. The fragmentation distribution of the storage device can be used to determine whether disk defragmentation of the storage device is necessary. See also [link to previous document] for details on identifying storage device fragmentation using a read address space attribute command that indicates the randomness of obtaining a first address space. Figure 9 .

[0122] When the first read address space attribute command indicates that the randomness of the first address space should be obtained, in response to the first read address space attribute command, the second address space in the first address space with a randomness greater than a preset threshold should be obtained; the valid elements in the second address space should be obtained; and the second address space should be marked according to the valid elements in the second address space.

[0123] Figure 9 A flowchart illustrating a fragmented data organization method provided in an embodiment of this application is shown.

[0124] Step 910: Use the read address space attributes command to obtain the randomness of the specified address space.

[0125] Step 920: Obtain the range of address spaces with a randomness greater than the threshold.

[0126] Step 930: Use the read address space attribute command to obtain the valid elements of the address space range.

[0127] Step 940: Identify the fragments of the address space range based on the valid elements.

[0128] According to embodiments of this application, the host identifies fragmentation on the storage device by issuing, for example, two read address space attribute commands to the storage device. The first read address space attribute command obtains the randomness attribute of the address space, classifying address spaces with randomness exceeding a threshold as fragmented. The second read address space attribute command obtains valid elements of the address space to distinguish valid data from invalid data within the fragments, facilitating defragmentation. For example, in response to a read address space attribute command instructing the acquisition of randomness, the control unit acquires the randomness of a specified logical address range according to the read address space attribute command.

[0129] Optionally, the host-provided read address space attribute command may also indicate a threshold or indicate the use of a preset threshold. For example, if the threshold is 0.5, the control unit obtains several logical addresses (a total of N logical addresses) corresponding to randomness values ​​greater than 0.5 within the specified logical address range. The control unit obtains the valid elements from these N logical addresses and provides them to the host, which uses these valid elements to mark fragments in the storage device. For example, if the logical address range is LBA 77-LBA88, and the randomness of this logical address space is greater than 0.5, the control unit obtains the valid element "010101001101" corresponding to LBA 77-LBA 88. The control unit uses the "1" in "010101001101" to mark the corresponding valid logical address, and the finally marked fragments are LBA 78, LBA 80, LBA 82, LBA 85, LBA86, and LBA88. Optionally, the control unit may also feed back the addresses corresponding to the marked fragments to the host. For example, the control unit feeds back LBA 78, LBA 80, LBA 82, LBA85, LBA86, and LBA88 to the host. Optionally, the control unit feeds back the tagged address to the host to indicate the status of the fragmented data in the host or storage device, thereby enabling further operation.

[0130] Using the command to read address space attributes can also help back up the address space attribute table of the storage device with the participation of the host. Similar to the L2P table, the address space attribute table is also important metadata for the storage device. Before shutting down the storage device, the address space attribute table needs to be backed up so that the storage device can function normally after the next power-on.

[0131] Figure 10 This application provides a method for storing an address space attribute table upon power-off, according to an embodiment of the present application.

[0132] like Figure 10As shown, the host sends a read address space attribute command, i.e., step 1010, to obtain all valid elements of the complete address space. In this embodiment, the control unit obtains all entries of the address space attribute table according to the read address space attribute command, thereby obtaining all valid elements of the complete address space.

[0133] Step 1020: Store the valid elements of the acquired complete address space. The control unit feeds back all entries of the address space attribute table to the host, which stores them. This prevents the address space attribute table from being lost when the control unit is powered off, and eliminates the need to regenerate the address space attributes based on the L2P table when the control unit is powered on. It should be noted that in this embodiment, the host does not necessarily need to store the address space attribute table internally; optionally, the host can store the address space attribute table on other storage devices.

[0134] Figure 11 The flowchart illustrates a method for identifying whether a read command belongs to a sequential stream, as provided in an embodiment of this application.

[0135] Step 1110: Obtain the read command. The control unit obtains the read command sent by the host and parses the read command.

[0136] Step 1120: Determine whether the read command belongs to a sequential stream read command. In step 1120, methods such as those in the prior art can be used to determine whether the read command belongs to a sequential stream. The control unit determines whether the read command belongs to a sequential stream read command. If the determination result is no, step 1130 is executed to mark the read command as belonging to a non-sequential stream. If the determination result is yes, step 1140 is executed to obtain the randomness of the address space accessed by the read command. The randomness of the address space accessed by the read command is obtained using, for example, an address space attribute table. Step 1150 is further executed to determine whether the randomness is greater than a threshold. If the current determination result is yes, step 1130 is executed. If the current determination result is no, step 1160 is executed to mark the read command as belonging to a sequential stream.

[0137] This embodiment improves the accuracy of judgment by determining whether a read command belongs to a sequential stream read command again based on randomness, thereby achieving accurate identification of sequential streams. Since the processing time required for subsequent sequential stream read commands and non-sequential stream read commands differs, accurate classification of read commands can effectively reduce the total processing time when processing a large number of read commands.

[0138] Figure 12 A flowchart illustrating the method for processing read commands using a cache, as provided in an embodiment of this application, is shown.

[0139] The address space attribute table provided in this application also helps to effectively identify whether to allocate cache for read commands. In storage devices, cache is a scarce resource. It is desirable to allocate cache to a small number of read commands whose accessed data is likely to be accessed again in a short period of time. The randomness variation of the address space provides auxiliary information for cache allocation. The degree of randomness variation in the address space indicates the degree to which that address space is updated. Frequently updated data is not suitable for caching in read commands because the cached data may quickly become invalid. Frequently updated data is suitable for caching in write commands because multiple updates can be merged before writing to the NVM storage medium, thereby reducing write operations to the NVM.

[0140] Step 1210: Obtain the read command. The control unit obtains the read command sent by the host, parses the read command, and obtains the address indicated by the read command.

[0141] Step 1220: Determine if the address hits the cache. The control unit determines whether the address indicated by the read command hits the cache. If the cache is hit, it means that the data to be read by this read command is already in the cache, which is the cache within the control unit. If the cache is not hit, it means that this read command needs to read data from the NVM chip.

[0142] Step 1231: Obtain the randomness change of the address space accessed by the read command. In this embodiment, the control unit also obtains the attribute of the randomness change of the address indicated by the read command.

[0143] Step 1232: Read data from NVM in response to the read command. It's important to note that steps 1231 and 1232 are not executed in any particular order. After step 1232, the host side has completed processing the read command, but the control unit still needs to execute the remaining steps.

[0144] Step 1240: Retrieve data from the cache in response to the read command. If the cache is hit, the control unit will read the data from the cache and respond to the read command.

[0145] Step 1250: Determine if the randomness change exceeds a threshold. The control unit further determines if the randomness change of the address space accessed by the read command exceeds a preset threshold. If it does not exceed the preset threshold, it indicates that the address space accessed by the read command is not frequently updated. Cache the data of the current read command, which helps to hit the cache when subsequent read commands also access this address space. Therefore, step 1260 is executed to retain the cache used by the read command. Thus, the control unit does not need to reallocate the cache the next time this address space is accessed, saving time. If the randomness change exceeds the preset threshold in step 1250, step 1270 is executed to release the cache used by the read command. When the randomness change exceeds the preset threshold, it means that this address space is frequently updated, causing the (old) data in the cache to become invalid and the cached data to be unusable for responding to subsequent read commands. Therefore, the control unit does not need to retain the cache for this address space and can release the cache for other tasks, thereby improving the utilization of cache resources.

[0146] It should be noted that, for the sake of brevity, this application describes some methods and their embodiments as a series of actions and combinations thereof. However, those skilled in the art will understand that the solution of this application is not limited to the order of the described actions. Therefore, based on the disclosure or teachings of this application, those skilled in the art will understand that some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art will understand that the embodiments described in this application can be considered as optional embodiments, that is, the actions or modules involved are not necessarily essential for the implementation of one or more solutions of this application. In addition, depending on the solution, the description of some embodiments in this application also has different emphases. In view of this, those skilled in the art will understand that parts not described in detail in a certain embodiment of this application can also be referred to the relevant descriptions of other embodiments.

[0147] In terms of specific implementation, based on the disclosure and teachings of this application, those skilled in the art will understand that the several embodiments disclosed in this application can also be implemented in other ways not disclosed herein. For example, regarding the various units in the electronic device or device embodiments described above, this document has divided them based on logical functions, but in actual implementation, there may be other ways of division. As another example, multiple units or components can be combined or integrated into another system, or some features or functions in a unit or component can be selectively disabled. Regarding the connection relationship between different units or components, the connection discussed above in conjunction with the accompanying drawings can be a direct or indirect coupling between units or components. In some scenarios, the aforementioned direct or indirect coupling involves a communication connection utilizing an interface, wherein the communication interface can support electrical, optical, acoustic, magnetic, or other forms of signal transmission.

[0148] Although the examples referenced in this application are described for illustrative purposes only and not for limiting the scope of this application, changes, additions and / or deletions to the implementation may be made without departing from the scope of this application.

[0149] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for identifying whether a read command in a storage device belongs to a sequential stream, characterized in that, The storage device includes an address space attribute table, and the method includes: The control unit receives the first read command sent by the host; In response to the first read command, the control unit determines whether the first read command is a sequential stream read command based on the first address space indicated by the first read command; When the condition is met, the control unit obtains the randomness of the first address space from the address space attribute table; The control unit determines again whether the first read command is a sequential read command based on the randomness of the first address space.

2. The method as described in claim 1, characterized in that, in, The control unit determines whether the randomness of the first address space is greater than a threshold. When the condition is met, the control unit marks the first read command as not belonging to a sequential stream read command.

3. The method as described in claim 1 or 2, characterized in that, in, If any judgment result is negative, the control unit marks the first read command as a sequential stream read command.

4. A method for processing read commands using a cache in a storage device, characterized in that, The storage device includes an address space attribute table, and the method includes: The control unit receives the second read command sent by the host; In response to the second read command, the control unit determines whether the second address space indicated by the second read command hits the first cache; If not, the control unit retrieves the second read data from the storage medium and moves the second read data to the second cache; the control unit then feeds back the second read data to the host. The control unit also obtains the randomness variation of the second address space from the address space attribute table; The control component determines whether the change in randomness is greater than a preset threshold. When the randomness change exceeds a preset threshold, the control component sends the second read data back to the host and then releases the second cache.

5. The method as described in claim 4, characterized in that, in, When the change in randomness is less than a preset threshold, the control component feeds back the second read data to the host and then retains the second cache.

6. The method as described in claim 4 or 5, characterized in that, in, When the second address space indicated by the second read command hits the first cache, the control unit retrieves the first read data from the first cache; The control unit feeds back the first read data to the host computer.

7. A method for organizing fragmented data, characterized in that, include: Use the first read address space attribute command to obtain the randomness of the specified address space; Obtain the address space range where the randomness is greater than a threshold; Use the second read address space attribute command to obtain the valid elements of the address space range; Fragmentation is performed by identifying fragments within the address space range based on valid element identifiers, in order to distinguish between valid and invalid data within the fragments.

8. The method as described in claim 7, characterized in that, Also includes: The control unit will send the address corresponding to the marked fragment back to the host.

9. A storage system, characterized in that, It includes a host, a control unit, and a storage medium; wherein, the control unit maintains an L2P table and an address space attribute table, and the address space attribute table indicates whether each address in the address space corresponds to a valid element; The storage system performs the method as described in any one of claims 1-8.