Garbage recycling method, electronic equipment and storage medium
By manually starting the garbage collection function on the operating system side and setting read and write channels and nodes, the problem of single and performance impact of the storage device garbage collection function triggered by the storage device is solved, and the independent controllable and efficient garbage collection and processing of the storage device is realized.
Patent Information
- Application Number
- CN202311871822.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-01
AI Technical Summary
In the prior art, the garbage collection function of the storage device is triggered in a single way, and when the storage device is insufficient, the garbage collection and access request are carried out simultaneously, which seriously affects the performance of the storage device.
The operating system sends the garbage collection function to the storage device. The storage device performs garbage collection processing when the remaining available storage space is less than or equal to the preset storage space target value, and sets read and write channels and nodes to improve startup efficiency and avoid interference.
The garbage collection function is realized independently and controllable, avoiding garbage collection and access requests simultaneously, reducing the adverse impact on the performance of the storage device, and improving the efficiency and performance of garbage collection and processing.
Smart Images

Figure CN120233941A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of storage technology, including but not limited to a garbage collection method, an electronic device, and a storage medium. Background Art
[0002] Related storage devices of electronic devices, such as embedded multi media cards (EMMC), universal flash storage (UFS), etc., have a garbage collection function. This function can process fragmented data generated by electronic devices to prevent the read and write speeds of storage devices from decreasing rapidly due to a large amount of fragmented data.
[0003] However, in the prior art, triggering the storage device to process fragmented data usually occurs when the operating system accesses the storage device and detects that the storage space of the storage device is insufficient. Then the storage device starts to process the fragmented data, and the triggering method is relatively single. Summary of the Invention
[0004] In view of this, the embodiments of the present application provide a garbage collection method, an electronic device, and a storage medium. The garbage collection method, electronic device, and storage medium provided by the embodiments of the present application are implemented as follows:
[0005] A garbage collection method provided by the embodiments of the present application is applied to an electronic device. The electronic device includes an operating system and a storage device. The method includes:
[0006] The operating system sends an enabling instruction for the garbage collection function to the storage device;
[0007] The storage device responds to the enabling instruction for the garbage collection function and obtains a target value of the preset storage space;
[0008] When the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space, the storage device performs garbage collection processing on the data in the storage device.
[0009] In the embodiments of the present application, a method for manually starting the garbage collection function at the operating system end is provided, realizing the autonomous control of the garbage collection function at the operating system end; and it can effectively avoid the simultaneous occurrence of garbage collection processing and access requests, reducing the adverse impact on the performance of the storage device.
[0010] In some embodiments, before the operating system sends an enabling instruction for the garbage collection function to the storage device, the method further includes:
[0011] The operating system sets a target read / write channel between it and the storage device;
[0012] The operating system sends an instruction to enable the garbage collection function to the storage device, including:
[0013] The operating system sends the instruction to enable the garbage collection function to the storage device through the target read / write channel.
[0014] In this embodiment, by setting the read / write channel between the operating system and the storage device, not only can the startup efficiency of the garbage collection function be improved, but also other communication operations between the operating system and the storage device can be avoided from interfering with the operation of the garbage collection function.
[0015] In some embodiments, the operating system sets a target read / write channel between it and the storage device, including:
[0016] The operating system sends a communication configuration command to the storage device, and the communication configuration command includes read / write channel configuration parameters;
[0017] The storage device sets the target read / write channel according to the read / write channel configuration parameters.
[0018] In this embodiment, by configuring the read / write channel with the read / write channel configuration parameters, the operating system and the storage device can correctly read and set the relevant parameters of the garbage collection function.
[0019] In some embodiments, after the storage device sets the target read / write channel according to the read / write channel configuration parameters and before the operating system sends an instruction to enable the garbage collection function to the storage device, the method further includes:
[0020] The operating system verifies the target read / write channel.
[0021] In this embodiment, by further verifying the read / write channel, it can be timely known whether the read / write channel is successfully set, so as to avoid affecting the startup and operation of the subsequent garbage collection function.
[0022] In some embodiments, the operating system verifies the target read / write channel, including:
[0023] The operating system sends a storage instruction to the storage device through the target read / write channel, and the storage instruction is used to store verification data;
[0024] The storage device stores the verification data in a target area of the storage device according to the storage instruction;
[0025] The storage device reads data from the target area and sends the read data to the operating system through the target read / write channel;
[0026] The operating system receives the read data and, when the verified data is the same as the read data, completes the verification of the target read / write path.
[0027] In this embodiment, by verifying the validity of the read / write channel through a storage instruction, it is possible to accurately and quickly determine whether the read / write channel is successfully set.
[0028] In some embodiments, before the operating system sends a communication configuration command to the storage device, the method further includes:
[0029] The operating system sends an authentication command to the storage device, and the authentication command is used to query whether the storage device has a garbage collection function;
[0030] The storage device receives the authentication command and queries according to the authentication command and sends a query result to the operating system;
[0031] The operating system receives the query result and, when the query result indicates that the storage device has the garbage collection function, completes the authentication of the storage device.
[0032] In this embodiment, by authenticating whether the storage device has a garbage collection function before starting to set the read / write channel, it is possible to establish the trust of the operating system in the storage device and avoid invalid read channel setting operations between the operating system and the storage device.
[0033] In some embodiments, the operating system is provided with a target setting node. Before the operating system sends an instruction to enable the garbage collection function to the storage device, the method further includes:
[0034] The operating system sets the preset storage space target value through the target setting node.
[0035] In this embodiment, by setting the node, it is possible to simplify the setting operation of the parameters related to the garbage collection function, and it is also possible to realize the centralized deployment and management of the parameters related to the garbage collection function to improve the efficiency and performance of the garbage collection process.
[0036] In some embodiments, the method further includes:
[0037] The operating system generates a setting instruction including a warning storage space value through the target setting node;
[0038] The operating system sends the setting instruction to the storage device through the target read / write channel;
[0039] The storage device responds to the setting instruction and sets the early warning storage space value.
[0040] In this embodiment, the early warning storage space value can be preset. Even if the operating system does not actively send a start instruction for the garbage collection function, the storage device can start the garbage collection function based on the size relationship between the early warning storage space value and the remaining storage space of the storage device.
[0041] In some embodiments, after the storage device responds to the setting instruction and sets the early warning storage space value, the method further includes:
[0042] The storage device detects the remaining storage space of the storage device at a preset time interval;
[0043] When the remaining storage space is less than or equal to the early warning storage space value, the storage device sends an early warning message to the operating system through the target read / write channel, and the early warning message is used to prompt the operating system to send an opening instruction for the garbage collection function to the storage device.
[0044] In this embodiment, by comparing the early warning storage space value with the remaining storage space of the storage device, the storage device can actively start the garbage collection function, effectively avoiding adverse effects on the performance of the storage device due to insufficient storage space of the storage device.
[0045] In some embodiments, the operating system is further provided with a target read node, and the method further includes:
[0046] The operating system generates a read instruction through the target read node, and the read instruction is used to read the running state parameters of the garbage collection function and the value of the remaining available storage space;
[0047] The operating system sends the read instruction to the storage device through the target read / write channel;
[0048] The storage device responds to the read instruction and sends the running state parameters of the garbage collection function and the value of the remaining available storage space to the operating system through the target read / write channel.
[0049] In this embodiment, the operating system can quickly and accurately obtain the size of the remaining space of the storage device and the running state of the garbage collection function through the read node, and the user can understand the current performance of the storage device on the operating system side.
[0050] An electronic device provided by an embodiment of the present application, the electronic device includes an operating system and a storage device, wherein:
[0051] The operating system is used to send an instruction to enable the garbage collection function to the storage device;
[0052] The storage device is used to obtain a preset storage space target value in response to the instruction to enable the garbage collection function;
[0053] The storage device is further used to perform garbage collection processing on the data in the storage device when the remaining available storage space of the storage device is less than or equal to the preset storage space target value.
[0054] An electronic device provided by an embodiment of the present application includes a memory and a processor. The memory stores a computer program that can run on the processor, and when the processor executes the program, the method described in the embodiment of the present application is implemented.
[0055] A computer-readable storage medium provided by an embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the method provided by the embodiment of the present application is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to explain the technical solutions of the present application.
[0057] Figure 1 It is a schematic flowchart of a garbage collection processing method provided by an embodiment of the present application;
[0058] Figure 2 It is a schematic flowchart of another garbage collection processing method provided by an embodiment of the present application;
[0059] Figure 3 It is a schematic flowchart of yet another garbage collection processing method provided by an embodiment of the present application;
[0060] Figure 4 It is a schematic flowchart of still another garbage collection processing method provided by an embodiment of the present application;
[0061] Figure 5 It is a schematic diagram of the test results of the impact of the garbage collection processing method in the prior art and the garbage collection processing method provided by the present application on the performance of the storage device;
[0062] Figure 6 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0063] Figure 7 It is a schematic structural diagram of another electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0064] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will further describe the specific technical solutions of this application in detail with reference to the accompanying drawings in the embodiments of this application. The following embodiments are used to illustrate this application but are not intended to limit the scope of this application.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0066] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.
[0067] It should be noted that the terms "first / second / third" involved in the embodiments of this application are used to distinguish similar or different objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged in a specific order or sequence when permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0068] After long-term operation, an electronic device will accumulate a large amount of fragmented data. Fragmented data refers to the garbage data generated during the operation of the electronic device and the data that is scattered and stored in discontinuous positions of the storage device. The garbage data will occupy the storage space of the relevant storage device of the electronic device, and the discontinuous stored data will cause the storage device to consume a large amount of addressing time during read and write operations, reducing the read and write speed of the storage device, and thus reducing the operating speed of the electronic device.
[0069] Currently, the firmware inside the relevant storage devices (such as EMMC, UFS, etc.) of electronic devices has a garbage collection (GC) function, which can process the fragmented data generated by the electronic device. For example, it can clear some of the fragmented data whose storage time exceeds a preset duration, and can also re-store the fragmented data stored discontinuously in continuous positions to reduce data dispersion, so as to avoid a rapid reduction in the read and write speed of the storage device caused by a large amount of fragmented data.
[0070] However, in the prior art, the triggering conditions for starting the garbage collection function are usually preset. The triggering condition is that when the operating system sends an access request to the storage device, if it is detected that the storage space of the storage device is insufficient, the garbage collection function of the storage device is triggered to start. This way of triggering the garbage collection function is relatively single, and in this case, the garbage collection process of fragmented data by the storage device and the access request are carried out simultaneously, which will seriously affect the performance of the storage device. For example, it will cause lags in the process of accessing the storage device.
[0071] Therefore, a new control method for the garbage collection function is proposed to avoid the simultaneous execution of the garbage collection process and the access request, and reduce the adverse impact on the performance of the storage device, which has become an urgent technical problem to be solved at present.
[0072] In view of this, the embodiments of the present application provide a garbage collection method, an electronic device, and a storage medium, which are applied to an electronic device. The electronic device includes an operating system and a storage device. The method includes: the operating system sends an activation instruction for the garbage collection function to the storage device; the storage device responds to the activation instruction for the garbage collection function and obtains a target value of a preset storage space; the storage device performs garbage collection processing on the data in the storage device when the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space.
[0073] In order to make the purpose and technical solutions of the present application clearer and more intuitive, the garbage collection method disclosed in the present application will be described in detail below with reference to the accompanying drawings.
[0074] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a garbage collection method disclosed in an embodiment of the present application. As Figure 1 shown, the method is applied to an electronic device.
[0075] It should be understood that the electronic device involved in the embodiments of the present application may be a mobile phone, a tablet computer, a notebook computer, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a headset, a terminal in industrial control, a terminal in self-driving, a personal digital assistant (PDA), etc. The embodiments of the present application are not limited thereto.
[0076] In an embodiment of the present application, the electronic device includes an operating system and a storage device.
[0077] It should be noted that the operating system of the electronic device in the embodiment of the present application may be an Android operating system, an iOS operating system, a Linux operating system, a Windows operating system, a Mac operating system, a Chrome OS operating system, a Unix operating system, etc., and the embodiment of the present application does not limit this.
[0078] It should also be noted that the storage device of the electronic device in the embodiment of the present application is a storage device with a garbage collection function (such as, EMMC, UFS, etc.), and the electronic device includes at least one storage device with a garbage collection function. The operating system may send an instruction to enable the garbage collection function to the storage device, and the storage device may receive the instruction to enable the garbage collection function and perform garbage collection processing according to the instruction. In addition, the operating system may also send a communication configuration command, a storage instruction, an authentication command, a setting instruction, and a reading instruction to the storage device. Specific implementation manners of the communication configuration command, the storage instruction, the authentication command, the setting instruction, and the reading instruction will be described in detail in the following embodiments and will not be elaborated here. The operating system may also send an access request to the storage device to access software programs and modules of the storage device, so as to execute various functional applications and data processing of the electronic device. The storage device may receive the instruction to enable the garbage collection function, the communication configuration command, the storage instruction, the authentication command, the setting instruction, the reading instruction, and the access request sent by the operating system and perform corresponding operations. Therefore, two-way communication may be performed between the operating system and the storage device. The storage device mainly includes a storage program area and a storage data area. Among them, the storage program area may store software tools with operating functions, application programs required for at least one function, etc.; the storage data area may store any kind of data generated during the use of the electronic device.
[0079] It should also be noted that in addition to the operating system and the storage device, the electronic device in the embodiment of the present application may further include more modules, or combine some modules, or split some modules. Other modules may be implemented in hardware, software, or a combination of software and hardware, and the present application does not limit this here.
[0080] Step 101, the operating system sends an instruction to enable the garbage collection function to the storage device.
[0081] In the embodiments of the present application, when the garbage collection function of the storage device is not started, it is usually in a closed state by default. Developers can set the enable switch of the garbage collection function, the enable node or interface of the garbage collection function, etc. to implement the operating system sending an enable instruction for the garbage collection function to the storage device. The present application does not limit the enabling method of the garbage collection function.
[0082] It should be noted that the operating system can automatically send an enable instruction for the garbage collection function to the storage device according to the setting, or the developer can trigger the operating system to send an enable instruction for the garbage collection function to the storage device through manual operation on the operating system side. The present application does not limit the triggering method of the operating system sending an enable instruction for the garbage collection function to the storage device.
[0083] As an example, in order to implement the case where the operating system automatically sends an enable instruction for the garbage collection function to the storage device, the developer can preset a startup time interval in advance. The operating system can call the enable node or interface of the garbage collection function according to the preset startup time interval, automatically generate an enable instruction for the garbage collection function, and send an enable instruction for the garbage collection function to the storage device.
[0084] As another example, in the case where the developer triggers the operating system to send an enable instruction for the garbage collection function to the storage device through manual operation on the operating system side, the developer can start the enable switch of the garbage collection function on the operating system side, so that the operating system generates an enable instruction for the garbage collection function and sends an enable instruction for the garbage collection function to the storage device.
[0085] In the embodiments of the present application, the operating system can send an enable instruction for the garbage collection function to the storage device, so that the storage device performs an operation of garbage collection processing according to the enable instruction for the garbage collection function. The enable instruction for the garbage collection function at least includes an enable parameter of the garbage collection function and a preset storage space target value. Among them, the enable parameter indicates that the storage device needs to enable the garbage collection function, and the preset storage space target value indicates the storage space that the operating system applies to the storage device to expect to be sorted out when starting the garbage collection function.
[0086] It should be noted that the developer can manually preset the preset storage space target value on the operating system side, or it can be the storage space target value predicted by the operating system according to the historical access requests sent by the operating system to the storage device. The present application does not limit the size and determination method of the preset storage space target value. Those skilled in the art can set a reasonable preset storage space target value according to the requirements.
[0087] It should also be noted that since the electronic device includes at least one storage device with a garbage collection function, when the operating system sends an activation instruction for the garbage collection function to the storage device, it can be set to send the activation instruction for the garbage collection function to only one target storage device, or it can be set to send the activation instruction for the garbage collection function to any one or more storage devices. This application does not make any restrictions in this regard, and those skilled in the art can set the storage device to which the operating system sends the activation instruction for the garbage collection function according to their needs.
[0088] Step 102: The storage device responds to the activation instruction for the garbage collection function and obtains the target value of the preset storage space.
[0089] In the embodiment of the present application, the storage device receives and responds to the activation instruction for the garbage collection function sent by the operating system, and obtains the target value of the preset storage space according to the activation instruction for the garbage collection function.
[0090] Step 103: When the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space, the storage device performs garbage collection processing on the data in the storage device.
[0091] In the embodiment of the present application, after the storage device responds to the activation instruction for the garbage collection function sent by the operating system and reads the target value of the preset storage space. The storage device obtains the size of its remaining available storage space, and compares the size of the remaining available storage space with the target value of the preset storage space to obtain a comparison result. The storage device determines whether to perform garbage collection processing on the data in the storage device through the comparison result, which specifically includes the following two situations:
[0092] Situation 1: The storage device determines whether the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space. When the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space, the storage device performs garbage collection processing on the data in the storage device.
[0093] It should be noted that Situation 1 means that the remaining available storage space of the current storage device is not enough to store data of the size of the target value of the preset storage space, and the storage device needs to start the garbage collection function and organize and release the corresponding expected storage space according to the target value of the preset storage space. In this case, the storage device successfully executes the garbage collection function.
[0094] Furthermore, after the storage device executes the garbage collection function, the storage device sends status information to the operating system, and the status information is used to display the operating status parameters of the storage device executing the garbage collection function this time and the value of the remaining available storage space of the storage device to the operating system.
[0095] Case 2: The storage device determines whether the remaining available storage space of the storage device is less than or equal to the preset storage space target value. If the remaining available storage space of the storage device is greater than the preset storage space target value, the storage device does not perform garbage collection on the data in the storage device.
[0096] It should be noted that situation 2 indicates that the remaining available storage space of the current storage device is relatively sufficient, and the storage device can store data of a preset storage space target value size. In this case, the storage device will not perform a garbage collection function.
[0097] Furthermore, after the storage device does not perform the garbage collection function, the storage device sends a prompt message to the operating system, where the prompt message is used to feedback to the operating system that the remaining available storage space of the current storage device can store data of a preset storage space target value size.
[0098] It can be seen that the embodiment of the present application provides a method for manually starting the garbage collection function on the operating system side, thereby realizing autonomous control of the garbage collection function on the operating system side; and can effectively avoid garbage collection processing and access requests being performed simultaneously, thereby reducing the adverse impact on the performance of the storage device.
[0099] See also Figure 2 , Figure 2 It is a flow chart of another garbage recycling method disclosed in an embodiment of the present application.
[0100] Step 201: The operating system sets a target read / write channel with the storage device.
[0101] In an embodiment of the present application, before the operating system sends an instruction to start the garbage collection function to the storage device, the operating system needs to set a target read-write channel between the operating system and the storage device, with the aim of opening up a communication transmission channel between the operating system and the storage device. The operating system can read and set relevant parameters of the garbage collection function through the target read-write channel.
[0102] As an example, the operating system sends an instruction to enable the garbage collection function to the storage device through the target read-write channel, and the storage device sends relevant execution parameters of the garbage collection function and the value of the remaining available storage space of the storage device to the operating system through the target read-write channel. The function of the target read-write channel is not elaborated in this application.
[0103] Step 202: The operating system sets a preset storage space target value through a target setting node.
[0104] In an embodiment of the present application, the operating system is provided with a target setting node, which can be used to set parameters such as a preset storage space target value, and can also set relevant setting parameters of the garbage collection function (for example, set the enable parameter of the garbage collection function, the disable parameter of the garbage collection function, etc. through the target setting node). The functions of this target setting node are not elaborated herein in the present application.
[0105] As an example, the operating system can set the target setting node in the following way: The operating system can receive the setting node configuration parameters input by the developer in the operating system, and the operating system completes the setting of the target setting node according to the setting node configuration parameters.
[0106] It should be noted that the target setting node is an interface in the form of files and directories, which allows the developer to set the startup parameters of the garbage collection function and the preset storage space target value on the operating system side by operating or calling the target setting node, and generate and send an enable instruction of the garbage collection function to the storage device. This target setting node can simplify the setting method of the relevant parameters of the garbage collection function in the operating system, and can also simplify the operation method of starting the garbage collection function.
[0107] Step 203, the operating system sends an enable instruction of the garbage collection function to the storage device through the target read / write channel.
[0108] In an embodiment of the present application, the operating system sends an enable instruction of the garbage collection function to the storage device through the set target read / write channel.
[0109] For other implementation manners of step 203, reference can be made to the content in the foregoing step 101 correspondingly, and details are not elaborated herein.
[0110] Step 204, the storage device responds to the enable instruction of the garbage collection function and obtains the preset storage space target value.
[0111] Step 205, when the remaining available storage space in the storage device is less than or equal to the preset storage space target value, the storage device performs garbage collection processing on the data in the storage device.
[0112] For the implementation manners of steps 204 to 205, reference can be made to the content in the foregoing steps 102 to 103 correspondingly, and details are not elaborated herein.
[0113] Step 206, the operating system generates a read instruction through the target read node.
[0114] In an embodiment of the present application, the operating system is provided with a target reading node. The operating system can generate a reading instruction through the target reading node, and this reading instruction can be used to read the operating state parameters of the garbage collection function of the storage device and the value of the remaining available storage space of the storage device. Among them, the operating state parameters of the garbage collection function include the execution state parameters of the garbage collection function and the execution result parameters of the garbage collection function. The present application does not limit the operating state parameters. In addition, those skilled in the art can read other parameters of the garbage collection function of the storage device according to actual needs.
[0115] Exemplarily, the operating system can read the execution state parameters of the garbage collection function through the target reading node (for example, "dirty" indicates that the garbage collection function is being executed, and "clean" indicates that the garbage collection function is stopped). The operating system can also read the execution result parameters of the garbage collection function through the target reading node (for example, "invalid" indicates that the garbage collection function has not started execution yet, "working" indicates that the garbage collection function is being executed, "completed" indicates that the garbage collection function has completed execution, "terminated" indicates that the garbage collection function is prematurely terminated, etc.). The operating system can also read the value of the remaining available storage space of the storage device through the target reading node. The present application does not elaborate on the functions of this target reading node and the relevant parameters that can be read here.
[0116] As an example, the operating system can set the target reading node in the following way: The operating system can receive the reading node configuration parameters input by the developer in the operating system, and the operating system completes the setting of the target reading node according to the reading node configuration parameters.
[0117] It should be noted that the target reading node is an interface in the form of files and directories, which allows the developer to generate a reading instruction by operating or calling the target reading node on the operating system side, and this reading instruction can read the relevant parameters of the garbage collection function. This target-related node can simplify the reading method for the operating system to read the relevant parameters of the garbage collection function.
[0118] Step 207, the operating system sends a reading instruction to the storage device through the target read-write channel.
[0119] In an embodiment of the present application, the operating system can send a reading instruction to the storage device through the set target read-write channel.
[0120] Step 208, the storage device responds to the reading instruction and sends the operating state parameters of the garbage collection function and the value of the remaining available storage space to the operating system through the target read-write channel.
[0121] In an embodiment of the present application, after the storage device receives and responds to a read instruction, the storage device may obtain the operating state parameters of the garbage collection function and the value of the remaining available storage space, and send the operating state parameters of the garbage collection function and the value of the remaining available storage space to the operating system through the target read / write channel. Further, the operating system may read the operating state parameters of the garbage collection function and the value of the remaining available storage space through the target read node.
[0122] It can be seen that by implementing the embodiment of the present application and setting the read / write channel between the operating system and the storage device, not only can the startup efficiency of the garbage collection function be improved, but also other communication operations between the operating system and the storage device can be avoided from interfering with the operation of the garbage collection function. By setting up nodes, the setting operation of the parameters related to the garbage collection function can be simplified, and the centralized deployment and management of the parameters related to the garbage collection function can also be realized to improve the efficiency and performance of the garbage collection process. The operating system can quickly and accurately obtain the size of the remaining space of the storage device and the operating state of the garbage collection function through the read node, and the user can understand the current performance of the storage device at the operating system end. The embodiment of the present application provides a method for manually starting the garbage collection function at the operating system end, realizing the autonomous control of the garbage collection function at the operating system end; and it can effectively avoid the simultaneous execution of the garbage collection process and access requests, reducing the adverse impact on the performance of the storage device.
[0123] Please refer to Figure 3 , Figure 3 which is a schematic flowchart of another garbage collection method disclosed in the embodiment of the present application.
[0124] Step 301, the operating system sends an authentication command to the storage device, and the authentication command is used to query whether the storage device has a garbage collection function.
[0125] In an embodiment of the present application, when the operating system sets the target read / write channel with the storage device, the operating system sends a communication configuration command to the storage device. Before the operating system sends the communication configuration command to the storage device, the operating system may send an authentication command to the storage device, and the authentication command is used to query whether the storage device has a garbage collection function.
[0126] It should be noted that since the electronic device includes at least one storage device, the operating system may send the authentication command to multiple storage devices simultaneously to quickly determine whether the storage device has a garbage collection function. Or, the authentication command may be sent only to the storage device for which the target read / write channel is set, and the present application does not make any limitation in this regard.
[0127] Step 302, the storage device receives the authentication command, and queries and sends the query result to the operating system according to the authentication command.
[0128] In an embodiment of the present application, the storage device receives and responds to the authentication command. The storage device queries whether it has a garbage collection function according to the authentication command, and sends the query result to the operating system.
[0129] As an example, the register of the storage device includes identification information indicating whether the storage device has a garbage collection function. The storage device can send the identification information to the operating system to complete the query.
[0130] As another example, the operating system can send an authentication command by calling a query interface or a command line interface to query whether the storage device has a garbage collection function. These query interfaces or command line interfaces include information on whether the storage device supports the garbage collection function and other detailed information on how to configure and manage garbage collection.
[0131] It should be noted that the present application does not limit the manner in which the operating system queries whether the storage device has a garbage collection function.
[0132] Step 303: The operating system receives the query result. When the query result indicates that the storage device has a garbage collection function, the authentication of the storage device is completed.
[0133] In an embodiment of the present application, the operating system receives the query result sent by the storage device. If the query result indicates that the storage device has a garbage collection function, the operating system further sends a communication configuration command to the storage device. If the query result indicates that the storage device does not have a garbage collection function, the operating system does not send a communication configuration command to the storage device.
[0134] Step 304: The operating system sends a communication configuration command to the storage device. The communication configuration command includes read / write channel configuration parameters.
[0135] In an embodiment of the present application, the operating system sends a communication configuration command to the storage device. The communication configuration command includes read / write channel configuration parameters, which are used to configure the target read / write channel between the operating system and the storage device.
[0136] Step 305: The storage device sets the target read / write channel according to the read / write channel configuration parameters.
[0137] In an embodiment of the present application, the storage device receives and responds to a communication configuration command, and sets a target read / write channel according to the obtained read / write channel configuration parameters. For example, if the storage device is an EMMC storage device, the operating system can send EMMC storage device-specific cmd56 command parameters to the storage device to complete the setting of the target read / write channel. The operating system can send an instruction to enable the garbage collection function to the storage device through the target read / write channel. The operating system can also read and write target data to the target area of the EMMC storage device through the target read / write channel.
[0138] It should be noted that since different storage devices need to set the target read / write channel through different specific command parameters, and the specific command parameters are determined by the underlying communication protocol of the storage device. Therefore, the operating system needs to determine what type of read / write channel configuration parameters to send to the storage device according to the type of the storage device.
[0139] For other implementation manners of the target read / write channel in steps 304 to 305, reference may be made to the content in step 201 above, which will not be elaborated here.
[0140] As an optional implementation manner, after the storage device sets the target read / write channel according to the read / write channel configuration parameters and before the operating system sends an instruction to enable the garbage collection function to the storage device, it further includes: the operating system verifies the target read / write channel. By further verifying the read / write channel, the operating system can timely understand whether the read / write channel is successfully set, avoiding affecting the subsequent start and operation of the garbage collection function.
[0141] For the specific verification steps, see steps 306 to 309.
[0142] Step 306, the operating system sends a storage instruction to the storage device through the target read / write channel, and the storage instruction is used to store verification data.
[0143] In an embodiment of the present application, the operating system can send a storage instruction to the storage device through the target read / write channel. The storage instruction includes verification data and a target area, and the storage instruction is used to instruct the storage device to store the verification data and store the verification data in the target area of the storage device.
[0144] It should be noted that the verification data and the target area can be arbitrarily selected by the operating system, and the present application does not limit this.
[0145] Step 307, the storage device stores the verification data in the target area of the storage device according to the storage instruction.
[0146] In an embodiment of the present application, the storage device receives and responds to a storage instruction sent by the operating system, and stores the verification data in a target area of the storage device according to the storage instruction.
[0147] It should be noted that the storage instruction may not include the target area. The target area may be an area in the storage device for verifying read and write functions. The present application does not limit this.
[0148] Step 308, the storage device reads data from the target area and sends the read data to the operating system through the target read / write channel.
[0149] In an embodiment of the present application, after the storage device stores the verification data in the target area of the storage device, the storage device can read data from the target area and send the read data to the operating system through the target read / write channel.
[0150] Step 309, the operating system receives the read data. When the verification data is the same as the read data, the verification of the target read / write path is completed.
[0151] In an embodiment of the present application, the operating system receives the read data sent by the storage device and determines whether the verification data is the same as the read data. When the verification data is the same as the read data, it indicates whether the target read / write path is successfully set, that is, the verification of the target read / write path is completed.
[0152] It should be noted that since the verification data sent by the operating system has been written into the target area, if the target read / write path is successfully set, the storage device can correctly read the verification data from the target area. If the target read / write path is not successfully set, the storage device cannot correctly read the verification data from the target area. Therefore, the operating system verifies whether the target read / write path is successfully set by sending a storage instruction to the storage device through the target read / write channel, which can improve the accuracy of the verification result.
[0153] Step 310, the operating system sets a preset storage space target value through the target setting node.
[0154] For the implementation manner of step 310, reference can be made to the content in the foregoing step 202, which will not be elaborated here.
[0155] Step 311, the operating system sends an instruction to enable the garbage collection function to the storage device through the target read / write channel.
[0156] For the implementation manner of step 311, reference can be made to the content in the foregoing step 101 and step 203, which will not be elaborated here.
[0157] Step 312: The storage device responds to the instruction to enable the garbage collection function and obtains the target value of the preset storage space.
[0158] Step 313: When the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space, the storage device performs garbage collection processing on the data in the storage device.
[0159] For the implementation manners of steps 312 to 313, reference can be made to the corresponding content in the foregoing steps 102 to 103, which will not be elaborated here.
[0160] It can be seen that when implementing the embodiments of the present application, before starting to set the read / write channel, authenticating whether the storage device has the garbage collection function can establish the trust of the operating system in the storage device, and can also avoid invalid read channel setting operations between the operating system and the storage device. Configuring the read / write channel through the read / write channel configuration parameters enables the correct reading and setting of the relevant parameters of the garbage collection function between the operating system and the storage device. Verifying the effectiveness of the read / write channel through the storage instruction can accurately and quickly determine whether the read / write channel is successfully set. By setting nodes, the setting operations of the relevant parameters of the garbage collection function can be simplified, and the centralized deployment and management of the relevant parameters of the garbage collection function can also be realized to improve the efficiency and performance of the garbage collection processing. The embodiments of the present application provide a method for manually starting the garbage collection function at the operating system end, realizing the independent control of the garbage collection function at the operating system end; and can effectively avoid the simultaneous execution of garbage collection processing and access requests, reducing the adverse impact on the performance of the storage device.
[0161] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of another garbage collection processing method disclosed in the embodiments of the present application.
[0162] Step 401: The operating system sets the target read / write channel between the operating system and the storage device.
[0163] For the implementation manners of step 410, reference can be made to the corresponding content in the foregoing steps 201 and steps 301 to 309, which will not be elaborated here.
[0164] Step 402: The operating system generates a setting instruction including the warning storage space value through the target setting node.
[0165] In an embodiment of the present application, the operating system may generate a setting instruction including a warning storage space value through a target setting node. As an example, the operating system generating a setting instruction including a warning storage space value through a target setting node may be implemented in the following manner: The operating system may generate a setting instruction for the warning storage space value according to the warning storage space value input by the developer at the target setting node. It should be noted that the warning storage space value refers to the size of the warning storage space for the storage device storage space input by the developer at the target setting node of the operating system. Setting this warning storage space value is to enable the storage device to prompt the operating system whether to enable the garbage collection function.
[0166] It should be noted that the warning storage space value may be set by those skilled in the art, or may be a warning storage space value predicted by the operating system based on historical access requests sent by the operating system to the storage device. The present application does not limit the size and determination method of the warning storage space value. Those skilled in the art can set a reasonable warning storage space value according to requirements.
[0167] Step 403, the operating system sends a setting instruction to the storage device through a target read / write channel.
[0168] Step 404, the storage device responds to the setting instruction and sets the warning storage space value.
[0169] In an embodiment of the present application, the storage device receives and responds to the setting instruction sent by the operating system and sets the warning storage space value.
[0170] Step 405, the storage device detects the remaining storage space of the storage device at a preset time interval.
[0171] It should be noted that the preset time interval may be set in advance by those skilled in the art, and the present application does not limit this. For example, the storage device may be set to detect the remaining storage space of the storage device every 1 hour.
[0172] Step 406, when the remaining storage space is less than or equal to the warning storage space value, the storage device sends a warning message to the operating system through the target read / write channel. The warning message is used to prompt the operating system to send an instruction to enable the garbage collection function to the storage device.
[0173] In an embodiment of the present application, the storage device determines whether the remaining storage space of the storage device is less than or equal to the warning storage space value. When the remaining storage space is less than or equal to the warning storage space value, the storage device sends a warning message to the operating system through the target read / write channel. In this case, it means that the size of the remaining storage space of the current storage device has reached the warning standard, and the current storage device needs to determine whether to enable the garbage collection function with the operating system.
[0174] Step 407: The operating system sends an instruction to enable the garbage collection function to the storage device through the target read / write channel.
[0175] For the implementation of step 407, reference can be made to the content in the foregoing steps 101 and 203, which will not be elaborated here.
[0176] Step 408: The storage device responds to the instruction to enable the garbage collection function and obtains the target value of the preset storage space.
[0177] Step 409: When the remaining available storage space of the storage device is less than or equal to the target value of the preset storage space, the storage device performs garbage collection processing on the data in the storage device.
[0178] For the implementation of steps 408 to 409, reference can be made to the content in the foregoing steps 102 to 103, which will not be elaborated here.
[0179] In order to further verify the impact degree of the garbage collection processing method provided by this application on the performance of the storage device, developers tested the impact degree of the garbage collection processing method of the prior art and the garbage collection processing method provided by this application on the performance of the storage device. When the garbage collection function of the storage device is started, first write data to the storage device 11 times, and write 1G of data to the storage device each time. Then, detect the read / write speed of the storage device. Finally, verify according to the change of the read / write speed of the storage device that the garbage collection processing method provided by this application can effectively reduce the adverse impact on the performance of the storage device.
[0180] Please refer to Figure 5 , Figure 5 which is a schematic diagram of the test results of the impact degree of the garbage collection processing method of the prior art and the garbage collection processing method provided by this application on the performance of the storage device. Figure 5 In the left figure in, it is the impact degree of the garbage collection processing method of the prior art on the read / write speed of the storage device, Figure 5 and in the right figure in, it is the impact degree of the garbage collection processing method provided by this application on the read / write speed of the storage device. Among them, Figure 5 the ordinate in is the read / write speed of the storage device, and the abscissa is the number of read / write times. The test results of the read / write speed of the storage device in this test are as follows:
[0181] Test results of the read / write speed corresponding to the ordinate in the left figure (read / write speed of the storage device):
[0182] [200.238.238.71.36.38.34.38.34.33.21.].
[0183] Test results of read / write speed corresponding to the vertical coordinate in the right figure (read / write speed of the storage device):
[0184] [202.241.240.239.240.241.23.25.38.34.36.]。
[0185] Through Figure 5 The line chart shown can reflect that in the prior art's garbage collection method, when the fourth read / write is performed, the read / write speed of the storage device has significantly decreased, while in the garbage collection method provided by this application, the read / write speed of the storage device only starts to decrease when the seventh read / write is performed. Therefore, the garbage collection method provided by this application can reduce the adverse impact on the performance of the storage device compared to the garbage collection method of the prior art.
[0186] It can be seen that by implementing the embodiments of this application, by setting up the read / write channel between the operating system and the storage device, it is possible to not only improve the startup efficiency of the garbage collection function but also avoid interference from other communication operations between the operating system and the storage device to the operation of the garbage collection function. The warning storage space value can be preset. Even if the operating system does not actively send a startup instruction for the garbage collection function, the storage device can start the garbage collection function based on the size relationship between the warning storage space value and the remaining storage space of the storage device. By comparing the warning storage space value with the remaining storage space of the storage device, the storage device can actively start the garbage collection function, effectively avoiding the adverse impact on the performance of the storage device due to insufficient storage space of the storage device. The embodiments of this application provide a method for manually starting the garbage collection function at the operating system end, achieving autonomous control of the garbage collection function at the operating system end; and can effectively avoid the simultaneous execution of garbage collection processing and access requests, reducing the adverse impact on the performance of the storage device.
[0187] It should be understood that although the steps in the above flowcharts are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps. In addition, the above multiple embodiments can be implemented independently or in combination with each other, and no limitation is made here.
[0188] Based on the foregoing embodiments, an embodiment of the present application provides an electronic device. The electronic device includes each module included therein, as well as each unit included in each module, and can be implemented by a processor; of course, it can also be implemented by specific logic circuits. During implementation, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0189] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in Figure 6 , the electronic device 600 includes an operating system 601 and a storage device 602, where:
[0190] The operating system 601 is used to send an instruction to enable the garbage collection function to the storage device 602;
[0191] The storage device 602 is used to respond to the instruction to enable the garbage collection function and obtain a preset storage space target value;
[0192] The storage device 602 is further used to perform garbage collection processing on the data in the storage device 602 when the remaining available storage space of the storage device 602 is less than or equal to the preset storage space target value.
[0193] In some embodiments, the operating system 601 is further used to set a target read / write channel with the storage device 602 before the operating system 601 sends an instruction to enable the garbage collection function to the storage device 602;
[0194] The operating system 601 is further used to send the instruction to enable the garbage collection function to the storage device 602 through the target read / write channel.
[0195] In some embodiments, the operating system 601 is further used to set a target read / write channel with the storage device 602, specifically including:
[0196] The operating system 601 is further used to send a communication configuration command to the storage device 602, and the communication configuration command includes read / write channel configuration parameters;
[0197] The storage device 602 is further used to set the target read / write channel according to the read / write channel configuration parameters.
[0198] In some embodiments, the operating system 601 is further configured to verify the target read / write channel after the storage device 602 sets the target read / write channel according to the read / write channel configuration parameter and before the operating system 601 sends an instruction to enable the garbage collection function to the storage device 602.
[0199] In some embodiments, the operating system 601 is further configured to verify the target read / write channel, specifically including:
[0200] The operating system 601 is further configured to send a storage instruction to the storage device 602 through the target read / write channel, where the storage instruction is used to store verification data;
[0201] The storage device 602 is further configured to store the verification data in a target area of the storage device 602 according to the storage instruction;
[0202] The storage device 602 is further configured to read data from the target area and send the read data to the operating system 601 through the target read / write channel;
[0203] The operating system 601 is further configured to receive the read data, and complete the verification of the target read / write path when the verification data is the same as the read data.
[0204] In some embodiments, the operating system 601 is further configured to send an authentication command to the storage device 602 before the operating system 601 sends a communication configuration command to the storage device 602, where the authentication command is used to query whether the storage device 602 has a garbage collection function;
[0205] The storage device 602 is further configured to receive the authentication command, and query and send a query result to the operating system 601 according to the authentication command;
[0206] The operating system 601 is further configured to receive the query result, and complete the authentication of the storage device when the query result indicates that the storage device 602 has the garbage collection function.
[0207] In some embodiments, the operating system 601 is provided with a target setting node, and the operating system 601 is further configured to set the preset storage space target value through the target setting node before the operating system 601 sends an instruction to enable the garbage collection function to the storage device 602.
[0208] In some embodiments, the operating system 601 is further configured to generate a setting instruction including a warning storage space value through the target setting node;
[0209] The operating system 601 is further configured to send the setting instruction to the storage device 602 through the target read / write channel;
[0210] The storage device 602 is further configured to respond to the setting instruction and set the warning storage space value.
[0211] In some embodiments, the storage device 602 is further configured to detect the remaining storage space of the storage device 602 at a preset time interval after the storage device 602 responds to the setting instruction and sets the warning storage space value;
[0212] The storage device 602 is further configured to, when the remaining storage space is less than or equal to the warning storage space value, send a warning message to the operating system 601 through the target read / write channel, where the warning message is used to prompt the operating system 601 to send an instruction to enable the garbage collection function to the storage device 602.
[0213] In some embodiments, the operating system 601 is further provided with a target read node, and the operating system 601 is further configured to generate a read instruction through the target read node, where the read instruction is used to read the operating state parameter of the garbage collection function and the value of the remaining available storage space;
[0214] The operating system 601 is further configured to send the read instruction to the storage device 602 through the target read / write channel;
[0215] The storage device 602 is further configured to respond to the read instruction and send the operating state parameter of the garbage collection function and the value of the remaining available storage space to the operating system 601 through the target read / write channel.
[0216] The description of the above embodiments of the electronic device is similar to the description of the above method embodiments, and has similar beneficial effects to the method embodiments. For the technical details not disclosed in the embodiments of the electronic device of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0217] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of another electronic device disclosed in the embodiments of the present application.
[0218] As Figure 7 shown, the electronic device includes:
[0219] A memory 701 storing executable program code;
[0220] A processor 702 coupled to the memory;
[0221] The processor 702 invokes the executable program code stored in the memory 701 and executes any one of the garbage collection processing methods in the above method embodiments.
[0222] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the garbage collection processing method provided in the above embodiments are implemented.
[0223] An embodiment of the present application provides a computer program product containing instructions. When it runs on a computer, it causes the computer to execute the steps in the garbage collection processing method provided in the above method embodiments.
[0224] Those skilled in the art can understand that Figure 7 the structure shown in
[0225] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements. Figure 7 In one embodiment, the electronic device provided by the present application can be implemented in the form of a computer program, and the computer program can run on a computer device as shown in
[0226] The memory of the computer device may store each program module that constitutes the above electronic device. The computer program constituted by each program module causes the processor to execute the steps in the garbage collection processing method of each embodiment of the present application described in this specification.
[0227] It should be understood that the "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the "in one embodiment" or "in an embodiment" or "in some embodiments" that appear throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the magnitude of the serial numbers of the above processes does not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments. The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated herein.
[0228] As used herein, the term "and / or" is merely a description of the relationship between associated objects, indicating that there can be three relationships. For example, object A and / or object B can mean: object A exists alone, object A and object B exist simultaneously, and object B exists alone.
[0229] It should be noted that, as used herein, the term "comprise", "include" or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article, system or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, system or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article, system or device comprising the element.
[0230] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there can be other division methods, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling or communication connection between the components shown or discussed with each other can be through some interfaces, indirect coupling or communication connection of devices or modules, and can be electrical, mechanical or other forms.
[0231] Those of ordinary skill in the art can understand that all or part of the steps to implement the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: various media that can store program codes, such as mobile storage devices, read only memory (ROM), magnetic disks, or optical discs.
[0232] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0233] The features disclosed in several electronic device embodiments provided in this application can be arbitrarily combined without conflict to obtain new electronic device embodiments.
[0234] As described above, only the implementation manners of this application are provided, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. A garbage collection and treatment method, characterized in that, Applied to an electronic device, the electronic device includes an operating system and a storage device, and the method includes: The operating system sends an activation instruction for the garbage collection function to the storage device; The storage device responds to the activation instruction for the garbage collection function and obtains a preset storage space target value; When the remaining available storage space of the storage device is less than or equal to the preset storage space target value, the storage device performs garbage collection processing on the data in the storage device.
2. The method according to claim 1, wherein Before the operating system sends an activation instruction for the garbage collection function to the storage device, the method further includes: The operating system sets a target read / write channel with the storage device; The operating system sending an activation instruction for the garbage collection function to the storage device includes: The operating system sends the activation instruction for the garbage collection function to the storage device through the target read / write channel.
3. The method according to claim 2, characterized in that, The operating system setting a target read / write channel with the storage device includes: The operating system sends a communication configuration command to the storage device, and the communication configuration command includes read / write channel configuration parameters; The storage device sets the target read / write channel according to the read / write channel configuration parameters.
4. The method according to claim 3, wherein After the storage device sets the target read / write channel according to the read / write channel configuration parameters and before the operating system sends an activation instruction for the garbage collection function to the storage device, the method further includes: The operating system verifies the target read / write channel.
5. The method according to claim 4, wherein The operating system verifying the target read / write channel includes: The operating system sends a storage instruction through the target read / write channel to the storage device, and the storage instruction is used to store verification data; The storage device stores the verification data in a target area of the storage device according to the storage instruction; The storage device reads data from the target area and sends the read data to the operating system through the target read / write channel; The operating system receives the read data, and when the verification data is the same as the read data, the verification of the target read / write path is completed.
6. The method according to claim 3, wherein Before the operating system sends a communication configuration command to the storage device, the method further includes: The operating system sends an authentication command to the storage device, and the authentication command is used to query whether the storage device has a garbage collection function; The storage device receives the authentication command, and queries and sends a query result to the operating system according to the authentication command; The operating system receives the query result, and when the query result indicates that the storage device has the garbage collection function, the authentication of the storage device is completed.
7. The method according to claim 2, wherein The operating system is provided with a target setting node. Before the operating system sends an activation instruction for the garbage collection function to the storage device, the method further includes: The operating system sets the preset storage space target value through the target setting node.
8. The method according to claim 7, wherein The method further includes: The operating system generates a setting instruction including a warning storage space value through the target setting node; The operating system sends the setting instruction to the storage device through the target read / write channel; The storage device responds to the setting instruction and sets the warning storage space value.
9. The method according to claim 8, wherein After the storage device responds to the setting instruction and sets the warning storage space value, the method further includes: The storage device detects the remaining storage space of the storage device at preset time intervals; When the remaining storage space is less than or equal to the warning storage space value, the storage device sends a warning message to the operating system through the target read / write channel, and the warning message is used to prompt the operating system to send an instruction to turn on the garbage collection function to the storage device.
10. The method according to claim 2, wherein The operating system is further provided with a target reading node, and the method further includes: The operating system generates a reading instruction through the target reading node, and the reading instruction is used to read the operating state parameter of the garbage collection function and the value of the remaining available storage space; The operating system sends the reading instruction to the storage device through the target read / write channel; The storage device responds to the reading instruction and sends the operating state parameter of the garbage collection function and the value of the remaining available storage space to the operating system through the target read / write channel.
11. An electronic device, characterized in that, The electronic device includes an operating system and a storage device, wherein: The operating system is used to send an instruction to turn on the garbage collection function to the storage device; The storage device is used to respond to the instruction to turn on the garbage collection function and obtain a preset storage space target value; The storage device is further used to perform garbage collection processing on the data in the storage device when the remaining available storage space of the storage device is less than or equal to the preset storage space target value.
12. An electronic device, characterized in that, It includes a memory and a processor. The memory stores a computer program that can be run on the processor, and when the processor executes the program, it implements the steps of the method according to any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method according to any one of claims 1 to 10.