A document management method and related equipment
By calculating the dispersion of file physical addresses in flash memory on the host side and reorganizing the file physical addresses, the problems of file fragmentation and reduced read performance in flash memory are solved, thereby improving the read performance and working efficiency of storage devices.
Patent Information
- Application Number
- CN202011557065.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2040-12-24
AI Technical Summary
In existing technologies, flash memory suffers from file fragmentation and reduced read performance after off-site data updates and garbage collection, making it impossible to effectively manage the physical address distribution of files.
By calculating the physical address dispersion of files on the host side and utilizing the mapping relationship between the host and storage devices, the physical addresses of files are reorganized to achieve contiguous storage and reduce fragmentation.
It improves the read performance of storage devices, reduces wear and tear on storage devices caused by frequent file defragmentation, and improves the working efficiency of the host and storage devices.
Smart Images

Figure CN114676092B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of flash memory storage technology, and in particular to a file management method and related equipment. Background Technology
[0002] With the continuous development of storage technology, flash memory, using NAND flash memory as its storage medium, has gradually become the mainstream storage form. The storage mechanism of NAND flash memory is to store data by controlling the number of electrons in transistors through gate voltage. Typically, NAND flash memory is read and written in units of pages and erased in units of blocks. Due to the nature of flash memory, the data in a block must be erased before the pages in the erased block can be programmed.
[0003] In one scenario, a block is designated to store data for a file. If some data within this block is updated, while the rest remains unchanged, two approaches can be taken. One approach is to move all data (including modified data) from the block into a new block, ensuring contiguous physical block addresses (PBAs) for easier subsequent data retrieval. However, this method incurs significant additional programming and reduces the lifespan of the storage device. Another approach involves introducing a Flash Translation Layer (FTL). The FTL maps logical addresses to physical addresses stored in the storage device. The host manages only the logical block addresses (LBAs), while the physical addresses are managed by the firmware within the storage device. When data content changes, the logical addresses remain the same; only the physical addresses within the storage device change. This means the modified data is stored in a new block, enabling off-site data updates. However, this off-site updating not only leads to file fragmentation but also results in the storage device being unused.
[0004] To address the issues arising from off-site data updates, existing technologies employ periodic garbage collection (GC) operations. This involves moving valid data from blocks with a high proportion of invalid data to new blocks, creating new empty blocks and increasing the number of usable valid blocks. However, in practice, garbage collection moves data to new blocks sequentially according to the order of valid data in the current block. This results in an unordered distribution of data in the physical address space of the garbage-collected file. Consequently, data can only be accessed discretely during file reading, reducing the read performance of the storage device.
[0005] Therefore, how to effectively manage files stored on storage devices is an urgent problem to be solved. Summary of the Invention
[0006] This invention provides a file management method and related equipment to effectively manage files stored on storage devices.
[0007] In a first aspect, embodiments of the present invention provide a file management method, characterized in that it is applied to a host, the method comprising: determining a first logical address range of a target file set; the target file set comprising M target files; M being an integer greater than 0; sending a first instruction to a storage device; the first instruction comprising the first logical address range; receiving logical-physical address mapping information sent by the storage device; the logical-physical address mapping information comprising a mapping relationship between the first logical address range and a first physical address; calculating the physical address dispersion of the M target files according to the mapping relationship; and determining files to be organized based on the physical address dispersion of the M target files.
[0008] In existing technologies, on the one hand, the host's file system can only perceive the logical address of a file, but cannot perceive the distribution of the physical addresses corresponding to the logical addresses in the storage device. Therefore, the host cannot calculate the dispersion of the physical addresses of files, resulting in the host's inability to actively manage the physical addresses of files. On the other hand, since the storage device can only perceive the mapping relationship between a certain logical address and a physical address, but cannot perceive the logical address range corresponding to a certain file, it also cannot perceive the physical addresses corresponding to the logical address range of the file. Therefore, after garbage collection operations are performed on the storage device side, it cannot be guaranteed that the data of the file exists in the storage device with continuous physical addresses, which will reduce the read performance of the storage device. By implementing the method provided by this invention, the host can obtain the mapping relationship between the logical address and the physical address of a file or file fragment, and then calculate the dispersion of the physical address of the file or file fragment based on the mapping relationship between the logical address and the physical address of each file or file fragment, thereby determining the files that need to be defragmented, and thus realizing the management of the physical addresses of files or file fragments. Specifically, the host obtains frequently accessed files or file fragments as target files and adds the target files to a target file set, which may include one or more target files. Next, the host determines a first logical address range based on the target file set. Then, the host sends an instruction to the storage device containing this first logical address range. This instruction instructs the storage device to send the mapping relationship between the logical and physical addresses of the target file set. After receiving the mapping relationship from the storage device, the host can calculate the physical address dispersion of each target file based on this mapping relationship, thereby identifying the files that need defragmentation and managing their physical addresses accordingly. Since the host's computing power is far greater than that of the storage device, the host can calculate the physical address dispersion of the target files much faster. Furthermore, the host can handle multiple tasks simultaneously, while the storage device can only handle one task at a time (e.g., the storage device cannot receive messages from the host while performing calculations). Therefore, the method provided by this invention allows the host to calculate the physical address dispersion of files or file fragments more quickly after obtaining the mapping relationship between the logical and physical addresses of the files or file fragments. This enables the host to actively manage the physical addresses of files or file fragments without affecting the normal operation of the storage device.
[0009] In one possible implementation, M is greater than 1; determining the first logical address range of the target file set includes: obtaining the logical address range of each target file based on the node information of each target file in the M target files; merging the logical address ranges of each target file to obtain the first logical address range; the node information includes the logical address information of the corresponding target file.
[0010] In this embodiment of the invention, when the target file set includes multiple target files, the host can obtain the corresponding logical address range based on the node information corresponding to each target file. Then, the host can merge multiple logical address ranges to obtain a first logical address range. In this case, the host only needs to send an instruction including the first logical address range to the storage device once to obtain the mapping relationship between the logical addresses and physical addresses of multiple target files, instead of sending the logical address range of each target file individually. This reduces the number of communications between the host and the storage device, improving the host's efficiency. Simultaneously, since the storage device can only execute one task at a time (e.g., the storage device cannot receive messages sent by the host while performing calculations), if the host sends an instruction including the logical address range of each target file to the storage device individually, especially when the number of target files is large, it will consume a significant amount of the storage device's time to receive the logical address ranges sent by the host. This may lead to malfunctions in the storage device. Therefore, implementing the method provided by this invention can also improve the efficiency of the storage device and prevent malfunctions.
[0011] In one possible implementation, the first instruction is an HPB Read Buffer instruction; sending the first instruction to the storage device includes: sending the HPB Read Buffer instruction to the storage device when M is greater than a preset threshold for the number of target files.
[0012] In this embodiment of the invention, the aforementioned threshold is preset. When the number of files in the target file set reaches this threshold, the host sends an HPB Read Buffer instruction to the storage device. This instruction includes the aforementioned first logical address range. Unlike existing technologies, by sending this instruction to the storage device, the host can instruct the storage device to find the mapping relationship between the first logical address range and its physical address, and can also instruct the storage device to send this mapping relationship to the host. This improves the host's efficiency, and the host can also obtain the mapping relationship between the logical addresses and physical addresses of multiple target files from the storage device through this instruction, facilitating subsequent calculation of the physical address dispersion of each target file.
[0013] In one possible implementation, the method further includes: adding the logical address of the file to be sorted to an update list; the file to be sorted is a target file among the M target files whose physical address dispersion exceeds a threshold.
[0014] In this embodiment of the invention, when the host receives the logical-physical address mapping information sent by the storage device, since the information includes a mapping relationship between a first logical address range and a first physical address, the host calculates the physical address dispersion of each target file according to the mapping relationship. Simultaneously, a physical address dispersion threshold can be preset. If the physical address dispersion of a target file exceeds the threshold, the target file is added to the update list as a file to be processed, indicating that the physical address dispersion of the target file is high and its physical address needs to be reprocessed. If the physical address dispersion of a target file does not exceed the threshold, it means that the physical address dispersion of the target file is not high enough and its physical address does not need to be processed temporarily. This improves the working efficiency of the host and the storage device.
[0015] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the method further includes: when N is greater than a minimum threshold L for the number of files to be organized, reading the data of the N files to be organized from the storage device into the host memory, where L is an integer greater than 0; and rewriting the data of the N files to be organized into the storage device according to the logical address of each file to be organized.
[0016] In this embodiment of the invention, when a certain number of files to be organized accumulate in the update list, the host can read the data of each file to be organized from the storage device, and then rewrite the corresponding file data to be organized back into the storage device according to the logical address of each file. The rewritten data is then stored sequentially in blocks of the storage device. For example, in one case, the data of a file is stored in only one block, so the physical addresses of this file are contiguous. In another case, if the data of a file needs to be stored in different blocks, but the data of that file in each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of files to be organized into contiguous physical addresses can be reduced, decreasing the degree of file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device. Simultaneously, it can reduce the increased wear and tear on the storage device caused by excessively frequent file organization (data migration).
[0017] In one possible implementation, reading the data of the N files to be organized from the storage device into the host memory includes: sending an HPB Read command to the storage device; the HPB Read command includes the logical address and physical address of the N files to be organized; or, sending a Read command to the storage device; the Read command includes the logical address of the N files to be organized.
[0018] In this embodiment of the invention, when a host needs to read data from a file to be processed from a storage device, in one possible implementation, the host can read the data by sending an HPB Read command to the storage device. Since this command includes the logical address and physical address of the file to be processed, the storage device, upon receiving the command, can read the data based on the physical address in the command, without first looking up the logical address-physical address mapping table in the storage device based on the logical address of the file to be read, and then reading the data based on the physical address in the table. This reduces the latency caused by loading the mapping table. It should be noted that since the physical address of the file to be processed in the storage device may change after the host receives the aforementioned logical-physical address mapping information, the HPB Read command can include both the logical address and physical address of the file to be processed. If the physical address of the file to be processed has not changed, the storage device can directly read the data based on the physical address in the HPB Read command; if the physical address of the file to be processed has changed, the storage device can find the modified physical address based on the logical address in the HPB Read command, and then read the corresponding data of the file to be processed based on the modified physical address. In another possible implementation, the host can send a Read command to the storage device to read the data of the file to be processed. It should be noted that the Read command includes the logical address range of the file to be processed. After receiving the Read command, the storage device finds the data stored at the physical address corresponding to the logical address range in the command, and then sends the data to the host.
[0019] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the method further includes: when N is greater than a minimum threshold L for the number of files to be organized, sending first information to the storage device; the first information includes one or more of the following: the number N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address and length of the logical address segments.
[0020] In this embodiment of the invention, after the host completes the calculation of the physical address dispersion of the target files, the host adds the target files with high physical address dispersion to the update list as files to be organized. When a certain number of files to be organized accumulate in the update list, the host sends the first information to the storage device. Since this information includes the number of files to be organized, the number of logical address segments corresponding to each file, and the starting address and length of the logical address segments, the storage device will move the data of the files to be organized according to this first information when it is idle. For example, in one case, the file data can be moved to one block, in which case the physical address of the file is contiguous; in another case, the file data needs to be moved to different blocks, but the data of the file in each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of the files to be organized into contiguous physical addresses can be reduced, thus reducing the degree of file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device. At the same time, it can reduce the increased wear and tear on the storage device caused by excessively frequent file organization (data movement).
[0021] Secondly, embodiments of the present invention provide a file management method, characterized in that it is applied to a storage device, the method comprising: receiving a first instruction sent by a host; the first instruction including a first logical address range; sending logical physical address mapping information to the host according to the first logical address range; the logical physical address mapping information including a mapping relationship between the first logical address range and a first physical address.
[0022] In this embodiment of the invention, when the host acquires a frequently accessed file or file fragment as a target file and adds the target file to a target file set (which may include one or more target files), the host determines a first logical address range based on the target file set and then sends an instruction to the storage device that includes the first logical address range. Upon receiving the instruction from the host, the storage device searches for the mapping relationship between the first logical address range and its physical address based on the first logical address range in the instruction, and then sends this mapping relationship back to the host. This allows the host to calculate the physical address dispersion of the target files based on the mapping relationship, and subsequently manage the physical addresses of the files accordingly based on the physical address dispersion of the target files.
[0023] In one possible implementation, the storage device supports Host Performance Enhancement Technology (HPB); the first instruction is an HPB Read Buffer instruction.
[0024] In this embodiment of the invention, after the storage device receives the HPB Read Buffer instruction sent by the host, the storage device will look up the mapping relationship between the first logical address range and its physical address according to the first logical address range in the instruction, and then send the mapping relationship to the host. This facilitates the host to calculate the physical address dispersion of each target file, which can improve the working efficiency of both the storage device and the host.
[0025] In one possible implementation, the storage device supports Host Performance Enhancement (HPB) technology; the method further includes: receiving an HPB Read command sent by the host, the HPB Read command including logical addresses and physical addresses of N files to be processed; reading data of the N files to be processed according to the physical addresses in the HPB Read command, and sending the data of the N files to be processed to the host; or, receiving a Read command sent by the host, the Read command including logical addresses of the N files to be processed, finding the corresponding physical addresses of the N files to be processed according to the logical addresses in the Read command, reading the data of the N files to be processed, and sending the data of the N files to be processed to the host.
[0026] In this embodiment of the invention, when a host needs to read data from a file to be processed from a storage device, in one possible scenario, the host can read the data by sending an HPB Read command to the storage device. Since this command includes the logical address and physical address of the file to be processed, the storage device, upon receiving the command, can read the data based on the physical address in the command, without needing to look up the logical address-physical address mapping table in the storage device based on the logical address of the file to be read, and then read the data based on the physical address in the table. This reduces the latency caused by loading the mapping table. It should be noted that since the physical address of the file to be processed in the storage device may change after the host receives the aforementioned logical-physical address mapping information, the HPB Read command can include both the logical address and physical address of the file to be processed. If the physical address of the file to be processed has not changed, the storage device can directly read the data based on the physical address in the HPB Read command; if the physical address of the file to be processed has changed, the storage device can find the modified physical address based on the logical address in the HPB Read command, and then read the corresponding data of the file to be processed based on the modified physical address. In another possible scenario, the host can send a Read command to the storage device to read the data of the file to be processed. It should be noted that the Read command includes the logical address range of the file to be processed. After receiving the Read command, the storage device finds the data stored at the physical address corresponding to the logical address range in the command, and then sends the data to the host.
[0027] In one possible implementation, the method further includes: receiving first information sent by the host; the first information includes one or more of the following: the number N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address and length of the logical address segments; and performing a data transfer operation on the N files to be organized according to the first information.
[0028] In this embodiment of the invention, after the host completes the calculation of the dispersion of the target files, the target files with high physical address dispersion are added to the update list as files to be processed. When a certain number of files to be processed accumulate in the update list, the host can send first information to the storage device. This information includes the number of files to be processed, the number of logical address segments corresponding to each file, and the starting address and length of the logical address segments. When the storage device receives this first information, it will move the data of the files to be processed according to this information. For example, in one case, the file data can be moved to one block, in which case the physical address of the file is contiguous; in another case, the file data needs to be moved to different blocks, but the data of the file in each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of the files to be processed can be organized into contiguous physical addresses, reducing the degree of file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device.
[0029] In one possible implementation, the step of moving the data of the files to be organized according to the first information includes: storing the first information in the storage medium when the storage device is in a working state, and moving the data of the N files to be organized according to the first information when the storage device is in an idle state.
[0030] In this embodiment of the invention, when the storage device receives the first information sent by the host, if the storage device is performing other tasks at this time, the first information will be stored in the storage device first. When the storage device finishes its task and is in an idle state, the data of the file to be sorted will be moved according to the information, so as to sort the discrete physical addresses of the file to be sorted into continuous physical addresses, thereby reducing the degree of file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device.
[0031] Thirdly, this application provides a file management device, characterized in that it is applied to a host computer, the device comprising: a first processing unit, configured to determine a first logical address range of a target file set; the target file set includes M target files; M is an integer greater than 0; a first sending unit, configured to send a first instruction to a storage device; the first instruction includes the first logical address range; a first receiving unit, configured to receive logical physical address mapping information sent by the storage device; the logical physical address mapping information includes a mapping relationship between the first logical address range and a first physical address; a first calculation unit, configured to calculate the physical address dispersion of the M target files according to the mapping relationship; and a second processing unit, configured to determine the files to be processed based on the physical address dispersion of the M target files.
[0032] In one possible implementation, M is greater than 1; the first processing unit is specifically used to: obtain the logical address range of each target file according to the node information of each target file in the M target files; merge the logical address ranges of each target file to obtain the first logical address range; the node information includes the logical address information of the corresponding target file.
[0033] In one possible implementation, the first instruction is an HPB Read Buffer instruction; the first sending unit is specifically used to: send the HPBRead Buffer instruction to the storage device when M is greater than a preset threshold for the number of target files.
[0034] In one possible implementation, the device further includes: a third processing unit, configured to add the logical address of the file to be processed to an update list; the file to be processed is a target file among the M target files whose physical address dispersion exceeds a threshold.
[0035] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the device further includes: a first reading unit, configured to read data of the N files to be organized from the storage device into host memory when N is greater than a minimum threshold L for the number of files to be organized, where L is an integer greater than 0; and to rewrite the data of the N files to be organized into the storage device according to the logical address of each file to be organized.
[0036] In one possible implementation, the first reading unit is specifically configured to: send an HPB Read command to the storage device; the HPB Read command includes the logical and physical addresses of the N files to be organized; or, send a Read command to the storage device; the Read command includes the logical addresses of the N files to be organized.
[0037] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the device further includes a second sending unit, configured to send first information to the storage device when N is greater than a minimum threshold L of the number of files to be organized; the first information includes one or more of the following: the number N of the N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address of the logical address segment, and its length.
[0038] Fourthly, this application provides a file management device, characterized in that it is applied to a storage device, the device comprising: a first receiving unit, configured to receive a first instruction sent by a host; the first instruction including a first logical address range; and a first sending unit, configured to send logical-physical address mapping information to the host according to the first logical address range; the logical-physical address mapping information including a mapping relationship between the first logical address range and a first physical address.
[0039] In one possible implementation, the storage device supports Host Performance Enhancement Technology (HPB); the first instruction is an HPB Read Buffer instruction.
[0040] In one possible implementation, the storage device supports Host Performance Enhancement (HPB) technology; the device further includes: a second receiving unit, configured to receive an HPB Read command sent by the host, the HPB Read command including logical addresses and physical addresses of N files to be processed; read data of the N files to be processed according to the physical addresses in the HPB Read command, and send the data of the N files to be processed to the host; or, receive a Read command sent by the host, the Read command including logical addresses of the N files to be processed, find the corresponding physical addresses according to the logical addresses of the N files to be processed in the Read command, read the data of the N files to be processed, and send the data of the N files to be processed to the host.
[0041] In one possible implementation, the device further includes: a third receiving unit, configured to receive first information sent by the host; the first information includes one or more of the following: the number N files to be organized, the number of logical address segments corresponding to each of the N files to be organized, the starting address and the length of the logical address segments; and a first processing unit, configured to perform a data transfer operation on the N files to be organized according to the first information.
[0042] In one possible implementation, the first processing unit is specifically used to: store the first information in the storage medium when the storage device is in a working state, and move the data of the N files to be organized according to the first information when the storage device is in an idle state.
[0043] Fifthly, this application provides a file management method, characterized in that it is applied to an electronic device, the electronic device including a host and a storage device, the method comprising: the electronic device running a target application, the first data of a first file of the target application being stored in a first storage block in the storage device; in response to a data update operation on the first file of the target application, the host updating a second data of the first file to a second storage block in the storage device; the host determining a first logical address range of a target file set; the target file set including M target files, the first file being one of the M target files; M being an integer greater than 0; the host sending a first... The instruction includes the first logical address range; the host receives logical physical address mapping information sent by the storage device; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address; the host calculates the physical address dispersion of the M target files according to the mapping relationship, and determines the file to be processed based on the physical address dispersion of the M target files; when the file to be processed includes the first file, and the first data and the second data are processed into the third storage block of the storage device, in response to the read operation of the first file of the target application, the host reads the first data and the second data from the third storage block of the storage device.
[0044] In a sixth aspect, an electronic device provided by an embodiment of the present invention includes a processor and a memory, wherein the memory is used to store program code, and the processor is used to call the program code stored in the memory to execute the storage device involved in any of the implementations of the fifth aspect above.
[0045] In a seventh aspect, embodiments of the present invention provide a computer program including instructions that, when executed by a storage device, cause the storage device to perform the data storage method process described in any of the first aspects above.
[0046] Eighthly, embodiments of the present invention provide a computer program including instructions that, when executed by a host, enable the host to perform the data storage method process described in any of the second aspects above. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the background art, the accompanying drawings used in the embodiments of the present invention or the background art will be described below.
[0048] Figure 1A This is a schematic diagram of a NAND storage array in the prior art.
[0049] Figure 1B This is a schematic diagram of the structure of each block in a NAND storage array in the prior art.
[0050] Figure 1C A schematic diagram illustrating the changes in logical and physical addresses during file write operations in existing technologies.
[0051] Figure 1D This is a schematic diagram of the waste recycling process in existing technologies.
[0052] Figure 1E This is a schematic diagram of a file fragmentation and organization technique in the prior art.
[0053] Figure 2A This is a schematic diagram of the structure of a host and a storage device provided in an embodiment of the present invention.
[0054] Figure 2B This is a schematic diagram of the structure of a storage device provided in an embodiment of the present invention.
[0055] Figure 2C This is a schematic diagram of communication between a memory chip and a main chip, provided as an embodiment of the present invention.
[0056] Figure 2D This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0057] Figure 3A This is a flowchart illustrating a file management method provided in an embodiment of this application.
[0058] Figure 3B This is a schematic diagram of the target file provided for an embodiment of the present invention.
[0059] Figure 3C This is a schematic diagram illustrating the mapping relationship between file logical addresses and physical addresses, provided for an embodiment of the present invention.
[0060] Figure 3D This is an HPB initialization flowchart provided for an embodiment of the present invention.
[0061] Figure 4A This is a schematic diagram illustrating the specific process of a file management method provided in an embodiment of the present invention.
[0062] Figure 4B This is a schematic diagram of file data storage after fragmentation and reorganization, provided as an embodiment of the present invention.
[0063] Figure 4C This is a schematic diagram of the host-side process of a file management method provided in an embodiment of the present invention.
[0064] Figure 4DThis is a schematic diagram of an HPB Read instruction provided in an embodiment of the present invention.
[0065] Figure 5A This is a schematic diagram illustrating the specific process of another file management method provided in an embodiment of the present invention.
[0066] Figure 5B This is a schematic diagram of a first information format provided in an embodiment of the present invention.
[0067] Figure 5C This is a flowchart illustrating another file management method provided in an embodiment of the present invention.
[0068] Figure 6A This invention provides a flowchart of a file management method for electronic devices.
[0069] Figure 6B This is a schematic diagram of a target application provided in an embodiment of the present invention.
[0070] Figure 6C This is a schematic diagram of a data update interface provided in an embodiment of the present invention.
[0071] Figure 6D This is a schematic diagram of a target file settings interface provided in an embodiment of the present invention.
[0072] Figure 6E This is a schematic diagram of a user interface provided in an embodiment of the present invention.
[0073] Figure 7A This is a schematic diagram of the structure of a file management device provided in an embodiment of the present invention.
[0074] Figure 7B This is a schematic diagram of another file management device provided in an embodiment of the present invention. Detailed Implementation
[0075] The embodiments of the present invention will now be described with reference to the accompanying drawings.
[0076] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0077] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0078] As used in this specification, the terms "component," "module," "system," etc., are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process and / or an execution thread, and components may be located on a single computer and / or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, and / or a network, such as the Internet interacting with other systems via signals).
[0079] First, some of the terms used in this application will be explained to facilitate understanding by those skilled in the art.
[0080] (1) Not-and-Flash (NAND Flash) is a non-volatile storage medium, meaning it retains data even after power is off. Its development goal is to reduce the cost per bit of storage and increase storage capacity. Typically, NAND Flash is read and written in units of pages and erased in units of blocks. Due to the nature of Flash storage, writing data to Flash can only change a bit from 1 to 0; erasing can only change all bits from 0 to 1. Therefore, modifying or writing new data must be done on an already erased free page; otherwise, the data will be corrupted.
[0081] (2) Universal Flash Storage (UFS) is a hard drive made using solid-state electronic storage chip arrays. UFS consists of a control unit (controller and SRAM) and storage units (FLASH chips). The FLASH chips in UFS typically use the aforementioned NAND Flash chips as their storage units. UFS is widely used in mobile devices such as mobile phones and tablets.
[0082] (3) Flash Friendly File System (F2FS) is a file storage architecture on the operating system. It is a new open-source flash file system specifically designed for NAND-based storage devices. F2FS supports the Linux operating system. It is suitable for flash memory devices such as NAND (e.g., solid-state drives, UFS, eMMC, and SD cards), making it more suitable for current mobile devices.
[0083] (4) Host Performance Booster (HPB) technology is a technology used to improve the random read performance of devices, enabling the host to perceive the physical address corresponding to the logical address, thereby improving the read performance of the device.
[0084] First, this application further analyzes and proposes the specific technical problem it aims to solve. In the field of flash memory storage technology, NAND Flash is read and written in units of pages and erased in units of blocks. For example, as... Figure 1A and Figure 1B As shown, Figure 1A This is a schematic diagram of a NAND storage array in the prior art. Figure 1A A NAND flash memory array can consist of multiple blocks, and NAND flash memory can only be erased in units of blocks as shown in the diagram. Figure 1B This is a schematic diagram of the structure of each block in a NAND flash memory array in the prior art. Figure 1B Each block in NAND Flash consists of device units at the intersection of word lines and bit lines. Word lines and pages correspond one-to-one. Typically, one page (16KB) can store data corresponding to four logical addresses (4KB each). NAND Flash can only perform read and write operations in units of pages. Due to the nature of Flash storage, blocks must be erased before pages within the erased block can be programmed. The prior art related to this application is as follows:
[0085] Technology 1: Remote data update technology.
[0086] If only a portion of the data in a block needs updating, while the rest of the data within that block remains unchanged, a Flash Translation Layer (FTL) can be introduced. The FTL represents the logical address mapping (L2P) between the data's logical address and its physical address stored in the storage device. The host only needs to manage the logical address, while the physical address is managed by the firmware (FW) within the storage device. When the data content changes, the logical address remains the same; only its physical address in the storage device changes. This means the modified data is stored in a new location (such as a new page or block). Therefore, due to the inconsistency between the programming and erasing of the smallest unit in NAND Flash devices, data storage must be updated off-site.
[0087] For example, such as Figure 1C As shown, Figure 1C This diagram illustrates the changes in logical and physical addresses during a file write operation in existing technology. Using files A and B as examples, the diagram explains the file write operation process. First, the host-side file system locates the logical address range for file A (LBA 0, LBA 1, LBA 2) by looking up node information, while file B corresponds to logical addresses LBA 3, LBA 4, LBA 5. Initially, the physical addresses corresponding to the data in files A and B are contiguous in the storage device. Figure 1C As shown in State1, LBA0, LBA1, LBA2, LBA3, LBA4, and LBA5 are stored sequentially in Block1. When the data content of LBA2 and LBA0 in file A and LBA4 in file B is changed, the logical addresses maintained by the host-side file system remain unchanged. However, for storage devices, the new data corresponding to LBA2, LBA4, and LBA0 is first written to the new physical pages, such as... Figure 1C As shown in State 2, the modified LBA2, LBA4, and LBA0 are stored in Pages 0, 1, and 2 of Block 2, and the physical addresses mapped to Pages 2, 4, and 0 in the original Block 1 are invalidated. If new data is appended to file A and its logical address is recorded as LBA6, the newly written data will be stored in Page 3 of Block 2. As file data is continuously modified, a file that was originally stored contiguously in flash memory may gradually transform into discrete storage in physical space, such as... Figure 1CAs shown in State 3, LBA 1, LBA0, LBA 2, and LBA 6 in file A are stored in Page 1 of Block 1 and Pages 2, 0, and 3 of Block 2, indicating increased fragmentation of the physical address space in file A. Reading discrete data (such as...) Figure 1C The time required to read data (as shown in State3) is greater than the time required to read data from contiguous storage (such as...). Figure 1C The time required for the data (shown in State1) varies, and the performance difference increases with the degree of dispersion.
[0088] The disadvantage of technique 1 is that off-site updates not only lead to file fragmentation, but also cause storage devices to be unused. As the proportion of unused space increases, the effective physical space available for programming gradually decreases.
[0089] Technology 2: Waste recycling technology.
[0090] To address the issue of invalid data being occupied by storage devices due to off-site data updates, storage devices periodically perform garbage collection. The principle behind this is to move valid data from blocks with a high proportion of invalid data to new blocks, thereby creating new empty blocks and increasing the number of usable valid blocks. Garbage collection is a widely used technology in current flash memory.
[0091] For example, such as Figure 1D As shown, Figure 1D This is a schematic diagram of the waste recycling process in existing technologies. Figure 1D In State 1, Block 0, Pages 1, 3, and 5 store valid data, while Pages 0, 2, and 4 store invalid data. In Block 1, Pages 3, 4, and 5 store valid data, while Pages 0, 1, and 2 store invalid data. Block 2 is empty. The following is... Figure 1DAs shown in State 2, garbage collection is performed. Valid data in Block 0 is moved in the order it appears. For example, LBA1 stored in Page 1, LBA3 stored in Page 3, and LBA5 stored in Page 5 are moved to Page 0, Page 1, and Page 2 of Block 2 in the order LBA1, LBA3, and LBA5. Then, all data in Block 0 is erased to obtain a new programmable Block 0. Similarly, LBA2, LBA4, and LBA0 in Block 1 are moved to Block 2 and stored in Page 3, Page 4, and Page 5 in sequence. Then, all data in Block 1 is erased to obtain a new programmable Block 1. Therefore, garbage collection can move valid data from different blocks to a new block and reclaim blocks that do not contain data, thus reducing invalid occupancy of storage devices.
[0092] The drawback of technique two: While garbage collection can move valid data together and reclaim blocks containing invalid data, it cannot fundamentally solve the problem of file dispersion. This is because the storage medium can only perceive the mapping relationship between a logical address and a physical address, but it cannot perceive the logical address range corresponding to a file, and therefore cannot perceive the physical address corresponding to the logical address range of the file. It simply moves data to the new block according to the order of valid data in the current block, resulting in an unordered distribution of data in the physical address space of the file after garbage collection. Therefore, when reading data, such as... Figure 1D The LBA0-LBA3 data in State1 can only be obtained in a discrete reading manner due to the discreteness of the physical address of the data on the storage device side, and cannot be read in a high-performance sequential manner, which ultimately leads to a decrease in the read performance of the storage device.
[0093] Technique 3: The host reads the data corresponding to the file into the host-side memory, and then rewrites it into the storage device, thereby achieving the purpose of file fragmentation and defragmentation.
[0094] For example, such as Figure 1E As shown, Figure 1E This is a schematic diagram of a file fragmentation and organization technique in the prior art. Figure 1EBlock 0 stores data for files A, B, C, and D. Using technique three, the host can load all file data from Block 0 into its memory in file order A, B, C, D, and then rewrite the files sequentially into Block 1 of the storage device, ensuring that the logical and physical addresses of the files are contiguous. Then, all data in Block 0 is invalidated, and Block 0 is erased to obtain a new programmable Block 0.
[0095] Disadvantages of Technique 3: While Technique 3 can reduce file dispersion (the logical and physical addresses of the data are continuous), since files A and B are contiguous in Block 0 and there is no need to relocate them, it will cause some additional overhead, accelerate device wear, and shorten device life.
[0096] Technique 4: The host sends the logical address range corresponding to the file to the storage device. The storage device then calculates the fragmentation level of the file based on the physical address corresponding to the logical address and returns the result to the host. The host decides whether to defragment the file based on the fragmentation level. Defragmentation can be done by reading the file into the host memory and then writing it to the storage device, or by sending the file information to the storage device and having the storage device perform defragmentation automatically at a specific time.
[0097] The fourth drawback of this technique is that, firstly, because the computing performance of the central processing unit (CPU) of the storage device is far lower than that of the CPU of the current host, the calculation of file fragmentation level on the storage device takes a relatively long time. Furthermore, since the storage device cannot process commands sent from the host side while performing file fragmentation calculations, it affects the system's response time. Secondly, the file fragmentation level calculated by this technique is based on the entire file and cannot reflect the degree of dispersion of segments within the file. For example, a file with a high degree of fragmentation may only be caused by the fragmentation of data corresponding to a portion of logical addresses; however, this technique cannot detect areas with a high degree of dispersion, so it can only perform overwrite operations on all data corresponding to the file, resulting in a large amount of writes and reducing the device's lifespan.
[0098] In summary, the technical problems that this application actually aims to solve include the following aspects: to address the limitations of existing storage technologies, a file fragmentation and defragmentation scheme is provided, and the scheme can be based on mainstream technology trends (i.e., including HPB technology) to reduce the degree of file fragmentation and improve the read performance of storage devices.
[0099] Based on the above, embodiments of the present invention provide a host and a storage device. Please refer to [link to relevant documentation]. Figure 2A , Figure 2A This is a schematic diagram of a host and storage device provided in an embodiment of the present invention. The host 10 can be any computing device that generates data, such as a server, personal computer, tablet computer, mobile phone, personal digital assistant, smart wearable device, and other similar devices. The storage device 103 can be any non-volatile memory that provides data storage / retrieval functions for the host 10. In this embodiment, the storage device 103 can be built into the host 10, or it can be a separate device from the host 10, or the storage device 103 and the host 10 can coexist in one electronic device. This application does not specifically limit this. The host 10 or storage device 103 can specifically be a chip or chipset, or a circuit board carrying a chip or chipset. The chip or chipset or the circuit board carrying a chip or chipset can operate under the necessary software drive. Specifically,
[0100] The host 10 may include host internal memory 101 and host controller 102. Optionally, it may also include a processor 100, and further, it may include... Figure 2A All physical devices on the application processing side, including power supplies, other input / output controllers, and interfaces, not shown in the diagram.
[0101] The host internal memory 101 is typically a power-loss volatile memory, whose stored contents are lost when power is off; it can also be called main memory or RAM. In this application, the host internal memory 101 includes readable and writable RAM, which is used to temporarily store computational data in the processor and data exchanged with storage device 103 or other external storage devices. It can serve as a storage medium for temporary data of the operating system or other running programs. For example, in this application, the host internal memory 101 can store logical physical address information sent by storage device 103. The operating system running on the processor retrieves the logical physical address information from the host internal memory 101 to the processor to perform physical address discretization calculations on the target file. After the calculation is completed, the processor then transmits the result.
[0102] The host internal memory 101 may include one or more of the following: Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), and Synchronous Dynamic Random Access Memory (SDRAM). DRAM further includes Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), second-generation Double Data Rate Synchronous Dynamic Random Access Memory (DDR2), third-generation Double Data Rate Synchronous Dynamic Random Access Memory (DDR3), fourth-generation Low Power Double Data Rate Synchronous Dynamic Random Access Memory (LPDDR4), and fifth-generation Low Power Double Data Rate Synchronous Dynamic Random Access Memory (LPDDR5).
[0103] Host controller 102 manages and controls communication between host 10 and storage device 103, and provides a standardized (e.g., SCSI standard supported) interface for this communication. Specifically, host controller 102 can transmit commands (e.g., write, read, erase commands) and data to storage device 103 based on read / write requests from the processor, and can also provide feedback events (e.g., command completion events, command status events, hardware error events, etc.) to host 10 based on the results of data read / write operations from storage device 103. For commands or data issued by the processor, host controller 102 can encapsulate them into data packets supporting a specific protocol; conversely, for data received by host 10, host controller 102 performs the reverse operation. Optionally, a host can support multiple host controllers to support communication with storage devices using different protocols. In this embodiment of the invention, the host controller 102 generates HPB Read Buffer commands, write commands, Read / HPB Read commands, erase commands, etc., involved in this application according to the protocol (e.g., UFS protocol) supported between the host 10 and the storage device 103. Optionally, the functions of the host controller 102 can also be integrated into the processor, that is, the processor performs the above-mentioned functions of the host controller 102, which is not specifically limited here.
[0104] Optionally, the host 10 may also include a processor 100. The processor 100 may run an operating system, a file system (such as the flash file system F2FS), or applications to control multiple hardware or software components connected to the processor 100, and may process various data and perform operations. The processor 100 may load instructions or data stored in the storage device 103 into the host memory 101, and may retrieve instructions or data that need to be processed to the processor 100 for processing. After the processing is completed, the processor 100 may temporarily store the results in the host memory 101, and may store instructions or data that need to be stored for a long time into the storage device 103 through the host controller 102. Processor 100 may include one or more processing units (also referred to as processing cores), such as a central processing unit (CPU), application processor (AP), modem processing unit, graphics processing unit (GPU), image signal processor (ISP), video codec unit, digital signal processor (DSP), baseband processing unit, and neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more devices. Optionally, processor 100 may also include memory for storing instructions and data. In some embodiments, the memory in processor 100 is a cache. The cache can store instructions or data that processor 100 has just used or is repeatedly used. If processor 100 needs to use the instruction or data again, it can directly retrieve it from the cache. This avoids repeated access, reduces the waiting time of processor 100, and thus improves system efficiency. Furthermore, processor 100 may also be implemented as a system on a chip (SoC). For example, in an embodiment of the present invention, the host controller 102 can load the logical physical address information stored in the host internal memory 101 into the processor 100 to calculate the physical address dispersion of the file.
[0105] Storage device 103 is a non-volatile memory, meaning its stored contents are not lost after power failure. Storage device 103 (including storage controller 1031, internal storage memory 1032, and storage medium array 1033) can be used for long-term storage of instructions and data involved in the operation of host 10, such as boot programs, operating systems, applications, and data. Since the processor in host 10 cannot directly read instructions and data from storage device 103 nor directly write instructions or data to storage device 103, when the processor executes a read (or load) command, it actually temporarily loads the content to be read (including instructions and / or data) stored in storage device 103 into internal storage memory 101 through host controller 102, and then the processor reads it from internal storage memory 101. Conversely, when executing a write (i.e., store) command, the processor 100 temporarily writes the data to be stored (including instructions and / or data) into internal storage memory 101, and then the host controller 102 stores it from internal storage memory 101 into storage device 103. Therefore, the performance of storage device 103, such as read rate, write rate, erase rate, number of erase / write cycles, and data retention capability, has a significant impact on the performance of host 10 and determines whether host 10 or the electronic device containing host 10 can operate normally, stably, and efficiently.
[0106] Storage device 103 may include one or more of the following: Flash memory (e.g., NAND flash memory, NOR flash memory, etc.), universal flash storage (UFS), embedded multimedia card eMMC, universal flash storage multi-chip package (uMCP) memory, embedded multimedia card multi-chip package (eMCP) memory, solid-state drive (SSD), etc. Furthermore, storage device 103 may also include other storage media such as hard disk drive (HDD). It should be noted that a page is the smallest addressing unit in NAND Flash, i.e., the smallest unit for reading / writing. The number of pages in a block varies depending on the manufacturer and specifications, and the size of the page itself also varies.
[0107] Storage controller 1031 is the interface device between host 10 and storage device 103. Its main function is to perform interface conversion, converting read, write, and delete commands issued by host 10 (e.g., the host controller in host 10) into signals that storage device 103 can recognize. It can also perform address decoding (e.g., mapping between the logical address of host 10 and the physical address in storage device 103) and data format conversion (e.g., data bit width) between host 10 and storage device 103. In short, storage controller 1031 is a device that can perform necessary control on access to its storage device 103 according to certain timing rules, including the control of address signals, data signals, and various command signals, so that host 10 can use the storage resources on storage device 103 as needed. For example, in one embodiment of the present invention, after the host 10 completes the calculation of the physical address dispersion of the file, the host 10 can identify the file with a high degree of physical address dispersion as the file to be organized. Then, the host 10 can send the information of the file to be organized to the storage device 103. Then, the storage controller 1031 can move the data of the file to be organized according to the information of the file to be organized, thereby reducing the file fragmentation degree of the file to be organized.
[0108] The internal memory 1032 of the storage device is typically a power-loss volatile memory, whose contents are lost when power is off; it can also be called main memory or RAM. In this application, the internal memory 1032 includes readable and writable RAM, which is used to temporarily store computational data from the processor of the storage device 103, as well as data exchanged with the host 10 or other external storage devices. It can serve as a storage medium for temporary data of the operating system or other running programs. For example, the internal memory 1032 can store a mapping table of logical addresses to physical addresses for some files. When the storage device 103 receives a logical address range sent by the host, if the mapping table in the internal memory 1032 includes the logical address range sent by the host 10, the physical address corresponding to that logical address range can be found in the internal memory 1032.
[0109] The internal memory 1032 of the storage device may include one or more of the following: Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), and Synchronous Dynamic Random Access Memory (SDRAM). DRAM further includes Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), second-generation Double Data Rate Synchronous Dynamic Random Access Memory (DDR2), third-generation Double Data Rate Synchronous Dynamic Random Access Memory (DDR3), fourth-generation Low Power Double Data Rate Synchronous Dynamic Random Access Memory (Low Power Double Data Rate 4, LPDDR4), and fifth-generation Low Power Double Data Rate Synchronous Dynamic Random Access Memory (Low Power Double Data Rate 5, LPDDR5). Optionally, the internal memory 1032 of the storage device may be integrated into the storage controller 1031; this is not specifically limited here.
[0110] The storage medium array 1033 may include multiple storage units for storing data, which can be used for long-term storage of instructions and data involved in the operation of the host 10, such as boot programs, operating systems, applications, and data. Each storage unit may include one or more of the following: a single-cell SLC storage area, fast and non-fast NAND memory, a multi-cell MLC storage area, a three-cell TLC storage area, a four-cell QLC storage area, and a five-cell PLC storage area. For example, as... Figure 2B As shown, Figure 2B This is a schematic diagram of a storage device provided in an embodiment of the present invention. The storage medium array 1033 may include L blocks, each block includes N pages, and all pages in all blocks of the storage medium array 1033 can be used to store data.
[0111] For example, such as Figure 2C As shown, Figure 2C This is a schematic diagram of communication between a memory chip and a main chip provided in an embodiment of the present invention. In the figure, the main chip is one of the aforementioned host 10, the memory chip is one of the aforementioned storage device 103, the main controller in the main chip is the aforementioned host controller 102, the DRAM is the aforementioned host internal memory 101, the controller in the memory chip is the aforementioned storage controller 1031, the SRAM is the aforementioned storage device internal memory 1032, and the NAND storage array is the aforementioned storage medium array 1033.
[0112] Understandable, Figure 2AThe structure of the host 10 or storage device 103 in the present invention is only some exemplary implementations provided by the embodiments of the present invention. The structure of the host 10 and storage device 103 in the embodiments of the present invention includes, but is not limited to, the above implementations.
[0113] It is also understood that the processor 100 can communicate with the host memory 101, the host controller 102, and the storage device 103 via a system bus or other connection methods, and this embodiment of the invention does not specifically limit this. The structure illustrated in this embodiment of the invention does not constitute a specific limitation on the host 10 or the storage device 103. In other embodiments of this application, the host 10 or the storage device 103 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0114] Furthermore, when both the host 10 and the storage device 103 are part of the electronic device 20 (i.e., both reside within the same electronic device 20), please refer to [link to relevant documentation]. Figure 2D , Figure 2D This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 20, or the host 10 part of the electronic device 20, may further include the following functional modules:
[0115] External storage interface 104 can be used to connect external memory cards, such as TF (TransFlash) cards (also known as T-Flash cards), flash drives, compact flash (CF) cards, secure digital cards (SD), micro SD, mini SD, high-speed cards (xD), multimedia cards (MMC), Memory Sticks, etc. The external memory card is operably and / or physically connected to electronic device 20 through external storage interface 104 to expand the storage capacity of electronic device 20. For example, music, video, and other files can be stored on the external memory card.
[0116] The SIM card interface 105 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 105 to make contact with and separate from the electronic device 20. The electronic device 20 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 105 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 105 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 105 is also compatible with different types of SIM cards. The SIM card interface 105 is also compatible with external memory cards. The electronic device 20 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 20 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 20 and cannot be separated from the electronic device 20.
[0117] Display screen 106 is used to display text, images, videos, etc. Display screen 106 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. Further, display screen 106 may include a touchscreen and may receive touch, gesture, proximity, or hover input from an electronic pen or a part of the user's body. In some embodiments, electronic device 20 may include one or N displays 106, where N is a positive integer greater than 1.
[0118] The audio system 107 may include a speaker, receiver, microphone, headphone jack, etc. The electronic device 20 can implement audio functions through the audio system 107 and the AP in the processor 100, such as making calls, playing music, and recording.
[0119] The camera system 108 may include one or more cameras (e.g., one front-facing camera and one rear-facing camera, or multiple front-facing cameras and multiple rear-facing cameras), and the camera may also be a set of camera modules. The camera is used to capture still images or videos. The electronic device 20 can realize the shooting function through the camera, the ISP in the processor 100, the video codec, the GPU and AP, and the display screen 106, etc.
[0120] The sensor system 109 may include a four-in-one (accelerometer, angular velocity meter, gyroscope, compass) motion sensor, pressure sensor, temperature sensor, light sensor, proximity sensor, 3D structured light sensor, etc. Different sensors are used to sense different signals, enabling the processor 100 to perform calculations based on the different sensed signals to realize different functions of the electronic device 20. For example, the four-in-one motion sensor can be used to determine the motion posture and orientation information of the electronic device 20; the light sensor is used to sense the ambient light brightness, and the electronic device 20 can adaptively adjust the brightness of the display screen 106 according to the sensed ambient light brightness, or it can also be used to automatically adjust the white balance when the shooting system 108 takes a picture.
[0121] The wireless communication function of the communication system, electronic device 20, can be implemented through antenna 1, antenna 2, mobile communication module 110, wireless communication module 111, modem processor, and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Mobile communication module 110 can provide wireless communication solutions for electronic device 20, including 2G / 3G / 4G / 5G. Wireless communication module 111 can provide wireless communication solutions for electronic device 20, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.
[0122] A power management module (PMU) 112 manages the power supply to the electronic device 20. The PMU 112 receives input from the battery 113 and / or the charging management module 114, supplying power to the processor 100, host memory 101, host controller 102, storage device 103, display screen 106, audio system 107, camera system 108, sensor system 109, mobile communication module 110, and wireless communication module 111, etc. The charging management module 114 can employ wired and / or wireless charging methods. Wireless charging methods may include, for example, magnetic resonance methods, magnetic induction methods, electromagnetic methods, etc. The battery 113 may include a rechargeable battery and / or a solar cell, etc.
[0123] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 20. In other embodiments of this application, the electronic device 20 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0124] The file organization method provided in this embodiment of the invention involves the process of the host 10 storing data in the storage device 103 and reading data from the storage device 103.
[0125] The following is combined Figures 2A-2C The structure of the host 10 and storage device 103 shown, and Figure 2D The structure of the electronic device 20 shown is illustrated, and the document organization method provided by the embodiments of the present invention is described in detail. See also Figure 3A , Figure 3A This is a flowchart illustrating a file management method according to an embodiment of this application. The following will describe it in conjunction with the attached diagram. Figure 3A The document organization method in the embodiments of this application is described. It should be noted that, in order to describe the business management method in the embodiments of this application in more detail, the corresponding execution entities in each process step are described as host 10 and storage device 103, but this does not mean that the embodiments of this application can only perform the corresponding method process through the described execution entities.
[0126] Step S301: The host determines the first logical address range of the target file set.
[0127] Specifically, the target file set includes M target files; M is an integer greater than 0. For example, when the host system is idle, in one case, the host can obtain frequently accessed files or file fragments as target files and add these target files to the target file set, which may include one or more target files. It should be noted that in this case, the aforementioned frequently accessed files or file fragments may be actively set by the user, and then the host uses the user-set frequently accessed files or file fragments as target files to generate the target file set. Optionally, the host's operating system may also actively identify and determine the target files according to certain preset rules; this embodiment of the invention does not specifically limit this. After the host determines the target file set, it will obtain a first logical address range based on the logical address range of the target files in the target set. This first logical address range may include the logical address ranges of the aforementioned M target files. For example, such as... Figure 3B As shown, Figure 3B This diagram illustrates target files provided in an embodiment of the present invention. The data for four files—A, B, C, and D—are stored in Block 0 of the storage device. The logical address ranges for file A (LBA0-LBA3), B (LBA4-LBA9), C (LBA10-LBA14), and D (LBA16-LBA19). The host can add these four files as target files to a target file set, and then determine a first logical address range (LBA0-LBA19) based on the logical address range of each target file.
[0128] In one possible implementation, M is greater than 1; determining the first logical address range of the target file set includes: obtaining the logical address range of each target file based on the node information of each of the M target files; merging the logical address ranges of each target file to obtain the first logical address range; the node information includes the logical address information of the corresponding target file. Specifically, when the target file set includes multiple target files, the host can obtain the corresponding logical address range based on the node information of each target file, and then the host can merge the multiple logical address ranges to obtain the first logical address range. In this case, the host only needs to send an instruction including the first logical address range to the storage device once to obtain the mapping relationship between the logical addresses and physical addresses of multiple target files, instead of sending the logical address range of each target file individually. This reduces the number of communications between the host and the storage device and improves the host's working efficiency. Meanwhile, since a storage device can only execute one task at a time (e.g., the storage device cannot receive messages sent by the host while performing calculations), if the host sends instructions containing logical address ranges of target files to the storage device one by one, especially if there are too many target files, it will consume a significant amount of the storage device's operating time to receive the logical address ranges sent by the host. This may lead to malfunctions in the storage device. Therefore, implementing the method provided by this invention can also improve the operating efficiency of the storage device and prevent malfunctions. For example, as... Figure 3B As shown, the host adds four frequently accessed files—A, B, C, and D—as target files to the target file set. The logical address range of file A is LBA0-LBA3, that of file B is LBA4-LBA9, that of file C is LBA10-LBA15, and that of file D is LBA16-LBA19. The host then merges these four logical address ranges to obtain the first logical address range of LBA0-LBA19.
[0129] Step S302: The host sends the first instruction to the storage device.
[0130] Specifically, the first instruction includes the first logical address range. After the host obtains the first logical address based on the target file set, it sends a first instruction to the storage device. This instruction instructs the storage device to send the mapping relationship between the logical and physical addresses of the target file set. For example, as... Figure 3BAs shown, based on the logical address information of the four files in the diagram, the first logical address range can be obtained as LBA0-LBA19. Then, the host sends a first instruction to the storage device, which includes the first logical address range LBA0-LBA19. It should be noted that the first instruction can load a fixed-length logical address range each time; for example, the first instruction can read the physical address information corresponding to 1000 logical addresses each time, but these 1000 logical addresses include the aforementioned first logical address range (LBA0-LBA19). Next, the storage device can use this logical address range to find the mapping relationship between the logical address range and its physical address within the storage device, and then send this mapping relationship to the host. This facilitates the host's subsequent calculation of the physical address dispersion of files A, B, C, and D.
[0131] In one possible implementation, the storage device receives a first instruction sent by the host; the first instruction includes the first logical address range. Specifically, when the storage device receives the first instruction sent by the host, it looks up the mapping relationship between the first logical address range and its physical address based on the first logical address range in the instruction.
[0132] In one possible implementation, the first instruction is an HPB Read Buffer instruction. The host sends the first instruction to the storage device, including sending the HPB Read Buffer instruction to the storage device when M is greater than a preset threshold for the number of target files. Specifically, the threshold is preset in advance. When the number of files in the target file set reaches the threshold, the host sends the HPB Read Buffer instruction to the storage device, which includes the aforementioned first logical address range. Unlike existing technologies, by sending this instruction to the storage device, the host can instruct the storage device to find the mapping relationship between the first logical address range and its physical address, and can also instruct the storage device to send this mapping relationship to the host. This improves the host's efficiency, and the host can also obtain the mapping relationship between the logical addresses and physical addresses of multiple target files from the storage device through this instruction, facilitating subsequent calculation of the physical address dispersion of each target file.
[0133] In one possible implementation, the storage device supports Host Performance Enhancement (HPB) technology; the first instruction is an HPB Read Buffer instruction. Specifically, after receiving the HPB Read Buffer instruction sent by the host, the storage device will look up the mapping relationship between the first logical address range and its physical address according to the first logical address range in the instruction, and then send the mapping relationship to the host. This facilitates the host's subsequent calculation of the physical address dispersion of each target file, thereby improving both the efficiency of the storage device and the efficiency of the host.
[0134] Step S303: The storage device sends logical physical address mapping information to the host according to the first logical address range.
[0135] Specifically, the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address. When the storage device finds the physical page number (PPN) corresponding to the first logical address range according to the instruction sent by the host, it obtains the mapping relationship between the first logical address range and the first physical address range, and then sends this mapping relationship to the host, so that the host can subsequently perform corresponding calculations on the physical address dispersion of the target file. For example, as... Figure 3C As shown, Figure 3C This diagram illustrates a file logical address and physical address mapping relationship according to an embodiment of the present invention. In Block 0 of the storage device, file A has a logical address range of LBA0-LBA3 and its corresponding physical addresses are PPN0-PPN3; file B has a logical address range of LBA4-LBA9 and its corresponding physical addresses are PPN4-PPN9; file C has a logical address range of LBA10-LBA15 and its corresponding physical addresses are PPN10-PPN13, PPN16, and PPN18; and file D has a logical address range of LBA16-LBA19 and its corresponding physical addresses are PPN14, PPN15, PPN17, and PPN19. When the storage device receives the aforementioned first instruction from the host, it can determine the corresponding physical address range (PPN0-PPN19) based on the first logical address range (LBA0-LBA19), thus obtaining the mapping relationship between logical and physical addresses. This mapping relationship is then sent to the host via logical-physical address information.
[0136] Step S304: The host calculates the physical address dispersion of the M target files based on the mapping relationship.
[0137] Specifically, in existing technologies, the host's file system can only perceive the logical addresses of files, but cannot perceive the distribution of the corresponding physical addresses in the storage device. Therefore, the host cannot calculate the physical address dispersion of files. However, the method provided in this invention allows the host to obtain the mapping relationship between the logical addresses and physical addresses of the target file set from the storage device side. The host can then calculate the physical address dispersion of each target file based on this mapping relationship. For example, ... Figure 3C As shown in the diagram, in Block 0 of the storage device, file A has a logical address range of LBA0-LBA3 and its corresponding physical addresses are PPN0-PPN3; file B has a logical address range of LBA4-LBA9 and its corresponding physical addresses are PPN4-PPN9; file C has a logical address range of LBA10-LBA15 and its corresponding physical addresses are PPN10-PPN13, PPN16, and PPN18; and file D has a logical address range of LBA16-LBA19 and its corresponding physical addresses are PPN14, PPN15, PPN17, and PPN19. When the host receives the mapping relationship between the first logical address and its physical address sent by the storage device, it can calculate the physical address dispersion of each file based on this mapping relationship. Furthermore, it finds that the physical address dispersion of file A is 0, the physical address dispersion of file B is 0, the physical address dispersion of file C is relatively high, and the physical address dispersion of file D is also relatively high.
[0138] Step S305: The host determines the files to be sorted based on the dispersion of the physical addresses of the M target files.
[0139] Specifically, after the host calculates the physical address dispersion of each target file, some files do not have a high enough physical address dispersion and therefore do not need to be organized. Files with a high physical address dispersion are identified as files to be organized, so that their physical addresses can be managed accordingly in the future.
[0140] Specifically, such as Figure 4A As shown, Figure 4AThis is a schematic diagram of a file management method according to an embodiment of the present invention. In step 406, the host adds the logical address of the file to be reorganized to the update list. The file to be reorganized is a target file whose physical address dispersion exceeds a threshold among the M target files. Specifically, when the host receives the logical physical address mapping information sent by the storage device, since the information includes a mapping relationship between a first logical address range and a first physical address, the host calculates the physical address dispersion of each target file according to the mapping relationship. At the same time, a physical address dispersion threshold can be preset. If the physical address dispersion of a target file exceeds the threshold, the target file is added to the update list as a file to be reorganized, indicating that the physical address dispersion of the target file is high and its physical address needs to be reorganized. If the physical address dispersion of a target file does not exceed the threshold, it means that the physical address dispersion of the target file is not high enough and its physical address does not need to be reorganized temporarily. This can improve the working efficiency of the host and the storage device, and at the same time reduce the increase in wear and tear on the storage device caused by too frequent file reorganization (data migration). For example, Figure 3C As shown in the diagram, files A and B have low physical address dispersion, so they do not require file reorganization and do not need to be added to the update list. However, file C has a logical address range of LBA10-LBA15 and corresponding physical addresses of PPN10-PPN13, PPN16, and PPN18, while file D has a logical address range of LBA16-LBA19 and corresponding physical addresses of PPN14, PPN15, PPN17, and PPN19. This results in higher physical address dispersion for files C and D, necessitating file reorganization. Therefore, these two files are added to the update list.
[0141] Optionally, the update list includes N files to be processed, where N is an integer greater than 0. For example... Figure 4AAs shown, after step 401 determines the first logical address range of the target file set; step 402 sends a first instruction to the storage device; step 403 sends logical physical address mapping information to the host according to the first logical address range; step 404 calculates the physical address dispersion of the M target files according to the mapping relationship; step 405 determines the files to be processed based on the physical address dispersion of the M target files; and step 406 adds the logical addresses of the files to be processed to the update list, step 407 reads the data of the N files to be processed from the storage device to the host memory; step 408 sends the data of the N files to be processed to the host; and step 409 rewrites the data of the N files to be processed to the storage device according to the logical address of each file. The method further includes: when N is greater than the minimum threshold L of the number of files to be processed, reading the data of the N files to be processed from the storage device to the host memory, where L is an integer greater than 0; and rewriting the data of the N files to be processed to the storage device according to the logical address of each file. Specifically, when a certain number of files to be organized accumulate in the update list, the host can read the data of each file from the storage device, and then rewrite the corresponding file data back into the storage device according to the logical address of each file. The rewritten data is stored sequentially in blocks on the storage device. For example, in one scenario, a file's data is stored in only one block, resulting in contiguous physical addresses for that file. In another scenario, if a file's data needs to be stored in different blocks, the data within each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of files to be organized into contiguous physical addresses, reducing file fragmentation. When these files are read again, they can be read more quickly, improving the read performance of the storage device. For example, as... Figure 4B As shown, Figure 4BThis diagram illustrates a fragmented file data storage method provided by an embodiment of the present invention. The host reads data from files C and D from Block 0 of the storage device. Then, the pages in Block 0 that were originally used to store data for files C and D are invalidated. Next, the data for files C and D are rewritten to Block 1 according to their respective logical addresses. In Block 1, the logical addresses of file C are LBA10-LBA11 and their corresponding physical addresses are PPN0-PPN5, while the logical addresses of file D are LBA16-LBA19 and their corresponding physical addresses are PPN6-PPN9. By rewriting the data for files C and D, the physical addresses of the two files are made contiguous. By implementing the method provided by the present invention, the fragmentation level of files C and D can be reduced, improving the data read performance of the storage device. For example... Figure 4C As shown, Figure 4C This is a schematic diagram of a host-side process for a file management method according to an embodiment of the present invention. The diagram includes: S4101 The host system is in an idle state; S4102 The host obtains a list of frequently accessed files; S4103 The host loads a mapping table of logical addresses to physical addresses corresponding to the files into the host memory; S4104 The host checks whether the physical address dispersion of each file exceeds a threshold; S4105 The host reads file data into the host-side memory and rewrites it sequentially into the storage device. Specifically, firstly, when the host's file system is in an idle state, a list of frequently accessed files (the aforementioned target file set) is obtained. Next, the host loads the mapping relationship between logical addresses and physical addresses corresponding to the files in the frequently accessed file list into the host memory. Then, the host calculates the physical address dispersion for each frequently accessed file and checks whether the physical address dispersion of each file exceeds a threshold. If the physical address dispersion of a frequently accessed file exceeds the threshold, the host reads the file data from the storage device into the host-side memory and then rewrites the file data sequentially into the storage device according to the file's logical address. This ultimately reduces file fragmentation and improves the readability of the storage device.
[0142] Optionally, reading data from the N files to be processed from the storage device into the host memory includes: sending an HPB Read command to the storage device; the HPB Read command includes the logical address and physical address of the N files to be processed; or sending a Read command to the storage device; the Read command includes the logical address of the N files to be processed. Specifically, when the host needs to read data from the files to be processed from the storage device, in one possible case, the host can read the data by sending an HPB Read command to the storage device. Since this command includes the logical address and physical address of the files to be processed, the storage device can read the data according to the physical address in the command after receiving the instruction, without first looking up the logical address and physical address mapping table in the storage device based on the logical address of the file to be read, and then reading the data according to the physical address in the mapping table. This can reduce the latency caused by loading the mapping table. It should be noted that since the physical address of the file to be processed in the storage device may change after the host receives the aforementioned logical-physical address mapping information, the HPB Read command can include both the logical address and physical address of the file to be processed. If the physical address of the file to be processed has not changed, the storage device can directly read it based on the physical address in the HPB Read command. If the physical address of the file to be processed has changed, the storage device can find the modified physical address based on the logical address in the HPB Read command, and then read the corresponding data of the file to be processed based on the modified physical address. For example, Figure 4D As shown, Figure 4D This embodiment provides a schematic diagram of an HPB Read instruction. As shown in the diagram, the instruction includes a 4-byte logical address and a 4-byte physical address. When the storage device receives this instruction, it can read the corresponding file data based on the 4-byte physical address in the instruction. Alternatively, the host can send a Read command to the storage device to read data from the file to be processed. It should be noted that the Read command includes a logical address range of the file to be processed. After receiving the Read command, the storage device locates the data stored at the physical address corresponding to the logical address range in the command, and then sends the data to the host.
[0143] It's important to note that because UFS devices have limited internal SRAM, they can only store a small number of logical address and physical address mapping entries. Therefore, during data reading, especially random access, the mapping table is likely not located in the UFS's SRAM. This forces the storage device to spend a significant amount of time retrieving the necessary mapping table from the storage medium into the UFS's SRAM, and only after finding the physical address through the logical address can the data be read. This lengthy process of retrieving the mapping table from the storage medium significantly reduces the storage device's read performance. To address the issue of insufficient memory in storage devices, reduce the frequency of loading mapping tables from the medium, and improve read speed, the UFS 3.1 protocol introduces HPB technology: a portion of the logical address and physical address mapping table is loaded into host memory. It should be noted that the UFS 3.1 protocol defines the HPB Entry size as 8 bytes, but does not specify the exact form of these 8 bytes. Optionally, in this embodiment, these 8 bytes can be split into: the first 4 bytes of physical address and the last 4 bytes of verification information, or the first 4 bytes of verification information and the last 4 bytes of physical address. Therefore, one LBA corresponds to one HPB Entry, and the HPB Entry contains the physical address corresponding to the current LBA. For example, as... Figure 3D As shown, Figure 3DThis invention provides an HPB initialization flowchart, which includes: Step 1: Initialization operation, configuring the HPB characteristics of the UFS device and allocating host memory; Step 2: The host uses the HPB Read Buffer command to read table entry information; Step 3: The UFS device reads the table entry information; Step 4: The UFS device transmits the table entry information to the host; Step 5: The host stores the table entry information in the host memory; Step 6: The host sends information with the physical address along with the HPB Read command to read data, reducing the latency caused by loading table entries. Specifically, when the storage device receives the HPB Read Buffer instruction sent by the host, it reads the table entry information from the storage device and then sends the table entry information to the host. In this way, when reading data, the physical address corresponding to the logical address of the data can be sent to the storage device along with the HPBREAD command, allowing the storage device to directly read data using the received physical address, thereby improving the read speed. Specifically, when using the HPB Read Buffer instruction to read a segment of table entries, such as those corresponding to LBA0-LBA1000, the storage device returns 1000 HPB Entries, including PPN0-PPN1000, along with corresponding checksum information (to prevent tampering with physical address information). This information is then stored in the host's memory. Since the host stores these 1000 8-byte entries sequentially, logical addresses can be calculated using memory addresses. For example, LBA1001-2000 are stored in memory addresses 8000-16000, memory addresses 8000-8007 store the HPB Entry corresponding to LBA1001, and memory addresses 8008-8015 store the HPB Entry corresponding to LBA1002. In one scenario, when using HPB Read to read LBA1002, the memory address of the HPB Entry corresponding to LBA1002 is calculated based on LBA1002, thus obtaining the 8 bytes of data. Therefore, the data is obtained... Figure 4DThe information in Bytes 2-13 allows a read request to be sent to the storage device. In one possible implementation, the storage device supports Host Performance Enhancement Technology (HPB); the method further includes: receiving an HPB Read command sent by the host, the HPB Read command including the logical addresses and physical addresses of N files to be processed; reading data from the N files to be processed according to the physical addresses in the HPB Read command, and sending the data from the N files to be processed to the host; or, receiving a Read command sent by the host, the Read command including the logical addresses of the N files to be processed, finding the corresponding physical addresses in the Read command to read the data from the N files to be processed, and sending the data from the N files to be processed to the host. Specifically, when the host wants to read data from the files to be processed from the storage device, in one possible case, the host can read the data by sending an HPBRead command to the storage device. Because the command includes both the logical and physical addresses of the file to be processed, the storage device can read the data based on the physical address in the command after receiving it. This avoids having to look up the logical-to-physical address mapping table in the storage device based on the logical address of the file and then read the data based on the physical address in that table. This reduces the latency caused by loading the mapping table. It should be noted that the physical address of the file to be processed in the storage device may change after the host receives the aforementioned logical-to-physical address mapping information. Therefore, the HPB Read command can include both the logical and physical addresses of the file to be processed. If the physical address of the file to be processed has not changed, the storage device can directly read the data based on the physical address in the HPB Read command. If the physical address of the file to be processed has changed, the storage device can find the modified physical address based on the logical address in the HPB Read command and then read the corresponding data of the file to be processed based on the modified physical address. In another possible scenario, the host can send a Read command to the storage device to read the data of the file to be processed. It should be noted that the Read command includes the logical address range of the file to be processed. After receiving the Read command, the storage device finds the data stored at the physical address corresponding to the logical address range in the command, and then sends the data to the host.
[0144] Optionally, the update list includes N files to be processed, where N is an integer greater than 0, such as... Figure 5A As shown, Figure 5AThis is a schematic diagram of another file management method provided by an embodiment of the present invention. After step 501, determining a first logical address range for the target file set; step 502, sending a first instruction to the storage device; step 503, sending logical-physical address mapping information to the host according to the first logical address range; step 504, calculating the physical address dispersion of the M target files according to the mapping relationship; step 505, determining the files to be organized based on the physical address dispersion of the M target files; and step 506, adding the logical addresses of the files to be organized to the update list, as shown in step 507, sending first information to the storage device, the method further includes: when N is greater than a minimum threshold L for the number of files to be organized, sending first information to the storage device; the first information includes one or more of the following: the number N of the N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address of the logical address segment, and its length. Specifically, after the host completes the calculation of the physical address dispersion of the target files, it adds the target files with high physical address dispersion to the update list as files to be processed. When a certain number of files to be processed accumulate in the update list, the host sends first information to the storage device. Since this information includes the number of files to be processed, the number of logical address segments corresponding to each file, and the starting address and length of each logical address segment, the storage device, when idle, will move the data of the files to be processed based on this first information. For example, in one case, the file data can be moved to one block, in which case the file's physical address is contiguous; in another case, the file data needs to be moved to different blocks, but the data of the file in each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of the files to be processed can be organized into contiguous physical addresses, reducing file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device. For example, as... Figure 5B As shown, Figure 5B This diagram illustrates a first information format provided in an embodiment of the present invention. The first information includes the number of files to be transferred, n (the files to be organized mentioned above), the number of logical address segments in each file, and the starting address and length of each logical address segment. The storage device can move data from the files to be organized based on this information. For example, if file 1 contains m1 logical address segments, and the information includes the starting address and length of the first logical address segment of file 1, up to the starting address and length of the m1th logical address segment of file 1, the storage device will move data from file 1 accordingly. This achieves file organization for files with high physical address dispersion, reduces file fragmentation, and improves the performance of the storage device in reading files.
[0145] Optionally, the storage device receives first information sent by the host; the first information includes one or more of the following: the number N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address and length of the logical address segments; and the data of the N files to be organized is moved according to the first information. For example, such as... Figure 5A Step 508 in the diagram illustrates the data transfer operation of the N files to be processed based on the first information. Specifically, after the host completes the calculation of the dispersion of the target files, it adds the target files with higher physical address dispersion as files to be processed to the update list. When a certain number of files to be processed accumulate in the update list, the host can send the first information to the storage device. This information includes the number of files to be processed, the number of logical address segments corresponding to each file, and the starting address and length of the logical address segments. When the storage device receives this first information, it will transfer the data of the files to be processed according to this first information. For example, one case is that the file data can be moved to one block, in which case the physical address of the file is contiguous; another case is that the file data needs to be moved to different blocks, but the data of the file in each block is contiguous. By implementing the method provided by this invention, the discrete physical addresses of the files to be processed can be organized into contiguous physical addresses, reducing the degree of file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device. For example, as... Figure 4B As shown, in an idle state, the storage device can move data from file C and file D from Block 0 to Block 1 based on the first information. Before the data movement, the logical address range of file C in Block 0 is LBA10-LBA15, and its corresponding physical addresses are PPN10-PPN13, PPN16, and PPN18. The logical address range of file D is LBA16-LBA19, and its corresponding physical addresses are PPN14, PPN15, PPN17, and PPN19. After the data movement, the logical address of file C in Block 1 is LBA10-LBA11, and its corresponding physical addresses are PPN0-PPN5. The logical address of file D in Block 1 is LBA16-LBA19, and its corresponding physical addresses are PPN6-PPN9. This achieves file reorganization of both file C and file D, re-moving data from files with high physical address dispersion according to their logical addresses, reducing file fragmentation, and improving the performance of the storage device in reading files.
[0146] In one possible implementation, the step of moving the data of the files to be organized according to the first information includes: when the storage device is in a working state, storing the first information in the storage medium; and when the storage device is in an idle state, moving the data of the N files to be organized according to the first information. Specifically, when the storage device receives the first information sent by the host, if the storage device is currently performing other tasks, it will first store the first information in the storage device. When the storage device finishes its task and is in an idle state, it will then move the data of the files to be organized according to the information. This process organizes the discrete physical addresses of the files to be organized into contiguous physical addresses, reducing file fragmentation. When these files are read again, they can be read faster, improving the read performance of the storage device. It's important to note that in this scenario, the storage device performs garbage collection based on the host's analysis results at specific times. Leveraging the host's high CPU processing power, file fragmentation analysis is handled by the host, while file defragmentation is delegated to the storage device during idle periods. This ensures defragmentation is achieved without interrupting the storage device's normal input / output (I / O) processes, and also reduces write amplification compared to traditional garbage collection. For example, ... Figure 5C As shown, Figure 5CThis is a flowchart illustrating another file management method provided in an embodiment of the present invention. The flowchart includes the following steps: S5101: The host system is in an idle state; S5102: The host obtains a list of frequently accessed files; S5103: The host loads the mapping table of logical addresses to physical addresses corresponding to the files into the host memory; S5104: Each file is individually checked to determine whether the dispersion of its physical address exceeds a threshold; S5105: The host sends all logical address ranges corresponding to the files to the storage device; S5106: The storage device receives the starting logical address of the file with high dispersion from the host side and stores it in a specific area; S5107: The storage device performs fragmentation and reorganization on the files with high dispersion analyzed by the host side; S5108: End. Specifically, firstly, when the host's file system is idle, a list of frequently accessed files (the target file set mentioned above) is obtained. Next, the host loads the mapping relationship between the logical addresses and physical addresses of the files in the frequently accessed file list into the host memory. Then, the physical address dispersion of each frequently accessed file is calculated, and it is determined whether the physical address dispersion of each file exceeds a threshold. If the physical address dispersion of a frequently accessed file exceeds the threshold, the host sends the logical address range corresponding to that file to the storage device. The storage device receives the starting logical address of the file with high dispersion sent by the host and stores it in a specific area. Then, the storage device performs fragmentation and reorganization according to the file with high dispersion analyzed by the host, ultimately reducing the degree of file fragmentation and improving the readability of the storage device.
[0147] By implementing the file management method provided by this invention, after the host obtains the mapping relationship between the logical address and physical address of a file or file fragment, it can calculate the degree of physical address dispersion of the file or file fragment more quickly, enabling the host to actively manage the physical address of the file or file fragment, reducing the degree of file fragmentation and improving the performance of the storage device in reading files. At the same time, it can reduce the increase in wear and tear on storage devices caused by excessively frequent file organization (data migration).
[0148] Figure 6A This illustration shows a flow chart of a file management method applied to an electronic device according to an embodiment of the present invention. The method is applied to an electronic device, which may include a host and a storage device. For a description of the host and storage device, please refer to the above. Figures 2A-2C The descriptions of the host 10 and storage device 103 are omitted here. The method flow mainly describes the method steps on the electronic device side, which may include:
[0149] Step S601: The electronic device runs the target application.
[0150] Specifically, the first data of the first file of the target application is stored in a first storage block in the storage device. For example, assuming the target application is currently running on the electronic device (e.g., the user has opened one of the applications on their phone, such as Taobao, WeChat, QQ, video, or reading), the first file of the target application (e.g., a chat history file from WeChat) is loaded into a storage block of the storage device. Figure 6B As shown, Figure 6B This is a schematic diagram of a target application provided in an embodiment of the present invention. The diagram illustrates how a user can run a social application installed on an electronic device, such as... For the application, please refer to user interface 71. At this time, the user can click through the input device of the electronic device, such as the display screen 106. The icon is 701. Next, please refer to the user interface 72. At this time, the user is prompted to log in by entering their username and password through the account input box 702 and password input box 703. The application interface, or user interface 73, is as follows: Assuming the user clicks on the chat window with user Arvin, the user will enter the chat interface shown in user interface 74. At this point, the chat history between the user and Arvin is stored as the first data in the first storage block of the storage device. It should be noted that the first data includes all chat history between the user and other users at this time.
[0151] Step S602: In response to a data update operation on the first file of the target application.
[0152] Specifically, the host updates the second data of the first file to the second storage block of the storage device. It should be noted that when performing a data update operation on the first file of the target application, the second data of the first file can be stored in the storage block that stores the first data, or the data can be stored in another storage block. However, this embodiment of the invention mainly addresses the situation where the first data of the first file and the updated second data are stored in different storage blocks. In this case, the fragmentation of the first file increases, further highlighting the advantages of the file management method provided by this embodiment of the invention. For example, as... Figure 6C As shown, Figure 6C This is a schematic diagram of a data update interface provided in an embodiment of the present invention. In the diagram, the user interface 75 compares the chat history between user 75 and Arvin with... Figure 6BIn the user interface 74, the user sends a new message 706 to Arvin. If the updated chat history data is stored as the second data in the second storage block of the storage device, then the first data of the first file and the second data are stored in different storage blocks of the storage device. It should be noted that the second data includes updated chat history data between the user and other users. For example, in one application scenario, as the chat application is used for longer periods, the physical addresses storing the chat history files may become highly dispersed. When viewing historical chat history again, the slow reading speed may occur because the historical chat history is distributed across multiple physical blocks of the memory. By using the method provided in this embodiment of the invention, chat history files can be organized, making it easier for users to view chat history more quickly.
[0153] Step S603: The host determines the first logical address range of the target file set.
[0154] Specifically, the target file set includes M target files, and the first file is one of the M target files; M is an integer greater than 0. When the host file system is idle, the host acquires frequently accessed files or file fragments as target files and adds these target files to the target file set. The target file set may include one or more target files. It should be noted that these frequently accessed files or file fragments can be actively set by the user, and then the host uses the user-set frequently accessed files or file fragments as target files to generate the target file set. For example, as shown... Figure 6D As shown, Figure 6D This is a schematic diagram of a target file settings interface provided in an embodiment of the present invention. In the diagram, the user enters the system device function user interface 82 by clicking the settings button 801. The user further clicks the file management settings 802, thereby entering the target application settings user interface 83. The user can use toggle controls for various applications, such as the toggle controls 803 in the image library. Switch control 804 The switch control 805, music switch control 806, etc., enable or disable the "target application settings" for each application. A prompt message 807 reminds the user: "When the target application settings mode is enabled (ON), the application's file data can be used as the target file, making it easier to actively manage the file's storage address." At this time, the gallery switch control 803 and... When switch control 805 is enabled, the user actively sets the file data of these two applications as frequently accessed target files and adds these two target files to the target file set. Optionally, the host can actively filter target files. After the host determines the target file set, it obtains a first logical address range based on the logical address range of the target files in the target set. This first logical address range includes the logical address ranges of all target files.
[0155] Step S604: The host sends a first instruction to the storage device.
[0156] Specifically, the first instruction includes the first logical address range. After the host obtains the first logical address based on the target file set, it sends a first instruction to the storage device, which instructs the storage device to send the mapping relationship between the logical address and physical address of the target file set.
[0157] Step S605: The host receives the logical physical address mapping information sent by the storage device.
[0158] Specifically, the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address. When the storage device finds the physical page number (PPN) corresponding to the first logical address range according to the instruction sent by the host, it obtains the mapping relationship between the first logical address range and the first physical address range, and then sends the mapping relationship to the host, so that the host can subsequently perform corresponding calculations on the physical address dispersion of the target file.
[0159] Step S606: The host calculates the physical address dispersion of the M target files according to the mapping relationship, and determines the files to be sorted based on the physical address dispersion of the M target files.
[0160] Specifically, in existing technologies, the host's file system can only perceive the logical addresses of files, but not the distribution of the corresponding physical addresses in the storage device. Therefore, the host cannot calculate the physical address dispersion of files. However, the method provided in this invention allows the host to obtain the mapping relationship between the logical addresses and physical addresses of the target file set from the storage device side. The host can then calculate the physical address dispersion of each target file based on this mapping relationship. After calculating the physical address dispersion of each target file, some files will have insufficient physical address dispersion and will not require file reorganization. Files with high physical address dispersion will be identified as files requiring reorganization, facilitating subsequent management of their physical addresses.
[0161] Step S607: The electronic device responds to a read operation on the first file of the target application.
[0162] When the file to be organized includes the first file, and the first data and the second data are organized into a third storage block, the electronic device, in response to a read operation on the first file of the target application, reads the first data and the second data from the third storage block of the storage device. It should be noted that the third storage block can be the first storage block, the second storage block, or a storage block other than the first and second storage blocks. For example, as... Figure 6E As shown, Figure 6E This is a schematic diagram of a user interface provided in an embodiment of the present invention. In the diagram, after the electronic device has completed the above steps, when the user re-enters... After accessing the user interface 93, the user can further click on option 904 to view the chat history with friend Avrin. By implementing the method provided by this invention, the user can load all chat history more quickly.
[0163] The methods of the embodiments of the present invention have been described in detail above. The related devices of the embodiments of the present invention are provided below.
[0164] Please see Figure 7A , Figure 7A This is a schematic diagram of the structure of a file management device provided in an embodiment of the present invention. The file management device 71 may include a first processing unit 7101, a first sending unit 7102, a first receiving unit 7103, a first calculation unit 7104, a second processing unit 7105, a third processing unit 7106, a first reading unit 7107, and a second sending unit 7108, wherein each unit is described in detail below.
[0165] The first processing unit 7101 is used to determine a first logical address range of the target file set; the target file set includes M target files; M is an integer greater than 0;
[0166] The first sending unit 7102 is configured to send a first instruction to the storage device; the first instruction includes the first logical address range.
[0167] The first receiving unit 7103 is configured to receive logical physical address mapping information sent by the storage device; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address;
[0168] The first calculation unit 7104 is used to calculate the physical address dispersion of the M target files according to the mapping relationship;
[0169] The second processing unit 7105 is used to determine the files to be processed based on the dispersion of the physical addresses of the M target files.
[0170] In one possible implementation, M is greater than 1; the first processing unit 7101 is specifically used to: obtain the logical address range of each target file according to the node information of each target file in the M target files; merge the logical address ranges of each target file to obtain the first logical address range; the node information includes the logical address information of the corresponding target file.
[0171] In one possible implementation, the first instruction is an HPB Read Buffer instruction; the first sending unit 7102 is specifically used to: send the HPB Read Buffer instruction to the storage device when M is greater than a preset threshold for the number of target files.
[0172] In one possible implementation, the device further includes: a third processing unit 7106, configured to add the logical address of the file to be processed to an update list; the file to be processed is a target file among the M target files whose physical address dispersion exceeds a threshold.
[0173] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the device further includes: a first reading unit 7107, configured to read data of the N files to be organized from the storage device into host memory when N is greater than a minimum threshold L for the number of files to be organized, where L is an integer greater than 0; and rewrite the data of the N files to be organized into the storage device according to the logical address of each file to be organized.
[0174] In one possible implementation, the first reading unit 7107 is specifically configured to: send an HPB Read command to the storage device; the HPB Read command includes the logical addresses and physical addresses of the N files to be organized; or, send a Read command to the storage device; the Read command includes the logical addresses of the N files to be organized.
[0175] In one possible implementation, the update list includes N files to be organized, where N is an integer greater than 0; the device further includes a second sending unit 7108, configured to send first information to the storage device when N is greater than a minimum threshold L of the number of files to be organized; the first information includes one or more of the following: the number N of the N files to be organized, the number of logical address segments corresponding to each file to be organized, the starting address of the logical address segment, and its length.
[0176] It should be noted that the functional modules of the file management device 71 described in this embodiment of the invention can be found in the above-mentioned... Figure 3A The relevant descriptions of steps S301-S302 and S304-S305 in the method embodiment will not be repeated here.
[0177] Please see Figure 7B , Figure 7B This is a schematic diagram of another file management device provided in an embodiment of the present invention. The file management device 72 may include a first receiving unit 7201, a first sending unit 7202, a second receiving unit 7203, a third receiving unit 7204, and a first processing unit 7205, wherein each unit is described in detail below.
[0178] The first receiving unit 7201 is configured to receive a first instruction sent by the host; the first instruction includes the first logical address range.
[0179] The first sending unit 7202 is used to send logical physical address mapping information to the host according to the first logical address range; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address.
[0180] In one possible implementation, the storage device supports Host Performance Enhancement Technology (HPB); the first instruction is an HPB Read Buffer instruction.
[0181] In one possible implementation, the storage device supports Host Performance Enhancement (HPB) technology; the device further includes: a second receiving unit 7203, configured to receive an HPB Read command sent by the host, the HPB Read command including logical addresses and physical addresses of N files to be processed; read data of the N files to be processed according to the physical addresses in the HPB Read command, and send the data of the N files to be processed to the host; or, receive a Read command sent by the host, the Read command including logical addresses of the N files to be processed, find the corresponding physical addresses according to the logical addresses of the N files to be processed in the Read command, read the data of the N files to be processed, and send the data of the N files to be processed to the host.
[0182] In one possible implementation, the device further includes: a third receiving unit 7204, configured to receive first information sent by the host; the first information includes one or more of the following: the number N files to be organized, the number of logical address segments corresponding to each of the N files to be organized, the starting address and length of the logical address segments; and a first processing unit 7205, configured to perform a data transfer operation on the N files to be organized according to the first information.
[0183] In one possible implementation, the first processing unit 7205 is specifically used to: store the first information in the storage medium when the storage device is in a working state, and move the data of the N files to be organized according to the first information when the storage device is in an idle state.
[0184] It should be noted that the functional modules of the file management device 72 described in this embodiment of the invention can be found in the above-mentioned... Figure 3A The relevant descriptions of step S303 in the embodiments of the method described will not be repeated here.
[0185] This invention also provides a computer-readable storage medium, wherein the computer-readable storage medium may store a program, which, when executed by a host or storage device, implements some or all of the steps of any of the file management methods described in the above method embodiments.
[0186] This invention also provides a computer program that includes instructions that, when executed by a host or storage device, enable the host or storage device to perform some or all of the steps of any file management method.
[0187] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0188] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0189] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0190] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0191] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0192] If the integrated units described above are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which can be a personal computer, server, or network device, specifically a processor in the computer device) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium may include various media capable of storing program code, such as a USB flash drive, portable hard drive, magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM).
[0193] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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 of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A file management method, characterized in that, Applied to a host, the method includes: A first logical address range is determined for the target file set; the target file set includes M target files; M is an integer greater than 0; the first logical address range is a continuous logical address range. Send a first instruction to the storage device; the first instruction includes the first logical address range; Receive logical physical address mapping information sent by the storage device; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address; The physical address dispersion of the M target files is calculated based on the mapping relationship, and the files to be sorted are determined based on the physical address dispersion of the M target files. The method further includes: adding the logical address of the file to be sorted to an update list; the file to be sorted is a target file among the M target files whose physical address dispersion exceeds a threshold; the update list includes N files to be sorted, where N is an integer greater than 0; The method further includes: reading data from the storage device into the host memory; rewriting the data of the N files to be organized into the storage device according to the logical address of each file; wherein the dispersion of the physical addresses of the N files to be organized after organization is less than the dispersion before organization.
2. The method as described in claim 1, characterized in that, The M is greater than 1; determining the first logical address range of the target file set includes: Based on the node information of each of the M target files, the logical address range of each target file is obtained; the logical address ranges of each target file are merged to obtain the first logical address range; the node information includes the logical address information of the corresponding target file.
3. The method as described in claim 1, characterized in that, The first instruction is an HPB Read Buffer instruction; sending the first instruction to the storage device includes: When M is greater than a preset threshold for the number of target files, the HPB Read Buffer instruction is sent to the storage device.
4. The method as described in claim 1, characterized in that, The method further includes: When N is greater than the minimum threshold L for the number of files to be organized, the data of the N files to be organized are read from the storage device into the host memory, where L is an integer greater than 0; The data of the N files to be organized are rewritten into the storage device according to the logical address of each file.
5. The method as described in claim 4, characterized in that, The step of reading data from the N files to be processed from the storage device into the host memory includes: Send an HPB Read command to the storage device, the HPB Read command including the logical and physical addresses of the N files to be processed; or... Send a Read command to the storage device, the Read command including the logical addresses of the N files to be processed.
6. The method as described in claim 1, characterized in that, The update list includes N files to be processed, where N is an integer greater than 0; the method further includes: When N is greater than the minimum threshold L of the number of files to be sorted, first information is sent to the storage device; the first information includes one or more of the following: the number N of the N files to be sorted, the number of logical address segments corresponding to each file to be sorted, the starting address and length of the logical address segments.
7. A file management method, characterized in that, Applied to a storage device, the method includes: The system receives a first instruction sent by a host; the first instruction includes a first logical address range of a target file set; the target file set includes M target files; M is an integer greater than 0; the first logical address range is a continuous logical address range; the system sends logical physical address mapping information to the host according to the first logical address range; the logical physical address mapping information includes the mapping relationship between the first logical address range and a first physical address. The method further includes: The host sends data of N files to be processed, so that the host rewrites the data of the N files to be processed into the storage device according to the logical address of each file; N is an integer greater than 0, and the N files to be processed are the target files whose physical address dispersion exceeds a threshold determined by the host based on the physical address dispersion of the M target files according to the mapping relationship; wherein, the dispersion of the physical address of the rewritten N files to be processed is less than the dispersion before processing.
8. The method as described in claim 7, characterized in that, The storage device supports Host Performance Enhancement Technology (HPB); the first instruction is the HPB Read Buffer instruction.
9. The method as described in claim 7, characterized in that, The storage device supports Host Performance Enhancement Technology (HPB); the method further includes: Receive an HPB Read command sent by the host, the HPB Read command including the logical addresses and physical addresses of N files to be processed; read the data of the N files to be processed according to the physical addresses in the HPB Read command, and send the data of the N files to be processed to the host; or, The system receives a Read command sent by the host, the Read command including the logical addresses of the N files to be organized, finds the corresponding physical addresses based on the logical addresses of the N files to be organized in the Read command, reads the data of the N files to be organized, and sends the data of the N files to be organized to the host.
10. The method as described in claim 7, characterized in that, The method further includes: The system receives first information sent by the host; the first information includes one or more of the following: the number N of the N files to be sorted, the number of logical address segments corresponding to each file to be sorted, the starting address and length of the logical address segments; Based on the first information, the data of the N files to be organized is moved.
11. The method as described in claim 10, characterized in that, The step of moving the data of the file to be organized according to the first information includes: When the storage device is in working condition, the first information is stored in the storage medium. When the storage device is in idle condition, the data of the N files to be organized is moved according to the first information.
12. A document management device, characterized in that, Applied to a host computer, the device includes: A first processing unit is configured to determine a first logical address range of a target file set; the target file set includes M target files; M is an integer greater than 0; the first logical address range is a continuous logical address range; a first sending unit is configured to send a first instruction to a storage device; the first instruction includes the first logical address range; The first receiving unit is configured to receive logical physical address mapping information sent by the storage device; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address; The first calculation unit is used to calculate the physical address dispersion of the M target files based on the mapping relationship. The second processing unit is used to determine the files to be processed based on the dispersion of the physical addresses of the M target files; The third processing unit is used to add the logical address of the file to be processed to the update list; the file to be processed is the target file whose physical address dispersion exceeds a threshold among the M target files; the update list includes N files to be processed, where N is an integer greater than 0; The first reading unit is used to read the data of the N files to be organized from the storage device into the host memory respectively; The second processing unit is further configured to rewrite the data of the N files to be processed into the storage device according to the logical address of each file to be processed; wherein the dispersion of the physical addresses of the N files to be processed after rewriting is less than the dispersion before processing.
13. The device as claimed in claim 12, characterized in that, The M is greater than 1; the first processing unit is specifically used for: Based on the node information of each of the M target files, the logical address range of each target file is obtained; the logical address ranges of each target file are merged to obtain the first logical address range; the node information includes the logical address information of the corresponding target file.
14. The device as claimed in claim 12, characterized in that, The first instruction is an HPB Read Buffer instruction; the first sending unit is specifically used for: When M is greater than a preset threshold for the number of target files, the HPB Read Buffer instruction is sent to the storage device.
15. The device as claimed in claim 12, characterized in that, The first reading unit is further configured to, when N is greater than the minimum threshold L of the number of files to be organized, read the data of the N files to be organized from the storage device into the host memory, where L is an integer greater than 0; and rewrite the data of the N files to be organized into the storage device according to the logical address of each file to be organized.
16. The device as claimed in claim 15, characterized in that, The first reading unit is specifically used for: Send an HPB Read command to the storage device; the HPB Read command includes the logical and physical addresses of the N files to be processed; or, Send a Read command to the storage device; the Read command includes the logical addresses of the N files to be processed.
17. The device as claimed in claim 12, characterized in that, The update list includes N files to be processed, where N is an integer greater than 0; the device also includes: The second sending unit is configured to send first information to the storage device when N is greater than the minimum threshold L of the number of files to be sorted; the first information includes one or more of the following: the number N of the N files to be sorted, the number of logical address segments corresponding to each file to be sorted, the starting address and length of the logical address segments.
18. A document management device, characterized in that, Applied to a storage device, the device includes: A first receiving unit is configured to receive a first instruction sent by a host; the first instruction includes a first logical address range of a target file set; the target file set includes M target files; M is an integer greater than 0; the first logical address range is a continuous logical address range; a first sending unit is configured to send logical physical address mapping information to the host according to the first logical address range; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address. The first sending unit is further configured to send data of N files to be processed to the host, so that the host rewrites the data of the N files to be processed according to the logical address of each file to be processed into the storage device; N is an integer greater than 0, and the N files to be processed are target files whose physical address dispersion exceeds a threshold determined by the host based on the physical address dispersion of the M target files according to the mapping relationship; wherein, the dispersion of the physical address of the rewritten N files to be processed is less than the dispersion before processing.
19. The device as claimed in claim 18, characterized in that, The storage device supports Host Performance Enhancement Technology (HPB); the first instruction is the HPB Read Buffer instruction.
20. The device as claimed in claim 18, characterized in that, The storage device supports Host Performance Enhancement Technology (HPB); the device also includes: The second receiving unit is configured to receive an HPB Read command sent by the host, the HPB Read command including the logical addresses and physical addresses of N files to be organized; read the data of the N files to be organized according to the physical addresses in the HPB Read command, and send the data of the N files to be organized to the host; or, receive a Read command sent by the host, the Read command including the logical addresses of the N files to be organized, find the corresponding physical addresses according to the logical addresses of the N files to be organized in the Read command, read the data of the N files to be organized, and send the data of the N files to be organized to the host.
21. The device as claimed in claim 18, characterized in that, The device also includes: The third receiving unit is used to receive first information sent by the host; the first information includes one or more of the following: the number N of the N files to be sorted, the number of logical address segments corresponding to each file to be sorted, the starting address and length of the logical address segments; The first processing unit is used to perform a data transfer operation on the N files to be sorted based on the first information.
22. The device as claimed in claim 21, characterized in that, The first processing unit is specifically used for: When the storage device is in working condition, the first information is stored in the storage medium. When the storage device is in idle condition, the data of the N files to be organized is moved according to the first information.
23. A file management method, characterized in that, Applied to an electronic device, the electronic device including a host and a storage device, the method includes: The electronic device runs a target application, and the first data of the first file of the target application is stored in a first storage block in the storage device; In response to a data update operation on the first file of the target application, the host updates the second data of the first file to the second storage block of the storage device; The host determines a first logical address range of the target file set; the target file set includes M target files, and the first file is one of the M target files; M is an integer greater than 0; the first logical address range is a continuous logical address range; The host sends a first instruction to the storage device; the first instruction includes the first logical address range. The host receives logical physical address mapping information sent by the storage device; the logical physical address mapping information includes the mapping relationship between the first logical address range and the first physical address; The host calculates the physical address dispersion of the M target files according to the mapping relationship, and determines the files to be processed based on the physical address dispersion of the M target files; the files to be processed are the target files among the M target files whose physical address dispersion exceeds a threshold. The host reads the data of the file to be organized from the storage device into the host memory; rewrites the data of the file to be organized into the storage device according to the logical address of the file to be organized; wherein the dispersion of the physical address of the rewritten file to be organized is less than the dispersion before organization; when the file to be organized includes the first file, and the first data and the second data are organized into a third storage block in the storage device, in response to the read operation of the first file of the target application, the host reads the first data and the second data from the third storage block of the storage device.
24. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory is used to store program code, and the processor is used to invoke the program code stored in the memory to cause the electronic device to perform the method as described in claim 23.
25. A computer program product, characterized in that, The computer program product includes instructions that, when executed by a storage device, cause the storage device to perform the method as described in any one of claims 1-6.
26. A computer program product, characterized in that, The computer program product includes instructions that, when executed by a host, cause the host to perform the method as described in any one of claims 7-11.
27. A computer program product, characterized in that, The computer program product includes instructions that, when executed by a host, cause the electronic device to perform the method as described in any one of claims 23.
Citation Information
Patent Citations
Data access method and data access device
CN104866428A
Storage Module and Host Device for Storage Module Defragmentation
CN105917333A
Address mapping relationship feedback method, device, apparatus, and readable storage medium
CN109344094A
Method of operating storage device, storage device performing the same and method of operating storage system
CN111128287A