Equipment naming method and device, computer equipment and storage medium
By obtaining device slot number information and generating a sorting table, assigning parameter value naming to each device, the problem of naming disorder during initialization of hardware devices on the PCIE bus is solved, and the efficiency of device management and simplicity of operation and maintenance are improved.
Patent Information
- Application Number
- CN202410861312.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-15
AI Technical Summary
When the hardware devices mounted on the PCIE bus are initialized, due to the difference in initialization time of the nvme devices, the device naming is out of order, affecting device management efficiency and operation and maintenance difficulty.
By obtaining the slot number information of the device, a device sorting table is generated based on the preset sorting method, assigning parameter values and naming each device to ensure that the device name is consistent with the physical location and avoid out-of-order problems caused by different initialization times.
It effectively reduces the probability of device naming disorder, simplifies device management, improves operation and maintenance efficiency, ensures that the corresponding relationship between device names and physical locations is consistent, and reduces operation and maintenance complexity.
Smart Images

Figure CN118779016A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of hardware management technology, and in particular to a device naming method, apparatus, computer equipment and storage medium. Background Art
[0002] After scanning the hardware devices mounted on the PCIE / PCIE bus and calling their drivers, the scanned hardware devices will be further named based on the scanning order. For example, if multiple nvme hard disks are scanned, an nvme device will be initialized once an nvme device is scanned. When any device is initialized to the nvme controller first, the parameter value will be assigned first, and the device name created by the device will be ranked first. Due to the time difference of nvme initialization, the disorder problem of nvme devices will occur. Summary of the invention
[0003] Based on this, it is necessary to provide a device naming method, apparatus, computer equipment and storage medium that facilitates device management and improves device management efficiency in response to the above technical problems.
[0004] In order to solve the above technical problems, in a first aspect, a device naming method is provided, the method comprising:
[0005] In response to the device being in the initialization stage, obtaining slot number information of the device, sorting the devices based on a preset sorting method and the numbered slot information, and generating a device sorting table;
[0006] Assign parameter values to each device according to the device ranking table;
[0007] Each device is named according to its parameter value.
[0008] In one embodiment, before obtaining the slot number information of the device, the method further includes:
[0009] Determining whether predefined reordering parameters are read in the multi-boot manager;
[0010] If a predefined reordering parameter is read in the multi-boot manager, a device reordering instruction is generated according to the predefined reordering parameter;
[0011] In response to receiving a device reordering instruction, defining a scan terminator;
[0012] The scan end character is used to determine whether the device has completed the scan.
[0013] In one embodiment, sorting the devices based on a preset sorting method and numbered slot information, and generating a device sorting table includes:
[0014] Create a sorting table, each entry in the sorting table includes an entry number, numbered slot information corresponding to the device, and a key value corresponding to the device;
[0015] Creating a hash table based on the sorting table, wherein the row corresponding to each key value in the hash table includes a first pointer variable and a second pointer variable, wherein the first pointer variable stores the entry number of the first appearance of the corresponding key value in the sorting table, and the second pointer variable stores the entry number of the last appearance of the corresponding key value in the sorting table;
[0016] The entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device are used as the target information;
[0017] Generate a device ranking table based on the target information and the hash table.
[0018] In one embodiment, the method further comprises:
[0019] In response to receiving a device scanning instruction, starting a device scanning operation, loading a preset function, and determining whether a device message queue exists in the system;
[0020] If there is a device message queue in the system, the device related information is stored in the device message queue corresponding to the device related information;
[0021] If the device message queue does not exist in the system, a device message queue is created, and device related information is stored in the created device message queue.
[0022] In one embodiment, the method further comprises:
[0023] In response to completion of scanning of any device, obtaining an identification ID corresponding to any device;
[0024] Add the identification ID corresponding to any device to the device message queue created by the preset function.
[0025] In one embodiment, naming each device according to the parameter value of each device includes:
[0026] Obtain the parameter value of each device, and create a target name frame according to the parameter value of each device, wherein the target name frame includes a target field and a target value;
[0027] According to the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework to obtain the name of each device.
[0028] In one embodiment, the method further comprises:
[0029] In response to receiving a device scanning instruction, acquiring scanning information corresponding to the device, the scanning information including scanning speed, scanning data size, and scanning data attributes;
[0030] Determine device scanning priority based on scanning speed, scan data size, and scan data attributes;
[0031] Devices are divided according to device scanning priorities to obtain multiple device scanning sets, and devices in the multiple device scanning sets are assigned to different threads for scanning processing;
[0032] Among them, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes:
[0033] Determine the device scanning priority based on the preset priority calculation formula, scanning speed, scanning data size, and scanning data attributes;
[0034] The default priority calculation formula is:
[0035]
[0036] Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n ].
[0037] In order to solve the above technical problem, in a second aspect, a naming device is provided, the device comprising:
[0038] An acquisition module, configured to acquire slot number information of the device in response to the device being in an initialization phase, sort the devices based on a preset sorting method and the numbered slot information, and generate a device sorting table;
[0039] an allocation module, for allocating parameter values to each device according to the device ranking table;
[0040] The naming module is used to name each device according to the parameter value of each device.
[0041] In order to solve the above technical problem, in the third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: the processor implements the steps of the method described in the first aspect when executing the computer program.
[0042] In order to solve the above technical problem, in a fourth aspect, the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0043] Different from the prior art, the present application obtains the slot numbering information of the device when the device is in the initialization stage, sorts the devices based on a preset sorting method and the numbered slot information, and generates a device sorting table; assigns parameter values to each device according to the device sorting table; names each device according to the parameter value of each device, and thus names the devices using the device slot numbers, and relates the naming of the devices to their physical locations. Once the physical location of the device is determined, its name is also fixed, so that devices at the same physical location will not be named differently due to different initialization times of the devices, thereby reducing the probability of devices being out of order. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a process for naming a device in the prior art;
[0045] Figure 2 A schematic diagram of a flow chart of a device naming method in one embodiment;
[0046] Figure 3 A schematic diagram of a flow chart of a step of setting a scan terminator in an embodiment;
[0047] Figure 4 A schematic diagram of a flow chart of a device naming method in another embodiment;
[0048] Figure 5 A schematic diagram of a flow chart of a device naming method in another embodiment;
[0049] Figure 6 A structural block diagram of a device naming apparatus in an embodiment;
[0050] Figure 7 A structural block diagram of a device naming apparatus in another embodiment;
[0051] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] With the rapid development of servers, the number of PCIE devices in servers is increasing. Due to the increase of PCIE devices, the boot time of Linux operating system will be greatly prolonged. In order to speed up the boot time of operating system, the loading of PCIE devices is changed from serial loading to parallel loading. In particular, the new version of operating system adds async di scovery probing (device asynchronous discovery detection) function PROBE_PREFER_ASYNCHRONOUS (asynchronous loading of device driver), which can speed up the system startup speed.
[0054] With the increase of PROBE_PREFER_ASYNCHRONOUS (asynchronous loading of device drivers), the probability of disordered device startup order when the system starts becomes higher. The relationship between the drive letter of the hard disk and the physical location is weaker. Although the system uses the UUID (Universally Unique Identifier) of the file system or systemdudev, systemd udev: is used to capture device event events. When an event occurs, the corresponding rules file will be read to process the event. Read the unique identifier of the hard disk for rule binding optimization. However, the bound device information is not accepted by people due to its non-usability, causing the disorder problem to plague end users. For example, for sata disks, the system names are sda, sdb... These names have become accustomed to people. Udev rules, Udev rules are tools for managing device files in the Linux system. It runs as a daemon process and manages the device files in the / dev directory by listening to uevent sent by the kernel. After binding, these names still exist in the system and will not disappear. Therefore, this will result in using the system default sda name when you are not used to it, causing problems such as data loss.
[0055] Take nvme hard disk as an example. When the system is initialized, after scanning the nvme device, the nvme driver is loaded for initialization. When the nvme controller is initialized, the instance value is assigned according to the initialization time sequence. When the block device is created, it is named according to the instance value. For example, it is named nvme1, nvme2, etc.
[0056] Specific reference Figure 1: After scanning the hardware devices mounted on the PCI / PCIE bus and calling their drivers, the scanned hardware devices will be further named based on the scanning order. For example, if multiple nvme hard disks are scanned, an nvme device will be initialized when an nvme device is scanned. When any device is initialized to the controller of the nvme device first, the parameter value will be assigned first, and the device name of the device will be ranked first when it is created. Due to the time difference of nvme initialization, the disorder problem of nvme devices will occur.
[0057] In addition, due to the parallel processing mechanism of modern operating systems to accelerate system startup and operation speeds, there is no corresponding relationship between the device name and the actual physical location, and there is no pattern to follow. The physical hard disk inserted in the first slot is not necessarily / dev / sda or hard disk 0, it may be / dev / sdc or hard disk 1 or other. Users cannot know which hard disk it is by the name of the hard disk device. It is necessary to use a series of query commands in the system (first query the controller number, then query the slot number) and the CPLD or BMC light-up instructions to locate the specific physical hard disk (first query the vpp address corresponding to the slot, and then use ipmitool raw to light it). It requires step-by-step operation. It will be difficult for non-professionals to remember or accurately execute these commands. This situation has increased the difficulty of operation and maintenance, especially the operation and maintenance of medium and large data centers, which will become complicated and prone to errors.
[0058] In order to solve the above technical problems, in one embodiment, Figure 2 As shown, the present application provides a device naming method, which specifically includes the following steps:
[0059] Step 201, in response to the device being in the initialization stage, obtaining the slot number information of the device, sorting the devices based on a preset sorting method and the numbered slot information, and generating a device sorting table.
[0060] The device in this application may be a hard disk device, and this application takes the device as an nvme hard disk as an example for description. During the device initialization phase, all devices may be scanned, and the slot number information of the device may be read through the PCIE bus. The slot number information here may be the physical slot number of the PCIE connected to the device.
[0061] Among them, sorting the devices based on a preset sorting method and number slot information, generating a device sorting table may include: creating a sorting table, each entry in the sorting table includes an entry number, the number slot information corresponding to the device, and the key value corresponding to the device; creating a hash table based on the sorting table, the rows in the hash table corresponding to each key value include a first pointer variable and a second pointer variable, the first pointer variable stores the entry number of the corresponding key value when it first appears in the sorting table, and the second pointer variable stores the entry number of the corresponding key value when it last appears in the sorting table; using the entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device as target information; generating a device sorting table based on the target information and the hash table.
[0062] Specifically, the device-related information can be obtained, and a sorting table can be created based on the keywords contained in the device-related information. The device-related information may include device slot number information, device number information, device type information, etc., and the corresponding keywords may be slot number, device number, and device type. Each entry includes an entry number, the numbered slot information corresponding to the device, the key value corresponding to the device, the device number, and the device type. The entry number is a number that represents the order of each entry. Taking each entry as the basic dimension, fill in the corresponding information of the device under the corresponding entry. The device slot number can be expressed in the form of a key value, and the device slot number can be converted into a key value in numerical form. According to the numerical value of the key value, the key values can be sorted in order from small to large, and then a sorting table can be created.
[0063] You can choose to create a sorted table using various existing sorting methods such as bubble sort, quick sort, simple sort, shell sort, simple selection sort, heap sort, two-way merge sort, multi-way merge sort, counting sort, bucket sort, radix sort, etc.
[0064] A hash table is a data table that determines the entry corresponding to a key value in a sorted table according to the hash value of the key value. The rows corresponding to each key value in the hash table include a first pointer variable and a second pointer variable. The first pointer variable stores the entry number of the first appearance of the corresponding key value in the sorted table, and the second pointer variable stores the entry number of the last appearance of the corresponding key value in the sorted table. In other words, the first pointer variable and the second pointer variable can determine the entry range of a specific key value in the sorted table.
[0065] For example, in one embodiment, the key value is composed of the device slot number and the device related information other than the device slot number. Assuming that the device related information other than the device slot number is the device type, the device type can be converted into letters. For example, a device key value can be 11F, where 11 represents the device slot number and F represents the type of device. Assuming that the first row in the hash table corresponds to a row with a key value of XXF, the first pointer variable in the first row points to the 0th row in the sort table, and the second pointer variable points to the 3rd row in the sequence table, that is, the key values corresponding to the 0th to 3rd rows in the sort table all include F. In this way, devices of any type of information can be quickly located according to the combination of different key values, and the devices can be searched and analyzed later.
[0066] After obtaining the sorting table and hash table through the above steps, the entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device can be extracted as the target information. The target information here acts as an index. The corresponding hash table and sorting table are located through the index, and the information of the hash table and sorting table is sorted to generate a device sorting table.
[0067] In one embodiment, before obtaining the slot number information of the device, it also includes: determining whether a predefined reordering parameter is read; if the predefined reordering parameter is read, generating a device reordering instruction according to the predefined reordering parameter; in response to receiving the device reordering instruction, defining a scan terminator; the scan terminator is used to determine whether the device has completed the scan.
[0068] Specifically, it is checked whether a predefined reordering parameter is added in grub (multi-boot manager). The predefined reordering parameter can be a string of a certain length. The specific form of the predefined reordering parameter is not limited. It is sufficient to associate the predefined reordering parameter with the generated device reordering instruction. If the reordering parameter is added, it means that the device needs to be named, and the device reordering instruction is generated according to the predefined reordering parameter.
[0069] See also Figure 3 , when receiving the device reordering instruction (shown as the start condition), the PCIE device starts scanning the nvme device and defines the scan end character (define the scan end identifier). For example, the scan end character can be PCIE_end, and the value of the scan end character is set to false to determine whether the PCIE device has completed the scan of all nvme devices. When the PCIE completes the detection scan of all devices, this value is set to true. That is: PCIE_end = true; use this parameter to ensure that all devices can be scanned. There will be no problem of missing devices from scanning.
[0070] In one embodiment, when a device scan instruction is received, a preset function is loaded, and based on the preset function, it is determined whether there is a device message queue in the system. If there is a device message queue in the device, the device-related information is stored in the device message queue corresponding to the device-related information. If there is no device message queue in the system, a device message queue is created, and the device-related information is stored in the created device message queue. In this application, as long as a device is scanned, the identification ID of the scanned device needs to be added to the device message queue created by the preset function. The identification ID can specifically be a PCIE bus ID. Through the above embodiment, the system reliability can be improved.
[0071] In one embodiment, when a device scanning instruction is received, scanning information corresponding to the device is obtained, and the scanning information includes scanning speed, scanning data size, and scanning data attributes; the device scanning priority is determined based on the scanning speed, scanning data size, and scanning data attributes; the devices are divided according to the device scanning priority to obtain multiple device scanning sets, and the devices in the multiple device scanning sets are assigned to different threads for scanning processing.
[0072] Wherein, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes: determining the device scanning priority based on a preset priority calculation formula, the scanning speed, the scanning data size, and the scanning data attribute; the preset priority calculation formula is:
[0073]
[0074] Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n ].
[0075] In this embodiment, after obtaining the priority of each device through the priority calculation formula, the devices can be divided into multiple levels according to the priority of each device, and the devices of each level can be placed in the same device scan set. The devices in the same scan set can be assigned to the same thread for processing, which greatly improves the scanning efficiency.
[0076] In a feasible implementation, before receiving the device scanning instruction, the device type may be obtained, the device failure event may be obtained according to the device type, and the device status may be determined according to the device failure event.
[0077] Specifically, each device may be classified. Each category may indicate the type of damage or defect that exists. The classification of each device may also help determine whether the disk should be discarded or used in a storage device. Classification may also help predict where certain defects or damage may exist.
[0078] Specifically, the device is scanned through multiple tracks to generate a scanning trajectory, a sparse map is generated based on the scanning trajectory, and the sparse map generated by the scanning trajectory is evaluated through a machine learning algorithm.
[0079] Multiple tracks can be set based on keywords of relevant information of the equipment. For example, when the equipment type is used as a keyword, each equipment type can be used as a track, and finally multiple tracks are obtained. The equipment is scanned according to multiple tracks to check the equipment fault corresponding to each track. A scanning trajectory is generated according to each track and the path of the equipment fault type found through the track. Sparse scanning can be used to classify or inspect equipment faster than traditional methods. This can be achieved by scanning only part of the equipment and using one or more compressed sensing machine learning processes to infer the remaining unscanned parts that are sufficient to make one or more judgments about the equipment.
[0080] Defects and damage found during scanning can be converted into an image, which can then be guided as input to one or more machine learning processes (such as CNN). In this way, CNNs developed to process images can be used to process and identify potential equipment defects and damage. For example, a compressed sensing process can receive a limited set of information as input and generate an output that attempts to fill in areas of missing information. Therefore, a partially scanned device can be processed by a CNN to generate a more complete image of potential defects and damage on the device, thereby classifying it when the partial scan itself cannot provide data. In order for this to happen. Using CNN to classify equipment using reconstructed image data from partially scanned equipment can greatly reduce the time required to perform initial inspections before deployment.
[0081] The sparse map generated by the scanning trajectory can be subjected to feature extraction through a machine learning algorithm to obtain a first feature vector. The above processing is performed on the equipment in good condition to obtain a second feature vector. The similarity between the first feature vector and the second feature vector is calculated. When the similarity between the first feature vector and the second feature vector is greater than a threshold value, it is considered that the current equipment status is normal and subsequent operations can be performed.
[0082] Step 202: assign parameter values to each device according to the device ranking table.
[0083] After obtaining the device ranking through the above steps, the arrangement order of each device in the device ranking table can be obtained to assign a parameter value to each device. The parameter value here can specifically be an instance value.
[0084] Step 203: Name each device according to the parameter value of each device.
[0085] After obtaining the parameter value of each device according to the above steps, the parameter value of each device can be used as the name of each device to name each device.
[0086] Specifically, the parameter value of each device can be obtained, and a target name framework can be created based on the parameter value of each device. The target name framework includes a target field and a target value. Based on the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework and obtain the name of each device.
[0087] Exemplarily, the target name framework may be a device type + a device parameter value. For example, a specific target name may be nvme10, wherein nvme indicates that the device is an nvme hard disk, and 10 is the device parameter value and also the arrangement order of the devices.
[0088] This application generates a device sorting table based on the device slot information, assigns parameter values to each device based on the device sorting table, and uses the parameter values to name each device. In this way, the device slot number is associated with the device name, so that the operator can obtain the physical location information of the device based on the device parameter value, simplifying the operation and maintenance operations, making device management simple, efficient and accurate. The naming is simpler and shorter and more easily accepted by customers. At the same time, it avoids the problem of disorder or drift of devices caused by the traditional device naming that does not correspond to the actual physical location of the device.
[0089] In one embodiment, in order to better illustrate the device naming method of the present application, a specific example is described. Figure 4 as well as Figure 5 , the specific steps are as follows:
[0090] 1. Check whether the nvme reordering parameter nvme_order (predefined reordering parameter) is added in grub (multi-boot manager). If the parameter is added, start nvme reordering (generate device reordering instructions). If the verification result shows that the parameter is not added, initialize the nvme device according to the default PCIE initialization mode ( Figure 1 in the naming method).
[0091] 2. Define the scan end character PCIE_end. When scanning the PCIEroot port, define the PCIE scan end character PCIE_end. And set this value to false. When PCIE completes all device detection scans, set this value to true. That is: PCIE_end = true; use this parameter to ensure that all nvme devices can be scanned. There will be no problem of missing scans.
[0092] 3. Define the nvme_reorder function (preset function) and start nvme settings reordering.
[0093] (1) When the nvme device is identified during PCIE scanning, the nvme_reorder function (preset function) is loaded.
[0094] (2) After the nvme_reorder function is loaded (preset function), first determine whether the nvme device information queue (device message queue) exists. If it does not exist, create this queue and add the nvme device information to it (create a device message queue and store device-related information in the created device message queue). The function of this queue is to save the information of the nvme device, such as PCIE bus id (PCIE bus ID) and other information. If it exists, there is no need to create this queue, and directly add the nvme device information to the existing queue.
[0095] (3) During the entire process of PCIE device scanning, once the nvme device is identified, the nvme device bus id and other information are added to the queue created by the nvme_reorder function (preset function).
[0096] (4) Read the PCIE scan end character. When the PCIE scan end character is False, it means that the PCIE scan has not been completed. It cannot be guaranteed that all nvme devices have been scanned. At this time, it is necessary to loop to read the PCIE scan end character. Until the value of the PCIE scan end character is True. When the PCIE scan end character is True, it means that all PCIE devices have been scanned. All nvme device information has been saved in the nvme device message queue. At this time, the nvme device reordering instruction is started.
[0097] (5) After the PCIE scan terminator is True, start reordering the nvme device. According to the nvme bus id information, read the slot information of the nvme device from the acpi table to obtain the slot number. The acpi table: Advanced Configuration and Power Interface is created by BIOS / UEFI to collect various system information during the system startup phase. Write the value of the slot number (slot number information) into the device information. Then sort the nvme slotnumber (slot number information) from small to large. Then, according to the order of the solt number (slot number information), set the initial value of the nvme instance (parameter value). The value of the instance (parameter value) increases from small to large starting from 0. And save the value of the instance (parameter value) to the nvme device related information.
[0098] (6) After nvme is reordered, nvme driver loading is started from small to large according to the reordered nvme devices. There is no need to wait for the previous device to complete loading, but all nvme devices are initialized at the same time.
[0099] (7) When initializing nvme control, a block (device name) corresponding to the nvme device will be created. At this time, the instance value (parameter value) set in step (5) is directly read according to the nvme information, and the block (device name) corresponding to nvme is created according to this value and named after the instance result. For example, nvme0, nvme1, nvme2...nvmeN, etc.
[0100] (8) After creating the block (device name), continue to complete other initialization processes of the nvme device until the nvme device initialization (device scan) process is completed.
[0101] By setting up to scan all nvme devices first when PCIE detects devices and initializes, and then read the slot id information (slot number information) of the device in acpitable, sort the nvme from small to large according to the slot id information (slot number information) provided by acpi, and assign the nvmeinstance value (parameter value) to the nvme device according to the arrangement order after the sorting is completed. When the nvme device driver is loaded and initialized to the nvme controller part, the assigned instance value is directly read, and the device is named with this value, so that the device name will be bound to the order of the slot number information after the system initialization is completed. Since the name of the nvme device is bound to the order of the slot id, as long as the slot id does not change, the name of the nvme device will not change, thus solving the problem of nvme disorder.
[0102] And when PCIE is initialized during the system startup process, the nvme devices are reordered according to the slot id value of the device, and the instance value is initialized in sequence. When creating the nvme block device, it is created according to the initialized instance value. Ensure that the name of the nvme device remains consistent at each startup to solve the problem of hard disk disorder. According to the slot number information of the device, the nvme devices are sorted in the order specified by the hardware during the system startup process. The nvme devices will maintain a fixed name each time the system restarts, thereby solving the problem of hard disk disorder. This method completes the nvme reordering autonomously when the system starts, so compared with other system disorder solutions, the advantage is that the end user is not aware of it. In addition, this method is controlled by system parameters. If the user has no requirements for the nvme drive letter, the corresponding function can be turned off through this parameter.
[0103] It should be understood that although Figure 2-Figure 5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 5 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0104] In one embodiment, Figure 6As shown, a device naming apparatus is provided, comprising: an acquisition module 60, an allocation module 61 and a naming module 62, wherein:
[0105] An acquisition module 60, configured to acquire slot number information of the device in response to the device being in the initialization stage, sort the devices based on a preset sorting method and the numbered slot information, and generate a device sorting table;
[0106] an allocation module 61, configured to allocate a parameter value to each device according to the device ranking table;
[0107] The naming module 62 is used to name each device according to the parameter value of each device.
[0108] See also Figure 7 The device naming device in the present application also includes a sorting module and a driver loading module, wherein the PCIE device scans the nvme device to obtain all the nvme devices (obtain the slot number information of the nvme device). The sorting module sorts the nvme devices according to the slot number information of the nvme device, and the allocation module allocates parameter values (allocates instance values) to each device according to the sorting. The driver loading module obtains the allocated instance value and creates a block (device name) according to the allocated instance value.
[0109] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0110] Before getting the slot number information of the device, also include:
[0111] Determining whether predefined reordering parameters are read in the multi-boot manager;
[0112] If a predefined reordering parameter is read in the multi-boot manager, a device reordering instruction is generated according to the predefined reordering parameter;
[0113] In response to receiving a device reordering instruction, defining a scan terminator;
[0114] The scan end character is used to determine whether the device has completed the scan.
[0115] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0116] Sorting the devices based on the preset sorting method and number slot information, generating a device sorting table includes:
[0117] Create a sorting table, each entry in the sorting table includes an entry number, numbered slot information corresponding to the device, and a key value corresponding to the device;
[0118] Creating a hash table based on the sorting table, wherein the row corresponding to each key value in the hash table includes a first pointer variable and a second pointer variable, wherein the first pointer variable stores the entry number of the first appearance of the corresponding key value in the sorting table, and the second pointer variable stores the entry number of the last appearance of the corresponding key value in the sorting table;
[0119] The entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device are used as the target information;
[0120] Generate a device ranking table based on the target information and the hash table.
[0121] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0122] The method also includes:
[0123] In response to receiving a device scanning instruction, starting a device scanning operation, loading a preset function, and determining whether a device message queue exists in the system;
[0124] If there is a device message queue in the system, the device related information is stored in the device message queue corresponding to the device related information;
[0125] If the device message queue does not exist in the system, a device message queue is created, and device related information is stored in the created device message queue.
[0126] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0127] The method also includes:
[0128] In response to completion of scanning of any device, obtaining an identification ID corresponding to any device;
[0129] Add the identification ID corresponding to any device to the device message queue created by the preset function.
[0130] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0131] Naming each device based on its parameter values includes:
[0132] Obtain the parameter value of each device, and create a target name frame according to the parameter value of each device, wherein the target name frame includes a target field and a target value;
[0133] According to the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework to obtain the name of each device.
[0134] In one embodiment, another implementation of the device naming method that can be implemented by the above apparatus includes the following specific steps:
[0135] The method also includes:
[0136] In response to receiving a device scanning instruction, acquiring scanning information corresponding to the device, the scanning information including scanning speed, scanning data size, and scanning data attributes;
[0137] Determine device scanning priority based on scanning speed, scan data size, and scan data attributes;
[0138] Devices are divided according to device scanning priorities to obtain multiple device scanning sets, and devices in the multiple device scanning sets are assigned to different threads for scanning processing;
[0139] Among them, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes:
[0140] Determine the device scanning priority based on the preset priority calculation formula, scanning speed, scanning data size, and scanning data attributes;
[0141] The default priority calculation formula is:
[0142]
[0143] Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n ].
[0144] For the specific definition of the device naming device, please refer to the definition of the device naming method above, which will not be repeated here. Each module in the above-mentioned device naming device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0145] In one embodiment, the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the device naming methods provided by the above methods.
[0146] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data used in the device naming method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a device naming method is implemented.
[0147] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0148] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0149] Step 201, in response to the device being in the initialization stage, obtaining the slot number information of the device, sorting the devices based on a preset sorting method and the numbered slot information, and generating a device sorting table.
[0150] Step 202: assign parameter values to each device according to the device ranking table.
[0151] Step 203: Name each device according to the parameter value of each device.
[0152] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0153] Before getting the slot number information of the device, also include:
[0154] Determining whether predefined reordering parameters are read in the multi-boot manager;
[0155] If a predefined reordering parameter is read in the multi-boot manager, a device reordering instruction is generated according to the predefined reordering parameter;
[0156] In response to receiving a device reordering instruction, defining a scan terminator;
[0157] The scan end character is used to determine whether the device has completed the scan.
[0158] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0159] Sorting the devices based on the preset sorting method and number slot information, generating a device sorting table includes:
[0160] Create a sorting table, each entry in the sorting table includes an entry number, numbered slot information corresponding to the device, and a key value corresponding to the device;
[0161] Creating a hash table based on the sorting table, wherein the row corresponding to each key value in the hash table includes a first pointer variable and a second pointer variable, wherein the first pointer variable stores the entry number of the first appearance of the corresponding key value in the sorting table, and the second pointer variable stores the entry number of the last appearance of the corresponding key value in the sorting table;
[0162] The entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device are used as the target information;
[0163] Generate a device ranking table based on the target information and the hash table.
[0164] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0165] The method also includes:
[0166] In response to receiving a device scanning instruction, starting a device scanning operation, loading a preset function, and determining whether a device message queue exists in the system;
[0167] If there is a device message queue in the system, the device related information is stored in the device message queue corresponding to the device related information;
[0168] If the device message queue does not exist in the system, a device message queue is created, and device related information is stored in the created device message queue.
[0169] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0170] The method also includes:
[0171] In response to completion of scanning of any device, obtaining an identification ID corresponding to any device;
[0172] Add the identification ID corresponding to any device to the device message queue created by the preset function.
[0173] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0174] Naming each device based on its parameter values includes:
[0175] Obtain the parameter value of each device, and create a target name frame according to the parameter value of each device, wherein the target name frame includes a target field and a target value;
[0176] According to the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework to obtain the name of each device.
[0177] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0178] In response to receiving a device scanning instruction, acquiring scanning information corresponding to the device, the scanning information including scanning speed, scanning data size, and scanning data attributes;
[0179] Determine device scanning priority based on scanning speed, scan data size, and scan data attributes;
[0180] Devices are divided according to device scanning priorities to obtain multiple device scanning sets, and devices in the multiple device scanning sets are assigned to different threads for scanning processing;
[0181] Among them, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes:
[0182] Determine the device scanning priority based on the preset priority calculation formula, scanning speed, scanning data size, and scanning data attributes;
[0183] The default priority calculation formula is:
[0184]
[0185] Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n].
[0186] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0187] Step 201, in response to the device being in the initialization stage, obtaining the slot number information of the device, sorting the devices based on a preset sorting method and the numbered slot information, and generating a device sorting table.
[0188] Step 202: assign parameter values to each device according to the device ranking table.
[0189] Step 203: Name each device according to the parameter value of each device.
[0190] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0191] Before getting the slot number information of the device, also include:
[0192] Determining whether predefined reordering parameters are read in the multi-boot manager;
[0193] If a predefined reordering parameter is read in the multi-boot manager, a device reordering instruction is generated according to the predefined reordering parameter;
[0194] In response to receiving a device reordering instruction, defining a scan terminator;
[0195] The scan end character is used to determine whether the device has completed the scan.
[0196] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0197] Sorting the devices based on the preset sorting method and number slot information, generating a device sorting table includes:
[0198] Create a sorting table, each entry in the sorting table includes an entry number, numbered slot information corresponding to the device, and a key value corresponding to the device;
[0199] Creating a hash table based on the sorting table, wherein the row corresponding to each key value in the hash table includes a first pointer variable and a second pointer variable, wherein the first pointer variable stores the entry number of the first appearance of the corresponding key value in the sorting table, and the second pointer variable stores the entry number of the last appearance of the corresponding key value in the sorting table;
[0200] The entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device are used as the target information;
[0201] Generate a device ranking table based on the target information and the hash table.
[0202] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0203] The method also includes:
[0204] In response to receiving a device scanning instruction, starting a device scanning operation, loading a preset function, and determining whether a device message queue exists in the system;
[0205] If there is a device message queue in the system, the device related information is stored in the device message queue corresponding to the device related information;
[0206] If the device message queue does not exist in the system, a device message queue is created, and device related information is stored in the created device message queue.
[0207] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0208] The method also includes:
[0209] In response to completion of scanning of any device, obtaining an identification ID corresponding to any device;
[0210] Add the identification ID corresponding to any device to the device message queue created by the preset function.
[0211] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0212] Naming each device based on its parameter values includes:
[0213] Obtain the parameter value of each device, and create a target name frame according to the parameter value of each device, wherein the target name frame includes a target field and a target value;
[0214] According to the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework to obtain the name of each device.
[0215] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0216] In response to receiving a device scanning instruction, acquiring scanning information corresponding to the device, the scanning information including scanning speed, scanning data size, and scanning data attributes;
[0217] Determine device scanning priority based on scanning speed, scan data size, and scan data attributes;
[0218] Devices are divided according to device scanning priorities to obtain multiple device scanning sets, and devices in the multiple device scanning sets are assigned to different threads for scanning processing;
[0219] Among them, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes:
[0220] Determine the device scanning priority based on the preset priority calculation formula, scanning speed, scanning data size, and scanning data attributes;
[0221] The default priority calculation formula is:
[0222]
[0223] Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n ].
[0224] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0225] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0226] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A device naming method, characterized in that: include: In response to the device being in the initialization stage, obtaining slot number information of the device, sorting the devices based on a preset sorting method and the numbered slot information, and generating a device sorting table; assigning a parameter value to each device according to the device ranking table; Each device is named according to its parameter value.
2. The method according to claim 1, characterized in that The step of obtaining the slot number information of the device also includes: Determining whether predefined reordering parameters are read in the multi-boot manager; If a predefined reordering parameter is read in the multi-boot manager, a device reordering instruction is generated according to the predefined reordering parameter; In response to receiving a device reordering instruction, defining a scan terminator; The scan end character is used to determine whether the device has completed the scan.
3. The method according to claim 1, characterized in that The device sorting method based on the preset sorting method and the numbered slot information is used to sort the devices, and the device sorting table is generated, comprising: Creating a sorting table, each entry in the sorting table includes an entry number, numbered slot information corresponding to a device, and a key value corresponding to the device; Creating a hash table based on the sorting table, wherein the row corresponding to each key value in the hash table includes a first pointer variable and a second pointer variable, wherein the first pointer variable stores the entry number of the corresponding key value when it first appears in the sorting table, and the second pointer variable stores the entry number of the corresponding key value when it last appears in the sorting table; The entry number in the sorting table, the number slot information corresponding to the device, and the key value corresponding to the device are used as target information; A device ranking table is generated based on the target information and the hash table.
4. The method according to claim 1, characterized in that The method further comprises: In response to receiving a device scanning instruction, starting a device scanning operation, loading a preset function, and determining whether a device message queue exists in the system; If there is a device message queue in the system, the device related information is stored in the device message queue corresponding to the device related information; If the device message queue does not exist in the system, a device message queue is created, and device related information is stored in the created device message queue.
5. The method according to claim 1, characterized in that The method further comprises: In response to completion of scanning of any device, obtaining an identification ID corresponding to any device; Add the identification ID corresponding to any one of the devices to the device message queue created by the preset function.
6. The method according to claim 1, characterized in that The naming of each device according to the parameter value of each device includes: Obtaining a parameter value of each device, and creating a target name frame according to the parameter value of each device, wherein the target name frame includes a target field and a target value; According to the correspondence between the target name and the device, the parameter value of each device is used as the target value corresponding to each device to fill the target name framework to obtain the name of each device.
7. The method according to claim 1, characterized in that The method further comprises: In response to receiving a device scanning instruction, acquiring scanning information corresponding to the device, the scanning information including scanning speed, scanning data size, and scanning data attributes; Determine a device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute; Devices are divided according to device scanning priorities to obtain multiple device scanning sets, and devices in the multiple device scanning sets are assigned to different threads for scanning processing; Wherein, determining the device scanning priority according to the scanning speed, the scanning data size, and the scanning data attribute includes: Determine the device scanning priority based on a preset priority calculation formula, the scanning speed, the scanning data size, and the scanning data attribute; The preset priority calculation formula is: Among them, S i is the scanning priority of device i, X i is the parameter value of device i, Y i is the scan data size of device i, Y i is the scanning speed of device i, is the scan data type feature vector of device i, M is the device set, M∈[M1,M2M3......M n ].
8. A device naming apparatus, characterized in that: The device comprises: An acquisition module, configured to acquire slot number information of a device in response to the device being in an initialization phase, sort the devices based on a preset sorting method and the numbered slot information, and generate a device sorting table; an allocation module, configured to allocate a parameter value to each device according to the device ranking table; The naming module is used to name each device according to the parameter value of each device.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
