Space recovery method and device, storage medium and electronic equipment
By dynamically adjusting the reserved space size of the storage space in the host and storing effective data through reserved space when the space recovery conditions are met, the problems of low storage space utilization and data space wear in the prior art are solved, achieving more efficient storage space management and extending the usage time of the storage chip.
Patent Information
- Application Number
- CN202311346799.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, the data space and reserved space of the memory chip are of a fixed value, resulting in a low space utilization rate of the storage space or a limitation on the host's IOPS. The data space recycling operation occupies a large amount of background bandwidth, increasing wear of the data space.
The host dynamically adjusts the size of the reserved space based on the data update rate of the target storage space within the first preset time period, divides the storage space into data space and reserved space, and when the space recovery conditions are met, the effective data in the data space is stored through the reserved space to realize space recycling.
On the premise of reducing IOPS restrictions on the host, the space utilization of storage space is improved, the wear of data space is reduced, the usage time of memory chips is extended, and the efficiency of space recycling is improved.
Smart Images

Figure CN119847411A_ABST
Abstract
Description
Technical Field
[0001] The technical solution disclosed herein relates to the field of computer technology, and in particular to a space recovery method and device, a storage medium, and an electronic device. Background Art
[0002] In the related technical solution, the storage space of the memory chip consists of the data space and the reserved space, and all data are mixed and stored in the data space. When it is determined that the recycling conditions for recycling the data space are met, the memory chip needs to first move the valid data stored in the data space to the reserved space, and then erase the data in the data space, so as to realize the recycling of the data space.
[0003] In this solution, the size of the data space and the reserved space are fixed values. If the reserved space is set to a large value, the space utilization of the storage space will be low. If the reserved space is set to a small value, it may limit the IOPS (Input / Output Operations Per Second) of the host. Summary of the invention
[0004] In view of this, embodiments of the present disclosure provide a space recovery method and device, a storage medium, and an electronic device.
[0005] According to a first aspect of the present disclosure, a space recovery method is proposed, the method comprising:
[0006] For a target storage space of a storage chip in the terminal device, determining a size of a reserved space in the target storage space based on a data update rate of the target storage space within a first preset time period;
[0007] Based on the determined size of the reserved space, dividing the target storage space into a data space and a reserved space;
[0008] The data space is used to store the data written into the target storage space;
[0009] In response to meeting a space reclamation condition, a space reclamation operation on the data space is performed; wherein, when performing the space reclamation operation, valid data in the data space is stored through the reserved space.
[0010] In combination with any implementation manner provided in the present disclosure, the size of the reserved space is positively correlated with the data update rate of the target storage space within the first preset time period.
[0011] In combination with any embodiment provided by the present disclosure, before determining the size of the reserved space in the target storage space for the storage chip in the terminal device based on the data update rate of the target storage space within the first preset time period, the method further includes:
[0012] When the terminal device is started for the first time, the storage chip is divided into a plurality of storage spaces based on a partitioning protocol;
[0013] Based on the partitioning protocol, different reserved spaces are divided for each of the storage spaces; for different storage spaces, the larger the reserved space divided, the faster the data update rate of the data stored in the storage space;
[0014] The divided storage space with the reserved space of 0 is determined as the target storage space; the reserved space of 0 indicates that the reserved space of the target storage space is to be configured.
[0015] In combination with any implementation manner provided in the present disclosure, the data space includes a plurality of data subspaces;
[0016] In response to the space reclamation condition being met, performing a space reclamation operation on the data space includes:
[0017] For each of the data subspaces, calculating the effective data ratio of the data stored in the data subspace; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace;
[0018] If the valid data ratio of a target data subspace among the multiple data subspaces is less than or equal to a preset first threshold, a space recovery operation is performed on the target data subspace.
[0019] In combination with any implementation manner provided in the present disclosure, in response to reaching a space reclamation condition, performing a space reclamation operation on the data space includes:
[0020] In response to determining that the number of input / output operations per second (IOPS) of the host of the terminal device within a second preset time period is less than or equal to a preset second threshold, a space recovery operation on the data space is performed.
[0021] In combination with any implementation manner provided in the present disclosure, the data space includes a plurality of data subspaces;
[0022] In response to the space reclamation condition being met, performing a space reclamation operation on the data space includes:
[0023] Calculating the space utilization rate of the data space; wherein the space utilization rate is used to represent the ratio of the used space to the total space in the data space;
[0024] For each of the data subspaces, calculating the effective data ratio of the data stored in the data subspace; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace;
[0025] When it is determined that the space utilization rate is greater than or equal to the target space utilization rate, a space recovery operation is performed on the data subspace whose effective data ratio is less than or equal to the target effective data ratio; wherein the target effective data ratio is positively correlated with the target space utilization rate.
[0026] In combination with any embodiment provided in the present disclosure, when the number of data subspaces whose effective data ratio is less than or equal to the target effective data ratio is multiple, performing a space recovery operation on the data subspaces whose effective data ratio is less than or equal to the target effective data ratio includes:
[0027] In order of the effective data ratio from small to large, space recovery operations are sequentially performed on a plurality of data subspaces whose effective data ratio is less than or equal to the target effective data ratio. 。
[0028] According to a second aspect of the present disclosure, a space recovery device is provided, the device comprising:
[0029] A reserved space determination module, configured to determine, for a target storage space of a storage chip in the terminal device, a size of a reserved space in the target storage space based on a data update rate of the target storage space within a first preset time period;
[0030] A first partitioning module, configured to partition the target storage space into a data space and a reserved space based on the determined size of the reserved space;
[0031] A storage module, used for storing the data written into the target storage space through the data space;
[0032] A recycling module is used to execute a space recycling operation on the data space in response to meeting a space recycling condition; wherein, when executing the space recycling operation, valid data in the data space is stored through the reserved space.
[0033] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, wherein the machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the processor is prompted to implement the space recovery method of any embodiment of the present disclosure.
[0034] According to a fourth aspect of the present disclosure, there is provided an electronic device, comprising:
[0035] processor;
[0036] a memory for storing processor-executable instructions;
[0037] The processor is configured to execute the space recovery method of any embodiment of the present disclosure.
[0038] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0039] In the space recovery method and device, storage medium and electronic device provided by the embodiments of the present disclosure, the host can determine the size of the reserved space in the target storage space based on the data update rate of the target storage space of the storage chip within the first preset time period, and divide the target storage space into data space and reserved space based on the size of the reserved space. The host dynamically adjusts the size of the reserved space of the target storage space based on the data update rate of the target storage space within the first preset time period, which can improve the space utilization of the storage space while reducing the restriction on the IOPS of the host.
[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0042] Figure 1 is a flow chart of a space recovery method according to an exemplary embodiment of the present disclosure;
[0043] Figure 2 is a flow chart of another space recovery method according to an exemplary embodiment of the present disclosure;
[0044] Figure 3 is a flow chart of another space recovery method according to an exemplary embodiment of the present disclosure;
[0045] Figure 4 is a flow chart of another space recovery method according to an exemplary embodiment of the present disclosure;
[0046] Figure 5 is a structural schematic diagram of a space recovery device according to an exemplary embodiment of the present disclosure;
[0047] Figure 6It is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0048] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0049] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0050] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0051] In the related technical solution, the storage space of the storage chip of the terminal device consists of a data space and a reserved space, and all types of data are mixed and stored in the data space. When it is determined that the recycling conditions for recycling the data space are met, the storage chip needs to first move all valid data stored in the data space to the reserved space, and then erase the data stored in the entire data space, so as to realize the recycling of the data space.
[0052] In this solution, the storage chip controls the space recovery. The size of the data space and reserved space of the storage chip are both fixed values. If the reserved space is set to a large value, the space utilization rate of the storage space will be low. If the reserved space is set to a small value, it may limit the IOPS of the host. In addition, in this solution, after the recovery conditions for reclaiming the data space are met, all valid data stored in the entire data space need to be moved, which will occupy a large amount of background bandwidth. The method of erasing all the data stored in the entire data space will also accelerate the wear of the data space and shorten the use time of the data space.
[0053] In view of this, the present disclosure provides a space recovery method. In the method, the space recovery can be controlled by the host of the terminal device. Specifically, the host can dynamically adjust the size of the reserved space in the storage space based on the data update rate of the storage space within a preset time period, thereby improving the space utilization of the storage space while reducing the IOPS restriction on the host. In addition, with respect to space recovery, the present disclosure also proposes a variety of specific executable space recovery schemes in order to reduce the wear and tear on the data space and the impact on the terminal performance.
[0054] The space recovery method of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0055] Figure 1 is a flow chart of a space recovery method according to an exemplary embodiment of the present disclosure. The method can be executed by a host of a terminal device, such as Figure 1 As shown, the exemplary embodiment method may include the following steps:
[0056] In step 101, for a target storage space of a storage chip in the terminal device, the size of a reserved space in the target storage space is determined based on a data update rate of the target storage space within a first preset time period.
[0057] In this example, the entire storage space of the storage chip of the terminal device may be determined as the target storage space. Alternatively, the host may divide the entire storage space of the storage chip into multiple storage spaces and then determine one or two of the storage spaces as the target storage space, which is not limited in the present disclosure. For the convenience of description, the following embodiments are described by taking the example of dividing the entire storage space of the storage chip into multiple storage spaces and then determining one of the storage spaces as the target storage space.
[0058] The data update rate can be characterized by IOPS. In this example, the host can determine the size of the reserved space based on the IOPS of the target storage space within the first preset time period. Exemplarily, the host can determine the size of the reserved space in the target storage space based on the IOPS of the target storage space within the first preset time period, such as 1 second.
[0059] When the reserved space is large, the host will not limit the IOPS of the host because it detects that there is still a large amount of free storage space in the target storage space. When the reserved space is small, the host may limit the IOPS of the host because it detects that the free storage space in the target storage space is relatively small, affecting the performance of the host.
[0060] Therefore, the size of the determined reserved space may be positively correlated with the IOPS of the target storage space in the first preset time period. In other words, when the IOPS of the target storage space in the first preset time period is larger, the determined reserved space should be larger, thereby reducing the IOPS restriction on the host. When the IOPS of the target storage space in the first preset time period is smaller, the determined reserved space should be smaller, thereby increasing the utilization rate of the storage space.
[0061] Optionally, the storage chip may be a UFS (Universal Flash Storage) chip.
[0062] In step 102, based on the determined size of the reserved space, the target storage space is divided into a data space and a reserved space.
[0063] After determining the size of the reserved space in the target storage space based on the IOPS of the target storage space in the first preset time period, the host may divide the target storage space into a data space and a reserved space based on the determined size of the reserved space.
[0064] In step 103, the data written into the target storage space is stored through the data space.
[0065] The host can store the data written into the target storage space in the divided data space.
[0066] In step 104, in response to a space reclamation condition being met, a space reclamation operation on the data space is performed.
[0067] The host may perform a space recovery operation on the data space when determining that a space recovery condition for recovering the data space is met. When performing the space recovery operation, valid data in the data space may be first moved to the reserved space, and then the data in the data space may be erased, thereby recovering the data space.
[0068] The aforementioned space recovery conditions will be described in detail in the subsequent embodiments and will not be repeated here.
[0069] In the space recovery method provided by the embodiment of the present disclosure, the host can dynamically adjust the size of the reserved space in the target storage space based on the data update rate of the target storage space within a first preset time period, thereby improving the space utilization of the storage space while reducing the IOPS restrictions on the host.
[0070] In one embodiment, if Figure 2As shown, the host of the terminal device can determine the target storage space based on the following steps:
[0071] In step 201, when the terminal device is started for the first time, the storage chip is divided into a plurality of storage spaces based on a partitioning protocol.
[0072] Exemplarily, the partition protocol may include the following contents:
[0073] Table 1
[0074] Is the function enabled? yes Identifier Storage Space 1 Maximum transmission bandwidth a Capacity Information X Space wear level (0-5) 5
[0075] When the function is enabled, Table 1 takes effect, and the host can partition the storage chip based on Table 1. As shown in Table 1, the maximum transmission bandwidth of storage space 1 is a, the capacity is X, and the space wear level is 5. From 0 to 5, the space wear level increases, and the size of the corresponding reserved space also increases.
[0076] Table 2
[0077] Is the function enabled? yes Identifier Storage Space 2 Maximum transmission bandwidth a Capacity Information X Space wear level (0-5) 2
[0078] As can be seen from Table 2 above, Table 2 is also effective, and the host can partition the storage chip based on Table 2. As can be seen from Table 2 above, the maximum transmission bandwidth of storage space 2 is a, the capacity is X, and the space wear level is 2, which is smaller than the space wear level of storage space 1. Correspondingly, the reserved space of storage space 2 is also smaller than the reserved space of storage space 1.
[0079] Table 3
[0080] Is the function enabled? yes Identifier Storage Space 3 Maximum transmission bandwidth a Capacity Information X Space wear level (0-5) 0
[0081] As can be seen from Table 3 above, Table 3 is also effective, and the host can partition the storage chip based on Table 3. As can be seen from Table 3 above, the maximum transmission bandwidth of storage space 3 is a, the capacity is X, and the space wear level is 0, that is, the reserved space of this area is temporarily divided into 0.
[0082] In combination with the three tables included in the aforementioned partitioning protocol, when the terminal device is started for the first time, the host of the terminal device can divide the storage chip into three storage spaces.
[0083] The aforementioned description of dividing the storage chip into three storage spaces based on the partition protocol and the contents of the three tables contained in the partition protocol is merely illustrative, and is intended to enable those skilled in the art to better understand the technical solution of the embodiment of the present disclosure. In practical applications, the number of storage spaces divided based on the partition protocol can also be 2, 4, etc., the partition protocol can also include other contents, and the partition protocol can also be displayed in other forms, which is not limited by the present disclosure. As long as it is satisfied, the host can divide the storage chip into multiple storage spaces based on the partition protocol.
[0084] In step 202, different reserved spaces are divided for each of the storage spaces based on the partition protocol.
[0085] In this example, the correspondence between the space wear level and the reserved space can be obtained in advance. For example, it can be shown in the following Table 4:
[0086] Table 4
[0087] Space wear level Reserve space 0 0 1 10 2 20 3 30 4 40 5 50
[0088] The host of the terminal device can allocate 50 reserved space for storage space 1 and 20 reserved space for storage space 2 based on the aforementioned partitioning protocol and the pre-acquired correspondence between the above-mentioned space wear level and the reserved space, and temporarily not allocate reserved space for storage space 3.
[0089] For different storage spaces, the larger the reserved space is, the faster the data update rate of the data stored in the storage space is. In other words, the data update rate of the data stored in the aforementioned storage space 1 is the fastest, the data update rate of the data stored in the storage space 2 is the second fastest, and the data update rate of the data stored in the storage space 3 is the slowest.
[0090] In combination with the foregoing, using a storage space with a larger reserved space to store data with a faster data update rate can reduce the IOPS restriction on the host, while using a storage space with a smaller reserved space to store data with a slower data update rate can improve the space utilization of the storage space.
[0091] In step 203, the divided storage space with the reserved space of 0 is determined as the target storage space.
[0092] The reserved space being 0 indicates that the reserved space of the target storage space is to be configured.
[0093] After determining the target storage space, the host can determine the size of the reserved space in the target storage space based on the data update rate of the target storage space within the first preset time period. Then, based on the determined size of the reserved space, the target storage space is divided into a data space and a reserved space. And based on the reserved space, a space recovery operation is performed on the data space.
[0094] In the space recovery method provided by the embodiment of the present disclosure, the host can divide the storage chip into multiple storage spaces based on the partition protocol, and divide different reserved spaces for each of the storage spaces based on the partition protocol. Then, the storage space with a larger reserved space is used to store data with a faster data update rate, thereby reducing the IOPS restriction on the host, and the storage space with a smaller reserved space is used to store data with a slower data update rate, thereby improving the space utilization of the storage space.
[0095] In one embodiment, when a space reclamation condition is met and a space reclamation operation is performed on the data space, the host may perform the operation based on the following scheme:
[0096] Option 1:
[0097] like Figure 3 As shown, it can be performed based on the following steps:
[0098] In step 301, the data space is divided into a plurality of data subspaces.
[0099] In step 302, for each of the data subspaces, the effective data ratio of the data stored in the data subspace is calculated.
[0100] The effective data ratio is used to represent the ratio of effective data to total data in the data stored in the data subspace.
[0101] In step 303, if the valid data ratio of a target data subspace among the multiple data subspaces is less than or equal to a preset first threshold, a space recovery operation is performed on the target data subspace.
[0102] The preset first threshold may be 70%, for example. When the valid data ratio of a data subspace is less than or equal to 70%, the data subspace may be determined as a target data subspace, and a space recovery operation may be performed on the target data subspace.
[0103] In an optional example, the host can create three linked lists, namely, a free linked list, a used linked list, and a to-be-reclaimed linked list. Among them, the free linked list is used to store unused data subspaces, the used linked list is used to store used data subspaces whose effective data ratio of the stored data is greater than 70%, and the to-be-reclaimed linked list is used to store used data subspaces whose effective data ratio of the stored data is less than or equal to 70%. The host can detect the effective data ratio of the data stored in each data subspace in real time, and adjust the linked list stored in each data subspace in real time based on the detected effective data ratio.
[0104] In this example, the host may pre-set that the data subspace in the to-be-reclaimed linked list is periodically reclaimed at intervals of a preset time period.
[0105] In the space recovery method provided by the embodiment of the present disclosure, the host can divide the data space of the target storage space into multiple data subspaces. Then, for each of the data subspaces, calculate the effective data ratio of the data stored in the data subspace. If the effective data ratio of the target data subspace in the multiple data subspaces is less than or equal to a preset first threshold, perform a space recovery operation on the target data subspace. Compared to the existing implementation, each time the space recovery condition is met, the recovery operation is performed on the entire data space in this example only for the data subspace where the effective data ratio of the stored data is lower than the preset first threshold, which can reduce the wear on the data space, extend the use time of the storage chip, and at the same time, improve the efficiency of space recovery.
[0106] Option 2:
[0107] The host may perform a space recovery operation on the data space when determining that the IOPS of the host of the terminal device is less than or equal to a preset second threshold within a second preset time period.
[0108] The second preset time period may be, for example, 4 seconds, 5 seconds, etc., which is not limited in the present disclosure.
[0109] When the host performs space reclamation operations, it needs to occupy a certain amount of bandwidth, which will affect the bandwidth occupied by other system processes.
[0110] In this example, when it is determined that the IOPS of the host within the second preset time period is less than or equal to the preset second threshold, it can be determined that the host of the terminal device is currently in an idle state. At this time, performing a space recovery operation on the data space can reduce the impact on system performance.
[0111] Option 3:
[0112] like Figure 4 As shown, it can be performed based on the following steps:
[0113] In step 401, the data space is divided into a plurality of data subspaces.
[0114] In step 402, the space usage rate of the data space is calculated.
[0115] The space utilization rate is used to represent the ratio of the used space to the total space in the data space.
[0116] In step 403, for each of the data subspaces, the effective data ratio of the data stored in the data subspace is calculated.
[0117] The effective data ratio is used to represent the ratio of effective data to total data in the data stored in the data subspace.
[0118] In step 404, when it is determined that the space usage rate is greater than or equal to the target space usage rate, a space reclamation operation is performed on the data subspace whose valid data ratio is less than or equal to the target valid data ratio.
[0119] Among them, the target effective data ratio is positively correlated with the target space utilization rate.
[0120] Since frequent space reclamation operations on data space will cause greater wear and tear on the storage chip, in this example, when the space usage rate is low, space reclamation operations can be performed only on data subspaces with relatively small valid data. When the space usage rate is high, it means that the remaining data space is small and more space needs to be reclaimed. At this time, the valid data ratio of the reclaimed data subspace can be appropriately increased.
[0121] For example, when it is determined that the space utilization rate is greater than or equal to 60%, a space recovery operation can be performed on a data subspace with a valid data ratio of less than or equal to 40%. When it is determined that the space utilization rate is greater than or equal to 90%, a space recovery operation can be performed on a data subspace with a valid data ratio of less than or equal to 80%, thereby recovering more data space.
[0122] In one embodiment, when the number of data subspaces whose effective data ratio is less than or equal to the target effective data ratio is multiple, the space recovery operation of the multiple data subspaces whose effective data ratio is less than or equal to the target effective data ratio can be performed in order from small to large. 。
[0123] For example, the target effective data ratio is 80%, and there are three data subspaces whose effective data ratios are less than or equal to 80%, and their corresponding effective data ratios are 78%, 68%, and 60%, respectively. When executing the space recovery operation on these three data subspaces, the space recovery operation on the data subspace with an effective data ratio of 60% can be executed first, and then the space recovery operation on the data subspace with an effective data ratio of 68% can be executed, and finally the space recovery operation on the data subspace with an effective data ratio of 78% can be executed.
[0124] Since the smaller the effective data ratio is, the less effective data is stored in the data subspace, and when performing space reclamation operations, less data needs to be moved to the reserved space. Therefore, giving priority to performing space reclamation operations on data subspaces with smaller effective data can speed up the reclamation process.
[0125] For the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described order of actions, because according to the present disclosure, certain steps can be performed in other orders or simultaneously.
[0126] Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0127] Corresponding to the aforementioned application function implementation method embodiment, the present disclosure also provides an application function implementation device and a corresponding terminal embodiment.
[0128] Figure 5 is a schematic structural diagram of a space recovery device according to an exemplary embodiment of the present disclosure. Figure 5 As shown, the space recovery device may include:
[0129] The reserved space determination module 51 is used to determine the size of the reserved space in the target storage space of the storage chip in the terminal device based on the data update rate of the target storage space within a first preset time period.
[0130] The first partitioning module 52 is configured to partition the target storage space into a data space and a reserved space based on the determined size of the reserved space.
[0131] The storage module 53 is used to store the data written into the target storage space through the data space.
[0132] The recycling module 54 is used to execute a space recycling operation on the data space in response to the space recycling condition being met; wherein, when executing the space recycling operation, valid data in the data space is stored through the reserved space.
[0133] Optionally, the size of the reserved space is positively correlated with a data update rate of the target storage space within the first preset time period.
[0134] Optional, in Figure 5 Based on the modules shown, the space recovery device may further include:
[0135] The second partitioning module is used to partition the storage chip into multiple storage spaces based on a partitioning protocol when the terminal device is started for the first time.
[0136] The third partitioning module is used to divide different reserved spaces into each of the storage spaces based on the partitioning protocol; for different storage spaces, the larger the reserved space divided, the faster the data update rate of the data stored in the storage space.
[0137] The target storage space determination module is used to determine the divided storage space with the reserved space of 0 as the target storage space; the reserved space of 0 indicates that the reserved space of the target storage space is to be configured.
[0138] Optionally, the data space includes multiple data subspaces.
[0139] The recycling module 54, when used to execute a space recycling operation on the data space in response to reaching a space recycling condition, includes:
[0140] For each of the data subspaces, the effective data ratio of the data stored in the data subspace is calculated; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace.
[0141] If the valid data ratio of a target data subspace among the multiple data subspaces is less than or equal to a preset first threshold, a space recovery operation is performed on the target data subspace.
[0142] Optionally, the recycling module 54, when used to execute a space recycling operation on the data space in response to meeting a space recycling condition, includes:
[0143] In response to determining that the number of input / output operations per second (IOPS) of the host of the terminal device within a second preset time period is less than or equal to a preset second threshold, a space recovery operation on the data space is performed.
[0144] Optionally, the data space includes multiple data subspaces.
[0145] The recycling module 54, when used to execute a space recycling operation on the data space in response to reaching a space recycling condition, includes:
[0146] Calculate the space utilization rate of the data space; wherein the space utilization rate is used to represent the ratio of the used space to the total space in the data space.
[0147] For each of the data subspaces, the effective data ratio of the data stored in the data subspace is calculated; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace.
[0148] When it is determined that the space utilization rate is greater than or equal to the target space utilization rate, a space recovery operation is performed on the data subspace whose effective data ratio is less than or equal to the target effective data ratio; wherein the target effective data ratio is positively correlated with the target space utilization rate.
[0149] Optionally, when there are multiple data subspaces whose effective data ratio is less than or equal to the target effective data ratio, the recycling module 54, when used to perform a space recycling operation on the data subspace whose effective data ratio is less than or equal to the target effective data ratio, includes:
[0150] In order of the effective data ratio from small to large, space recovery operations are sequentially performed on a plurality of data subspaces whose effective data ratio is less than or equal to the target effective data ratio. 。
[0151] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art may understand and implement it without creative work.
[0152] Figure 6 1 is a schematic diagram of the structure of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a user device, and may specifically be a mobile phone, a computer, a digital broadcast terminal, a tablet device, a personal digital assistant, a wearable device such as a smart watch, a smart bracelet, etc.
[0153] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0154] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0155] The memory 604 is configured to store various types of data to support operations on the device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0156] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0157] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0158] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0159] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0160] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0161] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 4G or 5G, 4G LTE, 5G NR or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0162] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0163] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory 604 including instructions, which, when executed by a processor 620 of an electronic device 600, enables the electronic device 600 to perform a space reclamation method, the method comprising:
[0164] For a target storage space of a storage chip in the terminal device, a size of a reserved space in the target storage space is determined based on a data update rate of the target storage space within a first preset time period.
[0165] Based on the determined size of the reserved space, the target storage space is divided into a data space and a reserved space.
[0166] The data written into the target storage space is stored through the data space.
[0167] In response to meeting a space reclamation condition, a space reclamation operation on the data space is performed; wherein, when performing the space reclamation operation, valid data in the data space is stored through the reserved space.
[0168] The non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0169] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0170] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A space recovery method, characterized in that: The method is executed by a host of a terminal device, and the method includes: For a target storage space of a storage chip in the terminal device, determining a size of a reserved space in the target storage space based on a data update rate of the target storage space within a first preset time period; Based on the determined size of the reserved space, dividing the target storage space into a data space and a reserved space; The data space is used to store the data written into the target storage space; In response to meeting a space reclamation condition, a space reclamation operation on the data space is performed; wherein, when performing the space reclamation operation, valid data in the data space is stored through the reserved space.
2. The method according to claim 1, characterized in that The size of the reserved space is positively correlated with a data update rate of the target storage space within the first preset time period.
3. The method according to claim 1, characterized in that Before determining the size of the reserved space in the target storage space for the storage chip in the terminal device based on the data update rate of the target storage space within a first preset time period, the method further includes: When the terminal device is started for the first time, the storage chip is divided into a plurality of storage spaces based on a partitioning protocol; Based on the partitioning protocol, different reserved spaces are divided for each of the storage spaces; for different storage spaces, the larger the reserved space divided, the faster the data update rate of the data stored in the storage space; The divided storage space with the reserved space of 0 is determined as the target storage space; the reserved space of 0 indicates that the reserved space of the target storage space is to be configured.
4. The method according to claim 1, characterized in that: The data space includes a plurality of data subspaces; In response to the space reclamation condition being met, performing a space reclamation operation on the data space includes: For each of the data subspaces, calculating the effective data ratio of the data stored in the data subspace; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace; If the valid data ratio of a target data subspace among the multiple data subspaces is less than or equal to a preset first threshold, a space recovery operation is performed on the target data subspace.
5. The method according to claim 1, characterized in that In response to the space reclamation condition being met, performing a space reclamation operation on the data space includes: In response to determining that the number of input / output operations per second (IOPS) of the host of the terminal device within a second preset time period is less than or equal to a preset second threshold, a space recovery operation on the data space is performed.
6. The method according to claim 1, characterized in that The data space includes a plurality of data subspaces; In response to the space reclamation condition being met, performing a space reclamation operation on the data space includes: Calculating the space utilization rate of the data space; wherein the space utilization rate is used to represent the ratio of the used space to the total space in the data space; For each of the data subspaces, calculating the effective data ratio of the data stored in the data subspace; wherein the effective data ratio is used to characterize the ratio of the effective data to the total data in the data stored in the data subspace; When it is determined that the space utilization rate is greater than or equal to the target space utilization rate, a space recovery operation is performed on the data subspace whose effective data ratio is less than or equal to the target effective data ratio; wherein the target effective data ratio is positively correlated with the target space utilization rate.
7. The method according to claim 6, characterized in that When the number of data subspaces whose effective data ratio is less than or equal to the target effective data ratio is multiple, performing a space recovery operation on the data subspaces whose effective data ratio is less than or equal to the target effective data ratio includes: In order of the effective data ratio from small to large, space recovery operations are sequentially performed on a plurality of data subspaces whose effective data ratio is less than or equal to the target effective data ratio. 。 8. A space recovery device, characterized in that: The device is applied to a host of a terminal device, and the device comprises: A reserved space determination module, configured to determine, for a target storage space of a storage chip in the terminal device, a size of a reserved space in the target storage space based on a data update rate of the target storage space within a first preset time period; A first partitioning module, configured to partition the target storage space into a data space and a reserved space based on the determined size of the reserved space; A storage module, used for storing the data written into the target storage space through the data space; A recycling module is used to execute a space recycling operation on the data space in response to meeting a space recycling condition; wherein, when executing the space recycling operation, valid data in the data space is stored through the reserved space.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of any method described in claims 1-7 are implemented.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the steps of any one of the methods of claims 1-7.