Data writing method and device, computer equipment and storage medium

By determining the worn hard disk in the hard disk domain and writing hot data to the hard disk, the problem of simultaneous failure of the hard disk in the hard disk domain is solved, and the differentiation of the wear degree of the hard disk is achieved, and data loss is avoided.

CN120233933APending Publication Date: 2025-07-01DAWNING INFORMATION IND (BEIJING) CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311839398.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-28
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

In the prior art, all hard disks in the hard disk domain fail at the same time within a similar time, resulting in loss of user data.

Method used

By obtaining the wear degree of multiple hard disks to be written in the hard disk domain, determine the wear hard disk that meets the accelerated wear conditions, and write the hot data in the target data to the worn hard disk, so that it wears quickly and pulls away the wear degree of other hard disks.

Benefits of technology

It effectively avoids all hard disks in the hard disk domain failing simultaneously within a similar time, reducing the risk of data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120233933A_ABST
    Figure CN120233933A_ABST
Patent Text Reader

Abstract

The invention relates to a data writing method and device, computer equipment and a storage medium. The method comprises the following steps: in response to a write-in request of target data, obtaining wear degrees of a plurality of to-be-written hard disks in a hard disk domain; determining a worn hard disk from the plurality of hard disks according to the wear degrees of the plurality of hard disks; the worn hard disk represents a hard disk meeting an accelerated wear condition; and writing hot data in the target data into the worn hard disk. By adopting the method, different hard disks in the same hard disk domain have different wear states, so that the situation that all the hard disks in the hard disk domain fail at the same time in similar time to cause user data loss is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data storage, and particularly to a data writing method, apparatus, computer device, and storage medium. Background Art

[0002] Virtualized redundant array of independent disks (RAID) is a type of multi-disk management technology that can provide high-performance storage.

[0003] In related technologies, all hard disks in a hard disk domain of a disk array are usually divided into logical blocks, and the logical blocks are used as units to form stripes for data reading and writing, so as to ensure that the hard disks in the hard disk domain have the same amount of read and write data.

[0004] However, the data writing method in related technologies may cause all hard disks in the hard disk domain to fail simultaneously within a short period of time, resulting in the loss of user data. Summary of the Invention

[0005] Based on this, in view of the above technical problems, it is necessary to provide a data writing method, apparatus, computer device, and storage medium, which can enable different hard disks in the same hard disk domain to have different wear states, effectively avoid all hard disks in the hard disk domain from failing simultaneously within a short period of time, and cause the loss of user data.

[0006] In a first aspect, this application provides a data writing method, including:

[0007] Responding to a write request for target data, obtaining the wear degrees of multiple hard disks to be written in a hard disk domain;

[0008] Determining worn hard disks from the multiple hard disks according to the wear degrees of the multiple hard disks; a worn hard disk refers to a hard disk that meets the accelerated wear condition;

[0009] Writing the hot data in the target data into the worn hard disks.

[0010] In the data writing method provided by the embodiments of the present application, in response to a write request for target data, the wear degrees of multiple hard disks to be written in a hard disk domain are obtained. Then, based on the wear degrees of the multiple hard disks, a worn hard disk is determined from the multiple hard disks. The worn hard disk represents a hard disk that meets the accelerated wear condition. Finally, the hot data in the target data is written into the worn hard disk. In this method, through the wear degrees of the multiple hard disks to be written and the accelerated wear condition, a worn hard disk with accelerated wear can be determined from the multiple hard disks. Since the hot data needs to be updated frequently, the hot data in the target data can be written into the worn hard disk later, causing the worn hard disk to wear quickly and widening the wear degree gap between the worn hard disk and other hard disks. In this way, within the same hard disk domain, different hard disks will have different wear degrees, effectively avoiding all hard disks in the hard disk domain from failing simultaneously in a short period of time and causing user data loss.

[0011] In one embodiment, the accelerated wear condition includes a high wear degree threshold; determining a worn hard disk from multiple hard disks includes:

[0012] Comparing the wear degrees of the multiple hard disks with the high wear degree threshold;

[0013] Determining the hard disk among the multiple hard disks that exceeds the high wear degree threshold and has the maximum wear degree as the worn hard disk.

[0014] In the data writing method provided by the embodiments of the present application, by comparing the wear degrees of multiple hard disks with the high wear degree threshold, and then determining the hard disk among the multiple hard disks that exceeds the high wear degree threshold and has the maximum wear degree as the worn hard disk. In this method, the accelerated wear condition includes a high wear degree threshold. By comparing the wear degree of each hard disk with the high wear degree threshold, it is determined that the hard disk with a wear degree exceeding the high wear degree threshold and the maximum wear degree is the worn hard disk. In this way, placing the hot data in the target data on the hard disk with the maximum wear degree can cause the hard disk to wear out fastest, that is, the hard disk will fail fastest, widening the wear degree gap with other hard disks and avoiding multiple hard disks from being damaged simultaneously.

[0015] In one embodiment, the accelerated wear condition includes a low wear degree threshold and a hot data quantity condition; determining a worn hard disk from multiple hard disks includes:

[0016] Obtaining at least one candidate hard disk that exceeds the low wear degree threshold from the multiple hard disks;

[0017] Based on the existing hot data quantity of each candidate hard disk, obtaining a target candidate hard disk that meets the hot data quantity condition among the candidate hard disks;

[0018] Determining the target candidate hard disk as the worn hard disk.

[0019] In the data writing method provided by the embodiments of the present application, at least one candidate hard disk with a wear degree exceeding the low wear degree threshold is obtained from multiple hard disks, and then according to the existing hot data quantity of each candidate hard disk, a target candidate hard disk that meets the hot data quantity condition is obtained from each candidate hard disk. Finally, the target candidate hard disk is determined as the worn hard disk. In this method, another optional way to determine the worn hard disk is provided. The accelerated wear conditions include the low wear degree threshold and the hot data quantity condition. First, multiple candidate hard disks are determined according to the low wear degree threshold, and then the worn hard disk is determined from the candidate hard disks through the hot data quantity condition.

[0020] In one embodiment, obtaining, according to the existing hot data quantity of each candidate hard disk, a target candidate hard disk that meets the hot data quantity condition from each candidate hard disk includes:

[0021] Determining the expected hot data quantity of each candidate hard disk according to the existing hot data quantity of each candidate hard disk;

[0022] For any candidate hard disk, if the expected hot data quantity of the candidate hard disk is greater than the existing hot data quantity of the candidate hard disk, then determine the candidate hard disk as the target candidate hard disk.

[0023] In the data writing method provided by the embodiments of the present application, the expected hot data quantity of each candidate hard disk is determined according to the existing hot data quantity of each candidate hard disk. For any candidate hard disk, if the expected hot data quantity of the candidate hard disk is greater than the existing hot data quantity of the candidate hard disk, then determine the candidate hard disk as the target candidate hard disk. In this method, after the worn hard disk is determined, hot data needs to be written into the worn hard disk. Therefore, when determining the target candidate hard disk from multiple candidate hard disks, the candidate hard disks that can still hold hot data should be used as the target candidate hard disks, that is, the expected hot data quantity of each candidate hard disk is determined, and the candidate hard disks with an expected hot data quantity greater than the existing hot data quantity are used as the target candidate hard disks.

[0024] In one embodiment, determining the expected hot data quantity of each candidate hard disk according to the existing hot data quantity of each candidate hard disk includes:

[0025] Determining the total existing hot data quantity of all candidate hard disks according to the existing hot data quantity of each candidate hard disk;

[0026] Determining the expected hot data ratio of each candidate hard disk according to the wear degree of each candidate hard disk;

[0027] Determining the expected hot data quantity of each candidate hard disk according to the expected hot data ratio of each candidate hard disk and the total existing hot data quantity.

[0028] In the data writing method provided by the embodiment of the present application, by determining the total amount of existing hot data of all candidate hard disks according to the amount of existing hot data of each candidate hard disk, and then determining the expected hot data ratio of each candidate hard disk according to the wear degree of each candidate hard disk, and then determining the expected hot data amount of each candidate hard disk according to the expected hot data ratio and the total amount of existing hot data of each candidate hard disk. In this method, by introducing the expected hot data ratio and determining the total amount of existing hot data of all candidate hard disks, the expected hot data amount of each candidate hard disk can be determined according to the expected hot data ratio and the total amount of existing hot data of each candidate hard disk, providing data support for determining the target candidate hard disk.

[0029] In one embodiment, determining the expected hot data ratio of each candidate hard disk according to the wear degree of each candidate hard disk includes:

[0030] Sorting each candidate hard disk in ascending order according to the wear degree of each candidate hard disk to obtain the hard disk ordinal number of each candidate hard disk;

[0031] For any candidate hard disk, determining the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks as the expected hot data ratio of the candidate hard disk.

[0032] In the data writing method provided by the embodiment of the present application, sorting each candidate hard disk in ascending order according to the wear degree of each candidate hard disk to obtain the hard disk ordinal number of each candidate hard disk, and then for any candidate hard disk, determining the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks as the expected hot data ratio of the candidate hard disk. In this method, by sorting in reverse order according to the wear degree of each candidate hard disk to obtain the hard disk ordinal number of each candidate hard disk, and determining the expected hot data ratio of each candidate hard disk based on the hard disk ordinal number of each candidate hard disk, an optional way is provided for quickly determining the expected hot data ratio of each candidate hard disk.

[0033] In one embodiment, the target data further includes cold data, and the method further includes:

[0034] Obtaining the remaining hard disks among the multiple hard disks except the worn hard disks;

[0035] Writing the cold data into the remaining hard disks.

[0036] In the data writing method provided by the embodiments of the present application, the remaining hard disks except the worn hard disks are obtained from multiple hard disks, and then the cold data is written into the remaining hard disks. In this method, if a worn hard disk that can store the hot data in the target data is determined from multiple hard disks, then the remaining hard disks except the worn hard disk among the multiple hard disks can be used to write the cold data in the target data. In this way, by writing the cold data in the target data into the remaining hard disks, since the cold data does not need to be updated frequently, the remaining hard disks will not wear out quickly, which widens the wear degree gap with the worn hard disk and avoids multiple hard disks reaching the end of their life cycles in a similar time, thus preventing data loss.

[0037] In a second aspect, the present application also provides a data writing device, including:

[0038] A data acquisition module, configured to acquire the wear degrees of multiple hard disks to be written in a hard disk domain in response to a write request for target data;

[0039] A hard disk determination module, configured to determine a worn hard disk from multiple hard disks according to the wear degrees of the multiple hard disks; a worn hard disk represents a hard disk that meets the accelerated wear condition;

[0040] A data writing module, configured to write the hot data in the target data into the worn hard disk.

[0041] In a third aspect, the embodiments of the present application also provide a computer device. The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps in any of the embodiments in the first aspect are implemented.

[0042] In a fourth aspect, the embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the embodiments in the first aspect are implemented.

[0043] In a fifth aspect, the embodiments of the present application also provide a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the embodiments in the first aspect are implemented.

[0044] The above data writing method, device, computer device and storage medium obtain the wear degrees of multiple hard disks to be written in a hard disk domain in response to a writing request for target data, and then determine a worn hard disk from the multiple hard disks according to the wear degrees of the multiple hard disks. The worn hard disk represents a hard disk that meets the accelerated wear condition. Finally, the hot data in the target data is written into the worn hard disk. In this method, the worn hard disk with accelerated wear can be determined from the multiple hard disks through the wear degrees of the multiple hard disks to be written and the accelerated wear condition. Since the hot data needs to be updated frequently, the hot data in the target data can be written into the worn hard disk later, so that the worn hard disk wears quickly, and the wear degree between the worn hard disk and other hard disks is widened. In this way, within the same hard disk domain, different hard disks will have different wear degrees, effectively avoiding all hard disks in the hard disk domain from failing simultaneously in a similar time, resulting in user data loss. Description of the Drawings

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0046] Figure 1 It is the internal structure diagram of a computer device in an embodiment;

[0047] Figure 2 It is the flowchart of the data writing method in an embodiment;

[0048] Figure 3 It is the flowchart of determining a worn hard disk in an embodiment;

[0049] Figure 4 It is the flowchart of determining a worn hard disk in another embodiment;

[0050] Figure 5 It is the flowchart of obtaining target candidate hard disks in an embodiment;

[0051] Figure 6 It is the flowchart of determining the expected quantity of hot data in an embodiment;

[0052] Figure 7 It is the flowchart of determining the expected proportion of hot data in an embodiment;

[0053] Figure 8 It is the flowchart of writing cold data in an embodiment;

[0054] Figure 9 It is the flowchart of the data writing method in another embodiment;

[0055] Figure 10 It is a schematic structural diagram of a data writing device in an embodiment. Detailed implementation manners

[0056] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] The data writing method provided by the embodiment of the present application can be applied to a computer device. The computer device can be a server, and its internal structure diagram can be as Figure 1 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data to be written. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a data writing method. Those skilled in the art can understand that Figure 1 the structure shown in

[0058] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0059] Since the lifespan of a solid-state drive is related to the total amount of data written to the drive, when all the drives within a drive domain bear almost the same amount of write data, the lifespan of the drives will also tend to be the same, resulting in all the drives within the drive domain failing simultaneously within a similar period of time, leading to RAID stripe over-redundancy and causing user data loss. Therefore, in a solid-state drive storage system, it is necessary to consider the reverse wear of the drives to prevent multiple drives from failing simultaneously at the end of their lifespan.

[0060] In related technologies, using the write method of traditional mechanical drives, metadata or frequently updated data is written to the drive that needs to be worn out more quickly, so that the drive wears out quickly, widening the wear degree between this drive and other drives, and preventing multiple drives from being damaged simultaneously.

[0061] Updating the RAID stripe using the overwrite method can indeed accelerate the rapid wear of a drive, but it will increase the data write amplification, which will instead cause the lifespan of the solid-state drive to be consumed too quickly. Moreover, in a flash memory system with virtual RAID technology and the append write method, new data will be redistributed to the logical blocks of other drives, and the old data will wait for garbage collection as invalid data, and it will not cause data such as parity blocks to be updated every time data is updated. Therefore, for virtual RAID technology and append write flash memory systems, a more suitable data write method needs to be adopted to effectively avoid all the drives within the drive domain from failing simultaneously within a similar period of time and causing user data loss.

[0062] Based on this, the present application proposes a data write method. Through the wear degree and accelerated wear conditions of multiple drives to be written, the worn drive for accelerated wear can be determined from multiple drives. Since hot data needs to be updated frequently, the hot data in the target data can then be written to the worn drive, causing the worn drive to wear out quickly and widening the wear degree between the worn drive and other drives. In this way, within the same drive domain, different drives will have different wear degrees, effectively avoiding all the drives within the drive domain from failing simultaneously within a similar period of time and causing user data loss.

[0063] It should be noted that the beneficial effects or technical problems solved by the embodiments of the present application are not limited to this one, and there may also be other implicit or related problems. For details, please refer to the descriptions of the following embodiments.

[0064] The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.

[0065] In an exemplary embodiment, as Figure 2As shown in the figure, a data writing method is provided. Taking the application of this method to a computer device as an example, it includes the following steps 201 to 203. Among them:

[0066] S201, in response to a write request for target data, obtain the wear degrees of multiple hard disks to be written in the hard disk domain.

[0067] In the embodiments of the present application, the target data is the data that needs to be stored in the hard disk, and may include hot data, cold data, etc. The write request for the target data may be a request sent by the user to the computer device when there is a need to write the target service to the hard disk. Among them, hot data refers to the data frequently updated by the user; cold data refers to the data infrequently updated by the user. The hard disk domain refers to a combination of multiple hard disks. A storage system may include one hard disk domain or multiple hard disk domains.

[0068] The reading and writing of a solid-state hard disk are performed in units of pages, and the erasure is performed in units of blocks. If a solid-state hard disk wants to write data to a page, then the page needs to perform an erasure operation first. And the number of erasure times of each flash block of the solid-state hard disk is limited. Therefore, the more data is written, the more erasure times there are, and then the shorter the life of the solid-state hard disk is. The wear degree of the hard disk refers to the degree of loss of the hard disk life. The remaining life of the hard disk can be directly read from the hard disk, and then the consumed life can be determined according to the remaining life, that is, the wear degree of the hard disk.

[0069] In practical applications, when data is written to the hard disk, the data is divided into multiple data blocks, and then the multiple data blocks are respectively stored in multiple hard disks. In this way, when writing the target data, there are also multiple hard disks to be written corresponding to the target data.

[0070] Exemplarily, in response to a write request for target data, the multiple hard disks to be written corresponding to the target data can be first determined, and then the life of each hard disk can be directly read from each hard disk, and the consumed life of each hard disk can be determined according to the read hard disk life, that is, the wear degree of each hard disk is obtained.

[0071] S202, according to the wear degrees of the multiple hard disks, determine the worn hard disks from the multiple hard disks.

[0072] In the embodiments of the present application, the worn hard disk represents a hard disk that meets the accelerated wear condition. Among them, the accelerated wear condition may include a wear degree threshold, the number of existing hot data conditions, etc.

[0073] Exemplarily, obtain the preset accelerated wear condition, compare the wear degrees of the multiple hard disks with the accelerated wear condition, and determine the hard disks that meet the accelerated wear condition as the worn hard disks. For example, if the accelerated wear condition is a wear degree threshold, then the hard disks among the multiple hard disks with a wear degree greater than or equal to the wear degree threshold are determined as the worn hard disks.

[0074] S203, write the hot data in the target data into the worn hard disk.

[0075] After determining the worn hard disk, write the hot data in the target data into the worn hard disk, and write the cold data in the target data into the remaining hard disks.

[0076] In the data writing method provided by the embodiments of the present application, in response to a write request for target data, the wear degrees of multiple hard disks to be written in the hard disk domain are obtained, and then, based on the wear degrees of the multiple hard disks, a worn hard disk is determined from the multiple hard disks. The worn hard disk represents a hard disk that meets the accelerated wear condition. Finally, the hot data in the target data is written into the worn hard disk. In this method, through the wear degrees of the multiple hard disks to be written and the accelerated wear condition, a worn hard disk with accelerated wear can be determined from the multiple hard disks. Since the hot data needs to be updated frequently, the hot data in the target data can be written into the worn hard disk later, so that the worn hard disk wears quickly, and the wear degree of the worn hard disk is separated from that of other hard disks. In this way, within the same hard disk domain, different hard disks will have different wear degrees, effectively avoiding all hard disks in the hard disk domain from failing simultaneously in a short period of time, causing user data loss.

[0077] The accelerated wear condition includes a high wear degree critical value. Based on the wear degrees of the multiple hard disks and the high wear degree critical value, the worn hard disks among the multiple hard disks can be determined. Based on this, in the following embodiment, the method for determining the worn hard disk will be described.

[0078] In an exemplary embodiment, as Figure 3 shown, determining the worn hard disk from multiple hard disks includes:

[0079] S301, compare the wear degrees of the multiple hard disks with the high wear degree critical value.

[0080] The high wear degree critical value is a pre-determined high wear degree threshold, expressed as a percentage, for example, it can be 80%.

[0081] Compare the wear degrees of all the multiple hard disks with the high wear degree critical value to determine the worn hard disks among the multiple hard disks.

[0082] S302, determine the hard disk with the largest wear degree among the multiple hard disks that exceeds the high wear degree critical value as the worn hard disk.

[0083] Determine the hard disk with the largest wear degree among the multiple hard disks whose wear degree is greater than or equal to the wear degree critical value as the worn hard disk. For example, if the high wear degree critical value is 80% and the wear degrees of the multiple hard disks are 70%, 62%, 65%, 81%, and 90% respectively, then the hard disk with a wear degree of 90% is determined as the worn hard disk.

[0084] In the data writing method provided by the embodiments of the present application, by comparing the wear degrees of multiple hard disks with a high wear degree critical value, the hard disk among the multiple hard disks that exceeds the high wear degree critical value and has the largest wear degree is determined as the worn hard disk. In this method, the accelerated wear condition includes the high wear degree critical value. By comparing the wear degree of each hard disk with the high wear degree critical value, the hard disk whose wear degree exceeds the high wear degree critical value and has the largest wear degree is determined as the worn hard disk. In this way, placing the hot data in the target data into the hard disk with the largest wear degree can cause the fastest wear of this hard disk, that is, the fastest failure of this hard disk, widen the wear degree from other hard disks, and avoid the simultaneous damage of multiple hard disks.

[0085] The accelerated wear condition may further include a low wear degree critical value and a hot data quantity condition. According to the low wear degree critical value and the hot data quantity condition, the worn hard disk among the multiple hard disks can be determined. Based on this, in the following embodiment, another method for determining the worn hard disk will be described.

[0086] In an exemplary embodiment, as Figure 4 shown, determining the worn hard disk from multiple hard disks includes:

[0087] S401, obtain at least one candidate hard disk exceeding the low wear degree critical value from the multiple hard disks.

[0088] Among them, the low wear degree critical value is a wear degree threshold determined in advance and smaller than the high wear degree critical value, expressed as a percentage. For example, it can be 60%.

[0089] Exemplarily, compare the wear degrees of multiple hard disks with the low wear degree critical value, and determine the hard disks among the multiple hard disks whose wear degrees exceed the low wear degree critical value as candidate hard disks. For example, the low wear degree critical value is 60%, and the wear degrees of multiple hard disks are 40%, 35%, 70%, and 65% respectively. At this time, the hard disks with wear degrees of 70% and 65% are determined as candidate hard disks.

[0090] S402, obtain the target candidate hard disks that meet the hot data quantity condition among the candidate hard disks according to the existing hot data quantity of each candidate hard disk.

[0091] In practical applications, the data written to each hard disk may include cold data and hot data. In this way, the candidate hard disks may also include cold data and hot data. According to the currently existing data in the candidate hard disks, the existing hot data quantity in the candidate hard disks can be determined.

[0092] Exemplarily, first obtain the existing hot data quantity of each candidate hard disk, and then the existing hot data quantity and the hot data quantity condition of each candidate hard disk can be input into a pre-trained model, and the model outputs the target candidate hard disks that meet the hot data quantity condition among the candidate hard disks.

[0093] Exemplarily, first, obtain the existing hot data quantity of each candidate hard disk. Then, the existing hot data quantity of each candidate hard disk can be compared with the hot data quantity condition, and the candidate hard disks among the multiple candidate hard disks whose existing hot data quantity meets the hot data quantity condition are determined as target candidate hard disks. For example, the hot data quantity condition includes a hot data quantity threshold. Compare the existing hot data quantity of each candidate hard disk with the hot data quantity threshold, and determine the candidate hard disks among the multiple candidate hard disks whose existing hot data quantity is less than the hot data quantity threshold as target candidate hard disks.

[0094] S403. Determine the target candidate hard disk as a worn hard disk.

[0095] After determining the target candidate hard disk, determine the target candidate hard disk as a worn hard disk.

[0096] In the data writing method provided by the embodiments of the present application, by obtaining at least one candidate hard disk exceeding the low wear degree threshold from multiple hard disks, and then according to the existing hot data quantity of each candidate hard disk, obtaining the target candidate hard disks that meet the hot data quantity condition among each candidate hard disk, and finally determining the target candidate hard disk as a worn hard disk. In this method, another optional way to determine a worn hard disk is provided. The accelerated wear conditions include a low wear degree threshold and a hot data quantity condition. First, determine multiple candidate hard disks according to the low wear degree threshold, and then determine the worn hard disk from the candidate hard disks through the hot data quantity condition.

[0097] Determining the worn hard disk is to place the hot data in the target data into the worn hard disk to accelerate the wear of the worn hard disk. Therefore, when selecting a worn hard disk from the candidate hard disks, it is necessary to select a candidate hard disk that can still continue to place hot data as the worn hard disk. Based on this, in the following embodiment, the method for obtaining the target candidate hard disk is described.

[0098] In an exemplary embodiment, as Figure 5 shown, obtaining the target candidate hard disks that meet the hot data quantity condition among each candidate hard disk according to the existing hot data quantity of each candidate hard disk includes:

[0099] S501. Determine the expected hot data quantity of each candidate hard disk according to the existing hot data quantity of each candidate hard disk.

[0100] Among them, the expected hot data quantity refers to the quantity of hot data that each hard disk expects to place.

[0101] Exemplarily, a mapping relationship between different wear degrees, different existing hot data quantities, and different expected hot data quantities is pre-stored in the database. The expected hot data quantity corresponding to each candidate hard disk can be obtained from the above mapping relationship according to the existing hot data quantity and wear degree of each candidate hard disk.

[0102] S502. For any candidate hard disk, if the expected number of hot data of the candidate hard disk is greater than the existing number of hot data of the candidate hard disk, determine the candidate hard disk as the target candidate hard disk.

[0103] After determining the expected number of hot data of each candidate hard disk, compare the existing number of hot data and the expected number of hot data of each candidate hard disk to determine the target candidate hard disk. For any candidate hard disk, if the expected number of hot data of the candidate hard disk is greater than the existing number of hot data of the candidate hard disk, determine the candidate hard disk as the target candidate hard disk.

[0104] In the data writing method provided by the embodiments of the present application, according to the existing number of hot data of each candidate hard disk, determine the expected number of hot data of each candidate hard disk. For any candidate hard disk, if the expected number of hot data of the candidate hard disk is greater than the existing number of hot data of the candidate hard disk, determine the candidate hard disk as the target candidate hard disk. In this method, after determining the worn hard disk, hot data needs to be written into the worn hard disk. Therefore, when determining the target candidate hard disk from multiple candidate hard disks, the candidate hard disks that can still hold hot data need to be used as the target candidate hard disks, that is, determine the expected number of hot data of each candidate hard disk, and use the candidate hard disks with the expected number of hot data greater than the existing number of hot data as the target candidate hard disks.

[0105] In an exemplary embodiment, as Figure 6 shown, according to the existing number of hot data of each candidate hard disk, determining the expected number of hot data of each candidate hard disk includes:

[0106] S601. According to the existing number of hot data of each candidate hard disk, determine the total existing number of hot data of all candidate hard disks.

[0107] Sum up the existing number of hot data of each candidate hard disk to obtain the total existing number of hot data of all candidate hard disks.

[0108] S602. According to the wear degree of each candidate hard disk, determine the expected hot data ratio of each candidate hard disk.

[0109] Among them, the expected hot data ratio refers to the ratio of the hot data expected to be placed in each hard disk.

[0110] Exemplarily, a mapping relationship between different wear degrees and different expected hot data ratios is pre-stored in the database, and the expected hot data ratio corresponding to each candidate hard disk can be obtained from the above mapping relationship according to the wear degree of each candidate hard disk.

[0111] S603. According to the expected hot data ratio and the total existing number of hot data of each candidate hard disk, determine the expected number of hot data of each candidate hard disk.

[0112] For any candidate hard disk, the product of the expected hot data ratio of the candidate hard disk and the total amount of existing hot data is used as the expected hot data quantity of the candidate hard disk. When calculating the expected hot data quantity, if it is less than 1, it is calculated as 1. For example, if the expected hot data ratio of a candidate hard disk is 1 / 2 and the total amount of existing hot data is 7, the calculated expected hot data quantity is 4.

[0113] In the data writing method provided by the embodiments of the present application, by determining the total amount of existing hot data of all candidate hard disks according to the existing hot data quantity of each candidate hard disk, and then determining the expected hot data ratio of each candidate hard disk according to the wear degree of each candidate hard disk, and then determining the expected hot data quantity of each candidate hard disk according to the expected hot data ratio and the total amount of existing hot data of each candidate hard disk. In this method, by introducing the expected hot data ratio and determining the total amount of existing hot data of all candidate hard disks, the expected hot data quantity of each candidate hard disk can be determined according to the expected hot data ratio and the total amount of existing hot data of each candidate hard disk, providing data support for determining the target candidate hard disk.

[0114] Through the sorting situation of the wear degrees of each candidate hard disk, the sorting ordinal numbers of each candidate hard disk are obtained, and based on the sorting ordinal numbers of each candidate hard disk, the expected hot data ratio of each candidate hard disk can be determined. Based on this, in the following embodiment, the method for determining the expected hot data ratio will be described.

[0115] In an exemplary embodiment, as Figure 7 shown, determining the expected hot data ratio of each candidate hard disk according to the wear degree of each candidate hard disk includes:

[0116] S701, according to the wear degree of each candidate hard disk, sort each candidate hard disk in ascending order to obtain the hard disk ordinal numbers of each candidate hard disk.

[0117] According to the wear degree of each candidate hard disk, perform reverse sorting on each candidate hard disk to obtain the hard disk ordinal numbers of each candidate hard disk. For example, there are candidate hard disks ①, ②, and ③ with wear degrees of 70%, 62%, and 65% respectively, then the hard disk ordinal numbers of candidate hard disks ①, ②, and ③ are 3, 1, and 2 respectively.

[0118] S702, for any candidate hard disk, determine the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks as the expected hot data ratio of the candidate hard disk.

[0119] According to the hard disk ordinal number of each candidate hard disk and the sum of the hard disk ordinal numbers of all candidate hard disks, the expected hot data ratio of each candidate hard disk can be obtained. For any candidate hard disk, the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks is determined as the expected hot data ratio of the candidate hard disk. For example, if the hard disk ordinal numbers of candidate hard disks ①, ②, and ③ are 3, 1, and 2 respectively, then the expected hot data ratios of candidate hard disks ①, ②, and ③ are 1 / 2, 1 / 6, and 2 / 6 respectively.

[0120] In the data writing method provided by the embodiments of the present application, according to the wear degree of each candidate hard disk, each candidate hard disk is sorted in ascending order to obtain the hard disk ordinal number of each candidate hard disk. Furthermore, for any candidate hard disk, the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks is determined as the expected hot data ratio of the candidate hard disk. In this method, by sorting in reverse order according to the wear degree of each candidate hard disk, the hard disk ordinal number of each candidate hard disk is obtained, and the expected hot data ratio of each candidate hard disk is determined based on the hard disk ordinal number of each candidate hard disk, providing an optional way for quickly determining the expected hot data ratio of each candidate hard disk.

[0121] In addition to hot data, the target data may also include cold data. If the hot data is placed in the worn hard disk, then the cold data is placed in the remaining hard disks except the worn hard disk. Based on this, in an exemplary embodiment, as Figure 8 shown, the method further includes:

[0122] S801, obtain the remaining hard disks except the worn hard disk among multiple hard disks.

[0123] Among the multiple hard disks to be written, the worn hard disk is determined for writing the hot data in the target data. Then, the cold data in the target data can be written into the remaining hard disks except the worn hard disk. Based on this, the remaining hard disks except the worn hard disk among multiple hard disks are obtained.

[0124] S802, write the cold data into the remaining hard disks.

[0125] How to distinguish hot data and cold data can be determined by the time when the data is written into the hard disk. In practical applications, when the data is written into the hard disk, the data is divided into multiple data blocks and written into multiple hard disks in the form of stripes. Then, all the data blocks in a stripe will be written to the disk at the same time, and the timestamp of the stripe being written to the disk can be recorded. When the data is overwritten, by comparing the time when the original stripe corresponding to the data was written to the disk with the current time, hot data and cold data can be distinguished. Among them, the hot data can be the data overwritten within 0 to 1 day, and the cold data can be the data overwritten after more than 1 day.

[0126] After determining the remaining hard disks except the worn hard disk among multiple hard disks, the cold data can be written into the remaining hard disks.

[0127] In the data writing method provided by the embodiments of the present application, the remaining hard disks except the worn hard disks are obtained from multiple hard disks, and then the cold data is written into the remaining hard disks. In this method, if a worn hard disk that can store the hot data in the target data is determined from multiple hard disks, the remaining hard disks except the worn hard disk can be used to write the cold data in the target data. In this way, by writing the cold data in the target data into the remaining hard disks, since the cold data does not need to be updated frequently, the remaining hard disks will not wear out quickly, which widens the wear degree gap with the worn hard disks and avoids multiple hard disks reaching the end of their life cycles in a similar time, thus preventing data loss.

[0128] In addition, in an exemplary embodiment, the present application also provides an alternative example of a data writing method, as Figure 9 shown, which may include the following steps:

[0129] S901, in response to a write request for target data, obtain the wear degrees of multiple hard disks to be written in the hard disk domain.

[0130] S902, from the multiple hard disks, obtain at least one candidate hard disk whose wear degree exceeds the low wear degree threshold.

[0131] S903, according to the existing hot data quantities of each candidate hard disk, determine the total existing hot data quantity of all candidate hard disks.

[0132] S904, according to the wear degrees of each candidate hard disk, sort each candidate hard disk in ascending order to obtain the hard disk ordinal numbers of each candidate hard disk.

[0133] S905, for any candidate hard disk, determine the expected hot data ratio of the candidate hard disk as the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks.

[0134] S906, according to the expected hot data ratios and the total existing hot data quantity of each candidate hard disk, determine the expected hot data quantities of each candidate hard disk.

[0135] S907, for any candidate hard disk, if the expected hot data quantity of the candidate hard disk is greater than the existing hot data quantity of the candidate hard disk, determine the candidate hard disk as the target candidate hard disk.

[0136] S908, determine the target candidate hard disk as the worn hard disk.

[0137] S909, write the hot data in the target data into the worn hard disk.

[0138] The processes of S901 - S909 above can refer to the description of the method embodiments above. Their implementation principles and technical effects are similar and will not be elaborated here.

[0139] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order limit for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment, but can be executed at different moments, and the execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.

[0140] Based on the same inventive concept, an embodiment of the present application further provides a data writing device for implementing the above-mentioned data writing method. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the data writing device provided below can refer to the limitations on the data writing method in the above text, and will not be repeated here.

[0141] In an exemplary embodiment, as Figure 10 shown, a data writing device 1 is provided, including: a data acquisition module 10, a hard disk determination module 20, and a data writing module 30, where:

[0142] The data acquisition module 10 is configured to obtain the wear degrees of multiple hard disks to be written in the hard disk domain in response to a write request for target data;

[0143] The hard disk determination module 20 is configured to determine a worn hard disk from multiple hard disks according to the wear degrees of the multiple hard disks; a worn hard disk refers to a hard disk that satisfies the accelerated wear condition;

[0144] The data writing module 30 is configured to write the hot data in the target data into the worn hard disk.

[0145] In one of the embodiments, the above hard disk determination module 20 is further configured to:

[0146] Compare the wear degrees of multiple hard disks with a high wear degree threshold; determine the hard disk with the largest wear degree among the multiple hard disks that exceed the high wear degree threshold as the worn hard disk.

[0147] In one of the embodiments, the above hard disk determination module 20 is further configured to:

[0148] Obtain at least one candidate hard disk with a wear level exceeding the low wear level threshold from multiple hard disks; based on the existing hot data quantity of each candidate hard disk, obtain the target candidate hard disks that meet the hot data quantity condition among the candidate hard disks; determine the target candidate hard disks as worn hard disks.

[0149] In one embodiment, the above hard disk determination module 20 is further configured to:

[0150] Based on the existing hot data quantity of each candidate hard disk, determine the expected hot data quantity of each candidate hard disk; for any candidate hard disk, if the expected hot data quantity of the candidate hard disk is greater than the existing hot data quantity of the candidate hard disk, then determine the candidate hard disk as the target candidate hard disk.

[0151] In one embodiment, the above hard disk determination module 20 is further configured to:

[0152] Based on the existing hot data quantity of each candidate hard disk, determine the total existing hot data quantity of all candidate hard disks; based on the wear level of each candidate hard disk, determine the expected hot data ratio of each candidate hard disk; based on the expected hot data ratio and the total existing hot data quantity of each candidate hard disk, determine the expected hot data quantity of each candidate hard disk.

[0153] In one embodiment, the above hard disk determination module 20 is further configured to:

[0154] Based on the wear level of each candidate hard disk, sort the candidate hard disks in ascending order to obtain the hard disk ordinal numbers of each candidate hard disk; for any candidate hard disk, determine the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks as the expected hot data ratio of the candidate hard disk.

[0155] In one embodiment, the above data writing device 1 is further configured to:

[0156] Obtain the remaining hard disks among the multiple hard disks except the worn hard disks; write cold data into the remaining hard disks.

[0157] Each module in the above data writing device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0158] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:

[0159] In response to a write request for target data, obtain the wear levels of multiple hard disks to be written in the hard disk domain;

[0160] Determine a worn hard disk from multiple hard disks according to the wear degrees of the multiple hard disks; the worn hard disk represents a hard disk that meets the accelerated wear condition;

[0161] Write the hot data in the target data into the worn hard disk.

[0162] For each step implemented by the processor in the embodiments of the present application, its implementation principle and technical effect are similar to those of the above data writing method, and will not be elaborated here.

[0163] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0164] In response to a write request for target data, obtain the wear degrees of multiple hard disks to be written in the hard disk domain;

[0165] Determine a worn hard disk from multiple hard disks according to the wear degrees of the multiple hard disks; the worn hard disk represents a hard disk that meets the accelerated wear condition;

[0166] Write the hot data in the target data into the worn hard disk.

[0167] For each step implemented when the computer program in the embodiments of the present application is executed by a processor, its implementation principle and technical effect are similar to those of the above data writing method, and will not be elaborated here.

[0168] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the following steps are implemented:

[0169] In response to a write request for target data, obtain the wear degrees of multiple hard disks to be written in the hard disk domain;

[0170] Determine a worn hard disk from multiple hard disks according to the wear degrees of the multiple hard disks; the worn hard disk represents a hard disk that meets the accelerated wear condition;

[0171] Write the hot data in the target data into the worn hard disk.

[0172] For each step implemented when the computer program in the embodiments of the present application is executed by a processor, its implementation principle and technical effect are similar to those of the above data writing method, and will not be elaborated here.

[0173] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of the relevant data need to comply with the relevant regulations.

[0174] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logics, data processing logics based on quantum computing, etc., without limitation.

[0175] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0176] The above-described embodiments merely represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A data writing method, characterized in that, The method includes: In response to a write request for target data, obtaining the wear levels of multiple hard disks to be written in a hard disk domain; Determining a worn hard disk from the multiple hard disks according to the wear levels of the multiple hard disks; the worn hard disk represents a hard disk that meets the accelerated wear condition; Writing the hot data in the target data into the worn hard disk.

2. The method according to claim 1, wherein The accelerated wear condition includes a high wear level threshold; the determining a worn hard disk from the multiple hard disks includes: Comparing the wear levels of the multiple hard disks with the high wear level threshold; Determining the hard disk among the multiple hard disks that exceeds the high wear level threshold and has the maximum wear level as the worn hard disk.

3. The method according to claim 1, characterized in that, The accelerated wear condition includes a low wear level threshold and a hot data quantity condition; the determining a worn hard disk from the multiple hard disks includes: Obtaining at least one candidate hard disk that exceeds the low wear level threshold from the multiple hard disks; Obtaining a target candidate hard disk that meets the hot data quantity condition among the candidate hard disks according to the existing hot data quantities of the candidate hard disks; Determining the target candidate hard disk as the worn hard disk.

4. The method according to claim 3, wherein The obtaining a target candidate hard disk that meets the hot data quantity condition among the candidate hard disks according to the existing hot data quantities of the candidate hard disks includes: Determining the expected hot data quantity of each candidate hard disk according to the existing hot data quantity of each candidate hard disk; For any candidate hard disk, if the expected hot data quantity of the candidate hard disk is greater than the existing hot data quantity of the candidate hard disk, determining the candidate hard disk as the target candidate hard disk.

5. The method according to claim 4, wherein The determining the expected hot data quantity of each candidate hard disk according to the existing hot data quantities of the candidate hard disks includes: Determining the total existing hot data quantity of all candidate hard disks according to the existing hot data quantities of the candidate hard disks; Determining the expected hot data ratio of each candidate hard disk according to the wear level of each candidate hard disk; Determining the expected hot data quantity of each candidate hard disk according to the expected hot data ratio of each candidate hard disk and the total existing hot data quantity.

6. The method according to claim 5, characterized in that, The determining the expected hot data ratio of each candidate hard disk according to the wear level of each candidate hard disk includes: Sorting the candidate hard disks in ascending order according to the wear levels of the candidate hard disks to obtain the hard disk ordinal numbers of the candidate hard disks; For any candidate hard disk, determining the ratio of the hard disk ordinal number of the candidate hard disk to the sum of the hard disk ordinal numbers of all candidate hard disks as the expected hot data ratio of the candidate hard disk.

7. The method according to any one of claims 1 to 6, characterized in that The target data further includes cold data, and the method further includes: Obtaining the remaining hard disks in the multiple hard disks except the worn hard disk; Writing the cold data into the remaining hard disks.

8. A data writing device, characterized in that, The device includes: A data acquisition module, configured to obtain the wear levels of multiple hard disks to be written in a hard disk domain in response to a write request for target data; A hard disk determination module, configured to determine a worn hard disk from the multiple hard disks according to the wear levels of the multiple hard disks; the worn hard disk represents a hard disk that meets the accelerated wear condition; A data writing module, configured to write the hot data in the target data into the worn hard disk.

9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method described in any one of claims 1 to 7.