Management method of storage device, electronic equipment and storage medium

By predicting the amount of data written to the memory device to decide whether to perform garbage collection, the problem of frequent garbage collection in the prior art affecting the life of the memory device and equipment performance, and the balance of the life of the memory device and equipment performance is achieved.

CN120066380APending Publication Date: 2025-05-30HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311615567.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-28
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The prior art often performs garbage collection operations when writing data to a memory device, which affects the service life of the memory device and the performance of the device, and cannot balance the two.

Method used

By predicting the amount of data written by the memory device in the future, it is determined whether to perform a garbage collection operation based on the prediction results. When the remaining storage space is greater than the predicted write amount, garbage collection is not started; when the remaining storage space is less than or equal to the predicted write amount, garbage collection is initiated.

Benefits of technology

It avoids frequent garbage collection when the remaining space of the memory device is sufficient to affect the life of the memory device, and also avoids temporary garbage collection when the remaining space is insufficient to affect the performance of the device, thereby balancing the life of the memory device and the performance of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066380A_ABST
    Figure CN120066380A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of memory management, in particular to a management method of a memory device, electronic equipment and a storage medium. According to the method, the data writing amount of the storage device in a future period of time is predicted firstly, and then whether GC operation is executed or not is determined based on the size relation between the predicted data writing amount and the remaining storage space, where no data is stored, in the storage device. When the remaining storage space is larger than the predicted data writing amount, garbage collection is not started, and when the remaining storage space is smaller than or equal to the predicted data writing amount, garbage collection is started. Therefore, the situation that the service life of the storage device is influenced by frequent execution of garbage collection when the remaining storage space is enough to store the to-be-written data corresponding to the I / O operation can be avoided, and the situation that the use performance of the device is influenced by temporary execution of garbage collection when the to-be-written data corresponding to the I / O operation cannot be stored due to insufficient remaining storage space can also be avoided; therefore, the service life of the storage device and the use performance of the equipment can be balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of memory management, and in particular, to a method for managing a storage device, an electronic device, and a storage medium. Background Art

[0002] For a storage device including multiple data blocks, a data block may include multiple data pages. When erasing in units of data blocks, the data of some data pages needs to be erased (hereinafter referred to as invalid pages), while the data of some data pages does not need to be erased (hereinafter referred to as valid pages). Erasing the entire data block will cause data loss.

[0003] To this end, in some technical solutions, garbage collection (GC) technology is adopted to transfer the valid data in the valid pages in the storage device to a specific data block, and perform a data erasing operation on the data block that is all invalid pages in the storage device to release the data block so that it can be written with data again to avoid the loss of valid data.

[0004] During the process of writing data to the storage device, it is necessary to frequently execute the GC operation to ensure that the storage device has sufficient storage space to store the written data corresponding to the I / O operation. However, since the service life of the storage device is limited (that is, the storage device has a fixed number of operations), frequently executing the GC will affect the service life of the storage device. At the same time, to ensure that the storage device has sufficient storage space to store the written data corresponding to the I / O operation, the storage device will give priority to responding to the GC operation in multiple operations (such as I / O operations and GC operations). In this way, the I / O operation will be blocked, which will in turn cause the mobile phone to experience stuttering phenomena such as frame drops and slow application startup.

[0005] It can be seen that during the process of writing data to the storage device, frequently executing the GC operation will affect the service life of the storage device, and occasionally executing the GC operation will affect the performance of the device, and it is impossible to balance the service life of the storage device and the performance of the device. Summary of the Invention

[0006] To solve the problem of being unable to balance the service life of the storage device and the performance of the device, the embodiments of this application provide a method for managing a storage device, an electronic device, and a storage medium.

[0007] In a first aspect, the present application provides a method for managing a storage device, which is applied to an electronic device and includes: obtaining a first data write amount of the storage device in a first period; predicting a second data write amount in a second period according to the first data write amount; the first period is before the second period; obtaining a first storage space of the storage device, where the first storage space is the remaining storage space; if the electronic device is in an idle state and the second data write amount is greater than the capacity of the first storage space, then release a second storage space from the storage device, where the total capacity of the first storage space and the second storage space is greater than or equal to the second data write amount.

[0008] Based on the above solution, when the second data write amount is less than or equal to the remaining storage space of the storage device, garbage collection is not started, and when the second data write amount is greater than the remaining storage space of the storage device, garbage collection is started. In this way, it is possible to avoid frequently performing garbage collection and affecting the service life of the storage device when the remaining storage space of the storage device is sufficient to store the data to be written corresponding to the I / O operation, and it is also possible to avoid temporarily performing garbage collection and affecting the performance of the electronic device when the remaining storage space of the storage device is insufficient to store the data to be written corresponding to the I / O operation, thereby balancing the service life of the storage device and the performance of the electronic device. Moreover, by releasing the storage space from the storage device when the electronic device is in an idle state, it is possible to avoid the problem of releasing the storage space when the electronic device is officially used and affecting the performance of the electronic device.

[0009] It can be understood that different categories can be divided according to the user's habit of using the electronic device. For example: two categories of weekdays and rest days, or for example: seven categories of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. The above-mentioned first period and second period respectively refer to two different time periods of the same category. The first period can refer to a historical time period, such as last Monday to last Sunday, last Monday to last Sunday, and the Monday before last to the Sunday before last. The second period can refer to a predicted time period, such as this Monday to this Sunday.

[0010] It can be understood that the second storage space can be determined based on the capacity of the remaining storage space of the storage device, the second data write amount, and the total capacity of the storage device. For example, when the second data write amount is less than the total capacity of the storage device, the difference between the second data write amount and the capacity of the remaining storage space of the storage device is determined as the capacity of the second storage space, or the difference between the second data write amount and the capacity of the remaining storage space of the storage device multiplied by 1.5 can also be determined as the capacity of the second storage space. In this way, it is possible to release a storage space sufficient to store the second data write amount, so as to avoid the situation that the storage space is insufficient and needs to be temporarily released to affect the performance of the electronic device when storing the data of the second data write amount.

[0011] In some optional examples of the above first aspect, the first data write amount includes at least one of the following data write amounts: the first data write amount is the write amount of dynamic data, and the first data write amount is the write amount of static data.

[0012] It can be understood that since static data needs to be generated and written to the storage device in each sub-cycle of the first cycle, the electronic device can use the sum of the static data and the dynamic data as metadata to predict the data write amount to be written to the storage device in the second cycle. Otherwise, due to the low occurrence frequency of static data, for example, taking pictures and chatting do not occur all the time. Therefore, the electronic device can ignore the static data generated in each sub-cycle of the first cycle that needs to be written to the storage device, and use the dynamic data as metadata to predict the data write amount to be written to the storage device in the second cycle.

[0013] In the embodiments of the present application, by statistically analyzing the write amounts of static data and dynamic data in the first cycle of the storage device to predict the data write amount to be written to the storage device in the second cycle, the accuracy of the prediction result can be improved.

[0014] In some optional examples of the above first aspect, the write amount of static data includes the amount of data written to the storage device when taking pictures, recording videos, chatting, and swiping short videos; the write amount of dynamic data includes the amount of data written to the storage device when running application packages and system files.

[0015] In some optional examples, predicting the second data write amount in the second cycle according to the first data write amount includes: determining the data write amount in each sub-cycle of the second cycle according to the mean value of the data sub-write amounts in each sub-cycle of the first cycle, to obtain the second data write amount in the second cycle; or determining the data write amount in each sub-cycle of the second cycle according to the maximum value of the data sub-write amounts in each sub-cycle of the first cycle, to obtain the second data write amount in the second cycle.

[0016] In some optional examples, the processor can use the data write amount of the storage device last Monday as the data write amount next Monday, the data write amount of the storage device last Tuesday as the data write amount next Tuesday, the data write amount of the storage device last Wednesday as the data write amount next Wednesday, the data write amount of the storage device last Thursday as the data write amount next Thursday, the data write amount of the storage device last Friday as the data write amount next Friday, the data write amount of the storage device last Saturday as the data write amount next Saturday, and the data write amount of the storage device last Sunday as the data write amount next Sunday.

[0017] In some other alternative examples, the processor may use the average data volume of the storage device over multiple historical weeks as the daily data write volume for the next week.

[0018] In some other alternative examples, the processor may use the average data volume of the storage device during the working days of a historical week as the data write volume for the working days in the next week, and use the average data volume of the storage device during the rest days of a historical week as the data write volume for the rest days in the next week.

[0019] In some other alternative examples, the processor may use the maximum data volume of the storage device over multiple historical weeks as the data write volume for each day in the next week.

[0020] In the embodiments of the present application, by predicting the predicted data write volume during a period based on the data write volume of the storage device during a historical period, that is, by means of machine learning with personalized services for each user, the accuracy of the predicted data write volume of the storage device during the prediction period can be improved.

[0021] In some alternative examples of the first aspect above, the method further includes: the controller of the storage device sends first feedback information to the processor in the electronic device, and the first feedback information includes the capacity of the third storage space released by the storage device.

[0022] In the embodiments of the present application, the controller of the storage device sending the first feedback information to the processor in the electronic device can enable the processor in the electronic device to monitor the release situation of the storage device.

[0023] In some alternative examples of the first aspect above, the method further includes: if the capacity of the third storage space is less than the capacity of the second storage space, the processor in the electronic device instructs the storage device to release storage space until the total capacity of the storage space released by the storage device is greater than or equal to the capacity of the second storage space.

[0024] In the embodiments of the present application, the controller of the storage device sending the first feedback information to the processor in the electronic device can enable the processor in the electronic device to monitor the release situation of the storage device until enough storage space for storing the second data write volume is released.

[0025] In some alternative examples of the first aspect above, the storage device is a storage device that erases in data block units.

[0026] In some alternative examples, the storage device can be any storage device based on Nand Flash storage media. For example, universal flash storage (UFS), embedded multimedia card (eMMC), solid state drive (SSD), etc.

[0027] In some alternative examples of the first aspect above, the idle state includes the electronic device being in a screen-off charging state, a screen-off state, or a charging state.

[0028] In the embodiments of the present application, by releasing storage space from the storage device when the electronic device is in an idle state such as a screen-off charging state, a screen-off state, or a charging state, the problem of releasing storage space during the formal use of the electronic device and thus affecting the device's performance can be avoided.

[0029] In a second aspect, the present application provides an electronic device, including: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the management method of the storage device mentioned in the present application.

[0030] In a third aspect, the present application provides a readable storage medium, on which instructions are stored, and when the instructions are executed on an electronic device, the electronic device is caused to execute the management method of the storage device mentioned in the present application.

[0031] In a fourth aspect, the embodiments of the present application provide a computer program product, including: a non-volatile computer-readable storage medium, and the non-volatile computer-readable storage medium contains computer program code for executing the management method of the storage device mentioned in the embodiments of the present application. Description of the Drawings

[0032] Figure 1 According to some examples of the present application, a schematic structural diagram of a storage device is shown;

[0033] Figure 2 According to some examples of the present application, a schematic diagram of an application scenario of a memory management method is shown;

[0034] Figure 3 According to some examples of the present application, a schematic flowchart of a method for memory management based on garbage collection is shown;

[0035] Figure 4 According to some examples of the present application, a curve graph showing the change of the write usage performance of a storage device with the remaining percentage of the storage capacity is shown;

[0036] Figure 5 According to some examples of the present application, a schematic flowchart of a method for managing a storage device is shown;

[0037] Figure 6 According to some examples of the present application, a schematic flowchart of a method for managing a storage device is shown;

[0038] Figure 7 According to some examples of the present application, a curve graph showing the write usage performance of a universal flash memory varying with the remaining percentage of the storage capacity of the universal flash memory after implementing the method for managing a storage device according to the embodiments of the present application is shown;

[0039] Figure 8 According to some examples of the present application, a schematic structural diagram of a memory management system is shown;

[0040] Figure 9 According to some examples of the present application, a hardware structure of an electronic device is shown;

[0041] Figure 10 According to some examples of the present application, a software structure block diagram of an electronic device is shown. Detailed implementation manners

[0042] Illustrative embodiments of the present application include but are not limited to a method for managing a storage device, an electronic device, and a storage medium.

[0043] It can be understood that the method for managing a storage device mentioned in the embodiments of the present application can be applicable to any storage device based on the NandFlash storage medium. For example, universal flash storage (UFS), embedded multimedia card (eMMC), solid state drive (SSD), etc. The storage device based on the Nand Flash storage medium can be installed in any implementable electronic device, such as a smart phone, a tablet computer, a laptop computer, a personal computer (PC), etc.

[0044] The structure of the storage device is introduced below. Figure 1 A schematic structural diagram of a storage device is shown, as Figure 1 shown, the storage device may include a plurality of data blocks, and each data block may have a plurality of data pages. For example, Figure 1Data pages 1 to 5 therein. For a storage device with data blocks as the erasure unit, all data in a data block needs to be erased at once. For example, for data block 1 with a storage space of 1 - 500M, data page 1 with 1 - 100M stores the image data corresponding to picture 1, and data pages 2 to 5 with 101 - 500M store the image data corresponding to picture 2. When deleting picture 1, not only the image data within 1 - 100M is erased, but all the image data within 1 - 500M needs to be erased, which will cause data loss. For example, the image data corresponding to picture 2 stored within 101 - 500M will be lost.

[0045] The method for memory management based on garbage collection mentioned in some embodiments will be introduced below.

[0046] In some specific implementations, the storage device can determine whether to perform a GC operation based on its pre-configured GC waterline. For example, the GC waterline of a general flash memory can be 30%. That is, when the general flash memory detects that the remaining percentage of its storage capacity is less than 30%, it determines to perform the GC operation; otherwise, it determines not to perform the GC operation.

[0047] The application scenario of the management method of the storage device according to the embodiments of the present application will be introduced below. Figure 2 Fig. shows a schematic diagram of an application scenario of a management method of a storage device.

[0048] As Figure 2 shown, when the electronic device application starts, I / O operations can be performed on the general flash storage device. GC operations can be performed in the general flash storage device, that is, the valid data in the valid pages in the storage device is transferred to a specific data block, and the data block in the storage device that is all invalid pages is erased to release the data block so that it can be written with data again, which can not only ensure that the storage device has enough storage space to store the write data corresponding to the I / O operation, but also avoid the loss of valid data.

[0049] Figure 3 Fig. shows a schematic flowchart of a method for memory management based on garbage collection. This method can be executed by a mobile phone. As Figure 3 shown, the management method of the storage device can include:

[0050] 301: Determine whether it is in an idle state.

[0051] It can be understood that the system on chip (SoC) in a mobile phone can determine whether the mobile phone is in an idle state. Here, the idle state can refer to the scenario where the mobile phone is when the user does not perform business interactions with the mobile phone based on the user interface (UI). For example, when the mobile phone is in the screen-off charging state, the screen-off state, or the charging state, the SoC can determine that the mobile phone is in the idle state. When it is determined that the mobile phone is in the idle state, it can proceed to step 302; otherwise, it can proceed to step 306.

[0052] 302: Issue a garbage collection instruction to the storage device.

[0053] It can be understood that when the SoC determines that the mobile phone is in the idle state, it can issue a garbage collection instruction to the controller of the storage device through the driver corresponding to the storage device. Here, the controller of the storage device and the storage device are integrated on the same chip.

[0054] 303: The controller of the storage device determines whether to initiate garbage collection.

[0055] It can be understood that the controller of the storage device can determine whether to initiate GC based on its own status (such as total storage capacity, remaining percentage of storage capacity, etc.) and the GC waterline.

[0056] Figure 4 Shows a curve graph of the write usage performance of a storage device changing with the remaining percentage of storage capacity. Figure 4 It can be seen that when the remaining percentage of the storage capacity of the storage device is less than 30%, the write usage performance of the storage device decreases as the remaining percentage of the storage capacity decreases. When the remaining percentage of the storage capacity of the storage device is 20%, the write usage performance of the storage device drops to 90%. When the remaining percentage of the storage capacity of the storage device is 10%, the write usage performance of the storage device drops to 30%. Therefore, the GC waterline can be set to 30%, that is, when the remaining percentage of the storage capacity of the storage device is less than 30%, initiate GC to release data blocks.

[0057] It can be understood that when the controller of the storage device detects that the remaining percentage of the storage capacity is less than the GC waterline of 30%, it can determine to perform the GC operation and proceed to step 305, that is, perform the garbage collection operation. When the controller of the storage device detects that the remaining percentage of the storage capacity is greater than or equal to the GC waterline of 30%, it can determine not to perform the GC operation and proceed to step 306, that is, perform the read data operation or the write data operation.

[0058] 304: The controller of the storage device performs the garbage collection operation.

[0059] It can be understood that after receiving a garbage collection instruction, the controller of the storage device can perform a garbage collection operation. That is, transfer the valid data in the valid pages of the storage device to a specific data block, and perform a data erasure operation on the data block in the storage device that is all invalid pages to release the data block so that it can be written with data again to avoid the loss of valid data.

[0060] It can be understood that after receiving a garbage collection instruction, the controller of the storage device may also not perform a garbage collection operation.

[0061] 305: The controller of the storage device performs a read data operation or a write data operation.

[0062] It can be understood that when the mobile phone is in a non-idle state, or when the controller of the storage device determines not to perform a garbage collection operation, a normal read data operation or a write data operation can be performed, that is, an I / O service is executed.

[0063] Since the total storage capacity and the GC waterline of the storage device are preset, the total storage capacity and the GC waterline of the storage device cannot be adjusted after the storage device is packaged.

[0064] Therefore, when the controller of the storage device detects that the remaining percentage of the storage capacity is less than the GC waterline, the GC operation will be frequently executed to ensure that the storage device has sufficient storage space to store the data to be written corresponding to the I / O operation. However, since the service life of the storage device is limited (that is, the storage device has a fixed number of operations), frequent execution of GC will affect the service life of the storage device.

[0065] When the controller of the storage device detects that the remaining percentage of the storage capacity is greater than or equal to the GC waterline, the GC operation will basically not be performed, unless it is detected that the remaining storage space without stored data is insufficient to store the data to be written corresponding to the I / O operation, then the GC operation will be temporarily performed. In this way, the I / O operation will be blocked, and then the mobile phone will have stuttering phenomena such as frame drops and slow application startup, which will affect the usage performance of the device.

[0066] Therefore, the above management method of the storage device cannot balance the service life of the storage device and the usage performance of the device.

[0067] To solve the above problems, an embodiment of the present application provides a method for managing a storage device. In this method, instead of determining whether to perform a GC operation based on the GC waterline, the data write volume of the storage device in a future period of time is first predicted, and then whether to perform a GC operation is determined based on the relationship between the predicted data write volume and the remaining storage space in the storage device that has not stored data. That is, when the remaining storage space is greater than the predicted data write volume, garbage collection is not started; when the remaining storage space is less than or equal to the predicted data write volume, garbage collection is started. In this way, it is possible to avoid frequently performing garbage collection and affecting the service life of the storage device when the remaining storage space is sufficient to store the data to be written corresponding to the I / O operation, and to avoid temporarily performing garbage collection and affecting the device performance when the remaining storage space is insufficient to store the data to be written corresponding to the I / O operation, thereby balancing the service life of the storage device and the device performance.

[0068] In some optional examples, the method for predicting the data write volume of the storage device in a future period of time may be: counting the static data (such as cold data generated by user taking pictures, recording videos, chatting, and swiping short videos) and dynamic data (such as hot data generated by running application packages, system files, etc.) of the storage device in a historical period of time, and predicting the data write volume of the storage device in a future period of time according to the statistical results.

[0069] In some optional examples, when the ratio of the remaining storage space in the storage device that has not stored data to the total storage space of the storage device is less than the ratio threshold, if the remaining storage space is greater than the predicted data write volume, garbage collection is not started; if the remaining storage space is less than or equal to the predicted data write volume, garbage collection is started.

[0070] The following introduces the method for managing a storage device mentioned in the embodiment of the present application. This method can be executed by an electronic device. Figure 5 The flowchart of a method for managing a storage device is shown, as Figure 5 shown, the method for managing this storage device may include:

[0071] 501: Predict the data write volume of the storage device in the second period according to the data write volume of the storage device in the first period.

[0072] It should be noted that different categories can be divided according to the user's habit of using the electronic device. For example: two categories of weekdays and rest days, or for another example: seven categories of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. The above-mentioned first period and second period respectively refer to two different time periods of the same category.

[0073] It can be understood that the first period may refer to a historical time period, such as last Monday to last Sunday, last Monday to last Sunday, and the Monday and Sunday before last. The second period may refer to a predicted time period, such as this Monday to this Sunday. The first moment of the first period may refer to the connection moment between the historical time period and the predicted time period, such as 24:00 on last Sunday (i.e., 0:00 on this Monday).

[0074] It can be understood that the electronic device can count the write amounts of static data (such as cold data generated by the user taking pictures, recording videos, chatting, and swiping short videos) and dynamic data (such as hot data generated by running application packages, system files, etc.) of the storage device during the historical time period, and predict the predicted data write amount of the storage device during the predicted time period.

[0075] In some alternative examples, the electronic device can automatically count the daily data write amounts of the storage device within the historical week according to the dimension from Monday to Sunday. For example, the electronic device can count the data write amount of the storage device on last Monday, on last Tuesday, on last Wednesday, on last Thursday, on last Friday, on last Saturday, and on last Sunday, and obtain the daily data write amounts of the storage device from Monday to Sunday in the next week through offline deduction and learning based on the daily data write amounts of the storage device within the historical week.

[0076] In some alternative examples, the processor can use the data write amount of the storage device on last Monday as the data write amount on next Monday, the data write amount of the storage device on last Tuesday as the data write amount on next Tuesday, the data write amount of the storage device on last Wednesday as the data write amount on next Wednesday, the data write amount of the storage device on last Thursday as the data write amount on next Thursday, the data write amount of the storage device on last Friday as the data write amount on next Friday, the data write amount of the storage device on last Saturday as the data write amount on next Saturday, and the data write amount of the storage device on last Sunday as the data write amount on next Sunday.

[0077] In some other alternative examples, the processor can use the average data amount of the storage device within multiple historical weeks as the data write amount within the next week.

[0078] In some other alternative examples, the processor can use the average data amount of the storage device on weekdays within the historical week as the data write amount on weekdays within the next week, and use the average data amount of the storage device on rest days within the historical week as the data write amount on rest days within the next week.

[0079] In some other alternative examples, the processor can use the maximum data amount of the storage device within multiple historical weeks as the data write amount within the next week.

[0080] Predicting the data write volume of the storage device in the prediction time period based on the data write volume of the storage device in the historical time period listed above is only several feasible implementation solutions listed in the embodiments of the present application. Other reasonable prediction methods are also within the scope protected by the embodiments of the present application, and the embodiments of the present application do not make specific limitations.

[0081] Since static data is generated every day from Monday to Sunday and needs to be written into the storage device, the electronic device can use the sum of the static data and the dynamic data as metadata to predict the data write volume to be written into the storage device from Monday to Sunday in the next week. Otherwise, since the occurrence frequency of static data is low, for example, taking pictures and chatting do not occur all the time, the electronic device can ignore the static data generated from Monday to Sunday that needs to be written into the storage device and use the dynamic data as metadata to predict the data write volume to be written into the storage device from Monday to Sunday in the future. Among them, the method of predicting the data write volume to be written into the storage device in the next week according to the static data and the dynamic data, or only according to the dynamic data, can refer to the above, and will not be elaborated here.

[0082] In the embodiments of the present application, by predicting the predicted data write volume in the prediction time period based on the data write volume of the storage device in the historical time period, that is, through the machine learning method of personalized recommendations for each user, the accuracy of the predicted data write volume of the storage device in the prediction time period can be improved.

[0083] 502: Obtain the first remaining storage space of the storage device currently.

[0084] It can be understood that the first remaining storage space of the storage device currently may refer to the remaining storage space without stored data.

[0085] 503: Compare the storage space required for the data write volume of the storage device in the second cycle with the size of the first storage space.

[0086] It can be understood that when the remaining storage space without stored data of the storage device is small and the storage space required for the predicted data write volume is large, the electronic device can obtain that the storage space required for the predicted data write volume is greater than the remaining storage space without stored data of the storage device. When the remaining storage space without stored data of the storage device is large and the storage space required for the predicted data write volume is small, the electronic device can obtain that the storage space required for the predicted data write volume is less than the remaining storage space without stored data of the storage device.

[0087] 504: When the storage space required for the data write volume of the storage device in the second cycle is greater than the first storage space, garbage collection is performed to release the second storage space from the storage device, where the total storage space of the first storage space and the second storage space is greater than or equal to the storage space required for the data write volume of the storage device in the second cycle.

[0088] It can be understood that the size of the second storage space can be determined based on the remaining storage space size of the storage device, the predicted data write volume, and the total storage space size of the storage device. For example, when the predicted data write volume is less than the total storage space size of the storage device, the difference between the predicted data write volume and the remaining storage space size of the storage device is determined as the size of the second storage space, or 1.5 times the difference between the predicted data write volume and the remaining storage space size of the storage device can also be determined as the size of the second storage space. In this way, sufficient storage space for storing the predicted data write volume can be released, so as to avoid the situation that when storing data with the predicted data write volume, the storage space is insufficient and temporary storage space needs to be released, thereby affecting the performance of the device.

[0089] It can be understood that when the storage space required for the predicted data write volume is greater than the first storage space, the controller of the storage device performs garbage collection, that is, transfers the valid data in the valid pages of the storage device to a specific data block, and performs a data erasure operation on the data block that is all invalid pages in the storage device to release the data block so that it can be written with data again. This can not only avoid the loss of valid data, but also ensure that the storage device has sufficient storage space to store the write data corresponding to the predicted write volume of I / O operations during the predicted time period.

[0090] Based on the embodiments of the present application, it is possible to avoid the controller of the storage device frequently performing garbage collection and affecting the service life of the storage device when the remaining storage space is sufficient to store the data to be written corresponding to the I / O operation, and it is also possible to avoid the controller of the storage device temporarily performing garbage collection and affecting the device usage performance when the remaining storage space is insufficient to store the data to be written corresponding to the I / O operation. Thus, the service life of the storage device and the device usage performance can be balanced.

[0091] Taking the universal flash memory in a mobile phone as an example below, the management method of the storage device mentioned above is described in detail.

[0092] Figure 6 The flowchart of another management method of the storage device is shown. This method can be executed by a mobile phone. As Figure 6 shown, the management method of the storage device may include:

[0093] 601: Determine whether it is in an idle state.

[0094] It can be understood that when the processor determines whether the mobile phone is in an idle state, it can refer to Figure 3 step 301 in this document, which will not be elaborated here. When the processor determines that the mobile phone is in an idle state, it can proceed to step 602; otherwise, it can proceed to step 609.

[0095] 602: Obtain the remaining storage space of the general flash memory.

[0096] In some optional examples, the processor can obtain the remaining storage space of the general flash memory where no data is stored.

[0097] 603: Based on the remaining storage space of the general flash memory, determine the remaining storage space ratio of the general flash memory, and determine whether the remaining storage space ratio of the general flash memory is less than the ratio threshold.

[0098] It can be understood that the processor can determine the remaining storage space ratio of the general flash memory based on the remaining storage space of the general flash memory and the total storage space of the general flash memory, and determine whether the remaining storage space ratio of the general flash memory is less than the ratio threshold. If the determination result is yes, execute step 604; otherwise, execute step 605.

[0099] It can be understood that the ratio threshold can be preset based on the relationship between the write usage performance of the general flash memory and the remaining storage space of the general flash memory. For example, based on Figure 4 the relationship between the write usage performance of the storage device shown and the remaining percentage of the storage capacity, the ratio threshold is set within the range [0, 0.3]. For example, the ratio threshold can be set to 30%, or the ratio threshold can be set to 20%, or the ratio threshold can be set to 10%. The embodiments of the present application do not make specific limitations.

[0100] In some optional examples, when the ratio threshold is set to 15%, if the remaining storage space ratio of the general flash memory is less than 15%, step 604 can be executed, that is, the processor configures the storage space that needs garbage collection and sends a garbage collection instruction to the controller of the general flash memory. If the remaining storage space ratio of the general flash memory is greater than or equal to 15%, step 502 can be executed, that is, the processor obtains the remaining storage space of the general flash memory.

[0101] 604: Configure the storage space that needs garbage collection and send a garbage collection instruction to the controller of the general flash memory.

[0102] It can be understood that the processor can predict the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period, and configure the storage space that needs to be garbage collected based on the data write volume of the general flash memory in the prediction time period.

[0103] In some optional examples, the storage space that needs to be garbage collected configured by the processor can be equal to the data write volume of the general flash memory in the prediction time period. For example, if the predicted data write volume of the general flash memory in the prediction time period is 5G, the storage space that needs to be garbage collected can be configured as 5G. The storage space that needs to be garbage collected configured by the processor can also be greater than the data write volume of the general flash memory in the prediction time period. For example, if the predicted data write volume of the general flash memory in the prediction time period is 5G, the processor can configure the storage space that needs to be garbage collected as 8G, and the processor can also configure the storage space that needs to be garbage collected as 10G.

[0104] It can be understood that the processor can predict the data write volume of the general flash memory in the prediction time period based on the write volumes of static data (cold data generated by users taking pictures, recording videos, chatting, and swiping short videos) and dynamic data (hot data generated by running application packages, system files, etc.) of the general flash memory in the historical time period.

[0105] It can be understood that predicting the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period can refer to step 501, which will not be elaborated here.

[0106] In the embodiments of the present application, by predicting the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period, that is, through the machine learning method of personalized recommendations for each user, the accuracy of the predicted data write volume of the general flash memory in the prediction time period can be improved.

[0107] It can be understood that the garbage collection instruction sent to the controller of the general flash memory can be an Enhanced Manual Garbage Collection (Enhanced Manul GC) instruction. Among them, the garbage collection instruction can carry the configured storage space that needs to be garbage collected.

[0108] 605: The controller of the general flash memory obtains the storage space that needs to be garbage collected and performs garbage collection.

[0109] In some alternative examples, after receiving a garbage collection instruction, the controller of the universal flash memory can obtain the storage space that needs to be garbage collected from the garbage collection instruction, and perform garbage collection based on the storage space that needs to be garbage collected.

[0110] In some alternative examples, when the controller of the universal flash memory executes a garbage collection instruction, it can recycle a storage space equal to the storage space that needs to be garbage collected, or can recycle a storage space less than the storage space that needs to be garbage collected, or can also not perform garbage collection.

[0111] 606: After the controller of the universal flash memory finishes executing garbage collection, feedback the execution result.

[0112] It can be understood that the execution result can include whether garbage collection is performed and the storage space of garbage collection. After the controller of the universal flash memory finishes executing garbage collection, it can feedback to the processor the execution result of whether garbage collection is performed and the storage space of garbage collection.

[0113] 607: Determine whether the storage space after garbage collection of the universal flash memory meets the recycling requirements.

[0114] It can be understood that the processor can receive the execution result of whether garbage collection is performed and the storage space of garbage collection feedback by the controller of the universal flash memory. When the controller of the universal flash memory does not perform garbage collection or the storage space of garbage collection is less than the storage space that needs to be garbage collected, the processor can determine that the storage space after garbage collection of the universal flash memory does not meet the recycling requirements, and go to step 604, otherwise go to step 608.

[0115] In the embodiments of the present application, by feedbacking the execution result, the garbage collection action of the controller of the universal flash memory can be changed from an uncontrollable behavior to a controllable behavior, that is, when the controller of the universal flash memory does not perform garbage collection or the storage space of garbage collection is less than the storage space that needs to be garbage collected, the universal flash memory can be controlled again to perform garbage collection until the storage space of garbage collection is greater than or equal to the storage space that needs to be garbage collected.

[0116] 608: End.

[0117] In the embodiments of the present application, when the storage space of garbage collection of the universal flash memory is greater than or equal to the storage space that needs to be garbage collected, the entire process can be ended, so as to ensure that the universal flash memory will not perform GC again within the next 24 hours, thereby avoiding blocking of I / O operations, and further reducing stuttering phenomena such as frame drops and slow application startup on the mobile phone.

[0118] Figure 7 The figure shows a graph of the write usage performance of a general flash memory varying with the remaining percentage of the storage capacity of the general flash memory after presenting the management method of the storage device according to the embodiments of the present application. It can be seen from Figure 7 that even if the remaining percentage of the storage capacity of the general flash storage device is less than the GC waterline on the previous day, since the general flash memory executes the garbage collection instruction and the storage space for garbage collection is greater than or equal to the storage space that needs to be garbage collected, which is sufficient to execute the I / O service, the write usage performance of the general flash memory on the next day does not vary with the remaining percentage of the storage capacity.

[0119] 609: Execute a read data operation or a write data operation.

[0120] It can be understood that when the processor determines that the mobile phone is in a non-idle state, for example, when the user interacts with the mobile phone based on the UI, the general flash memory can be controlled to execute normal read data operations or write data operations, that is, execute I / O services.

[0121] Next, the processing system of the management method of the storage device mentioned in the embodiments of the present application will be introduced. Figure 8 The figure shows a schematic structural diagram of a memory management system.

[0122] As Figure 8 shown, the memory management system may include a write volume monitoring module 810, a storage service monitoring module 820, a write volume prediction module 830, a remaining capacity monitoring module 840, a garbage collection instruction generation module 850, and a device garbage collection instruction execution module 860.

[0123] It can be understood that when the processor detects that the mobile phone is in an idle state, it can call the instructions corresponding to the write volume monitoring module 810, the storage service monitoring module 820, the write volume prediction module 830, the remaining capacity monitoring module 840, and the garbage collection instruction generation module 850, send a garbage collection instruction to the general flash memory, and receive the execution result feedback by the controller of the general flash memory.

[0124] It can be understood that after the controller of the general flash memory receives the garbage collection instruction, it can call the corresponding execution of the device garbage collection instruction execution module 860 to execute garbage collection.

[0125] Among them, the write volume monitoring module 810 is used to automatically count the daily data write volume of the mobile phone within the historical week according to the dimension from Monday to Sunday. For example, count the data write volume of the mobile phone last Monday, last Tuesday, last Wednesday, last Thursday, last Friday, last Saturday, and last Sunday.

[0126] A storage service monitoring module 820 is used to detect whether the device is in an idle state. Here, the idle state may refer to the scenario where the mobile phone is when the user does not perform business interactions with the mobile phone based on the user interface (UI). For example, the mobile phone is in the state of screen-off charging.

[0127] A write volume prediction module 830 is used to predict the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period.

[0128] In some optional examples, the write volume prediction module can obtain the data write volume of the mobile phone for each day from Monday to Sunday in the next week by offline deduction and learning based on the data write volume of the mobile phone for each day in the past week.

[0129] In some optional examples, the data write volume of the mobile phone last Monday can be used as the data write volume of the next Monday, the data write volume of the mobile phone last Tuesday can be used as the data write volume of the next Tuesday, the data write volume of the mobile phone last Wednesday can be used as the data write volume of the next Wednesday, the data write volume of the mobile phone last Thursday can be used as the data write volume of the next Thursday, the data write volume of the mobile phone last Friday can be used as the data write volume of the next Friday, the data write volume of the mobile phone last Saturday can be used as the data write volume of the next Saturday, and the data write volume of the mobile phone last Sunday can be used as the data write volume of the next Sunday.

[0130] In some other optional examples, the average data volume of the mobile phone in the past week can be used as the data write volume of the mobile phone for each day in the next week.

[0131] In some other optional examples, the average data volume of the mobile phone on weekdays in the past week can be used as the data write volume of the mobile phone on weekdays in the next week, and the average data volume of the mobile phone on rest days in the past week can be used as the data write volume of the mobile phone on rest days in the next week.

[0132] It can be understood that the above-listed prediction of the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period is only several feasible implementation solutions listed in the embodiments of the present application, and other reasonable prediction methods are also within the scope protected by the embodiments of the present application, and the embodiments of the present application do not make specific limitations.

[0133] In the embodiments of the present application, by predicting the data write volume of the general flash memory in the prediction time period based on the data write volume of the general flash memory in the historical time period, that is, by means of machine learning with personalized services for each user, the accuracy of the predicted data write volume of the general flash memory in the prediction time period can be improved.

[0134] The remaining capacity monitoring module 840 is used to obtain the remaining storage space of the general flash memory, that is, to obtain the remaining storage space of the general flash memory where no data is stored.

[0135] The garbage collection instruction generation module 850 is used to send a garbage collection instruction to the general flash memory when the proportion of the remaining storage space of the general flash memory is less than the proportion threshold. That is, the garbage collection instruction generation module can enable the device garbage collection instruction execution module.

[0136] It can be understood that the garbage collection instruction sent by the garbage collection instruction generation module to the general flash memory can be an Enhanced Manul Garbage Collection (Enhanced Manul GC) instruction. Among them, the garbage collection instruction can carry the configured storage space that needs to be garbage collected.

[0137] The device garbage collection instruction execution module 860 is a module in the general flash memory that is used to execute or not execute the garbage collection instruction, and is also used to feedback the execution result to the garbage collection instruction generation module.

[0138] In some alternative examples, the device garbage collection instruction execution module can recycle a storage space equal to the storage space that needs to be garbage collected, or can also recycle a storage space less than the storage space that needs to be garbage collected.

[0139] It can be understood that in the embodiments of the present application, the above storage device management method can be executed by an electronic device. The hardware structure of the electronic device will be introduced below.

[0140] Figure 9 It is a block diagram of the electronic device 900 provided in the embodiments of the present application. In some embodiments, the electronic device 900 may include one or more processors 901, a system control logic 902 connected to at least one of the processors 901, a system memory 903 connected to the system control logic 902, a non-volatile memory (NVM) 904 connected to the system control logic 902, and a network interface 905 connected to the system control logic 902.

[0141] In some embodiments, the processor 901 may include one or more single-core or multi-core processors. In some embodiments, the processor 901 may include any combination of a general-purpose processor and a dedicated processor (for example, a graphics processor, an application processor, a baseband processor, etc.).

[0142] It can be understood that the processor 901 can call the instructions corresponding to the write volume monitoring module, the storage service monitoring module, the remaining capacity monitoring module, and the garbage collection instruction generation module mentioned above to send a garbage collection instruction to the controller of the storage device.

[0143] In some embodiments, the system control logic 902 may include any suitable interface controller to provide any suitable interface to at least one of the processors 901 and / or any suitable device or component communicating with the system control logic 902.

[0144] In some embodiments, the non-volatile memory (NVM) 904 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory (NVM) 904 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of a hard disk drive (HDD), a compact disc (CD) drive, and a digital versatile disc (DVD) drive.

[0145] In some alternative examples, the non-volatile memory (NVM) 904 may include a universal flash memory, and the universal flash memory may have a controller that may be integrated with the universal flash memory on the same chip. The controller of the universal flash memory can call the instructions of the device garbage collection instruction execution module mentioned above to perform garbage collection.

[0146] The non-volatile memory (NVM) 904 may include a part of the storage resources installed on the device of the electronic device 900, or it may be accessed by the device but not necessarily be a part of the device. For example, the non-volatile memory (NVM) 904 can be accessed via the network interface 905 through a network.

[0147] The network interface 905 may include a transceiver for providing a radio interface for the electronic device 900, and then communicating with any other suitable device (such as a front-end module, an antenna, etc.) through one or more networks. In some embodiments, the network interface 905 may be integrated with other components of the electronic device 900. For example, the network interface 905 may be integrated with at least one of the processor 901, the system memory 903, the non-volatile memory (NVM) 904, and a firmware device (not shown) having instructions. When at least one of the processors 901 executes the instructions, the electronic device 900 implements the storage device management method mentioned in the embodiments of the present application.

[0148] The network interface 905 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 905 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.

[0149] In some embodiments, at least one of the processors 901 may be packaged with the logic of one or more controllers for the system control logic 902 to form a system-in-package (SiP). In one embodiment, at least one of the processors 901 may be integrated with the logic of one or more controllers for the system control logic 902 on the same die to form a system-on-chip (SoC).

[0150] The electronic device 900 may further include: an input / output (I / O) device 906. The input / output (I / O) device 906 may include a user interface that enables a user to interact with the electronic device 900; the design of the peripheral component interface enables peripheral components to also interact with the electronic device 900. In some embodiments, the electronic device 900 further includes sensors for determining at least one of environmental conditions and location information related to the electronic device 900.

[0151] In some embodiments, the user interface may include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., a light-emitting diode flash), and a keyboard.

[0152] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.

[0153] The software architecture of the electronic device mentioned in this application is introduced below.

[0154] Figure 10 The software structure block diagram of the electronic device according to the embodiments of this application is shown.

[0155] The layered architecture divides software into several layers, and each layer has a clear role and division of labor. The layers communicate through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime, the system libraries, the hardware abstraction layer (HAL) ( Figure 10 not shown in the figure), and the kernel layer.

[0156] The application layer may include a series of application packages.

[0157] Such asFigure 10 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, game, shopping, travel, instant messaging (such as short message), etc. In addition, the application package may also include system applications such as the home screen (i.e., desktop), negative first screen, control center, notification center, etc.

[0158] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.

[0159] Such as Figure 10 As shown, the application framework layer may include a state manager, an input manager, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a display manager, an activity manager, etc. For the sake of illustration, Figure 10 in this example, the application framework layer is exemplified by including a state manager, a window manager, a content provider, and a resource manager.

[0160] The input manager is used to receive instructions or requests reported by lower layers such as the kernel layer and the hardware abstraction layer.

[0161] The state manager is used to determine whether the electronic device is in an idle state. Among them, the idle state may refer to the scenario where the electronic device is when the user does not perform business interactions with the electronic device based on the user interface (UI). For example, the electronic device is in the screen-off charging state, the electronic device is in the screen-off state, or the electronic device is in the charging state.

[0162] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc. In this application, the window manager is used to display a window including one or more shortcut controls when the electronic device 100 meets the preset trigger conditions.

[0163] The activity manager is used to manage the activities running in the system, including processes, applications, services, task information, etc.

[0164] The content provider is used to store and obtain data, and make these data accessible to applications. The data may include videos, images, audio, dialed and answered calls, browsing history and bookmarks, phone book, etc.

[0165] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon can include a view for displaying text and a view for displaying pictures. In this application, the view system is used to display a quick area on the display screen 103 when the electronic device 100 meets a preset trigger condition, and one or more quick controls added by the electronic device 100 are included in the quick area. Among them, this application does not limit the position, layout of the quick area, as well as the icons, positions, layouts and functions of the controls in the quick area.

[0166] The display manager is used to transmit display content to the kernel layer.

[0167] The phone manager is used to provide the communication function of the electronic device 100. For example, the management of call status (including answering, hanging up, etc.).

[0168] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc.

[0169] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that the download is completed, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as a notification of a background-running application, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompt text information in the status bar, emit a prompt sound, the electronic device vibrates, the indicator light flashes, etc.

[0170] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.

[0171] The core libraries contain two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.

[0172] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0173] The system library may include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc.

[0174] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.

[0175] The media library supports the playback and recording of multiple common audio and video formats, as well as static image files, etc. The media library can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0176] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.

[0177] The 2D graphics engine is a drawing engine for 2D drawing.

[0178] The Hardware Abstraction Layer (HAL layer) is an interface layer between the operating system software and hardware components, which provides an interface for the interaction between the upper-layer software and the lower-layer hardware. The HAL layer abstracts the underlying hardware into software containing corresponding hardware interfaces. By accessing the HAL layer, the settings of the underlying hardware devices can be achieved. For example, relevant hardware components can be enabled or disabled in the HAL layer. In some embodiments, the core architecture of the HAL layer is composed of at least one of C++ or C.

[0179] The kernel layer is a layer between hardware and software. The kernel layer at least includes a storage device driver, a display driver, a camera driver, an audio driver, a sensor driver, a driver for a touch chip, and an input system, etc. For ease of explanation, Figure 10 in this example, the kernel layer is illustrated by including a storage device driver.

[0180] It can be understood that the display driver can communicate with the controller of the storage device through an interface of the processor. The processor can call this interface to send a garbage collection instruction to the controller of the storage device, and the controller of the storage device can feedback the execution result to the processor based on this interface.

[0181] It can be understood that the structure illustrated in this application does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure can be implemented in hardware, software, or a combination of software and hardware.

[0182] Embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memories and / or storage elements), at least one input device, and at least one output device.

[0183] The program code can be applied to the input instructions to perform the various functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit, or a microprocessor.

[0184] The program code can be implemented in a high-level procedural language or an object-oriented programming language to communicate with the processing system. When needed, the program code can also be implemented in assembly language or machine language. In fact, the mechanisms described in this application are not limited to the scope of any particular programming language. In any case, the language can be a compiled language or an interpreted language.

[0185] In some cases, the disclosed embodiments can be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments can also be implemented as instructions carried or stored on one or more transient or non-transient machine-readable (e.g., computer-readable) storage media, which can be read and executed by one or more processors. For example, the instructions can be distributed via a network or via other computer-readable media. Thus, a machine-readable medium can include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to, floppy disks, optical disks, optical discs, compact discs read-only memory (CD-ROMs), magneto-optical discs, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) in electrical, optical, acoustic, or other forms via the Internet. Thus, a machine-readable medium includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).

[0186] The above has introduced the possible hardware structures of the terminal device. It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the terminal device. In other embodiments of the present application, the terminal device may include more or fewer components than those shown in the figures, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figures may be implemented in hardware, software, or a combination of software and hardware.

[0187] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Additionally, the inclusion of a structural or method feature in a specific figure does not imply that such a feature is required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0188] It should be noted that each unit / module mentioned in the device embodiments of the present application is a logical unit / module. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or can be implemented as a combination of multiple physical units / module. The physical implementation manner of these logical units / modules themselves is not the most important. The combination of the functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, to highlight the innovative part of the present application, the above device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application. This does not mean that there are no other units / modules in the above device embodiments.

[0189] It should be noted that in the examples and descriptions of this patent, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one" does not exclude the presence of additional identical elements in the process, method, article or device including the element.

[0190] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, those of ordinary skill in the art should understand that various changes in form and detail may be made therein without departing from the scope of the present application.

Claims

1. A management method for a storage device, applied to an electronic device, characterized in that, it includes: Obtain the first data write volume of the storage device within the first period; Predict the second data write volume within the second period according to the first data write volume; The first period is before the second period; Obtain the first storage space of the storage device, and the first storage space is the remaining storage space; If the electronic device is in an idle state and the second data write volume is greater than the capacity of the first storage space, release a second storage space from the storage device, where the total capacity of the first storage space and the second storage space is greater than or equal to the second data write volume.

2. The method according to claim 1, characterized in that, The first data write volume includes at least one of the following data write volumes: The first data write volume is the write volume of dynamic data, and the first data write volume is the write volume of static data.

3. The method according to claim 2, characterized in that, The write volume of the static data includes the data volume written to the storage device when taking pictures, recording videos, chatting, and swiping short videos; The write volume of the dynamic data includes the data volume written to the storage device when running application program packages and system files.

4. The method according to claim 1, characterized in that, The predicting the second data write volume within the second period according to the first data write volume includes: Determine the data write volume within each sub-period of the second period according to the average value of the data write volume within each sub-period of the first period, and obtain the second data write volume within the second period; or, Determine the data write volume within each sub-period of the second period according to the maximum value of the data sub-write volume within each sub-period of the first period, and obtain the second data write volume within the second period.

5. The method according to claim 1, characterized in that, The method further includes: The controller of the storage device sends first feedback information to the processor in the electronic device, and the first feedback information includes the capacity of the third storage space released by the storage device.

6. The method according to claim 5, characterized in that, The method further includes: If the capacity of the third storage space is less than the capacity of the second storage space, the processor in the electronic device instructs the storage device to release storage space until the total capacity of the storage space released by the storage device is greater than or equal to the capacity of the second storage space.

7. The method according to claim 1, characterized in that, The storage device is a storage device that erases in data block units.

8. The method according to claim 1, characterized in that, The idle state includes that the electronic device is in a screen-off charging state, a screen-off state, or a charging state.

9. An electronic device, characterized in that, it includes: A memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the management method of the storage device according to any one of claims 1-8.

10. A readable storage medium, characterized in that, instructions are stored on the readable storage medium, and when the instructions are executed on an electronic device, the electronic device is caused to execute the management method of the storage device according to any one of claims 1-8.