Data processing method and electronic equipment

By merging read and write requests in the cache space and constructing a red-black tree, the I/O performance bottleneck of mechanical hard drives is solved, achieving more efficient data transfer and throughput.

CN120872256AInactive Publication Date: 2025-10-31LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511367674.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-24
Publication Date
2025-10-31
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The bottleneck of mechanical hard drives' I/O performance lies in addressing latency. Especially when sending frequent small and scattered requests, the hardware needs to repeatedly adjust the position of the read/write head and wait for the disk to rotate, resulting in high I/O latency and low throughput.

Method used

By merging read and write requests in the cache space, a red-black tree is constructed to determine target requests with logically contiguous addresses, and a single access to the disk is initiated based on the red-black tree-merged request description, thus avoiding memory copying.

Benefits of technology

This reduces the number of disk accesses, lowers the hardware preparation time percentage, improves data transfer efficiency and throughput, and reduces I/O latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120872256A_ABST
    Figure CN120872256A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and electronic equipment, and relates to the technical field of storage, and the method comprises the following steps: obtaining a request description of a read-write request in a cache space, and determining target requests which belong to the same volume and have continuous logic addresses based on the request description; constructing a red-black tree by taking the target request as a node; determining a request description of a merged request obtained by merging the target request based on a red-black tree; when read-write access is performed on the disk, single read-write access can be initiated to the disk based on the request description of the merged request. According to the method, the read-write requests in the cache space are merged based on the red-black tree, and small and scattered read-write requests can be merged into a small number of large read-write requests, so that the number of read-write access times initiated to a disk is reduced, the data volume of single read-write is increased, the time proportion of hardware preparation work for data reading is reduced, and the data reading efficiency is improved. The actual data transmission ratio is increased, the IO delay is reduced, and the throughput is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and more particularly to a data processing method and an electronic device. Background Technology

[0002] The I / O performance bottleneck of storage devices (especially hard disk drives, HDDs) lies in addressing latency (such as the head movement time and disk rotation latency of HDDs). If the system frequently sends small, scattered requests (e.g., reading sectors 1-2 first, then sectors 5-6, then sectors 3-4), the hardware needs to repeatedly adjust the head position and wait for the disk to rotate. A lot of time is wasted on preparation work rather than actual data transmission, resulting in high I / O latency and low throughput. Summary of the Invention

[0003] This invention provides a data processing method and electronic device that, by merging request descriptions without performing memory copying, can reduce the number of disk accesses, decrease the time spent on hardware preparation during disk access, improve data transmission efficiency, reduce I / O latency, and increase throughput.

[0004] This invention provides a data processing method, comprising: obtaining request descriptions of read and write requests in a cache space; using the request descriptions to determine target requests belonging to the same volume and with consecutive logical addresses; constructing a red-black tree using the target requests as nodes; the red-black tree corresponding to a merged request obtained by merging the target requests; using the red-black tree to determine the request description of the merged request; and using the request description of the merged request to initiate a single read / write access to the disk.

[0005] The present invention also provides a data processing apparatus, comprising: a request description acquisition module, configured to acquire request descriptions of read and write requests in a cache space; a request filtering module, configured to use the request descriptions to determine target requests belonging to the same volume and with consecutive logical addresses; a red-black tree construction module, configured to construct a red-black tree using the target requests as nodes; the red-black tree corresponding to a merged request obtained by merging the target requests; a request merging module, configured to use the red-black tree to determine the request description of the merged request; and a request access module, configured to use the request descriptions of the merged request to initiate a single read / write access to the disk.

[0006] The present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described data processing methods.

[0007] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described data processing methods.

[0008] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data processing methods.

[0009] In this invention, the request descriptions of read and write requests in the cache space are first obtained. Then, based on the request descriptions, target requests belonging to the same volume and with contiguous logical addresses are determined. That is, the target requests are the requests that can be merged. To achieve request merging without memory copying, a red-black tree data structure is used. Specifically, a red-black tree is constructed using the target requests as nodes; then, the request descriptions of the merged requests are determined using the red-black tree; finally, when performing read and write access to the disk, a single read / write access can be initiated based on the request descriptions of the merged requests. In this way, several target requests with contiguous logical addresses in several volumes can be aggregated using request descriptions to avoid data copying, thus converting small, scattered requests into large, fewer merged requests to access the disk.

[0010] This invention merges small, scattered read and write requests in the cache space using a red-black tree, thereby reducing the number of read and write accesses to the disk, increasing the amount of data in a single read or write operation, reducing the time spent on hardware preparation for data reading, increasing the actual data transfer rate, reducing I / O latency, and improving throughput. Attached Figure Description

[0011] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 A flowchart illustrating a data processing method provided in an embodiment of the present invention; Figure 2 A schematic diagram of a red-black tree with two nodes is provided for an embodiment of the present invention; Figure 3 A schematic diagram of a red-black tree with 3 nodes is provided for an embodiment of the present invention; Figure 4 A schematic diagram of a red-black tree with 4 nodes is provided for an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention; Figure 7This is a schematic diagram of the specific structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.

[0013] It should be noted that, in the description of this invention, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., used in this invention are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0014] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0015] Please refer to Figure 1 This method can be applied to storage systems, and the data processing method includes the following steps.

[0016] S101. Obtain the request description of read / write requests in the cache space.

[0017] When the host needs to access the disk, in order to accelerate data access efficiency, the cache in the cache space can be used for a fast response. However, for the data in the cache space to be actually written to the disk, read and write accesses need to be initiated to the disk. In this embodiment, in order to reduce the time spent on hardware preparation due to numerous small requests, this embodiment proposes to merge the read and write requests in the cache space into a large and few merged requests, thereby accessing the disk.

[0018] Specifically, in this embodiment, the request description of the read / write request can be obtained from the cache space. The request description is a structured and clear description of the read / write request, and its core objective is to accurately understand information such as the volume, its logical address, length, and the memory address where the IO data is stored.

[0019] In one specific embodiment of the present invention, obtaining the request description of a read / write request in the cache space includes: receiving a read / write request sent by a host; caching the read / write request according to a caching strategy, and writing the simplified original description of the read / write request into the cache space; and reading the simplified request description from the cache space; wherein the simplified request description includes a volume identifier, a starting logical address, a length, and a memory address for storing the request data.

[0020] In other words, for read and write requests that enter the cache space, the read and write requests can be cached according to the caching strategy, and the request description can be written into the cache space after simplifying the original description of the read and write request.

[0021] The description of read / write requests can be simplified to the following structure: struct io_blk { lun_id; / / Volume ID lba; / / The starting LBA address for this I / O operation length; / / IO length, unit is logical block mem_addr; / / Memory address used to store this IO data }

[0022] The io_blk structure describes an I / O operation. Its members include: lun_id (volume ID), lba (LBA address of the starting LBA for this I / O), length (length in logical blocks), and mem_addr (the starting address of the data memory for this I / O, which is required for both read and write operations). The length of the I / O data memory is length * lba_size, where lba_size is the size of a logical block in bytes.

[0023] Therefore, the request description of the read / write request can be read from the cache space.

[0024] S102. Using the request description, determine the target request that belongs to the same volume and has contiguous logical addresses.

[0025] It is important to note that for multiple non-continuous and scattered requests, and during the disk access process, the hardware needs to repeatedly adjust the position of the read / write head and wait for the disk to rotate. A lot of time is wasted on preparation work rather than actual data transmission, resulting in high IO latency and low throughput.

[0026] To reduce hardware setup time during disk access, requests meeting specific conditions can be merged. This combines small, scattered requests into a single large request, reducing the number of disk accesses and the time spent on hardware setup. Specifically, merging requests is only possible when the volumes are identical and the logical addresses are contiguous, allowing a single request to retrieve or write data from multiple smaller requests.

[0027] Therefore, in this embodiment, target requests belonging to the same volume and with contiguous logical addresses can be determined based on the request description. The number of such target requests is at least two.

[0028] In one specific embodiment of the present invention, determining target requests belonging to the same volume and with consecutive logical addresses using request descriptions includes: classifying read and write requests to obtain candidate requests of read type or write type; obtaining the volume identifier corresponding to the candidate request from the request description; obtaining the starting logical address and length corresponding to candidate requests with the same volume identifier from the request description; comparing the size of the starting logical addresses to determine a first starting logical address and a second starting logical address; adding the first starting logical address to the corresponding length to obtain the logical block end address; and determining the two candidate requests corresponding to the first starting logical address and the second starting logical address as target requests when the logical block end address is the same as the second starting logical address.

[0029] Considering that read and write requests access the disk in completely opposite directions, in this embodiment, when merging read and write requests, they can be categorized according to their read or write types. That is, read-type requests are merged separately, and write-type requests are merged separately.

[0030] After classifying the candidate requests into read-type or write-type candidate requests, the read-type requests or write-type requests can be merged. The candidate requests described below can all be read-type or all be write-type.

[0031] After identifying the candidate requests, the volume identifiers corresponding to the candidate requests can be clearly identified from the request descriptions. Then, based on the volume identifiers, the requests are further subdivided to find candidate requests with the same volume identifier. The starting logical addresses and lengths of these candidate requests are then read and processed from the request descriptions. By comparing the sizes of the read starting logical addresses, the size of the starting logical address can be determined. It is important to note that the comparison of the starting logical addresses here refers to the size of the logical block numbers corresponding to the logical addresses. A smaller starting logical address means that the logical block number corresponding to the starting logical address is smaller, and a larger starting logical address means that the logical block number corresponding to the starting logical address is larger. These sizes refer to the relative sizes of the two requests, not the absolute sizes.

[0032] After determining the relative size of the starting logical addresses, the smaller starting logical address can be designated as the first starting logical address, and the larger starting logical address as the second starting logical address. Then, the first starting logical address is added to its corresponding length to obtain the end address of the logical block. Next, by comparing the end address of the logical block with the second starting logical address, it is determined whether the logical addresses of the two requests are consecutive. Specifically, if the end address of the logical block is the same as the second starting logical address, the two candidate requests corresponding to the first and second starting logical addresses are identified as the target requests.

[0033] For example, consider two candidate requests: IO_1, with io_blk information io_blk1={lun_id=l1, lba=32, length=8, mem_addr=m_addr_1}; and IO_2, with io_blk information io_blk2={lun_id=l1, lba=40, length=8, mem_addr=m_addr_2}. Both IO_1 and IO_2 have a lun_id of l1, indicating they belong to the same volume. IO_1's lba=32 is smaller than IO_2's lba=40. Adding 32 to IO_1's length (32+8=40) gives 40, which is the same as IO_2's lba=40. Therefore, IO_1 and IO_2 belong to the same volume and have contiguous logical addresses, making them the target requests to be merged.

[0034] S103. Construct a red-black tree using the target request as the node.

[0035] The red-black tree corresponds to the merge request obtained from the merge target request.

[0036] Once the target request is determined, a red-black tree can be constructed using the target request as the node. A red-black tree is a self-balancing binary search tree that uses specific coloring rules and rotation operations to ensure that the height of the tree is always maintained at the O (log n) level, thus guaranteeing that the time complexity of operations such as insertion, deletion, and search is O (log n).

[0037] In one specific embodiment of the present invention, constructing a red-black tree with target requests as nodes includes: randomly selecting one target request as the root node and the unselected target requests as child nodes to construct the red-black tree.

[0038] That is, when constructing a red-black tree, the selection of the root node and child nodes can be randomized. Please refer to [reference needed]. Figure 2 If the target requests include: IO_1, whose io_blk information is io_blk1={lun_id=l1, lba=32, length=8, mem_addr=m_addr_1}; and IO_2, whose io_blk information is io_blk2={lun_id=l1, lba=40, length=8, mem_addr=m_addr_2}, then the resulting red-black tree describes an IO on volume l1 with lba=32 and length=16, which can be denoted as IO_M1. IO_M1 is the merge request obtained by merging IO_1 and IO_2.

[0039] Of course, in practical applications, root node selection rules can also be set to select nodes that meet certain conditions as root nodes. For example, the first starting logical address can be used as the root node.

[0040] S104. Use a red-black tree to determine the request description of the merge request.

[0041] In this embodiment, one red-black tree corresponds to one merge request. The nodes of the red-black tree correspond to the target requests that need to be merged; therefore, the request description of the merge request can be determined based on the red-black tree. The items described in this request can be the same as the items in the target request before merging.

[0042] In one specific embodiment of the present invention, the request description of the merge request is determined using a red-black tree, including: determining the volume identifier corresponding to the node in the red-black tree as the volume identifier of the merge request; determining the first starting logical address corresponding to the node in the red-black tree as the starting logical address of the merge request; accumulating the lengths corresponding to the nodes in the red-black tree to obtain the length of the merge request; adding the memory addresses corresponding to the nodes in the red-black tree to the memory address set, and determining the memory address set as the memory address of the merge request.

[0043] Since all nodes in a red-black tree correspond to the same volume identifier, the volume identifier corresponding to the merge request is still the same as the volume identifier of the node in the red-black tree. Because the red-black tree merges multiple target requests, and the logical addresses of these target requests are contiguous, the starting address of the merge request is the first logical address corresponding to the node. The length of the merge request is the sum of the lengths of the corresponding nodes in the red-black tree. The merge request still needs to write or read data from the allocated memory space; therefore, the memory space of the merge request includes the memory addresses of the target requests being merged.

[0044] like Figure 2 As shown, if the target requests include: IO_1, whose io_blk information is io_blk1={lun_id=l1, lba=32, length=8, mem_addr=m_addr_1}; and IO_2, whose io_blk information is io_blk2={lun_id=l1, lba=40, length=8, mem_addr=m_addr_2}, then the merged red-black tree description of the merged request IO_M1 is: lun_id=l1, lba=32, length=16, mem_addr=m_addr_1, m_addr_2.

[0045] In one specific embodiment of the present invention, before initiating a single read / write access to the disk using the request description of the merge request, the method further includes: obtaining the request description of the new request when a new request is written to the cache space; using the request description of the new request to determine whether the new request and the target request corresponding to the node in the red-black tree belong to the same volume and have consecutive logical addresses; if so, the new request is added as a new node in the red-black tree, and the updated red-black tree is used to determine the request description of the merge request.

[0046] In other words, when a new request arrives, it can be compared with the target request corresponding to a node in the red-black tree to determine whether the new request can be merged into the red-black tree. The merging condition remains the same: the volumes are identical and the logical addresses are contiguous. It should be noted that this only requires that the logical addresses of one node in the red-black tree be contiguous.

[0047] For example, if there is currently such Figure 2 In the red-black tree shown, if another IO_3 with lba=16 arrives, its io_blk information is io_blk3={lun_id=l1, lba=16, length=16, mem_addr=m_addr_3}. It is also an IO on volume l1 with a length of 16, and is adjacent to IO_M1. Therefore, IO_3 can be merged into IO_M1. The merged IO_M1 is as follows: Figure 3 As shown. At this point, IO_M1 describes a large IO block on volume l1 with lba=16 and length=32. Its data is scattered across various nodes of the red-black tree. By traversing the tree in order, the memory of m_addr_3 of IO_3, m_addr_1 of IO_1, and m_addr_2 of IO_2 can be accessed sequentially. This allows access to the contents of 32 consecutive logical blocks starting from the initial LBA (lba=16). In this way, the aggregation of data memory for IO_1, IO_2, and IO_3 is achieved through the red-black tree structure.

[0048] In one specific embodiment of the present invention, before initiating a single read / write access to the disk using the request description of the merge request, the method further includes: obtaining the request description of the update request when an update request is written to the cache space; using the request description of the update request to determine whether the update request corresponds to the target request corresponding to the node in the red-black tree; if so, deleting the target request corresponding to the update request from the red-black tree, and treating the update request as a new node in the red-black tree, and using the updated red-black tree to determine the request description of the merge request.

[0049] In other words, when an update request is required, the request description of the update request can be obtained. Based on the request description, it can be determined whether the corresponding nodes in the red-black tree need to be updated. If not, no processing with the compared red-black tree is required. If so, the corresponding node in the red-black tree is deleted, and the nodes in the red-black tree are updated / added based on the update request. This yields the request description of the updated merge request.

[0050] If the existing red-black tree is like Figure 3As shown, when there is an IO data update, such as a new IO_4, io_blk4={lun_id=l1, lba=36, length=8, mem_addr=m_addr_4}, this IO is on volume l1, with a length of 8 lba, and its LBA address range is from 36 to 43, belonging to IO_M1. At this time, it is necessary to update the corresponding old data in IO_M1 with the latest data in IO_4. First, the corresponding data in IO_M1 is removed, and then IO4 is merged into IO_M1.

[0051] The specific implementation process includes the following steps.

[0052] 1. Find the node containing lba=36. The found node is IO_1. The range of lba to be removed for this node is from 36 to 39, which is the length of 4 lba. Then, the io_blk information of IO_1 is updated to io_blk1={lun_id=l1, lba=32,length=4, mem_addr=m_addr_1}.

[0053] 2. Then find the node containing lba=36+4=40. The found node is IO_2. The range of lba to be removed for this node is 40 to 43, which is the length of 4 lba to be removed. Thus, the io_blk information of IO_2 is updated to io_blk2={lun_id=l1, lba=44, length=4, mem_addr=m_addr_2+4*lba_size}.

[0054] 3. Finally, merge IO_4 into IO_M1.

[0055] At this time, IO_M1 is as follows Figure 4 As shown, IO_M1 still describes a large block of IO on volume l1 with lba=16 and length=32. It merges the data memory of IO_1, IO_2, IO_3 and IO_4, and no memory copying of IO data occurs during the entire process.

[0056] In one specific embodiment of the present invention, after constructing the red-black tree, before initiating a single read / write access to the disk using the request description of the merge request, the method further includes: determining whether different merge requests belong to the same volume and have consecutive logical addresses; if so, merging the red-black trees corresponding to different merge requests.

[0057] The process of merging red-black trees corresponding to different merge requests includes: randomly selecting one red-black tree from the red-black trees corresponding to merge requests that belong to the same volume and have consecutive logical addresses, and inserting the nodes from the unselected red-black tree into the selected red-black tree to obtain the merged red-black tree.

[0058] As request merging is performed based on red-black trees, merge requests from different red-black trees may have the same volume and be logically consecutive. If this condition is met, further request merging can be performed based on red-black trees. That is, when two merged large I / O blocks are adjacent, merging can still be performed. The merge operation of two trees can be broken down into merging all nodes of one tree into the other tree; the merging process is similar to continuing to add or update nodes in a red-black tree.

[0059] S105. Using the request description of the merge request, initiate a single read / write access to the disk.

[0060] By traversing the red-black tree, the request description of the merge request can be determined, and a single read / write access to the disk can be initiated based on the request description of the merge request.

[0061] In other words, to complete a read or write operation for a merge request corresponding to a red-black tree on the disk, only one read or write operation needs to be initiated to the disk based on the request description corresponding to the red-black tree. Since a red-black tree has at least two nodes, the number of accesses can be effectively reduced compared to accessing the disk once for a single target request. Furthermore, since red-black trees merge consecutive logical addresses, the amount of data accessed in a single operation is also greater, and the proportion of hardware preparation time during a single operation is also reduced.

[0062] In one specific embodiment of the present invention, a single read / write access to the disk is initiated using the request description of the merge request, including: if the merge request is a read request, then the data corresponding to the merge request is read from the disk, and the corresponding read data is fed back to the sender of the target request using a red-black tree; if the merge request is a write request, then the data corresponding to the merge request is written to the disk, and the data is fed back to the sender of the target request using a red-black tree.

[0063] In other words, when a merge request is a read request, a single access to the disk is initiated, which means reading the data of the merge request from the disk in one go. This data is the data requested by multiple target requests. Based on the red-black tree, the read data can be written to the corresponding memory address, thereby completing the feedback of the read data to the corresponding sender.

[0064] When the merge request is a write request, a single access to the disk is initiated, which means that the data of the merge request is written to the disk at one time. The data of the merge request is located at the memory addresses corresponding to multiple target requests. Data can be read directly from different memory addresses and written directly to the disk. After the data writing is completed, a response indicating that the data has been written is sent back to the corresponding sender based on the red-black tree.

[0065] In one specific embodiment of this invention, read and write requests can be merged based on their timestamps. For example, requests whose waiting time is no longer than a preset threshold can be merged based on their timestamps. When accessing based on a red-black tree, it is necessary to ensure that the waiting time of the earliest target request in the red-black tree is no longer than the preset threshold. The size of this preset threshold can be set according to actual needs; for example, a smaller threshold is set for scenarios with higher latency requirements, and a larger threshold is set for scenarios with lower latency requirements. This ensures that request merging is not indefinite but is constrained to a certain time range, thereby avoiding delays in request processing due to request merging.

[0066] The method provided in this invention obtains the request descriptions of read and write requests in the cache space, and then determines the target requests belonging to the same volume and with contiguous logical addresses based on the request descriptions. That is, the target requests are the requests that can be merged. To achieve request merging without memory copying, a red-black tree data structure is used. Specifically, a red-black tree is constructed using the target requests as nodes; then, the request descriptions of the merged requests are determined using the red-black tree; finally, when performing read and write access to the disk, a single read / write access can be initiated based on the request descriptions of the merged requests. In this way, several target requests with contiguous logical addresses in several volumes can be aggregated using request descriptions to avoid data copying, thus converting small, scattered requests into large, fewer merged requests to access the disk.

[0067] This invention merges small, scattered read and write requests in the cache space using a red-black tree, thereby reducing the number of read and write accesses to the disk, increasing the amount of data in a single read or write operation, reducing the time spent on hardware preparation for data reading, increasing the actual data transfer rate, reducing I / O latency, and improving throughput.

[0068] In high-concurrency storage systems, data merging operations in memory can be performed quickly. Because there is no data copying, the merging efficiency is not affected by the size of the data, which improves the efficiency of memory merging and thus improves the performance of the storage system.

[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0070] Embodiments of the present invention also provide a data processing apparatus, which corresponds to the method and can be referred to in relation to it.

[0071] Please refer to Figure 5 The device includes: a request description acquisition module 101, used to acquire request descriptions of read and write requests in the cache space; a request filtering module 102, used to determine target requests belonging to the same volume and with consecutive logical addresses using the request descriptions; a red-black tree construction module 103, used to construct a red-black tree with the target requests as nodes; the red-black tree corresponds to the merged request obtained by merging the target requests; a request merging module 104, used to determine the request description of the merged request using the red-black tree; and a request access module 105, used to initiate a single read / write access to the disk using the request description of the merged request.

[0072] Using the apparatus provided in this embodiment of the invention, request descriptions of read and write requests in the cache space are obtained, and then target requests belonging to the same volume and with contiguous logical addresses are determined based on the request descriptions. That is, the target requests are the requests that can be merged. To achieve request merging without memory copying, a red-black tree data structure is used for request merging. Specifically, a red-black tree is constructed using the target requests as nodes; then, the request descriptions of the merged requests are determined using the red-black tree; finally, when performing read and write access to the disk, a single read / write access can be initiated to the disk based on the request descriptions of the merged requests. In this way, several target requests with contiguous logical addresses in several volumes can be aggregated using request descriptions to avoid data copying, thus converting small, scattered requests into large, fewer merged requests to access the disk.

[0073] This invention merges small, scattered read and write requests in the cache space using a red-black tree, thereby reducing the number of read and write accesses to the disk, increasing the amount of data in a single read or write operation, reducing the time spent on hardware preparation for data reading, increasing the actual data transfer rate, reducing I / O latency, and improving throughput.

[0074] In one specific embodiment of the present invention, the request filtering module is specifically used to classify read and write requests to obtain candidate requests of read type or candidate requests of write type; obtain the volume identifier corresponding to the candidate request from the request description; obtain the starting logical address and length corresponding to the candidate request with the same volume identifier from the request description; compare the size of the starting logical address to determine the first starting logical address and the second starting logical address; add the first starting logical address to the corresponding length to obtain the end address of the starting logical block; if the end address of the logical block is the same as the second starting logical address, determine the two candidate requests corresponding to the first starting logical address and the second starting logical address as the target request.

[0075] In one specific embodiment of the present invention, the red-black tree construction module is specifically used to randomly select one request from the target requests as the root node and the unselected target requests as child nodes to construct a red-black tree.

[0076] In one specific embodiment of the present invention, it further includes: a red-black tree node insertion module, used to obtain the request description of the new request before initiating a single read / write access to the disk using the request description of the merge request, in the case of writing a new request to the cache space; use the request description of the new request to determine whether the new request and the target request corresponding to the node in the red-black tree belong to the same volume and have contiguous logical addresses; if so, the new request is added as a new node in the red-black tree, and the updated red-black tree is used to determine the request description of the merge request.

[0077] In one specific embodiment of the present invention, it further includes: a red-black tree update module, used to obtain the request description of the update request before initiating a single read / write access to the disk using the request description of the merge request, in the case of writing the update request to the cache space; using the request description of the update request to determine whether the update request corresponds to the target request corresponding to the node in the red-black tree; if so, then delete the target request corresponding to the update request from the red-black tree, and treat the update request as a new node in the red-black tree, and use the updated red-black tree to determine the request description of the merge request.

[0078] In one specific embodiment of the present invention, the request access module is specifically used to read the data corresponding to the merge request from the disk if the merge request is a read request, and use a red-black tree to send back the corresponding read data to the sender of the target request respectively; if the merge request is a write request, write the data corresponding to the merge request to the disk, and use a red-black tree to send back a response that the data has been written to the sender of the target request respectively.

[0079] In one specific embodiment of the present invention, it further includes: a red-black tree merging module, used to determine whether different merging requests belong to the same volume and have consecutive logical addresses before initiating a single read / write access to the disk using the request description of the merging request after constructing the red-black tree; if so, the red-black trees corresponding to different merging requests are merged.

[0080] In one specific embodiment of the present invention, the red-black tree merging module is specifically used to randomly select one red-black tree from the red-black trees corresponding to the merge requests belonging to the same volume and with consecutive logical addresses, and to insert the nodes in the unselected red-black tree into the selected red-black tree to obtain the merged red-black tree.

[0081] In one specific embodiment of the present invention, the request description acquisition module is specifically used to receive read / write requests sent by the host; cache the read / write requests according to a caching strategy, and write the simplified original description of the read / write requests into the cache space; read the simplified request description from the cache space; wherein the simplified request description includes a volume identifier, a starting logical address, a length, and a memory address for storing request data; correspondingly, the request merging module is specifically used to determine the volume identifier corresponding to the node in the red-black tree as the volume identifier of the merged request; determine the first starting logical address corresponding to the node in the red-black tree as the starting logical address of the merged request; accumulate the lengths corresponding to the nodes in the red-black tree to obtain the length of the merged request; add the memory addresses corresponding to the nodes in the red-black tree to the memory address set, and determine the memory address set as the memory address of the merged request.

[0082] For a description of the features in the embodiment corresponding to the data processing device, please refer to the relevant description in the embodiment corresponding to the data processing method, which will not be repeated here.

[0083] Corresponding to the above method embodiments, this invention also provides an electronic device. The electronic device described below and the data processing method described above can be referred to each other.

[0084] See Figure 6 As shown, the electronic device includes: a memory 332 for storing a computer program; and a processor 322 for executing the computer program to implement the steps of the data processing method described in the above method embodiment.

[0085] For details, please refer to Figure 7 , Figure 7This is a schematic diagram of the specific structure of an electronic device provided in this embodiment. The electronic device can vary significantly due to differences in configuration or performance. It may include one or more central processing units (CPUs) (e.g., one or more processors) and a memory 332. The memory 332 stores one or more computer programs 342 or data 344. The memory 332 can be temporary or permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 and execute the series of instruction operations stored in the memory 332 on the electronic device 301.

[0086] Electronic device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341.

[0087] The steps in the data processing method described above can be implemented by the structure of an electronic device.

[0088] Corresponding to the above method embodiments, this invention also provides a readable storage medium. The readable storage medium described below corresponds to the data processing method described above. This invention also provides a computer-readable storage medium storing a computer program configured to execute the steps of any of the above data processing method embodiments at runtime.

[0089] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0090] Embodiments of the present invention also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above data processing method embodiments.

[0091] Embodiments of the present invention also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data processing method embodiments.

[0092] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the invention.

[0093] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only intended to help understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the present invention.

Claims

1. A data processing method, characterized in that, include: Retrieve the request description of read and write requests in the cache space; Using the request description, identify target requests that belong to the same volume and have contiguous logical addresses; Construct a red-black tree using the target request as the node; The red-black tree corresponds to the merged request obtained by merging the target requests; The request description of the merge request is determined using the red-black tree; Using the request description of the merge request, a single read / write access is initiated to the disk.

2. The method according to claim 1, characterized in that, Using the request description, determining target requests that belong to the same volume and have contiguous logical addresses includes: The read and write requests are classified to obtain candidate requests of either the read type or the write type. Obtain the volume identifier corresponding to the candidate request from the request description; From the request description, obtain the starting logical address and length corresponding to the candidate requests with the same volume identifier; By comparing the size of the starting logical address, the first starting logical address and the second starting logical address are determined; Add the first starting logical address to the corresponding length to obtain the end address of the starting logical block; If the end address of the logical block is the same as the second starting logical address, the two candidate requests corresponding to the first starting logical address and the second starting logical address are determined as the target request.

3. The method according to claim 1, characterized in that, Using the target request as a node, construct a red-black tree, including: The red-black tree is constructed by randomly selecting one target request from the target requests as the root node and the unselected target requests as child nodes.

4. The method according to claim 1, characterized in that, Before initiating a single read / write access to the disk using the request description of the merge request, the following steps are also included: When a new request is written to the cache space, obtain the request description of the new request; The request description of the new request is used to determine whether the new request and the target request corresponding to the node in the red-black tree belong to the same volume and have contiguous logical addresses; If so, the new request is added as a new node in the red-black tree, and the updated red-black tree is used to determine the request description of the merge request.

5. The method according to claim 1, characterized in that, Before initiating a single read / write access to the disk using the request description of the merge request, the following steps are also included: When an update request is written to the cache space, obtain the request description of the update request; Using the request description of the update request, determine whether the update request corresponds to the target request that updates the node in the red-black tree; If so, the target request corresponding to the update request is deleted from the red-black tree, and the update request is added as a new node in the red-black tree. The updated red-black tree is then used to determine the request description of the merge request.

6. The method according to claim 1, characterized in that, Using the request description of the merge request, a single read / write access is initiated to the disk, including: If the merge request is a read request, then the data corresponding to the merge request is read from the disk, and the corresponding read data is fed back to the sender of the target request using the red-black tree; If the merge request is a write request, then the data corresponding to the merge request is written to the disk, and the red-black tree is used to send a response to the sender of the target request that the data has been written.

7. The method according to claim 1, characterized in that, After constructing the red-black tree, before initiating a single read / write access to the disk using the request description of the merge request, the process also includes: Determine whether different merge requests belong to the same volume and have contiguous logical addresses; If so, the red-black trees corresponding to different merge requests will be merged.

8. The method according to claim 7, characterized in that, Merge the red-black trees corresponding to different merge requests, including: From the red-black trees corresponding to merge requests belonging to the same volume and with contiguous logical addresses, randomly select one red-black tree to retain. Insert the nodes from the unselected red-black tree into the selected red-black tree to obtain the merged red-black tree.

9. The method according to any one of claims 1 to 8, characterized in that, Retrieve the request descriptions for read and write requests in the cache space, including: Receive read / write requests sent by the host; According to the caching strategy, read and write requests are cached, and the original description of the read and write requests is simplified and written into the cache space. A simplified request description is read from the cache space; wherein the simplified request description includes a volume identifier, a starting logical address, a length, and a memory address for storing the request data; Accordingly, the request description of the merge request is determined using the red-black tree, including: The volume identifier corresponding to the node in the red-black tree is determined as the volume identifier of the merge request; The first starting logical address corresponding to the node in the red-black tree is determined as the starting logical address of the merge request; The length of the merge request is obtained by summing the lengths of the nodes in the red-black tree. The memory addresses corresponding to the nodes in the red-black tree are added to the memory address set, and the memory address set is determined as the memory address of the merge request.

10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the data processing method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • I / O scheduling method based on internal parallelism of solid state disk and scheduler

    CN103336669A

  • I / O scheduling method based on solid-state disc read-write characteristic

    CN106775438A

  • Method and device for processing IO requests

    CN111694770A

  • Configuration method of service system, electronic equipment and storage medium

    CN120596036A