A bandwidth adjustment method and device, electronic equipment and storage medium
By detecting changes in hard drive connection status, the total bandwidth of PCIe devices is dynamically allocated to the target hard drive, solving the problem of wasted bandwidth resources caused by insufficient hard drive installation and improving hard drive read and write performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-29
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, when server hard drives are not fully configured, it leads to a waste of bandwidth resources for PCIe devices.
By detecting changes in hard drive connection status, the total bandwidth of the PCIe device is obtained and dynamically allocated to the target hard drive to adjust the hard drive's bandwidth to match the sub-bandwidth of the backplane hard drive slot.
This allows for full utilization of the hard drive even when it is not fully utilized, improving hard drive read and write performance and avoiding waste of bandwidth resources.
Smart Images

Figure CN116150067B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, in particular to a bandwidth adjustment method, a bandwidth adjustment device, an electronic device and a computer readable storage medium. BACKGROUND
[0002] In the use of a server, when the server reads and writes a hard disk, signal and data transmission can be performed through a PCIe (peripheral component interconnect express, high-speed serial computer expansion bus standard) device. In the existing technical solution, the number of hard disks and the bandwidth of the hard disks matched with the server are generally fixed. For example, when the total bandwidth of the PCIe device is X16 and the transmission bandwidth of the X16 bandwidth is 32 Gb / S, and the number of slots on the PCIe device is 4, at most 4 hard disks can be installed, and the bandwidth of each hard disk is fixed, and the bandwidth is X4. For another example, when the total bandwidth of the PCIe device is X16 and the number of slots on the PCIe device is 8, at most 8 hard disks can be installed, and the bandwidth of each hard disk is X2. In this way, when the number of hard disks installed on the device is not full, the problem of bandwidth resource waste will occur. SUMMARY
[0003] In view of the above problems, the present application embodiments are proposed to provide a bandwidth adjustment method, a bandwidth adjustment device, an electronic device and a computer readable storage medium which overcome the above problems or at least partially solve the above problems.
[0004] In a first aspect, the present application embodiments disclose a bandwidth adjustment method, which is applied to a server, the server has a PCIe (peripheral component interconnect express, high-speed serial computer expansion bus standard) device, the PCIe device includes a backplane hard disk slot, the backplane hard disk slot is connected with at least one hard disk, and the method comprises:
[0005] detecting a connection state of the hard disk, determining at least one target hard disk currently connected with the backplane hard disk slot when the connection state changes;
[0006] obtaining a total bandwidth of the PCIe device;
[0007] allocating the total bandwidth of the PCIe device to the at least one target hard disk respectively.
[0008] Optionally, after the detection of the connection state of the hard disk and the determination of the at least one target hard disk currently connected with the backplane hard disk slot when the connection state changes, the method further comprises:
[0009] obtaining a hard disk quantity of the at least one target hard disk, a slot quantity of the backboard hard disk slot, and a slot quantity of a target backboard hard disk slot; the target backboard hard disk slot is a backboard hard disk slot connected with the at least one target hard disk;
[0010] the step of allocating the total bandwidth of the PCIe device to the at least one target hard disk respectively comprises:
[0011] dividing the total bandwidth of the PCIe device to obtain at least one sub-bandwidth; the number of the sub-bandwidth is same as the hard disk quantity;
[0012] allocating the sub-bandwidth to the target backboard hard disk slot respectively according to the slot quantity of the target backboard hard disk slot;
[0013] adjusting the bandwidth of the at least one target hard disk corresponding to the target backboard hard disk slot according to the sub-bandwidth allocated to the target backboard hard disk slot, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backboard hard disk slot.
[0014] Optionally, the step of dividing the total bandwidth of the PCIe device to obtain at least one sub-bandwidth comprises:
[0015] calculating a hard disk reference quantity according to the slot quantity of the backboard hard disk slot; the hard disk reference quantity is less than the slot quantity;
[0016] calculating a first reference bandwidth value and a second reference bandwidth value according to the total bandwidth of the PCIe device and the slot quantity; the first reference bandwidth value is greater than the second reference bandwidth value;
[0017] dividing the total bandwidth of the PCIe device to obtain at least one sub-bandwidth according to the hard disk quantity, the slot quantity, the hard disk reference quantity, the first reference bandwidth value and the second reference bandwidth value.
[0018] Optionally, the step of dividing the total bandwidth of the PCIe device to obtain at least one sub-bandwidth according to the hard disk quantity, the slot quantity, the hard disk reference quantity, the first reference bandwidth value and the second reference bandwidth value comprises:
[0019] when the hard disk quantity is less than or equal to the hard disk reference quantity, dividing the total bandwidth of the PCIe device into sub-bandwidths with the same hard disk quantity and the same first reference bandwidth value.
[0020] Optionally, the dividing the total bandwidth of the PCIe device according to the number of hard disks, the number of slots, the number of reference hard disks, the first reference bandwidth value and the second reference bandwidth value, to obtain at least one sub-bandwidth, comprises:
[0021] When the number of hard disks is greater than the number of reference hard disks and less than the number of slots, according to the number of slots and the number of hard disks, a first division number of bandwidth values is calculated as the first reference bandwidth value, and a second division number of bandwidth values is calculated as the second reference bandwidth value;
[0022] The total bandwidth of the PCIe device is divided into sub-bandwidths with the same number as the first division number and the same value as the first reference bandwidth value, and sub-bandwidths with the same number as the second division number and the same value as the second reference bandwidth value.
[0023] Optionally, the dividing the total bandwidth of the PCIe device according to the number of hard disks, the number of slots, the number of reference hard disks, the first reference bandwidth value and the second reference bandwidth value, to obtain at least one sub-bandwidth, comprises:
[0024] When the number of hard disks is equal to the number of slots, the total bandwidth of the PCIe device is divided into sub-bandwidths with the same number as the number of hard disks and the same value as the second reference bandwidth value.
[0025] Optionally, the adjusting the bandwidth of the at least one target hard disk corresponding to the target backplane hard disk slot according to the sub-bandwidth of the target backplane hard disk slot allocation, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backplane hard disk slot, comprises:
[0026] A first target backplane hard disk slot is determined from the target backplane hard disk slots in ascending order of the slot number; the number of the first target backplane hard disk slots is the same as the first division number;
[0027] The first target backplane hard disk slots are allocated bandwidth so that the sub-bandwidth of the first target backplane hard disk slots is the first reference bandwidth value, and the second target backplane hard disk slots are allocated bandwidth so that the sub-bandwidth of the second target backplane hard disk slots is the second reference bandwidth value; the second target backplane hard disk slots are the target backplane hard disk slots remaining except the first target backplane hard disk slots;
[0028] adjusting bandwidths of a first target hard disk corresponding to the first target backplane hard disk slot and a second target hard disk corresponding to the second target backplane hard disk slot, so that the bandwidth of the first target hard disk is consistent with a sub-bandwidth of the first target backplane hard disk slot, and the bandwidth of the second target hard disk is consistent with a sub-bandwidth of the second target backplane hard disk slot.
[0029] Optionally, the calculating the first reference bandwidth value and the second reference bandwidth value according to the total bandwidth of the PCIe device and the number of slots comprises:
[0030] taking a quotient of the total bandwidth of the PCIe device and the number of slots as the second reference bandwidth value;
[0031] taking a product of the second reference bandwidth value and a preset coefficient as the first reference bandwidth value.
[0032] In a second aspect, an embodiment of the present application discloses a bandwidth adjustment device, which is applied to a server, the server has a Peripheral Component Interconnect Express (PCIe) device, the PCIe device comprises a backplane hard disk slot, the backplane hard disk slot is connected with at least one hard disk, and the device comprises:
[0033] a determination module, which is used for detecting a connection state of the hard disk, and determining at least one target hard disk currently connected with the backplane hard disk slot when the connection state changes;
[0034] a first acquisition module, which is used for acquiring a total bandwidth of the PCIe device;
[0035] a distribution module, which is used for distributing the total bandwidth of the PCIe device to the at least one target hard disk respectively.
[0036] Optionally, the device further comprises:
[0037] second acquiring a number of hard disks of the at least one target hard disk, a number of slots of the backplane hard disk slot, and a number of slots of a target backplane hard disk slot; the target backplane hard disk slot is a backplane hard disk slot connected with the at least one target hard disk;
[0038] the distribution module comprises:
[0039] a division sub-module, which is used for dividing the total bandwidth of the PCIe device to obtain at least one sub-bandwidth; the number of sub-bandwidths is the same as the number of hard disks;
[0040] a distribution sub-module, which is used for distributing the sub-bandwidths to the target backplane hard disk slot according to the number of slots of the target backplane hard disk slot;
[0041] The adjusting sub-module is configured to adjust the bandwidth of the at least one target hard disk corresponding to the target backboard hard disk slot according to the sub-bandwidth allocated to the target backboard hard disk slot, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backboard hard disk slot.
[0042] Optionally, the dividing sub-module comprises:
[0043] The first calculating unit is configured to calculate a hard disk reference quantity according to the slot quantity of the backboard hard disk slot; the hard disk reference quantity is less than the slot quantity.
[0044] The second calculating unit is configured to calculate a first reference bandwidth value and a second reference bandwidth value according to the total bandwidth of the PCIe device and the slot quantity; the first reference bandwidth value is greater than the second reference bandwidth value.
[0045] The dividing unit is configured to divide the total bandwidth of the PCIe device according to the hard disk quantity, the slot quantity, the hard disk reference quantity, the first reference bandwidth value and the second reference bandwidth value, to obtain at least one sub-bandwidth.
[0046] Optionally, the dividing unit comprises:
[0047] The first dividing sub-unit is configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the hard disk quantity and with the same bandwidth value as the first reference bandwidth value, when the hard disk quantity is less than or equal to the hard disk reference quantity.
[0048] Optionally, the dividing unit comprises:
[0049] The calculating sub-unit is configured to calculate a first dividing quantity with the bandwidth value as the first reference bandwidth value and a second dividing quantity with the bandwidth value as the second reference bandwidth value according to the slot quantity and the hard disk quantity, when the hard disk quantity is greater than the hard disk reference quantity and less than the slot quantity.
[0050] The second dividing sub-unit is configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the first dividing quantity and with the same bandwidth value as the first reference bandwidth value, and sub-bandwidths with the same quantity as the second dividing quantity and with the same bandwidth value as the second reference bandwidth value.
[0051] Optionally, the dividing unit comprises:
[0052] The third dividing sub-unit is configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the hard disk quantity and with the same bandwidth value as the second reference bandwidth value, when the hard disk quantity is equal to the slot quantity.
[0053] Optionally, the adjusting sub-module comprises:
[0054] determining unit, configured to determine, according to the order from small to large of the slot numbers, a first target backplane hard disk slot from the target backplane hard disk slots; the number of the first target backplane hard disk slots is the same as the first division number;
[0055] an allocating unit, configured to allocate bandwidth to the first target backplane hard disk slots so that the sub-bandwidth of the first target backplane hard disk slots is the first reference bandwidth value, and allocate bandwidth to second target backplane hard disk slots so that the sub-bandwidth of the second target backplane hard disk slots is the second reference bandwidth value; the second target backplane hard disk slots are the target backplane hard disk slots other than the first target backplane hard disk slots;
[0056] an adjusting unit, configured to adjust the bandwidth of a first target hard disk corresponding to the first target backplane hard disk slot and the bandwidth of a second target hard disk corresponding to the second target backplane hard disk slot, so that the bandwidth of the first target hard disk is consistent with the sub-bandwidth of the first target backplane hard disk slot, and the bandwidth of the second target hard disk is consistent with the sub-bandwidth of the second target backplane hard disk slot.
[0057] Optionally, the second calculating unit comprises:
[0058] a first calculating sub-unit, configured to take the quotient of the total bandwidth of the PCIe device and the number of slots as a second reference bandwidth value;
[0059] a second calculating sub-unit, configured to take the product of the second reference bandwidth value and a preset coefficient as a first reference bandwidth value.
[0060] In a third aspect, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the steps of the bandwidth adjustment method described above are implemented.
[0061] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the bandwidth adjustment method described above are implemented.
[0062] The embodiments of the present application have the following advantages:
[0063] The embodiment of the present application detects the connection state of the hard disk, determines at least one target hard disk currently connected with the backplane hard disk slot when the connection state of the hard disk changes, and obtains the total bandwidth of the PCIe device, so that the total bandwidth of the PCIe device is dynamically allocated to the target hard disk according to the total bandwidth of the PCIe device and the at least one target hard disk when the connection state of the hard disk changes, so that the target hard disk can be fully used, the read-write performance of the target hard disk is improved, and the waste of bandwidth resources caused by the target hard disk in the non-full configuration state is avoided. BRIEF DESCRIPTION OF DRAWINGS
[0064] Figure 1 is a step flow chart of a bandwidth adjustment method provided by the embodiment of the present application;
[0065] Figure 2 is a structural block diagram of another bandwidth adjustment device provided by the embodiment of the present application;
[0066] Figure 3 is a structural block diagram of an electronic device provided by the embodiment of the present application;
[0067] Figure 4 is a structural block diagram of a computer readable storage medium provided by the embodiment of the present application. DETAILED DESCRIPTION
[0068] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application will be further described in detail below with reference to the drawings and specific embodiments.
[0069] In the prior art, when the hard disk is not installed in a full configuration, the problem of waste of bandwidth resources occurs, so it is necessary to improve the method strategy of traditional bandwidth allocation. In order to solve the above technical problems, the present application determines the target hard disk connected with the backplane hard disk slot, obtains the total bandwidth, and finally allocates the total bandwidth to the target hard disk, so as to dynamically adjust the bandwidth of the target hard disk according to the total bandwidth and the target hard disk.
[0070] Reference Figure 1 , a step flow chart of a bandwidth adjustment method provided by the embodiment of the present application is shown, the method is applied to a server, the server has a high-speed serial computer expansion bus standard PCIe device, the PCIe device includes a backplane hard disk slot, the backplane hard disk slot is connected with at least one hard disk, and the method can specifically include the following steps:
[0071] Step 101, detecting the connection state of the hard disk, when the connection state changes, determining at least one target hard disk currently connected with the backplane hard disk slot.
[0072] In the embodiment of the present application, the PCIe device can be installed in the server, and the PCIe device can include a plurality of backplane hard disk slots. The hard disks can be connected to the backplane hard disk slots, thereby being connected to the server. The server can detect the connection state of the hard disks in real time. When the connection state of the hard disks changes, for example, the number of hard disks connected to the backplane hard disk slots changes, or the position of the hard disks connected to the backplane hard disk slots changes. The server can determine at least one target hard disk currently connected to the backplane hard disk slots, wherein the at least one target hard disk is all the hard disks connected to the backplane hard disk slots.
[0073] In step 102, the total bandwidth of the PCIe device is obtained.
[0074] In the embodiment of the present application, after the target hard disk is determined, the total bandwidth of the PCIe device can be obtained. In actual application, the total bandwidth of the PCIe device is generally X16, and can also be other bandwidths, which are not specifically limited in the present application. In order to better describe the embodiments of the present application, the total bandwidth of the PCIe device in the subsequent embodiments is taken as an example of X16.
[0075] In step 103, the total bandwidth of the PCIe device is respectively allocated to the at least one target hard disk.
[0076] In the embodiment of the present application, after the total bandwidth of the PCIe device is obtained, the server can enter the IIO (Integrated I / O module) configuration menu through the BIOS (Basic Input Output System) to automatically divide the total bandwidth of the PCIe device, and then allocate the divided bandwidth to the backplane hard disk slots. Then, the bandwidth of the target hard disk connected to the backplane hard disk slot is adjusted, so that the bandwidth of the target hard disk is consistent with the bandwidth of the corresponding backplane hard disk slot.
[0077] In an embodiment, after determining the target hard disk currently connected with the backplane hard disk slot, the number of the target hard disks, the number of the backplane hard disk slots, and the number of the target backplane hard disk slot connected with the target hard disk can be obtained. The total bandwidth of the PCIe device is then divided into at least one sub-bandwidth. The number of the sub-bandwidth is the same as the number of the hard disks. The sub-bandwidth is allocated to the target backplane hard disk slot according to the number of the target backplane hard disk slot. The bandwidth of the target hard disk corresponding to the target backplane hard disk slot is adjusted according to the sub-bandwidth allocated to the target backplane hard disk slot, so that the bandwidth of the target hard disk is consistent with the sub-bandwidth of the target backplane hard disk slot. For example, the number of the target hard disks connected with the backplane hard disk slot is 5. The total bandwidth of the PCIe device is divided into 5 sub-bandwidth. Then, the 5 sub-bandwidth is allocated to the 5 target backplane hard disk slots according to the number of the target backplane slot.
[0078] In an embodiment, the total bandwidth of the PCIe device is divided into at least one sub-bandwidth in the present application. The total bandwidth of the PCIe device can be divided into at least one sub-bandwidth by the following method: the number of the hard disks is calculated according to the number of the backplane hard disk slot. The number of the hard disks is less than the number of the backplane hard disk slot. The first reference bandwidth value and the second reference bandwidth value are calculated according to the total bandwidth of the PCIe device and the number of the backplane hard disk slot. The first reference bandwidth value is greater than the second reference bandwidth value. The total bandwidth of the PCIe device is divided into at least one sub-bandwidth according to the number of the hard disks, the number of the backplane hard disk slot, the number of the hard disk reference, the first reference bandwidth value, and the second reference bandwidth value. For example, the number of the hard disks is 5, and the number of the backplane hard disk slot is 8. The number of the hard disk reference is calculated to be 4. The first reference bandwidth value is X4, and the second reference bandwidth value is X2. Then, the total bandwidth of the PCIe device is divided into 5 sub-bandwidth according to the number of the hard disks, the number of the backplane hard disk slot, the number of the hard disk reference, the first reference bandwidth value, and the second reference bandwidth value.
[0079] In an embodiment, the first reference bandwidth value and the second reference bandwidth value can be calculated by the following method: the quotient of the total bandwidth of the PCIe device and the number of the backplane hard disk slot is taken as the second reference bandwidth value. The product of the second reference bandwidth value and a preset coefficient is taken as the first reference bandwidth value. For example, the total bandwidth of the PCIe device is X16, and the number of the backplane hard disk slot is 8. The total bandwidth of the PCIe device is divided by the number of the backplane hard disk slot to obtain the second reference bandwidth value X2. Then, the second reference value is multiplied by the preset coefficient 2 to obtain the first reference bandwidth value X4. In the present application, the first reference bandwidth value and the second reference bandwidth value can also be preset parameters. The specific method of obtaining the first reference bandwidth value and the second reference bandwidth value is not limited in the present application.
[0080] In an embodiment, the total bandwidth of the PCIe device is divided into at least one sub-bandwidth according to the number of hard disks, the number of slots, the reference number of hard disks, the first reference bandwidth value and the second reference bandwidth value. The division can be performed in the following manner: when the number of hard disks is less than or equal to the reference number of hard disks, the total bandwidth of the PCIe device is divided into sub-bandwidths with the same number of hard disks and the bandwidth value is the first reference bandwidth value. For example: the total bandwidth of the PCIe device is X16, the number of hard disks is 4, the reference number of hard disks is 4, and the first reference bandwidth value is X4. When the total bandwidth of the PCIe device is divided, it is determined that the number of hard disks is equal to the reference number of hard disks, and the total bandwidth of the PCIe device is divided into 4 sub-bandwidths with a bandwidth value of X4.
[0081] In another example, the total bandwidth of the PCIe device is divided into at least one sub-bandwidth according to the number of hard disks, the number of slots, the reference number of hard disks, the first reference bandwidth value and the second reference bandwidth value. The division can be performed in the following manner: when the number of hard disks is greater than the reference number of hard disks and less than the number of slots, the first division number with the first reference bandwidth value and the second division number with the second reference bandwidth value are calculated according to the number of slots and the number of hard disks; the total bandwidth of the PCIe device is divided into sub-bandwidths with the same number of the first division number and the first reference bandwidth value, and sub-bandwidths with the same number of the second division number and the second reference bandwidth value.
[0082] Wherein, the first division number can be calculated by formula A1=M-N, and the second division number can be calculated by formula A2=2N-M, A1 is the first division number, A2 is the second division number, M is the number of slots, and N is the number of hard disks. In this application, the first division number and the second division number can also be obtained by other methods, which are not limited in this application.
[0083] For example: the total bandwidth of the PCIe device is X16, the number of slots is 8, the number of hard disks is 5, the reference number of hard disks is 4, the first reference bandwidth value is X4, and the second reference bandwidth value is X2. It can be determined that the number of hard disks is greater than the reference number of hard disks, and at this time, the first division number is 3 and the second division number is 2. Then the total bandwidth of the PCIe device can be divided into 3 sub-bandwidths with a bandwidth value of X4 and 2 sub-bandwidths with a bandwidth value of X2.
[0084] In another example, the total bandwidth of the PCIe device is divided into at least one sub-bandwidth according to the number of hard disks, the number of slots, the number of reference hard disks, the first reference bandwidth value and the second reference bandwidth value. The division can be performed in the following manner: when the number of hard disks is equal to the number of slots, the total bandwidth of the PCIe device is divided into sub-bandwidths with the same number as the number of hard disks and each sub-bandwidth is the second reference bandwidth value. For example, the total bandwidth of the PCIe device is X16, the number of slots is 8, the number of hard disks is 8, and the second reference bandwidth value is X2. It can be determined that the number of hard disks is equal to the number of slots. At this time, the total bandwidth of the PCIe device can be divided into 8 sub-bandwidths with a bandwidth value of X2.
[0085] In an embodiment, the bandwidth of at least one target hard disk corresponding to a target backplane hard disk slot is adjusted according to the sub-bandwidth allocated to the target backplane hard disk slot, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backplane hard disk slot. When the number of hard disks is less than or equal to the number of reference hard disks, the allocation and adjustment can be performed in the following manner: the target backplane hard disk slot is allocated with bandwidth, so that the sub-bandwidth of the target backplane hard disk slot is the first reference bandwidth value; and the at least one target hard disk corresponding to the target backplane hard disk slot is adjusted, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the target backplane hard disk slot. For example, the first reference bandwidth value is X4, the sub-bandwidth of X4 is allocated to the target backplane hard disk slot, and the target hard disk connected to the target backplane hard disk slot is adjusted, so that the bandwidth of the target hard disk is also X4.
[0086] In another example, the bandwidth of at least one target hard disk corresponding to a target backplane hard disk slot is adjusted according to the sub-bandwidth allocated to the target backplane hard disk slot, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backplane hard disk slot. When the number of hard disks is greater than the number of reference hard disks and less than the number of slots, the allocation and adjustment can be performed in the following manner: a first target backplane hard disk slot is determined from the target backplane hard disk slots in ascending order of slot number; the number of first target backplane hard disk slots is the same as the first division number; the first target backplane hard disk slot is allocated with bandwidth, so that the sub-bandwidth of the first target backplane hard disk slot is the first reference bandwidth value, and the second target backplane hard disk slot is allocated with bandwidth, so that the sub-bandwidth of the second target backplane hard disk slot is the second reference bandwidth value; the second target backplane hard disk slot is the target backplane hard disk slot remaining in the target backplane hard disk slot except the first target backplane hard disk slot; the bandwidth of the first target hard disk corresponding to the first target backplane hard disk slot is adjusted, and the bandwidth of the second target hard disk corresponding to the second target backplane hard disk slot is adjusted, so that the bandwidth of the first target hard disk is consistent with the sub-bandwidth of the first target backplane hard disk slot, and the bandwidth of the second target hard disk is consistent with the sub-bandwidth of the second target backplane hard disk slot.
[0087] For example, the target backplane hard disk slot is 5, the first division number is 3, the second division number is 2, the first reference bandwidth value is X4, the second reference bandwidth value is X2, the numbers corresponding to the target backplane hard disk slots are A, B, C, D, and E, and the numbers of the slots corresponding to the target backplane hard disk slots A to E are 1, 3, 5, 2, and 6, respectively. The order of the numbers of the slots from small to large is 1, 2, 3, 5, and 6. The first target backplane hard disk slot is determined to be the target backplane hard disk slot with the number A, D, and B, the second target backplane hard disk slot is determined to be the target backplane hard disk slot with the number C and E, the sub-bandwidth of X4 is allocated to the target backplane hard disk slots with the numbers A, D, and B, the sub-bandwidth of X2 is allocated to the target backplane hard disk slots with the numbers C and E, the bandwidth of the first target hard disk connected to the target backplane hard disk slots with the numbers A, D, and B is adjusted, and the bandwidth of the first target hard disk is X4. The bandwidth of the second target hard disk connected to the target backplane hard disk slots with the numbers C and E is adjusted, and the bandwidth of the second target hard disk is X2.
[0088] In another example, according to the sub-bandwidth allocated to the target backplane hard disk slot, the bandwidth of at least one target hard disk corresponding to the target backplane hard disk slot is adjusted, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backplane hard disk slot. When the number of hard disks is equal to the number of slots, the allocation and adjustment can be performed in the following manner: the target backplane hard disk slot is allocated with bandwidth, so that the sub-bandwidth of the target backplane hard disk slot is the second reference bandwidth value; at least one target hard disk corresponding to the target backplane hard disk slot is adjusted, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the target backplane hard disk slot. For example, the second reference bandwidth value is X2, the sub-bandwidth of X2 is allocated to the target backplane hard disk slot, and the target hard disk connected to the target backplane hard disk slot is adjusted, so that the bandwidth of the target hard disk is also X2.
[0089] In this embodiment, the connection state of the hard disk is detected, and when the connection state changes, at least one target hard disk currently connected to the backplane hard disk slot is determined. The total bandwidth of the PCIe device is obtained, and the total bandwidth of the PCIe device is allocated to the at least one target hard disk. Thus, when the hard disks connected to the PCIe device change, the total bandwidth of the PCIe device is reasonably allocated to the target hard disk according to the total bandwidth of the PCIe device and the target hard disk, so that the target hard disk is fully used, the read-write performance of the target hard disk is improved, and the waste of bandwidth resources is avoided when the number of target hard disks is not sufficient.
[0090] It should be noted that, for the method embodiments, the series of acts combinations are merely provided as an example. However, those skilled in the art will recognize that the present application embodiments can be carried out with only some of the acts, other steps in another order, or with additional or other acts according to the application embodiments. And these embodiments can be implemented in electronic hardware, software, firmware, or any combination thereof. Preferably, the various embodiments can be implemented in a processing system that includes one or more processors or controllers.
[0091] Referring to Figure 2 , a structure block diagram of a bandwidth adjustment device provided by an embodiment of the present application is shown. The device is applied to a server. The server has a high-speed serial computer expansion bus standard (PCIe) device. The PCIe device includes a backplane hard disk slot. The backplane hard disk slot is connected with at least one hard disk. The device includes:
[0092] A determination module 201 is configured to detect a connection state of the hard disk. When the connection state changes, the determination module 201 determines at least one target hard disk currently connected with the backplane hard disk slot.
[0093] A first acquisition module 202 is configured to acquire a total bandwidth of the PCIe device.
[0094] A distribution module 203 is configured to distribute the total bandwidth of the PCIe device to the at least one target hard disk respectively.
[0095] Optionally, the device further includes:
[0096] The at least one target hard disk, the number of the hard disks, the number of the slot of the backplane hard disk slot, and the number of the slot of the target backplane hard disk slot are acquired. The target backplane hard disk slot is the backplane hard disk slot connected with the at least one target hard disk.
[0097] The distribution module 203 includes:
[0098] A division sub-module is configured to divide the total bandwidth of the PCIe device to obtain at least one sub-bandwidth. The number of the sub-bandwidth is the same as the number of the hard disks.
[0099] A distribution sub-module is configured to distribute the sub-bandwidth to the target backplane hard disk slot according to the number of the slot of the target backplane hard disk slot.
[0100] An adjustment sub-module is configured to adjust the bandwidth of the at least one target hard disk corresponding to the target backplane hard disk slot according to the sub-bandwidth distributed to the target backplane hard disk slot, so that the bandwidth of the at least one target hard disk is consistent with the sub-bandwidth of the corresponding target backplane hard disk slot.
[0101] Optionally, the dividing sub-module comprises:
[0102] a first calculating unit, configured to calculate a hard disk reference quantity according to a slot quantity of the backboard hard disk slot;
[0103] a second calculating unit, configured to calculate a first reference bandwidth value and a second reference bandwidth value according to a total bandwidth of the PCIe device and the slot quantity; the first reference bandwidth value is greater than the second reference bandwidth value;
[0104] a dividing unit, configured to divide the total bandwidth of the PCIe device according to the hard disk quantity, the slot quantity, the hard disk reference quantity, the first reference bandwidth value and the second reference bandwidth value, to obtain at least one sub-bandwidth.
[0105] Optionally, the dividing unit comprises:
[0106] a first dividing sub-unit, configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the hard disk quantity and with the same bandwidth value as the first reference bandwidth value, when the hard disk quantity is less than or equal to the hard disk reference quantity.
[0107] Optionally, the dividing unit comprises:
[0108] a calculating sub-unit, configured to calculate a first dividing quantity with the first reference bandwidth value and a second dividing quantity with the second reference bandwidth value according to the slot quantity and the hard disk quantity, when the hard disk quantity is greater than the hard disk reference quantity and less than the slot quantity;
[0109] a second dividing sub-unit, configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the first dividing quantity and with the same bandwidth value as the first reference bandwidth value, and sub-bandwidths with the same quantity as the second dividing quantity and with the same bandwidth value as the second reference bandwidth value.
[0110] Optionally, the dividing unit comprises:
[0111] a third dividing sub-unit, configured to divide the total bandwidth of the PCIe device into sub-bandwidths with the same quantity as the hard disk quantity and with the same bandwidth value as the second reference bandwidth value, when the hard disk quantity is equal to the slot quantity.
[0112] Optionally, the adjusting sub-module comprises:
[0113] a determining unit, configured to determine a first target backboard hard disk slot from the target backboard hard disk slots in an order from small to large according to the slot quantity; the quantity of the first target backboard hard disk slot is the same as the first dividing quantity;
[0114] The distribution unit is configured to distribute bandwidth to the first target backplane hard disk slot so that the sub-bandwidth of the first target backplane hard disk slot is the first reference bandwidth value, and to distribute bandwidth to a second target backplane hard disk slot so that the sub-bandwidth of the second target backplane hard disk slot is the second reference bandwidth value; the second target backplane hard disk slot is a target backplane hard disk slot remaining in the target backplane hard disk slots except the first target backplane hard disk slot;
[0115] The adjustment unit is configured to adjust the bandwidth of a first target hard disk corresponding to the first target backplane hard disk slot and the bandwidth of a second target hard disk corresponding to the second target backplane hard disk slot, so that the bandwidth of the first target hard disk is consistent with the sub-bandwidth of the first target backplane hard disk slot, and the bandwidth of the second target hard disk is consistent with the sub-bandwidth of the second target backplane hard disk slot.
[0116] Optionally, the second calculation unit comprises:
[0117] The first calculation sub-unit is configured to take the quotient of the total bandwidth of the PCIe device and the number of slots as a second reference bandwidth value.
[0118] The second calculation sub-unit is configured to take the product of the second reference bandwidth value and a preset coefficient as a first reference bandwidth value.
[0119] The present application discloses a bandwidth adjustment device, comprising: a determination module configured to detect the connection state of a hard disk, and determine at least one target hard disk currently connected to a backplane hard disk slot when the connection state changes; a first acquisition module configured to acquire the total bandwidth of a PCIe device; and a distribution module configured to distribute the total bandwidth of the PCIe device to the at least one target hard disk. Thus, when the hard disks connected to the PCIe device change, the total bandwidth of the PCIe device is reasonably distributed to the target hard disks according to the total bandwidth of the PCIe device and the target hard disks, so that the target hard disks are fully used, the read-write performance of the target hard disks is improved, and the waste of bandwidth resources is avoided when the number of target hard disks is not sufficient.
[0120] For the above bandwidth adjustment device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts are described in the method embodiment.
[0121] As Figure 3 shown in the structural block diagram of the electronic device provided by the embodiment of the present application, the electronic device comprises:
[0122] The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the processes of the bandwidth adjustment method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.
[0123] As Figure 4 The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the processes of the bandwidth adjustment method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.
[0124] Each of the embodiments in the specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other.
[0125] Those skilled in the art should understand that the embodiments of the embodiments of the present application can be provided as a method, device, or computer program product. Therefore, the embodiments of the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0126] The embodiments of the present application are described with reference to flowcharts and / or block diagrams according to the method, terminal device (system), and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of the flows and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the computer or other programmable data processing terminal device produce a device that implements the functions specified in the flow Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one block or multiple blocks.
[0127] These computer program instructions can also be stored in a computer readable storage medium that can guide the computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including instruction devices that implement the functions specified in the flow Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one block or multiple blocks.
[0128] These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operational steps are performed on the computer or other programmable terminal device to generate a computer-implemented process, thus the instructions executed on the computer or other programmable terminal device provide a process for implementing the functions specified in the flowchart Figure 1 one flowchart or multiple flowcharts and / or blocks Figure 1 one block or multiple blocks.
[0129] Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to these embodiments once they have the basic inventive concept. Therefore, the appended claims are intended to cover all changes and modifications falling within the scope of the embodiments of the present application.
[0130] Finally, it should be noted that the relational terms herein, such as first and second, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any such actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, so that a process, method, article, or terminal device including a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or terminal device. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or terminal device including the element.
[0131] The above provides a bandwidth adjustment method, device, equipment, and storage medium, and the principles and implementation manners of the present application are described by using specific examples. The above description of the embodiments is only used to help understand the method and core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges can be changed, and the above description should not be understood as a limitation of the present application.
Claims
1. A bandwidth adjustment method, characterized in that, The method is applied to a server having a high-speed serial computer expansion bus standard PCIe device, the PCIe device including a backplane hard drive bay connected to at least one hard drive, the method comprising: The connection status of the hard drive is detected, and when the connection status changes, at least one target hard drive is identified that is currently connected to the backplane hard drive slot. Obtain the number of hard drives of the at least one target hard drive, the number of slots of the backplane hard drive slot, and the number of slots of the target backplane hard drive slot; Obtain the total bandwidth of the PCIe device; Calculate the reference number of hard drives based on the number of hard drive slots on the backplane; the reference number of hard drives is less than the number of slots. Based on the total bandwidth of the PCIe device and the number of slots, a first reference bandwidth value and a second reference bandwidth value are calculated; the first reference bandwidth value is greater than the second reference bandwidth value. When the number of hard drives is greater than the reference number of hard drives and less than the number of slots, a first number of partitions with bandwidth values equal to the first reference bandwidth value and a second number of partitions with bandwidth values equal to the second reference bandwidth value are calculated based on the number of slots and the number of hard drives; the total bandwidth of the PCIe device is divided into sub-bandwidths that are the same as the first number of partitions and are all equal to the first reference bandwidth value, and sub-bandwidths that are the same as the second number of partitions and are all equal to the second reference bandwidth value; the number of sub-bandwidths is the same as the number of hard drives; Based on the number of slots in the target backplane hard drive slots, the sub-bandwidth is allocated to the target backplane hard drive slots respectively; Based on the sub-bandwidth allocated to the target backplane hard drive slot, adjust the bandwidth of the at least one target hard drive corresponding to the target backplane hard drive slot so that the bandwidth of the at least one target hard drive is consistent with the sub-bandwidth of the corresponding target backplane hard drive slot.
2. The bandwidth adjustment method according to claim 1, characterized in that, The method further includes: When the number of hard disks is less than or equal to the reference number of hard disks, the total bandwidth of the PCIe device is divided into sub-bandwidths with the same number of hard disks and the same bandwidth value as the first reference bandwidth value.
3. The bandwidth adjustment method according to claim 1, characterized in that, The method further includes: When the number of hard drives equals the number of slots, the total bandwidth of the PCIe device is divided into sub-bandwidths that are the same as the number of hard drives and are all of the second reference bandwidth value.
4. The bandwidth adjustment method according to claim 1, characterized in that, The step of adjusting the bandwidth of at least one target hard drive corresponding to the target backplane hard drive slot according to the sub-bandwidth allocated to the target backplane hard drive slot, so that the bandwidth of the at least one target hard drive is consistent with the sub-bandwidth of the corresponding target backplane hard drive slot, includes: The first target backplane hard drive slot is determined from the target backplane hard drive slots in ascending order of the number of slots; the number of the first target backplane hard drive slots is the same as the number of the first divisions; Bandwidth allocation is performed on the first target backplane hard disk slot, such that the sub-bandwidth of the first target backplane hard disk slot is the first reference bandwidth value; and bandwidth allocation is performed on the second target backplane hard disk slot, such that the sub-bandwidth of the second target backplane hard disk slot is the second reference bandwidth value; the second target backplane hard disk slot is the target backplane hard disk slot remaining excluding the first target backplane hard disk slot. Adjust the bandwidth of the first target hard drive corresponding to the first target backplane hard drive slot and the bandwidth of the second target hard drive corresponding to the second target backplane hard drive slot, so that the bandwidth of the first target hard drive is consistent with the sub-bandwidth of the first target backplane hard drive slot and the bandwidth of the second target hard drive is consistent with the sub-bandwidth of the second target backplane hard drive slot.
5. The bandwidth adjustment method according to claim 1, characterized in that, The step of calculating the first reference bandwidth value and the second reference bandwidth value based on the total bandwidth of the PCIe device and the number of slots includes: The quotient of the total bandwidth of the PCIe device and the number of slots is used as the second reference bandwidth value; The product of the second reference bandwidth value and the preset coefficient is used as the first reference bandwidth value.
6. A bandwidth adjustment device, characterized in that, The device is applied to a server having a high-speed serial computer expansion bus standard PCIe device, the PCIe device including a backplane hard drive bay connected to at least one hard drive, the device comprising: The determination module is used to detect the connection status of the hard drive, and when the connection status changes, determine at least one target hard drive currently connected to the backplane hard drive slot; The second acquisition module is used to acquire the number of hard drives of the at least one target hard drive, the number of slots of the backplane hard drive slots, and the number of slots of the target backplane hard drive slots. The first acquisition module is used to acquire the total bandwidth of the PCIe device; The first calculation unit is used to calculate a reference number of hard drives based on the number of hard drive slots on the backplane; the reference number of hard drives is less than the number of slots. The second calculation unit is used to calculate a first reference bandwidth value and a second reference bandwidth value based on the total bandwidth of the PCIe device and the number of slots; the first reference bandwidth value is greater than the second reference bandwidth value. A partitioning unit is configured to, when the number of hard drives is greater than the reference number of hard drives and less than the number of slots, calculate a first partition number with a bandwidth value equal to the first reference bandwidth value and a second partition number with a bandwidth value equal to the second reference bandwidth value, based on the number of slots and the number of hard drives; divide the total bandwidth of the PCIe device into sub-bandwidths that are the same as the first partition number and all equal to the first reference bandwidth value, and sub-bandwidths that are the same as the second partition number and all equal to the second reference bandwidth value; the number of sub-bandwidths is the same as the number of hard drives; the number of sub-bandwidths is the same as the number of hard drives. The allocation submodule is used to allocate the subbandwidth to the target backplane hard disk slots according to the number of slots in the target backplane hard disk slots; An adjustment submodule is used to adjust the bandwidth of at least one target hard drive corresponding to the target backplane hard drive slot according to the sub-bandwidth allocated to the target backplane hard drive slot, so that the bandwidth of the at least one target hard drive is consistent with the sub-bandwidth of the corresponding target backplane hard drive slot.
7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the bandwidth adjustment method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the bandwidth adjustment method as described in any one of claims 1-5.
Citation Information
Patent Citations
PCIe bandwidth allocation method and basic input / output system
CN114048036A