A hard disk IO control method, product, device and storage medium
By creating a global IO controller in the cinder of the OpenStack cloud platform, monitoring and controlling the IO read and write operations of the local hard disk solves the problem of IO resource contention when uploading or downloading cloud hard disk images, ensuring the stability of the cloud platform and physical machines. .
Patent Information
- Application Number
- CN202410823789.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-25
AI Technical Summary
In the OpenStack cloud platform, during the cloud hard disk image upload or download process, the local hard disk IO read and write bandwidth of the physical machine is high, resulting in IO resource contention and acquisition timeout, which affects the stability of the cloud platform, especially during large-scale image uploads. Or when downloading, it may cause components such as mysql and rabbitmq to be abnormal, reducing the stability of the cloud platform and physical machines.
Create a global IO controller in cinder of the OpenStack cloud platform, monitor the IO read and write operations of the local hard disk, determine the sub-operation steps of the target IO operation, and use the context manager to modify the sub-process or command line, add it to the Cgroup, and control IO performance allocation ensures that IO is within controllable range, and sufficient IO resources are reserved to ensure the stability of the cloud platform and physical machines.
Through IO control methods, ensure the stability of the cloud platform and physical machines, avoid IO resource contention and timeouts, and ensure the normal operation of other system components and operating systems of the cloud platform.
Smart Images

Figure CN118377439B
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a hard disk IO control method, product, device and storage medium. Background Art
[0002] With the rapid development of big data and cloud computing technology, the OpenStack cloud platform with computing, network and storage functions has been widely used. OpenStack is an extremely complex cloud management platform. It usually labels physical machines, divides the roles of each module and deploys them on different physical machines according to high availability requirements. It also provides cloud computing services through a series of collaborative components, such as cinder (block storage), glance (image service), manila (shared file service), mysql (database), rabbitmq (message queue service), keystone (identity service), neutron (network service), Nova (computing service) and other system components. These components manage different resource types, such as computing (virtual machines), storage (block storage and object storage) and network.
[0003] Among them, cinder is used to manage the life cycle of cloud hard disks, such as adding, deleting, modifying, checking, mounting, unmounting, backing up, restoring, and creating, and it also supports uploading cloud hard disks to the image glance warehouse. However, in the process of creating an image cloud hard disk and uploading the cloud hard disk to the image library, the local hard disk on the physical machine needs to be temporarily transferred to download or export the image corresponding to the cloud hard disk to the local hard disk before executing the next step. In this way, in scenarios with large image size or high concurrency, high-bandwidth IO (input / output) reading and writing will continue to be performed on the local hard disk of the physical machine. While the local hard disk performs high-bandwidth reading and writing on cinder, it also provides IO services for other system components such as mysql and rabbitmq. Therefore, when there is a large-scale image upload or download, it is easy to cause components such as mysql and rabbitmq to be abnormal due to IO resource competition or IO resource acquisition timeout, which in turn causes abnormal services of the entire cloud platform, that is, abnormal operation, and reduces the stability of the cloud platform and the physical machine operating system. For example, due to IO resource acquisition timeout, the service status of components such as cinder and nova that need to write mysql data regularly becomes offline. Summary of the invention
[0004] In view of this, the purpose of this application is to provide a hard disk IO control method, product, device and storage medium, which can make the IO of each operation on the local hard disk within the controllable range and ensure sufficient IO reservation, so as to allow other system components and operating systems of the cloud platform to operate normally, thereby ensuring the stability of the cloud platform and physical machines. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a hard disk IO control method, which is applied to a global IO controller pre-created in cinder of an OpenStack cloud platform, comprising:
[0006] When an IO read / write operation request for a local hard disk of a target physical machine is monitored, a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request is determined; the OpenStack cloud platform is deployed on the target physical machine;
[0007] Obtain the subprocess of the storage backend corresponding to each of the sub-operation steps;
[0008] Using a context manager to modify the child process or a command line corresponding to the child process to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller to control IO performance allocation of the modified process or the modified command line, and executing the modified process or the modified command line in the Cgroup based on the allocated IO performance;
[0009] The Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder.
[0010] Optionally, the hard disk IO control method further includes:
[0011] When the cinder is detected to be started, an IO performance test is performed on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit, and a Cgroup is created based on the IO performance upper limit;
[0012] The remaining IO ratio is calculated according to the IO reserved ratio in the configuration item of the cinder, and the target IO performance corresponding to the Cgroup is calculated based on the remaining IO ratio and the IO performance upper limit, and the target IO performance is allocated to the Cgroup; the IO reserved ratio is a ratio reserved based on the IO performance requirements of other system components in the OpenStack cloud platform except the cinder.
[0013] Optionally, the performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit includes:
[0014] A temporary file is created on the local hard disk, and a data block write operation and a data block read operation are performed on the temporary file in sequence using a preset first data block and a preset second data block, so as to obtain a write performance upper limit and a read performance upper limit of the local hard disk, and obtain an IO performance upper limit; the size of the first data block is larger than the size of the second data block.
[0015] Optionally, the creating a Cgroup based on the IO performance upper limit includes:
[0016] A Cgroup is created based on the IO performance upper limit by using the libcgroup tool provided by the Linux kernel.
[0017] Optionally, the performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit includes:
[0018] The IO performance test is performed on the local hard disk of the target physical machine by using a subprocess corresponding to any storage backend of the cinder to obtain the performance upper limit of the local hard disk and obtain the IO performance upper limit.
[0019] Optionally, the process of using a subprocess corresponding to any storage backend of the cinder to perform an IO performance test on the local hard disk of the target physical machine also includes:
[0020] A lock file is created in the target physical machine using a local lock, and the operation right of the lock file is obtained, so that when other sub-processes except the sub-process corresponding to any one of the storage backends query that the operation right of the lock file is in a non-idle state, the creation process of the Cgroup is skipped, and the storage backend corresponding to the other sub-process is directly initialized.
[0021] Optionally, the step of determining a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request includes:
[0022] Determine a target IO operation corresponding to the IO read / write operation request; the target IO operation is an operation of creating a mirrored cloud hard disk;
[0023] Obtain multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include a step of downloading the image to a local, a step of converting the local image format, and a step of writing the converted image to a cloud hard disk.
[0024] Optionally, the step of determining a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request includes:
[0025] Determine a target IO operation corresponding to the IO read / write operation request; the target IO operation is a cloud hard disk image upload operation;
[0026] Obtain multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include exporting a cloud hard disk to a local step, converting a local image format, and uploading the converted image to an image warehouse step.
[0027] Optionally, the using a context manager to modify the child process or a command line corresponding to the child process to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller includes:
[0028] A context manager is used to add a preset prefix in front of the command line corresponding to the child process to obtain a modified command line, so that when the modified command line is executed, the process executed by the modified command line is automatically added to the Cgroup previously created by the global IO controller; the preset prefix contains an identifier related to the Cgroup.
[0029] Optionally, the using a context manager to modify the child process or a command line corresponding to the child process to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller includes:
[0030] The process controller of the child process is obtained, and the process controller is added to the child process by using a context manager to obtain an added process, and the added process is added to a Cgroup pre-created by the global IO controller.
[0031] Optionally, using a context manager to add the process control symbol to the child process to obtain an added process, and adding the added process to a Cgroup pre-created by the global IO controller includes:
[0032] Using a context manager and using the cgclassify command, the process control symbol is added to the child process to obtain the added process;
[0033] The added process is added to the Cgroup pre-created by the global IO controller.
[0034] Optionally, the hard disk IO control method further includes:
[0035] When it is detected that the modified process or the modified command line is executed completely, the modified process or the modified command line is deleted from the Cgroup.
[0036] In a second aspect, the present application discloses a computer program product, including a computer program / instruction, which implements the steps of the aforementioned hard disk IO control method when executed by a processor.
[0037] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the processor implements the aforementioned hard disk IO control method when executing a computer program stored in the memory.
[0038] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned hard disk IO control method is implemented.
[0039] It can be seen that the present application is applied to a global IO controller pre-created in the cinder of the OpenStack cloud platform. When an IO read / write operation request for the local hard disk of the target physical machine is monitored, multiple sub-operation steps in the target IO operation corresponding to the IO read / write operation request are first determined, and the sub-processes of the storage backend corresponding to each of the sub-operation steps are obtained. Then, the sub-process or the command line corresponding to the sub-process is modified by using the context manager to obtain the modified process or the modified command line, and the modified process or the modified command line is added to the Cgroup pre-created by the global IO controller to control the IO performance allocation of the modified process or the modified command line, and the modified process or the modified command line is executed in the Cgroup based on the allocated IO performance; wherein, the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder. The present application creates a global IO controller in cinder, and creates a Cgroup through the global IO controller in advance. When an IO read and write operation request for a local hard disk is monitored, multiple sub-operation steps in the target IO operation corresponding to the request are first determined, and then the sub-process corresponding to each sub-operation step is determined, and the context manager is used to modify each sub-process or the command line corresponding to the sub-process, and the modified process or the modified command line is added to the Cgroup, so as to control the IO performance allocation of the process or command line, and execute the corresponding process or command line in the Cgroup. It should be pointed out that the IO performance of the Cgroup in the present application is allocated based on the IO performance upper limit of the local hard disk and the reserved IO ratio in cinder. It can be seen that the present application splits the IO read and write operations, and allocates IO performance to the processes corresponding to each split sub-operation through the Cgroup. Since the IO performance of the Cgroup is allocated based on the reserved IO ratio, the IO performance is reserved for other system components. Therefore, the IO of each sub-operation step to the local hard disk can be controlled, and sufficient IO reservation is guaranteed, so that other system components and operating systems of the cloud platform can operate normally, thereby ensuring the stability of the cloud platform and the physical machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0041] Figure 1 This is a flow chart of a hard disk IO control method disclosed in this application;
[0042] Figure 2 A block diagram of a specific hard disk IO control method disclosed in this application;
[0043] Figure 3 A schematic diagram of a specific hard disk locking process disclosed in this application;
[0044] Figure 4 A flow chart of a specific hard disk IO control method disclosed in this application;
[0045] Figure 5 A flow chart of a specific hard disk IO control method disclosed in this application;
[0046] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The present application embodiment discloses a hard disk IO control method, which is applied to a global IO controller pre-created in cinder of an OpenStack cloud platform, see Figure 1 As shown, the method includes:
[0049] Step S11: when an IO read / write operation request for a local hard disk of a target physical machine is monitored, a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request is determined; the OpenStack cloud platform is deployed on the target physical machine.
[0050] It should be noted that the hard disk IO control solution proposed in this application is applied to the global IO controller pre-created in the cinder of the OpenStack cloud platform, which can perform global IO control on the local hard disk of the physical machine. Among them, the OpenStack cloud platform is deployed on the physical machine.
[0051] In this embodiment, when the global IO controller located in cinder detects an IO read / write operation request for a local hard disk of a certain physical machine, namely, a target physical machine, multiple sub-operation steps in the target IO operation corresponding to the IO read / write operation request are first obtained. Among them, the target IO operation includes but is not limited to the operation of creating a mirror cloud hard disk and the operation of uploading a mirror to a cloud hard disk; when the target IO operation is the operation of creating a mirror cloud hard disk, the corresponding sub-operation steps may specifically include the step of downloading the mirror to the local, the step of converting the local mirror format, and the step of writing the converted mirror to the cloud hard disk; when the target IO operation is the operation of uploading the mirror to the cloud hard disk, the corresponding sub-operation steps may specifically include the step of exporting the cloud hard disk to the local, the step of converting the local mirror format, and the step of uploading the converted mirror to the mirror warehouse.
[0052] Step S12: Obtain the sub-processes of the storage backend corresponding to each of the sub-operation steps.
[0053] In this embodiment, after determining multiple sub-operation steps in the target IO operation corresponding to the IO read and write operation request, further, the storage backend corresponding to each sub-operation step is determined, such as RBD (Rados Block Device, a block device based on distributed storage) backend, LVM (Logical Volume Manager, logical volume management) backend, centralized management backend, Iscsi (Internet Small Computer System Interface, a storage technology based on the Internet and SCSI-3 protocol) backend, FC (Fibre Channel, Fibre Channel) backend, etc., and then the sub-process corresponding to each storage backend is obtained.
[0054] In a specific embodiment, the determination of multiple sub-operation steps in the target IO operation corresponding to the IO read / write operation request may specifically include: determining the target IO operation corresponding to the IO read / write operation request; the target IO operation is a create mirror cloud hard disk operation; obtaining multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include a step of downloading the image to the local, a step of converting the local image format, and a step of writing the converted image to the cloud hard disk. For example, when the target IO operation corresponding to the IO read / write operation request is a create mirror cloud hard disk operation, the multiple sub-operation steps with IO read and write to the local hard disk are: downloading the image from the glance image library to the local (write IO to the local disk), converting the image format to RAW format, and then copying the converted image to the cloud hard disk (read IO to the local hard disk). It should be noted that for scsi-type cloud hard disks (such as cloud hard disks mounted on FC and iscsi), the corresponding cloud hard disk can be seen on the physical machine, and it can be directly copied from the local machine to the corresponding cloud hard disk; and for RBD-type cloud hard disks, the qcow2 format image can be converted to RAW format on the physical machine (with read and write IO to the local hard disk), and then the RAW format image can be imported into the RBD-type cloud hard disk (with read IO to the local disk). In addition, it should be noted that before downloading the image to the local machine, the cloud hard disk needs to be mounted locally, but this step does not involve IO operations.
[0055] In another specific embodiment, the determination of the multiple sub-operation steps in the target IO operation corresponding to the IO read / write operation request may specifically include: determining the target IO operation corresponding to the IO read / write operation request; the target IO operation is a cloud hard disk upload image operation; obtaining multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include exporting the cloud hard disk to the local step, the local image format conversion step, and the uploading of the converted image to the image warehouse step. For example, when the target IO operation corresponding to the IO read / write operation request is a cloud hard disk upload image operation, the multiple sub-operation steps for IO reading and writing on the local hard disk are: first export the cloud hard disk to the local, then convert the image format locally, and upload the converted image to the glance image warehouse. It should be pointed out that for a scsi-type cloud hard disk, the cloud hard disk mounted on Cinder can be used as a local path, and then the image can be converted to qcow2 format to the local (there is write IO to the local hard disk), and then the image in qcow2 format can be uploaded to the image warehouse (there is read IO to the local disk). For RBD-type cloud hard disks, you can first use the rbd export command to export an RBD-type cloud hard disk from the RBD cluster to the local disk (with write IO to the local disk), and then convert the corresponding image file into qcow2 format (with read and write IO to the local disk), and then upload the converted qcow2 format image to the glance image warehouse (with read IO to the local disk).
[0056] Step S13: using a context manager to modify the child process or the command line corresponding to the child process to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup created in advance by the global IO controller to control the IO performance allocation of the modified process or the modified command line, and executing the modified process or the modified command line within the Cgroup based on the allocated IO performance; wherein the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder.
[0057] In this embodiment, after obtaining the sub-process of the storage backend corresponding to each of the sub-operation steps, the context manager is used to modify the above sub-process or the command line corresponding to the above sub-process to obtain the corresponding modified process or modified command line, and then the above modified process or the above modified command line is added to the Cgroup (Control Group) created in advance by the global IO controller, so as to control the IO performance allocation of the above modified process or the above modified command line through the Cgroup, and execute the above modified process or the above modified command line within the Cgroup based on the allocated IO performance. It should be pointed out that the Cgroup is created based on the IO performance upper limit of the local hard disk of the target physical machine, and the IO performance of the Cgroup is allocated based on the above IO performance upper limit and the reserved IO ratio in cinder.
[0058] The process of creating the Cgroup may specifically include: when the cinder is monitored to be started, performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk and obtain the IO performance upper limit, and creating the Cgroup based on the IO performance upper limit; calculating the remaining IO ratio according to the IO reserved ratio in the configuration item of the cinder, and calculating the target IO performance corresponding to the Cgroup based on the remaining IO ratio and the IO performance upper limit, and allocating the target IO performance to the Cgroup; the IO reserved ratio is a ratio reserved based on the IO performance requirements of other system components in the OpenStack cloud platform except the cinder. In this embodiment, when the startup of cinder in the OpenStack cloud platform is monitored, the global IO controller in cinder is initialized. Specifically, the IO performance test can be performed on the local hard disk of the target physical machine first, so as to obtain the performance upper limit of the local hard disk and obtain the IO performance upper limit, and then a Cgroup is created based on the IO performance upper limit, and then the remaining IO ratio is calculated according to the IO reservation ratio in the configuration item of the cinder, and then the target IO performance corresponding to the Cgroup is calculated based on the remaining IO ratio and the IO performance upper limit, and the target IO performance is allocated to the Cgroup, wherein the IO reservation ratio is the ratio reserved based on the IO performance requirements of other system components in the OpenStack cloud platform except the cinder, for example, when the IO reservation ratio in the configuration item of cinder is 80%, the remaining IO ratio corresponding to cinder is 20%. By pre-setting the IO reservation ratio in the configuration item of cinder, the IO performance allocation of cinder can be limited, so as to avoid allocating too much IO performance to cinder and thus affecting the normal operation of other system components and the operating system, and to ensure that there is enough IO reservation, so as to provide the normal operation of other system components and the operating system of the cloud platform, thereby ensuring the stability of the cloud platform and the physical machine.
[0059] Specifically, the IO performance test of the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit may include: creating a temporary file on the local hard disk, using the preset first data block and the second data block to perform data block write operation and data block read operation on the temporary file in sequence, so as to obtain the write performance upper limit and the read performance upper limit of the local hard disk, and obtain the IO performance upper limit; the size of the first data block is larger than the size of the second data block. For example, a temporary file is created on the local hard disk, and then the temporary file is continuously written 1024 times using the preset first data block (such as a data block of 1MB size), and the total writing time is recorded, so as to calculate the write performance of the local hard disk per second; and then the temporary file is continuously read 1024 times, and the total writing time is recorded, so as to calculate the read performance of the local hard disk per second. Then, the temporary file is sequentially written and read 10240 times using the preset second data block (such as a data block of 4k size), and the time consumption is recorded respectively, so as to calculate the number of reads and writes of the local hard disk per second.
[0060] The creating of the Cgroup based on the IO performance upper limit may specifically include: creating the Cgroup based on the IO performance upper limit by using a libcgroup tool provided by the Linux kernel. For example, create a Cgroup using the libcgroup tool that comes with Linux, such as using the Cgcreate –g blkio:[cgroup_name] command. Specifically, you can use cgset –r blkio.throttle.write_bps_device="[local disk device id] IO_bps_write"[cgroup_name] to set the Cgroup's write upper limit; use cgset –r blkio.throttle.read_bps_device="[local disk device id] IO_bps_read" [cgroup_name] to set the Cgroup's read upper limit; use cgset –r blkio.throttle.write_iops_device="[local disk device id] IO_bps_read"[cgroup_name] to set the Cgroup's read iops (Input / Output Operations Per Second, input / output operations per second) upper limit; use cgset –r blkio.throttle.read_iops_device="[local disk device id] IO_bps_write" [cgroup_name] to set the upper limit of Cgroup's write iops.
[0061] In this embodiment, the IO performance test of the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit may specifically include: using the sub-process corresponding to any storage backend of the cinder to perform the IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk and obtain the IO performance upper limit. It can be understood that one cinder can correspond to multiple storage backends. In this embodiment, when the sub-processes corresponding to multiple storage backends are executed simultaneously, the sub-process corresponding to any storage backend of cinder can be used to perform the IO performance test on the local hard disk of the target physical machine, thereby obtaining the performance upper limit of the local hard disk, that is, the IO performance upper limit.
[0062] In addition, before using the context manager to modify the child process or the command line corresponding to the child process to obtain the modified process or the modified command line, it may also include: determining whether a Cgroup already exists; if it is detected that a Cgroup has been created, triggering the step of using the context manager to modify the child process or the command line corresponding to the child process to obtain the modified process or the modified command line; if the Cgroup does not exist, creating a Cgroup through the global IO controller in cinder, and after the creation is completed, triggering the step of using the context manager to modify the child process or the command line corresponding to the child process to obtain the modified process or the modified command line. By adding this judgment mechanism, the smooth execution of the hard disk IO control can be guaranteed, so that all operations on the local disk IO are within the controllable range, and sufficient IO reservation is guaranteed for the normal operation of other system components and operating systems of the cloud platform.
[0063] In addition, it should be pointed out that the process of using the subprocess corresponding to any storage backend of the cinder to perform IO performance testing on the local hard disk of the target physical machine may also include: using the local lock to create a lock file in the target physical machine and obtain the operation right of the lock file, so that when other subprocesses except the subprocess corresponding to any storage backend query that the operation right of the lock file is in a non-idle state, the Cgroup creation process is skipped and the storage backend corresponding to the other subprocess is directly initialized. In this embodiment, see Figure 2As shown, considering the scenario of multiple storage backends, there may be multiple cinder storage backends that perform IO performance tests on the local hard disk at the same time (that is, initialize their own global IO controllers at the same time). At this time, in order to avoid other sub-processes from performing repeated IO performance tests on the local hard disk of the physical machine, when it is detected that the sub-process corresponding to any storage backend of cinder is performing IO performance tests on the local hard disk of the target physical machine, a lock file is created in the target physical machine using the local lock, and the operation right of the lock file is obtained. In this way, when other sub-processes except the sub-process corresponding to any storage backend query the existence of the lock file and the operation right of the lock file is in a non-idle state, it can be known that the IO performance test is currently being performed on the local hard disk. At this time, the Cgroup creation process can be directly skipped, and the storage backend of cinder corresponding to the above-mentioned other sub-processes can be initialized directly. The initialization operation specifically refers to the operation corresponding to step S13, that is, using the context manager to modify the other sub-processes or the command line corresponding to the other sub-processes, obtain the modified process or the modified command line and add it to the Cgroup created in advance by the global IO controller, so as to perform IO performance allocation. When the local lock mechanism detects that an IO performance test is in progress, a lock file is created in the physical machine, that is, a lock operation is performed, which can ensure the uniqueness of the IO performance test operation. Once a storage backend tests the local hard disk, other backends will no longer repeat the test. In this way, the accuracy of the local disk IO test can be guaranteed, and inaccurate test results caused by multiple cinders performing IO performance tests on the local hard disk at the same time can be avoided. At the same time, it also avoids slow cinder startup caused by repeated performance tests and waste of resources caused by repeated IO tests.
[0064] Further, when it is detected that the modified process or the modified command line is executed, the modified process or the modified command line is deleted from the Cgroup. That is, after the modified process or the modified command line is executed, it is deleted from the Cgroup, so that the IO of the local hard disk can be controlled in real time through the Cgroup, and the completed IO read and write operation requests can be cleared in time, and the storage resources of the Cgroup can be saved.
[0065] It can be seen that the embodiment of the present application is applied to a global IO controller pre-created in the cinder of the OpenStack cloud platform. When an IO read / write operation request for the local hard disk of the target physical machine is monitored, multiple sub-operation steps in the target IO operation corresponding to the IO read / write operation request are first determined, and the sub-processes of the storage backend corresponding to each of the sub-operation steps are obtained. Then, the sub-process or the command line corresponding to the sub-process is modified by using the context manager to obtain a modified process or a modified command line, and the modified process or the modified command line is added to the Cgroup pre-created by the global IO controller to control the IO performance allocation of the modified process or the modified command line, and the modified process or the modified command line is executed in the Cgroup based on the allocated IO performance; wherein, the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder. In the embodiment of the present application, a global IO controller is created in cinder, and a Cgroup is created in advance through the global IO controller. When an IO read and write operation request for a local hard disk is monitored, multiple sub-operation steps in the target IO operation corresponding to the request are first determined, and then the sub-process corresponding to each sub-operation step is determined, and each sub-process or the command line corresponding to the sub-process is modified by using a context manager, and the modified process or the modified command line is added to the Cgroup, thereby controlling the IO performance allocation of the process or command line, and executing the corresponding process or command line in the Cgroup. It should be pointed out that the IO performance of the Cgroup in the embodiment of the present application is allocated based on the IO performance upper limit of the local hard disk and the reserved IO ratio in cinder. It can be seen that the embodiment of the present application splits the IO read and write operations, and allocates IO performance to the processes corresponding to each split sub-operation through the Cgroup. Since the IO performance of the Cgroup is allocated based on the reserved IO ratio, the IO performance is reserved for other system components. Therefore, the IO of each sub-operation step on the local hard disk can be controlled, and sufficient IO reservation is guaranteed, so that other system components and operating systems of the cloud platform can operate normally, thereby ensuring the stability of the cloud platform and the physical machine.
[0066] For example, see Figure 3As shown, the present application modifies the context information of the sub-process of the storage backend corresponding to the sub-operation steps corresponding to each cinder (i.e., cinder1, cinder2, and cinder3) through the context manager, thereby realizing the overall IO control of multiple cinders (i.e., cinder1, cinder2, and cinder3) through the Cgroup created in advance by the global IO controller. Since the IO performance allocated to each cinder is allocated based on the IO reserved ratio in the configuration item of the cinder, it can ensure that other system components, such as mysql, rabbitmq, etc. are not restricted, thereby ensuring the normal operation of other system components and operating systems of the cloud platform.
[0067] The present application embodiment discloses a specific hard disk IO control method, which is applied to a global IO controller pre-created in cinder of the OpenStack cloud platform, see Figure 4 As shown, the method includes:
[0068] Step S21: when an IO read / write operation request for a local hard disk of a target physical machine is monitored, a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request is determined; the OpenStack cloud platform is deployed on the target physical machine.
[0069] Step S22: Obtain the sub-processes of the storage backend corresponding to each of the sub-operation steps.
[0070] Step S23: using a context manager to add a preset prefix to the command line corresponding to the child process to obtain a modified command line, so that when the modified command line is executed, the process executed by the modified command line is automatically added to the Cgroup previously created by the global IO controller; the preset prefix contains an identifier related to the Cgroup; the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder.
[0071] In this embodiment, after obtaining the subprocess of the storage backend corresponding to each of the sub-operation steps, a context manager can be used to add a preset prefix in front of the command line corresponding to the above subprocess, such as adding cgexec –g [cgroup_name] in front of the command line corresponding to the subprocess to obtain a modified command line. In this way, when the modified command line is executed, the process executed by the modified command line can be automatically added to the Cgroup created in advance by the above global IO controller, that is, the process executing the modified command line in the Cgroup; wherein the preset prefix contains a Cgroup-related identifier. Furthermore, when it is monitored that the process of the modified command line is executed, the corresponding process can be automatically removed from the Cgroup and wait to receive new IO read and write operation requests for the local hard disk.
[0072] For more specific processing procedures of the above steps S21 and S22, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0073] It can be seen that the embodiment of the present application is applied to a global IO controller pre-created in the cinder of the OpenStack cloud platform. After obtaining the sub-processes of the storage backend corresponding to each sub-operation step, a preset prefix is added to the command line corresponding to the sub-process using the context manager to obtain a modified command line, so that when the modified command line is executed, the process executed by the modified command line is automatically added to the Cgroup pre-created by the global IO controller; the preset prefix contains an identifier related to the Cgroup; the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder. The embodiment of the present application uses the Cgroup created by the global IO controller to uniformly manage all IO operations on the local hard disk, simplifies the process of IO operation calculation and allocation, and refines the control to each sub-process, thereby ensuring that the process is not affected during non-IO operations. Specifically, it can include two major functions: creating a mirror cloud hard disk and uploading a cloud hard disk mirror. It also combines the context manager to implement the running of the modified command line in the Cgroup, so that the IO of each sub-operation step on the local hard disk is within the controllable range, and ensures that there is sufficient IO reservation for the normal operation of other system components and operating system of the cloud platform, thereby ensuring the stability of the cloud platform and physical machines.
[0074] The present application embodiment discloses a specific hard disk IO control method, which is applied to a global IO controller pre-created in cinder of the OpenStack cloud platform, see Figure 5 As shown, the method includes:
[0075] Step S31: when an IO read / write operation request for a local hard disk of a target physical machine is monitored, a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request is determined; the OpenStack cloud platform is deployed on the target physical machine.
[0076] Step S32: Obtain the sub-processes of the storage backend corresponding to each of the sub-operation steps.
[0077] Step S33: obtaining the process control symbol of the child process, and using the context manager to add the process control symbol to the child process to obtain the added process, and adding the added process to the Cgroup created in advance by the global IO controller to control the IO performance allocation of the modified process, and executing the modified process in the Cgroup based on the allocated IO performance; the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder.
[0078] In this embodiment, after obtaining the sub-processes of the storage backend corresponding to each of the sub-operation steps, the process control symbol (PID, Process Identifier) of each sub-process can be obtained through the os.getpid() command, and then the context manager is used to add the above process control symbol to the sub-process to obtain the added process, and then the above added process is added to the Cgroup created in advance by the global IO controller, so as to control the IO performance allocation of the above modified process, and finally the above modified process is executed within the Cgroup based on the allocated IO performance.
[0079] Specifically, the process of adding the process control symbol to the child process using the context manager to obtain the added process, and adding the added process to the Cgroup pre-created by the global IO controller may include: using the context manager and using the cgclassify command to add the process control symbol to the child process to obtain the added process; adding the added process to the Cgroup pre-created by the global IO controller. For example, using the context manager to add the process control symbol to the corresponding child process to obtain the added process, and then using the cgclassify command, such as cgclassify -g blkio: / [cgroup_name] [pid] to add the added process to the Cgroup pre-created by the global IO controller, thereby controlling the IO performance allocation of the modified process, and finally executing the modified process in the Cgroup based on the allocated IO performance. Further, after the modified process is executed, the modified process may be moved to the system default unrestricted Cgroup through the cgclassify command, such as cgclassify -g blkio: / [pid].
[0080] For more specific processing procedures of the above steps S31 and S32, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0081] It can be seen that the embodiment of the present application is applied to a global IO controller pre-created in the cinder of the OpenStack cloud platform. After obtaining the sub-processes of the storage backend corresponding to each sub-operation step, the process control symbol of the sub-process is obtained, and the process control symbol is added to the sub-process by using the context manager to obtain the added process, and the added process is added to the Cgroup pre-created by the global IO controller to control the IO performance allocation of the modified process, and execute the modified process in the Cgroup based on the allocated IO performance; the Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder. Embodiment of the present application The embodiment of the present application uniformly manages all IO operations on the local hard disk through the Cgroup created by the global IO controller, simplifies the process of IO operation calculation and allocation, and refines the control to each sub-process, thereby ensuring that the process is not affected during non-IO operations, and combines the context manager to implement the running of the added process in the Cgroup, so that the IO of each sub-operation step on the local hard disk is within the controllable range, and ensures that there is sufficient IO reservation for the normal operation of other system components and operating system of the cloud platform, thereby ensuring the stability of the cloud platform and physical machines.
[0082] Furthermore, the present application also discloses an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0083] Figure 6 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the hard disk IO control method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0084] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0085] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0086] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the hard disk IO control method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0087] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the hard disk IO control method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the above embodiments, and no further description will be given here.
[0088] Furthermore, an embodiment of the present application also discloses a computer program product, including a computer program / instruction, which implements the steps of the hard disk IO control method disclosed above when executed by a processor.
[0089] In this specification, each embodiment 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. For the products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.
[0090] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0091] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0092] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0093] The above is a detailed introduction to a hard disk IO control method, product, device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A hard disk IO control method, characterized in that: Applicable to the global IO controller pre-created in cinder of the OpenStack cloud platform, including: When an IO read / write operation request for a local hard disk of a target physical machine is monitored, a plurality of sub-operation steps in a target IO operation corresponding to the IO read / write operation request is determined; the OpenStack cloud platform is deployed on the target physical machine; Obtain the subprocess of the storage backend corresponding to each of the sub-operation steps; Using a context manager to modify the child process or a command line corresponding to the child process to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller to control IO performance allocation of the modified process or the modified command line, and executing the modified process or the modified command line in the Cgroup based on the allocated IO performance; The Cgroup is created based on the IO performance upper limit of the local hard disk, and the IO performance of the Cgroup is allocated based on the IO performance upper limit and the reserved IO ratio in the cinder; The hard disk IO control method further includes: when the cinder is detected to be started, performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit, and creating a Cgroup based on the IO performance upper limit; calculating the remaining IO ratio according to the IO reserved ratio in the configuration item of the cinder, and calculating the target IO performance corresponding to the Cgroup based on the remaining IO ratio and the IO performance upper limit, and allocating the target IO performance to the Cgroup; the IO reserved ratio is a ratio reserved based on the IO performance requirements of other system components in the OpenStack cloud platform except the cinder; The creating a Cgroup based on the IO performance upper limit includes: creating a Cgroup based on the IO performance upper limit by using a libcgroup tool provided by a Linux kernel.
2. The hard disk IO control method according to claim 1, characterized in that: The performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit includes: A temporary file is created on the local hard disk, and a data block write operation and a data block read operation are performed on the temporary file in sequence using a preset first data block and a preset second data block, so as to obtain a write performance upper limit and a read performance upper limit of the local hard disk, and obtain an IO performance upper limit; the size of the first data block is larger than the size of the second data block.
3. The hard disk IO control method according to claim 1, characterized in that: The performing an IO performance test on the local hard disk of the target physical machine to obtain the performance upper limit of the local hard disk to obtain the IO performance upper limit includes: The IO performance test is performed on the local hard disk of the target physical machine by using a subprocess corresponding to any storage backend of the cinder to obtain the performance upper limit of the local hard disk and obtain the IO performance upper limit.
4. The hard disk IO control method according to claim 3, characterized in that: The process of using the subprocess corresponding to any storage backend of the cinder to perform an IO performance test on the local hard disk of the target physical machine also includes: A lock file is created in the target physical machine using a local lock, and the operation right of the lock file is obtained, so that when other sub-processes except the sub-process corresponding to any one of the storage backends query that the operation right of the lock file is in a non-idle state, the creation process of the Cgroup is skipped, and the storage backend corresponding to the other sub-process is directly initialized.
5. The hard disk IO control method according to claim 1, characterized in that: The step of determining a plurality of sub-operations in the target IO operation corresponding to the IO read / write operation request comprises: Determine a target IO operation corresponding to the IO read / write operation request; the target IO operation is an operation of creating a mirrored cloud hard disk; Obtain multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include a step of downloading the image to a local, a step of converting the local image format, and a step of writing the converted image to a cloud hard disk.
6. The hard disk IO control method according to claim 1, characterized in that: The step of determining a plurality of sub-operations in the target IO operation corresponding to the IO read / write operation request comprises: Determine a target IO operation corresponding to the IO read / write operation request; the target IO operation is a cloud hard disk image upload operation; Obtain multiple sub-operation steps corresponding to the target IO operation; the sub-operation steps include exporting a cloud hard disk to a local step, converting a local image format, and uploading the converted image to an image warehouse step.
7. The hard disk IO control method according to claim 1, characterized in that: The using of the context manager to modify the subprocess or the command line corresponding to the subprocess to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller includes: A context manager is used to add a preset prefix in front of the command line corresponding to the child process to obtain a modified command line, so that when the modified command line is executed, the process executed by the modified command line is automatically added to the Cgroup previously created by the global IO controller; the preset prefix contains an identifier related to the Cgroup.
8. The hard disk IO control method according to claim 1, characterized in that: The using of the context manager to modify the subprocess or the command line corresponding to the subprocess to obtain a modified process or a modified command line, and adding the modified process or the modified command line to a Cgroup pre-created by the global IO controller includes: The process controller of the child process is obtained, and the process controller is added to the child process by using a context manager to obtain an added process, and the added process is added to a Cgroup pre-created by the global IO controller.
9. The hard disk IO control method according to claim 8, characterized in that: The process of adding the process control symbol to the child process by using the context manager to obtain an added process, and adding the added process to a Cgroup pre-created by the global IO controller includes: Using a context manager and using the cgclassify command, the process control symbol is added to the child process to obtain the added process; The added process is added to the Cgroup pre-created by the global IO controller.
10. The hard disk IO control method according to any one of claims 1 to 9, characterized in that: Also includes: When it is detected that the modified process or the modified command line is executed completely, the modified process or the modified command line is deleted from the Cgroup.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
12. An electronic device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the hard disk IO control method as described in any one of claims 1 to 10 is implemented.
13. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the hard disk IO control method according to any one of claims 1 to 10 is implemented.
