Data access request processing method, device and electronic device
By setting a status identifier for each data block in the storage system, it can quickly determine whether the data block is occupied, which solves the problem of low request processing efficiency in the existing technology and achieves more efficient data access request processing.
Patent Information
- Application Number
- CN202110639839.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-08
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-06-08
AI Technical Summary
When the existing technology processes data access requests in the storage system, it is necessary to compare the current request with all ongoing requests one by one, resulting in a waste of CPU resources and low request processing efficiency.
By setting a status identifier for each data block in the storage system, it is determined whether there is an occupied data block. If it does not exist, the request will be executed directly. Otherwise, the request will be added to the waiting queue and will not be executed until the data block is not occupied.
This avoids the waste of CPU resources caused by one-by-one comparison, improves the efficiency of request processing, and reduces processing time.
Smart Images

Figure CN113238716B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method, device and electronic device for processing a data access request. Background Art
[0002] The block storage driver layer can convert the read and write requests for block devices in the storage system into read and write requests that the underlying storage system can accept based on the offset, length, and data to be read and written carried in the read and write requests. If the underlying storage system cannot guarantee the order of reading and writing the same offset position of the block device, the driver layer needs to ensure that the read and write access to the same offset position is mutually exclusive, that is, only one read and write request for the same offset position can be sent to the underlying storage system at the same time, so as to avoid the problem of dirty reading and dirty writing of data.
[0003] In the related art, the driver layer saves the read and write requests sent by the user, and when the driver layer receives a new request, it will traverse the ongoing read and write requests that have been sent to the underlying storage system according to the type, block device offset and length of the new request, and compare each ongoing read and write request with the type, block device offset and length of the new request one by one. If a read-write, write-read or write-write position conflict is found, the new request is considered to conflict with an ongoing read and write request. At this time, the new request needs to wait in line until the conflicting read and write request is completed before it can be issued. Each time a new request is processed in this way, all currently ongoing requests need to be compared with the new request one by one. This one-by-one comparison process causes a waste of CPU resources and leads to low request processing efficiency. Summary of the invention
[0004] The object of the present invention is to provide a method, device and electronic device for processing data access requests to avoid waste of CPU resources and improve request processing efficiency.
[0005] In a first aspect, the present invention provides a method for processing a data access request, the method comprising: receiving a first data access request for a storage system, and determining target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is being occupied by the data access request; based on the status identifier, determining whether there is an occupied data block in the data blocks corresponding to the target data; if there is no occupied data block, executing the first data access request.
[0006] In an optional embodiment, after the step of executing the first data access request, the method further includes: setting a status identifier of a data block corresponding to the target data to a first identifier; the first identifier is used to indicate that the data block is being occupied by the data access request.
[0007] In an optional embodiment, the above method also includes: if there are occupied data blocks in the data blocks corresponding to the target data, adding the first data access request to a preset waiting queue, until the status identifiers of the data blocks corresponding to the target data accessed by the first data access request are not set to the first identifier, and executing the first data access request.
[0008] In an optional embodiment, a status identifier set for each data block corresponding to the above-mentioned storage system is stored in a designated memory; the status identifier is a first identifier indicating that the data block is occupied by a data access request; the status identifier is a second identifier indicating that the data block is not occupied; the above-mentioned step of judging whether there is an occupied data block in the data blocks corresponding to the target data based on the status identifier comprises: generating a first integer number of a specified number of bits according to the data blocks corresponding to the target data; wherein the first integer number comprises: the status identifier of the data block corresponding to the target data is a first identifier, and the status identifiers of the data blocks other than the data blocks corresponding to the target data are a second identifier; extracting a second integer number of a specified number of bits containing the status identifiers of the data blocks corresponding to the target data from the designated memory; performing bitwise operations on the first integer number and the second integer number to obtain an operation result; judging whether the operation result is a specified value; if so, determining whether there is no occupied data block in the data blocks corresponding to the target data.
[0009] In an optional embodiment, the step of extracting a second integer number of a specified number of bits containing a status identifier of a data block corresponding to the target data from the specified memory includes: determining an extraction starting position in the specified memory based on a starting data block in the data block corresponding to the target data; and extracting a second integer number of a specified number of bits from the specified memory starting from the extraction starting position.
[0010] In an optional embodiment, the first identifier is 1, and the second identifier is 0; the designated value is 0; the step of performing a bitwise operation on the first integer and the second integer to obtain the operation result includes: performing an AND operation on the first integer and the second integer to obtain the operation result; the step of judging whether the operation result is the designated value; if so, determining that there is no occupied data block in the data block corresponding to the target data, includes: judging whether the operation result is 0; if it is 0, determining that there is no occupied data block in the data block corresponding to the target data.
[0011] In an optional embodiment, after the above-mentioned step of setting the status identifier of the data block corresponding to the target data to the first identifier, the method further includes: if a message indicating that the execution of the first data access request is completed is received, setting the status identifier of the data block corresponding to the target data to the second identifier; the second identifier is used to indicate that the data block is not occupied by the data access request.
[0012] In an optional embodiment, after the above-mentioned step of setting the status identifier of the data block corresponding to the target data to the second identifier, the method further includes: determining whether there is a target request that meets the preset conditions in the preset waiting queue; wherein the preset conditions include: the status identifiers of the data blocks corresponding to the data accessed by the target request are not set to the first identifier; if there is a target request that meets the preset conditions, executing the target request.
[0013] In an optional implementation, the step of determining the target data accessed by the first data access request includes: determining the target data accessed by the first data access request according to an access start position and an access length carried by the first data access request.
[0014] In a second aspect, the present invention provides a device for processing data access requests, the device comprising: a data determination module, used to receive a first data access request for a storage system, and determine the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is being occupied by the data access request; a status judgment module, used to judge whether there is an occupied data block in the data blocks corresponding to the target data based on the status identifier; and a request processing module, used to execute the first data access request if there is no occupied data block.
[0015] In a third aspect, the present invention provides an electronic device comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for processing data access requests described in any of the aforementioned embodiments.
[0016] In a fourth aspect, the present invention provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for processing data access requests described in any one of the aforementioned implementations.
[0017] The embodiments of the present invention bring the following beneficial effects:
[0018] The present invention provides a method, device and electronic device for processing a data access request, which first receives a first data access request for a storage system and determines the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is currently occupied by the data access request; then, based on the status identifier, it is determined whether there is an occupied data block in the data block corresponding to the target data; if there is no occupied data block, the first data access request is executed. This method can quickly determine whether the data block accessed by the data access request is occupied by indicating whether the data block is currently occupied, and execute the data access request when it is not occupied. This method does not need to compare the data accessed by the data access request with all ongoing requests one by one when processing the data access request, thereby avoiding the waste of CPU resources caused by comparing one by one, and also improving the efficiency of request processing.
[0019] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A flowchart of a method for processing a data access request provided by an embodiment of the present invention;
[0023] Figure 2 A flowchart of another method for processing a data access request provided by an embodiment of the present invention;
[0024] Figure 3 A flowchart of another method for processing a data access request provided by an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of the structure of a data access request processing device provided by an embodiment of the present invention;
[0026] Figure 5A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0028] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] In order to ensure that the read and write accesses to the same offset position in the block device are not mutually exclusive, the driver layer usually saves the read and write requests sent by the user to the underlying storage system. When the driver layer receives a new request, it will traverse all the ongoing read and write requests that have been sent to the underlying storage system according to the type, block device offset and length of the new request, so as to compare the ongoing read and write requests with the type, block device offset and length of the new request one by one. If a read-write, write-read or write-write position conflict is found, the new request is considered to conflict with an ongoing read and write request. At this time, the new request needs to wait in line until the conflicting read and write request is completed before it can be issued. At the same time, when the underlying storage system completes a request, it needs to determine whether there is a request that meets the conditions and can be issued in the waiting queue due to the conflict. If so, the waiting request is issued to the underlying storage system. When this method processes a new request each time, all the currently ongoing requests need to be compared with the new request one by one. The one-by-one comparison process causes a waste of CPU (Central Processing Unit) resources and leads to low request processing efficiency.
[0030] Based on the above problems, the embodiments of the present invention provide a method, device and electronic device for processing data access requests. The technology can be applied to scenarios such as data reading and data writing of block devices in storage systems. To facilitate understanding of the present embodiment, a method for processing data access requests disclosed in the embodiments of the present invention is first described in detail. Figure 1 As shown, the method comprises the following specific steps:
[0031] Step S102, receiving a first data access request for the storage system, and determining the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status flag, and the status flag is used to indicate whether the data block is being occupied by the data access request.
[0032] In a specific implementation, the first data access request may be sent by a user through a terminal device, and the terminal device may be a mobile terminal such as a mobile phone, a tablet computer, a smart bracelet, or a computer. The first data access request may be a data read request, a data write request, or a data query request.
[0033] The above-mentioned storage system usually stores data in the form of a block device, which can usually store data in blocks of fixed size. Each block has its own address, and data of a certain length can be read at any position of the block device. Before executing step S102, it is necessary to divide the data stored in each block device in the storage system according to a fixed length to obtain a plurality of fixed-length data blocks. The fixed length can be set according to research and development requirements. For example, the fixed length can be set to 4K or 8K, etc. Among them, each data block is provided with a status identifier. The status identifier of a data block is used to indicate whether the data block is being occupied by a data access request, and can also be understood as indicating whether the data block is undergoing a data access request. In specific implementation, different status identifiers can be used to set the status identifier, that is, different status identifiers are used to indicate whether a data block is being occupied by a data access request.
[0034] When a first data access request is received, it is necessary to determine the target data accessed by the first data access request based on the access information carried by the first data access request, and then determine the data block corresponding to the target data; the access information may include information such as the request type, access offset position and access length; wherein the request type includes data writing or data reading, etc.
[0035] Step S104: Based on the above status identifier, it is determined whether there is an occupied data block in the data blocks corresponding to the target data.
[0036] Step S106: If there is no occupied data block, execute the first data access request.
[0037] According to the status identifier corresponding to each data block in the storage system, it can be determined whether there is an occupied data block in the data block corresponding to the target data. If there is no occupied data block, it means that the first data access request does not conflict with the ongoing data access request, and the first data access request can be executed, and the status identifier of the data block corresponding to the target data accessed by the first data access request is set to be occupied by the data access request. Among them, executing the first data access request can be understood as: sending the first data access request to the underlying storage system so that the underlying storage system processes the first data access request and returns the processing result.
[0038] If there are one or more occupied data blocks in the data blocks corresponding to the target data, it means that the first data access request conflicts with a certain ongoing data access request, and the first data access request cannot be sent to the underlying storage system. The first data access system needs to be added to a preset waiting queue to wait until the data blocks corresponding to the target data accessed by the first data access request are not occupied before executing the first data access request. The waiting queue can store multiple data access requests, and the data access requests in the waiting queue are all requests for occupied data blocks corresponding to the accessed data.
[0039] A method for processing a data access request provided by an embodiment of the present invention first receives a first data access request for a storage system, and determines the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is currently occupied by the data access request; then based on the status identifier, it is determined whether there is an occupied data block in the data block corresponding to the target data; if there is no occupied data block, the first data access request is executed. This method can quickly determine whether the data block accessed by the data access request is occupied by indicating whether the data block is currently occupied, and execute the data access request when it is not occupied. This method does not need to compare the data accessed by the data access request with all ongoing requests one by one when processing the data access request, thereby avoiding the waste of CPU resources caused by comparing one by one, and also improving the efficiency of request processing.
[0040] The embodiment of the present invention also provides another method for processing data access requests, which is implemented on the basis of the method of the above embodiment; the method focuses on describing the specific process of determining whether there is an occupied data block in the data block corresponding to the target data based on the state identifier (implemented by the following steps S204-S210); Figure 2 As shown, the method comprises the following specific steps:
[0041] Step S202, receiving a first data access request for the storage system, and determining the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, and a status identifier set for each data block is stored in a designated memory, wherein the status identifier is a first identifier indicating that the data block is being occupied by the data access request, and the status identifier is a second identifier indicating that the data block is not occupied.
[0042] In specific implementation, it is necessary to apply for a piece of memory (equivalent to a designated memory) according to the number of data blocks into which the data stored in the storage system is divided. Each bit in the designated memory corresponds to a status identifier of a data block. When the status identifier is a first identifier, it indicates that the data block is occupied by a data access request, that is, the data block is occupied by the data access request being executed and other data access requests cannot be executed; when the status identifier is a second identifier, it indicates that the data block is not currently occupied by a data access request. The above-mentioned first identifier and second identifier can be set according to research and development requirements. The first identifier and the second identifier are different identifiers. For example, the first identifier is 1 and the second identifier is 0.
[0043] Step S204, generating a first integer number of specified bits according to the data block corresponding to the target data; wherein the first integer number includes: the state identifier of the data block corresponding to the target data as a first identifier, and the state identifier other than the data block corresponding to the target data as a second identifier.
[0044] According to the data block corresponding to the target data, the starting data block and the ending data block corresponding to the target data can be determined. Since the data blocks corresponding to the target data are continuous, a first integer number of a specified number of bits can be generated according to the starting data block and the ending data block. Each bit in the first integer number corresponds to a state identifier of a data block. The state identifier is determined according to the data block corresponding to the target data, that is, the state identifier of the data block corresponding to the target data is set to the first identifier (it can also be understood that the state identifiers of the starting data block to the ending data block are all set to the first identifier), and the state identifiers other than the data block corresponding to the target data in the first integer number are set to the second identifier. The above-mentioned specified number of bits can be set according to user needs, for example, it can be set to 32 bits or 64 bits, etc.
[0045] Step S206: extracting a second integer number of a specified number of bits containing a status identifier of a data block corresponding to the target data from the above-mentioned specified memory.
[0046] The data block corresponding to each bit in the second integer extracted from the specified memory needs to correspond to the first integer so as to perform subsequent operations on the first integer and the second integer. The above-mentioned specified memory stores the status identifiers corresponding to all data blocks corresponding to the storage system, and the status identifier indicates the occupation of the data blocks by all requests being executed.
[0047] In specific implementation, the above step S206 can be implemented by the following steps 10-11:
[0048] Step 10: Determine the extraction start position in the designated memory according to the start data block in the data block corresponding to the target data.
[0049] Step 11, starting from the above extraction starting position, extract a second integer number of specified digits from the specified memory.
[0050] In the specific implementation, one bit in the specified memory corresponds to the status flag of a data block, and 8 bits correspond to a byte. Since the minimum unit of extraction is a byte, it is necessary to determine the byte in the specified memory to which the bit corresponding to the starting data block in the data block corresponding to the target data belongs, and then take the bits of the specified number of bits from this byte to obtain a second integer. For example, when the specified number of bits is 32 bits, 4 bytes can be taken from this byte to obtain a 32-bit second integer.
[0051] Step S208, performing a bitwise operation on the first integer and the second integer to obtain an operation result.
[0052] In a specific implementation, a bit operation is performed based on the status identifiers corresponding to the same data blocks in the first integer and the second integer to obtain an operation result, and then based on the operation result, it can be determined whether the first data access request conflicts with the data block accessed by the ongoing request.
[0053] Step S210, determine whether the operation result is a specified value; if so, execute step S212; otherwise, execute step S214.
[0054] In specific reality, the above-mentioned designated value can determine the specific value of the designated value according to the set first identifier, the second identifier and the bit operation adopted. For example, it can be assumed that the first identifier is 1, the second identifier is 0, and the designated value is 0; then the specific process of the above-mentioned step S208 can be: perform an AND operation on the first integer and the second integer to obtain the operation result. In the AND operation, only the AND operation result of 1 and 1 is 1, and the rest of the AND operation results are 0. If the operation result is 0, it is determined that there is no occupied data block in the data block corresponding to the target data; if the operation result is other values, it is determined that at least one data block in the data block corresponding to the target data is occupied, that is, the first data access request conflicts with a certain data access request being executed.
[0055] Step S212, determining that there is no occupied data block in the data blocks corresponding to the target data, executing the first data access request, and setting the state identifier of the data block corresponding to the target data in the specified memory to the first identifier.
[0056] If it is determined that there is no occupied data block in the data block corresponding to the target data, then the first data access request does not conflict with the ongoing request, and the first data access request can be sent to the underlying storage system. At this time, the status identifier of the data block corresponding to the target data accessed by the first data access request will be automatically set to the first identifier in the specified memory to update the status identifier in the specified memory.
[0057] Step S214, determine whether there are occupied data blocks in the data blocks corresponding to the target data, add the first data access request to the preset waiting queue, and execute the first data access request until the status identifiers of the data blocks corresponding to the target data accessed by the first data access request are not set to the first identifier.
[0058] In specific implementation, each time a request in the ongoing data access request is executed, it can be determined whether the requests in the waiting queue can be sent to the underlying storage system. The judgment logic here can refer to the above steps S204-S212, that is, to determine whether among the requests in the waiting queue, the data blocks corresponding to the data accessed by a certain request are not occupied (that is, the status identifiers in the designated memory are not set to the first identifier). In some embodiments, it can be determined whether only the first request in the waiting queue can be sent to the underlying storage system, or when the first request cannot be sent, it can be determined whether the second request in the waiting queue can be sent to the underlying storage system, until it is determined that there is a request in the waiting queue that can be sent to the underlying storage system, or all the requests in the waiting queue are determined to be completed and no request that can be sent to the underlying storage system is found.
[0059] The above-mentioned method for processing data access requests first receives a first data access request for a storage system, determines the target data accessed by the first data access request; then generates a first integer number of a specified number of bits according to the data block corresponding to the target data; then extracts a second integer number of a specified number of bits containing the status identifier of the data block corresponding to the target data from the specified memory; determines whether the result of the bitwise operation of the first integer number and the second integer number is a specified value; if so, determines that there is no occupied data block in the data block corresponding to the target data, executes the first data access request, and sets the status identifier of the data block corresponding to the target data in the specified memory to the first identifier; otherwise, determines that there is an occupied data block in the data block corresponding to the target data, adds the first data access request to a preset waiting queue, and executes the first data access request until the status identifier of the data block corresponding to the target data accessed by the first data access request is not set to the first identifier. This method only needs to perform a bitwise operation on the integer number corresponding to the target data block accessed by the first data access request and the integer numbers corresponding to all ongoing requests in the specified memory to determine whether to execute the first data request. Compared with the one-by-one comparison method in the prior art, this method reduces the waste of CPU resources and improves the processing efficiency of data access requests.
[0060] The embodiment of the present invention further provides another method for processing a data access request, which is implemented on the basis of the method in the above embodiment; the method focuses on describing the specific process of determining the target data accessed by the first data access request (implemented by the following step S304); Figure 3 As shown, the method comprises the following specific steps:
[0061] Step S302: receiving a first data access request for the storage system.
[0062] Step S304: determining the target data accessed by the first data access request according to the access start position and the access length carried in the first data access request.
[0063] The first data access request usually carries an access starting position (equivalent to an access offset position) and an access length. The data in the storage system from the access starting position to the position corresponding to the access length are determined as the target data accessed by the first data access request. Based on the target data, the data block spanned by the first data access request can also be determined, that is, the data block corresponding to the target data.
[0064] Step S306, based on the status identifier of the data block corresponding to the target data, determine whether there is an occupied data block in the data block corresponding to the target data; if not, execute step S308; otherwise, execute step S310.
[0065] Step S308, executing the first data access request, and setting the state identifier of the data block corresponding to the target data to the first identifier; executing step S312.
[0066] In a specific implementation, the first identifier is used to indicate that the data block is being occupied by a data access request.
[0067] Step S310, adding the first data access request to a preset waiting queue; executing step S312.
[0068] Step S312: If a message indicating that the first data access request is executed successfully is received, the status identifier of the data block corresponding to the target data is set to the second identifier.
[0069] In a specific implementation, the second identifier is used to indicate that the data block is not occupied by a data access request. When the first data access request is executed, the state identifier of the data block corresponding to the target data needs to be updated from the first identifier to the second identifier so that subsequent data access requests can access the data block corresponding to the target data.
[0070] Step S314, determine whether there is a target request that meets the preset conditions in the waiting queue; wherein the preset conditions include: the status identifiers of the data blocks corresponding to the data accessed by the target request are not set to the first identifier; if so, execute step S316; otherwise, end.
[0071] When the first data access request is executed, or other data access requests are executed, it can be determined whether there is a target request that meets the preset conditions in the waiting queue, and the target request is the request that meets the preset conditions in the waiting queue; the preset condition is that the status identifiers of the data blocks corresponding to the data accessed by the data access request are not set to the first identifier (which can also be understood as not being occupied).
[0072] Step S316, executing the target request.
[0073] The above-mentioned method for processing data access requests can quickly determine whether the data block accessed by the data access request is occupied by indicating the status mark of whether the data block is occupied, and execute the data access request when it is not occupied. This method does not need to compare the data accessed by the data access request with all ongoing requests one by one, thereby avoiding the waste of CPU resources caused by one-by-one comparison, and also improving the efficiency of request processing.
[0074] In view of the embodiment of the method for processing data access request, the embodiment of the present invention provides a device for processing data access request, such as Figure 4 As shown, the device comprises:
[0075] The data determination module 40 is used to receive a first data access request for the storage system and determine the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is being occupied by the data access request.
[0076] The state judgment module 41 is used to judge whether there is an occupied data block in the data blocks corresponding to the target data based on the state identifier.
[0077] The request processing module 42 is configured to execute the first data access request if there is no occupied data block.
[0078] The above-mentioned data access request processing device first receives a first data access request for a storage system, and determines the target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into multiple data blocks, and each data block is provided with a status identifier, and the status identifier is used to indicate whether the data block is currently occupied by the data access request; then based on the status identifier, it is determined whether there is an occupied data block in the data block corresponding to the target data; if there is no occupied data block, the first data access request is executed. This method can quickly determine whether the data block accessed by the data access request is occupied by indicating whether the data block is currently occupied, and execute the data access request when it is not occupied. This method does not need to compare the data accessed by the data access request with all ongoing requests one by one when processing the data access request, thereby avoiding the waste of CPU resources caused by one-by-one comparison, and also improving the efficiency of request processing.
[0079] Furthermore, the above-mentioned device also includes a first status update module, which is used to: when executing the first data access request, set the status identifier of the data block corresponding to the target data to a first identifier; the first identifier is used to indicate that the data block is being occupied by the data access request.
[0080] Furthermore, the above-mentioned device also includes a request waiting module, which is used to: if there are occupied data blocks in the data blocks corresponding to the target data, add the first data access request to a preset waiting queue, until the status identifiers of the data blocks corresponding to the target data accessed by the first data access request are not set to the first identifier, and execute the first data access request.
[0081] In a specific implementation, the status identifier set for each data block corresponding to the above-mentioned storage system is stored in a designated memory; the status identifier is a first identifier indicating that the data block is occupied by a data access request; the status identifier is a second identifier indicating that the data block is not occupied; the above-mentioned status judgment module 41 includes: an integer number generation module, which is used to generate a first integer number of a specified number of bits according to the data block corresponding to the target data; wherein the first integer number includes: the status identifier of the data block corresponding to the target data is a first identifier, and the status identifier of the data block other than the target data is a second identifier; an integer number extraction module, which is used to extract a second integer number of a specified number of bits containing the status identifier of the data block corresponding to the target data from the designated memory; a bit operation module, which is used to perform bit operations on the first integer number and the second integer number to obtain an operation result; a result judgment module, which is used to judge whether the operation result is a specified value; if so, determine whether there is no occupied data block in the data block corresponding to the target data.
[0082] Furthermore, the above-mentioned integer number extraction module is used to: determine the extraction starting position in the specified memory according to the starting data block in the data block corresponding to the target data; and extract a second integer number of specified bits from the specified memory starting from the extraction starting position.
[0083] In practical applications, the first identifier is 1, the second identifier is 0, and the specified value is 0; the bit operation module is used to: perform an AND operation on the first integer and the second integer to obtain an operation result; the result judgment module is used to: judge whether the operation result is 0; if it is 0, determine that there is no occupied data block in the data block corresponding to the target data.
[0084] Furthermore, the above-mentioned device also includes a second status update module, which is used to: if a message indicating that the first data access request is executed successfully is received, set the status identifier of the data block corresponding to the target data to a second identifier; the second identifier is used to indicate that the data block is not occupied by the data access request.
[0085] Furthermore, the above-mentioned device also includes a queue request execution module, which is used to: determine whether there is a target request that meets the preset conditions in the preset waiting queue; wherein the preset conditions include: the status identifiers of the data blocks corresponding to the data accessed by the target request are not set to the first identifier; if there is a target request that meets the preset conditions, execute the target request.
[0086] Furthermore, the data determination module 40 is further configured to determine the target data accessed by the first data access request according to the access start position and the access length carried in the first data access request.
[0087] The data access request processing device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0088] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, the electronic device includes a processor 101 and a memory 100. The memory 100 stores machine executable instructions that can be executed by the processor 101. The processor 101 executes the machine executable instructions to implement the above-mentioned data access request processing method.
[0089] Further, Figure 5 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0090] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0091] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.
[0092] An embodiment of the present invention also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned data access request processing method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0093] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0094] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for processing a data access request, characterized in that: The method comprises: Receive a first data access request for a storage system, and determine target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into a plurality of data blocks, each of the data blocks is provided with a status identifier, and the status identifier is used to indicate whether the data block is being occupied by a data access request; the status identifier set for each data block of the storage system corresponding to the storage system is stored in a designated memory; the status identifier is a first identifier indicating that the data block is being occupied by a data access request; the status identifier is a second identifier indicating that the data block is not being occupied; Based on the state identifier, determining whether there is an occupied data block in the data block corresponding to the target data; If there is no occupied data block, the first data access request is executed.
2. The method according to claim 1, characterized in that After the step of executing the first data access request, the method further includes: The state identifier of the data block corresponding to the target data is set to a first identifier; the first identifier is used to indicate that the data block is being occupied by a data access request.
3. The method according to claim 2, characterized in that The method further comprises: If there are occupied data blocks in the data blocks corresponding to the target data, the first data access request is added to a preset waiting queue until the status identifiers of the data blocks corresponding to the target data accessed by the first data access request are not set to the first identifier, and the first data access request is executed.
4. The method according to claim 1, characterized in that: The step of judging whether there is an occupied data block in the data block corresponding to the target data based on the state identifier comprises: Generate a first integer number of a specified number of bits according to the data block corresponding to the target data; wherein the first integer number includes: a state identifier of the data block corresponding to the target data as the first identifier, and a state identifier other than the data block corresponding to the target data as the second identifier; Extracting a second integer number of the specified number of bits containing a status identifier of a data block corresponding to the target data from the specified memory; Performing a bitwise operation on the first integer and the second integer to obtain an operation result; Determine whether the operation result is a specified value; if so, determine that there is no occupied data block in the data block corresponding to the target data.
5. The method according to claim 4, characterized in that The step of extracting from the designated memory a second integer number of the designated number of bits containing a status identifier of a data block corresponding to the target data comprises: Determining an extraction start position in the designated memory according to a start data block in the data blocks corresponding to the target data; Starting from the extraction start position, the second integer number of the specified number of bits is extracted from the specified memory.
6. The method according to claim 4, characterized in that The first identifier is 1, the second identifier is 0; the specified value is 0; The step of performing a bitwise operation on the first integer and the second integer to obtain an operation result comprises: Performing an AND operation on the first integer number and the second integer number to obtain the operation result; The step of judging whether the operation result is a specified value; if so, determining that there is no occupied data block in the data block corresponding to the target data, comprises: Determine whether the operation result is 0; if it is 0, determine that there is no occupied data block in the data block corresponding to the target data.
7. The method according to claim 2, characterized in that After the step of setting the state identifier of the data block corresponding to the target data to the first identifier, the method further includes: If a message that the first data access request is executed successfully is received, the status identifier of the data block corresponding to the target data is set to a second identifier; the second identifier is used to indicate that the data block is not occupied by a data access request.
8. The method according to claim 7, characterized in that After the step of setting the status identifier of the data block corresponding to the target data to the second identifier, the method further includes: Determine whether there is a target request that meets a preset condition in the preset waiting queue; wherein the preset condition includes: the state identifiers of the data blocks corresponding to the data accessed by the target request are not set to the first identifier; If there is a target request that meets the preset condition, the target request is executed.
9. The method according to claim 1, characterized in that: The step of determining the target data accessed by the first data access request includes: The target data accessed by the first data access request is determined according to the access start position and the access length carried by the first data access request.
10. A data access request processing device, characterized in that: The device comprises: A data determination module, used for receiving a first data access request for a storage system, and determining target data accessed by the first data access request; wherein the data stored in the storage system is pre-divided into a plurality of data blocks, each of which is provided with a status identifier, and the status identifier is used to indicate whether the data block is being occupied by a data access request; the status identifier set for each data block corresponding to the storage system is stored in a designated memory; the status identifier being a first identifier indicates that the data block is being occupied by a data access request; the status identifier being a second identifier indicates that the data block is not being occupied; A state judgment module, used for judging whether there is an occupied data block in the data block corresponding to the target data based on the state identifier; The request processing module is used to execute the first data access request if there is no occupied data block.
11. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for processing data access requests according to any one of claims 1 to 9.
12. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for processing a data access request according to any one of claims 1 to 9.
Citation Information
Patent Citations
Data management method and device for solid state disk, storage medium and electronic equipment
CN111984184A
Dynamic address mapping for finish in the field
US20150019830A1
Disk area isolation method and device
US20170177220A1
Data writing and reading method and apparatus, and distributed object storage cluster
WO2017201977A1
