Hard disk registration method and device, storage equipment and storage medium

By storing the information of registered hard disks in the controller and directly registering the hard disk based on identification search, the problem of long hard disk registration time is solved, and more efficient registration and failover is achieved.

CN119442342APending Publication Date: 2025-02-14CHENGDU HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310967565.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-02
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, when the controller registers multiple hard disks, the time required for the hard disk to respond to commands and return hard disk information is long, resulting in a longer registration time for the hard disk, which affects the failover speed and service interruption time.

Method used

By storing the hard disk information of the registered hard disk in a plurality of controllers in the first controller, searching the hard disk information based on the identification of the target hard disk, and directly registering it to avoid repeated acquisition of the hard disk information. If the hard disk information is not found, the hard disk information is obtained by sending the hard disk information acquisition command and synchronizing it to other controllers.

Benefits of technology

It shortens the registration time of hard disk, improves registration efficiency, reduces the failover time and service interruption time, and makes the hard disk access delay more stable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119442342A_ABST
    Figure CN119442342A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a hard disk registration method and device, storage equipment and a storage medium, and belongs to the field of data storage. In the application, a first controller in a plurality of controllers included in the storage device stores hard disk information of registered hard disks in the plurality of controllers. On the basis, the first controller can search the hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk to be registered, and if the hard disk information of the target hard disk is searched in the first controller, the first controller can directly register the target hard disk based on the searched hard disk information of the target hard disk. Therefore, when the first controller takes over the hard disk accessed by other controllers, the hard disk information of the hard disk is stored in the first controller because the hard disk completes registration in other controllers, so that the first controller does not need to issue a hard disk information acquisition command to the hard disk to acquire the hard disk information; and the registration duration of the hard disk is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage technology, and in particular to a hard disk registration method, apparatus, storage device and storage medium. Background Art

[0002] At present, a storage device may include multiple controllers, each of which may be connected to multiple hard disks, wherein the multiple hard disks connected to the controller refer to the hard disks registered in the controller. In addition, at least one virtual node may run on each controller. Each virtual node may correspond to multiple hard disks in the hard disk connected to the controller where it is located, so that each virtual node may manage and use the corresponding multiple hard disks to complete data services. Taking the first controller and the second controller among multiple controllers as an example, when the first virtual node on the second controller fails, the first controller may take over the multiple hard disks corresponding to the first virtual node. In this case, the multiple hard disks corresponding to the first virtual node may be registered on the first controller.

[0003] In the related art, after scanning multiple hard disks corresponding to the first virtual node, the first controller can sequentially obtain the hard disk information of each hard disk in a serial manner. Afterwards, the first controller can complete the registration of each hard disk based on the hard disk information of each hard disk. Among them, when obtaining the hard disk information of a certain hard disk, the first controller can send multiple commands to the hard disk to obtain different types of information. Since the hard disk takes a long time to respond to the command and return the hard disk information, the registration time of multiple hard disks is long. Summary of the invention

[0004] The present application provides a hard disk registration method, apparatus, storage device and storage medium, which can improve the hard disk registration speed when a controller takes over the hard disk of another controller.

[0005] In order to achieve the above objectives, this application adopts the following technical solutions:

[0006] In a first aspect, a hard disk registration method is provided, which is applied to a first controller among multiple controllers included in a storage device, and the method includes: obtaining an identifier of a target hard disk to be registered; searching for hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk, wherein the first controller stores hard disk information of hard disks registered in the multiple controllers; if the hard disk information of the target hard disk is found in the first controller, registering the target hard disk based on the found hard disk information of the target hard disk.

[0007] In the present application, the first controller among the multiple controllers included in the storage device stores the hard disk information of the hard disks registered in the multiple controllers. On this basis, the first controller can search for the hard disk information of the target hard disk in itself based on the identifier of the target hard disk to be registered. If the hard disk information of the target hard disk is found in the first controller, the first controller can directly register the target hard disk based on the hard disk information of the found target hard disk. Based on this, when the target hard disk is a hard disk connected to other controllers among the multiple controllers, since the target hard disk has been registered in other controllers, the hard disk information of the target hard disk will be stored in the first controller. In this way, the first controller no longer needs to send a hard disk information acquisition command to the target hard disk to obtain the hard disk information. In this way, the registration time of the target hard disk can be shortened, thereby improving the registration efficiency.

[0008] Optionally, the first controller includes a memory, and the method further includes: if the hard disk information of the target hard disk is not found in the first controller, sending a hard disk information acquisition command to the target hard disk; receiving the hard disk information of the target hard disk returned by the target hard disk in response to the hard disk information acquisition command; storing the hard disk information of the target hard disk in the memory, and synchronizing the hard disk information of the target hard disk to other controllers among the multiple controllers except the first controller; and registering the target hard disk based on the received hard disk information of the target hard disk.

[0009] In the present application, if the first controller does not find the hard disk information of the target hard disk in its own memory, it means that the target hard disk is connected to the multiple controllers for the first time. In this case, the first controller can obtain the hard disk information by sending a hard disk information acquisition command to the target hard disk. After obtaining the hard disk information of the target hard disk, the first controller can store the hard disk information of the target hard disk in its own memory, and synchronize the hard disk information of the target hard disk to other controllers in the multiple controllers. In this way, when any of the subsequent other controllers takes over the hard disk connected to the first controller, it can find the hard disk information of the hard disk connected to the first controller from its own stored hard disk information, without having to obtain the hard disk information by sending a hard disk information acquisition command to the hard disk. In this way, the registration time can be shortened and the registration efficiency can be improved.

[0010] Optionally, the identifier of the target hard disk includes a slot identifier and a device address of the target hard disk, and the implementation process of searching for the hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk may include: searching for the first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk in the first controller; if the first hard disk information is found, and the device address contained in the first hard disk information is the same as the device address of the target hard disk, then the first hard disk information is determined as the hard disk information of the target hard disk found.

[0011] In the present application, the hard disk information corresponding to the slot identifier of the found target hard disk is verified by the device address of the target hard disk, so that the accuracy of the hard disk information of the found target hard disk can be improved.

[0012] Optionally, obtaining the identification of the target hard disk to be registered includes: in the event that a failure of the second controller is detected, scanning multiple hard disks connected to the second controller to obtain the identifications of the multiple hard disks, the multiple hard disks including the target hard disk, and the second controller being any one of the multiple controllers; or, in the event of a failure of a virtual node in the second controller, scanning multiple hard disks corresponding to the failed virtual node to obtain the identifications of the multiple hard disks, the multiple hard disks including the target hard disk.

[0013] In the present application, the first controller can store hard disk information of the hard disk registered in the second controller. In this case, when the second controller fails or the virtual node on the second controller fails, the first controller can take over the hard disk connected to the second controller. Since the first controller stores the hard disk information of the hard disk connected to the second controller, the first controller can register the hard disk to be taken over by reading the hard disk information stored in its own memory. There is no need to send commands to the hard disk to be taken over to obtain the hard disk information, which shortens the time to obtain the hard disk information, thereby shortening the registration time, improving the fault switching speed, and thereby shortening the business interruption time caused by fault switching.

[0014] Optionally, the first controller includes a memory, and the method further includes: receiving hard disk information of registered hard disks sent by other controllers among the multiple controllers except the first controller; and storing the hard disk information of registered hard disks sent by the other controllers in the memory.

[0015] Among them, other controllers among the multiple controllers can synchronize the hard disk information of the registered hard disk to the first controller after completing the registration of the hard disk to be connected. In this way, when the first controller takes over the hard disk connected to any of the other controllers, it can directly read the hard disk information from its own memory to complete the hard disk registration. There is no need to send a hard disk information acquisition command to the hard disk to obtain the hard disk information, which shortens the registration time of the hard disk and improves the registration efficiency.

[0016] Optionally, the method further includes: if a removal command for the target hard disk is detected, deleting hard disk information of the target hard disk stored in the first controller.

[0017] In a second aspect, a hard disk registration device is provided, the hard disk registration device comprising at least one module, and the at least one module is used to execute the hard disk registration method described in the first aspect.

[0018] In a third aspect, a storage device is provided, the storage device comprising multiple controllers, the multiple controllers comprising a first controller, the first controller comprising a processor and a memory, the processor being used to execute at least one program instruction or code stored in the memory to implement the hard disk registration method described in the first aspect above.

[0019] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer device, the computer device executes the hard disk registration method described in the first aspect.

[0020] In a fifth aspect, a computer program product comprising instructions is provided. When the computer program product is run on a computer, the computer executes the hard disk registration method described in the first aspect.

[0021] The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here.

[0022] In an embodiment of the present application, the first controller among the multiple controllers included in the storage device stores the hard disk information of the hard disks registered in the multiple controllers. On this basis, the first controller can search for the hard disk information of the target hard disk in itself based on the identifier of the target hard disk to be registered. If the hard disk information of the target hard disk is found in the first controller, the first controller can directly register the target hard disk based on the hard disk information of the found target hard disk. Based on this, when the target hard disk is a hard disk connected to other controllers among the multiple controllers, since the target hard disk has been registered in other controllers, the hard disk information of the target hard disk will be stored in the first controller. In this way, the first controller no longer needs to send a hard disk information acquisition command to the target hard disk to obtain the hard disk information. In this way, the registration time of the target hard disk can be shortened, thereby improving the registration efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of the structure of a storage device provided in an embodiment of the present application;

[0024] Figure 2 A flowchart of obtaining hard disk information when a controller registers a hard disk in a kernel provided in the related art;

[0025] Figure 3 It is a function call flow chart of the controller in the related art when registering the hard disk through the SCSI system;

[0026] Figure 4 A flowchart of a hard disk registration method provided in an embodiment of the present application;

[0027] Figure 5 A function call flow chart for hard disk registration via a SCSI system provided in an embodiment of the present application;

[0028] Figure 6 A schematic diagram of an interface for reading and writing hard disk information in a memory of a controller provided in an embodiment of the present application;

[0029] Figure 7 A schematic diagram of a controller obtaining hard disk information during a hard disk registration process provided in an embodiment of the present application;

[0030] Figure 8 A structural diagram of a hard disk registration device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0032] Before explaining the embodiments of the present application in detail, the application scenarios involved in the embodiments of the present application are first introduced.

[0033] At present, in order to improve the reliability and business processing capability of the storage system, multiple controllers can be configured in the storage device. Among them, at least one virtual node can be run on each controller, and each virtual node is used to process at least one business. On this basis, each virtual node can be connected to an expansion board (expander), so that the virtual node can manage and use multiple hard disks on the corresponding expansion board to complete its own business. The hard disks on the expansion board corresponding to each virtual node are all hard disks registered in the kernel of the controller where the virtual node is located. Based on this, when a controller among multiple controllers fails, such as when the controller has a device failure or the controller cannot communicate with other devices, other controllers among the multiple controllers can take over the business of the virtual node on the failed controller and take over the hard disk of the failed controller to achieve fault switching. Alternatively, when a virtual node on a controller fails, for example, when a virtual node crashes abnormally, other controllers can also take over the business of the virtual node and the hard disk on the expansion board connected to the virtual node to achieve fault switching. When a controller takes over the hard disk of a failed controller or virtual node, the controller must register the hard disk to be taken over in its own kernel so that these hard disks can be managed and used later. The hard disk registration method provided in the embodiment of the present application can be applied to the fault switching scenario introduced above to shorten the time for the controller to register the hard disk in the kernel and realize fast registration of the hard disk, thereby shortening the fault switching time and further shortening the service interruption time caused by the fault switching.

[0034] The above is a possible application scenario of a hard disk registration method provided by an embodiment of the present application, and does not limit the application scenario of the hard disk registration method provided by the embodiment of the present application. For the case where one controller takes over a hard disk connected to another controller in other scenarios, the hard disk registration method provided by the embodiment of the present application can also be used to complete the registration of the taken-over hard disk. For example, when a controller is overloaded, another controller can take over part of the business and corresponding hard disk of the controller. In this case, the hard disk registration method of the embodiment of the present application can also be used to register the hard disk to be taken over.

[0035] Next, the structure of the storage device involved in the hard disk registration method provided in the embodiment of the present application is introduced.

[0036] Figure 1 Schematic diagram of a storage device provided in an embodiment of the present application. Figure 1 As shown, the storage device 10 includes a plurality of controllers 11 ( Figure 1Two controllers 11) and multiple expansion boards 12 ( Figure 1 Two expansion boards 12 are shown in the figure. The controllers can communicate with each other. In addition, each controller can be connected to at least one expansion board, and each expansion board can include multiple hard disks 121. The expansion boards can be connected by cables, for example, by serial attached SCSI (small computer system interface), SAS cables.

[0037] At the hardware level, see Figure 1 , the controller 11 may include a processor 111 and a memory 112 .

[0038] Among them, the processor 111 is a central processing unit (CPU), which is used to process data access requests from outside the storage device 10, and is also used to process requests generated inside the storage device 10. Exemplarily, when the processor 111 receives write data requests, it temporarily stores the data in these write data requests in the memory 112. When the total amount of data in the memory 112 reaches a certain threshold, the processor 111 sends the data stored in the memory 112 to the hard disk 121 on the expansion board 12 for persistent storage. In addition, the processor 111 is also used to calculate or process data, such as metadata management, deduplication, data compression, data verification, virtualized storage space, and address conversion. Figure 1 Only one processor 111 is shown in the figure. In practical applications, there may be multiple processors 111, wherein one processor 111 has one or more CPU cores. The embodiment of the present application does not limit the number of processors and the number of CPU cores.

[0039] The memory 112 refers to an internal memory that directly exchanges data with the processor. It can read and write data at any time and at a very fast speed. It serves as a temporary data storage for the operating system or other running programs. The memory 112 includes at least two types of memories. For example, the memory can be either a random access memory or a read-only memory (ROM). For example, the random access memory is a dynamic random access memory (DRAM) or a storage class memory (SCM). DRAM is a semiconductor memory, and like most random access memories (RAM), it is a volatile memory device. SCM is a composite storage technology that combines the characteristics of traditional storage devices and memory. Storage class memory can provide faster read and write speeds than hard disks, but is slower than DRAM in access speed and cheaper than DRAM in cost. However, DRAM and SCM are only exemplary descriptions in this embodiment, and the memory can also include other random access memories, such as static random access memory (SRAM). As for the read-only memory, for example, it can be a programmable read only memory (PROM), an erasable programmable read only memory (EPROM), etc. In addition, the memory 112 can also be a dual in-line memory module or a dual-line memory module (DIMM), that is, a module composed of DRAM, or a solid state disk (SSD). In practical applications, multiple memories 112 and different types of memories 112 can be configured in the controller 11. This embodiment does not limit the number and type of memory 112. In addition, the memory 112 can be configured to have a power-saving function. The power-saving function means that when the system loses power and then powers on again, the data stored in the memory 112 will not be lost. A memory with a power-saving function is called a non-volatile memory. In an embodiment of the present application, the memory 112 can be used to store hard disk information of hard disks that have been registered in each controller 11 of the storage device 10. In addition, the memory 112 stores a software program, and the processor 111 runs the software program in the memory 112 to implement the hard disk registration method provided in the embodiment of the present application.

[0040] Optionally, the controller 11 may further include a network card 113, which may be connected to the processor 111 and the memory 112. The network card 113 may be used to communicate with other storage devices, other controllers in the storage device where the network card 113 is located, and the expansion board 12.

[0041] At the software level, at least one virtual node 114 ( Figure 1 A virtual node 114 is deployed in it). Wherein, a virtual node 114 can refer to an independent business processing unit for processing at least one data business. Each virtual node 114 can have an independent running thread and memory space, and in addition, can also have an independent persistent storage path. For example, each virtual node 114 can be connected to a hard disk 121 on at least one expansion board 12 connected to the controller 11 in which it is located, so that the virtual node 114 can use the connected hard disk 121, for example, to store data persistently in the connected hard disk 121, or to read data from the connected hard disk 121. It should be noted that in an embodiment of the present application, different virtual nodes can be connected to different expansion boards to reduce access conflicts. It should be noted that the "connected hard disk" mentioned in the embodiment of the present application refers to a hard disk that has established a connection with the corresponding controller and has been registered in the kernel of the controller.

[0042] The expansion board 12 includes multiple hard disks 121 and a control unit 122. The control unit 122 can be used to manage the multiple hard disks 121. The control unit 122 can have various forms. In one case, Figure 1 As shown, the control unit 122 includes a CPU and a memory. The CPU can be used to perform operations such as address conversion and reading and writing data. The memory can be used to temporarily store data to be written to the hard disk 121, or read from the hard disk 121 to be sent to the controller. In another case, the control unit 122 is a programmable electronic component, such as a data processing unit (DPU). The DPU has the versatility and programmability of the CPU, but is more specialized and can run efficiently on network data packets, storage requests or analysis requests. The DPU is distinguished from the CPU by a greater degree of parallelism (a large number of requests need to be processed). Optionally, the DPU here can also be replaced by a processing chip such as a graphics processing unit (GPU), an embedded neural network processor (NPU), etc. In general, the number of control units 122 can be one, or two or more.

[0043] In another embodiment, the functions of the control unit 122 can be offloaded to the network card. In other words, in this embodiment, the expansion board 12 does not have a control unit 122 inside, but the network card completes hard disk management, data reading and writing, address conversion and other computing functions. At this time, the network card is an intelligent network card. It can include a CPU and memory. In some application scenarios, the network card may also have a persistent memory medium, such as persistent memory (PM), or non-volatile random access memory (NVRAM), or phase change memory (PCM), etc. There is no ownership relationship between the network card and the hard disk 121 in the expansion board 12. The network card can access any hard disk 121 in the expansion board 12, so it is more convenient to expand the hard disk when the storage space is insufficient.

[0044] The hard disk 121 is used to provide storage resources. Among them, there can be multiple slots on the expansion board 12, and the hard disk 121 can be plugged into the slots of the expansion board 12. The hard disk 121 can be a disk or other types of storage media, such as a solid-state hard disk. According to the type of communication protocol between the controller 11 and the expansion board 12, the type of hard disk on the expansion board 12 is also different. For example, in an embodiment of the present application, the expansion board 12 can communicate with the controller 11 using the SCSI protocol or the SAS protocol. At this time, the hard disk 121 on the expansion board 12 can be a SAS hard disk or a serial advanced technology attachment (SATA) hard disk, wherein a SATA hard disk can also be called a serial port hard disk.

[0045] It should be noted that the above is a possible implementation of the storage device provided in the embodiment of the present application. In other possible implementations, the above expansion board can also be replaced with a hard disk frame, each controller is connected to at least one hard disk frame, and each hard disk frame can be deployed with multiple hard disks.

[0046] For the storage device introduced in the above embodiment, when any controller in the storage device fails or a virtual node running on any controller fails, other controllers can take over the hard disk connected to the failed controller or virtual node. When taking over the hard disk, the controller can register the hard disk in the kernel. Currently, when registering a hard disk in the kernel, the controller can send a hard disk information acquisition command to the hard disk to be taken over. After receiving the hard disk information acquisition command, the hard disk feeds back its own hard disk information to the controller. After receiving the hard disk information fed back by the hard disk, the controller registers the hard disk in its own kernel based on the hard disk information.

[0047] Taking the example of using SCSI protocol for communication between the expansion board and the controller, a SCSI system can be deployed in the Linux kernel of the controller. The SCSI system is a software system, and the controller can register the hard disk through the SCSI system.

[0048] The SCSI system adopts a layered architecture, including the SCSI high layer, SCSI middle layer and SCSI low layer. The SCSI high layer can also be called the block device layer, which contains drivers for various types of SCSI devices, such as disk drives, tape drives, etc. Each driver in the SCSI high layer can identify the SCSI devices scanned and discovered by the SCSI low layer and assign device names to them; in addition, SCSI can also convert the input and output of SCSI devices into SCSI commands and send the SCSI commands to the SCSI low layer for processing.

[0049] The SCSI middle layer contains the public service layer of the SCSI high layer and the SCSI low layer. The SCSI middle layer provides multiple public service functions. The SCSI high layer and the SCSI low layer implement their functions by calling the functions of the SCSI middle layer, and the SCSI middle layer can also call the callback functions registered by the SCSI high layer and the SCSI low layer during execution.

[0050] The SCSI low layer includes various underlying hardware adapter drivers, such as SAS drivers, iSCSI drivers, etc. Therefore, the SCSI low layer can also be called the driver layer.

[0051] Based on the SCSI system introduced above, Figure 2 FIG. 1 shows a flow chart of a controller obtaining hard disk information when registering a hard disk in a kernel in a related art. Figure 2 As shown, taking the storage device including controller A and controller B as an example, when controller B fails, controller A can send a hard disk information acquisition command to the hard disk to be taken over in real time through the SCSI middle layer and SCSI low layer of the kernel to obtain the hard disk information. After obtaining the hard disk information, the SCSI middle layer in controller A registers the hard disk based on the hard disk information.

[0052] based on Figure 2 The hard disk registration process described in Figure 3 FIG. 2 shows a function call flow chart of the controller when registering the hard disk through the SCSI system. Figure 3As shown, after the controller scans the identifier of the hard disk to be taken over, for a certain hard disk, the SCSI low layer can call the sas_rphy_add function in the SCSI middle layer based on the identifier of the hard disk to register the hard disk. Among them, the sas_rphy_add function can call the scsi_scan_target function to scan the hard disk, and the scsi_scan_target function can call the scsi_probe_and_add_lun function to scan each logical unit (logical unit, LU) on the hard disk. It should be noted that since a LU can be identified by a logical unit number (logical unit number, LUN), in the embodiment of the present application, LUN can refer to a logical unit. The scsi_probe_and_add_lun function can call the scsi_probe_lun function to detect each LUN in the hard disk, and the scsi_probe_lun function constructs a hard disk information acquisition command, and executes the hard disk information acquisition command through the scsi_execute function. Among them, the hard disk information acquisition command can include an inquiry command, a logical unit report (report lun) command, a mode sense (modesense) command, etc. When executing the hard disk information acquisition command, the scsi_execute function can call the SCSI high-level blk_get_request function, and through the blk_get_request function, call the SCSI middle-level input output (IO) interface. The SCSI middle-level IO interface calls the SCSI low-level driver IO interface to send the hard disk information acquisition command to the corresponding hard disk.

[0053] After receiving the hard disk information acquisition command, the hard disk can return its own hard disk information to the driver IO interface of the SCSI low layer. After that, the driver IO interface fills the hard disk information back to the SCSI middle layer IO interface, and the SCSI middle layer IO interface fills the hard disk information back to the blk_get_request function. The blk_get_request function feeds back the hard disk information to the SCSI middle layer. In this way, the SCSI middle layer completes the registration of the hard disk based on the hard disk information and returns a response to the SCSI low layer. After that, the SCSI low layer can register the next hard disk based on the identifier of the next hard disk through the above-mentioned process.

[0054] In a possible situation, after receiving the hard disk information acquisition command, if the hard disk responds to the command slowly, for example, the hard disk does not return the hard disk information within the preset time, an IO timeout will be caused. In this case, the SCSI middle-layer IO interface can trigger an error handling process. Among them, the SCSI middle-layer IO interface can first call the IO abort interface, and the SCSI middle-layer IO abort interface calls the driver IO abort interface to perform interface processing. If the hard disk still does not respond after the interface processing, the SCSI middle-layer IO abort interface can call the devicereset interface, and the devicereset interface can call the driver devicereset interface to reset the device. If the hard disk still does not respond after the device is reset, the SCSI middle-layer error handling process will call the hostreset interface, and call the SCSI low-layer driver hostreset interface through the hostreset interface to reset the SAS initiator. If the hard disk still does not respond after the SAS initiator is reset, the hostreset interface returns an IO error to the blk_get_request function. The blk_get_request function feeds back the IO error to the SCSI middle layer, so that the SCSI middle layer fails to register the hard disk and returns a response to the SCSI low layer. After that, the SCSI low layer can register the next hard disk based on the next hard disk identifier through the above-mentioned process. Of course, if the hard disk returns the hard disk information after performing any of the above-mentioned interface processing, device reset or host reset operations, the SCSI middle layer can return the hard disk information to the blk_get_request function.

[0055] It can be seen from the above hard disk registration process that when the controller currently registers hard disks in the kernel, the next hard disk can only be registered after the previous hard disk is successfully registered, that is, the hard disk registration is serial. In the process of serially registering hard disks, for each hard disk, the SCSI middle layer obtains hard disk information by sending a hard disk information acquisition command to the hard disk. Since it takes a certain amount of time for the hard disk to respond to commands and return hard disk information, obtaining hard disk information through hard disk information acquisition commands will result in a longer registration time for multiple hard disks. And, as mentioned above Figure 3As shown in , once a hard disk responds slowly to the hard disk information acquisition command and causes an IO timeout, the error handling process will be triggered, thereby exacerbating the registration delay of other subsequent hard disks, resulting in a further increase in the total hard disk registration time. In this way, in a failover scenario, since the registration time of the hard disk being taken over is longer, the failover time is longer, which in turn leads to a longer service interruption time. In addition, it can be seen from the above analysis that in the related art, the hard disk registration time depends to a large extent on the speed at which the hard disk responds to the hard disk information acquisition command, which will cause the hard disk access delay to be unstable and uncontrollable. Based on this, an embodiment of the present application provides a hard disk registration method that can shorten the registration time of the hard disk and stabilize the hard disk access delay. In this way, in a failover scenario, the failover time can be made more stable, and the failover time can be shortened, thereby shortening the service interruption time and reducing the impact of service interruption.

[0056] Next, the hard disk registration method provided in the embodiment of the present application is introduced with reference to the accompanying drawings.

[0057] Figure 4 : is a flowchart of a hard disk registration method provided by an embodiment of the present application. The method can be applied to any controller among the multiple controllers included in the storage device described above. For the convenience of description, the hard disk registration method is introduced below with the first controller among the multiple controllers as the execution subject. Figure 4 , the method comprises the following steps:

[0058] Step 401: Obtain the identifier of the target hard disk to be registered.

[0059] In the embodiment of the present application, the first controller may obtain the identifier of the hard disk to be connected to itself, wherein the hard disk to be connected is the hard disk to be registered.

[0060] In a possible scenario, when the first controller is connected to an expansion board for the first time or when one or more hard disks are newly connected to an expansion board connected to the first controller, the expansion board may send a disk connection instruction to the first controller. After receiving the disk connection instruction, the first controller may scan the hard disks to be registered on the expansion board, thereby obtaining the identification of the one or more hard disks to be registered.

[0061] Wherein, the first controller can send a disk scan command to the expansion board through the SCSI low layer to scan the hard disk on the expansion board. After receiving the disk scan command, the expansion board can obtain the identification of the hard disk to be registered included in itself, and return the identification of the hard disk to be registered to the SCSI low layer of the first controller. Wherein, the identification of the hard disk may include a slot identification of the hard disk, and the slot identification is used to indicate the slot where the hard disk is located on the expansion board. Optionally, the identification of the hard disk may also include a device address of the hard disk, and the device address may include a SAS address or a MAC address, etc., which is not limited in the embodiment of the present application.

[0062] In another possible scenario, each controller of the storage device may correspond to at least one backup controller. When a controller fails or a virtual node deployed on a controller fails, the backup controller corresponding to the controller may take over the business and hard disk of the controller or the failed virtual node on the controller. Based on this, taking the first controller as the backup controller of the second controller as an example, when the second controller fails or the virtual node on the second controller fails, the first controller can obtain the identifiers of multiple hard disks to be taken over from the hard disks connected to the second controller, wherein the multiple hard disks to be taken over are the multiple hard disks to be registered by the first controller, and the multiple hard disks include the target hard disk.

[0063] In one possible implementation, the first controller can detect whether the second controller is available. If a fault is detected in the second controller, multiple hard disks connected to the second controller are scanned to obtain identifications of the multiple hard disks. At this time, the multiple hard disks are the hard disks to be registered that the first controller is to take over.

[0064] Exemplarily, the first controller can detect whether the second controller is available through a heartbeat detection mechanism. Among them, the first controller can send a heartbeat data packet to the second controller at preset time intervals. If the second controller is not faulty, the second controller can feedback a heartbeat response to the first controller within a first specified time period after receiving the heartbeat data packet. If the second controller fails, the second controller cannot feedback a heartbeat response to the first controller. Based on this, if the first controller does not receive a heartbeat response fed back by the second controller within a second specified time period after sending the heartbeat data packet, the first controller can determine that the second controller is faulty. Among them, the failure of the second controller may be that the second controller has a hardware failure or the second controller is in an abnormal reset state, etc. In addition, the second specified time period is not less than the sum of the first specified time period and the transmission time required for the heartbeat data packet.

[0065] The above is an implementation method for a first controller to detect whether a second controller is available, given in an embodiment of the present application. The first controller may also use other implementation methods to detect whether the second controller is available. For example, in one possible scenario, the storage system includes a storage device and an application server. In this case, the application server can communicate with each controller in the storage device to send service requests to each controller. Based on this, for any controller, the application server can detect whether the controller is available based on a heartbeat detection mechanism. If a failure of the controller is detected, the application server can send a failover instruction to the backup controller of the controller to instruct the backup controller to take over the service and hard disk of the failed controller. Based on this, if the application server detects a failure of the second controller, it can send a failover instruction to the first controller. After receiving the failover instruction, the first controller can determine that the second controller is faulty, thereby taking over the hard disk of the second controller.

[0066] After detecting that the second controller fails, the first controller may scan multiple hard disks connected to the second controller, thereby obtaining the identifications of the multiple hard disks to be registered.

[0067] For example, from the structure of the storage device described above, it can be known that the controller can be connected to an expansion board, and the hard disk is deployed in the expansion board. Based on this, the first controller can send a scan disk instruction to the expansion board connected to the second controller through the expansion board connected to itself, so as to scan multiple hard disks on the expansion board. After receiving the scan disk instruction, the expansion board connected to the second controller can obtain the identification of the multiple hard disks included in itself, and return the identification of the multiple hard disks to the first controller.

[0068] In another possible implementation, if a virtual node on the second controller fails, the first controller can scan multiple hard disks corresponding to the virtual node to obtain the identifications of multiple hard disks. In this case, the multiple hard disks corresponding to the virtual node are the hard disks to be registered by the first controller, and the multiple hard disks include the target hard disk.

[0069] Exemplarily, the second controller can detect whether the virtual nodes deployed in itself are available. If a virtual node deployed in itself is detected to be faulty, the second controller can directly send a takeover instruction to the first controller to instruct the first controller to take over the hard disk of the faulty virtual node. The virtual node failure may refer to an abnormal crash of the virtual node. Accordingly, after receiving the takeover instruction, the first controller can determine that the virtual node in the second controller is faulty, and then scan the multiple hard disks corresponding to the faulty virtual node on the second controller based on the takeover instruction to obtain the identifiers of the multiple hard disks to be registered.

[0070] The disk receiving instruction may include the identifier of the expansion board where the multiple hard disks corresponding to the failed virtual node are located. Based on this, after receiving the disk receiving instruction, the first controller may send a disk scanning instruction to the expansion board based on the identifier of the expansion board corresponding to the failed virtual node to scan the multiple hard disks on the expansion board. The first controller may send a disk scanning instruction to the expansion board corresponding to the failed virtual node through the expansion board connected to itself, or may send a disk scanning instruction to the expansion board corresponding to the failed virtual node through the second controller. Accordingly, after receiving the disk scanning instruction, the expansion board obtains the identifiers of the multiple hard disks it includes, and returns the identifiers of the multiple hard disks to the first controller.

[0071] Optionally, after detecting that a virtual node deployed by the second controller has failed, the second controller can also detect whether there are other available virtual nodes. If there are other available virtual nodes, the other virtual nodes can take over the services and hard disks of the failed virtual node. In this case, since the virtual node responsible for taking over the services and hard disks is deployed on the same controller as the failed virtual node, the hard disk of the failed virtual node has been registered in the controller, so there is no need to register the hard disk. Optionally, if there are no other available virtual nodes in the second controller, the second controller sends a takeover instruction to the first controller. Accordingly, after receiving the takeover instruction, the first controller can scan the multiple hard disks corresponding to the failed virtual node through the method described above to obtain the hard disk identifiers of the multiple hard disks to be registered.

[0072] The above are two possible situations in which the first controller provided in the embodiment of the present application obtains the identification of the hard disk to be registered. In other possible situations, due to business needs, the first controller can take over certain services and hard disks on the second controller. For example, when the load of the second controller is too large, the first controller can also take over part of the services and hard disks of the second controller. In this case, the second controller can send a takeover instruction to the first controller, and the takeover instruction can include the identification of the expansion board where the hard disk to be taken over by the first controller is located. Based on this, after receiving the takeover instruction, the first controller can refer to the relevant implementation method introduced above to send a scan disk instruction to the expansion board to scan at least one hard disk to be registered on the expansion board, so as to obtain the identification of at least one hard disk to be registered.

[0073] Step 402: searching for hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk, wherein the first controller stores hard disk information of hard disks registered in multiple controllers.

[0074] In an embodiment of the present application, the memory of each of the multiple controllers included in the storage device may store hard disk information of hard disks registered in the multiple controllers. The hard disk information of registered hard disks stored in any controller may include hard disk information of hard disks registered in its own kernel and hard disk information of hard disks registered in other controllers, and the hard disk information of hard disks registered in other controllers may be synchronized to the controller after the controller connected to the hard disk successfully registers the hard disk. Based on this, the first controller can receive hard disk information of registered hard disks sent by other controllers among the multiple controllers, and store the hard disk information of the registered hard disk in its own memory.

[0075] Wherein, the first controller can receive and store the hard disk information of the registered hard disk sent by each controller in the storage device except itself. That is, the multiple controllers mentioned in the hard disk information of the registered hard disk in multiple controllers stored in the first controller refer to all controllers in the storage device. Alternatively, the first controller can also receive and store the hard disk information of the registered hard disk sent by the associated controller of the first controller in the storage device. Wherein, the associated controller of the first controller includes the controller that allows the first controller to take over. For example, the associated controller of the first controller can be other controllers with the first controller as the backup controller. In this case, the multiple controllers mentioned in the hard disk information of the registered hard disk in multiple controllers stored in the first controller include the first controller and the associated controller of the first controller.

[0076] Taking the first controller as the backup controller of the second controller as an example, after the second controller completes the registration of multiple hard disks to be connected, the hard disk information of the registered hard disks can be sent to the first controller. Correspondingly, the first controller can receive the hard disk information of the registered hard disk sent by the second controller and store the hard disk information of the registered hard disk in the memory.

[0077] It should be noted that when the first controller stores the hard disk information of the hard disk in the memory, the slot identifier of the hard disk on the expansion board and the hard disk information can be stored correspondingly, so as to obtain a mapping relationship between the slot identifier and the hard disk information. The mapping relationship can be stored in the memory in a specified format, for example, it can be stored in the memory in the form of a file, which is not limited in the embodiment of the present application.

[0078] In addition, in an embodiment of the present application, the hard disk information of each registered hard disk may include multiple information items. The multiple information items may include basic parameters of the hard disk, the total number of LUNs included in the hard disk, the storage capacity of the hard disk, etc. Optionally, each information item may correspond to a command type, and the command type is used to indicate which type of hard disk information acquisition command is sent to the hard disk to obtain the corresponding information item. Among them, the command type may include an inquiry command, a report lun command, a modesense command, etc. For example, the hard disk information of a registered hard disk may include basic parameters of the hard disk such as the device type of the hard disk, and the command type corresponding to the basic parameters of the hard disk is an inquiry command, that is, when the hard disk is connected for the first time, the controller can obtain the basic parameters by sending an inquiry command to the hard disk.

[0079] Based on the above introduction, after the first controller obtains the identifiers of multiple hard disks to be registered, taking the target hard disk among the multiple hard disks to be registered as an example, the first controller can search for the hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk. That is, the first controller can search whether it stores the hard disk information of the target hard disk based on the identifier of the target hard disk. If the first controller finds the hard disk information of the target hard disk in itself, step 403 is executed. Optionally, if the first controller does not find the hard disk information of the target hard disk in itself, steps 404 to 407 can be executed.

[0080] The identification of the target hard disk includes the slot identification of the target hard disk. Based on this, the first controller can search for the first hard disk information whose corresponding slot identification is the slot identification of the target hard disk in itself. If the first hard disk information is found, the first hard disk information can be used as the hard disk information of the found target hard disk. If the first hard disk information is not found, it can be determined that the hard disk information of the target hard disk is not found.

[0081] As can be seen from the above description, the memory of the first controller may store a mapping relationship between the slot identifier and the hard disk information. Based on this, the first controller may search for the first hard disk information corresponding to the slot identifier of the target hard disk from the mapping relationship.

[0082] Exemplarily, the SCSI low layer of the first controller can call the information acquisition function of the SCSI middle layer based on the slot identifier of the target hard disk, and use the information acquisition function to search for the first hard disk information corresponding to the slot identifier of the target hard disk in the mapping relationship between the slot identifier and the hard disk information stored in the memory.

[0083] The information acquisition function may be a hook function. Exemplarily, the function name of the information acquisition function may be get_msg_from_other_node_compare.

[0084] In addition, the input parameter of the information acquisition function may include a device identifier, for example, the device identifier input parameter may be represented by struct scsi_device*sdev. In addition, the output parameter of the information acquisition function may include a query result. For example, the query result output parameter may be represented by unsigned char*inq_result. Optionally, the output parameter of the information acquisition function may also include a memory space required for the query result, wherein the memory space required for the query result is used to indicate the memory space required for storing the found information. For example, the memory space required for the query result output parameter may be represented by int result_len.

[0085] See also Figure 5 After the SCSI low layer of the first controller obtains the identifier of the target hard disk through the aforementioned step 401, it can call the sas_rphy_add function of the SCSI middle layer to register the hard disk. Among them, the sas_rphy_add function can call the scsi_scan_target function to scan the target hard disk. The scsi_scan_target function can call the scsi_probe_and_add_lun function to scan each LUN on the target hard disk. The scsi_probe_and_add_lun function can call the scsi_probe_lun function to detect each LUN in the target hard disk. The scsi_probe_lun function can call the information acquisition function, and use the slot identifier of the target hard disk as the parameter value of the device identifier in the input parameter of the information acquisition function, so as to search the first hard disk information corresponding to the slot identifier of the target hard disk in the memory of the first controller through the information acquisition function. If the first hard disk information is found, the found first hard disk information is used as the parameter value of the query result in the output parameter of the information acquisition function, and the first hard disk information is returned to the scsi_probe_lun function. If the first hard disk information is not found, the failure indication value is used as the parameter value of the query result in the output parameter of the information acquisition function, and the failure indication value is returned to the scsi_probe_lun function. For example, the failure indication value can be null.

[0086] Optionally, if the output parameters of the information acquisition function also include the memory space required for the query results, then after finding the hard disk information to be searched, the information acquisition function can count the data length of the hard disk information found, and determine the required memory space size based on the data length, and output the determined memory space size as the parameter value of the memory space required for the query result.

[0087] Optionally, as can be seen from the above introduction, each information item in the hard disk information of the registered hard disk stored in the controller can correspond to a command type, based on which, the input parameter of the information acquisition function can also include the command type. Among them, the command type refers to the command type corresponding to the information item to be found, that is, the command type can be used to indicate which hard disk information acquisition command is to be found. In this case, when the scsi_probe_lun function calls the information acquisition function, it can also use the command type corresponding to the information item to be obtained as the parameter value of the command type in the input parameter of the information acquisition function to find the information item corresponding to the specified command type. For example, the command type in the input parameter of the information acquisition function can be set to the inquiry command, so that the basic parameters of the target hard disk obtained by the inquiry command can be found through the information acquisition function.

[0088] Optionally, in a possible situation, the slot where the target hard disk is currently located may have been previously inserted with other hard disks, for example, the target hard disk may be used to replace the first hard disk in the slot. In this case, the first hard disk information corresponding to the slot identifier of the target hard disk stored in the first controller may be the hard disk information of the first hard disk that has been replaced. Based on this, when the identifier of the target hard disk also includes the device address of the target hard disk, after the first controller finds the first hard disk information corresponding to the slot identifier of the target hard disk in itself, it can also compare the device address included in the first hard disk information with the device address of the target hard disk, so as to verify whether the first hard disk information is the correct hard disk information of the target hard disk. If the device address included in the first hard disk information is the same as the device address of the target hard disk, it means that the first hard disk information is the hard disk information of the target hard disk. In this case, the first hard disk information can be determined as the hard disk information of the found target hard disk. If the device address included in the first hard disk information is different from the device address of the target hard disk, it means that the first hard disk information is not the hard disk information of the target hard disk. In this case, it can be determined that the hard disk information of the target hard disk has not been found. In this way, by verifying the hard disk information corresponding to the slot identifier of the target hard disk through the device address of the target hard disk, the accuracy of the hard disk information of the target hard disk found can be improved. The device address of the target hard disk is used to uniquely identify the target hard disk. For example, the device address can be a SAS address or a MAC address.

[0089] Exemplarily, the SCSI low layer of the first controller can call the information acquisition function of the SCSI middle layer based on the slot identifier and device address of the target hard disk, and use the information acquisition function to search for the first hard disk information corresponding to the slot identifier of the target hard disk in the mapping relationship between the slot identifier and the hard disk information stored in the memory, and verify whether the device address included in the first hard disk information is the same as the hard disk address of the target hard disk.

[0090] The first controller can refer to the method described above and call the information acquisition function through the scsi_probe_lun function. Different from the method described above, when calling the information acquisition function, the slot identifier and device address of the target hard disk can be used as the parameter value of the device identifier in the input parameter of the information acquisition function, and the information acquisition function is used to search for the first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk and whose device address is the device address of the target hard disk. For other implementation contents of calling the information acquisition function to search for the hard disk information of the target hard disk, please refer to the related introduction described above, which will not be repeated here.

[0091] Optionally, in a possible implementation, the mapping relationship between the slot identifier, the device address and the hard disk information can be stored in the memory of the first controller, that is, the slot identifier and the device address can be used as the index of the hard disk information at the same time. In this case, the first controller can directly search the first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk and whose corresponding device address is the device address of the target hard disk from the mapping relationship through the information acquisition function, and the embodiments of the present application will not be described in detail here.

[0092] Step 403: If the hard disk information of the target hard disk is found in the first controller, the target hard disk is registered based on the found hard disk information of the target hard disk.

[0093] If the first controller finds the hard disk information of the target hard disk in its own memory through step 402, it means that the target hard disk is a hard disk that has been registered in other controllers, that is, the target hard disk is the hard disk of other controllers taken over by the first controller. In this case, the first controller can use the hard disk information of the target hard disk found in the memory to generate a device name for the target hard disk and generate a directory file of the target hard disk, thereby completing the registration of the target hard disk in the kernel.

[0094] Among them, it can be known from the introduction in the aforementioned step 403 that the first controller can search for the hard disk information of the target hard disk through the information acquisition function of the SCSI middle layer. If the hard disk information of the target hard disk is found through the information acquisition function, the information acquisition function can return the first hard disk information to the scsi_probe_lun function. Based on this, after obtaining the first hard disk information, the scsi_probe_lun function can call the device registration function of the SCSI middle layer, and generate a device name and a directory file for the target hard disk based on the hard disk information of the target hard disk.

[0095] Step 404: If the hard disk information of the target hard disk is not found in the first controller, a hard disk information acquisition command is sent to the target hard disk.

[0096] As can be seen from the introduction in the aforementioned step 402, the first controller may store hard disk information of hard disks registered in multiple controllers. Based on this, if the first controller fails to find the hard disk information of the target hard disk in its own memory through step 402, it means that the target hard disk has not been registered in the multiple controllers, that is, the target hard disk is connected to the multiple controllers for the first time. In this case, the first controller can obtain the hard disk information of the target hard disk by sending a hard disk information acquisition command to the target hard disk.

[0097] As can be seen from the above step 403, the first controller can search for the hard disk information of the target hard disk through the information acquisition function of the SCSI middle layer. If the hard disk information of the target hard disk is not found through the information acquisition function, the information acquisition function can return a failure indication value to the scsi_probe_lun function. Based on this, see Figure 5 After obtaining the failure indication value, the scsi_probe_lun function can construct at least one hard disk information acquisition command based on the identifier of the target hard disk, and execute the at least one hard disk information acquisition command in sequence through the scsi_execute function. Among them, the at least one hard disk information acquisition command can include at least one of the report lun command, the inquiry command, the read capacity command, and the modesense command. Taking any hard disk information acquisition command as an example, when executing the hard disk information acquisition command, the scsi_execute function can call the blk_get_request function of the SCSI high layer, call the SCSI middle layer IO interface through the blk_get_request function, and the SCSI middle layer IO interface calls the SCSI low layer driver IO interface to send the hard disk information acquisition command to the target hard disk.

[0098] Step 405: Receive the hard disk information of the target hard disk returned by the target hard disk in response to the hard disk information acquisition command.

[0099] After receiving the hard disk information acquisition command, the target hard disk can return corresponding hard disk information to the first controller based on the hard disk information acquisition command. For example, when the hard disk information acquisition command is a report lun command, the target hard disk can return the total number of logical units included in itself to the first controller, and when the hard disk information acquisition command is an inquiry command, the target hard disk can return basic parameters such as its own device type to the first controller.

[0100] For example, Figure 5 For example, after receiving the hard disk information acquisition command, the target hard disk can return its own hard disk information to the SCSI low-level driver IO interface, and then the driver IO interface can fill the hard disk information back to the SCSI middle-level IO interface, and the SCSI middle-level IO interface fills the hard disk information back to the blk_get_request function. Optionally, in a possible situation, if the target hard disk does not return the hard disk information within a preset time after the SCSI low-level driver IO interface sends the hard disk information acquisition command to the target hard disk, that is, an IO timeout occurs, then the SCSI middle-level IO interface can start the error handling process, wherein the detailed implementation process of the error handling can refer to the relevant introduction in the previous text, and the embodiments of the present application will not be repeated here.

[0101] Step 406: store the hard disk information of the target hard disk, and synchronize the hard disk information of the target hard disk to other controllers among the multiple controllers except the first controller.

[0102] After receiving the hard disk information of the target hard disk, the first controller can store the hard disk information of the target hard disk in its own memory and synchronize the hard disk information of the target hard disk to other controllers in the multiple controllers. On this basis, subsequently, when any of the other controllers takes over the hard disk connected to the first controller, it can register the target hard disk through the aforementioned steps 401 to 403, without having to obtain the hard disk information by sending a hard disk information acquisition command to the target hard disk, thus shortening the registration time and improving the registration efficiency.

[0103] When the first controller stores the received hard disk information of the target hard disk in its own memory, the slot identifier of the target hard disk and the hard disk information of the target hard disk can be stored in a mapping relationship between the slot identifier and the hard disk information. Optionally, for each information item in the hard disk information, the first controller can also store each information item in correspondence with the command type of the hard disk information acquisition command used to obtain the corresponding information item.

[0104] In addition, when the first controller synchronizes the hard disk information of the target hard disk to other controllers, it can synchronize the slot identifier of the target hard disk, the hard disk information of the target hard disk, and the command type corresponding to each information item in the hard disk information to other controllers, so that other controllers can use the method introduced above to store each information item in the memory accordingly.

[0105] For example, Figure 5 For example, after the SCSI low layer in the first controller receives the hard disk information of the target hard disk and fills the hard disk information of the target hard disk back to the blk_get_request function of the SCSI high layer through the SCSI middle layer, the blk_get_request function can call the information saving function, and write the hard disk information of the target hard disk into the memory of the first controller through the information saving function. Among them, the information saving function can also be a hook function, for example, the name of the information saving function can be set_msg_for_other_node. After the hard disk information of the target hard disk is successfully written into the memory of the first controller, the information saving function returns a write success indication value to the blk_get_request function to indicate that the hard disk information is successfully stored. After obtaining the write success indication value, the blk_get_request function can fill the hard disk information of the target hard disk back to the scsi_probe_lun function of the SCSI middle layer, so that the scsi_probe_lun function calls the device registration function based on the hard disk information of the target hard disk to register the target hard disk.

[0106] In addition, after the information saving function successfully writes the hard disk information of the target hard disk into the memory of the first controller, the first controller may send the hard disk information of the target hard disk to other controllers through the communication connection established between the first controller and other controllers.

[0107] Step 407: Register the target hard disk based on the received hard disk information of the target hard disk.

[0108] After the first controller obtains the hard disk information of the target hard disk through the hard disk information obtaining command, the first controller may register the target hard disk based on the hard disk information of the target hard disk.

[0109] Among them, the implementation process of the first controller registering the target hard disk based on the hard disk information of the target hard disk can refer to the aforementioned related introduction, and the embodiment of the present application will not be repeated here.

[0110] Optionally, after the first controller registers the target hard disk in the kernel, if the first controller subsequently detects a removal command for the target hard disk, the hard disk information of the target hard disk stored in the first controller may be deleted.

[0111] Exemplarily, in some scenarios, after the first controller completes the registration of the target hard disk, the target hard disk may be removed later. For example, the target hard disk may be unplugged, or the target hard disk may be taken over by other controllers. In this case, the expansion board where the target hard disk is located can send a removal command for the target hard disk to the SCSI low layer of the first controller. The removal command may include the identifier of the target hard disk. After detecting the removal command, the SCSI low layer may call the device deregistration function of the SCSI middle layer based on the identifier of the target hard disk to deregister the target hard disk. In the process of deregistering the target hard disk, the device deregistration function may call an information deletion function to delete the hard disk information of the target hard disk stored in the memory of the first controller. The information deletion function may also be a hook function. For example, the function name of the information deletion function may be del_msg_for_other_node.

[0112] Based on the introduction in the above embodiments, it can be seen that Figure 6 , the first controller can search for hard disk information from the memory through the information acquisition function. If the hard disk information is not found, after obtaining the hard disk information through the hard disk information acquisition command, the hard disk information can be written into the memory through the information save function. Subsequently, when registering the hard disk, the hard disk information stored in the memory can be deleted through the information deletion function. The hard disk information in the memory can also be synchronized to the memory of other controllers. Among them, the information acquisition function, the information save function and the information deletion function are all hook functions. It can be seen that these three functions are interfaces for reading and writing hard disk information in the memory.

[0113] In an embodiment of the present application, the first controller of the multiple controllers included in the storage device stores the hard disk information of the hard disks registered in the multiple controllers. On this basis, the first controller can search for the hard disk information of the target hard disk in itself based on the identifier of the target hard disk to be registered. If the hard disk information of the target hard disk is found in the first controller, the first controller can directly register the target hard disk based on the hard disk information of the found target hard disk. Based on this, when the target hard disk is a hard disk connected to other controllers among the multiple controllers, since the target hard disk has been registered in other controllers, the hard disk information of the target hard disk will be stored in the first controller. In this way, the first controller does not need to send a hard disk information acquisition command to the target hard disk to obtain the hard disk information, which shortens the registration time of the target hard disk, improves the registration efficiency, and makes the access delay of the hard disk more stable. On this basis, if the first controller is a backup controller of a controller, then in the case of a failure of the controller or a failure of the virtual node on the controller, the first controller can quickly find the hard disk information of the hard disk currently to be taken over by the controller in its own memory through the method provided in the embodiment of the present application, thereby quickly completing the hard disk registration, improving the fault switching speed, and thus shortening the service interruption time caused by the fault switching.

[0114] Next, we will take controller A and controller B in the storage device as an example to illustrate the hard disk registration method described above. Assume that controller A and controller B are each other's backup controllers, and hard disks b1 to bn have not been registered in controller A and controller B before. Based on this, see Figure 7 , when controller B connects hard disk b1 to hard disk bn, taking hard disk b1 as an example, controller B can search for the hard disk information of hard disk b1 in its own memory through the SCSI middle layer. Since hard disk b1 has not been registered in controller A and controller B before, that is, this hard disk is connected to controller A and controller B for the first time, the hard disk information of hard disk b1 is not stored in the memory of controller B. In this case, controller B will not be able to find the hard disk information of hard disk b1 in its own memory. Therefore, the SCSI middle layer in controller B can send a hard disk information acquisition command to hard disk b1 through the SCSI low layer to obtain the hard disk information. After obtaining the hard disk information of hard disk b1, the SCSI middle layer in controller B can store the hard disk information in the memory, synchronize the hard disk information of hard disk b1 with controller A, and register hard disk b1 based on the hard disk information. For other hard disks, controller B can refer to the method of connecting to hard disk b1 to perform operations.

[0115] Subsequently, when controller B fails, when controller A takes over the hard disk connected to controller B, still taking hard disk b1 as an example, controller A can search for the hard disk information of hard disk b1 in its own memory through the SCSI middle layer. Since the memory of controller A stores the hard disk information of hard disks b1 to hard disk bn that are synchronized with controller B and registered in controller B, controller A can find the hard disk information of hard disk b1 in its own memory. In this case, controller A can directly register hard disk b1 based on the hard disk information of hard disk b1 stored in itself, without sending a hard disk information acquisition command to hard disk b1. For other hard disks connected to controller B, controller A can register them by referring to the method of registering hard disk b1, thereby quickly completing the takeover of the hard disk connected to controller B.

[0116] It can be seen that in the embodiment of the present application, after completing the first access of the hard disk, each controller can synchronize the hard disk information of the connected hard disk to the backup controller. In this case, when a controller or a virtual node on the controller fails, since the backup controller of the controller stores the hard disk information of the hard disk connected to the controller, the backup controller can register the hard disk to be taken over by reading the hard disk information stored in its own memory, and there is no need to send a command to the hard disk to be taken over to obtain the hard disk information, which shortens the hard disk information acquisition time, thereby shortening the registration time and improving the fault switching speed.

[0117] Next, the hard disk registration device provided in the embodiment of the present application is introduced.

[0118] Figure 8 8 is a schematic diagram of the structure of a hard disk registration device 800 provided in an embodiment of the present application. The device can be deployed in any controller among the multiple controllers included in the storage device in the aforementioned embodiment. Figure 8 As shown, the hard disk registration device includes an acquisition module 801, a search module 802 and a registration module 803.

[0119] Wherein, the acquisition module 801 is used to execute step 401 in the above embodiment;

[0120] A search module 802, used to execute step 402 in the above embodiment;

[0121] The registration module 803 is used to execute step 403 in the above embodiment.

[0122] Optionally, the first controller includes a memory, see Figure 8 , the device 800 further includes:

[0123] The sending module 804 is used to send a hard disk information acquisition command to the target hard disk if the hard disk information of the target hard disk is not found in the first controller;

[0124] The receiving module 805 is used to receive the hard disk information of the target hard disk returned by the target hard disk in response to the hard disk information acquisition command;

[0125] The storage module 806 is used to store the hard disk information of the target hard disk in the memory;

[0126] A synchronization module 807, configured to synchronize hard disk information of a target hard disk to other controllers among the multiple controllers except the first controller;

[0127] The registration module 803 is further used to register the target hard disk based on the received hard disk information of the target hard disk.

[0128] Optionally, the identifier of the target hard disk includes a slot identifier and a device address of the target hard disk, and the search module 802 is specifically used for:

[0129] Searching the first controller for first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk;

[0130] If the first hard disk information is found, and the device address included in the first hard disk information is the same as the device address of the target hard disk, the first hard disk information is determined as the hard disk information of the found target hard disk.

[0131] Optionally, the acquisition module 801 is specifically used for:

[0132] In the case of detecting a failure of the second controller, scanning multiple hard disks connected to the second controller to obtain identifications of the multiple hard disks, the multiple hard disks including the target hard disk, and the second controller being any one of the multiple controllers;

[0133] Alternatively, in the case of a virtual node failure in the second controller, multiple hard disks corresponding to the failed virtual node are scanned to obtain identifications of the multiple hard disks, where the multiple hard disks include the target hard disk.

[0134] Optionally, the first controller includes a memory, see Figure 8 The synchronization module 807 is also used for:

[0135] receiving hard disk information of registered hard disks sent by other controllers among the multiple controllers except the first controller;

[0136] Stores the hard disk information of registered hard disks sent by other controllers in memory.

[0137] Optionally, the device 800 further includes:

[0138] The deleting module is used to delete the hard disk information of the target hard disk stored in the first controller if a removal command for the target hard disk is detected.

[0139] In an embodiment of the present application, the first controller among the multiple controllers included in the storage device stores the hard disk information of the hard disks registered in the multiple controllers. On this basis, the first controller can search for the hard disk information of the target hard disk in itself based on the identifier of the target hard disk to be registered. If the hard disk information of the target hard disk is found in the first controller, the first controller can directly register the target hard disk based on the hard disk information of the found target hard disk. Based on this, when the target hard disk is a hard disk connected to other controllers among the multiple controllers, since the target hard disk has been registered in other controllers, the hard disk information of the target hard disk will be stored in the first controller. In this way, the first controller no longer needs to send a hard disk information acquisition command to the target hard disk to obtain the hard disk information, which shortens the registration time of the target hard disk and improves the registration efficiency.

[0140] It should be noted that the division of modules in the hard disk registration device provided in the above embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0141] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or 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 to enable a network device (which may be a router or switch, etc.) or a processor (processor) to execute all or part of the steps of the method of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0142] In addition, the hard disk registration device and the hard disk registration method embodiment provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0143] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

Claims

1. A hard disk registration method, characterized in that: Applied to a first controller among a plurality of controllers included in a storage device, the method comprises: Get the ID of the target hard disk to be registered; Searching the first controller for hard disk information of the target hard disk based on the identifier of the target hard disk, wherein the first controller stores hard disk information of hard disks registered in the multiple controllers; If the hard disk information of the target hard disk is found in the first controller, the target hard disk is registered based on the found hard disk information of the target hard disk.

2. The method according to claim 1, characterized in that The first controller includes a memory, and the method further includes: If the hard disk information of the target hard disk is not found in the first controller, a hard disk information acquisition command is sent to the target hard disk; Receiving hard disk information of the target hard disk returned by the target hard disk in response to the hard disk information acquisition command; storing the hard disk information of the target hard disk in the memory, and synchronizing the hard disk information of the target hard disk to other controllers among the multiple controllers except the first controller; The target hard disk is registered based on the received hard disk information of the target hard disk.

3. The method according to claim 1 or 2, characterized in that: The identification of the target hard disk includes a slot identification and a device address of the target hard disk, and searching the first controller for hard disk information of the target hard disk based on the identification of the target hard disk includes: Searching the first controller for first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk; If the first hard disk information is found, and the device address included in the first hard disk information is the same as the device address of the target hard disk, the first hard disk information is determined as the found hard disk information of the target hard disk.

4. The method according to any one of claims 1 to 3, characterized in that: The step of obtaining the identifier of the target hard disk to be registered includes: In the case where a failure of the second controller is detected, scanning multiple hard disks connected to the second controller to obtain identifications of the multiple hard disks, the multiple hard disks including the target hard disk, and the second controller being any one of the multiple controllers; Alternatively, in the case of a virtual node failure in the second controller, multiple hard disks corresponding to the failed virtual node are scanned to obtain identifiers of the multiple hard disks, where the multiple hard disks include the target hard disk.

5. The method according to any one of claims 1 to 4, characterized in that: The first controller includes a memory, and the method further includes: receiving hard disk information of registered hard disks sent by other controllers among the multiple controllers except the first controller; The hard disk information of the registered hard disk sent by the other controller is stored in the memory.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: If a removal command for the target hard disk is detected, the hard disk information of the target hard disk stored in the first controller is deleted.

7. A hard disk registration device, characterized in that: Applied to a first controller among a plurality of controllers included in a storage device, the apparatus comprises: An acquisition module, used to acquire the identifier of the target hard disk to be registered; a search module, configured to search the hard disk information of the target hard disk in the first controller based on the identifier of the target hard disk, wherein the first controller stores the hard disk information of the hard disks registered in the plurality of controllers; A registration module is used to register the target hard disk based on the hard disk information of the target hard disk if the hard disk information of the target hard disk is found in the first controller.

8. The device according to claim 7, characterized in that The first controller includes a memory, and the device further includes: A sending module, configured to send a hard disk information acquisition command to the target hard disk if the hard disk information of the target hard disk is not found in the first controller; A receiving module, used for receiving the hard disk information of the target hard disk returned by the target hard disk in response to the hard disk information obtaining command; A storage module, used for storing hard disk information of the target hard disk in the memory; A synchronization module, used for synchronizing the hard disk information of the target hard disk to other controllers among the multiple controllers except the first controller; The registration module is further used to register the target hard disk based on the received hard disk information of the target hard disk.

9. The device according to claim 7 or 8, characterized in that The identification of the target hard disk includes the slot identification and device address of the target hard disk, and the search module is specifically used for: Searching the first controller for first hard disk information whose corresponding slot identifier is the slot identifier of the target hard disk; If the first hard disk information is found, and the device address included in the first hard disk information is the same as the device address of the target hard disk, the first hard disk information is determined as the found hard disk information of the target hard disk.

10. The device according to any one of claims 7 to 9, characterized in that: The acquisition module is specifically used for: In the case where a failure of the second controller is detected, scanning multiple hard disks connected to the second controller to obtain identifications of the multiple hard disks, the multiple hard disks including the target hard disk, and the second controller being any one of the multiple controllers; Alternatively, in the case of a virtual node failure in the second controller, multiple hard disks corresponding to the failed virtual node are scanned to obtain identifiers of the multiple hard disks, where the multiple hard disks include the target hard disk.

11. The device according to any one of claims 7 to 10, characterized in that: The first controller includes a memory, and the device further includes: The synchronization module is used to receive hard disk information of registered hard disks sent by other controllers among the multiple controllers except the first controller; and store the hard disk information of registered hard disks sent by other controllers in the memory.

12. The device according to any one of claims 7 to 11, characterized in that The device also includes: A deleting module is used to delete the hard disk information of the target hard disk stored in the first controller if a removal command for the target hard disk is detected.

13. A storage device, characterized in that: The storage device includes multiple controllers, the multiple controllers include a first controller, the first controller includes a processor and a memory, the processor is used to execute at least one program instruction or code stored in the memory to implement the hard disk registration method described in any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer device, the computer device executes the hard disk registration method according to any one of claims 1 to 6.