Hard disk management method, device, readable storage medium and electronic device
By establishing a slot information mapping through communication between the hard drive driver and the controller, the signal integrity problem caused by cross-wiring in NVMe devices is solved, enabling rapid hard drive location confirmation and improving user experience.
Patent Information
- Application Number
- CN202110980047.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-25
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-08-25
AI Technical Summary
In computer motherboard design, cross-wiring of NVMe devices causes signal integrity issues, and existing LED positioning methods rely on specific tools and low-level controllers, which cannot quickly confirm the location of NVMe devices, increasing troubleshooting time.
By communicating with the hard drive driver, motherboard controller, and hard drive backplane controller, a mapping between slot information and hard drive serial number information is established, and the hard drive's identification in the motherboard controller is determined, avoiding problems caused by cross wiring and long cables.
Significantly reduces signal loss, improves user experience, is suitable for systems without BMC, directly locates hard drive slot information, has a wider range of applications, and avoids equipment heat dissipation problems caused by cross cabling and long cables.
Smart Images

Figure CN113760667B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a hard disk management method, device, readable storage medium and electronic equipment. Background Art
[0002] In the design process of computer motherboard, the PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) interface of NVMe (Non-Volatile Memory Express, a non-volatile memory standard) and the front panel of NVMe need to be connected with NVMe cables. In order to ensure that the NVMe slot numbers from left to right on the front panel correspond to the numbers of NVMe devices under OS control from small to large and are arranged in order, multiple NVMe cables need to be crossed and the cable length is increased. However, cross wiring easily affects signal integrity and cannot meet the ever-increasing data signal requirements.
[0003] At present, in order to solve the above problems, the method of locating NVMe devices by lighting up LEDs is used to avoid cross wiring. However, this method requires the use of LED tools compatible with NVMe devices to realize the lighting of LEDs, and each different LED tool may have multiple different tool versions. More importantly, the LED tool also depends on the flashing light protocol supported by the computer's underlying controller. If the correspondence between the NVMe label (logo) on the front panel of the computer and the NVMe PCIE interface cannot be determined by lighting the LED, then during the OS (Operation System, operating system) debugging process and the computer equipment maintenance personnel checking the OS log, when the NVMe error message is found, it is impossible to quickly confirm the specific location of the backplane where the NVMe is located in the error message to repair it, which increases the time for troubleshooting. Summary of the invention
[0004] Embodiments of the present invention provide a hard disk management method, device, readable storage medium and electronic device.
[0005] According to a first aspect of the present invention, a hard disk management method is provided, wherein a storage device comprises a mainboard and a hard disk, wherein the hard disk is connected to the mainboard via a hard disk backplane, and the method comprises: determining a hard disk mounted under the mainboard; obtaining, through the drive of the hard disk, in-place information of the hard disk, slot information of the hard disk on the hard disk backplane, and hard disk numbering information of the hard disk in a controller of the hard disk backplane; constructing a mapping of the slot information and the hard disk numbering information; determining hard disk numbering information of all current hard disks based on the hard disks mounted under the mainboard; determining the slot information of the current hard disk based on the hard disk numbering information of the current hard disk and the mapping; determining a hard disk identifier of the current hard disk in the controller of the mainboard based on the slot information, wherein the hard disk identifier is used to identify the slot information.
[0006] According to one embodiment of the present invention, determining the hard disk mounted on the mainboard includes: when the controller of the mainboard is started, enumerating the hard disks mounted on each bus host bridge in turn according to the bus host bridge order given by the interface information table of the unified extensible firmware interface.
[0007] According to one embodiment of the present invention, obtaining the hard disk's in-place information, the hard disk's slot position information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane through the hard disk driver includes: calling the driver; sending an information acquisition instruction to the controller of the hard disk backplane through the driver; receiving through the driver the following information returned by the controller of the hard disk backplane in response to the information acquisition instruction: the hard disk's in-place information, the hard disk's slot position information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane.
[0008] According to one embodiment of the present invention, constructing a mapping between the slot information and the hard disk numbering information includes: reserving hard disk identifiers for all hard disks in the controller of the motherboard based on the hard disk numbering information; and determining the correspondence between the slot information and the hard disk identifier in the controller of the motherboard based on the correspondence between the slot information of the hard disk and the hard disk numbering information of the hard disk in the controller of the hard disk backplane, as a mapping between the slot information of the hard disk and the hard disk identifier in the controller of the motherboard.
[0009] According to one embodiment of the present invention, determining the slot information of the current hard disk based on the hard disk numbering information of the current hard disk and the mapping includes: when the drive completes initialization, each time a hard disk is detected, obtaining the hard disk numbering information of the slot where the current hard disk is located; determining the slot information of the slot where the hard disk corresponding to the hard disk numbering information in the mapping is located.
[0010] According to an embodiment of the present invention, the hard disk is an NVMe hard disk.
[0011] According to the second aspect of the present invention, a hard disk management device is also provided, wherein the storage device comprises a mainboard and a hard disk, wherein the hard disk is connected to the mainboard via a hard disk backplane, and the device comprises: a hard disk determination module, for determining the hard disk mounted under the mainboard; an acquisition module, for acquiring, through the drive of the hard disk, the in-place information of the hard disk, the slot information of the hard disk on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane; a mapping construction module, for constructing a mapping of the slot information and the hard disk numbering information; a slot determination module, for determining the hard disk numbering information of all current hard disks based on the hard disks mounted under the mainboard; a number determination module, for determining the slot information of the current hard disk according to the hard disk numbering information of the current hard disk and the mapping; an identification determination module, for determining the hard disk identification of the current hard disk in the controller of the mainboard based on the slot information, wherein the hard disk identification is used to identify the slot information.
[0012] According to one embodiment of the present invention, the acquisition module includes: a calling driver submodule, used to call the driver; an information sending submodule, used to send an information acquisition instruction to the controller of the hard disk backplane through the driver; an information acquisition submodule, used to receive through the driver the controller of the hard disk backplane returns the following information in response to the information acquisition instruction: hard disk in-place information, slot position information of the hard disk on the hard disk backplane and hard disk number information of the hard disk in the controller of the hard disk backplane.
[0013] According to a third aspect of the present invention, a computer-readable storage medium is further provided, wherein the storage medium comprises a group of computer-executable instructions, and when the instructions are executed, the instructions are used to execute any of the above-mentioned hard disk management methods.
[0014] According to the fourth aspect of the present invention, a device is also provided, which includes at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; and the processor is used to call program instructions in the memory to execute any of the above-mentioned hard disk management methods.
[0015] The hard disk management method, device, computer-readable storage medium and electronic device of the embodiment of the present invention, the storage device includes a mainboard and a hard disk, the hard disk is connected to the mainboard through a hard disk backplane, and in the process of numbering and identifying the hard disk, the hard disk driver, the mainboard controller and the hard disk backplane controller communicate with each other, according to the hard disk slot information on the hard disk backplane and the hard disk number information in the hard disk backplane controller, and finally determine the hard disk identification of the current hard disk in the mainboard controller. The method of matching the hard disk slot information in the hard disk backplane with the hard disk identification in the mainboard by means of cross wiring and the like is effectively avoided, thereby avoiding the device heat dissipation problem caused by means of cross wiring and extending the length of the nvme cable, and significantly reducing the signal loss. In addition, the hard disk management method of the present invention has universal applicability, and is also applicable to the case where the nvme device slot number cannot be viewed in a system without a BMC. Compared with the method of using an LED tool to light up the nvme, the method of confirming the hard disk number has a wider scope of application, and the corresponding slot information can be directly found through the nvme number, which significantly improves the user experience.
[0016] It should be understood that the teachings of the present invention are not required to achieve all of the beneficial effects described above, but specific technical solutions can achieve specific technical effects, and other embodiments of the present invention can also achieve beneficial effects not mentioned above. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:
[0018] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0019] Figure 1 A schematic diagram showing an application scenario of the hard disk management method according to an embodiment of the present invention is shown;
[0020] Figure 2 A schematic diagram of the implementation process of the hard disk management method according to an embodiment of the present invention is shown;
[0021] Figure 3 A schematic diagram showing the implementation process of a specific application example of the hard disk management method according to an embodiment of the present invention is shown;
[0022] Figure 4 A schematic diagram showing the composition structure of a hard disk management device according to an embodiment of the present invention is shown;
[0023] Figure 5 A schematic diagram of the structure of the device according to the embodiment of the present invention is shown. DETAILED DESCRIPTION
[0024] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present invention more thorough and complete, and to fully convey the scope of the present invention to those skilled in the art.
[0025] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0026] Figure 1 A schematic diagram of an application scenario of a hard disk management method according to an embodiment of the present invention is shown.
[0027] refer to Figure 1 The hard disk management method of the embodiment of the present invention can be applied to the process of numbering hard disks in a storage device. Generally, a storage device may include a motherboard and a hard disk, wherein the hard disk is connected to the motherboard via a hard disk backplane, and the hard disk and the motherboard belong to the same server or computer device.
[0028] The server OS (operation system) is configured on the server's motherboard. The server OS is configured with an nvme driver program, which can obtain nvme information and set the nvme device identifier. Among them, the server OS program can be loaded into the server operating environment, such as the operating environment provided by the BMC. The motherboard can communicate with the backplane controller through the I2C bus. The motherboard communicates with the hard disk of the backplane through PCIE (Peripheral Component Interconnect Express, a high-speed serial bus). Each motherboard can be connected to multiple backplanes through the main bridge.
[0029] The backplane refers to the front panel of the server. Each backplane can be connected to multiple hard disks through slots. For example, hard disks nvme0-nvme7 are connected to the backplane through slots slot0-slot7. Each hard disk can correspond to an indicator light, which can be an LED light. In addition, the controller of the backplane (that is, the control chip on the front panel) communicates with the CPLD (complex programmable logic device) configured on the backplane through the SGPIO bus. Each CPLD can control a specified number of hard disks, which is generally 8, 16 or 32. In the embodiment of the present invention, the solution is described by taking the hard disk as an nvme hard disk as an example. Of course, in actual applications, it can also be other hard disks.
[0030] Figure 2 FIG. 1 is a schematic diagram showing the implementation process of the hard disk management method according to an embodiment of the present invention. Figure 2 The storage device includes a mainboard and a hard disk, and the hard disk is connected to the mainboard through a hard disk backplane. The hard disk management method of the embodiment of the present invention at least includes the following operation procedures: operation 201, determining the hard disk mounted on the mainboard; operation 202, obtaining the hard disk in-position information, the hard disk slot information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane through the hard disk driver; operation 203, constructing a mapping of the slot information and the hard disk numbering information; operation 204, determining the hard disk numbering information of all current hard disks based on the hard disk mounted on the mainboard; operation 205, determining the slot information of the current hard disk according to the hard disk numbering information and the mapping of the current hard disk; operation 206, determining the hard disk identifier of the current hard disk in the controller of the mainboard based on the slot information, and the hard disk identifier is used to identify the slot information.
[0031] In operation 201, a hard disk mounted under the mainboard is determined.
[0032] In one embodiment of the present invention, when the motherboard controller is started, the hard disks mounted on each bus master bridge can be enumerated in turn through the bus master bridge sequence given by the interface information table of the unified extensible firmware interface, thereby determining the hard disk mounted on the motherboard.
[0033] Here, the real-time operating system kernel in the server's OS can enumerate all nvme devices mounted under different host bridges in the order of the PCIE host bridge (bus host bridge) given by the DSDT (The Differentiated System Description Table, an interface information table describing different system information) of ACPI (Advanced Configuration and Power Management Interface) defined by UEFI (Unified Extensible Firmware Interface) during the server startup phase. For example: Figure 1 The hard disk mounted under PCIE2.
[0034] For example, Linux OS enumerates all nvme devices under different host bridges. First, PCIE devices need to be enumerated. The specific description is as follows:
[0035] When the Linux kernel initializes ACPI, it scans the PCIe host bridge defined in the DSDT table. The DSDT part is defined as follows:
[0036]
[0037] After scanning the PCIE main bridge device PNP0A08 defined in the DSDT table, it will parse the relevant information under the main bridge, and mainly perform the following operations:
[0038] 1. Get the segment number used by the main bridge through the _SEG parameter of ACPI. Segment refers to the PCIE number.
[0039] 2. Get the auxiliary bus range of the host bridge through the BusRange type resource in ACPI's _CRS.
[0040] 3. Get the root bus number of the host bridge through the _BNN parameter of ACPI.
[0041] At this point, you can see information like "ACPI: PCI Root Bridge [S0D0] (domain 0000 [bus 60-7f])" in dmesg, indicating that a PICE master bridge has been added.
[0042] Then, you need to enumerate the devices under the added main bridge, which mainly includes the following steps:
[0043] 1. Discover the host bridge device and the root bus.
[0044] 2. Discover all bus devices under the main bridge device.
[0045] 3. If the device under the main bridge is a bus bridge, then traverse all bus devices under this bus bridge again, and recursively do this until the current bus tree is traversed.
[0046] After PCIE enumeration is completed, resources need to be allocated to PCIE. The entire resource allocation process is to allocate resources to each bus driver bar from the total resources of the system, and to allocate resources to the base and limit registers of each bus bridge. It can include the following operations:
[0047] 1. Get the range of system resources managed by the upstream bus bridge device.
[0048] 2. Use depth-first scanning to allocate bar resources to all bus terminal devices.
[0049] 3. Use depth-first scan to set the base and limit values of the current bus bridge device and update these registers.
[0050] In operation 202, the hard disk location information, the hard disk slot information on the hard disk backplane, and the hard disk number information in the controller of the hard disk backplane are obtained through the hard disk driver.
[0051] In one embodiment of the present invention, the following operations can be used to obtain the hard disk's presence information, the hard disk's slot position information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane through the hard disk driver: calling the driver; sending an information acquisition instruction to the controller of the hard disk backplane through the driver; receiving the following information returned by the controller of the hard disk backplane in response to the information acquisition instruction through the driver: the hard disk's presence information, the hard disk's slot position information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane.
[0052] For example, when the nvme device is enumerated in the OS, the nvme device driver will be detected and called. During the initialization phase of the nvme device driver, an I2C command can be sent to the backplane controller to obtain the slots where all nvme devices currently mounted on the motherboard are located. After receiving the I2C command, the backplane controller parses the I2C command and attempts to detect the nvme devices on the backplane, obtain the in-place information of all nvme hard disks, the slot information of all nvme hard disks on the hard disk backplane, and the hard disk number information of all nvme hard disks in the controller of the hard disk backplane, etc., and feeds the obtained information back to the nvme driver of the OS. The slot information can be Figure 1 The slot information is slot0-slot7, and the hard disk number information can be Figure 1 The serial numbers of the nvme hard disks in the hard disk group are nvme0-nvme7, etc.
[0053] In operation 203, a mapping between the slot information and the hard disk number information is constructed.
[0054] In one embodiment of the present invention, the following operations can be used to achieve the mapping of slot information and hard disk numbering information: determine the correspondence between the slot information where the hard disk is located and the hard disk numbering information of the hard disk in the controller of the hard disk backplane; based on the correspondence, construct a mapping between the slot information where the hard disk is located and the hard disk numbering information in the controller of the mainboard.
[0055] Here, the motherboard controller refers to the control chip of the server motherboard. The server OS is configured on the motherboard controller chip. You can also reserve hard disk identifiers for all hard disks in the motherboard controller.
[0056] For example, when the nvme device is enumerated in the OS, a hard disk identifier corresponding to the hard disk number information is reserved for each hard disk device. For example: Based on operation 203, the nvme driver is detected and called to detect the hard disk number information and slot information of the nvme device in the backplane controller, and a mapping between the hard disk slot information and the hard disk number information is constructed in the mainboard controller, that is, in the OS system. For example: Based on Figure 1When nvme0 is enumerated, the corresponding relationship between hard disk nvme0 and slot information slot0 is determined. Thus, a number is reserved for each hard disk in turn, and the corresponding relationship between each slot information and hard disk number information is determined to construct Figure 1 There is a one-to-one correspondence between the slot information slot0-slot7 and the hard disk number information nvme0-nvme7.
[0057] In operation 204, based on the hard disks mounted under the mainboard, hard disk serial number information of all current hard disks is determined.
[0058] In this embodiment of the present invention, the nvme driver can be used to detect the presence information of the nvme device and determine the hard disk number information of all hard disks currently in place among the hard disks mounted under the mainboard.
[0059] In operation 205, the slot information of the current hard disk is determined according to the hard disk number information and mapping of the current hard disk.
[0060] In one embodiment of the present invention, during the startup phase of the OS, when the nvme device is enumerated, the nvme device driver can be detected and called. And when the driver is initialized, each time the hard disk is detected, the hard disk number information of the detected current hard disk in the controller of the backplane is obtained. And based on the mapping of the hard disk number information and the slot information constructed in operation 203, the slot information of the slot where the hard disk corresponding to the hard disk number information of the current hard disk is located in the mapping is determined.
[0061] For example, combining Figure 1 , a hard disk is detected, and the hard disk number information of the hard disk is obtained as nvme3. Then, according to the hard disk number information, it is determined from the mapping that the slot information where the hard disk corresponding to the hard disk number information nvme3 is located is slot3.
[0062] Operation 206 : determining a hard disk identifier of the current hard disk in a controller of the mainboard based on the slot information, where the hard disk identifier is used to identify the slot information.
[0063] In this embodiment of the present invention, the hard disk identifier of the hard disk in the controller of the motherboard can be set to an identifier with the same numbering pattern as the hard disk numbering information of the hard disk in the controller of the backplane. For example: if the hard disk is numbered nvme0~nvme7 in the controller of the backplane, the hard disk identifier of the hard disk in the controller of the motherboard can be set to S01_00~S01_07, where S01 can indicate that the hard disk is located under the first main bridge of the controller of the motherboard, and 00~07 can indicate the arrangement order of the hard disks under the first main bridge of the controller of the motherboard.
[0064] Figure 3FIG. 1 is a schematic diagram showing a specific application example of the hard disk management method according to an embodiment of the present invention. Figure 3 As shown, in a specific application example of the hard disk management method according to an embodiment of the present invention, the hard disk management method may include the following operations:
[0065] Operation 301, loading the nvme driver.
[0066] Operation 302, running the nvme driver initialization interface.
[0067] Operation 303, obtaining nvme device information.
[0068] Operation 304, creating an nvme device name table.
[0069] Operation 305, checking the nvme device status.
[0070] Operation 306, determining whether the nvme device is in place. If yes, then executing operation 307; if no, then executing operation 308.
[0071] Operation 307, fill in the nvme device name table according to the nvme device in place.
[0072] Operation 308, reserve the device number corresponding to the device name of the current nvme device in the nvme device name table for use by the current nvme.
[0073] Operation 309, registering the nvme driver.
[0074] Operation 311 scans nvme devices.
[0075] In operation 311, the nvme driver detects the nvme device.
[0076] Operation 312, checking the device name table.
[0077] Operation 313, determine whether the nvme device matches the nvme device name in the device name table. If yes, execute operation 314; if no, execute operation 317.
[0078] Operation 314, obtaining the nvme device number.
[0079] Operation 315, determining whether the nvme device number is occupied.
[0080] Operation 316, determine the nvme device number.
[0081] Operation 317, obtaining the nvme device number by a default method.
[0082] In this specific application example of the present invention, the nvme device number is obtained in a default manner, that is, the nvme device number is not obtained from the number reserved in operation 308, but the smallest unused number in the OS system is obtained. The number reserved in operation 308 indicates that the number will continue to be used later, so the number reserved in operation 308 can be considered to be occupied.
[0083] Operation 318, determining the nvme device identifier. According to the acquired or determined nvme device number, determine the nvme device identifier of the nvme device in the controller of the mainboard.
[0084] It should be noted that the nvme device in operations 301 to 318 has the same meaning as the nvme hard disk described elsewhere in the text. Figure 2 The specific implementation process of operations 201 to 206 in the illustrated embodiment is similar and will not be described in detail here.
[0085] The hard disk management method, device, computer-readable storage medium and electronic device of the embodiment of the present invention, in the process of numbering and identifying the hard disk, through the communication between the hard disk drive, the mainboard controller and the controller of the hard disk backplane, according to the slot information of the hard disk on the hard disk backplane and the hard disk number information of the hard disk in the controller of the hard disk backplane, finally determine the hard disk identification of the current hard disk in the controller of the mainboard. It effectively avoids the method of matching the slot information of the hard disk in the hard disk backplane with the hard disk identification in the mainboard by means of cross wiring, thereby avoiding the equipment heat dissipation problems caused by cross wiring, extending the length of the nvme cable, etc., and significantly reducing signal loss. In addition, it has universal applicability, and is also applicable to the situation where the nvme device slot number cannot be viewed in a system without a BMC. Compared with the method of using an LED tool to light up the nvme, the method of confirming the hard disk number has a wider scope of application, and the corresponding slot information can be directly found through the nvme number, which significantly improves the user experience.
[0086] Similarly, based on the above hard disk management method, an embodiment of the present invention also provides a computer-readable storage medium, which stores a program. When the program is executed by a processor, the processor performs at least the following operation steps: operation 201, determining the hard disk mounted on the motherboard; operation 202, obtaining the hard disk in-place information, the hard disk slot information on the hard disk backplane, and the hard disk numbering information of the hard disk in the controller of the hard disk backplane through the hard disk driver; operation 203, constructing a mapping of the slot information and the hard disk numbering information; operation 204, based on the hard disk mounted on the motherboard, determining the hard disk numbering information of all current hard disks; operation 205, determining the slot information of the current hard disk according to the hard disk numbering information and mapping of the current hard disk; operation 206, based on the slot information, determining the hard disk identifier of the current hard disk in the controller of the motherboard, the hard disk identifier is used to identify the slot information.
[0087] Further, based on the above hard disk management method, the embodiment of the present invention also provides a hard disk management device, such as Figure 4 As shown, the storage device includes a mainboard and a hard disk, and the hard disk is connected to the mainboard via a hard disk backplane. The device 40 includes: a hard disk determination module 401, used to determine the hard disk mounted under the mainboard; an acquisition module 402, used to obtain the hard disk in-place information, the hard disk slot information on the hard disk backplane and the hard disk numbering information of the hard disk in the controller of the hard disk backplane through the hard disk drive; a mapping construction module 403, used to construct a mapping of the slot information and the hard disk numbering information; a slot determination module 404, used to determine the hard disk numbering information of all current hard disks based on the hard disk mounted under the mainboard; a number determination module 405, used to determine the slot information of the current hard disk according to the hard disk numbering information and mapping of the current hard disk; an identification determination module 406, used to determine the hard disk identification of the current hard disk in the controller of the mainboard based on the slot information, and the hard disk identification is used to identify the slot information.
[0088] In one embodiment of the present invention, the hard disk determination module 401 includes: an enumeration submodule, which is used to enumerate the hard disks mounted on each bus host bridge in sequence according to the bus host bridge order given by the interface information table of the unified extensible firmware interface when the controller of the mainboard is started.
[0089] In one embodiment of the present invention, the acquisition module 402 includes: a calling driver submodule for calling the driver; an information sending submodule for sending an information acquisition instruction to the controller of the hard disk backplane through the driver; an information acquisition submodule for receiving through the driver the controller of the hard disk backplane returns the following information in response to the information acquisition instruction: hard disk in-place information, hard disk slot information on the hard disk backplane, and hard disk number information of the hard disk in the controller of the hard disk backplane.
[0090] In one embodiment of the present invention, the mapping construction module 403 includes: a relationship determination sub-module, used to determine the correspondence between the slot position information of the hard disk and the hard disk numbering information of the hard disk in the controller of the hard disk backplane; a mapping sub-module, used to construct a mapping between the slot position information of the hard disk and the hard disk numbering information in the controller of the mainboard according to the correspondence.
[0091] In one embodiment of the present invention, the number determination module 405 includes: a number information acquisition submodule, which is used to obtain the hard disk number information of the current hard disk detected each time the hard disk is detected when the drive completes initialization; and a slot determination submodule, which is used to determine the slot information of the slot where the hard disk corresponding to the hard disk number information is located in the mapping.
[0092] Further, based on the above hard disk management method, the embodiment of the present invention also provides a device, such as Figure 5 As shown, the device 50 includes at least one processor 501, and at least one memory 502 and a bus 503 connected to the processor 501; wherein the processor 501 and the memory 502 communicate with each other through the bus 503; the processor 501 is used to call the program instructions in the memory 502 to execute any of the above-mentioned hard disk management methods.
[0093] It should be noted that the above description of the hard disk management device and equipment embodiment is different from the above description of the hard disk management device and equipment embodiment. Figures 1 to 3 The description of the method embodiment shown is similar, with the same Figures 1 to 3 For technical details not disclosed in the embodiments of the hard disk management device and equipment of the present invention, please refer to the aforementioned Figures 1 to 3 The method embodiment shown in the figure can be understood by referring to the description, and will not be described in detail for the sake of saving space.
[0094] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0095] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0096] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0097] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0098] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0099] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0100] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A hard disk management method, wherein the storage device comprises a mainboard and a hard disk, wherein the hard disk is connected to the mainboard via a hard disk backplane, and the method comprises: Determine the hard disk mounted under the mainboard; Obtaining, through the drive of the hard disk, the hard disk in-position information, the hard disk slot information on the hard disk backplane, and the hard disk number information of the hard disk in the controller of the hard disk backplane; Constructing a mapping between the slot information and the hard disk number information; Based on the hard disks mounted on the mainboard, determine the hard disk serial number information of all the hard disks currently mounted on the mainboard; Determine the slot information of the current hard disk according to the hard disk number information of the current hard disk and the mapping; Based on the slot information, a hard disk identifier of the current hard disk in the controller of the mainboard is determined, where the hard disk identifier is used to identify the slot information.
2. According to the method of claim 1, the step of determining the hard disk mounted under the mainboard comprises: When the controller of the mainboard is started, the hard disks mounted by each bus host bridge are enumerated in sequence according to the bus host bridge sequence given by the interface information table of the unified extensible firmware interface.
3. The method according to claim 1, wherein obtaining, through the drive of the hard disk, the hard disk location information, the hard disk slot information on the hard disk backplane, and the hard disk number information of the hard disk in the controller of the hard disk backplane comprises: Calling the driver; Sending an information acquisition instruction to the controller of the hard disk backplane through the driver; The controller of the hard disk backplane receives the following information in response to the information acquisition instruction through the drive: hard disk presence information, slot information of the hard disk on the hard disk backplane, and hard disk number information of the hard disk in the controller of the hard disk backplane.
4. According to the method of claim 1, the step of constructing a mapping between the slot information and the hard disk number information comprises: Determine the correspondence between the slot information of the hard disk and the hard disk number information of the hard disk in the controller of the hard disk backplane; According to the corresponding relationship, a mapping between the hard disk slot information and the hard disk number information is constructed in the controller of the mainboard.
5. The method according to claim 1, wherein determining the slot information of the current hard disk according to the hard disk number information of the current hard disk and the mapping comprises: When the driver is initialized, each time a hard disk is detected, hard disk number information of the current hard disk detected is obtained; Determine the slot information of the hard disk slot corresponding to the hard disk number information in the mapping.
6. The method according to any one of claims 1 to 5, wherein the hard disk is an NVMe hard disk.
7. A hard disk management device, wherein the storage device comprises a mainboard and a hard disk, wherein the hard disk is connected to the mainboard via a hard disk backplane, and the device comprises: A hard disk determination module, used to determine the hard disk mounted under the mainboard; An acquisition module, used to acquire, through the drive of the hard disk, the in-position information of the hard disk, the slot information of the hard disk on the hard disk backplane, and the hard disk number information of the hard disk in the controller of the hard disk backplane; A mapping construction module, used to construct a mapping between the slot information and the hard disk number information; A slot determination module, used to determine the hard disk number information of all the hard disks currently mounted on the mainboard; A number determination module, used to determine the slot information of the current hard disk according to the hard disk number information of the current hard disk and the mapping; The identification determination module is used to determine the hard disk identification of the current hard disk in the controller of the mainboard based on the slot information, and the hard disk identification is used to identify the slot information.
8. The device according to claim 7, wherein the acquisition module comprises: A calling driver submodule, used for calling the driver; An information sending submodule, used for sending an information acquisition instruction to the controller of the hard disk backplane through the driver; The information acquisition submodule is used to receive the following information returned by the controller of the hard disk backplane in response to the information acquisition instruction through the driver: the hard disk presence information, the slot information of the hard disk on the hard disk backplane and the hard disk number information of the hard disk in the controller of the hard disk backplane.
9. A computer-readable storage medium, comprising a set of computer-executable instructions, which are used to execute the hard disk management method according to any one of claims 1 to 6 when the instructions are executed.
10. A device comprising at least one processor, and at least one memory and bus connected to the processor; wherein: The processor and the memory communicate with each other via the bus; The processor is used to call the program instructions in the memory to execute the hard disk management method according to any one of claims 1-6.
