Data compression storage method and device, electronic equipment and storage medium
By transferring data compression processing from the host processor to the device memory, the system performance problems caused by the host processor resource consumption are solved, and more efficient data compression storage is achieved.
Patent Information
- Application Number
- CN202410155954.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-02
- Publication Date
- 2025-08-05
AI Technical Summary
In the prior art, data compression through the host processor will cause large resource consumption to the central processor (CPU) and memory of the device, affecting system performance.
Transfer data compression processing from the host processor to the device memory, migrates the memory pages to segments through the host processor, and then migrates to clusters, and compresses and stores them from the device memory to reduce the resource consumption of the host processor.
Reduces resource consumption of data compression on host processors, and improves system performance and user experience.
Smart Images

Figure CN120428906A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data storage, and particularly to a method, apparatus, electronic device, and storage medium for compressed data storage. Background Art
[0002] In the scenario of compressed data storage, a device usually compresses data through a host processor and migrates the obtained compressed data to the device memory. The device includes a host processor and a device memory. For example, the host processor and the device memory can be different chips in the device.
[0003] However, compressing data through the host processor incurs relatively high overhead on the central processing unit (CPU) and memory of the device, which will have a certain impact on system performance. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a method, apparatus, electronic device, and storage medium for compressed data storage to reduce the impact of data compression on system performance.
[0005] On the one hand, an embodiment of this application provides a method for compressed data storage, which is applied to an electronic device. The electronic device includes a host processor and a device memory. The host processor includes memory pages, segments, and clusters, and the device memory includes logical units, including:
[0006] Migrate the target data of the memory page to the segment through the host processor;
[0007] Migrate the target data in the segment to the cluster through the host processor;
[0008] Send the target data in the cluster to the device memory through the host processor;
[0009] Compress the target data through the device memory to obtain compressed data;
[0010] Store the compressed data in the logical unit through the device memory.
[0011] In one implementation, there is at least one cluster. Migrating the target data in the segment to the cluster includes:
[0012] Determine whether there is a cluster that meets the set write condition in at least one cluster;
[0013] If so, use the cluster that meets the set write condition as the target cluster; otherwise, if it is determined that there is a released cluster, use the released cluster as the target cluster;
[0014] Migrate the target data to the corresponding erasable physical block in the target cluster; the cluster contains at least one erasable physical block.
[0015] In one implementation, determining whether there is a cluster that meets the set write condition in at least one cluster includes:
[0016] If it is determined that there is a cluster in the used state and the used cluster contains free space that meets the set space condition, or it is determined that there is a cluster in the idle state, it is determined that there is a cluster that meets the set write condition;
[0017] Otherwise, it is determined that there is no cluster that meets the set write condition.
[0018] In one implementation, sending the target data in the cluster to the device memory includes:
[0019] According to the correspondence between the erasable physical block and the logical unit, and the target data, determine the target erasable physical block; the target erasable physical block is determined according to the logical unit to which the target data is to be compressed and stored;
[0020] According to the free space of the logical unit corresponding to the target erasable physical block, determine the compression data threshold of the target erasable physical block;
[0021] Send a data compression storage request including the compression data threshold to the device memory;
[0022] When it is determined that an acknowledgment response returned by the device memory based on the data compression storage request is received, migrate the target data in the cluster to the logical unit corresponding to the target erasable physical block.
[0023] In one implementation, the method further includes:
[0024] When it is determined that an error response returned by the device memory based on the data compression storage request is received, obtain the compression write address included in the error response;
[0025] Update the target erasable physical block to obtain an updated target erasable physical block;
[0026] Obtain the logical unit address corresponding to the updated target erasable physical block;
[0027] If the compression write address is the same as the logical unit address, migrate the target data in the cluster to the logical unit corresponding to the updated erasable physical block;
[0028] Otherwise, update the target erasable physical block again and migrate the target data in the cluster to the logical unit corresponding to the erasable physical block after the second update.
[0029] In one implementation, after storing the compressed data in the logical unit, the method further includes:
[0030] Returning, through the device memory, the data compression length of the target data to the host processor;
[0031] Recording, through the host processor, the target erasable physical block and the data compression length for the target data.
[0032] On the one hand, in an embodiment of the present application, there is provided a data compression storage device, which is applied to an electronic device. The electronic device includes a host processor and a device memory. The host processor includes memory pages, segments, and clusters, and the device memory includes logical units, including:
[0033] A first migration unit, configured to migrate, through the host processor, the target data of the memory page to the segment;
[0034] A second migration unit, configured to migrate, through the host processor, the target data in the segment to the cluster;
[0035] A sending unit, configured to send, through the host processor, the target data in the cluster to the device memory;
[0036] A compression unit, configured to compress, through the device memory, the target data to obtain compressed data;
[0037] A storage unit, configured to store, through the device memory, the compressed data in the logical unit.
[0038] In one implementation, there is at least one cluster, and the second migration unit is configured to:
[0039] Determine whether there is a cluster that meets the set writing condition among at least one cluster;
[0040] If so, use the cluster that meets the set writing condition as the target cluster; otherwise, when it is determined that there is a released cluster, use the released cluster as the target cluster;
[0041] Migrate the target data to the corresponding erasable physical block in the target cluster; the cluster contains at least one erasable physical block.
[0042] In one implementation, the second migration unit is configured to:
[0043] If it is determined that there is a cluster in the used state and the used cluster contains free space that meets the set space condition, or it is determined that there is a cluster in the idle state, then it is determined that there is a cluster that meets the set writing condition;
[0044] Otherwise, it is determined that there is no cluster that meets the set writing condition.
[0045] In one implementation, the sending unit is configured to:
[0046] Determine a target erasable physical block according to the correspondence between the erasable physical blocks and the logical units, and the target data; the target erasable physical block is determined according to the logical unit to which the target data is to be compressed and stored;
[0047] Determine a compression data threshold of the target erasable physical block according to the free space of the logical unit corresponding to the target erasable physical block;
[0048] Send a data compression storage request including the compression data threshold to the device memory;
[0049] When it is determined that an acknowledgment response returned by the device memory based on the data compression storage request is received, migrate the target data in the cluster to the logical unit corresponding to the target erasable physical block.
[0050] In one implementation, the sending unit is further configured to:
[0051] When it is determined that an error response returned by the device memory based on the data compression storage request is received, obtain the compression write address included in the error response;
[0052] Update the target erasable physical block to obtain an updated target erasable physical block;
[0053] Obtain the logical unit address corresponding to the updated target erasable physical block;
[0054] If the compression write address is the same as the logical unit address, migrate the target data in the cluster to the logical unit corresponding to the updated erasable physical block;
[0055] Otherwise, update the target erasable physical block again, and migrate the target data in the cluster to the logical unit corresponding to the erasable physical block after the second update.
[0056] In one implementation, the storage unit is further configured to:
[0057] Return the data compression length of the target data to the host processor through the device memory;
[0058] Record the target erasable physical block and the data compression length for the target data through the host processor.
[0059] On the one hand, in an embodiment of the present application, an electronic device is provided, including:
[0060] A processor; and
[0061] A memory storing computer instructions for causing the processor to execute the steps of the methods provided in the various optional implementations of any of the above data compression storages.
[0062] On the one hand, an embodiment of the present application provides a storage medium storing computer instructions for causing a computer to execute the steps of the method provided in any of the various optional implementations of data compression storage as described above.
[0063] The data compression storage method in the embodiment of the present application includes migrating target data of a memory page to a segment through a host processor; migrating the target data in the segment to a cluster through the host processor; sending the target data in the cluster to a device memory through the host processor; compressing the target data by the device memory to obtain compressed data; and storing the compressed data in a logical unit by the device memory. In this way, the operation of data compression processing is transferred from the host processor to the device memory, reducing the resource consumption of the data compression on the host processor and the impact on the system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0065] Figure 1 It is a schematic diagram of the storage structure of an electronic device in an embodiment of the present application.
[0066] Figure 2 It is a flowchart of a data compression storage method in an embodiment of the present application.
[0067] Figure 3 It is an example diagram of a linked list in an embodiment of the present application.
[0068] Figure 4 It is a schematic diagram of data compression in an embodiment of the present application.
[0069] Figure 5 It is a schematic diagram of a PEB write protocol in an embodiment of the present application.
[0070] Figure 6 It is a schematic diagram of a PEB response protocol in an embodiment of the present application.
[0071] Figure 7 It is a schematic diagram of a PEB update in an embodiment of the present application.
[0072] Figure 8 It is a schematic diagram of a snode update in an embodiment of the present application.
[0073] Figure 9 It is a detailed flowchart of a data compression and storage method in an embodiment of the present application.
[0074] Figure 10 It is a structural block diagram of a data compression and storage device in an embodiment of the present application.
[0075] Figure 11 It is a schematic structural diagram of an electronic device in an embodiment of the present application. Specific embodiments
[0076] Next, the technical solutions of the present application will be clearly and completely described in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application. In addition, the technical features involved in different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0077] First, some terms involved in the embodiments of the present application will be explained to facilitate the understanding of those skilled in the art.
[0078] Terminal device: It can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a site, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system device, a personal navigation device, a personal digital assistant, an audio / video player, a digital camera / video camera, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a game device or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is also foreseeable that the terminal device can support any type of interface for users (such as wearable devices), etc.
[0079] Server: It can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0080] In the data compression and storage scenario, traditional devices usually compress data through a host processor and migrate the obtained compressed data to the device memory. Among them, the device includes a host processor and a device memory. For example, the host processor and the device memory can be different chips in the device.
[0081] However, data compression by the host processor incurs relatively high overhead on the device's CPU and memory, which will have a certain impact on system performance.
[0082] Based on the defects existing in the above related technologies, in the embodiments of the present application, a method, apparatus, electronic device, and storage medium for data compression storage are provided, aiming to reduce the impact of data compression on system performance.
[0083] In the embodiments of the present application, a method for data compression storage is provided. This method can be applied to an electronic device, and the present application does not limit the type of the electronic device. It can be any device type suitable for implementation, such as a terminal device and a server, etc. The present application will not elaborate on this.
[0084] The following combines Figure 1 , and describes the electronic device to which the present application is applied. Figure 1 It is a schematic diagram of the storage structure of an electronic device. Figure 1 Among them, it includes a host processor and a device memory. The host processor and the device memory can be different chips in the electronic device.
[0085] Among them, the host processor includes a first CPU, memory pages (page), meta-nodes (node), segments (segment), sub-meta-nodes (snode), and clusters (cluster). The cluster contains erasable physical blocks (Physical EraseBlock, PEB). The device memory includes a second CPU and logical units (Logical Unit Number, LUN).
[0086] Among them, page, node, segment, snode, cluster, PEB, and LUN can all be one or more. The PEB has a storage function and a management function. The storage function is to store the uncompressed original data written. The management function is that each PEB can manage at least one corresponding LUN. Different PEBs correspond to different LUNs. It should be noted that the LUN to which the original data stored in the PEB is written after compression can be the same as or different from the LUN corresponding to the PEB. The data storage capacity of the PEB and the total capacity of all the LUNs corresponding to the PEB can be the same or different. The data storage capacity of the PEB is usually larger than the size of the LUN for data compression. For example, the size of the PEB is 64k and the size of the LUN is 4k. For the convenience of management, a first-level space is formed based on each segment, and a second-level space is formed based on each cluster.
[0087] After the target data in the page is migrated to the segment, record the segment information of the target data migration in the node. For example, the identifier of the segment to which the target data is migrated, its offset address when writing to the segment, and the length of the target data, etc.
[0088] After writing the compressed data to the LUN, record the PEB corresponding to the LUN where the target data is compressed and written in the snode, as well as the cluster, offset address, and data compression length corresponding to the PEB.
[0089] The following combines Figure 1 and 2 to illustrate the method of data compression storage in the embodiments of the present application.
[0090] Figure 2 It is a flowchart of a method of data compression storage, and the specific implementation process of this method is as follows:
[0091] Step 200: Migrate the target data of the memory page to the segment through the host processor.
[0092] Optionally, the target data can be stored in one or more pages, and the data in each page can be written into one or more segments. That is, the target data is migrated to one or more segments.
[0093] Step 201: Migrate the target data in the segment to the cluster through the host processor.
[0094] In one implementation, when writing the target data in the segment to the PEB in the cluster, it is written in the size of the PEB. For example, if the size of the PEB is 64k and the target data in the segment is 200k, then the target data can be divided into four parts, that is, 200k = 64k + 64k + 64k + 8k, and then the target data can be written into 4 PEBs in the cluster in sequence.
[0095] In one implementation, when executing step 201, the host processor can adopt the following steps:
[0096] S2011: Determine whether there is a cluster that meets the set writing conditions in at least one cluster. If so, execute S2012, otherwise, execute S2013.
[0097] Specifically, when the first CPU receives a two - layer space writing request initiated by the segment, it determines whether there is a cluster that meets the set writing conditions in all clusters.
[0098] In one implementation, if it is determined that there is a cluster in the used state and the cluster in the used state contains free space that meets the set space condition, or if it is determined that there is a cluster in the idle state, then it is determined that there is a cluster that meets the set write condition; otherwise, it is determined that there is no cluster that meets the set write condition. Here, a cluster in the used state refers to a cluster where data is currently being written.
[0099] It should be noted that to ensure data continuity, among the clusters that meet the set write condition, the priority of the cluster in the used state is higher than that of the cluster in the idle state.
[0100] For example, the set space condition is non-zero. For another example, the set space condition is that the free space is greater than the size of the data currently being written. For another example, the set space condition is that the free space is greater than a specified space threshold. For another example, the set space condition is that the free space is greater than the sum of the size of the data currently being written and the size of the data currently requested to be written.
[0101] In practical applications, both the set write condition and the set space condition can be set according to the actual application scenario, and there is no limitation here.
[0102] S2012: Use the cluster that meets the set write condition as the target cluster and execute S2014.
[0103] In one implementation, if there is a cluster in the used state and the cluster in the used state contains free space that meets the set space condition, then use the cluster in the used state as the target cluster.
[0104] If there are a cluster in the used state and a cluster in the idle state, and the cluster in the used state does not contain free space that meets the set space condition, then select the cluster in the idle state as the target cluster.
[0105] If there is no cluster in the used state and there is a cluster in the idle state, then select the cluster in the idle state as the target cluster.
[0106] Among them, to ensure the continuity of the written data, when selecting an idle cluster as the target cluster, the following steps can be adopted: Determine the free capacity of the free space corresponding to each idle cluster, and use the cluster corresponding to the minimum free capacity as the target cluster.
[0107] Furthermore, the host processor can also set up a used list and a free list for the clusters. The used list is composed of clusters in the used state, and the free list is composed of clusters in the idle state.
[0108] The following combines Figure 3 to illustrate the list. Figure 3 It is an example diagram of a kind of list. Figure 3 In it, the host processor includes a used list and a free list. The gray area in the cluster is the used space, and the white area in the cluster is the free space. The clusters in the used list and the free list are sorted in ascending order according to the free capacity of the corresponding free space.
[0109] In one implementation, when executing S2012, any of the following methods can be adopted:
[0110] Method 1: If the used list contains clusters in the used state, and the clusters in the used state contain free space that meets the set space conditions, then use the clusters in the used state as the target clusters.
[0111] Method 2: If the used list does not contain clusters in the used state, or the clusters in the used state in the used list do not contain free space that meets the set space conditions, then select an idle cluster from the free list as the target cluster.
[0112] In this way, the target cluster can be selected from the used list or the free list.
[0113] S2013: When it is determined that there is a released cluster, use the released cluster as the target cluster.
[0114] S2014: Migrate the target data to the corresponding PEB in the target cluster; the cluster contains at least one PEB.
[0115] It should be noted that the PEBs in the target cluster are written with data in sequence. Therefore, if there is free space in the PEB that is written with data last, write data starting from this PEB; otherwise, write data starting from the next PEB of this PEB. The target data can be migrated to one or more PEBs.
[0116] Step 202: Send the target data in the cluster to the device memory through the host processor.
[0117] The following combines Figure 4 to illustrate data compression and migration. Figure 4 is a schematic diagram of data compression. Figure 4 It includes a host processor and a device memory. The host processor includes segments and clusters, and the cluster includes PEBs. The device memory includes LUNs. For example, the target data in the segment is migrated to the first PEB in the cluster. The target data in this PEB is sent to the device memory. After receiving the target data, the device memory compresses the target data and stores the obtained compressed data in the LUN.
[0118] In one implementation, when performing step 202, the following steps can be adopted:
[0119] S2021: Determine the target PEB according to the corresponding relationship between the PEB and the LUN, and the target data; the target PEB is determined according to the LUN where the target data is to be compressed and stored.
[0120] Specifically, the corresponding relationship between the PEB and the LUN can be set in advance, and the PEB can manage the corresponding LUNs.
[0121] For example, estimate the LUN where the target data is compressed and stored, and use the PEB corresponding to this LUN as the target PEB.
[0122] S2022: Determine the compressed data threshold of the target PEB according to the free space of the LUN corresponding to the target PEB.
[0123] For example, the target PEB corresponds to three LUNs. Among them, two LUNs are already full of data, and one LUN has not been written with any data. Then, use the capacity of this LUN as the compressed data threshold.
[0124] Among them, the compressed data threshold can change in real time.
[0125] S2023: Send a data compression storage request including the compressed data threshold to the device memory.
[0126] In one implementation, a data compression storage request is sent to the device memory through the PEB write protocol.
[0127] The following combines Figure 5 to describe the PEB write protocol. Figure 5 It is a schematic diagram of a PEB write protocol. Figure 5 The field LIMIT DATA LENGTH in it is the compressed data threshold. In the embodiments of the present application, Figure 5 It is only used to judge the space through LIMIT DATALENGTH, and whether other fields are clear does not affect the clarity of the present application.
[0128] This is because when the device memory compresses and stores data, the PEBs corresponding to the LUNs writing compressed data need to be in the same cluster. Therefore, if the target PEB is the last one in the cluster, the free space of the LUN corresponding to the target PEB may be insufficient. Therefore, sending the compressed data threshold to the device memory enables the device memory to judge whether there will be a problem of insufficient free space during this data compression storage according to the compressed data threshold.
[0129] S2024: When it is determined that an acknowledgment response returned by the device memory based on the data compression storage request is received, migrate the target data in the cluster to the LUN corresponding to the target PEB.
[0130] Furthermore, if an error response is received, the target PEB is updated and then data migration is performed. Specifically, the following steps can be adopted:
[0131] S20241: When it is determined that an error response returned by the device memory based on the data compression storage request is received, obtain the compressed write address included in the error response.
[0132] In one implementation, the device memory sends an error response to the host processor through the PEB response protocol. The host processor obtains the compressed write address included in the error response.
[0133] Among them, the compressed write address is the address of the LUN where the target data to be compressed is to be written determined by the device memory.
[0134] The following combines Figure 6 to describe the PEB response protocol. Figure 6 It is a schematic diagram of a PEB response protocol. Figure 6In it, the PEB response protocol includes the field WRITE LOGIC BLOCK ADDRESS, and may also include the following fields: WRITE LENGTH, ADDITIONAL SENSE CODE, and ADDITIONAL SENSE CODE QUALIFIER. Among them, WRITE LOGIC BLOCK ADDRESS can also be abbreviated as WLBA, representing the compressed write address. WRITE LENGTH can be abbreviated as WL, representing the data write length. ADDITIONAL SENSE CODE is abbreviated as ASC, and ADDITIONAL SENSE CODE QUALIFIER is abbreviated as ASCQ. Both ASC and ASCQ are error codes. The error code represents the error information returned based on the data write request. The data write length represents the compression length limit when the device memory determines data compression writing. In the embodiments of the present application, it is only used to Figure 6 perform compression judgment through the WRITE LOGIC BLOCK ADDRESS, WRITE LENGTH, ADDITIONAL SENSE CODE, and ADDITIONAL SENSE CODE QUALIFIER in Figure 6 Whether the other fields in are clear does not affect the clarity of the embodiments of the present application.
[0135] S20242: Update the target PEB to obtain the updated target PEB.
[0136] In one implementation, the host processor applies for a new cluster and uses the next PEB in the cluster as the updated target PEB.
[0137] S20243: Obtain the LUN address corresponding to the updated target PEB;
[0138] S20244: If the compressed write address is the same as the LUN address, migrate the target data in the cluster to the LUN corresponding to the updated PEB; otherwise, update the target PEB again and migrate the target data in the cluster to the LUN corresponding to the PEB after the second update.
[0139] Specifically, when updating the target PEB again, the following steps can be adopted: increment the updated PEB by one, that is, use the next PEB of the updated PEB as the PEB after the second update.
[0140] Step 203: Compress the target data through the device memory to obtain compressed data.
[0141] Step 204: Store the compressed data into the LUN through the device memory.
[0142] The following is combined with Figure 7 to illustrate the PEB update. Figure 7 It is a schematic diagram of a PEB update. Figure 7 In it, according to the free space of the LUN corresponding to the first PEB, the compressed data threshold is determined. Since the actual compressed length of the data to be written is greater than the compressed data threshold, the PEB is incremented by one to obtain the second PEB, and the data to be written is compressed and stored in the LUN managed by the second PEB data.
[0143] In one implementation, the implementation process of step 203 may further include the following steps:
[0144] S2031: Return the data compression length of the target data to the host processor through the device memory.
[0145] S2032: Record the target PEB and the data compression length for the target data through the host processor.
[0146] In one implementation, the cluster and offset value of the PEB corresponding to the LUN may also be recorded.
[0147] The following is combined with Figure 8 to illustrate the snode update. Figure 8 It is a schematic diagram of a snode update. Obtain the LUN where the target data is written after compression, and determine the PEB, cluster, offset value, and data compression length corresponding to the LUN, and store them in the snode.
[0148] The following is combined with Figure 9 to elaborate on the above embodiments in detail. Figure 9 It is a detailed flowchart of a data compression storage method, and the implementation process of this method includes:
[0149] Step 900: Migrate the target data of the memory page to the segment through the host processor.
[0150] Step 901: Determine whether there is a target cluster that meets the set write condition. If so, execute step 903; otherwise, execute step 902.
[0151] Step 902: Use the released cluster as the target cluster.
[0152] Step 903: Migrate the target data to the corresponding PEB in the target cluster.
[0153] Step 904: Send the target data in the PEB to the device memory through the host processor.
[0154] Step 905: Compress the target data through the device memory to obtain compressed data.
[0155] Step 906: Store the compressed data in the LUN through the device memory.
[0156] Step 907: Return the data compression length of the target data to the host processor through the device memory.
[0157] Step 908: Update the snode corresponding to the target data according to the target PEB and the data compression length through the host processor.
[0158] In the embodiments of the present application, through the host processor, the target data of the memory page is migrated to the segment; through the host processor, the target data in the segment is migrated to the cluster; through the host processor, the target data in the cluster is sent to the device memory; through the device memory, the target data is compressed to obtain compressed data; through the device memory, the compressed data is stored in the LUN. In this way, the operation of data compression processing is transferred from the host processor to the device memory, reducing the consumption of the CPU and memory of the host processor by data compression, and improving the system performance and user experience.
[0159] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for the user to choose to authorize or refuse.
[0160] Based on the same inventive concept, an apparatus for data compression storage is further provided in the embodiments of the present application. Since the principle of solving problems by the above apparatus and device is similar to that of a data compression storage method, the implementation of the above apparatus can refer to the implementation of the method, and the repeated parts will not be described again. The apparatus can be applied to electronic devices. The present application does not limit the type of electronic devices, and it can be any device type suitable for implementation, such as terminal devices and servers, etc., which will not be described again in the present application.
[0161] Refer to Figure 10 As shown, it is a structural block diagram of the apparatus for data compression storage in the embodiments of the present application. In some embodiments, the apparatus for data compression storage exemplified in the present application includes:
[0162] The first migration unit 1001 is configured to migrate the target data of the memory page to a segment through the host processor;
[0163] The second migration unit 1002 is configured to migrate the target data in the segment to a cluster through the host processor;
[0164] The sending unit 1003 is configured to send the target data in the cluster to the device memory through the host processor;
[0165] The compression unit 1004 is configured to compress the target data through the device memory to obtain compressed data;
[0166] The storage unit 1005 is configured to store the compressed data in a logical unit through the device memory.
[0167] In one implementation, there is at least one cluster, and the second migration unit 1002 is configured to:
[0168] Determine whether there is a cluster that meets the set writing condition among at least one cluster;
[0169] If so, use the cluster that meets the set writing condition as the target cluster; otherwise, when it is determined that there is a released cluster, use the released cluster as the target cluster;
[0170] Migrate the target data to the corresponding erasable physical block in the target cluster; the cluster contains at least one erasable physical block.
[0171] In one implementation, the second migration unit 1002 is configured to:
[0172] If it is determined that there is a cluster in the used state and the used state cluster contains free space that meets the set space condition, or if it is determined that there is a cluster in the idle state, it is determined that there is a cluster that meets the set writing condition;
[0173] Otherwise, it is determined that there is no cluster that meets the set writing condition.
[0174] In one implementation, the sending unit 1003 is configured to:
[0175] According to the correspondence between the erasable physical block and the logical unit, and the target data, determine the target erasable physical block; the target erasable physical block is determined according to the logical unit where the target data is to be compressed and stored;
[0176] According to the free space of the logical unit corresponding to the target erasable physical block, determine the compression data threshold of the target erasable physical block;
[0177] Send a data compression storage request including the compression data threshold to the device memory;
[0178] When it is determined that an acknowledgment response returned by the device memory based on the data compression storage request is received, migrate the target data in the cluster to the logical unit corresponding to the target erasable physical block.
[0179] In one implementation, the sending unit 1003 is further configured to:
[0180] When it is determined that an error response returned by the device memory based on the data compression storage request is received, obtain the compression write address included in the error response;
[0181] Update the target erasable physical block to obtain an updated target erasable physical block;
[0182] Obtain the logical unit address corresponding to the updated target erasable physical block;
[0183] If the compression write address is the same as the logical unit address, migrate the target data in the cluster to the logical unit corresponding to the updated erasable physical block;
[0184] Otherwise, update the target erasable physical block again, and migrate the target data in the cluster to the logical unit corresponding to the erasable physical block after the second update.
[0185] In one implementation, the storage unit 1005 is further configured to:
[0186] Return the data compression length of the target data to the host processor through the device memory;
[0187] Record the target erasable physical block and the data compression length for the target data through the host processor.
[0188] The method for data compression storage in the embodiments of the present application includes migrating the target data of the memory page to the segment through the host processor; migrating the target data in the segment to the cluster through the host processor; sending the target data in the cluster to the device memory through the host processor; compressing the target data by the device memory to obtain compressed data; and storing the compressed data in the logical unit by the device memory. In this way, the operation of data compression processing is transferred from the host processor to the device memory, reducing the resource consumption of the data compression on the host processor and the impact on the system performance.
[0189] In the embodiments of the present application, an electronic device is provided, including:
[0190] A processor; and
[0191] A memory storing computer instructions for causing the processor to execute the method according to any of the above implementations.
[0192] In an embodiment of the present application, a storage medium is provided, storing computer instructions for causing a computer to execute the method according to any of the above embodiments. Figure 11 FIG. shows a schematic structural diagram of an electronic device 1100. Refer to Figure 11 As shown, the electronic device 1100 includes: a processor 1110 and a memory 1120. Optionally, it may further include a power supply 1130, a display unit 1140, and an input unit 1150.
[0193] The processor 1110 is the control center of the electronic device 1100, connecting various components through various interfaces and lines, and executing various functions of the electronic device 1100 by running or executing software programs and / or data stored in the memory 1120, so as to perform overall monitoring of the electronic device 1100.
[0194] In an embodiment of the present application, when the processor 1110 calls the computer program stored in the memory 1120, it executes each step in the above embodiment.
[0195] Optionally, the processor 1110 may include one or more processing units; preferably, the processor 1110 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, applications, etc., and the modem processor mainly processes wireless communication. It can be understood that the above modem processor may not be integrated into the processor 1110. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be separately implemented on independent chips.
[0196] The memory 1120 may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system, various applications, etc.; the data storage area may store data created according to the use of the electronic device 1100, etc. In addition, the memory 1120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices, etc.
[0197] The electronic device 1100 further includes a power supply 1130 (such as a battery) for supplying power to each component. The power supply may be logically connected to the processor 1110 through a power management system, so as to manage functions such as charging, discharging, and power consumption through the power management system.
[0198] The display unit 1140 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device 1100, etc. In the embodiments of the present application, it is mainly used to display the display interfaces of various applications in the electronic device 1100 and objects such as text and pictures displayed in the display interfaces. The display unit 1140 may include a display panel 1141. The display panel 1141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
[0199] The input unit 1150 can be used to receive information such as numbers or characters input by the user. The input unit 1150 may include a touch panel 1151 and other input devices 1152. Among them, the touch panel 1151, also known as a touch screen, can collect touch operations of the user on or near it (such as operations of the user using any suitable object or accessory such as a finger or a stylus on the touch panel 1151 or near the touch panel 1151).
[0200] Specifically, the touch panel 1151 can detect the touch operation of the user, detect the signals brought by the touch operation, convert these signals into contact coordinates, send them to the processor 1110, and receive and execute the commands sent by the processor 1110. In addition, the touch panel 1151 can be implemented in multiple types such as resistive, capacitive, infrared, and surface acoustic wave. The other input devices 1152 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, etc.
[0201] Of course, the touch panel 1151 can cover the display panel 1141. After the touch panel 1151 detects a touch operation on or near it, it transmits it to the processor 1110 to determine the type of touch event. Subsequently, the processor 1110 provides a corresponding visual output on the display panel 1141 according to the type of touch event. Although in Figure 11 the touch panel 1151 and the display panel 1141 are implemented as two independent components to realize the input and output functions of the electronic device 1100, in some embodiments, the touch panel 1151 and the display panel 1141 can be integrated to realize the input and output functions of the electronic device 1100.
[0202] The electronic device 1100 may also include one or more sensors, such as a pressure sensor, a gravitational acceleration sensor, a proximity light sensor, etc. Of course, according to the needs in specific applications, the above-mentioned electronic device 1100 may also include other components such as a camera. Since these components are not the key components used in the embodiments of the present application, therefore, in Figure 11It is not shown in [the figure] and will not be elaborated further.
[0203] Those skilled in the art can understand that Figure 11 [The figure] is only an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than shown in the figure, or combine certain components, or different components.
[0204] For the convenience of description, the above parts are divided into various modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0205] Obviously, the above embodiments are only examples given for clear illustration and not limitations on the embodiments. For those of ordinary skill in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. And the obvious changes or modifications derived therefrom are still within the protection scope of this application.
Claims
1. A method for data compression storage, characterized in that: Applied to an electronic device, the electronic device includes a host processor and a device memory, the host processor includes memory pages, segments, and clusters, and the device memory includes logic units, the method comprising: Migrating, by the host processor, target data of the memory page to the segment; Migrating the target data in the segment to the cluster by the host processor; sending, by the host processor, the target data in the cluster to the device memory; compressing the target data through the device memory to obtain compressed data; The compressed data is stored in the logic unit via the device memory.
2. The method according to claim 1, characterized in that There is at least one cluster, and migrating the target data in the segment to the cluster includes: Determining whether there is a cluster in at least one cluster that meets the set write condition; If yes, the cluster that meets the set write condition is used as the target cluster; otherwise, when it is determined that there is a released cluster, the released cluster is used as the target cluster; The target data is migrated to a corresponding erasable physical block in the target cluster; the cluster includes at least one erasable physical block.
3. The method according to claim 2, characterized in that The determining whether there is a cluster in the at least one cluster that meets the set write condition includes: If it is determined that there is a cluster in use and the cluster in use contains free space that meets the set space condition, or if it is determined that there is a cluster in free state, then it is determined that there is a cluster that meets the set write condition; Otherwise, it is determined that there is no cluster that meets the set write condition.
4. The method according to claim 2 or 3, characterized in that The sending the target data in the cluster to the device memory includes: Determining a target erasable physical block according to the correspondence between the erasable physical block and the logical unit, and the target data; the target erasable physical block is determined according to the logical unit where the target data is to be compressed and stored; determining a compression data threshold of the target erasable physical block according to a free space of a logical unit corresponding to the target erasable physical block; sending a data compression storage request including the compressed data threshold to the device memory; When it is determined that a confirmation response returned by the device memory based on the data compression storage request is received, the target data in the cluster is migrated to a logical unit corresponding to the target erasable physical block.
5. The method according to claim 4, characterized in that The method further comprises: When determining that an error response returned by the device memory based on the data compression storage request is received, obtaining a compression write address included in the error response; Updating the target erasable physical block to obtain an updated target erasable physical block; Obtaining a logical unit address corresponding to the updated target erasable physical block; If the compressed write address is consistent with the logical unit address, migrating the target data in the cluster to the logical unit corresponding to the updated erasable physical block; Otherwise, the target erasable physical block is updated again, and the target data in the cluster is migrated to the logical unit corresponding to the updated erasable physical block.
6. The method according to claim 5, characterized in that After storing the compressed data in the logic unit, the method further includes: returning the data compression length of the target data to the host processor via the device memory; The host processor records the target erasable physical block and the data compression length for the target data.
7. A device for data compression storage, characterized in that: Applied to an electronic device, the electronic device includes a host processor and a device memory, the host processor includes memory pages, segments, and clusters, the device memory includes logic units, and the apparatus includes: a first migration unit, configured to migrate target data of the memory page to the segment via the host processor; a second migration unit, configured to migrate the target data in the segment to the cluster via the host processor; a sending unit, configured to send the target data in the cluster to the device memory via the host processor; a compression unit, configured to compress the target data through the device memory to obtain compressed data; A storage unit is configured to store the compressed data in the logic unit via the device memory.
8. An electronic device, characterized in that: include: processor; as well as A memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: Computer instructions are stored, and the computer instructions are used to make a computer execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for processing data, storage apparatus, solid state disk and storage system
CN109690681A
Memory system and method of operating the same
CN111752468A
System and method for configuration and management of flash memory
US20070038802A1
Storage device that compresses data received from a host before writing therein
US20180088811A1
Efficient compression of data in storage systems through offloading computation to storage devices
US20200133545A1