Data processing method and device, computer equipment, storage medium and program product
By allocating different physical blocks to compressed data, the problem of traditional data compression and copying affecting disk performance is solved, and a more efficient data writing process is achieved.
Patent Information
- Application Number
- CN202410867612.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-17
AI Technical Summary
The traditional data compression and copying process will affect disk performance and require reading address information from other storage locations, resulting in reduced performance.
This reduces the impact on disk performance during the copying process by allocating different physical blocks to the compressed data and writing it to disk without reading other data.
It effectively reduces the impact of disk performance, improves data copy efficiency, and avoids the consumption of supplementary reading caused by reading other data.
Smart Images

Figure CN118656027A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the rapid development of information technology, the amount of data has exploded, which has brought great challenges to distributed storage systems in today's big data era. Data compression technology can reduce the amount of data or reorganize the data without losing useful information, so as to reduce storage space and improve storage efficiency.
[0003] In conventional technology, when data is overwritten on a physical block, it is necessary to read address information of other storage locations on the physical block, and then store the compressed data to be overwritten and the data of other storage locations to the original location on the physical block.
[0004] However, the above method will affect the performance of the disk. Summary of the invention
[0005] Based on this, it is necessary to provide a data processing method, device, computer equipment, computer-readable storage medium and computer program product that can reduce the impact of compressed data copying on disk performance in order to address the above technical problems.
[0006] In a first aspect, the present application provides a data processing method. The method comprises:
[0007] According to the received IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block;
[0008] Compressing the data to be compressed to obtain compressed data;
[0009] A second physical block is allocated for the compressed data, and the compressed data is written into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0010] In one embodiment, compressing the data to be compressed to obtain compressed data includes:
[0011] According to the type of the data volume of the IO request, the data to be compressed is compressed to obtain compressed data.
[0012] In one embodiment, compressing the data to be compressed according to the type of the data volume of the IO request to obtain the compressed data includes:
[0013] When the type of the data volume is a small IO request, writing the data to be compressed into a cache;
[0014] In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
[0015] In one embodiment, compressing the data to be compressed according to the type of the data volume of the IO request to obtain the compressed data includes:
[0016] When the type of the data volume is a large IO request, writing the data to be compressed into a disk;
[0017] During the disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
[0018] In one embodiment, obtaining the to-be-compressed data corresponding to the received IO request from the first physical block according to the received IO request includes:
[0019] When the data amount of the IO request is a large IO request, scanning first metadata information of each physical block;
[0020] If the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, the data to be compressed is obtained.
[0021] In one embodiment, after allocating the second physical block for the compressed data, the method further comprises:
[0022] A mapping relationship between the logical address corresponding to the IO request and the second physical address is established.
[0023] In one embodiment, the method further comprises:
[0024] Second metadata information of the second physical block is modified, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
[0025] In one embodiment, before allocating a second physical block for the compressed data, the method further comprises:
[0026] Determining whether there is write data in the first physical block;
[0027] If the write data does not exist in the first physical block, the mapping relationship between the logical address and the first physical address is cleared.
[0028] In one embodiment, writing the compressed data into the second physical block includes:
[0029] Aggregating the plurality of compressed data to be written into the second physical block to obtain aggregated data;
[0030] The aggregate data is written into the second physical block.
[0031] In one embodiment, the method further comprises:
[0032] Determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each of the physical blocks includes the first physical block and the second physical block;
[0033] If the target physical block exists in each of the physical blocks, the discrete data in other physical blocks except the target physical block in each of the physical blocks are moved to the target physical block, so that there is no free storage space in the target physical block.
[0034] In a second aspect, the present application further provides a data processing device. The device comprises:
[0035] An acquisition module, configured to acquire, according to a received IO request, the to-be-compressed data corresponding to the IO request from the first physical block;
[0036] A compression module, used for compressing the data to be compressed to obtain compressed data;
[0037] A writing module is used to allocate a second physical block for the compressed data and write the compressed data into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0038] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in the first aspect are implemented.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0040] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0041] In the above-mentioned data processing method, apparatus, computer equipment, computer-readable storage medium and computer program product, the server obtains the data to be compressed corresponding to the IO request from the first physical block according to the received IO request, then compresses the data to be compressed to obtain the compressed data, and then allocates a second physical block for the compressed data, and writes the compressed data into the second physical block. Compared with the process of writing the compressed data into the first physical block, which requires reading other data in the first physical block, in the data processing method, since the first physical address corresponding to the first physical block is different from the second physical address corresponding to the second physical block, that is, the second physical block and the first physical block are different physical blocks, the compressed data can be written to the disk without reading other data in the second physical block in the process of writing the compressed data into the second physical block. Therefore, when writing the compressed data to the disk, the supplementary reading consumption caused by reading other data in the physical block can be avoided, thereby reducing the impact on the disk performance during the process of copying the data on the disk. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 An application environment diagram of a data processing method in an embodiment;
[0044] Figure 2 is a flow chart of a data processing method in one embodiment;
[0045] Figure 3 is a flow chart of a data processing method in another embodiment;
[0046] Figure 4 is a flow chart of a data processing method in another embodiment;
[0047] Figure 5 is a flow chart of step 201 in another embodiment;
[0048] Figure 6 is a flow chart of a data processing method in another embodiment;
[0049] Figure 7 is a flow chart of a data processing method in another embodiment;
[0050] Figure 8is a flow chart of a data processing method in another embodiment;
[0051] Fig. 9 is a structural block diagram of a data processing device in one embodiment;
[0052] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] The data processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 can receive the IO request sent by the terminal 102, and obtain the data to be compressed from the first physical block, and after compressing the data to be compressed, write it into the allocated second physical block. Among them, the terminal 102 can be but not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0055] In an exemplary embodiment, Figure 2 As shown, a data processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate, including the following steps 201-203:
[0056] Step 201: According to the received IO request, the to-be-compressed data corresponding to the IO request is obtained from the first physical block.
[0057] It should be noted that the data processing method provided in the present application can be applied to the scenario of overwriting data that has been stored in a disk.
[0058] The IO request is received by the server from the terminal through the network. The server can read and write data by responding to the IO request. In this embodiment, the IO request can instruct the server to modify the data corresponding to the IO request.
[0059] In this embodiment, the server can receive an IO request sent by a terminal through a network, and obtain the logical address of the first physical block storing the data to be compressed by parsing the IO request. Then, the server can determine the physical address of the first physical block based on the logical address, and thus obtain the data to be compressed from the first physical block based on the physical address of the first physical block.
[0060] Step 202: compress the data to be compressed to obtain compressed data.
[0061] The compression process refers to a method of reorganizing data according to a certain algorithm to reduce data redundancy and storage space. It is understandable that the storage space occupied by the compressed data is smaller than the storage space occupied by the data to be compressed.
[0062] In this embodiment, the server may use a compression algorithm to perform compression processing on the data to be compressed to reduce the amount of the data to be compressed, and determine the result after the compression processing as the compressed data.
[0063] Optionally, the compression algorithm may be a lossless compression algorithm, such as the Huffman algorithm, a string table compression algorithm, etc. Wherein, no compression means that the compressed data is used for reconstruction, and the reconstructed data is exactly the same as the data to be compressed, and the information of the data is not damaged after compression. For example, after lossless compression, the data of an ordinary file can be compressed to 1 / 2-1 / 4 of the original size.
[0064] Step 203: allocate a second physical block for the compressed data, and write the compressed data into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0065] It should be noted that after the server compresses the data to be compressed according to the IO request, it needs to rewrite the compressed data to the disk. However, since disk writing is generally written in a 4k aligned manner, after obtaining the data to be processed from the physical block of the disk and processing it, when the data to be processed needs to be rewritten to the physical block, it is necessary to read other data in the physical block, and then write the processed data and other data to the physical block again. However, this will cause the consumption of supplementary reading, thereby affecting the performance of the disk.
[0066] Therefore, in an embodiment of the present application, the compressed data after the compression process can be written into other physical blocks, that is, the second physical block. The second physical block refers to other physical blocks in the disk except the first physical block, and the address of the first physical block in the disk is determined as the first physical address, and the address of the second physical block in the disk is determined as the second physical address. It can be understood that the size of the storage space of the second physical block can be the same as the size of the storage space of the second physical block, and the second physical block can be a physical block adjacent to the first physical block, or the second physical block can also be non-adjacent to the first physical block. The available storage space of the second physical block can be greater than or equal to the compressed data to avoid the situation where the compressed data needs to be stored in two physical blocks.
[0067] In this embodiment, the server may use a free physical block in the disk as the second physical block, allocate the second physical block to the compressed data, and then write the compressed data into the second physical block.
[0068] In the above data processing method, the server obtains the data to be compressed corresponding to the IO request from the first physical block according to the received IO request, then compresses the data to be compressed to obtain the compressed data, and then allocates a second physical block for the compressed data, and writes the compressed data into the second physical block. Compared with the process of writing the compressed data into the first physical block, which requires reading other data in the first physical block, in this data processing method, since the first physical address corresponding to the first physical block is different from the second physical address corresponding to the second physical block, that is, the second physical block and the first physical block are different physical blocks, the compressed data can be written to the disk without reading other data in the second physical block in the process of writing the compressed data into the second physical block. Therefore, when writing the compressed data to the disk, the supplementary reading consumption caused by reading other data in the physical block can be avoided, thereby reducing the impact on the disk performance in the process of overwriting the data on the disk.
[0069] based on Figure 2 The embodiment shown in the figure is related to the process of how the server compresses the data to be compressed to obtain the compressed data. The process may include: compressing the data to be compressed according to the type of the data volume of the IO request to obtain the compressed data.
[0070] The data volume type of the IO request refers to the size of the data volume corresponding to the IO request. According to the size of the data volume corresponding to the IO request, the type of the data volume can be determined. For example, if the data volume is greater than a preset data volume threshold, the data volume type of the IO request can be determined to be a large IO request, or if the data volume is less than the preset data volume threshold, the data volume type of the IO request can be determined to be a small-large IO request.
[0071] It should be noted that in a distributed storage system, different data writing methods are used for large IO requests and small IO requests. Therefore, in an embodiment of the present application, different data compression processing methods can be used to perform data compression processing on small IO requests and large IO requests respectively.
[0072] In a possible implementation of the compression process, the server may perform compression processing on the to-be-compressed data corresponding to the small IO request. Figure 3 , the server can execute steps 301 and 302 to implement this implementation.
[0073] Step 301: When the data volume type is a small IO request, write the data to be compressed into the cache.
[0074] Cache refers to a high-speed memory with faster access speed than random access memory, which can speed up the opening of browser pages and reduce network bandwidth consumption. When the server receives a small IQ request, it can write the compressed data corresponding to the IO request into the browser cache first, and then respond to the terminal, thereby improving the response efficiency to the IO request.
[0075] In this embodiment, the server may write the data corresponding to the IO request into the cache when determining that the IO request is a small IO request according to the type of the data amount of the IO request.
[0076] Step 302 : In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain compressed data.
[0077] It should be noted that after the server writes the data to be compressed corresponding to the IO request into the cache, the data to be written into the disk can be transferred to the disk according to the identifier of the data in the cache. In the embodiment of the present application, the data to be compressed can be compressed while transferring the data to the disk without affecting the response efficiency of the server to the IO request.
[0078] Optionally, in this embodiment, the server may read the data to be compressed corresponding to each small IO request from the cache in turn, and use a compression algorithm to compress the data to be compressed, and determine the result of the compression processing as the compressed data; or, the server may also periodically read the compressed data corresponding to multiple small IO requests from the cache, and use a compression algorithm to compress the data to be compressed, and determine the result of the compression processing as the compressed data.
[0079] In this implementation, when the data volume type is a small IO request, the server writes the data to be compressed into the cache, and then compresses the data to be compressed stored in the cache while transferring the data to be compressed stored in the cache to the disk to obtain compressed data. Since the data to be compressed is written into the cache before data compression, the small IO request can be responded to in a timely manner, and then the data to be compressed stored in the cache is compressed, thereby saving disk storage space through compression processing without affecting the response efficiency to the small IQ request.
[0080] In another possible implementation of the compression process, the server may perform compression processing on the to-be-compressed data corresponding to the large IO request. Figure 4 , the server can execute steps 401 and 402 to implement this implementation.
[0081] Step 401 : when the data volume type is a large IO request, write the data to be compressed to the disk.
[0082] It should be noted that in data storage, in order to improve disk performance, the number of disk accesses can be reduced. Usually, the server uses a physical block as the minimum unit of read and write operations. Since the amount of data to be compressed corresponding to a large IO request is relatively large and can meet the storage space size of the physical block, the server can directly write the data to be compressed to the disk. Among them, the disk refers to a storage device for storing data. In order to facilitate the management of file data on the disk, the disk can be divided into multiple physical blocks of the same size. When reading and writing data, one physical block is used as the access unit for reading and writing operations.
[0083] In this embodiment, the server can determine the physical address corresponding to the logical address based on the logical address corresponding to the large IO request and the stored address mapping relationship, and then write the data to be compressed corresponding to the large IO request into the physical block corresponding to the physical address, thereby realizing the operation of writing the data to be compressed corresponding to the large IO request into the disk.
[0084] Step 402, during the process of disk space arrangement, compress the data to be compressed stored in the disk to obtain compressed data.
[0085] It should be noted that after writing the data to be compressed corresponding to the large IO request to the disk, in order not to affect the response efficiency to the large IO request, the server can first respond to the large IO request, and then organize the disk space when the server system is relatively idle. In the process of disk space organization, the data to be compressed corresponding to the large IO request can be compressed to save disk storage space.
[0086] In this embodiment, during the process of organizing the disk space, the server may first obtain the data to be compressed in the disk, and then use a compression algorithm to perform compression processing on the data to be compressed, and obtain the compressed data according to the result of the compression processing.
[0087] In this implementation, when the data volume type is a large IO request, the server writes the data to be compressed to the disk, and then, during the disk space organization process, the compressed data can be obtained by compressing the data to be compressed stored in the disk, thereby saving the storage space occupied by the data to be compressed; further, since the disk space organization process is an operation performed when the server system is idle, it can save storage space while avoiding reducing the response speed to large IO requests.
[0088] In an embodiment of the present application, the server can compress the data to be compressed according to the type of data volume requested by the IO, and then obtain the compressed data. Since the compressed data can be processed separately according to the type of data volume requested by the IO, the data compression requirements of different IO requests can be met.
[0089] Based on the above embodiment, this embodiment involves a process of how the server obtains the data to be compressed corresponding to the large IO request. Figure 5 , step 201 includes Figure 5 Step 501 and step 502 are shown:
[0090] Step 501 : When the data volume of the IO request is a large IO request, scan the first metadata information of each physical block.
[0091] The first metadata information refers to data used to describe whether the data of each physical block in the disk is compressed data or uncompressed data. It can be understood that since the data to be compressed corresponding to the large IO request is directly written to the disk, the data in the physical block storing the data to be compressed corresponding to the large IO request is uncompressed data.
[0092] In this embodiment, when determining that the type of the data volume of the IO request is a large IO request, the server may respectively obtain the first metadata information corresponding to each physical block to scan the first metadata information of each physical block.
[0093] Step 502: If the first metadata information of the first physical block indicates that the first physical block stores data to be compressed, the data to be compressed is obtained.
[0094] It should be noted that, if the data stored in the first physical block is compressed data, the first metadata information of the first physical block can represent that the data stored in the first physical block is compressed data; if the data stored in the first physical block is uncompressed data, the first metadata information of the first physical block can represent that the data stored in the first physical block is uncompressed data.
[0095] In this embodiment, the server may parse and identify metadata information of each physical block. If the parsing and identification results indicate that the first physical block stores data to be compressed, the data to be compressed may be obtained from the first physical block.
[0096] In an embodiment of the present application, when the type of data volume is a large IO request, the server can obtain the data to be compressed by scanning the first metadata information of each physical block when the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, thereby compressing the uncompressed data in the disk, thereby saving storage space of the disk.
[0097] Based on the above embodiment, this embodiment relates to the processing of the server after the server allocates the second physical block for the compressed data. The above method also includes: establishing a mapping relationship between the logical address corresponding to the IO request and the second physical address.
[0098] It should be noted that in the disk file system, if data has been stored in a physical block, the logical address of the stored data can be mapped to the physical address of the physical block, so that the server can determine the corresponding physical address based on the logical address, and thereby perform read and write operations on the data on the physical block corresponding to the physical address.
[0099] As a possible implementation, when a mapping relationship between a logical address corresponding to an IO request and a second physical address is established, second metadata information of the second physical block may also be modified, where the second metadata information is used to indicate that compressed data is stored in the second physical block. If the data stored in the second physical block changes, the second metadata information needs to be modified accordingly.
[0100] In the embodiment of the present application, by establishing a mapping relationship between the logical address corresponding to the IO request and the second physical address, the server can quickly determine the second physical address through the logical address corresponding to the IO request and the mapping relationship, thereby quickly determining the corresponding second physical block based on the second physical address, and then quickly writing the compressed data into the second physical block corresponding to the second physical address.
[0101] It should be noted that if the server allocates a second physical block for the compressed data, it is necessary to map the logical address corresponding to the IO request with the second physical address of the second physical block. However, before the compressed data is compressed, there is a mapping relationship between the logical address corresponding to the IO request and the first physical address of the first physical block. Therefore, before the server allocates the second physical block for the compressed data, it is necessary to clear the mapping relationship between the logical address and the first physical address. Figure 6 , the server implements the process through steps 601 and 602.
[0102] Step 601, determine whether there is write data in the first physical block.
[0103] Step 602: If there is no write data in the first physical block, clear the mapping relationship between the logical address and the first physical address.
[0104] It can be understood that if data has been written in the first physical block, it means that a mapping relationship has been established between the first physical address of the first physical block and the logical address of the written data, that is, the logical address corresponding to the IO request is in a state where there is no mapping relationship. In this case, the server can directly establish a mapping relationship between the logical address corresponding to the IO request and the second physical address, and store the mapping relationship in the mapping relationship table of the second physical block; if no data has been written in the first physical block, it means that a mapping relationship still exists between the first physical address of the first physical block and the logical address corresponding to the IO request. In this case, the server needs to clear the mapping relationship between the logical address and the first physical address, so that the logical address is in a state where there is no mapping relationship, so that a mapping relationship between the logical address and the second physical address can be established.
[0105] In this embodiment, the server can execute an instruction to perform a data read operation on the first physical block to obtain the data in the first physical block. If the result of the data read operation is that data exists, it can be determined that there is write data in the first physical block; if the result of the data read operation is that data does not exist, it can be determined that there is no write data in the first physical block; thus, when there is no write data in the first physical block, the relationship mapping table corresponding to the first physical block is modified, and the record of the mapping relationship between the logical address and the first physical address is deleted to clear the mapping relationship between the logical address and the first physical address.
[0106] In an embodiment of the present application, the server can determine whether there is write data in the first physical block. When there is no write data in the first physical block, the server can clear the mapping relationship between the logical address and the first physical address, thereby making the logical address in a state where there is no mapping relationship, and then can establish a mapping relationship between the logical address and the second physical address.
[0107] In one embodiment, based on the above embodiment, see Figure 7 This embodiment relates to how the server writes compressed data into the second physical block, including Figure 7 Step 701 and step 702 are shown:
[0108] Step 701 : Aggregate a plurality of compressed data to be written into a second physical block to obtain aggregated data.
[0109] Aggregation processing refers to a method of concatenating multiple data to obtain an aggregated data. It is understandable that after the compressed data belonging to the same physical block are aggregated, the aggregated data can be written into the second physical block by performing a data write operation.
[0110] Step 702: write the aggregated data into the second physical block.
[0111] In this embodiment, the server can determine the compressed data belonging to the second physical address based on the physical address corresponding to the logical address of the compressed data, and then perform data aggregation processing on the compressed data belonging to the second physical address, aggregate multiple compressed data into one aggregated data, and then execute the data write operation to write the aggregated data into the second physical block.
[0112] In an embodiment of the present application, the server aggregates multiple compressed data written in the second physical block to obtain aggregated data, and writes the aggregated data into the second physical block. This can reduce the number of operations of writing the compressed data into the second physical block, thereby reducing the consumption of server performance in writing the data to be compressed into the disk.
[0113] In one embodiment, based on the above embodiment, see Figure 8 This embodiment relates to how the server processes the physical block to release the free storage space if there is still free storage space on the physical block in the disk after the compressed data is written into the second physical block. Figure 8 Shown, including Figure 8 Step 801 and step 802 are shown:
[0114] Step 801, determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each physical block includes a first physical block and a second physical block.
[0115] It should be noted that a physical block may include several storage units. During the process of data writing, reading, modifying, and deleting, the storage units in the physical block may be occupied or released. Therefore, there may be a situation where the storage space in the physical block is partially occupied. However, the server performs data operations with a physical block as the operation unit. Therefore, if there is free storage space in the physical block, the free storage space will be fragmented. If there is space fragmentation in the physical block of the storage space, the available storage space of the disk will be reduced, thereby affecting the storage performance of the disk. Therefore, the space fragments in the physical blocks of the storage space can be sorted to release excess storage space to improve the storage performance of the disk.
[0116] Among them, the target physical block refers to a physical block with free storage space, which may include the first physical block storing the data to be compressed, the second physical block for writing compressed data, and other physical blocks except the first physical block and the second physical block.
[0117] In this embodiment, the server can obtain metadata information of the first physical block, the second physical block, and other physical blocks except the first physical block and the second physical block in the disk, and determine whether there is free storage space in each physical block based on the metadata information. Optionally, if there is free storage space in the physical block, the physical block is determined to be the target physical block; if there is no free storage space in the physical block, the physical block is determined not to be the target physical block.
[0118] Step 802: If there is a target physical block in each physical block, then the discrete data in other physical blocks except the target physical block in each physical block are moved to the target physical block, so that there is no free storage space in the target physical block.
[0119] The discrete data refers to the data stored in other physical blocks except the target physical block. It can be understood that by moving the discrete data in other physical blocks to the target physical block, the storage space occupied by the discrete data in other physical blocks can be released, thereby converting the other physical blocks into free physical blocks and reducing the free storage space in the target physical block, thereby improving the overall storage performance of the disk.
[0120] In this embodiment, when the server determines that there is a target physical block in the physical blocks, it can move discrete data in other physical blocks to the target physical block, and use the moved discrete data to occupy free storage space in the target physical block.
[0121] As a possible implementation method, when there is no free storage space in the target physical block, a new target physical block can be determined from the physical blocks, and then the new discrete data on other physical blocks can be moved to the new target physical block until there is no free storage space in the target physical blocks in the disk.
[0122] Exemplarily, if each physical block includes 4 storage units, and there are 2 free storage spaces R1 and R2 in the target physical block, and there is data A in other physical blocks, then data A can be moved to the free storage space R1 so that there is no free storage space in the target physical block.
[0123] In an embodiment of the present application, the server determines whether there is a target physical block including free storage space in each physical block in the disk. If there is a target physical block in each physical block, the server can move discrete data in other physical blocks except the target physical block in each physical block to the target physical block, so that there is no free storage space in the target physical block, and then other physical blocks can release free storage space, increase the free physical blocks in the disk, and improve the storage performance of the disk; in addition, since each physical block includes a first physical block and a second physical block, it is possible to reduce space fragmentation caused by compressing the data to be compressed and writing it to the disk, further reducing the impact of data compression on disk performance.
[0124] In one embodiment, a data processing method is provided for use in a server, the method comprising:
[0125] Step a, receiving an IO request.
[0126] Step b: when the IO request is a small IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block.
[0127] Step c: when the IO request is a large IO request, scan the first metadata information of each physical block, and if the first metadata information of the first physical block indicates that the first physical block stores data to be compressed, obtain the data to be compressed corresponding to the IO request.
[0128] Step d: when the IO request is a small IO request, the data to be compressed is written into the cache; in the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain compressed data.
[0129] Step e: when the IO request is a large IO request, the data to be compressed is written to the disk, and during the disk space arrangement, the data to be compressed stored in the disk is compressed to obtain compressed data.
[0130] Step f, determining whether there is write data in the first physical block.
[0131] Step g: if there is no write data in the first physical block, clear the mapping relationship between the logical address corresponding to the IO request and the first physical address.
[0132] Step h: allocating a second physical block for the compressed data.
[0133] Step i: establishing a mapping relationship between the logical address corresponding to the IO request and the second physical address.
[0134] Step j: modify the second metadata information of the second physical block, where the second metadata information is used to indicate that compressed data is stored in the second physical block.
[0135] Step k: aggregate the multiple compressed data to be written into the second physical block to obtain aggregated data.
[0136] Step 1: write the aggregated data into the second physical block.
[0137] Step m, determining whether there is a target physical block in each physical block in the disk, and whether there is free storage space in the target physical block, and each physical block includes a first physical block and a second physical block.
[0138] Step n: if the target physical block exists in each physical block, the discrete data in the other physical blocks except the target physical block in each physical block are moved to the target physical block, so that there is no free storage space in the target physical block.
[0139] It should be understood that, although each step in the flow chart involved in each embodiment as above is shown in sequence according to the indication of arrows, these steps are not necessarily executed in sequence according to the order indicated by arrows. Unless there is clear explanation in this article, the execution of these steps does not have strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flow chart involved in each embodiment of the write module as above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with at least a part of the steps or stages in other steps or other steps.
[0140] Based on the same inventive concept, the embodiment of the present application also provides a data processing device for implementing the data processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data processing device embodiments provided below can refer to the limitations on the data processing method above, and will not be repeated here.
[0141] In an exemplary embodiment, Fig. 9 As shown, a data processing device is provided, comprising:
[0142] The acquisition module 901 is used to acquire the to-be-compressed data corresponding to the received IO request from the first physical block according to the received IO request;
[0143] The compression module 902 is used to compress the data to be compressed to obtain compressed data;
[0144] The writing module 903 is used to allocate a second physical block for the compressed data and write the compressed data into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0145] In one embodiment, the compression module 902 includes:
[0146] The compression unit is used to compress the data to be compressed according to the type of the data volume of the IO request to obtain compressed data.
[0147] In one of the embodiments, the compression unit is specifically configured to write the to-be-compressed data into a cache when the type of the data volume is a small IO request;
[0148] In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
[0149] In one of the embodiments, the compression unit is specifically configured to write the to-be-compressed data to a disk when the type of the data volume is a large IO request;
[0150] During the process of disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
[0151] In one embodiment, the acquisition module 901 includes:
[0152] A scanning unit, configured to scan first metadata information of each physical block when the data amount type of the IO request is a large IO request;
[0153] An acquiring unit is configured to acquire the data to be compressed if the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block.
[0154] In one of the embodiments, after allocating the second physical block for the compressed data, the apparatus further comprises:
[0155] An establishing module is used to establish a mapping relationship between the logical address corresponding to the IO request and the second physical address.
[0156] In one embodiment, the device further comprises:
[0157] A modification module is used to modify second metadata information of the second physical block, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
[0158] In one of the embodiments, before allocating the second physical block for the compressed data, the apparatus further comprises:
[0159] A judging module, used for judging whether there is written data in the first physical block;
[0160] A clearing module is used to clear the mapping relationship between the logical address and the first physical address if the write data does not exist in the first physical block.
[0161] In one embodiment, the writing module 903 includes:
[0162] An aggregation unit, configured to aggregate the plurality of compressed data to be written into the second physical block to obtain aggregated data;
[0163] A writing unit is used to write the aggregated data into the second physical block.
[0164] In one embodiment, the device further comprises:
[0165] A determination module, used for determining whether there is a target physical block in each physical block in the disk, the target physical block has free storage space, and each of the physical blocks includes the first physical block and the second physical block;
[0166] A moving module is used to move discrete data in other physical blocks except the target physical block in each of the physical blocks to the target physical block if the target physical block exists in each of the physical blocks, so that there is no free storage space in the target physical block.
[0167] Each module in the above data processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the server in the form of hardware, or can be stored in the memory in the server in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0168] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data to be compressed and compressed data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data processing method is implemented.
[0169] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0170] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0171] According to the received IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block;
[0172] Compressing the data to be compressed to obtain compressed data;
[0173] A second physical block is allocated for the compressed data, and the compressed data is written into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0174] In one embodiment, the processor implements the following steps when executing the computer program:
[0175] According to the type of the data volume of the IO request, the data to be compressed is compressed to obtain compressed data.
[0176] In one embodiment, the processor implements the following steps when executing the computer program:
[0177] When the data amount of the IO request is a small IO request, writing the data to be compressed into a cache;
[0178] In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
[0179] In one embodiment, the processor implements the following steps when executing the computer program:
[0180] When the type of the data volume is a large IO request, writing the data to be compressed into a disk;
[0181] During the process of disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
[0182] In one embodiment, the processor implements the following steps when executing the computer program:
[0183] When the type of the data volume is a large IO request, scanning first metadata information of each physical block;
[0184] If the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, the data to be compressed is obtained.
[0185] In one embodiment, the processor implements the following steps when executing the computer program:
[0186] A mapping relationship between the logical address corresponding to the IO request and the second physical address is established.
[0187] In one embodiment, the processor implements the following steps when executing the computer program:
[0188] Second metadata information of the second physical block is modified, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
[0189] In one embodiment, the processor further implements the following steps when executing the computer program:
[0190] Determining whether there is write data in the first physical block;
[0191] If the write data does not exist in the first physical block, the mapping relationship between the logical address and the first physical address is cleared.
[0192] In one embodiment, the processor further implements the following steps when executing the computer program:
[0193] Aggregating the plurality of compressed data to be written into the second physical block to obtain aggregated data;
[0194] The aggregate data is written into the second physical block.
[0195] In one embodiment, the processor further implements the following steps when executing the computer program:
[0196] Determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each of the physical blocks includes the first physical block and the second physical block;
[0197] If the target physical block exists in each of the physical blocks, the discrete data in other physical blocks except the target physical block in each of the physical blocks are moved to the target physical block, so that there is no free storage space in the target physical block.
[0198] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0199] According to the received IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block;
[0200] Compressing the data to be compressed to obtain compressed data;
[0201] A second physical block is allocated for the compressed data, and the compressed data is written into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0202] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0203] According to the type of the data volume of the IO request, the data to be compressed is compressed to obtain compressed data.
[0204] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0205] When the type of the data volume is a small IO request, writing the data to be compressed into a cache;
[0206] In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
[0207] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0208] When the data amount of the IO request is a large IO request, writing the data to be compressed into a disk;
[0209] During the disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
[0210] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0211] When the type of the data volume is a large IO request, scanning first metadata information of each physical block;
[0212] If the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, the data to be compressed is obtained.
[0213] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0214] A mapping relationship between the logical address corresponding to the IO request and the second physical address is established.
[0215] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0216] Second metadata information of the second physical block is modified, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
[0217] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0218] Determining whether there is write data in the first physical block;
[0219] If the write data does not exist in the first physical block, the mapping relationship between the logical address and the first physical address is cleared.
[0220] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0221] Aggregating the plurality of compressed data to be written into the second physical block to obtain aggregated data;
[0222] The aggregate data is written into the second physical block.
[0223] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0224] Determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each of the physical blocks includes the first physical block and the second physical block;
[0225] If the target physical block exists in each of the physical blocks, the discrete data in other physical blocks except the target physical block in each of the physical blocks are moved to the target physical block, so that there is no free storage space in the target physical block.
[0226] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0227] According to the received IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block;
[0228] Compressing the data to be compressed to obtain compressed data;
[0229] A second physical block is allocated for the compressed data, and the compressed data is written into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
[0230] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0231] According to the type of the data volume of the IO request, the data to be compressed is compressed to obtain compressed data.
[0232] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0233] When the data amount of the IO request is a small IO request, writing the data to be compressed into a cache;
[0234] In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
[0235] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0236] When the type of the data volume is a large IO request, writing the data to be compressed into a disk;
[0237] During the process of disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
[0238] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0239] When the type of the data volume is a large IO request, scanning first metadata information of each physical block;
[0240] If the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, the data to be compressed is obtained.
[0241] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0242] A mapping relationship between the logical address corresponding to the IO request and the second physical address is established.
[0243] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0244] Second metadata information of the second physical block is modified, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
[0245] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0246] Determining whether there is write data in the first physical block;
[0247] If the write data does not exist in the first physical block, the mapping relationship between the logical address and the first physical address is cleared.
[0248] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0249] Aggregating the plurality of compressed data to be written into the second physical block to obtain aggregated data;
[0250] The aggregate data is written into the second physical block.
[0251] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0252] Determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each of the physical blocks includes the first physical block and the second physical block;
[0253] If the target physical block exists in each of the physical blocks, the discrete data in other physical blocks except the target physical block in each of the physical blocks are moved to the target physical block, so that there is no free storage space in the target physical block.
[0254] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0255] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0256] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data processing method, characterized in that: The method comprises: According to the received IO request, obtaining the to-be-compressed data corresponding to the IO request from the first physical block; Compressing the data to be compressed to obtain compressed data; A second physical block is allocated for the compressed data, and the compressed data is written into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
2. The method according to claim 1, characterized in that The compressing the data to be compressed to obtain compressed data includes: According to the type of the data volume of the IO request, the data to be compressed is compressed to obtain compressed data.
3. The method according to claim 2, characterized in that The compressing the data to be compressed according to the type of the data amount of the IO request to obtain compressed data includes: When the type of the data volume is a small IO request, writing the data to be compressed into a cache; In the process of transferring the data to be compressed stored in the cache to the disk, the data to be compressed stored in the cache is compressed to obtain the compressed data.
4. The method according to claim 2, characterized in that: The compressing the data to be compressed according to the type of the data amount of the IO request to obtain compressed data includes: When the type of the data volume is a large IO request, writing the data to be compressed into a disk; During the process of disk space arrangement, the data to be compressed stored in the disk is compressed to obtain the compressed data.
5. The method according to claim 1, characterized in that The step of obtaining, from the first physical block, the to-be-compressed data corresponding to the received IO request, includes: When the data amount of the IO request is a large IO request, scanning first metadata information of each physical block; If the first metadata information of the first physical block indicates that the data to be compressed is stored in the first physical block, the data to be compressed is obtained.
6. The method according to any one of claims 1 to 5, characterized in that: After allocating the second physical block for the compressed data, the method further comprises: A mapping relationship between the logical address corresponding to the IO request and the second physical address is established.
7. The method according to claim 6, characterized in that The method further comprises: Second metadata information of the second physical block is modified, where the second metadata information is used to indicate that the compressed data is stored in the second physical block.
8. The method according to claim 1, characterized in that Before allocating a second physical block for the compressed data, the method further comprises: Determining whether there is write data in the first physical block; If the write data does not exist in the first physical block, the mapping relationship between the logical address and the first physical address is cleared.
9. The method according to claim 1, characterized in that: Writing the compressed data into the second physical block comprises: Aggregating the plurality of compressed data to be written into the second physical block to obtain aggregated data; The aggregate data is written into the second physical block.
10. The method according to claim 1, characterized in that The method further comprises: Determine whether there is a target physical block in each physical block in the disk, there is free storage space in the target physical block, and each of the physical blocks includes the first physical block and the second physical block; If the target physical block exists in each of the physical blocks, the discrete data in other physical blocks except the target physical block in each of the physical blocks are moved to the target physical block, so that there is no free storage space in the target physical block.
11. A data processing device, characterized in that: The device comprises: An acquisition module, configured to acquire, according to a received IO request, the to-be-compressed data corresponding to the IO request from the first physical block; A compression module, used for compressing the data to be compressed to obtain compressed data; A writing module is used to allocate a second physical block for the compressed data and write the compressed data into the second physical block, wherein a first physical address corresponding to the first physical block is different from a second physical address corresponding to the second physical block.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
