A cache reconstruction method and device
Through multi-thread parallel processing, the storage location of the disk file source data is determined and the corresponding relationship is established, which solves the problem of low cache reconstruction efficiency in the existing technology, realizes a faster cache reconstruction process, and ensures the normal operation of the server.
Patent Information
- Application Number
- CN201811559832.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-19
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2038-12-19
AI Technical Summary
As the number of disks and files increases, the cache reconstruction efficiency in the existing technology is low, affecting the normal use of the server.
By determining the storage location of each disk file source data in the cache and in the memory, and starting the thread corresponding to the disk, using multiple threads to simultaneously reconstruct the file source data into the cache, establishing a storage location correspondence, processing the number of files and storage space size to optimize the reconstruction process.
The reconstruction time is reduced, the cache reconstruction efficiency is improved, and the normal operation of the server is ensured.
Smart Images

Figure CN111338560B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a cache reconstruction method, device, electronic device and computer-readable storage medium. Background Art
[0002] As a storage server, in order to ensure the speed of accessing files, the file source data in each disk is usually saved in the cache. If the server is restarted, the file source data in each disk needs to be rebuilt into the cache. In the prior art, the file source data in each disk is rebuilt in sequence, but as the number of disks and / or the number of files in the disks increases, it will take more time to complete the reconstruction, resulting in low efficiency of reconstruction and affecting the normal use of the server. Summary of the invention
[0003] In view of the above problems, the present invention is proposed to provide a cache reconstruction method, device, electronic device and computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0004] According to one aspect of the present invention, a cache reconstruction method is provided, wherein the method comprises:
[0005] Determine the storage location in the cache corresponding to the file source data on each disk in the memory;
[0006] Start several threads, where the started threads correspond one-to-one to the disks in the memory;
[0007] Using several threads, the file source data stored in the corresponding disk is rebuilt to the corresponding storage location in the cache.
[0008] Optionally, determining the storage location in the cache corresponding to the file source data of each disk in the memory includes:
[0009] Get the number of files on each disk;
[0010] Calculate the storage space required for the file source data on each disk based on the acquired file number information;
[0011] According to the calculated storage space size required by the file source data of each disk, a storage location of the corresponding storage space size is requested from the cache for each disk, and a corresponding relationship is established between each disk and the storage location of the corresponding storage space size.
[0012] Optionally, requesting a storage location of a corresponding storage space size for each disk from the cache includes:
[0013] According to the minimum storage unit of the cache, a storage location of a corresponding storage space size is requested from the cache for each disk.
[0014] Optionally, using a plurality of threads to respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache includes:
[0015] According to the established corresponding relationship, several threads are used to access the storage positions of the corresponding disks respectively, and the file source data stored in the corresponding disks are rebuilt into the corresponding storage positions in the cache.
[0016] Optionally, the method further comprises:
[0017] According to the file number information of each disk, determine whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache;
[0018] If the judgment is yes, determine the file source data of each disk to be rebuilt;
[0019] The method of using a plurality of threads to respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache includes:
[0020] Using several threads, the file source data of each disk to be rebuilt is rebuilt to the corresponding storage position in the cache.
[0021] Optionally, determining the file source data of each disk to be rebuilt includes:
[0022] One or more disks are selected from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0023] Optionally, the method further comprises:
[0024] The file source data and files in the unselected disk are deleted by using the thread corresponding to the unselected disk.
[0025] Optionally, determining the file source data of each disk to be rebuilt includes:
[0026] Calculate the difference between the sum of the sizes of the source data of the files on each disk and the total storage space size of the cache;
[0027] According to the preset ratio and the calculated difference, the file source data to be discarded of each disk is determined, and the file source data not to be discarded of each disk is used as the file source data of each disk to be reconstructed.
[0028] Optionally,
[0029] The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0030] Optionally, the method further comprises:
[0031] Utilize several threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
[0032] According to another aspect of the present invention, a cache reconstruction device is provided, wherein the device comprises:
[0033] a determination unit adapted to determine storage locations in the cache corresponding to file source data on each disk in the memory;
[0034] An opening unit, adapted to open a number of threads, wherein the opened threads correspond one to one with the disks in the memory;
[0035] The reconstruction unit is adapted to utilize a plurality of threads to respectively reconstruct the file source data stored in the corresponding disk to the corresponding storage location in the cache.
[0036] Optionally,
[0037] The determination unit is suitable for obtaining the file number information of each disk; calculating the storage space size required for the file source data of each disk based on the obtained file number information; requesting a storage location of the corresponding storage space size for each disk from the cache based on the calculated storage space size required for the file source data of each disk, and establishing a corresponding relationship between each disk and the storage location of the corresponding storage space size.
[0038] Optionally,
[0039] The determining unit is adapted to request a storage location of a corresponding storage space size for each disk from the cache according to the minimum storage unit of the cache.
[0040] Optionally,
[0041] The reconstruction unit is adapted to use a plurality of threads to access storage locations of corresponding disks respectively according to the established corresponding relationship, and to reconstruct the file source data stored in the corresponding disks to the corresponding storage locations in the cache.
[0042] Optionally, the device further comprises:
[0043] A judgment unit, adapted to judge whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache according to the file number information of each disk; if the judgment is yes, determine the file source data of each disk to be rebuilt;
[0044] The reconstruction unit is suitable for using a plurality of threads to respectively reconstruct the file source data of each disk to be reconstructed to the corresponding storage position in the cache.
[0045] Optionally,
[0046] The determination unit is adapted to select one or more disks from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0047] Optionally, the device further comprises:
[0048] The deleting unit is adapted to utilize the threads corresponding to the unselected disks to delete the file source data and files in the unselected disks.
[0049] Optionally,
[0050] The judgment unit is suitable for calculating the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache; determining the file source data to be discarded of each disk according to a preset ratio and the calculated difference, and using the non-to-be-discarded file source data of each disk as the file source data of each disk to be rebuilt.
[0051] Optionally,
[0052] The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0053] Optionally, the device further comprises:
[0054] The deletion unit is adapted to utilize a plurality of threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
[0055] According to another aspect of the present invention, there is provided an electronic device, wherein the electronic device comprises:
[0056] processor; and,
[0057] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method according to the foregoing.
[0058] According to yet another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the aforementioned method is implemented.
[0059] According to the technical solution of the present invention, the storage location in the cache corresponding to the file source data of each disk in the memory is determined; a plurality of threads are started, wherein the started threads correspond one to one to the disks in the memory; and the file source data stored in the corresponding disks are rebuilt into the corresponding storage location in the cache using the plurality of threads. In the technical solution, the plurality of threads simultaneously rebuild the file source data stored in the corresponding disks into the corresponding storage location in the cache, thereby reducing the reconstruction time, improving the reconstruction efficiency, and ensuring the normal use of the server.
[0060] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0062] Figure 1 A schematic diagram of a process flow of a cache reconstruction method according to an embodiment of the present invention is shown;
[0063] Figure 2 A schematic diagram of the structure of a cache reconstruction device according to an embodiment of the present invention is shown;
[0064] Figure 3 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention is shown;
[0065] Figure 4 A schematic diagram of the structure of a computer-readable storage medium according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0066] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0067] Figure 1 FIG. 2 is a flow chart showing a cache reconstruction method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0068] Step S110, determining the storage location in the cache corresponding to the file source data of each disk in the memory.
[0069] Step S120, opening a plurality of threads, wherein the opened threads correspond one-to-one to the disks in the memory.
[0070] Step S130, using a plurality of threads, respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache.
[0071] The file source data includes basic information of the file saved on the disk. Saving the file source data in the cache can increase the file acquisition speed.
[0072] In this embodiment, a thread is opened for each disk. Using each thread, the file source data stored in each disk can be rebuilt to the corresponding storage location in the cache at the same time. There is no need to rebuild the file source data in each disk one by one, which reduces the reconstruction time, improves the reconstruction efficiency, and ensures the normal use of the server.
[0073] In one embodiment of the present invention, Figure 1 Determining the storage location in the cache corresponding to the file source data of each disk in the memory in step S110 of the method shown includes: obtaining the file number information of each disk; calculating the storage space size required for the file source data of each disk based on the obtained file number information; requesting a storage location of the corresponding storage space size for each disk from the cache based on the calculated storage space size required for the file source data of each disk, and establishing a corresponding relationship between each disk and the storage location of the corresponding storage space size.
[0074] Considering that when multiple threads are executed, if one thread accesses the cache to write data, a mutex lock will be added, and other threads cannot access the cache, that is, the mutual exclusion problem between multiple threads. To solve this problem, in this embodiment, a corresponding storage location is requested in the cache for each disk, and each thread only accesses the corresponding storage location, so that the threads will not affect each other and will not cause mutual exclusion problems.
[0075] When requesting a storage location, it is determined based on the number of files on each disk, because the format of the file information is fixed, that is, the storage space required for each file information is fixed. The more files there are, the more storage space is required for the file source data on the disk.
[0076] For example, if the storage space required for each file information is 20 kilobytes (KB), and the number of files on disk 1 is 100, then the storage space required for the file source data on disk 1 is 1.95 megabytes (M); the number of files on disk 2 is 200, then the storage space required for the file source data on disk 2 is 3.9M. Then the storage locations 0-1.95M in the cache are used as the storage locations corresponding to disk 1, and the storage locations 1.95M-5.85M are used as the storage locations corresponding to disk 2.
[0077] Furthermore, the above-mentioned requesting a storage location of a corresponding storage space size for each disk from the cache includes: requesting a storage location of a corresponding storage space size for each disk from the cache according to a minimum storage unit of the cache.
[0078] Considering that the cache has a minimum storage unit, for example, the minimum storage unit is 1M, then when allocating storage locations to each disk, they should be integer multiples of 1M. For example, based on the above example, the storage locations 0-2M in the cache are used as the storage locations corresponding to disk 1, and the storage locations 2M-6M are used as the storage locations corresponding to disk 2.
[0079] Further, Figure 1 Step S130 of the method shown uses several threads to reconstruct the file source data stored in the corresponding disk to the corresponding storage location in the cache, including: according to the established correspondence, using several threads to access the storage location of the corresponding disk respectively, and reconstructing the file source data stored in the corresponding disk to the corresponding storage location in the cache.
[0080] In this embodiment, after a correspondence is established between each disk and a storage location in the corresponding cache, the thread corresponding to each disk only accesses the storage location in the cache that has a corresponding relationship. For example, based on the above example, thread 1 corresponding to disk 1 only accesses the 0-2M location in the cache to write data, and thread 2 corresponding to disk 2 only accesses the 2M-6M location in the cache to write data.
[0081] In one embodiment of the present invention, Figure 1 The method shown also includes: judging whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache according to the file number information of each disk; if the judgment is yes, determining the file source data of each disk to be rebuilt;
[0082] Figure 1 In step S130 of the method shown, using several threads to respectively reconstruct the file source data stored in the corresponding disks to the corresponding storage locations in the cache includes: using several threads to respectively reconstruct the file source data of the corresponding disks to be reconstructed to the corresponding storage locations in the cache.
[0083] Considering that after the server is restarted, the total size of the file source data in each disk may exceed the size of the cached storage space and cannot be completely rebuilt. In this embodiment, in response to this situation, the file source data of each disk to be rebuilt is determined, and then the file source data of each disk to be rebuilt is rebuilt.
[0084] The file source data of each disk to be rebuilt here includes two situations. One is to select the disk to be rebuilt and reconstruct all the file source data in the disk to be rebuilt; the other is to select the file source data to be rebuilt from the file source data saved in each disk and reconstruct the file source data to be rebuilt in each disk.
[0085] Specifically, the above-mentioned determining the file source data of each disk to be rebuilt includes: selecting one or more disks from each disk as the disk to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0086] For example, there are file source data in disk 1, disk 2, disk 3 and disk 4 that need to be rebuilt, but the sum of the sizes of the file source data in disk 1, disk 2, disk 3 and disk 4 is greater than the total storage space size of the cache. In disk 1-disk 4, the sum of the sizes of the file source data in disk 1, disk 2 and disk 3 is less than or equal to the total storage space size of the cache, then disk 1, disk 2 and disk 3 are used as disks to be rebuilt, and then threads 1, thread 2 and thread 3 corresponding to disk 1, disk 2 and disk 3 are used to simultaneously rebuild the file source data in disk 1, disk 2 and disk 3 to the corresponding storage locations of the cache.
[0087] Further, based on the above embodiment, Figure 1 The method shown also includes: using threads corresponding to unselected disks to delete file source data and files in the unselected disks.
[0088] Because the file source data in the unselected disks are not rebuilt and the files stored therein cannot be accessed, the file source data and files in the unselected disks are deleted to save space, so as to ensure the reasonable allocation of disk resources. For example, based on the above example, for example, thread 4 corresponding to disk 4 deletes the file source data and files stored in disk 4.
[0089] Specifically, the above-mentioned determination of the file source data of each disk to be rebuilt includes: calculating the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache; determining the file source data to be discarded of each disk based on a preset ratio and the calculated difference, and using the non-to-be-discarded file source data of each disk as the file source data of each disk to be rebuilt.
[0090] In this embodiment, if the sum of the sizes of the file source data on each disk is larger than the total storage space size of the cache, a portion of the file source data from each disk is discarded and not reconstructed.
[0091] For example, there are file source data in disk 1, disk 2, disk 3 and disk 4 that need to be rebuilt, but the sum of the sizes of the file source data in disk 1, disk 2, disk 3 and disk 4 is greater than the total storage space size of the cache. The preset ratio is 1:1:1:1, and if the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache is 100M, then according to the preset ratio, 25M of file source data are determined from disk 1, disk 2, disk 3 and disk 4 as the file source data to be discarded, and then the file source data not to be discarded in disk 1, disk 2, disk 3 and disk 4 are rebuilt.
[0092] Preferably, the above-mentioned preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0093] Based on the above example, if the files in disk 1 are more popular than the files in disk 2, the discard ratio of disk 1 and disk 2 can be reduced accordingly. For example, the preset ratio is 1:2:3:3.
[0094] Further, based on the above embodiment, Figure 1 The method shown also includes: using a plurality of threads to delete the file source data to be discarded and the corresponding files in the corresponding disks respectively.
[0095] For example, based on the above example, Thread 1, Thread 2, Thread 3 and Thread 3 corresponding to Disk 1, Disk 2, Disk 3 and Disk 4 are used to delete 25M of file source data to be discarded from Disk 1, Disk 2, Disk 3 and Disk 4 respectively.
[0096] Figure 2 FIG. 4 shows a schematic diagram of the structure of a cache reconstruction device according to an embodiment of the present invention. Figure 2 As shown, the cache reconstruction device 200 includes:
[0097] The determination unit 210 is adapted to determine storage locations in the cache corresponding to the file source data of each disk in the memory.
[0098] The opening unit 220 is adapted to open a plurality of threads, wherein the opened threads correspond one-to-one to the disks in the memory.
[0099] The reconstruction unit 230 is adapted to utilize a plurality of threads to respectively reconstruct the file source data stored in the corresponding disk to the corresponding storage location in the cache.
[0100] The file source data includes basic information of the file saved on the disk. Saving the file source data in the cache can increase the file acquisition speed.
[0101] In this embodiment, a thread is opened for each disk. Using each thread, the file source data stored in each disk can be rebuilt to the corresponding storage location in the cache at the same time. There is no need to rebuild the file source data in each disk one by one, which reduces the reconstruction time, improves the reconstruction efficiency, and ensures the normal use of the server.
[0102] In one embodiment of the present invention, Figure 2 The determination unit 210 shown is suitable for obtaining the file number information of each disk; calculating the storage space size required for the file source data of each disk based on the obtained file number information; requesting a storage location of the corresponding storage space size for each disk from the cache based on the calculated storage space size required for the file source data of each disk, and establishing a corresponding relationship between each disk and the storage location of the corresponding storage space size.
[0103] Considering that when multiple threads are executed, if one thread accesses the cache to write data, a mutex lock will be added, and other threads cannot access the cache, that is, the mutual exclusion problem between multiple threads. To solve this problem, in this embodiment, a corresponding storage location is requested in the cache for each disk, and each thread only accesses the corresponding storage location, so that the threads will not affect each other and will not cause mutual exclusion problems.
[0104] When requesting a storage location, it is determined based on the number of files on each disk, because the format of the file information is fixed, that is, the storage space required for each file information is fixed. The more files there are, the more storage space is required for the file source data on the disk.
[0105] For example, if the storage space required for each file information is 20 kilobytes (KB), and the number of files on disk 1 is 100, then the storage space required for the file source data on disk 1 is 1.95 megabytes (M); the number of files on disk 2 is 200, then the storage space required for the file source data on disk 2 is 3.9M. Then the storage locations 0-1.95M in the cache are used as the storage locations corresponding to disk 1, and the storage locations 1.95M-5.85M are used as the storage locations corresponding to disk 2.
[0106] Furthermore, the above-mentioned determination unit 210 is adapted to request a storage location of a corresponding storage space size for each disk from the cache according to the minimum storage unit of the cache.
[0107] Considering that the cache has a minimum storage unit, for example, the minimum storage unit is 1M, then when allocating storage locations to each disk, they should be integer multiples of 1M. For example, based on the above example, the storage locations 0-2M in the cache are used as the storage locations corresponding to disk 1, and the storage locations 2M-6M are used as the storage locations corresponding to disk 2.
[0108] Further, Figure 2 The reconstruction unit 230 shown is suitable for using a plurality of threads to access the storage locations of the corresponding disks respectively according to the established corresponding relationship, and reconstructing the file source data stored in the corresponding disks to the corresponding storage locations in the cache.
[0109] In this embodiment, after a correspondence is established between each disk and a storage location in the corresponding cache, the thread corresponding to each disk only accesses the storage location in the cache that has a corresponding relationship. For example, based on the above example, thread 1 corresponding to disk 1 only accesses the 0-2M location in the cache to write data, and thread 2 corresponding to disk 2 only accesses the 2M-6M location in the cache to write data.
[0110] In one embodiment of the present invention, Figure 2 The device shown also includes:
[0111] The judgment unit is adapted to judge whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache according to the file number information of each disk; if the judgment is yes, the file source data of each disk to be rebuilt is determined.
[0112] Figure 2 The reconstruction unit 230 shown is suitable for using a plurality of threads to respectively reconstruct the file source data of each disk to be reconstructed into the corresponding storage position in the cache.
[0113] Considering that after the server is restarted, the total size of the file source data in each disk may exceed the size of the cached storage space and cannot be completely rebuilt. In this embodiment, in response to this situation, the file source data of each disk to be rebuilt is determined, and then the file source data of each disk to be rebuilt is rebuilt.
[0114] The file source data of each disk to be rebuilt here includes two situations. One is to select the disk to be rebuilt and reconstruct all the file source data in the disk to be rebuilt; the other is to select the file source data to be rebuilt from the file source data saved in each disk and reconstruct the file source data to be rebuilt in each disk.
[0115] Specifically, the above-mentioned determination unit is adapted to select one or more disks from various disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0116] For example, there are file source data in disk 1, disk 2, disk 3 and disk 4 that need to be rebuilt, but the sum of the sizes of the file source data in disk 1, disk 2, disk 3 and disk 4 is greater than the total storage space size of the cache. In disk 1-disk 4, the sum of the sizes of the file source data in disk 1, disk 2 and disk 3 is less than or equal to the total storage space size of the cache, then disk 1, disk 2 and disk 3 are used as disks to be rebuilt, and then threads 1, thread 2 and thread 3 corresponding to disk 1, disk 2 and disk 3 are used to simultaneously rebuild the file source data in disk 1, disk 2 and disk 3 to the corresponding storage locations of the cache.
[0117] Further, based on the above embodiment, Figure 2 The device shown also includes:
[0118] The deleting unit is adapted to utilize the threads corresponding to the unselected disks to delete the file source data and files in the unselected disks.
[0119] Because the file source data in the unselected disks are not rebuilt and the files stored therein cannot be accessed, the file source data and files in the unselected disks are deleted to save space, so as to ensure the reasonable allocation of disk resources. For example, based on the above example, for example, thread 4 corresponding to disk 4 deletes the file source data and files stored in disk 4.
[0120] Specifically, the above-mentioned judgment unit is suitable for calculating the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache; according to the preset ratio and the calculated difference, the file source data to be discarded of each disk is determined, and the file source data of each disk that is not to be discarded is used as the file source data of each disk to be rebuilt.
[0121] In this embodiment, if the sum of the sizes of the file source data on each disk is larger than the total storage space size of the cache, a portion of the file source data from each disk is discarded and not reconstructed.
[0122] For example, there are file source data in disk 1, disk 2, disk 3 and disk 4 that need to be rebuilt, but the sum of the sizes of the file source data in disk 1, disk 2, disk 3 and disk 4 is greater than the total storage space size of the cache. The preset ratio is 1:1:1:1, and if the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache is 100M, then according to the preset ratio, 25M of file source data are determined from disk 1, disk 2, disk 3 and disk 4 as the file source data to be discarded, and then the file source data not to be discarded in disk 1, disk 2, disk 3 and disk 4 are rebuilt.
[0123] Preferably, the above-mentioned preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0124] Based on the above example, if the files in disk 1 are more popular than the files in disk 2, the discard ratio of disk 1 and disk 2 can be reduced accordingly. For example, the preset ratio is 1:2:3:3.
[0125] Further, based on the above embodiment, Figure 2 The device shown also includes:
[0126] The deletion unit is adapted to utilize a plurality of threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
[0127] For example, based on the above example, Thread 1, Thread 2, Thread 3 and Thread 3 corresponding to Disk 1, Disk 2, Disk 3 and Disk 4 are used to delete 25M of file source data to be discarded from Disk 1, Disk 2, Disk 3 and Disk 4 respectively.
[0128] In summary, according to the technical solution of the present invention, the storage location in the cache corresponding to the file source data of each disk in the memory is determined; several threads are started, wherein the started threads correspond one to one to the disks in the memory; and the file source data stored in the corresponding disks are rebuilt into the corresponding storage location in the cache using several threads. In this technical solution, several threads simultaneously rebuild the file source data stored in the corresponding disks into the corresponding storage location in the cache, thereby reducing the reconstruction time, improving the reconstruction efficiency, and ensuring the normal use of the server.
[0129] It should be noted that:
[0130] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.
[0131] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0132] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0133] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0134] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0135] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components of a cache reconstruction device, an electronic device, and a computer-readable storage medium according to an embodiment of the present invention. The present invention may also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing a portion or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0136] For example, Figure 3 FIG. 3 is a block diagram of an electronic device according to an embodiment of the present invention. The electronic device 300 conventionally includes a processor 310 and a memory 320 arranged to store computer executable instructions (program code). The memory 320 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. The memory 320 has a memory for storing instructions for executing the program. Figure 1 The storage space 330 for program code 340 of any method step shown in the figure and in each embodiment. For example, the storage space 330 for program code may include various program codes 340 respectively used to implement various steps in the above method. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are usually, for example, Figure 4 The computer readable storage medium 400. The computer readable storage medium 400 may have Figure 3 The memory 320 in the electronic device of the present invention is similarly arranged as a storage segment, storage space, etc. The program code can be compressed, for example, in an appropriate form. Generally, the storage unit stores program code 410 for executing the steps of the method according to the present invention, that is, program code that can be read by a processor such as 310, and when these program codes are run by the electronic device, the electronic device performs the various steps in the method described above.
[0137] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be constructed as a limitation to the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present invention can be implemented by means of hardware including several different elements and by means of appropriately programmed computers. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, first, and third, etc. does not indicate any order. These words may be interpreted as names.
[0138] The embodiment of the present invention discloses A1, a cache reconstruction method, wherein the method comprises:
[0139] Determine the storage location in the cache corresponding to the file source data on each disk in the memory;
[0140] Start several threads, where the started threads correspond one-to-one to the disks in the memory;
[0141] Using several threads, the file source data stored in the corresponding disk is rebuilt to the corresponding storage location in the cache.
[0142] A2. The method as described in A1, wherein determining the storage location in the cache corresponding to the file source data of each disk in the memory comprises:
[0143] Get the number of files on each disk;
[0144] Calculate the storage space required for the file source data on each disk based on the acquired file number information;
[0145] According to the calculated storage space size required by the file source data of each disk, a storage location of the corresponding storage space size is requested from the cache for each disk, and a corresponding relationship is established between each disk and the storage location of the corresponding storage space size.
[0146] A3. The method as described in A2, wherein the step of requesting a storage location of a corresponding storage space size for each disk from the cache comprises:
[0147] According to the minimum storage unit of the cache, a storage location of a corresponding storage space size is requested from the cache for each disk.
[0148] A4. The method as described in A2, wherein the step of using a plurality of threads to respectively reconstruct the file source data stored in the corresponding disk to the corresponding storage location in the cache comprises:
[0149] According to the established corresponding relationship, several threads are used to access the storage positions of the corresponding disks respectively, and the file source data stored in the corresponding disks are rebuilt into the corresponding storage positions in the cache.
[0150] A5. The method as described in A1, wherein the method further comprises:
[0151] According to the file number information of each disk, determine whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache;
[0152] If the judgment is yes, determine the file source data of each disk to be rebuilt;
[0153] The method of using a plurality of threads to respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache includes:
[0154] Using several threads, the file source data of each disk to be rebuilt is rebuilt to the corresponding storage position in the cache.
[0155] A6. The method as described in A5, wherein determining the file source data of each disk to be rebuilt comprises:
[0156] One or more disks are selected from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0157] A7. The method as described in A6, wherein the method further comprises:
[0158] The file source data and files in the unselected disk are deleted by using the thread corresponding to the unselected disk.
[0159] A8. The method as described in A5, wherein determining the file source data of each disk to be rebuilt comprises:
[0160] Calculate the difference between the sum of the sizes of the source data of the files on each disk and the total storage space size of the cache;
[0161] According to the preset ratio and the calculated difference, the file source data to be discarded of each disk is determined, and the file source data not to be discarded of each disk is used as the file source data of each disk to be reconstructed.
[0162] A9. The method as described in A8, wherein:
[0163] The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0164] A10. The method as described in A8, wherein the method further comprises:
[0165] Utilize several threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
[0166] The embodiment of the present invention further discloses B11, a cache reconstruction device, wherein the device comprises:
[0167] a determination unit adapted to determine storage locations in the cache corresponding to file source data on each disk in the memory;
[0168] An opening unit, adapted to open a number of threads, wherein the opened threads correspond one to one with the disks in the memory;
[0169] The reconstruction unit is adapted to utilize a plurality of threads to respectively reconstruct the file source data stored in the corresponding disk to the corresponding storage location in the cache.
[0170] B12. The device as described in B11, wherein
[0171] The determination unit is suitable for obtaining the file number information of each disk; calculating the storage space size required for the file source data of each disk based on the obtained file number information; requesting a storage location of the corresponding storage space size for each disk from the cache based on the calculated storage space size required for the file source data of each disk, and establishing a corresponding relationship between each disk and the storage location of the corresponding storage space size.
[0172] B13. The device as described in B12, wherein:
[0173] The determining unit is adapted to request a storage location of a corresponding storage space size for each disk from the cache according to the minimum storage unit of the cache.
[0174] B14. The device as described in B12, wherein:
[0175] The reconstruction unit is adapted to use a plurality of threads to access storage locations of corresponding disks respectively according to the established corresponding relationship, and to reconstruct the file source data stored in the corresponding disks to the corresponding storage locations in the cache.
[0176] B15. The device as described in B11, wherein the device further comprises:
[0177] A judgment unit, adapted to judge whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache according to the file number information of each disk; if the judgment is yes, determine the file source data of each disk to be rebuilt;
[0178] The reconstruction unit is suitable for using a plurality of threads to respectively reconstruct the file source data of each disk to be reconstructed to the corresponding storage position in the cache.
[0179] B16. The device as described in B15, wherein
[0180] The determination unit is adapted to select one or more disks from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
[0181] B17. The device as described in B16, wherein the device further comprises:
[0182] The deleting unit is adapted to utilize the threads corresponding to the unselected disks to delete the file source data and files in the unselected disks.
[0183] B18. The device as described in B15, wherein
[0184] The judgment unit is suitable for calculating the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache; determining the file source data to be discarded of each disk according to a preset ratio and the calculated difference, and using the non-to-be-discarded file source data of each disk as the file source data of each disk to be rebuilt.
[0185] B19. The device as described in B18, wherein
[0186] The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
[0187] B20. The device as described in B18, wherein the device further comprises:
[0188] The deletion unit is adapted to utilize a plurality of threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
[0189] The embodiment of the present invention further discloses C21, an electronic device, wherein the electronic device comprises:
[0190] processor; and,
[0191] A memory arranged to store computer executable instructions, which when executed cause the processor to perform a method according to any one of A1 to A10.
[0192] An embodiment of the present invention further discloses D22, a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the methods described in any one of A1 to A10 are implemented.
Claims
1. A cache reconstruction method, wherein: The method includes: Determine a storage location in the cache corresponding to the file source data of each disk in the memory, wherein each disk has a corresponding relationship with the storage location; Start several threads, where the started threads correspond one-to-one to the disks in the memory; Using several threads, the file source data stored in the corresponding disk is rebuilt to the corresponding storage location in the cache; The method of using a plurality of threads to respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache includes: According to the established corresponding relationship, several threads are used to access the storage positions of the corresponding disks respectively, and the file source data stored in the corresponding disks are rebuilt into the corresponding storage positions in the cache.
2. The method of claim 1, wherein: Determining the storage location in the cache corresponding to the file source data of each disk in the memory includes: Get the number of files on each disk; Calculate the storage space required for the file source data on each disk based on the acquired file number information; According to the calculated storage space size required by the file source data of each disk, a storage location of the corresponding storage space size is requested from the cache for each disk, and a corresponding relationship is established between each disk and the storage location of the corresponding storage space size.
3. The method of claim 2, wherein: The storage location of requesting corresponding storage space size for each disk from the cache includes: According to the minimum storage unit of the cache, a storage location of a corresponding storage space size is requested from the cache for each disk.
4. The method of claim 1, wherein: The method further includes: According to the file number information of each disk, determine whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache; If the judgment is yes, determine the file source data of each disk to be rebuilt; The method of using a plurality of threads to respectively rebuild the file source data stored in the corresponding disk to the corresponding storage location in the cache includes: Using several threads, the file source data of each disk to be rebuilt is rebuilt to the corresponding storage position in the cache.
5. The method of claim 4, wherein: The determining of the file source data of each disk to be rebuilt includes: One or more disks are selected from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
6. The method of claim 5, wherein: The method further includes: The file source data and files in the unselected disk are deleted by using the thread corresponding to the unselected disk.
7. The method of claim 4, wherein: The determining of the file source data of each disk to be rebuilt includes: Calculate the difference between the sum of the sizes of the source data of the files on each disk and the total storage space size of the cache; According to the preset ratio and the calculated difference, the file source data to be discarded of each disk is determined, and the file source data not to be discarded of each disk is used as the file source data of each disk to be reconstructed.
8. The method of claim 7, wherein: The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
9. The method of claim 7, wherein: The method further includes: Utilize several threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
10. A cache reconstruction device, wherein: The device includes: A determination unit, adapted to determine a storage location in the cache corresponding to the file source data of each disk in the memory, wherein each disk has a corresponding relationship with the storage location; An opening unit, adapted to open a plurality of threads, wherein the opened threads correspond one to one with the disks in the memory; The reconstruction unit is suitable for using several threads to reconstruct the file source data stored in the corresponding disk to the corresponding storage position in the cache; the method of using several threads to reconstruct the file source data stored in the corresponding disk to the corresponding storage position in the cache includes: according to the established corresponding relationship, using several threads to access the storage position of the corresponding disk respectively, and reconstructing the file source data stored in the corresponding disk to the corresponding storage position in the cache.
11. The device of claim 10, wherein: The determination unit is suitable for obtaining the file number information of each disk; calculating the storage space size required for the file source data of each disk based on the obtained file number information; requesting a storage location of the corresponding storage space size for each disk from the cache based on the calculated storage space size required for the file source data of each disk, and establishing a corresponding relationship between each disk and the storage location of the corresponding storage space size.
12. The device of claim 11, wherein: The determining unit is adapted to request a storage location of a corresponding storage space size for each disk from the cache according to the minimum storage unit of the cache.
13. The device of claim 11, wherein: The reconstruction unit is adapted to use a plurality of threads to access storage locations of corresponding disks respectively according to the established corresponding relationship, and to reconstruct the file source data stored in the corresponding disks to the corresponding storage locations in the cache.
14. The device of claim 10, wherein: The device also includes: A judgment unit, adapted to judge whether the sum of the sizes of the file source data of each disk is greater than the total storage space size of the cache according to the file number information of each disk; if the judgment is yes, determine the file source data of each disk to be rebuilt; The reconstruction unit is suitable for using a plurality of threads to respectively reconstruct the file source data of each disk to be reconstructed to the corresponding storage position in the cache.
15. The device of claim 14, wherein: The determination unit is adapted to select one or more disks from the disks as disks to be rebuilt, wherein the sum of the sizes of the file source data of the disks to be rebuilt matches the total storage space size of the cache.
16. The device of claim 15, wherein: The device also includes: The deleting unit is adapted to utilize the threads corresponding to the unselected disks to delete the file source data and files in the unselected disks.
17. The device of claim 14, wherein: The judgment unit is suitable for calculating the difference between the sum of the sizes of the file source data of each disk and the total storage space size of the cache; determining the file source data to be discarded of each disk according to a preset ratio and the calculated difference, and using the non-to-be-discarded file source data of each disk as the file source data of each disk to be rebuilt.
18. The device of claim 17, wherein: The preset ratio is determined according to the access popularity of each disk before cache reconstruction.
19. The device of claim 17, wherein: The device also includes: The deletion unit is adapted to utilize a plurality of threads to delete the file source data to be discarded and the corresponding files in the corresponding disk respectively.
20. An electronic device, wherein: The electronic device includes: processor; and, A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method according to any one of claims 1 to 9.
21. A computer-readable storage medium, wherein: The computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the method according to any one of claims 1 to 9 is implemented.
