Mobile device and method of maintaining storage device of mobile device

By freeing up storage device space based on the foreground application status in mobile devices and triggering defragmentation when appropriate, the problem of the storage device competing for I/O resources with the foreground application when reclaiming space is solved, improving user experience and improving space recycling efficiency.

CN120144280APending Publication Date: 2025-06-13SAMSUNG (CHINA) SEMICONDUCTOR CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510160117.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

When maintaining the storage device of a mobile device, the processing of reclaiming the space of the storage device may compete with the front-end applications of the mobile device for I/O resources, resulting in data read and write delays of the front-end applications and affecting the user experience.

Method used

The computer program instructions are executed by at least one processor to determine the foreground application status of the mobile device, and based on the state, regardless of the background application status, freeing up the storage space of the storage device. Specific steps include sending a drop request to invalidate the physical address of the invalid data page and automatically triggering a host-initiated defragmentation (HID) routine when the foreground application is idle.

Benefits of technology

This method avoids competition between the front-end applications and the I/O resources of the storage device maintenance processing, improves the user experience, and improves the efficiency of storage device space recycling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144280A_ABST
    Figure CN120144280A_ABST
Patent Text Reader

Abstract

A mobile device and a method of maintaining a storage device of the mobile device are disclosed. The method includes executing, by at least one processor, computer program instructions to perform operations including: determining a state of a foreground application of the mobile device; the storage space of the storage device is released based on the state of the foreground application and irrespective of the state of one or more current background applications of the mobile device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage, and more particularly, to a mobile device and a method for maintaining a storage device of the mobile device. Background Art

[0002] As mobile devices are increasingly widely used, technologies for effectively maintaining the storage devices of mobile devices are becoming increasingly needed. Generally, when maintaining the storage device of a mobile device, the space of the storage device is reclaimed when the input / output (I / O) is idle. However, the process of reclaiming the space of the storage device may compete with the foreground applications of the mobile device for I / O resources, which may cause delays in data reading and writing of the foreground applications, thereby affecting the user experience. Summary of the Invention

[0003] This Summary of the Invention is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary of the Invention is not intended to identify key features and / or essential features of the claimed subject matter, nor is it intended to be used to assist in determining the scope of the claimed subject matter.

[0004] This application provides a mobile device and a method for maintaining a storage device of the mobile device, which can at least improve the user experience while maintaining the storage device.

[0005] According to some example embodiments, a method for maintaining a storage device of a mobile device includes: executing computer program instructions by at least one processor to perform operations, the operations including: determining a state of a foreground application of the mobile device; and releasing a storage space of the storage device based on the state of the foreground application and without considering states of one or more current background applications of the mobile device.

[0006] In this application, the storage space of the storage device is released to maintain the storage device only based on the state of the current foreground application, which can avoid the current foreground application competing with the process of maintaining the storage device for I / O resources, thereby improving the user experience. In addition, compared with the solution of releasing the storage space of the storage device based on both the foreground application and the background application, this application can perform the process of maintaining the storage device more efficiently.

[0007] The step of releasing the storage space of the storage device includes: sending a current discard request to the storage device based on the state of the current foreground application being determined to be an idle state, where the current discard request includes at least one discard command configured to invalidate physical addresses storing invalid data pages of the storage device.

[0008] In this application, when the foreground application is idle, a discard request is sent, thereby avoiding adverse effects on the foreground application caused by sending the discard request.

[0009] The number of the at least one discard command of the current discard request is based on the number of discard commands of the previous discard request, and the operation includes determining whether the transmission of the previous discard request is interrupted. If the transmission of the previous discard request is interrupted, the number of the at least one discard command of the current discard request is a default value; if the transmission of the previous discard request is not interrupted, the number of the at least one discard command of the current discard request is greater than the number of discard commands of the previous discard request. When the current discard request is the first sent discard request among all discard requests or multiple discard requests, the number of the at least one discard command of the current discard request is a default value.

[0010] The at least one discard command of the current discard request is configured to invalidate physical addresses at most.

[0011] In the present application, the number of discard commands of the current discard request is adjusted based on whether the transmission of the previous discard request is interrupted, thereby improving the space recycling efficiency of the storage device.

[0012] The steps of releasing the storage space of the storage device include: based on the state of the current foreground application being determined to be an idle state, determining whether to send an analysis command to the storage device based on a first quantity of written data pages of the storage device within a predetermined time interval from the time point of determining the state of the current foreground application and a second quantity of invalid data pages of the storage device within the predetermined time interval; in response to sending the analysis command, determining whether to execute a host-initiated defragmentation (HID) routine; in response to determining to execute the HID routine, initiating a host-initiated defragmentation (HID) routine to send a request regarding a garbage collection operation to the storage device.

[0013] The steps of determining whether to send an analysis command to the storage device include: sending the analysis command to the storage device based on the first quantity being greater than a first threshold or based on the second quantity being greater than a second threshold, where the second quantity is the sum of the quantity of a first data page, the quantity of a second data page, the quantity of a third data page, and the quantity of a fourth data page, where the first data page represents the data page corresponding to the first discard request that has been sent to the storage device; where the second data page represents the in-place updated data page in the user area of the storage device; where the third data page represents the data page corresponding to the second discard request to be sent to the storage device; where the fourth data page represents the in-place updated data page in the metadata area of the storage device, and the first threshold and the second threshold are the same or different.

[0014] The steps of determining whether to execute the HID routine include: determining to execute the HID routine based on the number of fragments of the storage device being greater than a third threshold or the number of free blocks of the storage device being less than a fourth threshold.

[0015] In the present application, when the current foreground application is idle, the HID is automatically triggered or initiated to improve the space recycling efficiency of the storage device and ensure sufficient free space in the storage device; in addition, in the present application, the automatically triggered HID is used to release a small amount of storage space, which can avoid excessive data migration from affecting the data read / write latency of the foreground application, thereby improving the user experience.

[0016] The steps for determining the state of the current foreground application of the mobile device include: based on a predetermined time having passed since the time point when the most recent request was sent from the current foreground application to the storage device to perform a normal operation on the storage device, determining the state of the current foreground application as the idle state, where the normal operation represents at least one of a read operation and a write operation performed on the storage device.

[0017] The storage device may include a flash memory device, such as a Universal Flash Storage (UFS).

[0018] According to some example embodiments, a mobile device includes: a storage device, a processor configured to: execute computer program instructions that, when executed, cause the processor to determine the state of the foreground application of the mobile device; and based on the state of the foreground application and without considering the state of one or more background applications of the mobile device, release storage space of the storage device.

[0019] In the present application, the storage space of the storage device is released only based on the state of the current foreground application to maintain the storage device, which can avoid the current foreground application and the process of maintaining the storage device from competing for I / O resources, thereby improving the user experience; in addition, compared with the solution of releasing the storage space of the storage device based on both the foreground application and the background applications, the present application can perform the process of maintaining the storage device more efficiently.

[0020] When the computer program instructions are executed, cause the processor to send a current discard request to the storage device based on the state of the foreground application being determined as the idle state, the current discard request including at least one discard command configured to invalidate the physical addresses of the storage device storing invalid data pages, the number of the at least one discard command of the current discard request being based on the number of discard commands of the previous discard request, and when the computer program instructions are executed, cause the processor to determine whether the sending of the previous discard request was interrupted, and in response to determining that the sending of the previous discard request was interrupted, the number of the at least one discard command of the current discard request is a default value.

[0021] When the computer program instructions are executed, cause the processor to send a current discard request to a storage device based on the foreground application's state being determined to be an idle state, the current discard request including at least one discard command configured to invalidate physical addresses of the storage device storing invalid data pages, the number of the at least one discard command of the current discard request being based on the number of discard commands of a previous discard request, and when the computer program instructions are executed, cause the processor to determine whether the sending of the previous discard request is interrupted, and in response to determining that the sending of the previous discard request is not interrupted, the number of the at least one discard command of the current discard request is greater than the number of discard commands of the previous discard request.

[0022] When the computer program instructions are executed, cause the processor to send a current discard request to a storage device based on the foreground application's state being determined to be an idle state, the current discard request including at least one discard command configured to invalidate physical addresses of the storage device storing invalid data pages, the number of the at least one discard command of the current discard request being based on the number of discard commands of a previous discard request, and when the current discard request is the first sent discard request among a plurality of discard requests, the number of the at least one discard command of the current discard request is a default value.

[0023] When the computer program instructions are executed, cause the processor, when the foreground application's state is determined to be an idle state, to determine whether to send an analysis command to the storage device based on a first quantity of written data pages of the storage device within a predetermined time interval from the time point of determining the current foreground application's state and a second quantity of invalid data pages of the storage device within the predetermined time interval; in response to sending the analysis command, determine whether to execute a host-initiated defragmentation (HID) routine; and in response to determining to execute the HID routine, initiate the HID routine to send a request regarding a garbage collection operation to the storage device.

[0024] When the computer program instructions are executed, cause the processor to send an analysis command to the storage device based on the first quantity being greater than a first threshold or the second quantity being greater than a second threshold, the second quantity being the sum of the quantity of a first data page, the quantity of a second data page, the quantity of a third data page, and the quantity of a fourth data page, the first data page representing a data page corresponding to a first discard request that has been sent to the storage device; the second data page representing a data page of in-place update in a user area of the storage device; the third data page representing a data page corresponding to a second discard request to be sent to the storage device; and the fourth data page representing a data page of in-place update in a metadata area of the storage device.

[0025] When the computer program instructions are executed, cause the processor to determine to execute a HID routine based on the number of fragments of the storage device being greater than a third threshold or the number of free blocks of the storage device being less than a fourth threshold.

[0026] When the computer program instructions are executed, cause the processor to determine the state of the foreground application as an idle state based on a predetermined time having passed since a time point when a request is sent from the foreground application to the storage device to perform a normal operation on the storage device, where the normal operation represents at least one of a read operation and a write operation performed on the storage device.

[0027] In the present application, when the foreground application is idle, send a discard request, thereby avoiding an adverse impact on the foreground application caused by sending the discard request.

[0028] In the present application, adjust the number of discard commands of the current discard request based on whether the sending of the previous discard request is interrupted, thereby improving the space recovery efficiency of the storage device.

[0029] Compared with a HID scheme triggered by a user, in the present application, when the current foreground application is idle, automatically trigger a HID for releasing a small amount of storage space to ensure sufficient free space of the storage device, thereby improving the space recovery efficiency of the storage device.

[0030] The present disclosure provides a mobile device, the mobile device including: a flash memory device; and a processor configured to: execute computer program instructions, and when the computer program instructions are executed, cause the processor to: determine that the foreground application is in an idle state when a predetermined time has passed since a time point when a request for performing a read operation or a write operation on the flash memory device is sent from the foreground application of the mobile device; in response to the foreground application being in an idle state, send a current discard request; determine whether there is a previous discard request and whether the sending of the previous discard request is interrupted; determine the number of discard commands of the current discard request based on determining that there is a previous discard request and determining that the sending of the previous discard request is interrupted; and based on the discard commands and regardless of the state of one or more background applications of the mobile device, execute a host-initiated defragmentation routine to release the storage space of the flash memory device.

[0031] According to some example embodiments, there is provided a computer-readable storage medium storing a computer program, where when the computer program is executed by a processor, the above method is implemented.

[0032] Additional aspects and / or advantages of the present disclosure will be partially set forth in the following description, and some will be clear from the description, and / or can be learned through the implementation of various example embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The above and other objects, features, and advantages of the present disclosure will become more apparent from the following detailed description taken in conjunction with the accompanying drawings.

[0034] Figure 1 is a block diagram showing a mobile device according to some example embodiments.

[0035] Figure 2 is a flowchart showing a method for maintaining a storage device of a mobile device according to some example embodiments.

[0036] Figure 3 is a flowchart showing a method for releasing storage space of a storage device according to some example embodiments.

[0037] Figure 4 is a flowchart showing a method for releasing storage space of a storage device according to some example embodiments.

[0038] Figure 5 is a flowchart showing a method for releasing storage space of a storage device according to some example embodiments.

[0039] Figure 6 is a flowchart showing a method for determining a state of a current foreground application of a mobile device according to some example embodiments. Detailed Description

[0040] The following detailed description is provided to assist the reader in obtaining a comprehensive understanding of the methods, devices, and / or systems described herein. However, various changes, modifications, and equivalents of the methods, devices, and / or systems described herein will be apparent after understanding the disclosure of the present application. For example, the order of operations described herein is merely an example, except for operations that must be sent in a specific order, and is not limited to those set forth herein, but may be changed as will be apparent after understanding the disclosure of the present application. In addition, descriptions of features known in the art may be omitted for greater clarity and brevity.

[0041] The features described herein may be implemented in different forms and should not be construed as limited to the examples described herein. Instead, the examples described herein have been provided only to illustrate some of the many possible ways of implementing the methods, devices, and / or systems described herein that will be apparent after understanding the disclosure of the present application.

[0042] The structural or functional description of the examples disclosed herein is only intended for the purpose of describing the examples, and the examples may be implemented in various forms. The examples are not intended to be limiting, but rather are intended that various modifications, equivalents, and alternatives are also covered within the scope of the claims.

[0043] Although the terms "first" or "second" are used to explain various components, the components are not limited to the terms. These terms should only be used to distinguish one component from another. For example, within the scope of the rights according to the concept of the present disclosure, a "first" component may be referred to as a "second" component, or similarly, a "second" component may be referred to as a "first" component.

[0044] It will be understood that when a component is referred to as being "connected to" another component (e.g., electrically, physically, and / or communicatively connected), the component can be directly connected to or coupled to the other component, or there can be an intermediate component.

[0045] As used herein, unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. It should also be understood that when the terms "comprises" and / or "comprising" are used in this specification, it indicates the presence of the stated features, integers, steps, operations, elements, components, or combinations thereof, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or their groups.

[0046] Unless otherwise defined, all terms (including technical or scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the examples belong. It will also be understood that terms, such as those defined in a general dictionary, should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.

[0047] Hereinafter, examples will be described in detail with reference to the accompanying drawings. Regarding the reference numerals assigned to the elements in the drawings, it should be noted that the same elements will be denoted by the same reference numerals, and redundant descriptions thereof will be omitted.

[0048] Figure 1 is a block diagram showing a mobile device according to some example embodiments.

[0049] The mobile device 1 according to various example embodiments of the present disclosure may include, for example, a mobile phone, a smartphone, a tablet personal computer (PC), a game console, etc. However, the embodiments are not limited thereto, and the mobile device 1 according to the present disclosure can be other types of electronic devices.

[0050] As Figure 1 shown, the mobile device 1 may include a processor 11 and a storage device 12.

[0051] According to an example embodiment, the processor 11 may control the overall operation of the mobile device 1. For example, the processor 11 may include a central processing unit (CPU). For example, the processor 11 may include a single processing core or may include multiple processing cores (multi-core). The processor 11 may process or execute programs and / or data stored in the storage device 12. For example, the processor 11 may control the mobile device 1 to execute applications stored thereon.

[0052] According to an example embodiment, the storage device 12 may include a non-volatile memory device. For example, the storage device 12 may include a storage device (e.g., Universal Flash Storage (UFS)) that supports host initiated defrag (HID) routines. However, the example is not limited thereto, and the storage device 12 may include other storage devices.

[0053] Figure 2 is a flowchart showing a method for maintaining a storage device of a mobile device according to some example embodiments.

[0054] As Figure 2 shown, in operation S110, the processor 11 may determine the state of the current foreground application of the mobile device 1 (e.g., the foreground application at the current moment).

[0055] According to an example embodiment, the current foreground application of the mobile device 1 may be an application that performs operations based on user interaction with the mobile device 1 (such as a game application or a messaging application). For example, when the mobile device 1 is not locked, the current foreground application of the mobile device 1 may be the application displayed on the screen of the mobile device 1; when the mobile device 1 is locked, the current foreground application of the mobile device 1 may be the application displayed on the screen before the mobile device 1 is locked. According to an example embodiment, the number of current foreground applications of the mobile device 1 may be one or more.

[0056] In operation S120, the processor 11 may release the storage space of the storage device 12 based on the state of the current foreground application without considering the current background application of the mobile device 1 or the state of the current background application of the mobile device 1. As used herein, a "background application" is an application that performs operations without considering user interaction with the mobile device 1 or without user interaction with the mobile device 1, such as an application for updating an operating system.

[0057] According to an example embodiment, based on the state of the current foreground application being determined to be an idle state, the processor 11 may release the storage space of the storage device 12. Releasing the storage space includes, but is not limited to, deleting cached data and / or temporary files, uninstalling unused or unnecessary data, and releasing unused data structures, as well as other known storage space release operations.

[0058] According to an example embodiment, when a predetermined time has passed since the time point at which the most recent (or last) request for performing a normal operation on the storage device 12 was sent from the current foreground application to the storage device 12, the processor 11 may determine the state of the current foreground application as an idle state.

[0059] For example, the normal operation may represent at least one of a read operation and a write operation performed on the storage device 12.

[0060] According to another embodiment, the processor 11 may also release the storage space of the storage device 12 based on whether the storage device 12 is in an idle state.

[0061] For example, the processor 11 may determine whether the storage device 12 is in an idle state based on the discard command to be sent to the storage device 12 and the number of discard commands (commands for releasing the storage space of the storage device) that have been sent to the storage device 12 but not processed by the storage device 12.

[0062] In the present application, releasing the storage space of the storage device to maintain the storage device based only on the state of the current foreground application can avoid the current foreground application competing with the process of maintaining the storage device for I / O resources, thereby improving the user experience; in addition, compared with the solution of releasing the storage space of the storage device based on both the foreground application and the background application, the present application can perform the process of maintaining the storage device more efficiently.

[0063] Figure 3 is a flowchart showing a method of releasing the storage space of a storage device according to some example embodiments.

[0064] As Figure 3 shown, in operation S210, the processor 11 may determine whether the state of the current foreground application is an idle state.

[0065] When the state of the current foreground application is determined to be an idle state (Yes in operation S210), in operation S220, the processor 11 may send the current discard request to the storage device 12 to invalidate at least one of the physical addresses storing invalid data pages in the storage device 12.

[0066] According to an example embodiment, the current discard request may include at least one discard command from a set of discard commands (e.g., the current set of discard commands) for invalidating the physical addresses storing invalid data pages (e.g., current invalid data pages) in the storage device 12. In one example, the processor 11 may perform a host-initiated defragmentation (HID) routine based on at least one discard command of the current discard request and without considering the state of one or more background applications of the mobile device 1 to release the storage space of the storage device 12.

[0067] According to an example embodiment, the processor 11 may determine the number of at least one discard command of the current discard request based on the number of discard commands of the previous discard request.

[0068] For example, the previous discard request may represent a discard request sent to the storage device 12 before sending the current discard request (e.g., when the previous foreground application is idle). According to an example embodiment, the previous foreground application and the current foreground application may be the same application or different applications.

[0069] According to an example embodiment, if the transmission of the previous discard request is interrupted, the number of at least one discard command of the current discard request is a default value; if the transmission of the previous discard request is not interrupted, the number of at least one discard command of the current discard request is greater than the number of discard commands of the previous discard request. When the current discard request is the first discard request sent among all discard requests, the number of at least one discard command of the current discard request is a default value.

[0070] For example, at least one discard command of the current discard request is at least one discard command in the discard command set that invalidates the most physical addresses. The process of sending a discard request will be described in detail with reference to Figure 4 The process of sending a discard request will be described in detail with reference to

[0071] In addition, when the state of the current foreground application is determined to be the idle state (Yes in operation S210), in operation S230, the processor 11 may trigger a host-initiated defragmentation (HID) routine for releasing a storage space of the storage device 12 that is less than a predetermined size (e.g., 4 GB, but not limited thereto).

[0072] According to an example embodiment, the processor 11 may determine whether to send an analysis command to the storage device 12 based on a first number of written data pages and a second number of invalid data pages of the storage device within a predetermined time interval from the time point of determining the state of the current foreground application (e.g., within a predetermined time interval before or after the time point of determining the state of the current foreground application).

[0073] For example, based on the first quantity being greater than the first threshold or based on the second quantity being greater than the second threshold, the processor 11 may send an analysis command to the storage device 12. For example, the second quantity may be the sum of the quantity of the first data page, the quantity of the second data page, the quantity of the third data page, and the quantity of the fourth data page. For example, the first data page may represent a data page corresponding to a discard request that has been sent to the storage device 12 (e.g., an invalid data page); the second data page may represent a data page that is updated in place in the user area of the storage device 12 (e.g., a data page updated at the current location of the storage device 12, rather than creating and saving a version of the data page at another location in the storage device 12); the third data page may represent a data page corresponding to a discard request to be sent to the storage device 12 (e.g., an invalid data page); the fourth data page may represent a data page that is updated in place in the metadata area of the storage device 12. In one example, the first threshold and the second threshold may be the same or different.

[0074] According to an example embodiment, when sending an analysis command to the storage device 12, the storage device 12 may determine whether a defragmentation routine needs to be executed in response to the analysis command.

[0075] According to an example embodiment, based on the number of fragments of the storage device 12 being greater than a third threshold or the number of free blocks of the storage device 12 being less than a fourth threshold, the storage device 12 may determine that a defragmentation routine needs to be executed.

[0076] According to an example embodiment, when it is determined that defragmentation needs to be performed, the processor 11 may trigger or initiate a HID to send a request regarding a garbage collection operation to the storage device 12, so as to release a storage space of the storage device 12 that is smaller than a predetermined size. The process of executing the HID will be described in detail with reference to Figure 5 Execute the process of the HID in detail.

[0077] When the state of the current foreground application is determined to be a busy state (No in operation S210), the process may proceed to operation S110.

[0078] According to an example embodiment, the processor 11 may execute operation S220 and operation S230 in parallel or sequentially, or the processor 11 may execute only one of operation S220 and operation S230.

[0079] In this application, when the foreground application is idle, a discard request is sent, thereby avoiding adverse effects on the foreground application caused by sending the discard request. In this application, the number of discard commands of the current discard request is adjusted based on whether the sending of the previous discard request is interrupted, thereby improving the space recovery efficiency of the storage device.

[0080] In the present application, when the current foreground application is idle, the HID is automatically triggered or initiated to improve the space recycling efficiency of the storage device and ensure sufficient free space in the storage device; in addition, in the present application, the automatically triggered / initiated HID is used to release a small amount of storage space, which can avoid excessive data migration from affecting the data read / write latency of the foreground application, thereby improving the user experience.

[0081] Figure 4 is a flowchart showing a method for releasing storage space of a storage device according to some example embodiments.

[0082] As Figure 4 shown, in operation S310, the processor 11 may determine whether the current discard request CDQ is the first discard request sent.

[0083] When the current discard request CDQ is the first discard request sent (Yes in operation S310), in operation S320, the processor 11 may determine the number of discard commands CDN of the current discard request CDQ as the first default value D1 (for example, D1 is an integer greater than or equal to 1).

[0084] When the current discard request CDQ is not the first discard request sent (No in operation S310), in operation S330, the processor 11 may determine whether the transmission of the previous discard request LDQ was interrupted.

[0085] When the transmission of the previous discard request LDQ was interrupted (Yes in operation S330), in operation S340, the processor 11 may determine the number of discard commands CDN of the current discard request CDQ as the first default value D1.

[0086] When the transmission of the previous discard request LDQ was not interrupted (No in operation S330), in operation S350, the processor 11 may determine the number of discard commands CDN of the current discard request CDQ as greater than the number of discard commands LDN of the previous discard request LDQ and less than the second default value D2 (for example, D2 is an integer greater than D1).

[0087] In operation S360, the processor 11 may select CDN discard commands from the set of discard commands that invalidate the most physical addresses (for example, the first CDN discard commands that invalidate the most physical addresses).

[0088] Figure 5 is a flowchart showing a method for releasing storage space of a storage device according to some example embodiments.

[0089] As Figure 5As shown, in operation S410, the processor 11 may determine whether the first quantity of the written data pages of the storage device 12 within a predetermined time interval from the time point when the state of the current foreground application is determined is greater than the first threshold or whether the second quantity of the invalid data pages of the storage device 12 within the predetermined time interval is greater than the second threshold.

[0090] When the first quantity is less than or equal to the first threshold and the second quantity is less than or equal to the second threshold (No in operation S410), the process may proceed to operation S410.

[0091] When the first quantity is greater than the first threshold or the second quantity is greater than the second threshold (Yes in operation S410), in operation S420, the processor 11 may send an analysis command to the storage device 12.

[0092] In operation S430, the storage device 12 may determine whether the quantity of the fragments of the storage device 12 is greater than the third threshold or whether the quantity of the free blocks of the storage device 12 is less than the fourth threshold based on or in response to the analysis command.

[0093] When the quantity of the fragments of the storage device 12 is less than or equal to the third threshold and the quantity of the free blocks of the storage device 12 is greater than or equal to the fourth threshold (No in operation S430), the process may proceed to operation S410.

[0094] When the quantity of the fragments of the storage device 12 is greater than the third threshold or the quantity of the free blocks of the storage device 12 is less than the fourth threshold (Yes in operation S430), in operation S440, the processor 11 may determine that a defragmentation routine needs to be executed (e.g., trigger or initiate HID), and send a request for a garbage collection operation to the storage device 12, and the garbage collection operation is performed on a small amount (e.g., less than a predetermined size) of the storage space of the storage device 12.

[0095] Figure 6 FIG. is a flowchart showing a method for determining the state of the current foreground application of a mobile device according to some example embodiments.

[0096] As Figure 6 shown, in operation S510, the processor 11 may determine the user identifier (UID) of the current foreground application.

[0097] According to an example embodiment, the processor 11 may use the Java Native Interface (JNI) method and the system call (Syscall) method to determine the UID of the current foreground application.

[0098] For example, the UID of the current foreground application may be passed to the processor 11 (e.g., the kernel of the processor 11) through the JNI method and the Syscall method.

[0099] However, the examples are not limited to this, and other known methods can also be used to determine the UID of the current foreground application.

[0100] In operation S520, the processor 11 may determine the state of the current foreground application corresponding to the determined UID.

[0101] For example, when a predetermined time has passed since the time point when the most recent (or last) request for performing a normal operation on the storage device 12 was sent from the current foreground application to the storage device 12, the processor 11 may determine the state of the current foreground application as an idle state.

[0102] The devices, units, modules, and other components described herein are implemented by hardware components. Examples of hardware components that can be used to perform the operations described in this application include, where appropriate: controllers, sensors, generators, drivers, memories, comparators, arithmetic logic units, adders, subtractors, multipliers, dividers, integrators, and any other electronic components configured to perform the operations described in this application. In other examples, one or more of the hardware components that perform the operations described in this application are implemented by computing hardware (e.g., by one or more processors or computers). A processor or computer can be implemented by one or more processing elements (such as logic gate arrays, controllers, and arithmetic logic units, digital signal processors, microcomputers, programmable logic controllers, field programmable gate arrays, programmable logic arrays, microprocessors, or any other device or combination of devices configured to respond and execute instructions in a defined manner to achieve a desired result). In one example, a processor or computer includes or is connected to one or more memories that store instructions or software executed by the processor or computer. The hardware components implemented by the processor or computer can execute instructions or software (such as an operating system (OS) and one or more software applications running on the OS) for performing the operations described in this application. The hardware components can also access, manipulate, process, create, and store data pages in response to the execution of the instructions or software. For the sake of brevity, the singular terms "processor" or "computer" may be used in the description of the examples described in this application, but in other examples, multiple processors or computers may be used, or a processor or computer may include multiple processing elements, or multiple types of processing elements, or both. For example, a single hardware component, or two or more hardware components, can be implemented by a single processor, or two or more processors, or a processor and a controller. One or more hardware components can be implemented by one or more processors, or a processor and a controller, and one or more other hardware components can be implemented by one or more other processors, or another processor and another controller. One or more processors, or a processor and a controller, can implement a single hardware component, or two or more hardware components. The hardware components can have any one or more of different processing configurations. Examples of different processing configurations include: single processor, independent processors, parallel processors, single instruction single data page (SISD) multiprocessing, single instruction multiple data page (SIMD) multiprocessing, multiple instruction single data page (MISD) multiprocessing, and multiple instruction multiple data page (MIMD) multiprocessing.

[0103] The method of performing the operations described in this application is performed by computing hardware (e.g., by one or more processors or computers), which is implemented to execute instructions or software as described above to perform the operations performed by the method described in this application. For example, a single operation, or two or more operations, may be performed by a single processor, or two or more processors, or a processor and a controller. One or more operations may be performed by one or more processors, or a processor and a controller, and one or more other operations may be performed by one or more other processors, or another processor and another controller. One or more processors, or a processor and a controller, may perform a single operation, or two or more operations.

[0104] Instructions or software for controlling a processor or computer to implement the hardware components and perform the method as described above may be written as a computer program, code segment, instruction, or any combination thereof, to individually or jointly direct or configure the processor or computer to operate as a machine or special-purpose computer to perform the operations performed by the hardware components and method as described above. In one example, the instructions or software include machine code (such as machine code generated by a compiler) that is directly executed by the processor or computer. In another example, the instructions or software include high-level code that is executed by the processor or computer using an interpreter. A person of ordinary skill in the art can easily write the instructions or software based on the block diagrams and flowcharts shown in the drawings and the corresponding descriptions in the specification, which disclose algorithms for performing the operations performed by the hardware components and method as described above.

[0105] Instructions or software for controlling a processor or computer to implement a hardware component and perform a method as described above (e.g., as shown in the above flowcharts and / or block diagrams) and any associated data pages, data page files, and data page structures are recorded, stored, or fixed in one or more non-transitory computer-readable storage media, or are recorded, stored, or fixed on one or more non-transitory computer-readable storage media. Examples of non-transitory computer-readable storage media include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disc storage devices, hard disk drives (HDD), solid state drives (SSD), flash memory, cartridge memory (such as, multimedia card or micro card (e.g., Secure Digital (SD) or Extreme Digital (XD))), magnetic tape, floppy disk, magneto-optical data page storage device, optical data page storage device, hard disk, solid state disk, and any other device, any other device being configured to store instructions or software and any associated data pages, data page files, and data page structures in a non-transitory manner and provide the instructions or software and any associated data pages, data page files, and data page structures to a processor or computer such that the processor or computer can execute the instructions.

[0106] The present disclosure is described with reference to the flowcharts and / or block diagram illustrations of methods, systems, and apparatuses according to exemplary embodiments of the invention. It will be understood that each block of the flowcharts and / or block diagram illustrations, and combinations of blocks in the flowcharts and / or block diagram illustrations, can be implemented by computer program instructions and / or hardware operations. These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing device for generating a machine, such that the instructions executed via the processor of the computer or other programmable data processing device are configured to implement the functions specified in the flowchart and / or one or more block diagrams.

[0107] The computer program instructions can also be loaded onto a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to generate a computer-implemented process, such that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in the flowchart and / or one or more block diagrams.

[0108] Although the present disclosure has been specifically shown and described with reference to its exemplary embodiments, those skilled in the art should understand that various changes in form and detail may be made thereto without departing from the scope of the present disclosure as defined by the claims.

Claims

1. A method for maintaining a storage device of a mobile device, comprising: The computer program instructions are executed by at least one processor to perform operations including: Determine the state of the foreground application of the mobile device; Storage space of a storage device is freed up based on a state of a foreground application and without regard to a state of one or more background applications of the mobile device.

2. The method according to claim 1, wherein: The step of releasing the storage space of the storage device includes: based on the state of the foreground application being determined to be an idle state, sending the current discard request to the storage device, The current discard request includes at least one discard command configured to invalidate a physical address of the storage device storing an invalid data page.

3. The method according to claim 2, wherein: The number of the at least one discard command of the current discard request is based on the number of discard commands of the previous discard request.

4. The method according to claim 3, wherein: The operations include determining whether the sending of a previous discard request was interrupted, and In response to determining that the sending of the previous discard request is interrupted, the number of the at least one discard command of the current discard request is a default value.

5. The method according to claim 3, wherein: The operations include determining whether the sending of a previous discard request was interrupted, and In response to determining that the sending of the previous discard request is not interrupted, the number of the at least one discard command of the current discard request is greater than the number of discard commands of the previous discard request.

6. The method according to claim 3, wherein: Based on the fact that the current discard request is the discard request sent for the first time among the multiple discard requests, the number of the at least one discard command of the current discard request is a default value.

7. The method according to claim 3, wherein: The at least one discard command of the current discard request is configured to invalidate the most physical addresses.

8. The method according to claim 1, wherein: The step of releasing the storage space of the storage device includes: based on the state of the foreground application being determined to be an idle state: determining whether to send an analysis command to the storage device based on a first number of written data pages of the storage device within a predetermined time interval from a time point in which a state of a current foreground application is determined and a second number of invalid data pages of the storage device within the predetermined time interval; In response to sending the analysis command, determining whether to perform a host-initiated defragmentation routine; In response to determining to perform a host-initiated defragmentation routine, a host-initiated defragmentation routine is initiated to send a request for a garbage collection operation to the storage device.

9. The method according to claim 8, wherein: The step of determining whether to send the analysis command to the storage device includes: sending the analysis command to the storage device based on the first number being greater than a first threshold or the second number being greater than a second threshold, The second number is the sum of the number of the first data pages, the number of the second data pages, the number of the third data pages, and the number of the fourth data pages, The first data page represents a data page corresponding to a first discard request that has been sent to the storage device, The second data page represents an in-place updated data page in the user area of ​​the storage device, The third data page represents a data page corresponding to a second discard request to be sent to the storage device, The fourth data page represents an updated-in-place data page in the meta area of ​​the storage device.

10. The method according to claim 8, wherein: The step of determining whether to execute the host-initiated defragmentation routine includes: determining to execute the host-initiated defragmentation routine based on the number of fragments of the storage device being greater than a third threshold or the number of free blocks of the storage device being less than a fourth threshold.

11. The method according to claim 1, wherein: The steps for determining the state of the foreground application of the mobile device include: determining the state of the foreground application to be an idle state based on a predetermined time elapsed from a time point when the foreground application sends a request to the storage device to perform a normal operation on the storage device, The normal operation refers to at least one of a read operation and a write operation performed on the storage device.

12. A mobile device, comprising: Storage devices, A processor is configured to: execute computer program instructions, which, when executed, cause the processor to determine the state of a foreground application of the mobile device; and release storage space of a storage device based on the state of the foreground application and without considering the state of one or more background applications of the mobile device.

13. A mobile device, comprising: Flash memory device; as well as, A processor configured to: execute computer program instructions, which, when executed, cause the processor to: determining that the foreground application is in an idle state based on a predetermined time elapsed from a time point when the foreground application of the mobile device sends a request for performing a read operation or a write operation on the flash memory device; In response to the foreground application being in an idle state, sending a current discard request; Determining whether there is a previous discard request and whether the sending of the previous discard request is interrupted; determining a number of discard commands for a current discard request based on determining that there is a previous discard request and determining that sending of the previous discard request is interrupted; Based on the discard command and without regard to a state of one or more background applications of the mobile device, a host-initiated defragmentation routine is performed to free up storage space of the flash memory device.