A method and apparatus for writing data
By generating and sorting the data sets to be written, the problem of slow writing speed of cache devices during cache updates is solved, and faster cache device flushing speed is achieved.
Patent Information
- Application Number
- CN201710196462.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2017-03-29
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2037-08-05
AI Technical Summary
When the cache device reaches the cache update threshold, the destination storage address of the data to be written is far away, resulting in slow writing speed of the disk device and slow flashing speed of the cache device.
By generating a data set to be written to the second storage module, the first data in the data set is sorted according to its own destination storage address and sent to the second storage module in sequence, ensuring that when the second storage module writes the first data in sequence, the total write path corresponding to each first data is written in the order of the destination storage address sorting, reducing the length of the write path.
By generating a data set with a short write time, the speed at which the first storage module writes data to the second storage module is improved, thereby increasing the flashing speed of the cache device.
Smart Images

Figure CN107168892B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular, to a method and device for writing data. Background Art
[0002] With the rapid development of computer hardware performance, both the capacity of computer cache devices and the access speed of cache devices have been greatly improved.
[0003] Currently, when the cache device reaches the cache update threshold, that is, when there is a large amount of cached data stored in the cache device and more data cannot be read in, some data with a lower usage frequency in the cache device needs to be flushed out. The cache device can send the data to be flushed out to the disk device for writing data, and the disk device writes the data to the destination storage address of each data by moving the magnetic head.
[0004] However, when the destination storage addresses of the data to be written are far apart, the movement range of the magnetic head is large, and the writing speed of the disk device is slow, which in turn leads to a slow flushing speed of the cache device. Summary of the Invention
[0005] In view of this, the main purpose of the embodiments of the present invention is to provide a method for writing data, so as to implement a data writing method that can improve the flushing speed of the cache device.
[0006] To achieve the above object, the technical solution of the present invention is realized as follows:
[0007] In a first aspect, an embodiment of the present invention provides a method for writing data, including: a first storage module generates a data set to be written to a second storage module; the first data in the data set is sorted according to its own destination storage address; the first storage module sends the first data in the data set to the second storage module in sequence.
[0008] In the above solution, the first storage module is a cache device, and the generating a data set to be written to the second storage module includes: the first storage module selects a plurality of first data from its own cache data set; the first storage module generates the data set according to the plurality of first data.
[0009] In the above solution, the data set includes one or more data subsets; the first storage module selects a plurality of first data from its own cached data set, including: the first storage module selects at least one disk area from the disk area set, and at least two second data are stored in the disk area; the first storage module selects cached data corresponding to each disk area in the at least one disk area in the cached data set as the plurality of first data in the one or more data subsets, and the destination storage address of the cached data belongs to the at least one disk area. The first storage module generates the data set according to the plurality of first data, including: generating the one or more data subsets according to the first data of each selected data subset and the order of the destination storage address in the corresponding disk area; generating the data set according to the one or more data subsets.
[0010] In the above solution, the at least one disk area is a disk area in the disk area set with an activity level lower than the first threshold.
[0011] In the above solution, before generating the data set to be written to the second storage module, it further includes: the first storage module generates a disk area queue, and the disk areas in the disk area queue are sorted according to their respective destination storage addresses; at least two second data are stored in each disk area. The first storage module generates the data set according to the plurality of first data, including: generating the data set according to the selected plurality of first data and the order of the corresponding disk area in the disk area queue.
[0012] In the above solution, the first data in each disk area is sorted according to its respective destination storage address.
[0013] In the above solution, the plurality of first data are cached data in the cached data set with an activity level lower than the second threshold.
[0014] In the above solution, generating the data set to be written to the second storage module includes: the first storage module has reached the cache update condition, and the cache update condition is that the data volume of the cached data set reaches the cache saturation threshold.
[0015] In the above solution, before generating the data set to be written to the second storage module, it includes: receiving a second storage module access request, where the second storage module access request includes the destination storage address of the second data to be accessed; determining whether the second data to be accessed has been synchronized; if the second data to be accessed has not been synchronized, determining whether the first storage module has reached the cache update condition; if the first storage module has reached the cache update condition, performing the step of generating the data set.
[0016] In the above solution, the method further includes: if the first storage module does not meet the update cache condition, synchronize the second data to be accessed in the first storage module to obtain cache data corresponding to the second data to be accessed, where the destination storage address of the cache data is the same as the destination storage address of the second data to be accessed, and record the activity of the cache data corresponding to the second data to be accessed.
[0017] In the above solution, the method further includes: if the second data to be accessed has been synchronized, update the activity of the cache data corresponding to the second data to be accessed.
[0018] In a second aspect, the present invention provides a method for writing data, including: a first storage module generates a data set to be written to a second storage module; the destination storage address of the first data in the data set belongs to a preset address range; the first storage module sends the data set to the second storage module.
[0019] In the above solution, the first storage module is a cache device, and generating the data set to be written to the second storage module includes: the first storage module selects a plurality of first data from its own cache data set; the first storage module generates the data set according to the plurality of first data.
[0020] In the above solution, the data set includes one or more data subsets; the plurality of first data includes first data belonging to the one or more data subsets. The first storage module selects a plurality of first data from its own cache data set, including: the first storage module selects at least one disk area from a disk area set, each disk area has a preset length of address range, and at least two second data are stored in the disk area; the first storage module selects cache data corresponding to the at least one disk area in the cache data set as the first data in the one or more data subsets, and the destination storage address of the cache data belongs to the at least one disk area.
[0021] In the above solution, the at least one disk area is a disk area in the disk area set with an activity lower than a first threshold.
[0022] In the above solution, before generating the data set to be written to the second storage module, it further includes: the first storage module generates a disk area queue, and the disk areas in the disk area queue are sorted according to their respective destination storage addresses; at least two second data are stored in each disk area. The first storage module generates the data set according to the plurality of first data, including: generating the data set according to the selected plurality of first data and the order of the corresponding disk areas in the disk area queue.
[0023] In the above solution, the first data in each disk area is sorted according to its respective destination storage address.
[0024] In the above solution, the multiple first data are cache data in the cache data set with an activity level lower than a second threshold.
[0025] In the above solution, generating the data set to be written to the second storage module includes: the first storage module has reached the cache update condition, and the cache update condition is that the data volume of the cache data set reaches the cache saturation threshold.
[0026] In the above solution, before generating the data set to be written to the second storage module, it includes: receiving a second storage module access request, where the second storage module access request includes the destination storage address of the second data to be accessed; determining whether the second data to be accessed has been synchronized; if the second data to be accessed has not been synchronized, determining whether the first storage module has reached the cache update condition; if the first storage module has reached the cache update condition, performing the step of generating the data set.
[0027] In the above solution, the method further includes: if the first storage module has not reached the cache update condition, synchronizing the second data to be accessed in the first storage module to obtain the cache data corresponding to the second data to be accessed, where the destination storage address of the cache data is the same as the destination storage address of the second data to be accessed, and recording the activity level of the cache data corresponding to the second data to be accessed.
[0028] In the above solution, the method further includes: if the second data to be accessed has been synchronized, updating the activity level of the cache data corresponding to the second data to be accessed.
[0029] In a third aspect, an embodiment of the present invention provides a data writing device, including: a processing module, configured to generate a data set to be written to a second storage module; the first data in the data set is sorted according to its own destination storage address; a sending module, configured to sequentially send the first data in the data set to the second storage module.
[0030] In the above solution, the processing module is configured to select multiple first data from its own cache data set; and is further configured to generate the data set according to the multiple first data.
[0031] In the above solution, the first processing module is specifically configured to select at least one disk area from the disk area set, where at least two second data are stored in the disk area; and select, from the cache data set, the cache data corresponding to the at least one disk area as the multiple first data, where the destination storage address of the cache data belongs to the at least one disk area.
[0032] In the above solution, the processing module is further configured to generate a disk area queue, where the disk areas in the disk area queue are sorted according to their respective destination storage addresses; each disk area stores at least two pieces of second data; and is configured to generate the data set according to the selected multiple pieces of first data and the order of the corresponding disk areas in the disk area queue.
[0033] In the above solution, the device further includes: a receiving module, configured to receive a second storage module access request, where the second storage module access request includes the destination storage address of the second data to be accessed; the processing module is further configured to determine whether the second data to be accessed has been synchronized; and to determine whether the first storage module meets the update cache condition when the second data to be accessed has not been synchronized, where the update cache condition is that the data volume of the cached data set reaches the cache saturation threshold; and to execute the step of generating the data set when the first storage module has met the update cache condition.
[0034] In the above solution, the processing module is further configured to synchronize the second data to be accessed in the first storage module when the first storage module does not meet the update cache condition, to obtain the cached data corresponding to the second data to be accessed, where the destination storage address of the cached data is the same as the destination storage address of the second data to be accessed, and to record the activity of the cached data corresponding to the second data to be accessed.
[0035] In the above solution, the processing module is further configured to update the activity of the cached data corresponding to the second data to be accessed when the second data to be accessed has been synchronized.
[0036] In a fourth aspect, the present invention provides a data writing device, including: a processing module, configured to generate a data set to be written into a second storage module; the destination storage addresses of the first data in the data set belong to a preset address range; a sending module, configured to send the data set to the second storage module.
[0037] In an embodiment of the present invention, by generating a data set to be written into a second storage module, the data set is sorted according to the destination storage addresses of the first data, and the first data in the data set is sent to the second storage module in order. When the second storage module writes the first data in sequence, the total write path corresponding to each first data written in the order sorted by the destination storage address is necessarily shorter than the total write path corresponding to other sorts. Therefore, by generating a data set with a shorter write time, the embodiment of the present invention can improve the speed of writing data from the first storage module to the second storage module. Description of the Drawings
[0038] Figure 1 It is a schematic flowchart of the data writing method in Embodiment 1 of the present invention;
[0039] Figure 2 It is a schematic flowchart of the data writing method in Embodiment 2 of the present invention;
[0040] Figure 3 is Figure 2 a flowchart of an alternative embodiment of the data writing method shown;
[0041] Figure 4 It is a schematic flowchart of the data writing method in Embodiment 3 of the present invention;
[0042] Figure 5 It is a schematic diagram of an alternative embodiment of the disk area queue in the data writing method of the embodiment of the present invention;
[0043] Figure 6 It is a schematic structural diagram of the data writing device in Embodiment 1 of the present invention;
[0044] Figure 7 It is a schematic structural diagram of the data writing device in Embodiment 2 of the present invention. Specific Embodiments
[0045] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention.
[0046] Embodiment 1
[0047] Figure 1 It is a schematic flowchart of the data writing method in Embodiment 1 of the present invention. As Figure 1 shown, the data writing method provided in this embodiment includes:
[0048] S101: The first storage module generates a data set to be written to the second storage module, and the first data in the data set is sorted according to its own destination storage address.
[0049] S102: The first storage module sequentially sends the first data in the data set to the second storage module.
[0050] In the embodiment of the present invention, the first storage module and the second storage module may include multiple storage units. For example, a sector or a block. The size of the first data may be an integer multiple of the storage unit. The destination storage address of the first data may be the physical storage address of the first data in the second storage module to be written.
[0051] Optionally, a network server, etc. The second storage module may be a device with a data storage function, such as a disk device, a network server, etc. For example, the data writing method provided in the embodiments of the present invention may be applied to a scenario where a cache device writes data to a disk device.
[0052] For example, when the first storage module is a cache device and the second storage module is a disk device, an optional implementation manner is provided in the embodiments of the present invention. In this implementation manner, S101 may include:
[0053] The first storage module selects a plurality of first data from its own cache data set;
[0054] The first storage module generates a data set according to the plurality of first data.
[0055] It should be noted that the destination storage addresses of the plurality of first data may belong to the same second storage module or multiple second storage modules. Then, the first storage module may send the first data in the data set to the second storage module to which the destination storage address belongs. Exemplarily, the cache device may send the data set to the disk drive of the corresponding disk device.
[0056] Optionally, the cache device may perform the step of generating a data set to be written to the second storage module when the update cache threshold condition is met. For example, the update cache threshold condition may be that the data volume of the cache data set of the cache device reaches the cache saturation threshold, that is, the cache device is about to be full.
[0057] It should be noted that when the cache device is about to be full and cannot read new data from the disk device, it is necessary to select one or more first data from the currently stored cache data in the cache device and write them to the disk device to replace part of the storage space. Therefore, based on this application scenario, the data writing method provided in the embodiments of the present invention can improve the speed of the cache device during the cache update operation, thereby releasing the storage space in the cache device faster.
[0058] Optionally, the plurality of first data may be cache data with an activity level lower than a second threshold in the cache data set. Or, the plurality of first data may be the plurality of cache data with the lowest activity level in the cache data set.
[0059] It should be noted that when the processor sends an access request to the cache device to request access to the second data on the disk device, if the second data has been synchronized from the disk device to the cache device, that is, the cache data corresponding to the second data is stored in the cache data set of the cache device, the processor can directly access the cache data corresponding to the second data in the cache device, and the operation result can be called a hit. Correspondingly, the data hit rate for a period of time can be calculated based on whether multiple access requests are hit during that period. Since the selected first data is cache data with low activity, adopting this method of selecting the first data to be replaced out of the cache device according to activity can improve the data hit rate of the cache data set remaining on the cache device, thereby improving the average access speed of the processor.
[0060] Optionally, the multiple first data in the data set can be sorted in ascending order or descending order according to the destination storage address. The total write path lengths corresponding to the data sets sorted in these two ways are the same. Therefore, the present invention does not limit this and will not elaborate here.
[0061] In the data writing method provided by the embodiments of the present invention, by generating a data set to be written to the second storage module, the data set is sorted according to the destination storage address of the first data, and the first data in the data set is sent to the second storage module in sequence. When the second storage module writes the first data in sequence, the total write path for writing each first data in the order sorted by the destination storage address is necessarily shorter than the corresponding write path sorted in other ways. Therefore, the embodiments of the present invention can improve the speed of writing data from the first storage module to the second storage module by generating a data set with a shorter writing time.
[0062] Embodiment 2
[0063] Figure 2 FIG. is a schematic flowchart of the data writing method in Embodiment 2 of the present invention. The embodiments of the present invention also provide a data writing method for improving the speed of writing data from the first storage module to the second storage module by generating a data set with a shorter writing time.
[0064] As Figure 2 shown, the steps of the embodiments of the present invention include:
[0065] S201: The first storage module generates a data set to be written to the second storage module, and the destination storage address of the first data in the data set belongs to a preset address range.
[0066] S202: The first storage module sends the data set to the second storage module.
[0067] In an embodiment of the present invention, the preset address range may be a continuous storage space on the second storage module. The preset address range may have a preset length. Then, when a data set includes two or more first data, the distance between the destination storage addresses of any two first data is less than the preset length.
[0068] In this way, the destination storage addresses of the first data in the generated data set are relatively close in the second storage module. When the second storage module performs a write operation, the distance it needs to move is shorter than that when writing a data set with a more discrete distribution. Therefore, the write speed of the second storage module for the data set generated in this way is faster than that of the data set with a more distant distribution.
[0069] Optionally, the first data in the data set to be written to the second storage module may be sorted according to its own destination storage address and each first data belongs to the preset address range. By using this method, the Figure 1 technical effects of the shown embodiment can be achieved at the same time. Then, the write speed of the second storage module can be improved from the above two aspects simultaneously.
[0070] It should be noted that, similar to the Figure 1 shown method, the first storage module may be a cache device, and the second storage module may be a disk device. Optionally, when the cache device reaches the cache update threshold condition, it may execute the step of generating the data set to be written to the second storage module. Based on this application scenario, the data writing method provided by the embodiment of the present invention can also improve the speed when the cache device performs cache update operations, thereby releasing the storage space in the cache device faster.
[0071] Optionally, an address range of a preset length may be defined as a disk zone, and each disk zone may include multiple storage units. Among them, each storage unit may be a sector or a block.
[0072] Then S201 may specifically include:
[0073] The first storage module selects a disk zone from the disk zone set, and at least two second data are stored in the disk zone. The first storage module selects the cache data corresponding to the disk zone in its own cache data set as the first data in the data set, and the destination storage address of the cache data belongs to the disk zone. The first storage module generates a data set according to the multiple first data.
[0074] Among them, it should be noted that the second storage module may be divided into multiple disk zones, and the disk zone set may include the identifiers of multiple disk zones. By using this method of selecting a disk zone, it is convenient for the first storage module to quickly select first data with a relatively close distance to generate a data set.
[0075] Optionally, the selected disk area can be a disk area in the disk area set with an activity lower than the first threshold. Alternatively, the selected disk area can be the disk area with the lowest activity in the disk area set. Similar to the Figure 1 method shown, since the first data selected is the cache data corresponding to the disk area with lower activity, adopting this method of selecting the first data to be replaced out of the cache device according to the activity can improve the data hit rate of the cache data set retained on the cache device, and thus improve the average access speed of the processor.
[0076] The data writing method provided by the embodiment of the present invention generates a data set including at least one data subset. Among them, the destination storage address of the first data in the data subset belongs to an address range with a preset length. Since the distribution of the writing addresses of the first data in each subset in the second storage device is relatively concentrated, the distance that the second storage module needs to move during the writing operation is shorter than that when writing relatively discrete data. Therefore, the embodiment of the present invention can improve the speed of writing data from the first storage module to the second storage module.
[0077] Figure 3 For Figure 2 a flowchart of an optional implementation manner of the data writing method shown. Optionally, Figure 2 the data set to be written into the second storage module in the method shown can include at least one data subset, and the first data in any data subset can belong to an address range with a preset length. That is, the first data in one data subset can belong to one address range, and different data subsets can correspond to different address ranges.
[0078] Then, on the basis of the Figure 2 method shown, as Figure 3 shown, in this embodiment, S201 can be specifically implemented by the following S301 - S303, and S202 can be implemented by the following S304.
[0079] S301: The first storage module selects at least two disk areas from the disk area set.
[0080] Among them, at least one of the at least two disk areas stores at least two second data.
[0081] S302: The first storage module selects the cache data corresponding to the at least two disk areas in its own cache data set as the first data in each data subset in the data set. The destination storage address of the cache data corresponding to any disk area belongs to the disk area.
[0082] S303: The first storage module generates a data set according to the multiple data subsets.
[0083] S304: The first storage module sends the data subsets in the data set to the second storage module respectively.
[0084] In this embodiment, since the distances between the first data in each data subset are relatively close, when the second storage module writes the first data in each data set, it can write the first data in the data subsets with relatively close distributions respectively. Therefore, the writing speed of the second storage module for the data set generated in this way is faster than the writing speed of repeatedly writing data across the address range.
[0085] Optionally, at least one disk area is a disk area in the disk area set with an activity lower than the first threshold. Or, at least one disk area is at least one disk area with the lowest activity in the disk area set.
[0086] It should be noted that the activity of each disk area can be obtained according to the activity of the cache data corresponding to the disk area. For example, if the activities of the three cache data corresponding to the disk area are a, b, and c respectively, the activity S of the disk area can be the sum of a, b, and c. The three cache data can correspond to three sectors or blocks, for example, sector p and sector q.
[0087] Specifically, with the rapid development of storage technology, the capacity of cache devices has been greatly improved. For example, the non-volatile dual inline memory module (NVDIMM) in non-volatile memory chips can reach up to 256G at most. When the storage capacity of the cache device reaches a certain level, the time interval T for the cache device to reach the cache update threshold condition will be relatively long. During this relatively long time interval T, the access requests of the processor to the disk device in the past period of time will be concentrated in one or more disk areas of the disk device. For example, when the processor accesses a program, the storage addresses of the files involved in this program are usually relatively close, for example, belonging to one disk area. Therefore, when the cache device needs to perform a cache update operation, the method of selecting disk areas from the disk area set can replace all the cache data corresponding to the disk area out of the cache device, that is, replace the cache data corresponding to a program out of the cache device. In this way, the data hit rate of the cache device will not decrease because the cache data corresponding to the selected disk area includes some cache data with relatively high activity. Thus, the speed of the cache device for performing update operations can be improved on the basis of ensuring the data hit rate of the cache device.
[0088] Optionally, the disk areas in the disk area set can be sorted according to their respective destination storage addresses. Then, generating the data set according to multiple data subsets in S303 can specifically include: generating the data set according to the order of the disk areas corresponding to the multiple data subsets in the disk area set, where each data subset in the data set is sorted according to the destination storage address.
[0089] Furthermore, the first data in each data subset can also be sorted according to its own destination storage address. Generating the data set according to multiple data subsets in S303 can also specifically include: generating the data set according to the order of the multiple first data in the corresponding first data subsets, where each data subset in the data set is sorted according to the destination storage address, and the cached data in each data subset is sorted according to the destination storage address.
[0090] It should be noted that, in this way, it actually combines Figure 1 and Figure 2 the two methods shown, that is, the destination storage address of the first data in the generated data set to be written belongs to a preset address range and the first data in the data set is sorted according to the destination storage address. Therefore, this way can simultaneously have Figure 1 and Figure 2 the technical effects brought by the methods shown. That is, the distribution of the first data to be written is relatively concentrated, and it can avoid detours in the write operation, so that the total write path is shorter, and thus the write speed of the second storage module can be greatly improved.
[0091] The other technical solution details and technical effects of this embodiment are similar to those of the Figure 2 shown method, and will not be elaborated here.
[0092] Embodiment 3
[0093] Figure 4 is a schematic flowchart of the data writing method in Embodiment 3 of the present invention, Figure 5 is a schematic diagram of an optional embodiment of the disk area queue in the data writing method of the embodiment of the present invention. The method of the embodiment of the present invention provides an embodiment of triggering a cache update operation when the cache device reaches the update cache threshold condition. And, the method of the embodiment of the present invention can be used to obtain the activity of the cached data in the cache data set of the first storage module itself, so as to be able to select the cached data with lower activity as the data to be written to the second storage module when triggering the cache update operation.
[0094] The steps of this embodiment can include:
[0095] In Figure 1 the method, step 101 ( Figure 4 not shown) or Figure 2Before step S201 ( Figure 4 not shown in the figure), the following steps are performed:
[0096] S401: The first storage module receives a data access request, which includes the destination storage address of the second data to be accessed.
[0097] Wherein, the data access request may be sent by the processor to the first storage module.
[0098] S402: The first storage module determines whether the second data to be accessed has been synchronized. If the second data to be accessed has not been synchronized, S403 is executed; if the second data to be accessed has been synchronized, 406 is executed.
[0099] S403: Determine whether the first storage module has reached the cache update condition. If the first storage module has reached the cache update condition, S404 is executed; if the first storage module has not reached the cache update condition, S405 is executed.
[0100] S404: Perform a cache update operation and then execute S405.
[0101] Wherein, if the steps of this embodiment are executed Figure 1 before step 101, the cache update operation may include: generating a data set to be written to the second storage module, and sequentially sending the first data in the data set to the second storage module. It should be noted that the method of generating the data set to be written to the second storage module can adopt Figure 1 any of the embodiments shown in the method.
[0102] If the steps of this embodiment are executed before S201, the cache update operation may be: generating a data set to be written to the second storage module, and sending the data set to the second storage module. It should be noted that the method of generating the data set to be written to the second storage module can adopt Figures 2 to 3 any of the embodiments shown in the method.
[0103] S405: Synchronize the second data to be accessed in the first storage module to obtain the cache data corresponding to the second data to be accessed, and record the activity of the cache data corresponding to the second data to be accessed, then execute S406.
[0104] Wherein, the destination storage address of the cache data is the same as the destination storage address of the second data to be accessed.
[0105] S406: Update the activity of the cache data corresponding to the second data to be accessed, and then execute the processing steps after a data hit.
[0106] Optionally, the value of the activity of the cached data can be incremented by 1. Optionally, the activity of the cached data can be updated according to the Least Recently Used (LRU) algorithm, the least frequently used page-replacement algorithm, or other algorithms for updating the cache by the cache device.
[0107] Optionally, before S401, it may include:
[0108] S400: The first storage module generates a disk area queue.
[0109] Among them, the disk area queue can record the attribute information and order of all disk areas in the form of a linked list or an array. The attribute information of each disk area can include at least one of the following: the identifier of the disk area, the activity of the disk area, the length and number of cached data in the disk area, and the cached data queue corresponding to the disk area. For reference, Figure 5 . Optionally, the disk area queue can also be used as Figure 2 the disk area set in the illustrated embodiment.
[0110] Then, recording the activity of the cached data corresponding to the second data to be accessed in S405 can specifically include:
[0111] Adding the identifier of the cached data corresponding to the second data to be accessed to the cached data queue of the corresponding disk area in the disk area queue.
[0112] Among them, the cached data queue can record the attribute information and order of each first cached data in the disk area in the form of a linked list or an array. The attribute information of each cached data can include at least one of the following: the identifier of the cached data, the activity of the cached data, etc. For reference, Figure 5 .
[0113] Recording the information of the disk area queue, the disk area set, and the cached data queue corresponding to each disk area in the disk area using a linked list or an array can save the sorting information of the cached data corresponding to each disk area and the sorting information of the disk area with less storage space. On the basis of realizing the fast writing of data from the first storage module to the second storage module, the overhead is extremely small and the speed of querying cached data is relatively fast.
[0114] Other technical solution details and technical effects of the embodiments of the present invention are similar to those of the Figures 1 to 3 illustrated method and will not be elaborated here.
[0115] Figure 6 is a schematic structural diagram of a data writing device according to Embodiment 1 of the present invention. As Figure 6As shown, the writing device of this embodiment can be located in the first storage module. The device 60 of the embodiment of the present invention includes:
[0116] A first processing module 601, configured to generate a data set to be written into the second storage module; the first data in the data set is sorted according to its own destination storage address;
[0117] A first sending module 602, configured to sequentially send the first data in the data set to the second storage module.
[0118] Among them, the first processing module 601 can be used to select multiple first data from its own cached data set; it can also be used to generate a data set according to the multiple first data.
[0119] Optionally, the first processing module 601 can specifically be used to select at least one disk area from a disk area set, where at least two second data are stored in the disk area; and it can be used to select cached data corresponding to the at least one disk area in the cached data set as the multiple first data, and the destination storage address of the cached data belongs to the at least one disk area.
[0120] Optionally, the first processing module 601 can also be used to generate a disk area queue, where the disk areas in the disk area queue are sorted according to their respective destination storage addresses; each disk area stores at least two second data; and it is used to generate a data set according to the selected multiple first data and the order of the corresponding disk areas in the disk area queue.
[0121] For other technical solution details and technical effects of this embodiment and Figure 1 、 Figure 4 The shown embodiments are similar and will not be elaborated here.
[0122] Figure 7 This is a schematic structural diagram of the data writing device according to the second embodiment of the present invention. As Figure 7 shown, the writing device of this embodiment can be located in the first storage module. The device 70 of the embodiment of the present invention includes:
[0123] A second processing module 701, configured to generate a data set to be written into the second storage module; the destination storage address of the first data in the data set belongs to an address range with a preset length;
[0124] A second sending module 702, configured to send the data set to the second storage module.
[0125] Among them, the second processing module can be used to select multiple first data from its own cached data set; it can also be used to generate a data set according to the multiple first data.
[0126] Optionally, the second processing module 701 may be specifically configured to select at least one disk area from a set of disk areas, where at least two second data are stored in the disk area; and may be configured to select cache data corresponding to the at least one disk area from the cache data set as a plurality of first data, and the destination storage addresses of the cache data belong to the at least one disk area.
[0127] Optionally, the second processing module 701 may also be configured to generate a disk area queue, where the disk areas in the disk area queue are sorted according to their respective destination storage addresses; at least two second data are stored in each disk area; and is configured to generate a data set according to the selected plurality of first data and the order of the corresponding disk areas in the disk area queue.
[0128] Details of other technical solutions and their technical effects in this embodiment are the same as those in Figure 1 、 Figure 4 the embodiments shown, and will not be elaborated here.
[0129] As described above, the specific implementation manners of the present invention are only described, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
[0130] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories and optical memories, etc.) containing computer-usable program codes.
[0131] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, and the combination of processes and / or blocks in the flowcharts and / or block diagrams, can be realized by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, so that the instructions executed by the processors of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0132] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction means that implements the functions specified in one or more of the processes and / or blocks Figure 1 one or more of the processes and / or blocks Figure 1 specified in one or more of the blocks or blocks.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one or more of the processes and / or blocks Figure 1 one or more of the processes and / or blocks Figure 1 specified in one or more of the blocks or blocks.
[0134] As described above, only the preferred embodiments of the present invention are given, and they are not intended to limit the protection scope of the present invention.
Claims
1. A method for writing data, characterized in that, the method includes: A first storage module generates a data set to be written to a second storage module; the first data in the data set is sorted according to its own destination storage address; the first storage module is a cache device; the second storage module includes multiple disk areas; The first storage module sequentially sends the first data in the data set to the second storage module; wherein, generating the data set to be written to the second storage module includes: the first storage module selects multiple first data from its own cache data set; the first storage module generates the data set according to the multiple first data; wherein, selecting multiple first data from its own cache data set includes: the first storage module selects at least one of the disk areas from the disk area set; the first storage module selects the cache data corresponding to each disk area of the at least one disk area in its own cache data set as the first data; wherein, The address range of one disk area is a preset length; the at least one disk area is a disk area in the disk area set with an activity lower than a first threshold, or the at least one disk area is the disk area with the lowest activity in the disk area set.
2. The method according to claim 1, characterized in that, the data set includes one or more data subsets; the first data is used as the first data in the one or more data subsets, and the destination storage address of the cache data belongs to the at least one disk area; the first storage module generating the data set according to the multiple first data includes: generating the one or more data subsets according to the first data of each selected data subset and the order of its own destination storage address in the corresponding disk area; generating the data set according to the one or more data subsets.
3. The method according to claim 1, characterized in that, before generating the data set to be written to the second storage module, it further includes: the first storage module generates a disk area queue, and the disk areas in the disk area queue are sorted according to their own destination storage addresses; each disk area stores at least two second data; the first storage module generating the data set according to the multiple first data includes: generating the data set according to the multiple selected first data and the order of the corresponding disk areas in the disk area queue.
4. The method according to claim 3, characterized in that, the first data in each disk area is sorted according to its own destination storage address.
5. The method according to any one of claims 2-4, characterized in that, generating the data set to be written to the second storage module includes: the first storage module has reached the cache update condition, and the cache update condition is that the data volume of the cache data set reaches the cache saturation threshold.
6. A data writing device, characterized in that, the writing device is located in the first storage module, and the first storage module is a cache device; the writing device includes: A processing module for generating a data set to be written to a second storage module; the first data in the data set is sorted according to its destination storage address; wherein, the second storage module includes a plurality of disk areas; generating the data set to be written to the second storage module includes: selecting a plurality of first data from its own cache data set; generating the data set according to the plurality of first data; selecting a plurality of first data from its own cache data set includes: selecting at least one of the disk areas from the disk area set; selecting the cache data corresponding to each of the at least one disk area in its own cache data set as the first data; wherein, The address range of one of the disk areas is a preset length; the at least one disk area is a disk area in the disk area set with an activity level lower than a first threshold, or the at least one disk area is the disk area with the lowest activity level in the disk area set; A sending module for sequentially sending the first data in the data set to the second storage module.
Citation Information
Patent Citations
RAID5-orientated optimal design method for writing operation in continuous data storage
CN101727299A
Data storage method and apparatus
CN105573668A
Disk drive system and method for controlling a cache memory
US20030212855A1
Method for reducing energy consumption of server by using mixed storage of solid-state drive and mechanical hard disk
CN102662459A
Staging sorted data in intermediate storage
CN104050090A