Method and device for accelerating access to USB flash disk and medium
By introducing the CACHE module and optimizing the continuous BLOCK reading mechanism in the single-guided device platform, the problem of low USB disk access efficiency in the prior art is solved, and the data transmission performance is significantly improved.
Patent Information
- Application Number
- CN202411437590.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-01-07
AI Technical Summary
When accessing USB disk data, existing single-guided device platforms frequently query BLOCK index blocks, resulting in a large number of I/O requests and inefficient transmission performance.
The CACHE module is introduced in the middle of the CPU and file system modules of the single-guide device platform to cache BLOCK data with high access frequency, and reduce the number of I/O accesses through the CACHE module, and optimize the reading mechanism of multiple continuous BLOCKs.
It greatly reduces the number of I/O requests of the single-guided chip CPU, improves data transmission efficiency, and improves USB disk access efficiency, from 6M/S to 22M/S.
Smart Images

Figure CN119271146A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage, and in particular to a method, a device and a medium for accelerating access to a USB flash drive. Background Art
[0002] With the continuous advancement and full popularization of localization, various industries have begun to apply domestic hosts and systems on a large scale. In order to be compatible with Windows host systems, the industry has launched a single-guide device platform for one-way import of USB flash drives. Through this single-guide device platform, cross-platform data transmission of USB flash drive data of any file system type can be realized, greatly improving convenience and security. At present, when parsing the file system of the USB flash drive, the general single-guide device platform needs to query the physical address of the BLOCK where the data is located each time it accesses the BLOCK where the data is located, and due to the limitations of the file system, it can only read the data of one BLOCK (4K) at a time, and there are problems such as inefficient transmission performance.
[0003] like Figure 1 As shown in the figure, it is a working schematic diagram of the existing single-guide device platform. The single-guide device platform transfers the data in the U disk to the PC end. The single-guide device platform has the function of identifying and processing the target U disk file system. After the U disk is inserted into the single-guide module, the single-guide module identifies the U disk device through the driver layer, and parses the data content in the U disk through the file system module, and transfers the U disk data to the PC host, realizing cross-platform data transmission of different file systems. When accessing the file system, due to the BLOCK storing the file index (index BLOCK for short), each time the BLOCK is read, it is necessary to read the index BLOCK first, query the target BLOCK, and then access the corresponding data block according to the BLOCK physical address. In the single-guide chip, when the CPU accesses the file system structure of the U disk, it queries the BLOCK index block, and will access the specified index BLOCK multiple times to obtain the BMAP of the data BLOCK, resulting in too many I / O requests. Summary of the invention
[0004] In view of the defects of the prior art, the present invention provides a method, device and medium for accelerating access to a USB flash drive, which reduces the number of I / O requests for a single-chip CPU to access the USB flash drive, increases the amount of data transmitted at one time, and thus greatly improves data transmission efficiency.
[0005] In order to solve the technical problem, the technical solution adopted by the present invention is: a method for accelerating access to a USB flash drive, the method comprising: A CACHE module is added between the CPU and the file system module of the single-boot device platform. The CACHE module is used to store blocks with access frequencies greater than the set requirements. When the CPU of the single-boot device platform wants to read data from the USB flash drive, it first searches the CACHE list. If the corresponding block is found, the data is directly taken from the CACHE, which reduces the number of CPU I / O accesses. At the same time, when the CPU of the single-lead device platform starts to read data, it first checks whether the BLOCK addresses to be read are continuous. If they are continuous, multiple continuous BLOCKs are read at one time.
[0006] Furthermore, the CACHE module sets up multiple partitions, each partition is used to store cache data and information of one BLOCK, the information includes a physical BLOCK address, access count, abandonment flag, and use flag. After the CPU starts an I / O request, it reads the physical BLOCK address from the U disk, and records the physical BLOCK address and the data stored in it into the CACHE partition. When all partitions are used up, the available CACHE partitions are determined based on the access count, abandonment flag, and use flag, and the information of the available CACHE partitions is updated; when the CPU reads the physical BLOCK address, it first retrieves it from the CACHE module. If the physical BLOCK to be accessed exists in the CACHE module, the data is directly obtained from the corresponding CACHE module.
[0007] Furthermore, the index BLOCK is always stored in the CACHE module.
[0008] Furthermore, the process of querying BLOCK cache data from the CACHE module is as follows: the CPU initiates a read data request, matches the physical BLOCK address in the CACHE partition according to the target BLOCK address, traverses the cache data corresponding to the physical BLOCK address in the CACHE partition, and if the physical BLOCK address is matched, directly reads the corresponding cache data and increments the access count in the cache partition, indicating that the physical BLOCK address is accessed.
[0009] Furthermore, the process of storing BLOCK data in the CACHE module is as follows: after the CPU starts an I / O request, the physical BLOCK address and BLOCK data obtained each time are placed in the CACHE linked list. The storage logic is as follows: first check whether there is an unused CACHE partition. If so, return the address of the current CACHE partition and store the BLOCK data and address information in the CACHE partition. If not, it means that the CACHE module is full. Then traverse the CACHE list and compare the number of accesses. The address of the CACHE partition with the least number of accesses is returned for writing the latest BLOCK data and address information. If the available CACHE partition has not been traversed, return the address of the last CACHE partition in the CACHE list.
[0010] Furthermore, it is checked whether there is an unused CACHE partition by using the usage flag. If the usage flag is 0, it indicates that there is an unused CACHE partition.
[0011] Furthermore, a byte flag is used to represent the number of consecutive BLOCK blocks. When reading file system data, the CPU first obtains the BMAP content of the index BLOCK, searches for the physical BLOCK address according to the logical address, continuously reads and parses multiple physical BLOCK addresses, and determines whether they are consecutive. If the physical BLOCK addresses are consecutive, the number of consecutive BLOCK blocks is determined, and the flag is assigned a value. Then, the judgment is made based on the returned flag value, and the number of physical BLOCKs to be read at one time is selected based on the flag value.
[0012] Furthermore, the method is applicable to a single-lead device platform of an embedded CPU.
[0013] The present invention also discloses a device for accelerating access to a USB flash drive, comprising a processor and a memory storing program instructions, wherein the processor is configured to execute the method for accelerating access to a USB flash drive as described above when running the program instructions.
[0014] The present invention also discloses a storage medium storing program instructions, which execute the method for accelerating access to a USB flash drive as described above when running.
[0015] Beneficial effects of the present invention: The device and method for accelerating access to a USB flash drive proposed by the present invention greatly reduce the number of times the USB flash drive is accessed by introducing a high-speed CACHE and a CACHE management method, thereby improving the I / O efficiency of a single-chip CPU. By designing a plurality of BLOCK data block transmission mechanisms, the transmission performance of a single-chip system accessing a USB flash drive is greatly improved, especially the efficiency of large file transmission. The present invention does not require changing the structure of the original file system, thus reducing the difficulty of development, and at the same time greatly improves the efficiency of a single-chip device platform accessing a USB flash drive. The original transmission efficiency is 6M / S, and the present invention improves the data transmission efficiency to 22M / S. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A schematic diagram of the principle of transferring files for an existing single-guide device platform; Figure 2 It is a schematic diagram of the principle of file transmission on a single-guide device platform in the present invention; Figure 3 The flowchart for transmitting multiple consecutive BLOCK data blocks. DETAILED DESCRIPTION
[0017] The present invention will be further described below in conjunction with the accompanying drawings and specific implementations.
[0018] Example 1 First, the English expressions appearing in the present invention are explained: CACHE: cache storage; BLOCK: data storage block, one BLOCK is 4096 bytes; Index BLOCK: used to store the address of the data BLOCK; Data BLOCK: used to store data content; BMAP: Indexes the logical address to physical address mapping table in BLOCK.
[0019] This embodiment discloses a method for accelerating access to a USB flash drive. This method is applied to a single-lead device platform equipped with an embedded CPU, such as Figure 2As shown, the method first adds a CACHE module between the CPU and the file system module of the single-guide device platform. The CACHE module stores frequently accessed BLOCKs. Since the file system frequently accesses the same index BLOCK when parsing the data BLOCK, the CACHE module can automatically identify the index BLOCK and store the data content of the index BLOCK in the CACHE. In this way, the number of CPU I / Os can be greatly reduced and the efficiency of reading data can be improved. When the single-guide platform is working, the CPU will always read the BLOCK and write the BLOCK data obtained last time into the CACHE. If the address corresponding to the BLOCK is not accessed again, it will be overwritten when the CACHE is full. If it is accessed multiple times, the BLOCK data will reside in the CACHE until it is no longer accessed by the CPU.
[0020] The CACHE module in this method is divided into multiple CACHE partitions according to needs. In this embodiment, it is divided into 8 CACHE partitions. Each partition can store data and information of 1 BLOCK. The content and meaning of each CACHE are shown in Table 1: Table 1 Schematic diagram of the CACHE structure After the CPU starts the I / O request, it reads the address of the physical BLOCK from the USB flash drive and records the physical BLOCK address (BLOCK_addr) and BLOCK cache (Buf) in the CACHE. When the 8 CACHE partitions are used up, the available CACHE partitions are determined based on other parameters (Access_times, Dirty_flag, In_use) and the information of the available CACHE partitions is updated.
[0021] Usually, the BLOCK that records the BMAP index will be accessed frequently. Therefore, according to the rules, the index BLOCK will reside in the CACHE memory. When the CPU program wants to read the address of the physical BLOCK, it first searches from the CACHE to see if the physical BLOCK address (BLOCK_addr) to be accessed exists in the CACHE linked list. If so, the data is directly obtained from the Buf of the corresponding CACHE partition, thus reducing one I / O request.
[0022] The process of querying the BLOCK cache from the CACHE is as follows: the CPU program starts a read data request, matches the BLOCK_addr address of the partition in the CACHE according to the target BLOCK address, traverses the BLOCK cache corresponding to the BLOCK_addr address in the CACHE partition, and if the BLOCK_addr address is matched, directly reads the BLOCK cache and increments the Access_times in the CACHE partition, indicating that the BLOCK_addr address has been accessed. Since the speed at which the CPU accesses the CACHE is much higher than the speed of an I / O operation, this method can greatly improve the CPU efficiency.
[0023] The process of storing BLOCK data in CACHE is as follows: After the CPU program starts the I / O request, it will put each acquired BLOCK_addr address and BLOCK data into the CACHE linked list. The logic of CACHE data storage is as follows: first check whether there is an unused CACHE partition (the In_use flag is 0). Once found, the address of the current CACHE partition is returned, and the BLOCK data and address information are stored in the CACHE partition; if not, it means that the CACHE is full, then traverse the CACHE list, compare the Access_times (number of accesses), and the address of the CACHE partition with the least number of accesses will be returned for writing the latest BLOCK data and address information. If no available CACHE partition is found, the address of the last CACHE partition in the CACHE list is returned.
[0024] In the above method, the data BLOCK is usually read only once, so the Access_times value of this type of BLOCK is 0, while the index BLOCK will be accessed multiple times, so it will always reside in the CACHE, so when the CPU reads the index BLOCK, it only needs one I / O operation, and at other times it can be retrieved from the CACHE according to the BLOCK_addr address of the index BLOCK. An index BLOCK can store the addresses of 4096*512 data BLOCKs, so it can save 2097152 I / O operations, greatly improving the efficiency of reading the USB file system.
[0025] Since the data blocks of the file system may be discontinuous, the file system reads and writes data by default by reading only one block of data (4K) at a time. For a host with powerful CPU performance, the impact of this method on performance is negligible. However, for an embedded CPU, frequent I / O access will reduce the performance of the embedded CPU. To address this issue, when optimizing the file system to read data, we will first check whether the block address to be read next is continuous. If it is continuous, multiple continuous blocks can be read at a time. In this way, the I / O access frequency of the embedded CPU can be reduced, greatly improving the data transmission efficiency.
[0026] The number of consecutive BLOCK blocks is indicated by a byte FLAG and controlled by the BIT bit of the byte. The meaning of each BIT bit (0~7) is as follows: Table 2 Bit position diagram As shown in Table 2, its binary value is 00000010, which is converted to a decimal value of 2, indicating that the current 2 BLOCKs are continuous; similarly, if the binary value is 00000100, the decimal value is 4, indicating that the current 4 BLOCKs are continuous. In the present invention, due to the limitation of the RAM cache size, taking 2 BLOCKs or 4 BLOCKs as an example, a maximum of 128 continuous BLOCKs are supported.
[0027] like Figure 3 As shown, when the CPU program reads file system data, it first obtains the BMAP (address mapping table) content of the index BLOCK, searches for the physical address BLOCK according to the logical address, continuously reads and parses multiple physical BLOCKs and determines whether they are continuous. If the physical addresses are continuous, it determines that there are 4 continuous BLOCKs or 2 continuous BLOCKs, and assigns a value to FLAG. If there are 4 continuous BLOCKs, FLAG is 4 (binary 00000100), if there are 2 continuous BLOCKs, FLAG is 2 (binary 00000010). The CPU program chooses to read 2 BLOCKs (8K) at a time or 4 BLOCKs (16K) at a time according to the available RAM cache.
[0028] If it is not continuous, FLAG is assigned a value of 0 (binary 00000000). In this case, when the CPU program reads the file system, it must first query BMAP to obtain the physical address BLOCK and read a single BLOCK (4K) data each time.
[0029] The CPU program makes a judgment based on the FLAG value returned by the above steps, and selects the number of physical BLOCKs to be read at one time based on the FLAG value.
[0030] The present invention stores the frequently accessed BLOCK blocks (i.e., index BLOCKs) of the single-core CPU in the CACHE by adding a CACHE caching mechanism. When the single-core chip wants to read data from the USB flash drive, it first searches the CACHE list. If the corresponding BLOCK can be found, the data is directly taken from the CACHE, which reduces the number of I / O accesses of the CPU and greatly improves the efficiency. At the same time, for reading only one data BLOCK at a time, it is changed to first determine whether the BLOCK is continuous. If it is continuous, multiple BLOCKs are read at one time. For the embedded CPU, the larger the data packet transmitted at one time, the higher the transmission efficiency, which also greatly improves the efficiency of accessing the USB flash drive, thereby improving the overall transmission performance.
[0031] Example 2 The embodiment of the present disclosure provides a device for accelerating access to a USB flash drive, including a processor and a memory. Optionally, the device may also include a communication interface and a bus. The processor, the communication interface, and the memory may communicate with each other through the bus. The communication interface is used for information transmission. The processor may call the logic instructions in the memory to execute the method for accelerating access to a USB flash drive of the above embodiment.
[0032] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0033] The memory, as a computer-readable storage medium, can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor executes the functional application and data processing by running the program instructions / modules stored in the memory, that is, the method for accelerating access to the USB flash drive in the above embodiment is implemented.
[0034] Example 3 An embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute the above-mentioned method for accelerating access to a USB flash drive.
[0035] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0036] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes, or a transient storage medium.
[0037] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible changes. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the scope of protection. As used in the description in the text, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method or device including the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
Claims
1. A method for accelerating access to a USB flash drive, characterized in that: The method includes: A CACHE module is added between the CPU and the file system module of the single-boot device platform. The CACHE module is used to store blocks with a higher access frequency than the required frequency. When the CPU of the single-boot device platform wants to read data from a USB flash drive, it first searches the CACHE list. If the corresponding block is found, the data is directly taken from the CACHE, which reduces the number of CPU I / O accesses. When the CPU of a single-lead device platform starts to read data, it first checks whether the addresses of the blocks to be read are continuous. If they are continuous, it reads multiple continuous blocks at a time.
2. The method for accelerating access to a USB flash drive according to claim 1, characterized in that: The CACHE module sets up multiple partitions, each of which is used to store cache data and information of a BLOCK, including the physical BLOCK address, access count, abandonment flag, and use flag. After the CPU starts an I / O request, it reads the physical BLOCK address from the USB flash drive and records the physical BLOCK address and the data stored in it into the CACHE partition. When all partitions are used up, the available CACHE partitions are determined based on the access count, abandonment flag, and use flag, and the information of the available CACHE partitions is updated; When the CPU reads the physical BLOCK address, it first retrieves it from the CACHE module. If the physical BLOCK to be accessed exists in the CACHE module, the data is directly obtained from the corresponding CACHE module.
3. The method for accelerating access to a USB flash drive according to claim 1 or 2, characterized in that: Index BLOCK is always stored in the CACHE module.
4. The method for accelerating access to a USB flash drive according to claim 2, characterized in that: The process of querying BLOCK cache data from the CACHE module is as follows: the CPU initiates a read data request, matches the physical BLOCK address in the CACHE partition according to the target BLOCK address, traverses the cache data corresponding to the physical BLOCK address in the CACHE partition, and if the physical BLOCK address is matched, directly reads the corresponding cache data and increments the access count in the cache partition, indicating that the physical BLOCK address has been accessed.
5. The method for accelerating access to a USB flash drive according to claim 2, characterized in that: The process of storing BLOCK data in the CACHE module is as follows: after the CPU starts an I / O request, the physical BLOCK address and BLOCK data obtained each time are placed in the CACHE linked list. The storage logic is as follows: first check whether there is an unused CACHE partition. If so, return the address of the current CACHE partition and store the BLOCK data and address information in the CACHE partition. If not, it means that the CACHE module is full. Then traverse the CACHE list and compare the number of accesses. The address of the CACHE partition with the least number of accesses is returned for writing the latest BLOCK data and address information. If the available CACHE partition has not been traversed, return the address of the last CACHE partition in the CACHE list.
6. The method for accelerating access to a USB flash drive according to claim 5, characterized in that: Use the usage flag to find out whether there is an unused CACHE partition. If the usage flag is 0, it means that there is an unused CACHE partition.
7. The method for accelerating access to a USB flash drive according to claim 1, characterized in that: A byte flag is used to represent the number of consecutive BLOCK blocks. When reading file system data, the CPU first obtains the BMAP content of the index BLOCK, searches for the physical BLOCK address based on the logical address, continuously reads and parses multiple physical BLOCK addresses, and determines whether they are consecutive. If the physical BLOCK addresses are consecutive, the number of consecutive BLOCK blocks is determined, and the flag is assigned a value. The CPU then determines based on the returned flag value and selects the number of physical BLOCKs to read at one time based on the flag value.
8. The method for accelerating access to a USB flash drive according to claim 1, characterized in that: This method is applicable to single-lead device platforms with embedded CPUs.
9. A device for accelerating access to a USB flash drive, comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the method for accelerating access to a USB flash drive as described in any one of claims 1 to 8 when running the program instructions.
10. A storage medium storing program instructions, characterized in that: When the program instructions are executed, the method for accelerating access to a USB flash drive as described in any one of claims 1 to 8 is executed.