Query instruction processing method and device, electronic equipment and medium

By caching query commands in the storage system and monitoring their dwell time, and then resending the commands upon returning a power-on reset status code, the problem of untimely response to query commands after the storage system restarts is solved, improving the stability and automatic recovery capabilities of the storage system and reducing operation and maintenance costs.

CN119166652BActive Publication Date: 2026-11-20INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411034780.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2026-11-20
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

In existing technologies, after a storage system restarts, query commands in the block device scanning discovery process cannot be responded to in a timely manner, leading to complex client server performance, increased operation and maintenance costs, and is not applicable to CentOS 7.9/Red Hat 7.9 and earlier versions.

Method used

By caching query commands that cannot be executed in the storage system and monitoring their dwell time, a power-on reset status code is returned when the timeout is approaching, causing the SCSI kernel engine to resend the command. The number of resends is limited, and a singly linked list data structure is used to manage the commands, thus optimizing the query command processing flow.

Benefits of technology

It significantly improves the stability and automatic recovery capabilities of storage systems, reduces operation and maintenance costs, is suitable for various types of server systems, and ensures the smooth execution of the block scanning process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166652B_ABST
    Figure CN119166652B_ABST
Patent Text Reader

Abstract

The application provides a query instruction processing method and device, electronic equipment and medium, and relates to the technical field of storage. The method is used for a storage system, and the method comprises the following steps: storing a received instruction that cannot be executed into a cache; in the case that it is monitored that there is a query instruction sent by a SCSI kernel engine of a server in the cache, detecting the residence time of the query instruction to obtain an instruction residence time; in the case that the instruction residence time is close to and does not reach a preset instruction timeout time, taking the query instruction out of the cache, and returning a power-on reset state code to the SCSI kernel engine to make the SCSI kernel engine resend the query instruction. The application scheme improves the processing mode of the storage system for the query instruction, significantly improves the automatic recovery capability and stability of the storage system after power-off, and helps to reduce the operation and maintenance cost.
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 in particular to a query instruction processing method, apparatus, electronic device, and medium. Background Technology

[0002] Block devices are a type of I / O device that uses blocks as the unit of transmission, storing information in fixed-size blocks. Each block has its own address, allowing data of a certain length to be read from any location on the device. After a storage system restarts, the server operating system's SCSI (Small Computer System Interface) kernel engine automatically initiates block device scan commands to scan for block devices provided by the storage system. Only servers that sequentially complete the block device scan discovery process can obtain services from the storage system. Whether the query commands used to retrieve storage system information in the block device scan discovery process are responded to in a timely manner determines whether subsequent processes can be executed sequentially.

[0003] Currently, in existing technologies, a common approach to ensure that query commands can be effectively responded to by the storage system is to set a relatively long waiting time on the client server. However, this design places requirements on the client server's system. For example, CentOS 7.9 / Red Hat 7.9 and earlier versions cannot implement this function. When the query command times out, the block device scanning and discovery process cannot continue. In addition, for storage systems that provide storage services to a large number of client servers, the performance and system requirements of each server are quite complex. After each restart of the storage system, maintenance personnel need to individually debug the servers that cannot accurately obtain block devices, which increases maintenance costs. Summary of the Invention

[0004] This invention provides a query command processing method, apparatus, electronic device, and medium to solve the problem in the prior art where client servers are prone to block device unrecoverability after a storage system restart. By improving the way the storage system processes query commands, the possibility of query commands not being responded to is significantly reduced, thereby improving the stability of the storage system.

[0005] According to a first aspect of the present invention, a query instruction processing method is provided, wherein the query instruction is an instruction used in a block device scanning and discovery process to obtain storage system information, the method being used in a storage system, the method comprising:

[0006] Store the received unexecutable instructions in the cache;

[0007] If a query command sent by the server's SCSI kernel engine is detected in the cache, the dwell time of the query command is detected to obtain the command dwell time;

[0008] If the instruction dwell time is close to but has not reached the preset instruction timeout time, the query instruction is retrieved from the cache, and a power-on reset status code is returned to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction.

[0009] According to the query instruction processing method of the present invention, before the steps of retrieving the query instruction from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction, the method further includes:

[0010] Determine whether the number of times the query command has been resent exceeds a preset number;

[0011] If the number of resends does not exceed the preset number, then the step of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command is allowed;

[0012] If the number of resends exceeds the preset number, the steps of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command are prohibited, and the number of resends is reset to zero.

[0013] According to the query instruction processing method of the present invention, the storage system includes multiple processing cores, and the step of storing the received unexecutable instructions into a cache includes:

[0014] Each received instruction is determined individually to determine whether it can be executed by the processing core.

[0015] If it is confirmed that a certain instruction cannot be executed, the instruction is written into the cache;

[0016] For each processing core, the starting address, arrival time, and information of each instruction are recorded using a singly linked list data structure, resulting in an instruction cache queue corresponding to each processing core.

[0017] According to the query instruction processing method of the present invention, the step of detecting the dwell time of the query instruction to obtain the instruction dwell time includes:

[0018] Obtain the arrival time of the query instruction from the instruction cache queue;

[0019] Execute a scheduled task, wherein the scheduled task is used to calculate the difference between the current time and the arrival time of the instruction corresponding to the query instruction when a preset timer arrives to obtain the current instruction dwell time;

[0020] Calculate the difference between the current instruction dwell time and the preset instruction timeout time;

[0021] Determine whether the difference between the current instruction dwell time and the preset instruction timeout time is less than the preset waiting time;

[0022] If the difference between the current instruction dwell time and the preset instruction timeout time is less than or equal to the preset waiting time, then it is confirmed that the instruction dwell time is close to and has not reached the preset instruction timeout time.

[0023] If the difference between the current instruction dwell time and the preset instruction timeout time is greater than the preset waiting time, then it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the process returns to the step of executing the timed task.

[0024] According to the query instruction processing method of the present invention, the preset number of times is determined according to the following steps:

[0025] Obtain the historical startup time of the storage system;

[0026] Determine whether the historical startup time exceeds twice the preset instruction timeout time;

[0027] If the historical startup time does not exceed twice the preset instruction timeout time, then the preset number of times is set to once;

[0028] If the historical startup time exceeds twice the preset instruction timeout time, the preset number of times will be set to two.

[0029] According to the query instruction processing method of the present invention, obtaining the historical startup time of the storage system includes:

[0030] Read log data from the storage system;

[0031] Based on preset keywords, query the log data for the most recent startup times;

[0032] The historical startup time can be obtained by calculating the average or median of the most recent startup times, or by calculating the median of the most recent startup times.

[0033] According to the query instruction processing method of the present invention, the preset timing time corresponding to the timed task is equal to 100 milliseconds, the preset instruction timeout time is equal to 20 seconds, and the preset waiting time is between 19000 milliseconds and 19700 milliseconds.

[0034] According to a second aspect of the present invention, the present invention also provides a query instruction processing apparatus, wherein the query instruction is an instruction used in a block device scanning and discovery process to obtain storage system information, the apparatus being used in a storage system, the apparatus comprising:

[0035] The instruction cache module is used to store received instructions that cannot be executed into the cache;

[0036] The time detection module is used to detect the dwell time of a query command sent by the server's SCSI kernel engine when the cache is detected to contain such a query command.

[0037] The instruction retransmission module is used to retrieve the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine when the instruction dwell time is close to but has not reached the preset instruction timeout time, so that the SCSI kernel engine retransmits the query instruction.

[0038] According to a third aspect of the present invention, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the query instruction processing method as described above.

[0039] According to a fourth aspect of the present invention, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the query instruction processing method as described above.

[0040] This invention provides a query command processing method that improves the way storage systems handle query commands. By storing unexecutable commands received by the storage system in a cache, and detecting the dwell time of a query command when it is detected in the cache, the method retrieves the query command from the cache when the dwell time approaches a preset timeout. The command is then resent by returning a power-on reset code to the server's SCSI kernel engine. This increases the response time of the server and other storage systems to the query command, and ignores the influence of the client server's system and block scan process parameters. It is applicable to various types of server systems, exhibiting good versatility, effectively ensuring the smooth execution of the client block scan process, significantly improving the storage system's automatic recovery capability and stability after power-off, and helping to reduce maintenance costs.

[0041] In addition, the query instruction processing device, the electronic device, and the non-transitory computer-readable storage medium provided by the present invention can also achieve the above-mentioned technical effects, and will not be described in detail here. Attached Figure Description

[0042] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0043] Figure 1 This is a schematic diagram of the connection between the server and storage system provided by the present invention.

[0044] Figure 2 This is a schematic diagram of the query instruction processing method provided by the present invention.

[0045] Figure 3 This is one of the schematic diagrams of the block device scanning and discovery process provided by the present invention.

[0046] Figure 4 This is the second schematic diagram of the block device scanning and discovery process provided by the present invention.

[0047] Figure 5 This is a schematic diagram illustrating the mapping relationship between logical units and the host in the storage system provided by the present invention.

[0048] Figure 6 This is a schematic diagram of the block device scanning and discovery process after the storage system provided by the present invention has been optimized.

[0049] Figure 7 This is a schematic diagram of query instruction timeout detection in a multi-processor core scenario provided by the present invention.

[0050] Figure 8 This is a schematic diagram of a cache for unprocessable instructions provided by the present invention.

[0051] Figure 9 This is a schematic diagram comparing the dwell time of a query command with the startup time of the storage system after optimization, provided by the present invention.

[0052] Figure 10 This is a schematic diagram of the query instruction processing device provided by the present invention.

[0053] Figure 11 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0055] The following is combined with Figures 1 to 11 This invention describes a query instruction processing method, a query instruction processing apparatus, an electronic device, and a non-transitory computer-readable storage medium.

[0056] To facilitate understanding of the present invention, the technical terms mentioned in the solution, such as block device, block device scanning and discovery process, query command, etc., will be explained first.

[0057] A storage system refers to a server that can provide a large amount of data storage space to meet the needs of different applications and users. A server is a client that can use the storage space provided by the server. The server can provide services to multiple clients simultaneously, and each client can access different servers to obtain storage services. For example... Figure 1 As shown, the server and storage system are connected through an FC (Fibre Channel, a standard network architecture) switch. After the storage system starts up, port B of the storage system and port A of the server will automatically establish a connection (this is a standard operation of the FC protocol at the link layer, which will not be elaborated here).

[0058] The block device scanning and discovery process is a standard procedure applied to client servers for discovering block devices in a storage system. Please refer to [link / reference needed]. Figure 1 As shown, after the connection between the server and the storage system is established, the SCSI (Small Computer System Interface) kernel engine of the server operating system will automatically initiate a scan command to scan the storage system and generate a block device / dev / sdx in the operating system's file system. In this way, the server can access the volume on the storage through the / dev / sdx block device for data reading / writing. The storage system can provide the server with multiple volumes—logical units. These volumes appear to the server as multiple block devices. By accessing these block devices, the server can indirectly access the logical units on the storage, write data to these logical units, or read data from these logical units.

[0059] The query command is a crucial command in the block device scanning and discovery process. It is the first query command in the process, used to retrieve the vendor and product information of the storage system. The success of the query determines the execution of subsequent steps in the block device scanning and discovery process. Typically, a successful query will obtain the vendor and product information of the storage system, enabling subsequent mapping between the block device and the physical volumes on the storage system. If the query fails, the server acting as the client will be unable to use the storage services provided by the storage system.

[0060] Figure 2 This is a flowchart illustrating the query instruction processing method provided in an embodiment of the present invention. Please refer to it. Figure 2 As shown, this embodiment provides a query instruction processing method. The query instruction is an instruction used to obtain storage system information in the block device scanning and discovery process. The method is used for the storage system and can be implemented through steps S201 to S203. The following will describe each step in detail:

[0061] Step S201: Store the received unexecutable instructions in the cache.

[0062] In this embodiment, the storage system can establish connections with multiple servers, and each server can send instructions to the storage system. These instructions include, but are not query instructions, write instructions, delete instructions, read instructions, etc. Instructions that cannot be executed are determined based on the content of the instruction and the state of the storage system. For example, if a server sends an instruction to the storage system to read data from a certain storage block, and the current storage system has not yet fully started, then this instruction is an unexecutable instruction.

[0063] In practical implementation, there are many ways to identify instructions that cannot be executed. For example, execution conditions can be preset for each type of instruction. When an instruction of that type is received, it can be pre-checked whether the storage system can meet the execution conditions. If the conditions are met, the instruction is executable; otherwise, it is not. Alternatively, instructions that cannot be executed can be collected in advance based on the storage system's operating status. When an instruction is received, it is matched with the non-executable instructions marked in the operating status to determine whether the instruction can be executed.

[0064] Step S202: If a query command sent by the server's SCSI kernel engine is detected in the cache, the dwell time of the query command is detected to obtain the instruction dwell time.

[0065] In this embodiment, there are many ways for the storage system to monitor query commands. It can periodically check whether there are query commands in the cache, or it can find query commands every time data is written to the cache. It should be noted that the storage system can identify whether a command is a query command by means of special identifiers in the command or certain common characteristics of such commands.

[0066] In this embodiment, there are many ways to detect the dwell time of a query command. In the specific implementation process, an arrival timestamp can be recorded immediately after the query command arrives, and the difference between the current time and the arrival timestamp can be calculated at preset time intervals to determine the dwell time. Alternatively, a timer can be started after the command arrives to reflect the dwell time of the query command.

[0067] Step S203: If the instruction dwell time is close to but has not reached the preset instruction timeout time, the query instruction is retrieved from the cache, and a power-on reset status code is returned to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction.

[0068] In this embodiment, the preset instruction timeout is a maximum time agreed upon by the storage system and the server to allow responses to instructions, etc., typically referring to the maximum allowed execution time for a particular instruction or operation. Once the instruction timeout is reached, the server no longer accepts the corresponding query data returned by the storage system. In practice, the preset instruction timeout can be set by the user according to their needs.

[0069] In this embodiment, "close to but not reaching the preset instruction timeout time" means that the difference between the preset instruction timeout time and the actual timeout time is within a relatively small range. In specific implementation, this can be achieved by setting at least one reference time. For example, if the preset instruction timeout time is 5 seconds, the reference time can be set to 4.5 seconds, 4.8 seconds, etc. It is understood that the reference times listed above for judging whether the instruction dwell time has resolved the preset timeout time are only for illustrative purposes and should not be construed as limiting the present invention.

[0070] In this embodiment, the power-on reset status code can be pre-generated or generated in real time. For example, the pre-generated power-on reset status code can be stored in a register. When it is necessary to return the power-on reset status code, the data in the register can be read to achieve the return of the power-on reset status code.

[0071] It should be noted that this embodiment does not limit the server's operating system or the block device scanning and discovery process used, as long as the process can issue query commands through the server's operating system's SCSI during runtime. For ease of understanding, this embodiment provides two commonly used block device scanning and discovery processes.

[0072] Please combine Figure 3 The block device discovery process is as follows: After the server port and the storage system port are connected, the server operating system will actively initiate a query command to retrieve the vendor and product information of the storage system. If the query for the vendor and product information fails, the server will actively log out from the storage system port after 90 seconds and then log in again. After successfully logging in, it will continue to initiate a query command to retrieve the vendor and product information of the storage system. If the query for the vendor and product information of the storage system is successful, the server will continue to query the list of logical units on the storage system (see the mapping relationship between logical units and hosts). Based on the retrieved list of logical units, the server will read the capacity and UUID of each logical unit. After reading all relevant information, the corresponding block device will be generated in the file system.

[0073] Please combine Figure 4 As shown, the block scanning process for server systems CentOS 7.9 / Red Hat 7.9 and earlier versions is as follows: After the server port and storage system port are connected, the server operating system will actively initiate a query command to query the vendor and product information of the storage system. If the query for the vendor and product information fails, the SCSI kernel engine will directly exit the scanning process. If the query for the vendor and product information of the storage system is successful, the server will continue to query the list of logical units on the storage system (see the mapping relationship between logical units and hosts). Based on the retrieved list of logical units, the capacity and UUID of each logical unit are read one by one. After all relevant information is read, the corresponding block device will be generated in the file system.

[0074] The query command processing method in this embodiment improves the way the storage system handles query commands. By storing unexecutable commands received by the storage system in a cache, and detecting the dwell time of a query command when it is detected in the cache, the query command is retrieved from the cache when the dwell time is close to the preset command timeout time. The command can be resent by returning a power-on status reset code to the server's SCSI kernel engine. This increases the response time of the server and other storage systems to the query command and can ignore the influence of the system used by the client server and the block scan process parameters. It is applicable to various types of server systems, has good versatility, can effectively ensure the smooth execution of the client block scan process, significantly improves the automatic recovery capability and stability of the storage system after power failure, and helps to reduce operation and maintenance costs.

[0075] In some possible implementations, before step S103, retrieving the query instruction from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction, the method further includes:

[0076] Determine whether the number of times the query command has been resent exceeds a preset number;

[0077] If the number of resends does not exceed the preset number, then the step of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command is allowed;

[0078] If the number of resends exceeds the preset number, the steps of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command are prohibited, and the number of resends is reset to zero.

[0079] The query command processing method in this embodiment limits the number of times a query command can be resent. Before each resend of the query command, it determines whether the number of times the query command has been resent exceeds the set value, thereby ensuring that the number of resends of the query command is within the acceptable range of the client server and avoiding invalid resends of query commands.

[0080] In some possible implementations, the storage system includes multiple processing cores, and storing received unexecutable instructions in a cache includes:

[0081] Each received instruction is determined individually to determine whether it can be executed by the processing core.

[0082] If it is confirmed that a certain instruction cannot be executed, the instruction is written into the cache;

[0083] For each processing core, the starting address, arrival time, and information of each instruction are recorded using a singly linked list data structure, resulting in an instruction cache queue corresponding to each processing core.

[0084] The query instruction processing method in this embodiment manages non-executable instructions through a cache queue corresponding to the core, which improves the efficiency of instruction management and ensures that queries can be obtained in a timely and accurate manner. At the same time, the singly linked list data structure containing specific information facilitates the detection of the dwell time of subsequent query instructions.

[0085] In some possible implementations, detecting the dwell time of the query instruction to obtain the instruction dwell time includes:

[0086] Obtain the arrival time of the query instruction from the instruction cache queue;

[0087] Execute a scheduled task, wherein the scheduled task is used to calculate the difference between the current time and the arrival time of the instruction corresponding to the query instruction when a preset timer arrives to obtain the current instruction dwell time;

[0088] Calculate the difference between the current instruction dwell time and the preset instruction timeout time;

[0089] Determine whether the difference between the current instruction dwell time and the preset instruction timeout time is less than the preset waiting time;

[0090] If the difference between the current instruction dwell time and the preset instruction timeout time is less than or equal to the preset waiting time, then it is confirmed that the instruction dwell time is close to and has not reached the preset instruction timeout time.

[0091] If the difference between the current instruction dwell time and the preset instruction timeout time is greater than the preset waiting time, then it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the process returns to the step of executing the timed task.

[0092] In some possible implementations, the timeout settings for scheduled tasks can be configured with multiple granularities. For example, the time a query command can remain in the storage system for the first ten seconds after it arrives can be relatively long. Assuming the client service's default timeout is 20 seconds, the scheduled task's duration can be set relatively long, such as executing every 400 milliseconds. After that, the duration can be set relatively short, such as executing every 100 milliseconds. This approach can, to some extent, reduce the number of times the scheduled task executes while maintaining time detection accuracy, thus avoiding wasting computing resources. Similarly, the timing of scheduled tasks can also be limited based on the number of retransmissions. For example, in the first retransmission cycle, the scheduled task can execute every 200 milliseconds, and in the second retransmission cycle, it can execute every 100 milliseconds. This configuration balances time detection accuracy and task execution frequency, further improving the flexibility of query command processing.

[0093] In some possible implementations, the preset number of times is determined according to the following steps:

[0094] Obtain the historical startup time of the storage system;

[0095] Determine whether the historical startup time exceeds twice the preset instruction timeout time;

[0096] If the historical startup time does not exceed twice the preset instruction timeout time, then the preset number of times is set to once;

[0097] If the historical startup time exceeds twice the preset instruction timeout time, the preset number of times will be set to two.

[0098] The query command processing method in this embodiment collects the historical startup time of the storage system and sets the number of command resends based on the historical startup time. This makes the time that the scheduled task can stay closer to the actual startup time of the storage system, adapts to the performance of each storage system, and makes the setting of the number of resends more reasonable and accurate.

[0099] In some possible implementations, obtaining the historical startup time of the storage system includes:

[0100] Read log data from the storage system;

[0101] Based on preset keywords, query the log data for the most recent startup times;

[0102] The historical startup time can be obtained by calculating the average or median of the most recent startup times, or by calculating the median of the most recent startup times.

[0103] The query command processing method in this embodiment obtains multiple recent historical startup times using the storage system's own log data, and then further confirms the historical startup times by calculating the average or median. The historical startup times determined in this way are more accurate, which helps to improve the accuracy of the retry count setting.

[0104] In some possible implementations, the preset timing time corresponding to the timed task is equal to 100 milliseconds, the preset instruction timeout time is equal to 20 seconds, and the preset waiting time is between 19000 milliseconds and 19700 milliseconds.

[0105] The query instruction processing method in this embodiment further limits the timing time and maximum waiting time of the scheduled task, enabling the storage system to extend the waiting time of the query instruction to the maximum extent, providing sufficient time for the storage system to respond to the query task, and significantly increasing the likelihood that the subsequent processes of the block device scanning discovery process will be executed smoothly.

[0106] In yet another embodiment, for ease of understanding of the present invention, the following is used... Figure 5Taking the application scenario shown as an example, let's assume that server A is running a CentOS 7.9 / Red Hat 7.9 or later operating system, and server B is running an operating system earlier than CentOS 7.9 / Red Hat 7.9. In this scenario, the mapping relationship between logical units and hosts is as follows: There are 6 logical units on the storage system. Logical units 0, 1, and 2 are mapped to server A. Therefore, server A can only scan logical units 0, 1, and 2 on the storage system and generate the corresponding block devices (e.g., / dev / sdaa, / dev / sdab, / dev / sdac) on server A. Logical units 3, 4, and 5 are mapped to server B. Therefore, server B can only scan logical units 3, 4, and 5 on the storage system and generate the corresponding block devices (e.g., / dev / sdba, / dev / sdbb, / dev / sdbc) on server B. This embodiment optimizes the block device discovery process using the aforementioned query command processing method. The principle is as follows: Before the query command times out, the server responds with a "power-on reset" status code (a status code in the SCSI standard), triggering the SCSI kernel engine to resend the query command to retrieve the storage system's vendor and product information. This allows the server to rescan the logical units on the storage system and generate block devices, resuming access to these logical units. The SCSI kernel engine module handles the status codes returned by the storage system specially. If the storage system returns a power-on reset status code, the SCSI kernel engine will resend the query command to retrieve the storage system's vendor and product information. This retry is limited to two attempts. If both retries fail, the SCSI kernel engine module will abandon the query.

[0107] Please refer to Figure 6 As shown, the optimized block device scanning and discovery processes for servers A and B can both execute according to the following set standards: If querying the vendor and product information of the storage system fails, and the number of responses to the query command is less than 2, a power-on reset status code will be returned to the server before the query command times out (upon receiving the power-on reset status code, the server will resend the query command to obtain the vendor and product information of the storage system; see the power-on reset response process for the response handling process); if the number of responses to the query command has reached 2, the response process will be exited directly (the server's maximum number of attempts is 2); if querying the vendor and product information of the storage system succeeds, the server will continue to query the list of logical units on the storage system (see the mapping relationship between logical units and hosts); based on the retrieved list of logical units, the capacity and UUID of each logical unit will be read one by one; after reading all relevant information, the corresponding block device will be generated in the file system.

[0108] Specifically, please refer to Figure 7 The power-on reset response process is as follows: Multiple threads within the storage system process data simultaneously (reading / writing data), and each thread is bound to a CPU core (CPU affinity, a common operation, will not be elaborated here). For data processing efficiency, we set up an instruction buffer on each thread to store the query instructions for that thread (one queue buffer corresponds to one thread, which serializes data processing, avoids lock acquisition and waiting operations during data processing, and improves data processing efficiency).

[0109] struct command_s {

[0110] struct command_s * next; / / Pointer to the current data structure

[0111] uint64 timestamp; / / Command arrival timestamp

[0112] char cdb

[64] ; / / Stores instruction information

[0113] Other members of the instruction data structure are irrelevant to this invention and will not be described in detail here.

[0114] }

[0115] The above are the "instruction data structures" that need to be temporarily stored in the instruction buffer. Next is the starting address of the current data structure, which is used to add it to the instruction buffer to form a linked list. Timestamp is used to record the time when the instruction arrives. When the timer task scans, it uses this time as a reference and calculates the instruction timeout by subtracting the current time from it. CDB is used to store instruction information (its content is defined in the SCSI protocol specification. Different instructions have different definitions, which is not the focus of this invention and will not be elaborated here).

[0116] The instruction buffer is a singly linked list data structure, as defined below. The s_slist data structure is a typical singly linked list data structure definition. Adding and removing members of a singly linked list are common operations, but they are not the focus of this invention and will not be elaborated here.

[0117] struct s_slist_node {

[0118] struct s_slst_node *next;

[0119] / / Singly linked list node definition

[0120] struct s_slist {

[0121] struct s_slist_node *head; / / Head pointer of the instruction buffer

[0122] struct s_slist_node *tail; / / Tail pointer of instruction buffer

[0123] uint32 count; / / Length of the instruction buffer (number of members in the list)

[0124] }

[0125] Please refer to Figure 8 As shown, during the startup phase, the storage system cannot process query commands sent by the server. Upon receiving a query command from the server, the storage system temporarily stores it in a command buffer. A timer task continuously scans the command buffer every 100 milliseconds. When it detects a query command that is about to time out (the default timeout for a query command is 20 seconds), it removes the command from the buffer (a singly linked list member removal operation), fills it with a power-on reset status code, and sends it to the server. This triggers the server to resend the query command. (If a power-on reset status code is not sent to the server, the server considers the query command to have timed out and will initiate subsequent query operations, causing the block device scan to fail.)

[0126] Since the timer period is 100 milliseconds, the instruction buffer scan error is also 100 milliseconds. The query instruction timeout threshold needs to be defined as 19700 milliseconds. When the timeout exceeds 19700 milliseconds, the query instruction is considered to have timed out. This is easy to understand. Because the timer polling period is 100 milliseconds (meaning it executes once every 100 milliseconds), if it exceeds 19700 milliseconds, the next query will occur after 100 milliseconds, and this time will fall between 19800 and 20000 milliseconds (because the timer also has a certain margin of error). The reason for choosing a timer execution period of 100 milliseconds is mainly to ensure that the timeout is as close as possible to 20000 milliseconds, guaranteeing a relatively accurate timeout, but not extremely precise. 100 milliseconds is an empirical value (executing once every 100 milliseconds does not significantly affect the execution of other tasks on the thread).

[0127] Please refer to Figure 9 As shown, Figure 9The comparison describes the query command timeout time and the storage system node startup time. The storage system startup time is approximately 30-50 seconds, while the server query command timeout is 20 seconds (for CentOS 7.9 / Red Hat 7.9 and earlier versions, the SCSI kernel engine abandons subsequent operations after one timeout, resulting in the inability to generate block devices on the server). This invention triggers the server to retry the query command, extending the timeout from the original 20 seconds to 60 seconds, covering the storage system startup time, thus effectively solving this problem.

[0128] The query instruction processing apparatus provided by the present invention is described below. The query instruction processing apparatus described below and the query instruction processing method described above can be referred to in correspondence.

[0129] Please refer to Figure 10 As shown, this embodiment provides a query instruction processing device. The query instruction is an instruction used to obtain storage system information in the block device scanning and discovery process. The device is used for the storage system. Specifically, the device includes: an instruction cache module 1010, a time detection module 1020, and an instruction retransmission module 1030. The above modules will be described in detail below:

[0130] The instruction cache module 1010 is used to store received unexecutable instructions into the cache;

[0131] The time detection module 1020 is used to detect the dwell time of a query command sent by the server's SCSI kernel engine when the cache is detected to contain such a query command.

[0132] The instruction retransmission module 1030 is used to retrieve the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine when the instruction dwell time is close to but has not reached the preset instruction timeout time, so that the SCSI kernel engine retransmits the query instruction.

[0133] The query instruction processing device in this embodiment improves the way the storage system handles query instructions. By storing unexecutable instructions received by the storage system in a cache, and detecting the dwell time of a query instruction when it is detected in the cache, the query instruction is retrieved from the cache when the dwell time is close to a preset instruction timeout. The instruction is then resent by returning a power-on status reset code to the server's SCSI kernel engine. This increases the response time of the server and other storage systems to the query instruction and can ignore the influence of the system used by the client server and the block scan process parameters. It is applicable to various types of server systems, has good versatility, can effectively ensure the smooth execution of the client block scan process, significantly improves the automatic recovery capability and stability of the storage system after power failure, and helps to reduce operation and maintenance costs.

[0134] In some possible implementations, the device further includes a retransmission determination module, which is used to:

[0135] Determine whether the number of times the query command has been resent exceeds a preset number;

[0136] If the number of resends does not exceed the preset number, then the step of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command is allowed;

[0137] If the number of resends exceeds the preset number, the steps of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command are prohibited, and the number of resends is reset to zero.

[0138] In some possible implementations, the storage system includes multiple processing cores, and the instruction cache module 1010 is further used for:

[0139] Each received instruction is determined individually to determine whether it can be executed by the processing core.

[0140] If it is confirmed that a certain instruction cannot be executed, the instruction is written into the cache;

[0141] For each processing core, the starting address, arrival time, and information of each instruction are recorded using a singly linked list data structure, resulting in an instruction cache queue corresponding to each processing core.

[0142] In some possible implementations, the time detection module 1020 is further configured to:

[0143] Obtain the arrival time of the query instruction from the instruction cache queue;

[0144] Execute a scheduled task, wherein the scheduled task is used to calculate the difference between the current time and the arrival time of the instruction corresponding to the query instruction when a preset timer arrives to obtain the current instruction dwell time;

[0145] Calculate the difference between the current instruction dwell time and the preset instruction timeout time;

[0146] Determine whether the difference between the current instruction dwell time and the preset instruction timeout time is less than the preset waiting time;

[0147] If the difference between the current instruction dwell time and the preset instruction timeout time is less than or equal to the preset waiting time, then it is confirmed that the instruction dwell time is close to and has not reached the preset instruction timeout time.

[0148] If the difference between the current instruction dwell time and the preset instruction timeout time is greater than the preset waiting time, then it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the process returns to the step of executing the timed task.

[0149] In some possible implementations, the preset number of times is determined according to the following steps:

[0150] Obtain the historical startup time of the storage system;

[0151] Determine whether the historical startup time exceeds twice the preset instruction timeout time;

[0152] If the historical startup time does not exceed twice the preset instruction timeout time, then the preset number of times is set to once;

[0153] If the historical startup time exceeds twice the preset instruction timeout time, the preset number of times will be set to two.

[0154] In some possible implementations, obtaining the historical startup time of the storage system includes:

[0155] Read log data from the storage system;

[0156] Based on preset keywords, query the log data for the most recent startup times;

[0157] The historical startup time can be obtained by calculating the average or median of the most recent startup times, or by calculating the median of the most recent startup times.

[0158] In some possible implementations, the preset timing time corresponding to the timed task is equal to 100 milliseconds, the preset instruction timeout time is equal to 20 seconds, and the preset waiting time is between 19000 milliseconds and 19700 milliseconds.

[0159] It should be noted that each module in the above-mentioned query instruction processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the electronic device in hardware form or independent of it, or stored in the memory of the electronic device in software form, so that the processor can call and execute the operations corresponding to each module.

[0160] Figure 11 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 11 As shown, the electronic device may include: a processor 1110, a communications interface 1120, a memory 1130, and a communication bus 1140, wherein the processor 1110, the communications interface 1120, and the memory 1130 communicate with each other through the communication bus 1140. The processor 1110 can call logical instructions in the memory 1130 to execute a query instruction processing method. The query instruction is an instruction used to obtain storage system information in the block device scanning and discovery process. The method is used for the storage system and includes: storing received unexecutable instructions in a cache; when a query instruction sent by the server's SCSI kernel engine is detected in the cache, detecting the dwell time of the query instruction to obtain the instruction dwell time; when the instruction dwell time is close to but has not reached a preset instruction timeout time, retrieving the query instruction from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction.

[0161] Furthermore, the logical instructions in the aforementioned memory 1130 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0162] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the query instruction processing method provided by the above methods. The query instruction is an instruction used to obtain storage system information in the block device scanning and discovery process. The method is used in the storage system and includes: storing a received unexecutable instruction in a cache; when a query instruction sent by the SCSI kernel engine of the server is detected in the cache, detecting the dwell time of the query instruction to obtain the instruction dwell time; when the instruction dwell time is close to but has not reached a preset instruction timeout time, retrieving the query instruction from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction.

[0163] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the query instruction processing method provided by the above methods. The query instruction is an instruction used to obtain storage system information in a block device scanning and discovery process. The method is used in the storage system and includes: storing a received unexecutable instruction in a cache; when a query instruction sent by the SCSI kernel engine of a server is detected in the cache, detecting the dwell time of the query instruction to obtain the instruction dwell time; when the instruction dwell time is close to but has not reached a preset instruction timeout time, retrieving the query instruction from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query instruction.

[0164] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0165] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0166] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A query instruction processing method, characterized in that, The query instruction is a command used in the block device scanning and discovery process to obtain storage system information. The method is used for the storage system and includes: Store the received unexecutable instructions in the cache; If a query command sent by the server's SCSI kernel engine is detected in the cache, the dwell time of the query command is detected to obtain the command dwell time; If the instruction dwell time is close to but has not reached the preset instruction timeout time, the query instruction is retrieved from the cache and a power-on reset status code is returned to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction; The storage system includes multiple processing cores, and the received unexecutable instructions are stored in the cache to obtain an instruction cache queue corresponding to each processing core; The step of detecting the dwell time of the query command to obtain the command dwell time includes: Obtain the arrival time of the query instruction from the instruction cache queue; Execute a scheduled task, wherein the scheduled task is used to calculate the difference between the current time and the arrival time of the instruction corresponding to the query instruction when a preset timer arrives to obtain the current instruction dwell time; Calculate the difference between the current instruction dwell time and the preset instruction timeout time; Determine whether the difference between the current instruction dwell time and the preset instruction timeout time is less than the preset waiting time; If the difference between the current instruction dwell time and the preset instruction timeout time is less than or equal to the preset waiting time, then it is confirmed that the instruction dwell time is close to and has not reached the preset instruction timeout time. If the difference between the current instruction dwell time and the preset instruction timeout time is greater than the preset waiting time, then it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the process returns to the step of executing the timed task.

2. The query instruction processing method according to claim 1, characterized in that, Before the steps of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to cause the SCSI kernel engine to resend the query command, the method further includes: Determine whether the number of times the query command has been resent exceeds a preset number; If the number of resends does not exceed the preset number, then the step of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command is allowed; If the number of resends exceeds the preset number, the steps of retrieving the query command from the cache and returning a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query command are prohibited, and the number of resends is reset to zero.

3. The query instruction processing method according to claim 1, characterized in that, The step of storing the received unexecutable instructions in the cache includes: Each received instruction is determined individually to determine whether it can be executed by the processing core. If it is confirmed that a certain instruction cannot be executed, the instruction is written into the cache; For each processing core, the starting address, arrival time, and information of each instruction are recorded using a singly linked list data structure to obtain the instruction cache queue corresponding to each processing core.

4. The query instruction processing method according to claim 2, characterized in that, The preset number of times is determined according to the following steps: Obtain the historical startup time of the storage system; Determine whether the historical startup time exceeds twice the preset instruction timeout time; If the historical startup time does not exceed twice the preset instruction timeout time, then the preset number of times is set to once; If the historical startup time exceeds twice the preset instruction timeout time, the preset number of times will be set to two.

5. The query instruction processing method according to claim 1, characterized in that, The preset timeout period for the scheduled task is 100 milliseconds, the preset instruction timeout period is 20 seconds, and the preset waiting time is between 19000 milliseconds and 19700 milliseconds.

6. A query instruction processing device, characterized in that, The query command is a command used in the block device scanning and discovery process to obtain storage system information. The device is used in the storage system and includes: The instruction cache module is used to store received instructions that cannot be executed into the cache; The time detection module is used to detect the dwell time of a query command sent by the server's SCSI kernel engine when the cache is detected to contain such a query command. The instruction retransmission module is used to retrieve the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine when the instruction dwell time is close to but has not reached the preset instruction timeout time, so that the SCSI kernel engine retransmits the query instruction. The storage system includes multiple processing cores, and the received unexecutable instructions are stored in the cache to obtain an instruction cache queue corresponding to each processing core; The time detection module is further used for: Obtain the arrival time of the query instruction from the instruction cache queue; Execute a scheduled task, wherein the scheduled task is used to calculate the difference between the current time and the arrival time of the instruction corresponding to the query instruction when a preset timer arrives to obtain the current instruction dwell time; Calculate the difference between the current instruction dwell time and the preset instruction timeout time; Determine whether the difference between the current instruction dwell time and the preset instruction timeout time is less than the preset waiting time; If the difference between the current instruction dwell time and the preset instruction timeout time is less than or equal to the preset waiting time, then it is confirmed that the instruction dwell time is close to and has not reached the preset instruction timeout time. If the difference between the current instruction dwell time and the preset instruction timeout time is greater than the preset waiting time, then it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the process returns to the step of executing the timed task.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the query instruction processing method as described in any one of claims 1 to 5.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the query instruction processing method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Caching data synchronous system and method in process of accessing iSCSI (Internet Small Computer System Interface) storage device

    CN101923442A

  • Method, system and device for processing instruction timeout and medium

    CN112631659A