Data transmission method, apparatus and storage device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2026-08-11
AI Technical Summary
[0003]在相关技术中,由于存储介质区的单次存储块大小(即在一次读取或写入的存储操作中,存储介质能够处理的数据块的大小)往往会影响数据传输速度,而在传统的乒乓缓存技术中缓冲区的大小往往是固定且单一的,导致缓冲区的大小并不能与单次存储块大小相匹配,从而无法充分发挥其性能优势,甚至可能出现负优化的现象
[0015]通过上述技术方案,确定主机针对存储设备的待传输数据量;根据传输数据量与分割尺寸的映射关系,确定出待传输数据量对应的目标分割尺寸;根据目标分割尺寸在存储设备中确定乒乓缓冲区;根据乒乓缓冲区在主机和存储设备之间进行数据传输。通过传输数据量与分割尺寸的映射关系,确定待传输数据对应的目标分割尺寸,动态调整用于表征乒乓缓冲区的大小的分割尺寸,以确保乒乓缓冲区始终与单次存储块大小相匹配,提高缓存效率,进而提高主机和存储设备之间的数据传输效率。
Smart Images

Figure CN122547273A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data transmission technology, and more specifically, to a data transmission method, apparatus, and storage device. Background Technology
[0002] Storage devices (such as USB flash drives) can use ping-pong caching technology to improve data transfer speeds. Ping-pong caching typically improves data transfer speeds by setting up two buffers for alternating read and write operations.
[0003] In related technologies, the size of a single storage block in the storage medium area (i.e., the size of the data block that the storage medium can handle in a single read or write operation) often affects the data transfer speed. In traditional ping-pong caching technology, the size of the buffer is often fixed and singular, which means that the size of the buffer cannot match the size of a single storage block, thus failing to fully realize its performance advantages and may even lead to negative optimization. Summary of the Invention
[0004] The purpose of this disclosure is to provide a data transmission method, apparatus, and storage device to solve the problems in the related art.
[0005] To achieve the above objectives, this disclosure provides a data transmission method, the data transmission method comprising: Determine the amount of data the host needs to transfer to the storage device; Based on the mapping relationship between the amount of data to be transmitted and the segmentation size, the target segmentation size corresponding to the amount of data to be transmitted is determined. A ping-pong buffer is determined in the storage device according to the target segmentation size; Data transfer is performed between the host and the storage device using the ping-pong buffer.
[0006] Optionally, the mapping relationship between the amount of transmitted data and the segmentation size is determined in the following manner: For each amount of data to be transmitted, determine the transmission duration of that amount of data under each preset segmentation size, and determine the preset segmentation size with the minimum transmission duration as the segmentation size corresponding to that amount of data to be transmitted.
[0007] Optionally, determining the transmission data duration for the transmitted data volume under each preset segmentation size includes: For each preset segmentation size, the transmission data consumption time of the transmitted data volume under the preset segmentation size is determined multiple times to obtain multiple transmission data consumption times, and the transmission data duration of the transmitted data volume under the preset segmentation size is determined based on the multiple transmission data consumption times.
[0008] Optionally, determining the transmission data duration of the transmission data volume under the preset segmentation size based on the transmission data duration of the plurality of transmission data includes: The average time taken to transmit the multiple data sets is determined as the transmission duration of the data set under the preset segmentation size.
[0009] Optionally, determining the transmission data duration of the transmission data volume under the preset segmentation size based on the transmission data duration of the plurality of transmission data includes: The maximum and minimum data transmission times are determined from the multiple data transmission times. Calculate the time difference between the maximum data transmission time and the minimum data transmission time; If the time difference is less than a preset time difference threshold, the average of the time taken to transmit the multiple data is determined as the transmission duration of the data at the preset segmentation size.
[0010] Optionally, the step of transferring data between the host and the storage device according to the ping-pong buffer includes: In continuous read mode, the data address and data length read by the host this time are matched with the data address and data length of the prefetched data in the estimated buffer of the storage device; In the event of an unsuccessful match, data is transferred between the host and the storage device via the ping-pong buffer.
[0011] Optionally, the data transmission method further includes: If a match is successful, the prefetched data in the estimation buffer is sent to the host, and the predicted data for the next prefetch is stored in the estimation buffer.
[0012] Optionally, the data transmission method further includes: If no match is found after a preset number of consecutive reads, the data address and data length of the Nth read after the most recent read by the host are predicted based on the data address and data length of the most recent read by the host, and the prefetched data is stored in the estimated buffer based on the data address and data length of the Nth read.
[0013] This disclosure also provides a data transmission apparatus, the data transmission apparatus comprising: The first processing module is configured to determine the amount of data to be transferred from the host to the storage device. The second processing module is configured to determine the target segmentation size corresponding to the amount of data to be transmitted based on the mapping relationship between the amount of data to be transmitted and the segmentation size. The third processing module is configured to determine a ping-pong buffer in the storage device according to the target segmentation size; The fourth processing module is configured to perform data transfer between the host and the storage device according to the ping-pong buffer.
[0014] This disclosure also provides a storage device, including: A memory on which computer programs are stored; A processor is configured to execute the computer program in the memory to implement the steps of the data transmission method described above.
[0015] The above technical solution determines the amount of data to be transferred from the host to the storage device; based on the mapping relationship between the amount of data to be transferred and the partition size, the target partition size corresponding to the amount of data to be transferred is determined; a ping-pong buffer is determined in the storage device based on the target partition size; and data is transferred between the host and the storage device based on the ping-pong buffer. By determining the target partition size corresponding to the data to be transferred through the mapping relationship between the amount of data to be transferred and the partition size, the partition size used to characterize the size of the ping-pong buffer is dynamically adjusted to ensure that the ping-pong buffer always matches the size of a single storage block, improving caching efficiency and thus improving the data transfer efficiency between the host and the storage device.
[0016] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0017] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart illustrating a data transmission method according to an exemplary embodiment.
[0018] Figure 2 This is a schematic diagram illustrating a storage device according to an exemplary embodiment.
[0019] Figure 3 This is a schematic diagram of another storage device according to an exemplary embodiment.
[0020] Figure 4 This is a block diagram illustrating a data transmission apparatus according to an exemplary embodiment. Detailed Implementation
[0021] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0022] In the following description, the words "first" and "second" are used only to distinguish the purpose of the description and should not be interpreted as indicating or implying relative importance or order.
[0023] In the current storage market, a wide variety of storage media are available, including Embedded Multi-Media Cards (EMMC), Secure Digital Cards (SD), and NAND flash memory. Each type of media not only offers diverse options but also possesses unique performance advantages, providing users with a rich selection. However, the read and write performance of storage devices, such as USB flash drives, in practical applications is not only limited by the type of storage media but also influenced by multiple factors, including the file system type and the read / write speed of the USB interface.
[0024] Storage devices (such as USB flash drives) can use ping-pong caching technology to improve data transfer speeds. Ping-pong caching typically improves data transfer speeds by setting up two buffers for alternating read and write operations.
[0025] To further improve the read and write speed of USB flash drives, finding the optimal balance between the read and write speed of the storage medium and the overall performance of the USB flash drive has become a key issue that urgently needs to be addressed in the current USB flash drive design and manufacturing field.
[0026] In related technologies, the size of a single storage block (i.e., the size of a data block that the storage medium can handle in a single read or write operation) often affects data transfer speed. A larger single storage block size can reduce the number of storage operations and improve data transfer efficiency. For example, if the disk's single storage block size is large, it can reduce the number of head movements and seek time when reading large amounts of data, thereby improving read speed. However, if the single storage block size is too large, it may lead to wasted storage space because the file system may allocate space according to the storage block size, even if the file size is smaller than the single storage block size, it will still occupy a complete storage block.
[0027] In traditional ping-pong caching technology, the size of the buffer is often fixed and singular, which means that the size of the buffer cannot match the size of a single storage block, thus failing to fully realize its performance advantages and may even lead to negative optimization.
[0028] This disclosure provides a data transmission method that determines the target segment size corresponding to the data to be transmitted by mapping the amount of data to be transmitted to the segment size, and dynamically adjusts the segment size used to characterize the size of the ping-pong buffer. For a larger amount of data to be transmitted, a larger buffer block is obtained with a larger segment size, and for a smaller amount of data to be transmitted, a smaller buffer block is obtained with a smaller segment size, so as to ensure that the ping-pong buffer always matches the size of a single storage block, thereby improving caching efficiency and improving the data transmission efficiency between the host and the storage device.
[0029] This disclosure provides a data transmission method that can be applied to a storage device. It should be understood that the storage device can be an independent external storage device, such as a USB flash drive, external hard drive, optical disc, portable solid-state drive, or external hard drive. The storage device can also be an internal storage device of a computer.
[0030] Figure 1 This is a flowchart illustrating a data transmission method according to an exemplary embodiment. Figure 2 This is a schematic diagram illustrating a storage device according to an exemplary embodiment. Please refer to... Figure 1 and Figure 2 The data transmission method may include steps S1 to S4.
[0031] Step S1: Determine the amount of data to be transferred from host 10 to storage device 20.
[0032] The amount of data to be transmitted can be the total amount of data that the host 10 needs to send to or receive from the storage device 20 at a specific point in time.
[0033] The amount of data to be transmitted can be obtained by parsing the Command Block Wrapper (CBW).
[0034] Step S2: Determine the target segmentation size corresponding to the amount of data to be transmitted based on the mapping relationship between the amount of data to be transmitted and the segmentation size.
[0035] The storage device 20 pre-stores a mapping relationship between the amount of data transmitted and the segmentation size, in which the amount of data transmitted corresponds one-to-one with the segmentation size. The mapping relationship can be expressed by a function or recorded by a table; this embodiment does not limit the specific method used.
[0036] Determine a data volume that is the same as or similar to the data volume to be transmitted, and use the segmentation size corresponding to this data volume as the target segmentation size. A data volume that is similar to the data volume to be transmitted can be understood as a data volume whose difference from the data volume to be transmitted does not exceed a preset difference.
[0037] Step S3: Determine the ping-pong buffer 21 in the storage device 20 according to the target segmentation size.
[0038] The ping-pong buffer 21 in the storage device 20 is divided into multiple buffer blocks of target segment size, and the ping-pong buffer 21 is composed of multiple buffer blocks of target segment size.
[0039] Step S4: Data transfer is performed between the host 10 and the storage device 20 according to the ping-pong buffer 21.
[0040] The host 10 transmits data to the storage medium area of the storage device 20 through the ping-pong buffer 21, and the storage device 20 transmits data to the host 10 through the ping-pong buffer 21.
[0041] By mapping the amount of data to be transmitted to the segmentation size, the target segmentation size corresponding to the data to be transmitted is determined, and the segmentation size used to characterize the size of the ping-pong buffer 21 is dynamically adjusted to ensure that the ping-pong buffer 21 always matches the size of a single storage block, thereby improving caching efficiency and thus improving the data transmission efficiency between the host 10 and the storage device 20.
[0042] In one possible implementation, the mapping relationship between the amount of data transmitted and the segment size is determined as follows: For each amount of data to be transmitted, determine the transmission duration of that amount of data under each preset segmentation size, and determine the preset segmentation size with the minimum transmission duration as the segmentation size corresponding to that amount of data to be transmitted.
[0043] Multiple preset segmentation sizes are set, such as 4KB, 2KB, 1KB, 512 bytes, 256 bytes, and 0 bytes. It should be understood that when the preset segmentation size is 0 bytes, it indicates that transmission is performed serially without using the ping-pong buffer 21.
[0044] For example, for each amount of transmitted data, the transmission duration T1 is determined as follows: T1 is determined for a preset partition size of 4KB; T2 is determined for a preset partition size of 2KB; T3 is determined for a preset partition size of 1KB; T4 is determined for a preset partition size of 512 bytes; T5 is determined for a preset partition size of 256 bytes; and T6 is determined for a transmission duration T6 in serial transmission mode. The transmission durations T1, T2, T3, T4, T5, and T6 are compared to obtain the minimum transmission duration. The preset partition size corresponding to the minimum transmission duration is then determined as the partition size corresponding to the transmitted data amount.
[0045] For example, if the amount of data to be transmitted is 2KB, the transmission duration can be determined for the preset segmentation sizes of 1KB, 512 bytes, 256 bytes, and 0 bytes, respectively, and the segmentation size corresponding to the amount of data to be transmitted can be determined.
[0046] In one embodiment, if a data volume is transmitted, and the transmission duration is determined as follows: T7 for a data volume with a preset partition size of 4KB; T8 for a data volume with a preset partition size of 2KB; T9 for a data volume with a preset partition size of 1KB; T10 for a data volume with a preset partition size of 512 bytes; T11 for a data volume with a preset partition size of 256 bytes; and T12 for a data volume transmitted in serial transmission mode, then the transmission durations T7, T8, T9, T10, T11, and T12 are compared. The minimum transmission duration is determined to be T12. Therefore, subsequent data transmissions for this data volume are performed using serial transmission mode.
[0047] It should be understood that when multiple preset segmentation sizes correspond to the same data transmission duration and are all equal to the minimum data transmission duration, the minimum preset segmentation size is taken as the segmentation size corresponding to the data transmission amount.
[0048] By calculating and calibrating the optimal partition size in the current storage environment, the data transmission efficiency is highest when a set amount of data needs to be transmitted. When encountering the same or similar amount of data to be transmitted later, the data can be transmitted through the ping-pong buffer 21 divided by the optimal partition size, thereby improving the data transmission efficiency.
[0049] In one possible implementation, determining the transmission data duration for each preset segment size includes: For each preset segmentation size, the transmission data consumption time of the transmitted data volume under the preset segmentation size is determined multiple times to obtain multiple transmission data consumption times, and the transmission data duration of the transmitted data volume under the preset segmentation size is determined based on the multiple transmission data consumption times.
[0050] The specific number of times can be set according to the actual situation, such as 10 times or 50 times.
[0051] In one embodiment, determining the transmission duration of the data volume under the preset segmentation size based on the transmission time of multiple data transmissions can be understood as determining the average of the transmission times of multiple data transmissions as the transmission duration of the data volume under the preset segmentation size.
[0052] The transmission data duration under the preset segmentation size is determined by averaging the values from multiple calibration processes, ensuring that the final transmission data duration is reliable and accurate.
[0053] In another embodiment, determining the transmission duration of the transmitted data volume under the preset segmentation size based on multiple transmission data durations can be understood as follows: determining the maximum and minimum transmission data durations from multiple transmission data durations; calculating the time difference between the maximum and minimum transmission data durations; and determining the average of the multiple transmission data durations as the transmission duration of the transmitted data volume under the preset segmentation size if the time difference is less than a preset time difference threshold.
[0054] The preset time difference threshold can be set according to the actual situation.
[0055] By comparing the time difference with the preset time threshold, the time deviation of each transmitted data is ensured to be small, so as to ensure the validity of the transmitted data duration. On this basis, the transmission data duration under the preset segmentation size is determined by the average of multiple calibration processes, so that the final transmitted data duration is more reliable and accurate.
[0056] If the time difference is greater than the preset time difference threshold, multiple transmission data times can be obtained again, and the maximum and minimum transmission data times can be determined from the multiple transmission data times; the time difference between the maximum and minimum transmission data times can be calculated; if the time difference is less than the preset time difference threshold, the average of the multiple transmission data times can be determined as the transmission data duration of the data volume under the preset segmentation size.
[0057] If the time difference is greater than the preset time difference threshold, the maximum and minimum data transmission times can be removed, and the average of the remaining multiple data transmission times can be determined as the data transmission duration of the data volume under the preset segmentation size.
[0058] In one possible implementation, please refer to Figure 3 Step S4 may include: In continuous read mode, the data address and data length read by host 10 this time are matched with the data address and data length of the prefetched data in the estimated buffer 23 in storage device 20.
[0059] The sequential read mode is determined as follows: Based on the identification and prediction of the continuous read pattern of host 10. Specifically, when the data block size resolved by CBW is 4K (this value is an example and can vary in actual applications), and the address difference is fixed at the same number of data blocks for M consecutive times (M is configured by the user), it can be considered that host 10 is attempting to perform continuous 4K address block reads.
[0060] If the address of the data read by host 10 this time is the same as the address of the data to be fetched in the estimated buffer 23 in storage device 20, the length of the data read by host 10 this time is the same as the length of the data to be fetched in the estimated buffer 23 in storage device 20, and there is a flag indicating that storage is complete, then the host 10 issues an instruction that is consistent with the pre-stored data, and the match is successful; otherwise, the match is unsuccessful.
[0061] In the event of an unsuccessful match, data is transferred between the host 10 and the storage device 20 via the ping-pong buffer 21.
[0062] Data transmission methods may also include: If a match is successful, the prefetched data in the estimation buffer 23 is sent to the host 10, and the predicted next prefetched data is stored in the estimation buffer 23.
[0063] A new thread is created, with its priority set below the read / write thread but above the idle thread, to ensure that idle resources are used for data pre-storage without affecting normal read / write operations. Upon receiving the prefetch instruction, the new thread begins preparing the next data block that the CBW might request and pre-stores it in the presumed buffer 23.
[0064] By directly sending the prefetched data from the estimated buffer 23 to the host 10, the reading time is greatly shortened and the data reading efficiency is improved.
[0065] In one possible implementation, the data transmission method may further include: If no match is found after a preset number of consecutive reads, the data address and data length of the Nth read after the most recent read by the host 10 are predicted based on the data address and data length of the most recent read by the host 10, and the prefetched data is stored in the estimation buffer 23 based on the data address and data length of the Nth read.
[0066] Since the prefetch buffer 23 has been missed multiple times, the prefetch distance can be adjusted appropriately. The address of the prefetched data can be changed from the next data to the Nth data after it, so that the data pre-stored in the prefetch buffer 23 can be hit, thereby increasing the probability of a hit.
[0067] The number of consecutive preset times can be set according to the actual situation, for example, 3 times.
[0068] For example, if the preset number of consecutive attempts is 3, and no match is found in all 3 attempts, the data address and data length for the Nth read after the third read are predicted based on the data address and data length read by the host 10 in the third read, and the prefetched data is stored in the estimation buffer 23 based on the data address and data length read in the Nth read.
[0069] N can be set by the difference in the number of data blocks between the pre-stored data address and the most recently read address. In the next pre-store, the presumed buffer 23 pre-stores the data block data of the Nth time in advance to increase the probability of a hit.
[0070] It should be understood that once the size or address of the data block resolved by CBW no longer conforms to the continuous read mode, the pre-store mechanism will be immediately disabled to avoid unnecessary resource consumption. At the same time, it will continuously monitor changes in the read mode, wait for the next continuous read mode to appear, and automatically restart the pre-store mechanism of the presumed buffer 23.
[0071] The adaptive ping-pong buffer optimization strategy involves pre-setting multiple ping-pong buffer sizes, recording the time consumption under different partition sizes through actual transmission tests, and comparing it with the serial transmission time. The solution with the shortest time consumption is selected as the current best strategy.
[0072] The adaptive pre-store acceleration technology identifies continuous read patterns by parsing the CBW to recognize changes in data block size and address; creates new threads to pre-store data without affecting normal read and write operations; and determines whether to directly use the pre-stored data in the estimated buffer based on the matching of the pre-stored data with the actual read request, and adjusts the pre-store strategy to improve the hit rate.
[0073] The above data transmission method can achieve the following effects: 1. Significantly improves USB flash drive read and write speeds: By employing an adaptive ping-pong caching optimization strategy, the optimal cache size is selected based on media characteristics, reducing waiting time during data transmission. Combined with adaptive pre-store acceleration technology, which prepares and pre-stores potentially needed data in advance, read time is significantly shortened.
[0074] 2. Enhance universality and practicality: This method can intelligently adapt to different media and models of USB flash drives, eliminating the need for individual optimization for each drive. It can not only accelerate data transfer on USB flash drives but also serve as a testing program, providing precise feedback for firmware flashing during factory testing to ensure optimal performance of the USB flash drive in various application scenarios.
[0075] 3. Improve resource utilization efficiency: The adaptive pre-storage mechanism utilizes idle system resources for data pre-storage without interfering with normal read and write operations. When the continuous read mode is detected to be no longer available, the pre-storage mechanism is immediately disabled to avoid unnecessary resource consumption.
[0076] 4. Improve user experience: Speed up data transmission, reduce user waiting time, and improve the overall user experience.
[0077] Through intelligent optimization and pre-storage mechanisms, the USB flash drive can provide stable and efficient data transfer performance in different scenarios.
[0078] Based on the same inventive concept, this disclosure also provides a data transmission device, see reference. Figure 4 , Figure 4 This is a block diagram illustrating a data transmission apparatus according to an exemplary embodiment. The data transmission apparatus 600 may include: The first processing module 601 is configured to determine the amount of data to be transferred by the host to the storage device; The second processing module 602 is configured to determine the target segmentation size corresponding to the amount of data to be transmitted based on the mapping relationship between the amount of data to be transmitted and the segmentation size. The third processing module 603 is configured to determine a ping-pong buffer in the storage device based on the target segmentation size; The fourth processing module 604 is configured to perform data transfer between the host and the storage device based on the ping-pong buffer.
[0079] Optionally, the data transmission device 600 further includes: The fifth processing module is configured to determine the transmission data duration for each transmitted data volume under each preset segmentation size, and to determine the preset segmentation size with the minimum transmission data duration as the segmentation size corresponding to the transmitted data volume.
[0080] Optionally, the fifth processing module includes: The first processing submodule is configured to determine the transmission data consumption time of the transmission data volume under each preset segmentation size multiple times, obtain multiple transmission data consumption times, and determine the transmission data duration of the transmission data volume under the preset segmentation size based on the multiple transmission data consumption times.
[0081] Optionally, the first processing submodule is specifically configured as follows: The average of the transmission times of multiple data transmissions is determined as the transmission time of the data volume under the preset segmentation size.
[0082] Optionally, the first processing submodule is specifically configured as follows: The maximum and minimum data transmission times are determined from the transmission times of multiple data transmissions. Calculate the time difference between the maximum and minimum data transmission times; If the time difference is less than the preset time difference threshold, the average of the time taken for multiple data transmissions is determined as the transmission duration of the data volume under the preset segmentation size.
[0083] Optionally, the fourth processing module 604 includes: The second processing submodule is configured to match the data address and data length read by the host in the current reading mode with the data address and data length of the prefetched data in the estimated buffer in the storage device in the continuous reading mode; The third processing submodule is configured to transfer data between the host and storage device via a ping-pong buffer if no match is found.
[0084] Optionally, the data transmission device 600 further includes: The sixth processing module is configured to send the prefetched data in the estimation buffer to the host when a match is successful, and to store the predicted next prefetched data in the estimation buffer.
[0085] Optionally, the data transmission device 600 further includes: The seventh processing module is configured to, if no match is found after a preset number of consecutive reads, predict the data address and data length of the Nth read after the most recent read by the host based on the data address and data length of the most recent read by the host, and store the prefetched data in the estimated buffer based on the data address and data length of the Nth read.
[0086] Regarding the data transmission device in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the data transmission method, and will not be elaborated upon here.
[0087] Based on the same inventive concept, this disclosure also provides a storage device, including: A memory on which computer programs are stored; A processor for executing a computer program in memory, in accordance with the steps of the data transfer method described above.
[0088] The processor controls the overall operation of the storage device to complete all or part of the steps in the data transfer method described above. The memory stores various types of data to support the operation of the storage device. This memory can be implemented using any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0089] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0090] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0091] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A data transmission method, characterized in that, The data transmission method includes: Determine the amount of data the host needs to transfer to the storage device; Based on the mapping relationship between the amount of data to be transmitted and the segmentation size, the target segmentation size corresponding to the amount of data to be transmitted is determined. A ping-pong buffer is determined in the storage device according to the target segmentation size; Data transfer is performed between the host and the storage device using the ping-pong buffer.
2. The data transmission method according to claim 1, characterized in that, The mapping relationship between the amount of transmitted data and the segmentation size is determined in the following way: For each amount of data to be transmitted, determine the transmission duration of that amount of data under each preset segmentation size, and determine the preset segmentation size with the minimum transmission duration as the segmentation size corresponding to that amount of data to be transmitted.
3. The data transmission method according to claim 2, characterized in that, Determining the transmission data duration for each preset segmentation size includes: For each preset segmentation size, the transmission data consumption time of the transmitted data volume under the preset segmentation size is determined multiple times to obtain multiple transmission data consumption times, and the transmission data duration of the transmitted data volume under the preset segmentation size is determined based on the multiple transmission data consumption times.
4. The data transmission method according to claim 3, characterized in that, The step of determining the transmission data duration of the transmission data volume under the preset segmentation size based on the transmission data duration of the multiple transmission data includes: The average time taken to transmit the multiple data sets is determined as the transmission duration of the data set under the preset segmentation size.
5. The data transmission method according to claim 3, characterized in that, The step of determining the transmission data duration of the transmission data volume under the preset segmentation size based on the transmission data duration of the multiple transmission data includes: The maximum and minimum data transmission times are determined from the multiple data transmission times. Calculate the time difference between the maximum data transmission time and the minimum data transmission time; If the time difference is less than a preset time difference threshold, the average of the time taken to transmit the multiple data is determined as the transmission duration of the data at the preset segmentation size.
6. The data transmission method according to claim 1, characterized in that, The step of transferring data between the host and the storage device according to the ping-pong buffer includes: In continuous read mode, the data address and data length read by the host this time are matched with the data address and data length of the prefetched data in the estimated buffer of the storage device; In the event of an unsuccessful match, data is transferred between the host and the storage device via the ping-pong buffer.
7. The data transmission method according to claim 6, characterized in that, The data transmission method further includes: If a match is successful, the prefetched data in the estimation buffer is sent to the host, and the predicted data for the next prefetch is stored in the estimation buffer.
8. The data transmission method according to claim 6, characterized in that, The data transmission method further includes: If no match is found after a preset number of consecutive reads, the data address and data length of the Nth read after the most recent read by the host are predicted based on the data address and data length of the most recent read by the host, and the prefetched data is stored in the estimated buffer based on the data address and data length of the Nth read.
9. A data transmission device, characterized in that, The data transmission device includes: The first processing module is configured to determine the amount of data to be transferred from the host to the storage device. The second processing module is configured to determine the target segmentation size corresponding to the amount of data to be transmitted based on the mapping relationship between the amount of data to be transmitted and the segmentation size. The third processing module is configured to determine a ping-pong buffer in the storage device according to the target segmentation size; The fourth processing module is configured to perform data transfer between the host and the storage device according to the ping-pong buffer.
10. A storage device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the data transmission method according to any one of claims 1-8.