A disk writing control method and related device
By calculating the disk write ratio and dynamically adjusting the write strategy, the problem of excessive replacement time and high cost caused by the expiration of multiple disks at the same time is solved, extending the disk life and ensuring business continuity.
Patent Information
- Application Number
- CN202310745626.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2043-06-21
AI Technical Summary
When multiple disks are read and write operations at the same time, if multiple disks have a lifetime expiration at the same time, the replacement time will be longer, which will affect the read and write delay and may lead to business interruption. At the same time, replacement of disks too early can lead to higher costs.
By obtaining all the write request information received in the previous cycle and the amount of data that can be written to the second disk, the proportion of the amount of data written to the first disk to the actual amount of data written to the first disk is calculated, and the amount of data written to the first disk is dynamically adjusted according to this proportion to extend the life of the second disk.
While ensuring that the read and write delay is relatively low, the write ratio is dynamically adjusted, the life of the second disk is extended, the frequency and cost of replacing the disk is reduced, and business interruptions are avoided.
Smart Images

Figure CN116954500B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular to a disk writing control method and related devices. Background Art
[0002] Disk is one of the most important storage devices in a computer, including solid state drives (SSD), hard disk drives (HDD), etc.
[0003] As disks continue to perform read and write operations, their lifespan decreases. In actual applications, multiple disks are generally used for read and write operations at the same time. If multiple disks reach the end of their lifespan at the same time, they all need to be replaced. Since there are a large number of disks reaching the end of their lifespan, the replacement time is long, which seriously affects the read and write latency and even causes business interruption, further affecting business continuity. If a disk is replaced too early when there is a lot of life left, it will result in a high cost. Summary of the invention
[0004] The present application provides a disk writing control method and related device, which can extend the life of the disk.
[0005] In a first aspect, the present application provides a disk write control method, which can be applied to the field of storage technology, including:
[0006] First, a first ratio is obtained, where the first ratio refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on the information of all write requests received in the previous cycle and the amount of data that can be written to the second disk; then, the amount of data written to the first disk in this cycle is controlled according to the first ratio.
[0007] In the present application, the amount of data that can be written to the second disk is used to evaluate the life of the second disk, and the proportion of writing to the first disk is dynamically adjusted by counting the information of write requests received in each cycle and the amount of data that can be written to the second disk. This is to ensure that when the read and write delays are relatively low, the data is partially written to the first disk according to the first ratio, so as to further extend the life of the second disk.
[0008] In a possible implementation of the first aspect, calculating the first ratio according to information of all write requests received in a previous cycle and the amount of data that can be written to the second disk includes:
[0009] Obtaining information about all write requests received in the previous cycle, the information including the amount of data in each write request and the number of times each location in the first disk is written;
[0010] According to the data volume of each write request, the actual data volume written in the previous cycle is obtained;
[0011] Obtain the amount of data that can be written to the second disk and the amount of data currently written to the second disk that are counted in the previous cycle;
[0012] According to the amount of data that can be written to the second disk and the amount of data currently written to the second disk, the expected amount of data to be written is obtained;
[0013] A first ratio is obtained according to the amount of data actually written and the amount of data expected to be written.
[0014] In this implementation, the life of the second disk is evaluated by counting the amount of data that can be written to the second disk in the previous cycle and the amount of data currently written to the second disk. In addition, the first proportion that should be written to the first disk in this cycle is calculated based on the actual amount of data written in the previous cycle and the expected amount of data written, so as to dynamically adjust the proportion written to the first disk, ensuring that the data is partially written to the first disk according to the first proportion when the read and write latency is relatively low, so as to further extend the life of the second disk.
[0015] In a possible implementation of the first aspect, obtaining the expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk includes:
[0016] Get the expected usage time of the second disk;
[0017] The quotient of the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk and the expected usage time is taken as the expected amount of data to be written.
[0018] In this implementation, the life of the second disk is evaluated by counting the amount of data that can be written to the second disk in the previous cycle and the amount of data currently written to the second disk. Further, the amount of data expected to be written in the previous cycle is calculated by the difference between the two and the quotient of the expected usage time.
[0019] In a possible implementation manner of the first aspect, obtaining the first ratio according to the actual amount of data written and the expected amount of data written includes:
[0020] The quotient of the difference between the amount of data actually written and the amount of data expected to be written and the amount of data actually written is taken as the first ratio.
[0021] In this implementation, the difference between the actual amount of data written and the expected amount of data written is calculated to determine the amount of data written to the first disk. Furthermore, the quotient of the difference and the actual amount of data written is used as the ratio directly written to the first disk.
[0022] In a possible implementation of the first aspect, controlling the amount of data written to the first disk in the current cycle according to the first ratio includes:
[0023] Receive write request;
[0024] Obtaining a first threshold value of the amount of data written to the first disk in this cycle according to the first ratio;
[0025] When the amount of data in the write request is greater than or equal to the first threshold, the data in the write request is written into the first disk.
[0026] In this implementation method, after calculating the first proportion that should be written to the first disk in the current cycle based on the statistical data of the previous cycle, a first threshold for the amount of data written to the first disk in the current cycle is set to filter the amount of data written to the first disk, thereby dynamically adjusting the amount of data written to the first disk in the current cycle based on the first proportion calculated based on the life of the second disk in the previous cycle.
[0027] In a possible implementation manner of the first aspect, obtaining a first threshold value of the amount of data written to the first disk in the current cycle according to the first ratio includes:
[0028] Obtaining a first value according to the amount of data actually written in the previous cycle and the first ratio;
[0029] Arrange the data amounts of each write request in descending order, starting from the largest data amount, and sequentially superimpose the data amounts with the next data amount until the superimposed sum is greater than or equal to the first value;
[0030] The value of the last superimposed data amount is used as the first threshold value of the data amount written to the first disk.
[0031] In this implementation, after calculating the first ratio based on the information of the write request received in the previous cycle and the relevant information corresponding to the life of the second disk, the first threshold is determined in a certain manner within the current cycle to filter the amount of data written to the first disk, thereby dynamically adjusting the amount of data written to the first disk within the current cycle based on the first ratio calculated based on the life of the second disk in the previous cycle.
[0032] In a possible implementation of the first aspect, writing data whose write request data amount is greater than or equal to the first threshold into the first disk further includes:
[0033] When the amount of data of the write request received in this cycle is greater than or equal to the first threshold, obtaining the number of times the location written by the write request has been written;
[0034] If the number of times is less than or equal to the second threshold, the data of the write request is written into the first disk.
[0035] In this implementation, during this cycle, when the amount of data in the received write request is greater than or equal to the first threshold, the data to be written to the first disk can be filtered based on the number of times each location in the first disk is written by data, so that data corresponding to locations with larger data amounts or fewer write times are preferentially selected to be written to the first disk, thereby ensuring that the read and write latency of the second disk is relatively low, reducing the loss to the second disk, and further extending the life of the second disk.
[0036] In a second aspect, the present application provides a disk writing control device, comprising:
[0037] A ratio acquisition module, used to acquire a first ratio, where the first ratio refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on information of all write requests received in the previous cycle and the amount of data that can be written to the second disk;
[0038] The write control module is used to control the amount of data written to the first disk in this cycle according to the first ratio.
[0039] In a possible implementation manner of the second aspect, the ratio acquisition module is further used to:
[0040] Obtaining information about all write requests received in the previous cycle, the information including the amount of data in each write request and the number of times each location in the first disk is written;
[0041] According to the data volume of each write request, the actual data volume written in the previous cycle is obtained;
[0042] Obtain the amount of data that can be written to the second disk and the amount of data currently written to the second disk that are counted in the previous cycle;
[0043] According to the amount of data that can be written to the second disk and the amount of data currently written to the second disk, the expected amount of data to be written is obtained;
[0044] A first ratio is obtained according to the amount of data actually written and the amount of data expected to be written.
[0045] In a possible implementation manner of the second aspect, the ratio acquisition module is further used to:
[0046] Get the expected usage time of the second disk;
[0047] The quotient of the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk and the expected usage time is taken as the expected amount of data to be written.
[0048] In a possible implementation manner of the second aspect, the ratio acquisition module is further used to:
[0049] The quotient of the difference between the amount of data actually written and the amount of data expected to be written and the amount of data actually written is taken as the first ratio.
[0050] In a possible implementation manner of the second aspect, the write control module is further configured to:
[0051] Receive write request;
[0052] Obtaining a first threshold value of the amount of data written to the first disk in this cycle according to the first ratio;
[0053] When the amount of data in the write request is greater than or equal to the first threshold, the data in the write request is written into the first disk.
[0054] In a possible implementation manner of the second aspect, the write control module is further configured to:
[0055] Obtaining a first value according to the amount of data actually written in the previous cycle and the first ratio;
[0056] Arrange the data amounts of each write request in descending order, starting from the largest data amount, and sequentially superimpose the data amounts with the next data amount until the superimposed sum is greater than or equal to the first value;
[0057] The value of the last superimposed data amount is used as the first threshold value of the data amount written to the first disk.
[0058] In a possible implementation manner of the second aspect, the write control module is further configured to:
[0059] When the amount of data of the write request received in this cycle is greater than or equal to the first threshold, obtaining the number of times the location written by the write request has been written;
[0060] If the number of times is less than or equal to the second threshold, the data of the write request is written into the first disk.
[0061] In a third aspect, the present application provides a computing device cluster, characterized in that it includes at least one computing device, each computing device includes a processor and a memory;
[0062] The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0063] In a fourth aspect, the present application provides a computer program product comprising instructions, characterized in that when the instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0064] In a fifth aspect, the present application provides a chip system, which includes a processor for implementing the method in the first aspect or any possible implementation of the first aspect. In one possible design, the chip system also includes a memory for storing program instructions and / or data. The chip system can be composed of a chip, or can include a chip and other discrete devices.
[0065] In a sixth aspect, the present application provides a computer-readable storage medium, characterized in that it includes computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0066] The solutions of the second to sixth aspects mentioned above are used to implement or cooperate with the method in the first aspect or any possible implementation method thereof, and therefore can achieve the same or corresponding beneficial effects as the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 A schematic diagram of a structure of a computing device provided in an embodiment of the present application;
[0068] Figure 2 A schematic diagram of a storage system provided in an embodiment of the present application;
[0069] Figure 3a A flowchart of a disk writing control method currently provided;
[0070] Figure 3b A schematic diagram of a flow chart of a disk writing control method provided in an embodiment of the present application;
[0071] Figure 3c Another schematic diagram of a flow chart of a disk writing control method provided in an embodiment of the present application;
[0072] Figure 4 Another schematic diagram of a flow chart of a disk writing control method provided in an embodiment of the present application;
[0073] Figure 5 A schematic diagram of the structure of a disk writing control device provided in an embodiment of the present application;
[0074] Figure 6 A schematic diagram of a structure of a computing device provided in an embodiment of the present application;
[0075] Figure 7 A schematic diagram of a structure of a computing device cluster provided in an embodiment of the present application;
[0076] Figure 8Another structural diagram of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] 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 some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0078] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices.
[0079] The term "and / or" in this application can be a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.
[0080] It should also be noted that, in some alternative implementations, the functions / acts noted may occur out of the order of the drawings. For example, two figures shown in succession may in fact occur substantially simultaneously or may sometimes be performed in the reverse order, depending on the functions / acts involved.
[0081] In the embodiments of the present application, unless otherwise specified, the meaning of "at least one" refers to one or more, and the meaning of "plurality" refers to two or more. It is understood that in the present application, "when", "if" and "if" all refer to the device making corresponding processing under certain objective circumstances, and do not limit the time, nor do they require that there must be a judgment action when the device is implemented, nor do they mean that there are other limitations. In addition, the special word "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described as "exemplary" is not necessarily interpreted as being superior or better than other embodiments.
[0082] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0083] First, in order to better understand the solution of the embodiment of the present application, the application scenario of the embodiment of the present application is described below. The disk write control method provided by the embodiment of the present application is mainly applied in a computing device to continue the availability of a service.
[0084] Combine the following Figure 1 and Figure 2 , an example is given to illustrate the application scenario of the disk write control method provided in the embodiment of the present application. Figure 1 , Figure 1 A schematic diagram of a computing device provided in an embodiment of the present application. Figure 1 In the process, the computing device 100 on the service side receives the write request sent by the client module (Client) on the application side through the server module (Server), and after a series of processing, writes the data of the write request into the second disk as the cache and then returns the result to the client module, and then the background task schedules the data in the cache of the second disk to the first disk as the main memory. After receiving the read request, the computing device 100 will first read the data from the second disk as the cache. If the second disk is not hit, the data will be read from the first disk as the main memory. Among them, the second disk may include a solid state disk (Solid State Disk or Solid State Drive, SSD), etc., and the first disk may include a mechanical hard disk (Hard Disk Drive, HDD), etc.
[0085] It can be understood that the life of a disk mainly includes the write life and the read life, and the read life is almost infinite. Therefore, the life of the disk referred to in the embodiments of the present application mainly refers to the write life of the disk.
[0086] In order to improve storage performance and save costs, a major architecture currently used is Figure 2 See Figure 2 , Figure 2 A schematic diagram of a storage system provided in an embodiment of the present application. Figure 2 In the distributed storage system shown in FIG. 1 , the storage system 200 includes at least one server-side server such as Figure 1The computing device 100 and at least one computing device 201 on the application side are shown. The at least one computing device 100 and the at least one computing device 201 can be connected in a one-to-one, many-to-one, one-to-many or many-to-many manner, which can be set according to actual needs.
[0087] The computing device 201 is mainly responsible for providing storage services for upper-layer applications. The computing device 100 is mainly responsible for managing the physical storage devices connected to the backend and combining these devices into one or more logical storage pools. After a series of processing by the server module of the computing device 100, the input / output (I / O) write request from the computing device 201 is written to the second disk as cache, and the background task scheduling then writes the data in the second disk as cache to the first disk as main memory.
[0088] In an optional implementation, Figure 2 The distributed storage system shown can adopt the architecture of SSD hard disk and HDD hard disk of PCIe based on NVMe protocol. Among them, SSD hard disk can also be replaced by SSD with SATA (Serial Advanced Technology Attachment) interface or SAS (Serial Attached Small Computer System Interface) SSD.
[0089] It is understandable that the storage capacity of the second disk is generally lower than that of the first disk, but the storage performance is better than that of the first disk. The read and write speed of the first disk is lower and the cost is relatively low. Compared with a storage system composed entirely of second disks with better performance, the use of Figure 2 The architecture shown is mainly to improve storage performance while saving costs. In actual application, the method provided in the embodiment of the present application can be applied to any application scenario involving a cache medium with a write life, which is only an example and not limited here.
[0090] In addition, it is understandable that Figure 2 The specific composition and connection method of the modules inside the at least one computing device 100 and the at least one computing device 201 shown in the figure can be set according to actual needs. The client module inside the application side and the server module inside the service side are only summarized as examples. Any other modules, devices or method steps with the same functions as the two can be implemented. This is only for the convenience of explaining the workflow between the various computing devices in the distributed storage system, and no limitation is made.
[0091] exist Figure 1 The computing device shown is Figure 2 Based on the storage system shown, see Figure 3a , Figure 3a The following is a flowchart of a disk writing control method currently provided. Figure 3a As shown, after the server module of the computing device 100 receives the write request sent by the client module, it is processed by the server module and written into the storage medium. If the cache as the second disk is turned on, the computing device writes the data into the cache as the second disk and returns success to the client module, and then the background task writes the cache data in the second disk into the first disk as the main memory. When the cache as the second disk is turned off, the computing device directly writes the data into the first disk and returns success to the client module.
[0092] However, in a distributed storage system, if the second disks in the computing devices reach the end of their life in batches, the replacement process will be long due to the large number of disks. If the data writing speed is temporarily controlled or the cache function is turned off, it will seriously affect the read and write latency, and even cause business interruption and affect business continuity. If the second disks are replaced too early when there is a lot of life left, the cost will be too high.
[0093] In order to solve the above problems, the present application embodiment provides a disk writing control method, which is applied to Figure 1 For details, see Figure 3b , Figure 3b A flowchart of a disk write control method provided in an embodiment of the present application. The method specifically includes: S1, obtaining a first ratio, wherein the first ratio refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on the information of all write requests received in the previous cycle and the amount of data that can be written to the second disk. S2, controlling the amount of data written to the first disk in this cycle according to the first ratio.
[0094] After obtaining the first ratio of write-through writing to the first disk, the write-through strategy can be adjusted according to the first ratio. Figure 3c , Figure 3c Another flowchart of the disk writing control method provided in the embodiment of the present application is shown below. Figure 3c As shown, for the sake of ease of explanation, it is assumed that the disk write control method provided in the embodiment of the present application is executed by a cache management module in the computing device. Those skilled in the art will appreciate that the cache management module is only for illustration and is not intended to be limiting.
[0095] After receiving the write request sent by the client module, the server module of the computing device 100 writes the request to the storage medium after being processed by the server module. If the cache of the second disk is turned on, the cache management module executes the following steps: Figure 3b The method shown writes a portion of the write request data to the cache of the second disk, and directly writes the other portion of the write request data to the first disk as the main memory. If the cache of the second disk is closed, the computing device directly writes the data to the first disk and returns success to the client module.
[0096] It is understandable that since the performance of the second disk is generally better than that of the first disk, writing data to the first disk will lose performance. Therefore, currently, the computing device will generally write data to the first disk only when it is determined that the cache of the second disk is in a closed state. In the present application, the life of the second disk is evaluated by counting the amount of data that can be written to the second disk, and the proportion of writing to the first disk is dynamically adjusted by counting the information of write requests received in each cycle and the amount of data that can be written to the second disk, so as to ensure that when the read and write latency is relatively low, the data is partially written to the first disk according to the first ratio, thereby further extending the life of the second disk.
[0097] The above introduces the application scenario of the disk write control method provided by the embodiment of the present application. The following will introduce in detail the implementation process of the disk write control method provided by the embodiment of the present application.
[0098] First of all, in order to better understand the solutions of the embodiments of the present application, the relevant terms and concepts that may be involved in the embodiments of the present application are introduced below.
[0099] (1) Total write volume
[0100] Total Bytes Written refers to the total amount of data that can be written to a disk before the disk's life ends.
[0101] (2) Write-through
[0102] In the embodiment of the present application, Write Through means that the computing device writes data directly to the first disk of the back end without writing it to the second disk.
[0103] The present application provides a disk write control method. For ease of understanding, the disk write control method provided by the present application embodiment is specifically described below in conjunction with the accompanying drawings and application scenarios. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided by the present application embodiment are also applicable to similar technical problems.
[0104] See also Figure 4, Figure 4 Another flow chart of the disk writing control method provided in the embodiment of the present application is shown in FIG. Figure 1 The computing device shown is executed. Figure 4 As shown, the computing device can perform the following steps 401 to 409 to extend the availability of the service and prolong the service life of the disk.
[0105] Step 401: The computing device obtains information of all write requests received in the previous cycle.
[0106] In the embodiment of the present application, at the end of each cycle, the computing device recalculates the first ratio of data written through to the first disk based on the information of all write requests received in the cycle, and adjusts the amount of data written through to the first disk according to the ratio in the next cycle. The information of the write request includes the amount of data of each write request and the number of times each location in the first disk is written.
[0107] It is understood that the number of times each location in the first disk is written refers to the number of times or frequency at which data is written to each location in the first disk in the computing device. To simplify the description, the number of times each location in the first disk is written is described by a hotspot value. It should be understood that a high hotspot value of a certain location means that the number of times data is written to the location in the first disk is large, and a low hotspot value of a certain location means that the number of times data is written to the location in the first disk is small.
[0108] Step 402: The computing device obtains the amount of data actually written in the previous cycle based on the amount of data in each write request.
[0109] In an embodiment of the present application, at the end of the previous cycle, the computing device uses the sum of the data amounts of each write request received in the previous cycle as the total amount of data actually written in the previous cycle.
[0110] Optionally, the computing device may also obtain the number of all write requests received in the previous cycle, and use the product of the number of all write requests and the average value of the data volume of each write request as the total data volume actually written in the previous cycle.
[0111] It is understandable that in actual application, the total amount of data actually written in the previous cycle can be obtained in a variety of ways according to actual needs. This is only one implementation method and is not limited.
[0112] Step 403: The computing device obtains the amount of data that can be written to the second disk and the amount of data currently written to the second disk, which are counted in the previous cycle.
[0113] In the embodiment of the present application, the amount of data that can be written to the second disk refers to the total amount of data that can be written to the second disk from the time the second disk leaves the factory to the end of its service life, and can be used to evaluate the service life of the second disk. The amount of data currently written to the second disk refers to the total amount of data written to the second disk at the end of the previous cycle, and is not limited to the amount of data written in the previous cycle.
[0114] In an optional implementation, the amount of data that can be written to the second disk and the amount of data currently written to the second disk can be obtained by querying through a SMART (Self-Monitoring Analysis and Reporting Technology) interface.
[0115] Step 404: The computing device obtains the expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk.
[0116] In the embodiment of the present application, after obtaining the amount of data that can be written to the second disk and the amount of data currently written to the second disk, the computing device can further calculate the amount of data that is expected to be written to the second disk in the previous cycle.
[0117] As an optional implementation, the computing device obtains the expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk, which may include:
[0118] The computing device obtains the expected usage time of the second disk.
[0119] The computing device uses the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk, and the quotient of the expected usage time as the expected amount of data to be written.
[0120] In this implementation, the computing device first obtains the expected usage time of the second disk, where the expected usage time refers to the difference between the life cycle time defined by a specific product and the usage time of the current disk, which can be modified by external input. Then, the computing device can obtain the expected amount of data written to the second disk in the previous cycle through the following formula (1).
[0121]
[0122] Step 405: The computing device obtains a first ratio according to the actual amount of data written and the expected amount of data written.
[0123] In the embodiment of the present application, after calculating the amount of data expected to be written to the second disk in the previous cycle, the computing device can calculate the proportion of data that should be written to the first disk in the current cycle according to the amount of data actually written to the second disk in the previous cycle and the amount of data expected to be written. The computing device directly writes a portion of the data to the first disk as the main memory according to the first proportion, and writes the other portion of the data to the cache of the second disk.
[0124] As an optional implementation manner, the computing device obtains the first ratio according to the actual amount of data written and the expected amount of data written, which may include:
[0125] The computing device uses the quotient of the difference between the amount of data actually written and the amount of data expected to be written and the amount of data actually written as the first ratio.
[0126] In this implementation, the computing device calculates the amount of data that can be written in excess of the expected amount of data written based on the difference between the amount of data actually written and the expected amount of data written in the previous cycle. This amount of data is the amount of data that the computing device needs to write through to the first disk. Further, by calculating the quotient of the difference between the amount of data actually written and the expected amount of data written and the amount of data actually written, the first ratio of the data to be written through to the first disk is obtained. The specific formula (2) is as follows:
[0127]
[0128] It is understandable that, in practical applications, the specific calculation method for calculating the first ratio can be adjusted according to actual needs, and all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application. Those skilled in the art will know that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0129] Step 406: The computing device receives a write request in this cycle.
[0130] In an embodiment of the present application, after the computing device calculates the first ratio of write-through to the first disk at the end of the previous cycle, in the next cycle, i.e., the current cycle described in the embodiment of the present application, the computing device receives write requests in real time and adjusts the first ratio of write-through according to the calculated first ratio.
[0131] Step 407: The computing device obtains a first threshold value of the amount of data written to the first disk in the current cycle according to the first ratio.
[0132] In an embodiment of the present application, after the computing device has counted the information of all write requests received in the previous cycle and calculated the first ratio, it obtains a first threshold value for the amount of data written to the first disk in this cycle based on the first ratio, and has filtered the received write requests based on the threshold to filter out the data written to the first disk through write-through.
[0133] As an optional implementation manner, the computing device obtains a first threshold value of the amount of data written to the first disk in the current cycle according to the first ratio, which may include:
[0134] The computing device obtains a first value according to the amount of data actually written in the previous cycle and the first ratio.
[0135] The computing device arranges the data amounts of each write request in order from large to small, starting from the largest data amount, and sequentially superimposes them with the next data amount until the superimposed sum is greater than or equal to the first value.
[0136] The computing device uses the value of the last superimposed data amount as a first threshold value of the data amount written to the first disk.
[0137] In this implementation, the computing device first calculates the amount of data written through the first disk according to the amount of data actually written in the previous cycle and the first ratio. On this basis, the computing device screens the data written through the first disk in this cycle according to the information of all write requests in the previous cycle, and preferentially selects to write through the large block of data greater than or equal to the first threshold value to the first disk from the write requests received in this cycle. Wherein, the method for determining the first threshold value is to arrange the data amount of each write request received in the previous cycle from large to small or from small to large, starting from the largest data amount, and sequentially superimpose with the data amount of the second order to obtain the superimposed data amount, and then continue to superimpose the superimposed data amount with the data amount of the third order, and so on, until the superimposed data amount is greater than or equal to the first value. Wherein, the first value refers to the product of the amount of data actually written in the previous cycle and the first ratio. Subsequently, the last superimposed data amount is screened out from the superimposed data amount, and the data amount of the write request is determined as the first threshold for screening whether it is a large block of data.
[0138] Step 408: The computing device determines whether the amount of data in the write request is greater than or equal to the first threshold. If yes, execute step 409. If no, terminate the operation.
[0139] In an embodiment of the present application, after determining the first threshold, the computing device can determine whether the data volume of the write request is greater than or equal to the first threshold when receiving a write request in real time within this cycle, so as to filter out the data of the write request that can be written through to the first disk.
[0140] In an optional implementation, in addition to determining whether the amount of data in the write request is greater than or equal to the first threshold, the computing device also needs to determine the number of times the location written by the write request has been written, specifically including:
[0141] Counts the number of times the location that the device has received a write request to write has been written.
[0142] If the number of times is less than or equal to the second threshold, the computing device writes the data of the write request into the first disk.
[0143] In this implementation, after determining whether the amount of data in the write request is greater than or equal to the first threshold, the computing device may further determine whether the number of times the location where the write request is written has been written is less than or equal to the second threshold. If the condition is met, the computing device writes the data of the write request to the first disk.
[0144] In this implementation, after the computing device filters out the data of the write request that meets the requirements of large blocks of data according to the first threshold, it further prioritizes data with lower hotspot values to be written to the first disk, so as to extend the usage time and life of the second disk while ensuring that the write latency is relatively stable as much as possible.
[0145] It is understandable that in actual application, rules for filtering the data written through the first disk may be set according to actual needs. Here, only several implementation modes are exemplified and are not limited.
[0146] Step 409: The computing device writes the data of the write request into the first disk.
[0147] In an embodiment of the present application, the computing device receives write requests in real time during the current cycle, and after filtering out write requests that meet the requirements according to the first threshold and / or hotspot value, writes the data of the write requests to the first disk.
[0148] It can be understood that the computing device can indirectly evaluate the life of the second disk by counting the proportion of data written to the first disk. If the remaining life of the second disk is lower, the proportion of data written to the first disk is higher relative to the proportion of data written to the second disk.
[0149] Optionally, if the computing device filters out the total amount of data written through to the first disk according to the first threshold and / or hotspot value in the current cycle and finds that it is less than the first value, one optional method is to directly ignore it, and another optional method is to calculate the amount of data that should be written through but is not written through to the first disk in the current cycle, and when calculating the first ratio of write-through in the next cycle, add the remaining amount of data to the amount of data written through to the first disk.
[0150] Optionally, if the computing device filters out the total amount of data written through to the first disk as greater than a first value based on the first threshold and / or hotspot value during the current cycle, the computing device will calculate the total amount of data currently written through to the first disk after each time data is written through to the first disk during the current cycle, and stop writing data through to the first disk when the total amount of data is greater than the first value, that is, greater than the product of the amount of data actually written in the previous cycle and the first ratio.
[0151] exist Figures 1 to 4 On the basis of the corresponding embodiments, in order to better implement the above solutions of the embodiments of the present application, the following also provides related devices for implementing the above solutions. Figure 5 , Figure 5 A schematic diagram of the structure of a disk write control device provided in an embodiment of the present application.
[0152] The disk writing control device 5000 may be located at Figure 1 In the computing device shown in FIG. 5 , the disk writing control device 5000 includes:
[0153] The ratio acquisition module 5001 is used to acquire a first ratio, which refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on information of all write requests received in the previous cycle and the amount of data that can be written to the second disk;
[0154] The write control module 5002 is used to control the amount of data written to the first disk in this cycle according to the first ratio.
[0155] As an example of a software functional unit, the write control module 5002 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the write control module 5002 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including a data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0156] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0157] As an example of a hardware functional unit, the write control module 5002 may include at least one computing device, such as a server, etc. Alternatively, the write control module 5002 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0158] The multiple computing devices included in the write control module 5002 can be distributed in the same region or in different regions. The multiple computing devices included in the write control module 5002 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the write control module 5002 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0159] It should be noted that, in other embodiments, the write control module 5002 can be used to execute any step in the disk write control method, and the ratio acquisition module 5001 can be used to execute any step in the disk write control method. The steps that the ratio acquisition module 5001 and the write control module 5002 are responsible for implementing can be specified as needed. The ratio acquisition module 5001 and the write control module 5002 respectively implement different steps in the disk write control method to realize the full functions of the disk write control device.
[0160] In a possible implementation, the ratio acquisition module 5001 is further used for:
[0161] Obtaining information about all write requests received in the previous cycle, including the amount of data in each write request and the number of times each location in the first disk is written;
[0162] According to the data volume of each write request, the actual data volume written in the previous cycle is obtained;
[0163] Obtain the amount of data that can be written to the second disk and the amount of data currently written to the second disk that are counted in the previous cycle;
[0164] According to the amount of data that can be written to the second disk and the amount of data currently written to the second disk, the expected amount of data to be written is obtained;
[0165] A first ratio is obtained according to the amount of data actually written and the amount of data expected to be written.
[0166] In a possible implementation, the ratio acquisition module 5001 is further used for:
[0167] Get the expected usage time of the second disk;
[0168] The quotient of the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk and the expected usage time is taken as the expected amount of data to be written.
[0169] In a possible implementation, the ratio acquisition module 5001 is further used for:
[0170] The quotient of the difference between the amount of data actually written and the amount of data expected to be written and the amount of data actually written is taken as the first ratio.
[0171] In a possible implementation, the write control module 5002 is further used for:
[0172] Receive write request;
[0173] Obtaining a first threshold value of the amount of data written to the first disk in this cycle according to the first ratio;
[0174] When the amount of data in the write request is greater than or equal to the first threshold, the data in the write request is written into the first disk.
[0175] In a possible implementation, the write control module 5002 is further used for:
[0176] Obtaining a first value according to the amount of data actually written in the previous cycle and the first ratio;
[0177] Arrange the data amounts of each write request in descending order, starting from the largest data amount, and sequentially superimpose the data amounts with the next data amount until the superimposed sum is greater than or equal to the first value;
[0178] The value of the last superimposed data amount is used as the first threshold value of the data amount written to the first disk.
[0179] In a possible implementation, the write control module 5002 is further used for:
[0180] When the amount of data of the write request received in this cycle is greater than or equal to the first threshold, obtaining the number of times the location written by the write request has been written;
[0181] If the number of times is less than or equal to the second threshold, the data of the write request is written into the first disk.
[0182] In this embodiment, the operations performed by each unit in the disk writing control device 5000 are the same as those described above. Figure 4 The method described in the embodiment shown is similar, and can be used to implement the functions of the computing device in the above method embodiment, and can also achieve the beneficial effects of the above method embodiment, which will not be repeated here. Among them, the ratio acquisition module 5001 and the write control module 5002 can be implemented by software, or can be implemented by hardware.
[0183] The present application also provides a computing device 600. Figure 6 , Figure 6 A schematic diagram of a computing device provided in an embodiment of the present application. Figure 6 As shown, computing device 600 includes: bus 602, processor 604, memory 606 and communication interface 608. Processor 604, memory 606 and communication interface 608 communicate through bus 602. Computing device 600 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in computing device 600.
[0184] The bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The bus 602 may include a path for transmitting information between various components of the computing device 600 (eg, the memory 606, the processor 604, and the communication interface 608).
[0185] The processor 604 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0186] The memory 606 may include a hard disk drive (HDD), a solid state drive (SSD), or other disks.
[0187] The memory 606 stores executable program codes, and the processor 604 executes the executable program codes to respectively implement the functions of the aforementioned ratio acquisition module 5001 and the write control module 5002, thereby implementing the disk write control method. That is, the memory 606 stores instructions for executing the disk write control method.
[0188] The communication interface 608 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 600 and other devices or communication networks.
[0189] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0190] See also Figure 7 , Figure 7 A schematic diagram of a computing device cluster provided in an embodiment of the present application. Figure 7 As shown, the computing device cluster includes at least one computing device 600. The memory 606 in one or more computing devices 600 in the computing device cluster may store the same instructions for executing the disk write control method.
[0191] In some possible implementations, the memory 606 of one or more computing devices 600 in the computing device cluster may also store partial instructions for executing the disk write control method. In other words, the combination of one or more computing devices 600 may jointly execute the instructions for executing the disk write control method.
[0192] It should be noted that the memory 606 in different computing devices 600 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the disk write control device. That is, the instructions stored in the memory 606 in different computing devices 600 can implement the functions of one or more modules in the ratio acquisition module 5001 and the write control module 5002.
[0193] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Figure 8 shows a possible implementation. Figure 8 , Figure 8 Another structural diagram of a computing device cluster provided in an embodiment of the present application. Figure 8 As shown, two computing devices 600A and 600B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 606 in the computing device 600A stores instructions for executing the function of the write control module 5002. At the same time, the memory 606 in the computing device 600B stores instructions for executing the function of the ratio acquisition module 5001.
[0194] It should be understood that Figure 8 The functions of the computing device 600A shown in FIG. 6A may also be completed by multiple computing devices 600. Similarly, the functions of the computing device 600B may also be completed by multiple computing devices 600.
[0195] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the disk write control method.
[0196] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute a disk write control method, or instruct the computing device to execute a disk write control method.
[0197] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0198] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0199] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0200] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0201] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
Claims
1. A disk writing control method, characterized in that: include: Obtaining a first ratio, where the first ratio refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on information of all write requests received in the previous cycle and the amount of data that can be written to the second disk; controlling the amount of data written to the first disk in the current cycle according to the first ratio; The calculating the first ratio according to information of all write requests received in the previous cycle and the amount of data that can be written to the second disk includes: Acquire information about all write requests received in the previous cycle, the information including the amount of data in each write request and the number of times each location in the first disk is written; According to the data amount of each write request, the data amount actually written in the previous cycle is obtained; Obtaining the amount of data that can be written to the second disk and the amount of data currently written to the second disk, which are counted in the previous cycle; Obtaining an expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk; Obtaining a first ratio according to the actually written data amount and the expected written data amount; The controlling the amount of data written to the first disk in the current cycle according to the first ratio includes: Receive write request; Obtaining a first threshold value of the amount of data written to the first disk in the current cycle according to the first ratio; When the data amount of the write request is greater than or equal to the first threshold, the data of the write request is written into the first disk.
2. The method according to claim 1, characterized in that The step of obtaining the expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk comprises: Obtaining the expected usage time of the second disk; The quotient of the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk and the expected usage time is taken as the expected amount of data to be written.
3. The method according to claim 1 or 2, characterized in that: The obtaining a first ratio according to the actually written data amount and the expected written data amount includes: The quotient of the difference between the actually written data amount and the expected written data amount and the actually written data amount is taken as the first ratio.
4. The method according to claim 1, characterized in that The obtaining, according to the first ratio, a first threshold value of the amount of data written to the first disk in the current cycle includes: Obtaining a first value according to the amount of data actually written in the previous cycle and the first ratio; Arrange the data amounts of the write requests in descending order, starting from the largest data amount, and sequentially superimpose the data amounts with the next data amount until the superimposed sum is greater than or equal to the first value; The value of the last superimposed data amount is used as a first threshold value of the data amount written to the first disk.
5. The method according to claim 1 or 4, characterized in that: The step of writing the data whose data amount of the write request is greater than or equal to the first threshold into the first disk further includes: When the amount of data of the write request received in the current cycle is greater than or equal to the first threshold, obtaining the number of times the location written by the write request has been written; If the number of times is less than or equal to a second threshold, the data of the write request is written into the first disk.
6. A disk writing control device, characterized in that: include: A ratio acquisition module, used to acquire a first ratio, where the first ratio refers to the ratio of the amount of data written to the first disk to the amount of data actually written, and the first ratio is calculated based on information of all write requests received in the previous cycle and the amount of data that can be written to the second disk; a write control module, used for controlling the amount of data written to the first disk in this cycle according to the first ratio; The ratio acquisition module is also used for: Acquire information about all write requests received in the previous cycle, the information including the amount of data in each write request and the number of times each location in the first disk is written; According to the data amount of each write request, the data amount actually written in the previous cycle is obtained; Obtaining the amount of data that can be written to the second disk and the amount of data currently written to the second disk, which are counted in the previous cycle; Obtaining an expected amount of data to be written according to the amount of data that can be written to the second disk and the amount of data currently written to the second disk; Obtaining a first ratio according to the actually written data amount and the expected written data amount; The write control module is also used for: Receive write request; Obtaining a first threshold value of the amount of data written to the first disk in the current cycle according to the first ratio; When the data amount of the write request is greater than or equal to the first threshold, the data of the write request is written into the first disk.
7. The device according to claim 6, characterized in that The ratio acquisition module is also used for: Obtaining the expected usage time of the second disk; The quotient of the difference between the amount of data that can be written to the second disk and the amount of data currently written to the second disk and the expected usage time is taken as the expected amount of data to be written.
8. The device according to claim 6 or 7, characterized in that The ratio acquisition module is also used for: The quotient of the difference between the actually written data amount and the expected written data amount and the actually written data amount is taken as the first ratio.
9. The device according to claim 6, characterized in that The write control module is also used for: Obtaining a first value according to the amount of data actually written in the previous cycle and the first ratio; Arrange the data amounts of the write requests in descending order, starting from the largest data amount, and sequentially superimpose the data amounts with the next data amount until the superimposed sum is greater than or equal to the first value; The value of the last superimposed data amount is used as a first threshold value of the data amount written to the first disk.
10. The device according to claim 6 or 9, characterized in that The write control module is also used for: When the amount of data of the write request received in the current cycle is greater than or equal to the first threshold, obtaining the number of times the location written by the write request has been written; If the number of times is less than or equal to a second threshold, the data of the write request is written into the first disk.
11. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 5.
12. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 5.
13. A computer-readable storage medium, characterized in that: The method comprises computer program instructions, and when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Disk storage system and method for controlling disk storage and device thereof
CN101533335A
An optical disc data reading and writing method
CN109426434A