Query instruction processing method and device, electronic equipment and medium
By cached query instructions in the storage system and resented at appropriate times, the block device recovery problem after the storage system is restarted is solved, the system stability and response capabilities are improved, and the operation and maintenance costs are reduced.
Patent Information
- Application Number
- CN202411034780.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-12-20
AI Technical Summary
After the storage system is restarted, the client server is prone to problems such that the block device cannot be restored, resulting in untimely response to query instructions, affecting system stability and operation and maintenance costs.
When a query instruction that cannot be executed is received in the storage system, it is stored in the cache, and when it is detected that the instruction residence time is close to the preset timeout, it is retrieved from the cache and returns to the SCSI kernel engine to power-on reset Status code, make it resend, limiting the number of resends to avoid invalid resends.
It significantly reduces the possibility that query instructions are not responded, improves the stability and automatic recovery capabilities of the storage system, reduces operation and maintenance costs, and is suitable for various types of server systems.
Smart Images

Figure CN119166652A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a query instruction processing method, device, electronic equipment and medium. Background Art
[0002] Block devices are a type of I / O device that uses blocks as the transmission unit and stores information in blocks of fixed size. Each block has its own address, allowing data of a certain length to be read at any location on the device. After the storage system is restarted, the SCSI (Small Computer System Interface) kernel engine of the server operating system will automatically initiate a block device scan command to scan the block devices provided by the storage system. Only servers that have completed the block device scan discovery process in sequence can obtain services from the storage system. Whether the query command used to query the storage system information in the block device scan discovery process can be responded to in a timely manner determines whether the subsequent processes can be executed in sequence.
[0003] At present, in order to ensure that query instructions can be effectively responded to by the storage system in the existing technology, a common method is to set a longer waiting time on the client server; however, this design has requirements for the client server system. For example, centos7.9 / redhat7.9 and its previous versions cannot implement this function. When the query instruction times out, the block device scanning and discovery process cannot continue to execute. In addition, for storage systems that provide storage services for a large number of client servers, the performance and system requirements of each server are relatively complex. After each restart of the storage system, the operation and maintenance personnel need to debug the server that cannot accurately obtain the block device separately, resulting in increased operation and maintenance costs. Summary of the invention
[0005] The present invention provides a query instruction processing method, device, electronic device and medium, which are used to solve the problem in the prior art that a client server is prone to block device failure after a storage system is restarted. By improving the storage system's processing method for query instructions, the possibility of query instructions not being responded to is significantly reduced, thereby improving the stability of the storage system.
[0006] According to a first aspect of the present invention, the present invention provides a query instruction processing method, wherein the query instruction is an instruction for obtaining storage system information in a block device scanning discovery process, and the method is used for a storage system, and the method comprises: Storing received unexecutable instructions in a cache; In the case where it is detected that there is a query instruction sent by the SCSI kernel engine of the server in the cache, the residence time of the query instruction is detected to obtain the instruction residence time; When the instruction residence time approaches but does not reach the preset instruction timeout time, the query instruction is taken out 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.
[0007] According to the query instruction processing method of the present invention, before the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction, the method further includes: Determining whether the number of retransmissions of the query instruction exceeds a preset number; If the number of retransmissions does not exceed the preset number, the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine to enable the SCSI kernel engine to resend the query instruction is allowed to be executed; If the number of retransmissions exceeds the preset number, the steps of taking the query instruction out of the cache, returning a power-on reset status code to the SCSI core engine so that the SCSI core engine resends the query instruction, and clearing the number of retransmissions are prohibited.
[0008] According to the query instruction processing method of the present invention, the storage system includes multiple processing cores, and storing the received unexecutable instructions in the cache includes: Determine whether each instruction received can be executed by the processing core; When it is confirmed that a certain instruction cannot be executed, writing the certain instruction into the cache; For each processing core, the first address, instruction arrival time, and instruction information of each instruction are recorded based on a single linked list data structure to obtain an instruction cache queue corresponding to each processing core.
[0009] According to the query instruction processing method of the present invention, the step of detecting the residence time of the query instruction to obtain the instruction residence time includes: Obtaining the instruction arrival time corresponding to the query instruction from the instruction cache queue; Execute a timed task, wherein the timed task is used to calculate the difference between the current time and the instruction arrival time corresponding to the query instruction to obtain the current instruction residence time when the preset timed time arrives; 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, 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, it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the step of executing the scheduled task is returned.
[0010] According to the query instruction processing method of the present invention, the preset number of times is determined according to the following steps: Get the historical startup time of the storage system; Determine whether the historical startup time exceeds twice the preset instruction timeout period; When the historical startup time does not exceed twice the preset instruction timeout period, the preset number of times is set to one; When the historical startup time exceeds twice the preset instruction timeout period, the preset number of times is set to twice.
[0011] According to the query instruction processing method of the present invention, obtaining the historical startup time consumption of the storage system includes: Read log data from the storage system; Based on preset keywords, query the log data for multiple startup times closest to the current time; The historical startup time is obtained by calculating an average or median of multiple recent startup time consumptions, or by calculating a median of multiple recent startup time consumptions.
[0012] 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.
[0013] According to a second aspect of the present invention, the present invention further provides a query instruction processing device, wherein the query instruction is an instruction for obtaining storage system information in a block device scanning discovery process, and the device is used for a storage system, and the device comprises: An instruction cache module, used for storing received unexecutable instructions in a cache; A time detection module is used to detect the residence time of the query instruction to obtain the instruction residence time when detecting that there is a query instruction sent by the SCSI kernel engine of the server in the cache; The instruction resending module is used to take out the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query instruction when the instruction residence time is close to and has not reached a preset instruction timeout time.
[0014] According to the third aspect of the present invention, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements any of the query instruction processing methods described above.
[0015] According to a fourth aspect of the present invention, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the query instruction processing method as described in any one of the above is implemented.
[0016] The present invention provides a query instruction processing method, which improves the processing mode of the query instruction by the storage system. The method stores the unexecutable instructions received by the storage system in a cache, and detects the residence time of the instruction when detecting that the query instruction is stored in the cache. When it is detected that the residence time of the instruction is close to the preset instruction timeout time, the query instruction is taken out from the cache, and the instruction can be resent by returning a power-on state reset code to the SCSI kernel engine of the server, so that the time for the server and other storage systems to respond to the query instruction is prolonged, and the influence of the system adopted by the client server and the block scanning process parameters can be ignored. The method is applicable to various types of server systems, has good versatility, can effectively ensure the smooth execution of the client block scanning process, significantly improves the automatic recovery capability and stability of the storage system after power-off, and helps to reduce operation and maintenance costs.
[0017] In addition, a query instruction processing device, an electronic device and a non-transitory computer-readable storage medium provided by the present invention can also achieve the above-mentioned technical effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a schematic diagram of the connection between the server and the storage system provided by the present invention.
[0020] Figure 2It is a flowchart of the query instruction processing method provided by the present invention.
[0021] Figure 3 This is one of the block device scanning and discovery process diagrams provided by the present invention.
[0022] Figure 4 This is the second schematic diagram of the block device scanning and discovery process provided by the present invention.
[0023] Figure 5 It is a schematic diagram of the mapping relationship between the logical unit and the host in the storage system provided by the present invention.
[0024] Figure 6 It is a schematic diagram of the block device scanning and discovery process after the storage system provided by the present invention is optimized.
[0025] Figure 7 It is a schematic diagram of query instruction timeout detection in a multi-processing core situation provided by the present invention.
[0026] Figure 8 It is a schematic diagram of a cache that cannot process instructions provided by the present invention.
[0027] Fig. 9 The present invention provides a schematic diagram for comparing the query instruction residence time and the storage system startup time after the storage system is optimized.
[0028] Fig.10 It is a structural schematic diagram of the query instruction processing device provided by the present invention.
[0029] Fig.11 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. 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.
[0031] Combine the following Figures 1 to 11 The present invention describes a query instruction processing method, a query instruction processing device, an electronic device and a non-transitory computer-readable storage medium.
[0032] In order to facilitate understanding of the solution of the present invention, the technical terms mentioned in the solution, such as block device, block device scanning and discovery process, query instruction, etc., are first explained.
[0033] The 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. The server is a client that can use the storage space provided by the server. The server can provide services to multiple clients at the same time, and each client can also access different servers to obtain storage services. Figure 1 As shown in the figure, the server and storage system are connected through an FC (Fibre Channel is a standard-based network structure) switch. After the storage system is started, port B of the storage system and port A of the server will automatically establish a connection (this is the standard operation of the link layer FC protocol and will not be described here).
[0034] The block device scanning and discovery process is a standard process used by client servers to discover block devices in storage systems. Please continue to refer to Figure 1 As shown in the figure, 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 file system of the operating system. In this way, the server can access the volume on the storage through the / dev / sdx block device for reading / writing data. The storage system can provide the server with multiple volumes - logical units. These volumes are multiple block devices in the eyes of the server. 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.
[0035] The query instruction is a key instruction in the block device scanning and discovery process. The query instruction is the first query instruction in the discovery process. It is used to query the manufacturer information and product information of the storage system. Whether the query instruction can successfully obtain the query result will determine the execution of the subsequent process of the block device scanning and discovery process. Usually, if the query is successful, the manufacturer information and product information of the storage system will be successfully obtained, so that the subsequent block device and the physical volume on the storage system can be mapped to each other. If the query is unsuccessful, the server as the client will not be able to use the storage service provided by the storage system.
[0036] Figure 2 is a flowchart of a query instruction processing method provided by an embodiment of the present invention. Figure 2 As shown, this embodiment provides a query instruction processing method, wherein the query instruction is an instruction for obtaining storage system information in a block device scanning discovery process, and the method is used for a storage system. The method can be implemented by steps S201 to S203, and each step will be described in detail below: Step S201: store the received unexecutable instructions in a cache.
[0037] 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 non-query instructions, write instructions, delete instructions, read instructions, etc. Unexecutable instructions are instructions that cannot be executed based on the instruction content and the system status of the storage system. For example, a server sends an instruction to the storage system to read data from a storage block. If the current storage system has not been fully started, the instruction is an unexecutable instruction.
[0038] There are many ways to find that instructions cannot be executed during the specific implementation process. For example, an execution condition can be preset for each instruction. When receiving an instruction of this type, it can be confirmed in advance whether the storage system can meet the execution condition. If the execution condition can be met, it is an executable instruction, otherwise it is an unexecutable instruction. In addition, it is also possible to collect unexecutable instructions in each state in advance according to the operating state of the storage system. When an instruction is received, the instruction is matched with the unexecutable instruction marked in the operating state to determine whether the instruction can be executed.
[0039] Step S202: when it is detected that there is a query instruction sent by the SCSI kernel engine of the server in the cache, the residence time of the query instruction is detected to obtain the instruction residence time.
[0040] In this embodiment, there are many ways for the storage system to monitor query instructions. It can periodically query whether there are query instructions in the cache. Of course, it can also find out the query instructions every time data is written to the cache. It should be noted that the storage system identifies whether an instruction is a query instruction in many ways, including but not limited to using special identifiers in the instruction or certain common characteristics of such instructions to determine.
[0041] In this embodiment, there are many ways to detect the residence time of the query instruction. In the specific implementation process, an arrival timestamp can be recorded immediately after the query instruction arrives, and the difference between the current time and the arrival timestamp can be calculated at intervals of a preset time to determine the residence time. Of course, the timing can also be started after the instruction arrives to reflect the residence time of the query instruction through timing.
[0042] Step S203, when the instruction residence time is close to but has not reached the preset instruction timeout time, the query instruction is taken out 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.
[0043] In this embodiment, the preset command timeout is a maximum time agreed upon in advance between the storage system and the server for allowing a command or the like to respond, and generally refers to the maximum time allowed for a command or operation to be executed. After the command timeout is reached, the server no longer accepts the corresponding query data returned by the storage system. In the specific implementation process, the preset command timeout can be set by the user according to needs.
[0044] In this embodiment, approaching but not reaching the preset instruction timeout time means that the difference with the preset instruction timeout time is within a relatively small range, which can be achieved by setting at least one reference time in the specific implementation process. 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 can be understood that the reference time listed above for judging whether the instruction residence time solves the preset timeout time is only for illustration and should not be understood as a limitation to the scheme of the present invention.
[0045] 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, and when the power-on reset status code needs to be returned, the power-on reset status code can be returned by reading the data in the register.
[0046] It should be noted that this embodiment does not limit the server operating system and the block device scanning and discovery process used, and only requires that the process can issue query instructions through the SCSI of the server operating system during operation. To facilitate understanding, this embodiment provides two commonly used block device scanning and discovery processes.
[0047] 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 query the manufacturer information and product information of the storage system; if the query of the manufacturer information and product information of the storage system fails, the server will actively log out from the port of the storage system after 90 seconds, and then log in again. After successful login, it will continue to initiate query commands to query the manufacturer information and product information of the storage system; if the query of the manufacturer information 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); according to the queried logical unit list, read the logical unit capacity, UUID and other information one by one; after reading all relevant information, the corresponding block device will be generated in the file system.
[0048] Please combine Figure 4As shown, the block scanning process of the current server system centos7.9 / redhat7.9 and its previous versions 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 query the manufacturer information and product information of the storage system; if the query of the manufacturer information and product information of the storage system fails, the SCSI kernel engine will directly exit the scanning process; if the query of the manufacturer information and product information of the storage system is successful, the server will continue to query the logical unit list on the storage system (see the mapping relationship between the logical unit and the host); according to the queried logical unit list, read the logical unit capacity, UUID and other information one by one; after reading all relevant information, the corresponding block device will be generated in the file system.
[0049] The query instruction processing method of the present embodiment improves the storage system's processing manner of query instructions by storing the unexecutable instructions received by the storage system in a cache, and detecting the residence time of the instruction when detecting that the query instruction is stored in the cache. When it is detected that the residence time of the instruction is close to the preset instruction timeout time, the query instruction is taken out of the cache, and the instruction is resent by returning a power-on status reset code to the SCSI kernel engine of the server, thereby lengthening the time it takes for the server and other storage systems to respond to the query instruction, and ignoring the influence of the system adopted by the client server and the block scanning process parameters. The method is applicable to various types of server systems, has good versatility, can effectively ensure the smooth execution of the client block scanning process, significantly improve the automatic recovery capability and stability of the storage system after power-off, and help reduce operation and maintenance costs.
[0050] In some possible implementations, before taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine in step S103 so that the SCSI kernel engine resends the query instruction, the method further includes: Determining whether the number of retransmissions of the query instruction exceeds a preset number; If the number of retransmissions does not exceed the preset number, the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine to enable the SCSI kernel engine to resend the query instruction is allowed to be executed; If the number of retransmissions exceeds the preset number, the steps of taking the query instruction out of the cache, returning a power-on reset status code to the SCSI core engine so that the SCSI core engine resends the query instruction, and clearing the number of retransmissions are prohibited.
[0051] The query instruction processing method of the present embodiment limits the number of times the query instruction is resent. Before each time the query instruction needs to be resent, it is determined whether the number of times the query instruction is resent exceeds the set value, thereby allowing the resentment. This ensures that the number of times the query instruction is resent is within the range acceptable to the client server, thereby avoiding invalid resent query instructions.
[0052] In some possible implementations, the storage system includes multiple processing cores, and storing the received unexecutable instructions in a cache includes: Determine whether each instruction received can be executed by the processing core; When it is confirmed that a certain instruction cannot be executed, writing the certain instruction into the cache; For each processing core, the first address, instruction arrival time, and instruction information of each instruction are recorded based on a single linked list data structure to obtain an instruction cache queue corresponding to each processing core.
[0053] The query instruction processing method of this embodiment manages the instructions that cannot be executed through a cache queue that corresponds one to one with the core, which can improve the management efficiency of instructions and ensure that queries can only be obtained in a timely and accurate manner. At the same time, the single linked list data structure containing specific information used facilitates the detection of the residence time of subsequent query instructions.
[0054] In some possible implementations, detecting the dwell time of the query instruction to obtain the instruction dwell time includes: Obtaining the instruction arrival time corresponding to the query instruction from the instruction cache queue; Execute a timed task, wherein the timed task is used to calculate the difference between the current time and the instruction arrival time corresponding to the query instruction to obtain the current instruction residence time when the preset timed time arrives; 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, 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, it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the step of executing the scheduled task is returned.
[0055] In some possible implementations, the set time corresponding to the scheduled task can be set at multiple granularities. For example, when the query instruction just reaches the storage system, the time it can stay is relatively long. Assuming that the preset instruction timeout of the client service is 20 seconds, the time of the scheduled task can be set relatively long in the first ten seconds after the query instruction arrives, such as executing it once every 400 milliseconds. After more than ten seconds, the time of the scheduled task can be set relatively short, such as executing it once every 100 milliseconds. This can ensure the accuracy of time detection to a certain extent while minimizing the number of executions of the scheduled task and avoiding wasting computing resources. Similarly, the timing time of the scheduled task can also be limited by reference to the number of retransmissions. For example, in the first retransmission cycle, the scheduled task can be executed with a period of 200 milliseconds, and in the second retransmission cycle, the scheduled task can be executed with a period of 100 milliseconds. This setting method can take into account both the accuracy of time detection and the number of task executions, and further improve the flexibility of query instruction processing.
[0056] In some possible implementations, the preset number of times is determined according to the following steps: Get the historical startup time of the storage system; Determine whether the historical startup time exceeds twice the preset instruction timeout period; When the historical startup time does not exceed twice the preset instruction timeout period, the preset number of times is set to one; When the historical startup time exceeds twice the preset instruction timeout period, the preset number of times is set to twice.
[0057] The query instruction processing method of this embodiment collects the historical startup time of the storage system, and sets the number of instruction retransmissions based on the historical startup time, so that the time the scheduled task can stay is closer to the actual startup time of the storage system. It can adapt to the performance of each storage system and make the setting of the number of retransmissions more reasonable and accurate.
[0058] In some possible implementations, obtaining the historical startup time consumption of the storage system includes: Read log data from the storage system; Based on preset keywords, query the log data for multiple startup times closest to the current time; The historical startup time is obtained by calculating an average or median of multiple recent startup time consumptions, or by calculating a median of multiple recent startup time consumptions.
[0059] The query instruction processing method of this embodiment uses the log data of the storage system itself to obtain multiple recent historical startup times, 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 setting the number of retransmissions.
[0060] In some possible implementations, the preset timing time corresponding to the scheduled 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.
[0061] The query instruction processing method of this embodiment further limits the timing time and maximum waiting time of the scheduled task, so that the storage system can extend the waiting time of the query instruction to the greatest extent, provide sufficient time for the storage system to respond to the query task, and significantly improve the possibility of smooth execution of subsequent processes of the block device scanning discovery process.
[0062] In another embodiment, in order to facilitate understanding of the solution of the present invention, the following Figure 5Taking the application scenario shown as an example, it is assumed that server A is installed with an operating system of a version later than centos7.9 / redhat7.9, and server B is installed with an operating system of a version earlier than centos7.9 / redhat7.9. In this scenario, the mapping relationship between the logical unit and the host is as follows: There are 6 logical units on the storage system, among which logical unit 0, logical unit 1, and logical unit 2 are mapped with server A. Then, server A can only scan logical unit 0, logical unit 1, and logical unit 2 on the storage system, and generate corresponding block devices on server A (such as / dev / sdaa, / dev / sdab, and / dev / sdac); logical unit 3, logical unit 4, and logical unit 5 are mapped with server B. Then, server B can only scan logical unit 3, logical unit 4, and logical unit 5 on the storage system, and generate corresponding block devices on server B (such as / dev / sdba, / dev / sdbb, and / dev / sdbc). This embodiment applies the above-mentioned query instruction processing method to optimize the block device discovery process, and its implementation principle is as follows: by responding to the server with a "power-on reset" status code (status code in the SCSI standard) before the query instruction times out, the SCSI kernel engine is triggered to resend the query instruction to query the manufacturer information and product information of the storage system, so that the server can rescan the logical unit on the storage system and generate a block device, and restore access to the logical unit on the storage system. Among them, the SCSI kernel engine module has special processing for the status code returned by the storage system. If the storage system returns a power-on reset status code, the SCSI kernel engine will resend the query instruction to query the manufacturer information and product information of the storage system. There are only two such retry opportunities. If both retries fail, the SCSI kernel engine module will give up the query.
[0063] Please refer to Figure 6 As shown in the figure, after optimization, the block device scanning and discovery processes of servers A and B can be executed according to the following set standards: if the query of the manufacturer information and product information of the storage system fails, and the number of responses to the query command is less than 2 times, a power-on reset status code will be returned to the server before the query command times out (after receiving the power-on reset status code, the server will resend the query command to obtain the manufacturer information and product information of the storage system. For the response processing flow, see the power-on reset response flow); if the number of responses to the query command has reached 2 times, the response flow will be directly exited (the maximum number of server attempts is 2 times); if the query of the manufacturer information 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); according to the queried list of logical units, read the capacity of the logical units, UUID and other information one by one; after reading all relevant information, the corresponding block device will be generated in the file system.
[0064] Specifically, please refer to Figure 7 The power-on reset response process is as follows: There are multiple threads in the storage system that process data (read data / write data) at the same time, and each thread is bound to a CPU core (CPU affinity, which is a common operation and will not be described here). For data processing efficiency considerations, we set up an instruction buffer on each thread to store the query instructions on the thread (one queue buffer corresponds to one thread, which can serialize data processing, avoid acquiring locks and waiting for locks in data processing, and improve data processing efficiency).
[0065] struct command_s {
[0066] struct command_s * next; / / Current data structure pointer
[0067] uint64 timestamp; / / instruction arrival timestamp
[0068] char cdb
[64] ; / / Store instruction information
[0069] The other members of the instruction data structure are not related to this invention and will not be described here.
[0070] }
[0071] The above is the "instruction data structure" that needs to be temporarily stored in the instruction buffer. Next is the first address of the current data structure, which is used to add to the instruction buffer to form a linked list; timestamp is used to record the time when the instruction arrives. The timer task scans this time as a reference, and the current time is subtracted from it to calculate the instruction timeout time; 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 repeated here).
[0072] The instruction buffer is a single linked list data structure, as shown in the following data structure definition. The s_slist data structure is a typical single linked list data structure definition. The addition and removal operations of single linked list members are relatively common operations, which are not the focus of the present invention and will not be described here.
[0073] struct s_slist_node {
[0074] struct s_slst_node *next; } / / Single linked list node definition
[0075] struct s_slist {
[0076] struct s_slist_node *head; / / instruction buffer head pointer
[0077] struct s_slist_node *tail; / / instruction buffer tail pointer
[0078] uint32 count; / / Command buffer length (number of members in the list)
[0079] }
[0080] Please refer to Figure 8 As shown in the figure, the storage system cannot process the query command sent by the server during the startup phase. The storage system receives the query command sent by the server and temporarily stores the query command in the command buffer. A timer task will continuously scan the command buffer at a period of 100 milliseconds. When it finds a query command that is about to time out (the default timeout for the query command is 20 seconds), it will remove the command that is about to time out from the buffer (single linked list member removal operation), fill in the power-on reset status code and send it to the server, triggering the server to resend the query command (if the power-on reset status code is not sent to the server, the server will think that the query command has timed out and will initiate subsequent query operations, resulting in the failure of the block device scan).
[0081] Since the timer cycle is 100 milliseconds, the instruction buffer scanning error is also 100 milliseconds. The query instruction timeout threshold needs to be defined as 19700 milliseconds. When the timeout is greater than 19700 milliseconds, the query instruction is considered to have timed out. This is relatively easy to understand. Since the timer polling cycle is 100 milliseconds (that is, it is executed every 100 milliseconds), the next query will be 100 milliseconds after 19700 milliseconds, and this time will fall between 19800 and 20000 milliseconds (because the timer also has a certain error). The reason why the timer execution cycle is chosen as 100 milliseconds is mainly because the timeout time should be as close to 20000 milliseconds as possible to ensure that the timeout time is relatively accurate, but it does not need to be very precise. 100 milliseconds is an empirical value (it is executed once every 100 milliseconds, which does not affect the execution of other tasks on the thread).
[0082] Please refer to Fig. 9 As shown, Fig. 9The query instruction timeout time and the storage system node startup time are compared and described. The storage system startup time is about 30 to 50 seconds, while the server query instruction timeout time is 20 seconds (for centos7.9 / redhat7.9 and earlier versions, the SCSI kernel engine will abandon subsequent operations after a query timeout, which will cause the block device on the server to fail to generate). The present invention will trigger the server to retry the query instruction, extend the timeout time from the original 20 seconds to 60 seconds, cover the storage system startup time, and solve this problem well.
[0083] The query instruction processing device provided by the present invention is described below. The query instruction processing device described below and the query instruction processing method described above can be referred to each other.
[0084] Please refer to Fig.10 As shown, this embodiment provides a query instruction processing device, wherein the query instruction is an instruction for obtaining storage system information in a block device scanning discovery process, and the device is used for a storage system. Specifically, the device includes: an instruction cache module 1010, a time detection module 1020, and an instruction resending module 1030. The above modules are described in detail below: The instruction cache module 1010 is used to store the received unexecutable instructions in the cache; The time detection module 1020 is used to detect the residence time of the query instruction to obtain the instruction residence time when detecting that there is a query instruction sent by the SCSI kernel engine of the server in the cache; The instruction resending module 1030 is used to take out the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine to enable the SCSI kernel engine to resend the query instruction when the instruction residence time is close to but has not reached a preset instruction timeout time.
[0085] The query instruction processing device of the present embodiment improves the storage system's processing method for query instructions by storing the unexecutable instructions received by the storage system in a cache, and detecting the residence time of the instruction when detecting that the query instruction is stored in the cache. When it is detected that the residence time of the instruction is close to the preset instruction timeout time, the query instruction is taken out of the cache, and the instruction is resent by returning a power-on status reset code to the SCSI kernel engine of the server, thereby lengthening the time for the server and other storage systems to respond to the query instruction, and ignoring the influence of the system adopted by the client server and the block scanning process parameters. It is applicable to various types of server systems, has good versatility, can effectively ensure the smooth execution of the client block scanning process, significantly improve the automatic recovery capability and stability of the storage system after power failure, and help reduce operation and maintenance costs.
[0086] In some possible implementations, the apparatus further includes a retransmission determination module, and the retransmission determination module is configured to: Determining whether the number of retransmissions of the query instruction exceeds a preset number; If the number of retransmissions does not exceed the preset number, the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine to enable the SCSI kernel engine to resend the query instruction is allowed to be executed; If the number of retransmissions exceeds the preset number, the steps of taking the query instruction out of the cache, returning a power-on reset status code to the SCSI core engine so that the SCSI core engine resends the query instruction, and clearing the number of retransmissions are prohibited.
[0087] In some possible implementations, the storage system includes multiple processing cores, and the instruction cache module 1010 is further configured to: Determine whether each instruction received can be executed by the processing core; When it is confirmed that a certain instruction cannot be executed, writing the certain instruction into the cache; For each processing core, the first address, instruction arrival time, and instruction information of each instruction are recorded based on a single linked list data structure to obtain an instruction cache queue corresponding to each processing core.
[0088] In some possible implementations, the time detection module 1020 is further configured to: Obtaining the instruction arrival time corresponding to the query instruction from the instruction cache queue; Execute a timed task, wherein the timed task is used to calculate the difference between the current time and the instruction arrival time corresponding to the query instruction to obtain the current instruction residence time when the preset timed time arrives; 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, 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, it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the step of executing the scheduled task is returned.
[0089] In some possible implementations, the preset number of times is determined according to the following steps: Get the historical startup time of the storage system; Determine whether the historical startup time exceeds twice the preset instruction timeout period; When the historical startup time does not exceed twice the preset instruction timeout period, the preset number of times is set to one; When the historical startup time exceeds twice the preset instruction timeout period, the preset number of times is set to twice.
[0090] In some possible implementations, obtaining the historical startup time consumption of the storage system includes: Read log data from the storage system; Based on preset keywords, query the log data for multiple startup times closest to the current time; The historical startup time is obtained by calculating an average or median of multiple recent startup time consumptions, or by calculating a median of multiple recent startup time consumptions.
[0091] In some possible implementations, the preset timing time corresponding to the scheduled 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.
[0092] It should be noted that each module in the query instruction processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in a memory in an electronic device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0093] Fig.11 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.11As shown, the electronic device may include: a processor 1110, a communication interface 1120, a memory 1130 and a communication bus 1140, wherein the processor 1110, the communication interface 1120 and the memory 1130 communicate with each other through the communication bus 1140. The processor 1110 may call the logic instructions in the memory 1130 to execute the query instruction processing method, wherein the query instruction is an instruction for obtaining storage system information in the block device scanning discovery process, and the method is used for the storage system, and the method includes: storing the received unexecutable instruction in the cache; when it is detected that there is a query instruction sent by the SCSI kernel engine of the server in the cache, detecting the residence time of the query instruction to obtain the instruction residence time; when the instruction residence time is close to and does not reach the preset instruction timeout time, taking the query instruction out of the cache, and returning a power-on reset status code to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction.
[0094] In addition, the logic instructions in the above-mentioned memory 1130 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, 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, and the computer software product is stored in a storage medium, including a number of 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 method 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. Various media that can store program codes.
[0095] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program 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-mentioned 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 for a storage system, and the method includes: storing the received unexecutable instructions in a cache; when it is detected 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 the instruction residence time; when the instruction residence time is close to and has not reached a preset instruction timeout time, taking the query instruction out of the cache, and returning a power-on reset status code to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction.
[0096] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the query instruction processing method provided by the above-mentioned methods. The query instruction is an instruction for obtaining storage system information in a block device scanning and discovery process. The method is used for a storage system, and the method includes: storing the received unexecutable instructions in a cache; when it is detected 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 the instruction residence time; when the instruction residence time is close to and has not reached a preset instruction timeout time, taking the query instruction out of the cache, and returning a power-on reset status code to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction.
[0097] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions 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 an instruction for obtaining storage system information in a block device scanning and discovery process. The method is used for a storage system, and the method includes: Storing received unexecutable instructions in a cache; In the case where it is detected that there is a query instruction sent by the SCSI kernel engine of the server in the cache, the residence time of the query instruction is detected to obtain the instruction residence time; When the instruction residence time approaches but does not reach the preset instruction timeout time, the query instruction is taken out 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.
2. The query instruction processing method according to claim 1, characterized in that: Before the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine so that the SCSI kernel engine resends the query instruction, the method further comprises: Determining whether the number of retransmissions of the query instruction exceeds a preset number; If the number of retransmissions does not exceed the preset number, the step of taking the query instruction out of the cache and returning a power-on reset status code to the SCSI kernel engine to enable the SCSI kernel engine to resend the query instruction is allowed to be executed; If the number of retransmissions exceeds the preset number, the steps of taking the query instruction out of the cache, returning a power-on reset status code to the SCSI core engine so that the SCSI core engine resends the query instruction, and clearing the number of retransmissions are prohibited.
3. The query instruction processing method according to claim 1, characterized in that: The storage system includes a plurality of processing cores, and storing the received unexecutable instructions into a cache includes: Determine whether each instruction received can be executed by the processing core; When it is confirmed that a certain instruction cannot be executed, writing the certain instruction into the cache; For each processing core, the first address, instruction arrival time, and instruction information of each instruction are recorded based on a single linked list data structure to obtain an instruction cache queue corresponding to each processing core.
4. The query instruction processing method according to claim 3, characterized in that: The step of detecting the dwell time of the query instruction to obtain the instruction dwell time includes: Obtaining the instruction arrival time corresponding to the query instruction from the instruction cache queue; Execute a timed task, wherein the timed task is used to calculate the difference between the current time and the instruction arrival time corresponding to the query instruction to obtain the current instruction residence time when the preset timed time arrives; 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, 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, it is confirmed that the instruction dwell time is not close to and has not reached the preset instruction timeout time, and the step of executing the scheduled task is returned.
5. The query instruction processing method according to claim 2, characterized in that: The preset number of times is determined according to the following steps: Get the historical startup time of the storage system; Determine whether the historical startup time exceeds twice the preset instruction timeout period; When the historical startup time does not exceed twice the preset instruction timeout period, the preset number of times is set to one; When the historical startup time exceeds twice the preset instruction timeout period, the preset number of times is set to twice.
6. The query instruction processing method according to claim 5, characterized in that: The obtaining of the historical startup time consumption of the storage system includes: Read log data from the storage system; Based on preset keywords, query the log data for multiple startup times closest to the current time; The historical startup time is obtained by calculating an average or median of multiple recent startup time consumptions, or by calculating a median of multiple recent startup time consumptions.
7. The query instruction processing method according to claim 4, characterized in that: The preset timing time corresponding to the scheduled 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.
8. A query instruction processing device, characterized in that: The query instruction is an instruction for obtaining storage system information in a block device scanning and discovery process. The device is used for a storage system, and the device includes: An instruction cache module, used for storing received unexecutable instructions in a cache; A time detection module is used to detect the residence time of the query instruction to obtain the instruction residence time when detecting that there is a query instruction sent by the SCSI kernel engine of the server in the cache; The instruction resending module is used to take out the query instruction from the cache and return a power-on reset status code to the SCSI kernel engine to make the SCSI kernel engine resend the query instruction when the instruction residence time is close to and has not reached a preset instruction timeout time.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the query instruction processing method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the query instruction processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Block device generation method, storage system and server
CN120929023A
