Capacity control method and device and storage medium
By determining the data storage space and garbage cleaning space in the terminal UFS chip and expanding the data storage space based on the garbage cleaning space, the problem of degradation in terminal storage performance is solved, and more efficient storage space utilization and performance improvement is achieved.
Patent Information
- Application Number
- CN202311344939.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2025-04-18
Smart Images

Figure CN119847410A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of terminal technology, and in particular to a capacity control method, device and storage medium. Background Art
[0002] With the development of science and technology and the improvement of technology, the storage capacity of electronic device storage space is constantly increasing. Among them, Universal Flash Storage (UFS), which is the standard specification of flash memory for consumer electronic devices, provides higher data bandwidth and higher reliability for flash memory storage. In addition, using UFS as the internal memory of the terminal can provide a larger storage capacity for the terminal's data storage.
[0003] With the continuous development of new services, the demand for terminal data storage capacity is also increasing. However, the terminal UFS chip space cannot be used reasonably, resulting in a decline in terminal storage performance. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a capacity control method, device and storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, a capacity control method is provided, comprising: determining that a storage space of an electronic device includes a data storage space and a garbage cleaning space; based on the garbage cleaning space, expanding the data storage space; and performing capacity control based on the used capacity in the expanded data storage space.
[0006] In one implementation, the garbage cleanup space includes a reserved space, and expanding the data storage space based on the garbage cleanup space includes: expanding the data storage space with part or all of the reserved space.
[0007] In one embodiment, capacity control is performed based on the used capacity in the expanded data storage space, including: in response to the used capacity in the expanded data storage space being greater than a first threshold, generating a first instruction, the first instruction being used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space; and performing capacity control based on the first instruction.
[0008] In one implementation, the first instruction includes a second instruction, and the second instruction is used to erase user data in the data storage space; and the capacity control based on the first instruction includes:
[0009] Based on the second instruction, data in the data storage space is erased to expand the capacity of the data storage space.
[0010] In one embodiment, the second instruction includes an address area field for identifying a data storage address; erasing the data in the data storage space based on the second instruction includes: determining the address area indicated by the address area field in the second instruction; detecting the user data status of the data storage space corresponding to the address area; wherein the user data status of the data storage space includes at least one of the following: a valid data status; or an invalid data status; if the data status is an invalid data status, erasing the data with the invalid data status.
[0011] In one embodiment, the first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space; the capacity control based on the first instruction includes: in response to the used capacity of the data storage space being greater than a second threshold, restoring part or all of the expanded capacity in the data storage space to the capacity of the garbage cleaning space.
[0012] In one implementation, the first instruction is carried in a space field bit of a universal flash memory command protocol unit.
[0013] In one embodiment, before determining that the electronic device storage space includes data storage space and garbage cleaning space, it also includes: in response to detecting that the storage space is initialized, generating a fourth instruction, the fourth instruction is used to set a reserved space in the garbage cleaning space.
[0014] According to a second aspect of an embodiment of the present disclosure, there is provided a capacity control device, comprising:
[0015] A determination unit, used to determine that the storage space of the electronic device includes a data storage space and a garbage cleaning space;
[0016] An expansion unit, configured to expand the data storage space based on the garbage cleaning space;
[0017] The control unit is used to perform capacity control based on the used capacity in the expanded data storage space.
[0018] In one implementation, the expansion unit expands the data storage space based on the garbage cleanup space in the following manner: expanding the data storage space by part or all of the reserved space.
[0019] In one embodiment, the control unit performs capacity control based on the used capacity in the expanded data storage space in the following manner: in response to the used capacity in the expanded data storage space being greater than a first threshold, generates a first instruction, wherein the first instruction is used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space; and performs capacity control based on the first instruction.
[0020] In one embodiment, the first instruction includes a second instruction, and the second instruction is used to erase user data in the data storage space; the control unit performs capacity control based on the first instruction in the following manner: based on the second instruction, erasing the data in the data storage space to expand the capacity of the data storage space.
[0021] In one embodiment, the second instruction includes an address area field for identifying a data storage address; the control unit erases the data in the data storage space based on the second instruction in the following manner: determining the address area indicated by the address area field in the second instruction; detecting the user data status of the data storage space corresponding to the address area; wherein the user data status of the data storage space includes at least one of the following: a valid data status; or an invalid data status; if the data status is an invalid data status, erasing the data with the invalid data status.
[0022] In one embodiment, the first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space; the control unit performs capacity control based on the first instruction in the following form: in response to the used capacity of the data storage space being greater than a second threshold, part or all of the expanded capacity in the data storage space is restored to the capacity of the garbage cleaning space.
[0023] In one implementation, the first instruction is carried in a space field bit of a universal flash memory command protocol unit.
[0024] In one embodiment, before the determining unit determines in the following manner that the electronic device storage space includes the data storage space and the garbage cleaning space, the device further includes:
[0025] The setting unit is used to generate a fourth instruction in response to detecting the storage space initialization, wherein the fourth instruction is used to set the reserved space in the garbage cleaning space.
[0026] According to a third aspect of an embodiment of the present disclosure, there is provided a capacity control device, comprising:
[0027] processor;
[0028] a memory for storing processor-executable instructions;
[0029] The processor is configured to: execute the method described in the first aspect or any one of the embodiments of the first aspect.
[0030] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the capacity control method described in the first aspect or any one of the embodiments of the first aspect.
[0031] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: by determining the data storage space and the garbage cleaning space in the storage space of the electronic device, the data storage space is expanded based on the garbage cleaning space, so that the storage space of the electronic device is fully utilized. And based on the storage capacity used by the expanded data space, the storage space of the electronic device is capacity controlled, so as to ensure that the storage space of the electronic device is reasonably used, improve the storage space utilization rate and improve the storage performance of the electronic device.
[0032] 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
[0033] 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.
[0034] Figure 1 The figure is a flow chart of a capacity control method according to an exemplary embodiment.
[0035] Figure 2 The invention is a flow chart showing a method for controlling capacity by extending reserved space according to an exemplary embodiment.
[0036] Figure 3 The figure is a flow chart of a capacity control method according to an exemplary embodiment.
[0037] Figure 4 The invention is a flow chart showing a method for controlling capacity by erasing data in a data storage space according to an exemplary embodiment.
[0038] Figure 5 The invention is a flow chart showing a method for controlling capacity by erasing data in a data storage space according to an exemplary embodiment.
[0039] Figure 6The present invention is a flowchart showing a method for performing capacity control by restoring garbage cleaning space capacity according to an exemplary embodiment.
[0040] Figure 7 The present invention is a block diagram of a data storage space capacity control device according to an exemplary embodiment.
[0041] Figure 8 It is a block diagram of a device for capacity control according to an exemplary embodiment. DETAILED DESCRIPTION
[0042] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.
[0043] With the development of science and technology and the advancement of technology, the flash memory particles in Universal Flash Storage (UFS) have changed from triple-level cell NAND flash memory particles (Triple Level Cell Not AND, TLC NAND) to quad-level cell NAND flash memory particles (Quad level cells Not AND, QLC NAND). Therefore, the UFS chip using hybrid TLC NAND and QLC NAND provides higher capacity for terminal data storage. In addition, using UFS as a terminal storage chip enables the terminal to have the advantages of high-speed reading and writing, low power consumption and high reliability when storing data.
[0044] In the UFS storage chip, in addition to the space for data storage, space for executing the garbage collection (GC) mechanism, i.e., GC space, is reserved. For example, some terminals may use 10%-20% of the space in the UFS storage chip to execute the GC function. Among them, the GC mechanism erases invalid user data to ensure that the UFS storage chip can quickly record valid data and extend the service life of the UFS storage chip. The larger the GC space set in the UFS storage chip, the better the flash memory performance and the longer the service life of the UFS storage chip, but the capacity for data storage will be reduced accordingly. Therefore, when designing a UFS storage chip, it is necessary to weigh factors such as data storage capacity, performance, and service life for design. However, in actual use, the GC space may not be fully used to execute the GC mechanism, and some GC space may be idle, which causes a waste of UFS storage chip space.
[0045] In addition, in the related art, when the terminal stores data, the UFS storage chip is read or written through the file system. After the file system frequently reads, writes, and deletes data, the data in the file system and the UFS storage chip will appear as shown in Table 1:
[0046] File System VALID INVALID VALID INVALID UFS VALID INVALID INVALID VALID
[0047] Table 1
[0048] Table 1 is a corresponding table of data status in the file system and the universal flash memory chip. As shown in Table 1, when the data status in the file system is valid (VALID), the data status in the UFS memory chip can be valid (VALID) or invalid (INVALID), and when the data status in the UFS memory chip is invalid (INVALID), it indicates that the data is lost. When the data status in the file system is invalid (INVALID), the data status in the UFS memory chip can be valid (VALID) or invalid (INVALID), wherein the data status in the file system is invalid, and the data status in the UFS memory chip is valid, because the file system performs GC, but does not send a command to discard data (DISCARD) to the UFS memory chip; or after sending a command to discard data, because the threshold for GC is not reached in the UFS memory chip, the user data is only marked as invalid to avoid spending too much time and resources on data erasure. However, this will cause too much invalid data to occupy the storage space of the UFS memory chip, resulting in insufficient data storage space and reduced data storage performance.
[0049] Therefore, the present disclosure provides a solution, by determining the storage capacity of the data storage space and the garbage cleaning space in the storage space of the electronic device, and based on the storage capacity of the garbage cleaning space, expanding the storage capacity of the data storage space, thereby increasing the storage capacity of the data storage space, so that the storage space of the electronic device is fully utilized. And based on the storage capacity used by the expanded data space, the capacity of the storage space of the electronic device is controlled, so as to ensure that the storage space of the electronic device is reasonably used, improve the utilization rate of the storage space, and improve the storage performance of the electronic device.
[0050] Figure 1 is a flow chart of a capacity control method according to an exemplary embodiment. Figure 1 As shown, the capacity control method is used in a terminal and includes the following steps.
[0051] In step S11, it is determined that the electronic device storage space includes data storage space and garbage cleaning space.
[0052] The data storage space is used for data storage. For example, the data storage space can store data written by a file system in the electronic device.
[0053] Among them, the garbage cleaning space is used to perform the garbage cleaning GC function.
[0054] In the embodiment of the present disclosure, part of the garbage cleaning space may be in an idle state, that is, part of the space may not be used to perform the GC function.
[0055] In the disclosed embodiment, the storage capacity of the data storage space and the storage capacity of the garbage cleaning space in the storage space of the electronic device can be determined by the file system in the electronic device.
[0056] In the embodiment of the present disclosure, the storage space of the electronic device may be the storage space of a UFS storage chip in a universal flash memory UFS.
[0057] In the disclosed embodiment, when it is detected that the storage space of the electronic device is initialized, or when it is detected that the electronic device is restarted, it is determined that the storage space of the electronic device includes data storage space capacity and garbage cleaning space capacity.
[0058] In step S12, the data storage space is expanded based on the garbage cleaning space.
[0059] In the embodiment of the present disclosure, the data storage space is expanded based on the garbage cleaning space, which may be to use part of the space in the garbage cleaning space for data storage, that is, to expand the storage capacity of the data storage space.
[0060] In step S13, capacity control is performed based on the used capacity in the expanded data storage space.
[0061] In the embodiment of the present disclosure, the capacity of the data storage space and the garbage cleaning space can be controlled by determining the size of the used storage space in the data storage space.
[0062] In the disclosed embodiment, the storage space capacity of the electronic device can be controlled through the interaction between the file system and the flash memory. The file system can detect the storage capacity of the UFS storage chip. In addition, the file system can send a universal flash memory command protocol unit (UFS Protocol Information Unit, UIPU) instruction to the UFS, or receive a UPIU instruction sent by the UFS. The UFS storage chip can receive and execute the UPIU instruction sent by the file system.
[0063] In the disclosed embodiment, when the storage capacity of the data storage space and the garbage cleaning space in the storage space of the electronic device is determined, the storage capacity of the data storage space is expanded based on the storage capacity of the garbage cleaning space, thereby increasing the storage capacity of the data storage space and making full use of the storage space of the electronic device. And based on the used storage capacity in the expanded data space, the capacity of the data storage space and the garbage cleaning space of the electronic device is controlled, thereby ensuring that the storage space of the electronic device is used rationally, improving the utilization rate of the storage space, and improving the storage performance of the electronic device.
[0064] In the embodiment of the present disclosure, the garbage cleaning space in the storage space of the electronic device may include a space for executing the garbage cleaning function and a space for not executing the garbage cleaning function, wherein the space for not executing the garbage cleaning can be used as a reserved space in the garbage cleaning space.
[0065] Figure 2 is a flow chart showing a method for controlling capacity by extending reserved space according to an exemplary embodiment. Figure 2 As shown, the capacity control method is used in a terminal and includes the following steps.
[0066] In step S21, it is determined that the electronic device storage space includes data storage space and garbage cleaning space.
[0067] In step S22, the data storage space is expanded by part or all of the reserved space.
[0068] In the disclosed embodiment, step S21 is consistent with step S11 and will not be described in detail here.
[0069] In the disclosed embodiment, the reserved space in the garbage cleaning space, that is, the space where the garbage cleaning function is not performed, can be used for data storage, thereby expanding the storage capacity of the data storage space. Among them, the entire reserved space can be used for data storage, or part of the reserved space can be used for data storage.
[0070] In the disclosed embodiment, the storage capacity of the reserved space in the garbage cleaning space in the UFS storage chip and the storage capacity of the garbage cleaning space can be determined by the user or relevant testers.
[0071] In the disclosed embodiment, the space in the garbage cleaning space used to perform the GC function can be in sectors, which can be used for garbage cleaning or other management operations; the reserved space in the garbage cleaning space can be in sectors, which can be used for performing the GC function or for data storage.
[0072] In one example, when the space set by the user for performing the GC function is smaller than the space currently used to perform the GC function, the UFS chip will not be able to allocate enough space for performing the GC function, resulting in a decrease in garbage cleaning efficiency and a shortened life of the UFS storage chip.
[0073] In one example, when the space set by the user for performing the GC function is greater than or equal to the space currently used to perform the GC function, the UFS storage chip will allocate additional space to the GC function, thereby improving the garbage cleaning efficiency and the life of the UFS storage chip.
[0074] In one example, when the reserved interval set by the user is larger than the space outside the control for executing the GC function in the garbage cleaning space, the UFS storage chip will not be able to recover enough space, resulting in insufficient storage space.
[0075] In one example, when the reserved interval set by the user is less than or equal to the space outside the control of the garbage cleaning space used to perform the GC function, the UFS storage chip will recover the space of the specified size, thereby improving the availability of the storage space.
[0076] In the disclosed embodiment, the reserved space in the garbage cleaning space can be used for data storage, thereby expanding the data storage space, improving data storage efficiency, and avoiding waste of UFS chip storage capacity, so that the storage space in the electronic device can be used reasonably.
[0077] In the embodiment of the present disclosure, when it is detected that the expanded data storage space of the electronic device is greater than a first threshold, the electronic device may perform capacity control on the storage capacity.
[0078] In the embodiment of the present disclosure, it can be detected through the file system that the data storage space is greater than the first threshold.
[0079] Figure 3 is a flow chart of a capacity control method according to an exemplary embodiment. Figure 3 As shown, the capacity control method is used in a terminal and includes the following steps.
[0080] In step S31 , in response to the used capacity of the expanded data storage space being greater than a first threshold, a first instruction is generated.
[0081] The first instruction is used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space.
[0082] In the disclosed embodiment, the file system may detect that the used capacity of the expanded data storage space is greater than a first threshold value. For example, the first threshold value may be 80%, and a first instruction is generated, wherein the first instruction may be used to manage the capacity of the expanded data storage space, or to manage the capacity of the storage space of the garbage cleaning space.
[0083] In step S32, capacity control is performed based on the first command.
[0084] In the disclosed embodiment, the UFS storage chip may perform capacity management on the expanded data storage space or capacity management on the storage space of the garbage cleaning space according to the first instruction.
[0085] In the embodiment of the present disclosure, when the file system detects that the used capacity in the expanded data storage space is greater than the first threshold, a first instruction is generated and sent to the UFS storage chip. The UFS storage chip receives the first instruction and, according to the first instruction, performs capacity management on the expanded data storage space in the UFS chip or performs capacity management on the storage space of the garbage cleaning space.
[0086] In the disclosed embodiment, by detecting that the used capacity in the expanded data storage space is greater than a first threshold, a first instruction is generated, and the capacity of the UFS storage chip is controlled based on the first instruction, thereby ensuring that the storage space of the electronic device is used rationally and improving the storage space utilization rate.
[0087] In the embodiment of the present disclosure, the capacity control of the storage capacity of the electronic device may be the control of the capacity of the data storage space, wherein the capacity control of the data storage space may be achieved by erasing user data in the data storage space, and the capacity control of the data storage space may be achieved by a second instruction included in the first instruction.
[0088] Figure 4 is a flow chart showing a method for controlling capacity by erasing data in a data storage space according to an exemplary embodiment. Figure 4 As shown, the capacity control method is used in a terminal and includes the following steps.
[0089] In step S41, in response to the used capacity of the expanded data storage space being greater than a first threshold, a first instruction is generated.
[0090] In step S42, based on the data management second instruction, the data in the data storage space is erased to expand the capacity of the data storage space.
[0091] In the embodiment of the present disclosure, the second instruction can be used to erase user data in the data storage space.
[0092] In the embodiment of the present disclosure, the file system may send a second instruction to the UFS storage chip, the UFS storage chip may receive the second instruction, and based on the second instruction, erase the user data in the data storage space.
[0093] In the disclosed embodiment, the second instruction may be sent in the form of direct memory access (DMA), or may be sent in the form of data exchange by executing I / O port instructions (Programming Input / Output Model, PIO) through a central processing unit (CPU) to perform data reading and writing.
[0094] In the embodiment of the present disclosure, the file system may detect that the used capacity in the expanded data storage space is greater than a first threshold, and send a second instruction to the UFS storage chip. The UFS storage chip receives the second instruction and erases the user data in the data storage space based on the second instruction.
[0095] In the disclosed embodiment, user data is erased to reduce the occupancy rate of data in the data storage space, thereby expanding the capacity of the data storage space and further improving the data storage performance of the electronic device.
[0096] In the embodiment of the present disclosure, the second instruction may include an address area field, wherein the address area field may be used to indicate a data storage address.
[0097] Figure 5 is a flow chart showing a method for controlling capacity by erasing data in a data storage space according to an exemplary embodiment. Figure 5 As shown, the capacity control method is used in a terminal and includes the following steps.
[0098] In step S51, the address area indicated by the address area field in the second data management instruction is determined.
[0099] In the embodiment of the present disclosure, the address area indicated by the address area field in the second data management instruction may be determined by the UFS storage chip.
[0100] In the embodiment of the present disclosure, the address area may include multiple data storage addresses.
[0101] The address area field may be stored in a logical block address (LOGICAL BLOCKADDRESS, LBA) in the UPIU command.
[0102] In step S52, the data status of the address area corresponding to the data storage space is detected.
[0103] The data status of the data storage space includes at least one of the following: a valid data status; or an invalid data status.
[0104] In the embodiment of the present disclosure, the data state of the corresponding address area can be determined based on the address area in the second instruction.
[0105] In step S53, if the data status is invalid, the data in the invalid data status is erased.
[0106] In the embodiment of the present disclosure, when the UFS storage chip detects that the data state of the corresponding address area is invalid, the data with the invalid data state is erased.
[0107] In the disclosed embodiment, the UFS storage chip can send a corresponding data segment based on the detected data status to reply to the file system. In addition, errors may occur during the data transmission process. Therefore, the data segment replied by the UFS storage chip may include an address area field indicating the data storage address, a field indicating the user data status, and an error code. Different error codes may correspond to different error types.
[0108] In one example, when performing a write operation, the file system can first query whether the LBA to be written has data in a valid state. If it is an invalid data state, the operation can be directly skipped, thereby avoiding unnecessary write operations and the risk of data damage.
[0109] In one example, when performing a read operation, the file system may first query whether the LBA to be read has data in a valid state. If it is an invalid data state, an error may be directly returned, thereby avoiding unnecessary read operations and the risk of causing data errors.
[0110] In the disclosed embodiment, the file system receives the data segment sent by the UFS storage chip, and thus can avoid the file system reading and writing invalid data by querying the validity of the address area field, thereby improving the performance and reliability of the UFS storage chip.
[0111] In the disclosed embodiment, by detecting the data status corresponding to the address area field in the second instruction, it is determined that the data status is invalid, and the data with invalid data status is erased, thereby reducing the utilization rate of the data storage space, thereby achieving the expansion of the data storage space capacity, and then improving the data storage performance of the electronic device.
[0112] In the disclosed embodiment, the capacity control of the storage capacity of the electronic device may be the control of the capacity of the reserved space, wherein the capacity control of the garbage cleaning space may be achieved by restoring the reserved space to execute a garbage cleaning function.
[0113] The first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space.
[0114] Figure 6 is a flow chart showing a method for controlling capacity by restoring garbage cleaning space capacity according to an exemplary embodiment. Figure 6 As shown, the capacity control method is used in a terminal and includes the following steps.
[0115] In step S61, in response to the used capacity of the data storage space being greater than a second threshold.
[0116] In the embodiment of the present disclosure, the second threshold may be equal to the first threshold. For example, the first threshold and the second threshold may both be set to 80%, or the second threshold may not be equal to the first threshold.
[0117] In step S62, part or all of the capacity in the expanded capacity of the data storage space is restored to the capacity of the garbage cleaning space.
[0118] In the embodiment of the present disclosure, when the file system detects that the used storage space in the data storage space of the electronic device is greater than the second threshold, a third instruction is sent to the UFS storage chip. The UFS storage chip receives the third instruction and based on the third instruction, restores part or all of the capacity of the extended capacity in the data storage space of the FS storage chip to the capacity of the garbage cleaning space, that is, restores the space used for data storage to the space used for garbage cleaning.
[0119] In the embodiment of the present disclosure, the size of a part or all of the capacity in the expanded capacity in the data storage space restored to the capacity of the garbage cleaning space may be inconsistent with the set reserved space size.
[0120] In one example, if the capacity of the garbage cleaning space to be restored is smaller than the pre-set reserved space, the UFS storage chip will not be able to allocate enough space for performing the GC function, resulting in reduced garbage cleaning efficiency and shortened life of the UFS storage chip.
[0121] In one example, if the capacity of the garbage cleaning space to be restored is greater than or equal to the preset reserved space, the UFS storage chip has enough space to perform the GC function, thereby improving the garbage cleaning efficiency and the life of the UFS storage chip.
[0122] In the embodiment of the present disclosure, based on the data capacity of the data storage space, part or all of the capacity of the extended capacity in the data storage space is restored to the capacity of the garbage cleaning space, thereby avoiding insufficient space in the UFS storage chip for performing the garbage cleaning function, resulting in reduced garbage cleaning efficiency and shortened UFS storage chip life.
[0123] In the disclosed embodiment, the first instruction is carried in the empty bit of the universal flash memory command protocol unit of the high-speed flash memory control UFS instruction.
[0124] In the embodiment of the present disclosure, the file management system may send the first instruction to the universal flash memory in the form of a UFS Protocol Information Unit (UPIU).
[0125] The UPIU instruction including the first instruction includes at least a command code (RDPROTECT), a flag (FUA), a data transmission direction, a data length (TRANSFER LENGTH), etc., wherein OPERATION CODE represents the operation code of the UPIU instruction; DPO represents the flag of the UPIU instruction, and the data management instruction can be written into the empty bit (Reserved) in the UPIU instruction, so that the UFS can execute the corresponding function.
[0126] In the disclosed embodiment, when the file system detects that the UFS storage chip is updated or formatted, a fourth instruction is sent to the UFS storage chip, and the UFS storage chip sets the storage capacity of the reserved space in the garbage cleaning space based on the file system instruction.
[0127] In the disclosed embodiment, a reserved space is set to determine the size of the capacity for data space expansion, thereby avoiding waste of garbage cleaning space capacity in the electronic device, ensuring the rational use of the storage space of the electronic device, and improving the storage performance of the electronic device.
[0128] In the embodiments of the present disclosure, a capacity control method is described in conjunction with the following examples.
[0129] In the disclosed embodiment, the storage space capacity of the UFS storage chip is controlled through information interaction between the file system in the terminal and the UFS storage chip.
[0130] In the embodiment of the present disclosure, after the file system detects that the UFS storage chip is initialized, it sends a fourth instruction to the UFS storage chip, and the UFS storage chip sets the data capacity of the reserved space of the garbage cleaning space based on the fourth instruction. The reserved space is used for data storage.
[0131] In the embodiment of the present disclosure, when the file system detects that the used capacity of the data storage space of the UFS storage chip is greater than the first threshold value, for example, the first threshold value may be 80% of the total capacity of the UFS storage chip, a second instruction is sent to the UFS storage chip. After the UFS storage chip receives the second instruction sent by the file system, the UFS storage chip may query the data status in the corresponding address area according to the address area in the second instruction, and delete the user data whose user data status is invalid. In addition, the UFS storage chip may send a data segment representing the user data status to the file system.
[0132] In the embodiment of the present disclosure, when the file system detects that the used capacity of the data storage space in the UFS storage chip is greater than the second threshold, wherein the second threshold may be consistent with the first threshold, the file system sends a third instruction to the UFS storage chip. The third instruction is used to release the reserved space so that the reserved space is used to perform the GC function.
[0133] Based on the same concept, an embodiment of the present disclosure also provides a capacity control device.
[0134] It is understandable that the capacity control device provided in the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.
[0135] Figure 7 FIG. 1 is a block diagram of a data storage space capacity control device according to an exemplary embodiment. Figure 7 The device 100 includes a determining unit 101, an extending unit 102, a controlling unit 103 and a setting unit 104.
[0136] The determining unit 101 is used to determine that the storage space of the electronic device includes data storage space and garbage cleaning space.
[0137] The expansion unit 102 is used to expand the data storage space based on the garbage cleaning space.
[0138] The control unit 103 is used to perform capacity control based on the used capacity in the expanded data storage space.
[0139] The setting unit 104 is used to generate a fourth instruction in response to detecting the initialization of the storage space, where the fourth instruction is used to set the reserved space in the garbage cleaning space.
[0140] In one implementation, the expansion unit expands the data storage space based on the garbage cleanup space in the following manner: the data storage space is expanded by a part or all of the reserved space.
[0141] In one embodiment, the control unit performs capacity control based on the used capacity in the expanded data storage space in the following manner: in response to the used capacity in the expanded data storage space being greater than a first threshold, a first instruction is generated, the first instruction being used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space. Based on the first instruction, capacity control is performed.
[0142] In one embodiment, the first instruction includes a second instruction, and the second instruction is used to erase user data in the data storage space. The control unit performs capacity control based on the first instruction in the following manner: based on the second instruction, erase the data in the data storage space to expand the capacity of the data storage space.
[0143] In one embodiment, the second instruction includes an address area field for identifying a data storage address. The control unit erases data in the data storage space based on the second instruction in the following manner: determining the address area indicated by the address area field in the second instruction. Detecting the user data state of the address area corresponding to the data storage space. The user data state of the data storage space includes at least one of the following: a valid data state. Or an invalid data state. If the data state is an invalid data state, erasing the data with an invalid data state.
[0144] In one embodiment, the first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space. The control unit performs capacity control based on the first instruction in the following form: in response to the used capacity of the data storage space being greater than the second threshold, part or all of the capacity of the expanded capacity in the data storage space is restored to the capacity of the garbage cleaning space.
[0145] In one implementation, the first instruction is carried in a space field bit of a universal flash memory command protocol unit.
[0146] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0147] Figure 82 is a block diagram of a device 200 for capacity control according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0148] Reference Figure 8 , the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .
[0149] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.
[0150] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 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.
[0151] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.
[0152] The multimedia component 208 includes a screen that provides an output interface between the device 200 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 208 includes a front camera and / or a rear camera. When the device 200 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.
[0153] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.
[0154] I / O interface 212 provides an interface between processing component 202 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.
[0155] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0156] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 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 216 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.
[0157] In an exemplary embodiment, the apparatus 200 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 method.
[0158] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0159] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.
[0160] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.
[0161] It will be further understood that the terms “center”, “longitudinal”, “lateral”, “front”, “back”, “up”, “down”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present embodiment and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation.
[0162] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.
[0163] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0164] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0165] It should be understood that the present disclosure is not limited to the precise 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 scope of the appended claims.
Claims
1. A capacity control method, characterized in that: include: Determine the storage space of electronic devices including data storage space and garbage removal space; Based on the garbage cleaning space, expanding the data storage space; Capacity control is performed based on the used capacity in the expanded data storage space.
2. The capacity control method according to claim 1, wherein the garbage cleaning space includes a reserved space, and the step of expanding the data storage space based on the garbage cleaning space comprises: The data storage space is expanded by a part or all of the reserved space.
3. The method according to claim 1 or 2, characterized in that: Based on the used capacity of the expanded data storage space, capacity control is performed, including: In response to the used capacity of the expanded data storage space being greater than a first threshold, generating a first instruction, the first instruction being used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space; Based on the first instruction, capacity control is performed.
4. The method according to claim 3, characterized in that The first instruction includes a second instruction, and the second instruction is used to erase the data in the data storage space; The performing capacity control based on the first instruction includes: Based on the second instruction, data in the data storage space is erased to expand the capacity of the data storage space.
5. The method according to claim 4, characterized in that The second instruction includes an address area field for identifying a data storage address; The erasing the data in the data storage space based on the second instruction includes: Determine the address area indicated by the address area field in the second instruction; Detecting the data state of the data storage space corresponding to the address area; wherein the data state of the data storage space includes at least one of the following: a valid data state; or an invalid data state; If the data status is invalid, the data in the invalid data status is erased.
6. The method according to any one of claims 3 to 5, characterized in that The first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space; The performing capacity control based on the first instruction includes: In response to the used capacity of the data storage space being greater than a second threshold, part or all of the capacity of the extended capacity in the data storage space is restored to the capacity of the garbage cleaning space.
7. The method according to any one of claims 3 to 6, characterized in that The first instruction is carried in the empty domain bit of the universal flash memory command protocol unit.
8. The capacity control method according to claim 1, before determining that the electronic device storage space includes data storage space and garbage cleaning space, further comprising: In response to detecting the storage space initialization, a fourth instruction is generated, the fourth instruction being used to set a reserved space in the garbage cleaning space.
9. A capacity control device, characterized in that: include: A determination unit, used to determine that the storage space of the electronic device includes a data storage space and a garbage cleaning space; An expansion unit, configured to expand the data storage space based on the garbage cleaning space; The control unit is used to perform capacity control based on the used capacity in the expanded data storage space.
10. The capacity control device according to claim 9, characterized in that: The garbage cleaning space includes a reserved space, and the expansion unit expands the data storage space based on the garbage cleaning space in the following manner: The data storage space is expanded by a part or all of the reserved space.
11. The device according to claim 9 or 10, characterized in that The control unit performs capacity control based on the used capacity in the expanded data storage space in the following manner: In response to the used capacity of the expanded data storage space being greater than a first threshold, generating a first instruction, the first instruction being used to perform capacity management on at least one of the expanded data storage space and the garbage cleaning space; Based on the first instruction, capacity control is performed.
12. The device according to claim 11, characterized in that The first instruction includes a second instruction, and the second instruction is used to erase the data in the data storage space; The control unit performs capacity control based on the first instruction in the following manner: Based on the second instruction, data in the data storage space is erased to expand the capacity of the data storage space.
13. The device according to claim 12, characterized in that The second instruction includes an address area field for identifying a data storage address; The control unit erases the data in the data storage space based on the second instruction in the following manner: Determine the address area indicated by the address area field in the second instruction; Detecting the data state of the data storage space corresponding to the address area; wherein the data state of the data storage space includes at least one of the following: a valid data state; or an invalid data state; If the data status is invalid, the data in the invalid data status is erased.
14. The device according to any one of claims 11 to 13, characterized in that The first instruction includes a third instruction, and the third instruction is used to restore the capacity of the garbage cleaning space; The control unit performs capacity control based on the first instruction in the following manner: In response to the used capacity of the data storage space being greater than a second threshold, part or all of the capacity of the extended capacity in the data storage space is restored to the capacity of the garbage cleaning space.
15. The device according to any one of claims 9 to 14, characterized in that The first instruction is carried in the empty domain bit of the universal flash memory command protocol unit; The storage space is allocated as data storage space and garbage cleaning space, wherein the garbage cleaning space includes a reserved space.
16. The capacity control device according to claim 9, before the determining unit determines that the electronic device storage space includes the data storage space and the garbage cleaning space in the following manner, the device further comprises: The setting unit is used to generate a fourth instruction in response to detecting the storage space initialization, wherein the fourth instruction is used to set the reserved space in the garbage cleaning space.
17. A capacity control device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the capacity control method according to any one of claims 1-8.
18. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of the terminal, the terminal is enabled to execute the method described in any one of claims 1 to 8.