CN116166570A - Garbage recycling method and device - Google Patents

Garbage recycling method and device Download PDF

Info

Publication number
CN116166570A
CN116166570A CN202211612816.0A CN202211612816A CN116166570A CN 116166570 A CN116166570 A CN 116166570A CN 202211612816 A CN202211612816 A CN 202211612816A CN 116166570 A CN116166570 A CN 116166570A
Authority
CN
China
Prior art keywords
memory
storage space
data
garbage collection
processing unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211612816.0A
Other languages
Chinese (zh)
Inventor
童朝柱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority claimed from CN201911209032.1A external-priority patent/CN112306896B/en
Publication of CN116166570A publication Critical patent/CN116166570A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Abstract

In the method, garbage collection of a file system and garbage collection of a memory in a terminal device are combined, for example, garbage collection processing can be uniformly performed on data stored in a part of a logic area of the file system and data stored in a physical block corresponding to the part of the logic area in the memory through a garbage collection mechanism in the file system, or garbage collection processing can be uniformly performed on data stored in the rest of the logic area of the file system and data stored in the rest of the physical block in the memory through the garbage collection mechanism in the memory, so that garbage collection processing can be performed only once for the same data, the situation that data are repeatedly moved when the file system and the memory perform garbage collection simultaneously can be avoided, and the time delay of accessing files by an application program can be reduced.

Description

Garbage recycling method and device
The present application is a division of the chinese patent application filed at month 31 2019 at chinese patent office, application number 201910719350.6, application name "a method of file system management", the entire contents of which are incorporated herein by reference.
Technical Field
The application relates to the technical field of computers, in particular to a garbage recycling method and device.
Background
In the terminal device, the data is stored in a memory of the terminal device in a file mode, and the stored file is managed through a file system of the terminal device. After receiving a file access request of an application program, a file system of the terminal equipment converts the access request into read-write operation of data stored in a memory, and then issues the read-write operation to the memory through a block equipment layer and equipment drivers, thereby realizing file access.
Currently, a memory employed in a terminal device is a flash memory (flash memory), for example, a NAND (NAND) flash memory (flash). Since the flash memory writes data in a remote update manner, in order to be memory-friendly, it is required that the file system of the terminal device also uses a file system in which the data writing manner is a remote update manner, for example, the file system of the terminal device may be a flash-friendly file system (flash friendly file system, F2 FS).
Writing data in a remote update mode gradually reduces the storage space in a memory or a file system, and garbage collection processing is performed on the file system and the memory in order to continuously write data generated by an application program into the memory. However, when both the file system and the memory are garbage-recycled, the file access of the application program is delayed greatly, and even blocked.
Disclosure of Invention
The application provides a garbage collection method and device, which are used for reducing time delay of accessing files by an application program.
In a first aspect, a garbage collection method is provided, in which a processor of a terminal device first obtains first information indicating a size of a first unit processing unit from a memory of the terminal device, the first unit processing unit is a unit processing unit for performing garbage collection operation on the memory, and configures a size of a second unit processing unit used by a file system of the terminal device for performing garbage collection operation according to the size of the first unit processing unit. And then, the processor sends an address configuration instruction to the memory, wherein the address configuration instruction comprises a logic address of the block device occupied by the file system, the address configuration instruction is used for indicating the memory to not need to carry out garbage collection operation on a physical storage space corresponding to the logic address, and finally, the processor carries out garbage collection operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
In the technical scheme, the processor uniformly reclaims the logic storage space and the physical storage space, that is, the memory does not need to carry out garbage reclaiming operation on the part of the physical storage space, so that the process of carrying out garbage reclaiming operation on the part of the physical storage space by the memory can be omitted, and the time delay of an application program when accessing a file can be reduced.
In one possible design, the second unit processing unit has the same size as the first unit processing unit, or the second unit processing unit has a size that is an integer multiple of the size of the first unit processing unit.
In the above technical solution, the size of the unit processing unit for performing the garbage collection operation by the file system is unified with the size of the unit processing unit for performing the garbage collection operation by the memory, and in general, the unit processing unit for performing the garbage collection operation by the memory is larger, so that the size of the unit processing unit for performing the garbage collection operation by the file system is increased, and the efficiency of performing the garbage collection operation by the file system can be improved.
In one possible design, the file system includes a main data area and a metadata area, where the main data area is used to store data, the metadata is used to store metadata of the data, and the logical address is a set of logical addresses corresponding to the main data area.
In the technical scheme, the storage space occupied by the main data area of the file system is larger, so that the garbage collection operation can be performed only on the main data area of the file system, and the efficiency of the garbage collection operation can be improved.
In one possible design, the processor prohibits the logical storage space corresponding to the logical address from writing data in a locally updated manner.
That is, the data is written into the logic storage space corresponding to the logic address in a mode of updating in different places, so that the consistency of the data stored in the logic storage space occupied by the file system and the data stored in the memory can be ensured.
In a second aspect, a garbage collection method is provided, in which, after receiving data, a memory of a terminal device writes the received data into a target storage space, where the target storage space includes a physical storage space corresponding to a metadata area of a file system of the terminal device and/or a physical storage space corresponding to a non-user data UDA partition of the terminal device, the file system includes a main data area and the metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data. And then, the memory performs garbage collection operation on the target storage space according to a preset garbage collection strategy and a preset unit processing unit.
In the technical scheme, after the memory performs garbage collection operation on the target storage space, the file system does not need to perform garbage collection operation on the storage space corresponding to the metadata partition, so that the process of performing garbage collection operation on part of the storage space by the file system can be omitted, and the time delay of an application program when accessing a file can be reduced.
In one possible design, the memory establishes a mapping relationship between a logical page of the logical storage space and a physical page of the target storage space, where the logical storage space is a logical storage space corresponding to the metadata area and/or the non-user data UDA partition, and then the memory may determine invalid data according to the mapping relationship, and if the number of invalid data in one physical page is greater than a threshold, the memory performs garbage collection operation on the physical page.
In the embodiment of the application, the manner in which the invalid data is determined by the memory is not limited.
In one possible design, the memory writes data to the target storage space in a locally updated manner.
In a third aspect, a garbage collection device is provided, where the garbage collection device may be a terminal device or a device in a terminal device. The waste reclamation apparatus comprises a processor for implementing the method described in the first aspect above. The garbage collection device may further comprise a memory for storing program instructions and data. The memory is coupled to the processor, which may call and execute program instructions stored in the memory for implementing any one of the methods described in the first aspect above. The waste reclamation apparatus may also include an interface for the waste reclamation apparatus to communicate with other devices or modules.
In one possible design, the waste reclamation device processor and interface, wherein:
the processor is configured to obtain first information from a memory of the terminal device, where the first information is used to indicate a size of a first unit processing unit, and the first unit processing unit is a unit processing unit that performs a garbage collection operation on the memory; the size of a second unit processing unit is configured according to the size of the first unit processing unit, and the second unit processing unit is used for garbage collection operation of a file system of the terminal equipment;
the interface is used for sending an address configuration instruction to the memory under the control of the processor, wherein the address configuration instruction comprises a logical address of block equipment occupied by the file system, and the address configuration instruction is used for indicating the memory not to carry out garbage collection operation on a physical storage space corresponding to the logical address;
the processor is further configured to perform garbage collection operation on the logical storage space corresponding to the logical address according to the size of the second unit processing unit.
The configuration, logical address, and data writing manner of the size of the second unit processing unit are similar to those of the first aspect, and are not described herein.
In a fourth aspect, a garbage collection device is provided, where the garbage collection device may be a terminal device or a device in a terminal device. The waste reclamation apparatus comprises a processor for implementing the method described in the second aspect above. The garbage collection device may further comprise a memory for storing program instructions and data. The memory is coupled to the processor which may invoke and execute program instructions stored in the memory for implementing any of the methods described in the second aspect above. The waste reclamation apparatus may also include an interface for the waste reclamation apparatus to communicate with other devices or modules.
In one possible design, the waste reclamation device processor and interface, wherein:
the interface is used for receiving data;
the processor is configured to write received data into a target storage space, where the target storage space includes a physical storage space corresponding to a metadata area of a file system of the terminal device and/or a physical storage space corresponding to a non-user data UDA partition of the terminal device, the file system includes a main data area and the metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data; the method comprises the steps of,
And carrying out garbage recycling operation on the target storage space according to a preset garbage recycling strategy and a preset unit processing unit.
In one possible design, the processor is further configured to:
establishing a mapping relation between a logical page of a logical storage space and a physical page of the target storage space, wherein the logical storage space is a logical storage space corresponding to the metadata area and/or the non-user data UDA partition; determining invalid data according to the mapping relation; and if the quantity of invalid data in one physical page is large and the threshold value is high, the memory performs garbage collection operation on the physical page.
In one possible design, the processor writes data to the target storage space in a locally updated manner.
In a fifth aspect, a garbage collection device is provided, which may be a terminal device or a device in a terminal device, where the garbage collection device may include a processing module and a communication module, where the modules may perform the corresponding functions performed in any of the design examples of the first aspect, and in particular:
the communication module is used for acquiring first information from a memory of the device, wherein the first information is used for indicating the size of a first unit processing unit, and the first unit processing unit is a unit processing unit for garbage collection operation of the memory;
The processing module is used for configuring the size of a second unit processing unit according to the size of the first unit processing unit, wherein the second unit processing unit is used for garbage collection operation of a file system of the device;
the communication module is further configured to send an address configuration instruction to the memory, where the address configuration instruction includes a logical address of a block device occupied by the file system, and the address configuration instruction is used to instruct the memory to not perform garbage collection operation on a physical storage space corresponding to the logical address;
and the processing module is also used for carrying out garbage recycling operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
In a sixth aspect, a garbage collection device is provided, which may be a terminal device or a device in a terminal device, where the garbage collection device may include a processing module and a communication module, where the modules may perform corresponding functions performed in any of the design examples of the second aspect, and in particular:
the communication module is used for receiving data;
The processing module is used for writing the received data into a target storage space, wherein the target storage space comprises a physical storage space corresponding to a metadata area of a file system of the device and/or a physical storage space corresponding to a non-User Data (UDA) partition of the device, the file system comprises a main data area and the metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data; the method comprises the steps of,
and carrying out garbage recycling operation on the target storage space according to a preset garbage recycling strategy and a preset unit processing unit.
In a seventh aspect, embodiments of the present application also provide a computer-readable storage medium comprising instructions that, when run on a computer, cause the computer to perform the method of the first or second aspect.
In an eighth aspect, there is also provided in an embodiment of the present application a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of the first or second aspect.
In a ninth aspect, embodiments of the present application provide a chip system, where the chip system includes a processor and may further include a memory, to implement the method in the first aspect or the second aspect. The chip system may be formed of a chip or may include a chip and other discrete devices.
Advantageous effects of the second to ninth aspects and implementations thereof described above may be referred to the description of advantageous effects of the method of the first or second aspect and implementations thereof.
In a tenth aspect, there is provided a garbage collection method comprising: the first object determines a storage space corresponding to the first object from a terminal equipment memory; the memory comprises a memory space corresponding to at least one object, the object comprises a memory of the terminal equipment or a processor of the terminal equipment, and the first object is any one of the at least one object; and the first object performs garbage collection operation on the storage space corresponding to the first object.
In the above technical solution, when the objects in the terminal device and the storage space have a corresponding relationship, each object only performs garbage collection operation on the storage space corresponding to itself, and when a plurality of objects exist in the terminal device, different objects (such as a memory and a processor) can perform garbage collection operation on different storage spaces in the memory respectively, so that time delay when an application program accesses a file can be reduced.
In one possible design, the first object is a processor of the terminal device; the method further comprises the steps of: the method comprises the steps that a processor of a terminal device obtains first information from a memory of the terminal device, wherein the first information is used for indicating the size of a first unit processing unit, and the first unit processing unit is a unit processing unit for garbage collection operation of the memory; the processor configures the size of a second unit processing unit according to the size of the first unit processing unit, wherein the second unit processing unit is used for garbage collection operation of a file system of the terminal equipment; the processor sends an address configuration instruction to the memory, wherein the address configuration instruction comprises a logical address of block equipment occupied by a file system, and the address configuration instruction is used for indicating the memory not to carry out garbage collection operation on a physical storage space corresponding to the logical address; the garbage collection operation is carried out on the storage space corresponding to the first object by the first object, and the garbage collection operation comprises the following steps: and the processor performs garbage collection operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
Therefore, the processor uniformly reclaims the logic storage space and the physical storage space, that is, the memory does not need to reclaim the part of the physical storage space, so that the process of reclaiming the part of the physical storage space by the memory can be omitted, and the time delay of an application program when accessing a file can be reduced.
In one possible design, the second unit processing unit has the same size as the first unit processing unit, or the second unit processing unit has a size that is an integer multiple of the size of the first unit processing unit.
In the above technical solution, the size of the unit processing unit for performing the garbage collection operation by the file system is unified with the size of the unit processing unit for performing the garbage collection operation by the memory, and in general, the unit processing unit for performing the garbage collection operation by the memory is larger, so that the size of the unit processing unit for performing the garbage collection operation by the file system is increased, and the efficiency of performing the garbage collection operation by the file system can be improved.
In one possible design, the file system includes a main data area and a metadata area, where the main data area is used to store data, the metadata is used to store metadata of the data, and the logical address is a set of logical addresses corresponding to the main data area.
In the technical scheme, the storage space occupied by the main data area of the file system is larger, so that the garbage collection operation can be performed only on the main data area of the file system, and the efficiency of the garbage collection operation can be improved.
In one possible design, the processor prohibits the logical storage space corresponding to the logical address from writing data in a locally updated manner.
That is, the data is written into the logic storage space corresponding to the logic address in a mode of updating in different places, so that the consistency of the data stored in the logic storage space occupied by the file system and the data stored in the memory can be ensured.
In one possible design, the first object is a memory of the terminal device; the method further comprises the steps of: the memory of the terminal equipment receives data; the storage writes the received data into a target storage space, wherein the target storage space comprises a physical storage space corresponding to a metadata area of a file system of the terminal equipment and/or a physical storage space corresponding to a non-User Data (UDA) partition of the terminal equipment, the file system comprises a main data area and a metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data; the first object determines a storage space corresponding to the first object from a terminal device memory, and the method comprises the following steps: and the memory performs garbage collection operation on the target storage space according to a preset garbage collection strategy and a preset unit processing unit.
Therefore, after the garbage collection operation is carried out on the target storage space in the memory, the file system does not need to carry out the garbage collection operation on the storage space corresponding to the metadata partition, so that the process of carrying out the garbage collection operation on part of the storage space by the file system can be omitted, and the time delay of an application program when accessing a file can be reduced.
In one possible design, the memory establishes a mapping relationship between a logical page of the logical storage space and a physical page of the target storage space, where the logical storage space is a logical storage space corresponding to the metadata area and/or the non-user data UDA partition, and then the memory may determine invalid data according to the mapping relationship, and if the number of invalid data in one physical page is greater than a threshold, the memory performs garbage collection operation on the physical page.
In the embodiment of the application, the manner in which the invalid data is determined by the memory is not limited.
In one possible design, the memory writes data to the target storage space in a locally updated manner.
An eleventh aspect provides a waste reclamation apparatus comprising: the processing module is used for determining a storage space corresponding to the first object from a memory of the device; the memory comprises a memory space corresponding to at least one object, the object comprises a memory of the device or a processor of the device, and the first object is any one of the at least one object; and the processing module is also used for carrying out garbage collection operation on the storage space corresponding to the first object.
In one possible design, the first object is a processor of the device; the device also comprises a communication module, a first processing module and a second processing module, wherein the communication module is used for acquiring first information from a memory of the device, the first information is used for indicating the size of a first unit processing unit, and the first unit processing unit is a unit processing unit for performing garbage recycling operation on the memory; the processing module is also used for configuring the size of a second unit processing unit according to the size of the first unit processing unit, wherein the second unit processing unit is used for garbage collection operation of a file system of the device; the communication module is also used for sending an address configuration instruction to the memory, wherein the address configuration instruction comprises a logical address of block equipment occupied by a file system, and the address configuration instruction is used for indicating the memory not to carry out garbage collection operation on a physical storage space corresponding to the logical address; and the processing module is also used for carrying out garbage collection operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
In one possible design, the size of the second unit processing unit is the same as the size of the first unit processing unit, or the size of the second unit processing unit is an integer multiple of the size of the first unit processing unit.
In one possible design, the file system includes a main data area and a metadata area, the main data area is used for storing data, the metadata is used for storing metadata of the data, and the logical address is a set of logical addresses corresponding to the main data area.
In one possible design, the processing module is further configured to: and prohibiting the logic storage space corresponding to the logic address from writing data in a local updating mode.
In one possible design, the first object is a memory of the device; the communication module is also used for receiving data; the processing module is further used for writing the received data into a target storage space, wherein the target storage space comprises a physical storage space corresponding to a metadata area of a file system of the device and/or a physical storage space corresponding to a non-User Data (UDA) partition of the device, the file system comprises a main data area and a metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data; and performing garbage collection operation on the target storage space according to a preset garbage collection strategy and a preset unit processing unit.
In one possible design, the processing module is further configured to: establishing a mapping relation between a logical page of a logical storage space and a physical page of a target storage space, wherein the logical storage space is a logical storage space corresponding to a metadata area and/or a non-User Data (UDA) partition; and determining invalid data according to the mapping relation; and if the quantity of invalid data in one physical page is large and the threshold value is high, performing garbage collection operation on the physical page.
In one possible design, the processing module is to: and writing the received data into the target storage space in a local updating mode.
In a twelfth aspect, there is provided a computer storage medium having stored therein computer executable instructions which when invoked by a computer are for causing the computer to perform the method as described in the tenth aspect or any one of the possible designs of the tenth aspect.
In a thirteenth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method as described in the tenth aspect or any one of the possible designs of the tenth aspect.
In a fourteenth aspect, there is provided a terminal device comprising a processor and a memory having stored therein computer executable instructions for causing the processor to perform the method as described in the tenth aspect or any one of the possible designs of the tenth aspect when invoked by the processor.
Advantageous effects of the above eleventh to fourteenth aspects and implementations thereof reference may be made to the description of the advantageous effects of the method of the tenth aspect and implementations thereof.
Drawings
FIG. 1 is a schematic diagram of one example of a manner of off-site update;
fig. 2 is an exemplary structural schematic diagram of a terminal device in an embodiment of the present application;
FIG. 3 is a logic block diagram of an example of a terminal device in an embodiment of the present application;
FIG. 4 is a schematic diagram of an example of garbage collection by a file system;
FIG. 5 is a schematic diagram of an example of garbage collection processing of a memory;
FIG. 6 is a schematic diagram of one example of a logical page or physical page mapping;
FIG. 7 is a flowchart of an example of a garbage collection method provided in an embodiment of the present application;
FIG. 8 is a flowchart of another example of a garbage collection method provided in an embodiment of the present application;
fig. 9 is a flowchart of an example of a garbage recycling device provided in an embodiment of the present application;
fig. 10 is a flowchart of another example of a garbage recycling device provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
1) The terminal device may be any one of various types of computer systems or devices that are mobile or portable and perform wireless communication, or may be a server terminal device. For example, may include a mobile phone or smart phone, a portable gaming device, a personal communication services (personal communication service, PCS) phone, a session initiation protocol (session initiation protocol, SIP) phone, a wireless local loop (wireless local loop, WLL) station, a personal digital assistant (personal digital assistant, PDA), a portable internet device, a music player, a data storage device, other handheld devices, and a wearable device.
Alternatively, the terminal device may also include a limited device, such as a device with lower power consumption, or a device with limited storage capacity, or a device with limited computing capacity, etc. Examples include bar codes, radio frequency identification (radio frequency identification, RFID), sensors, global positioning systems (global positioning system, GPS), laser scanners, and other information sensing devices.
Or, the terminal device can also be intelligent wearable device, which is a generic name for intelligently designing daily wearing and developing wearable devices, such as glasses, gloves, watches, clothes, shoes and the like, by applying wearable technology. Alternatively, it may be a Virtual Reality (VR) device, an augmented reality (augmented reality, AR) device, a wireless terminal device in industrial control (industrial control), a wireless terminal device in unmanned (driverless), a wireless terminal device in teleoperation (remote medical surgery), a wireless terminal device in smart grid (smart grid), a wireless terminal device in transportation safety (transportation safety), a wireless terminal device in smart city, a wireless terminal device in smart home (smart home), or the like.
2) The local updating mode refers to that after a write operation request is received, an operation address corresponding to the write operation request is first determined, then data carried in the write operation request is written into the address, and if original data is stored in the address, the data included in the write operation instruction is covered with the original data.
3) The mode of updating in different places refers to that after receiving a write operation request, the write operation request is written into the storage space in sequence, and the write operation is not directly performed on an operation address corresponding to the write operation request. As an example, referring to fig. 1, the memory may maintain a mapping relationship between an address identifier and a memory space, for example, an initial mapping relationship between an address 1 and a memory space is that an address 1 is mapped to a first memory location (e.g., a physical block or a physical page), an address 2 is mapped to a second memory location, and so on. If the first 10 storage units in the memory store data, after the memory receives a write operation request for address 9, the memory stores the data corresponding to the write operation request in the 11 th storage unit. Then, the memory will map the address 9 to the 11 th memory cell according to the mapping relationship between the address and the memory cell, so that when the data in the address 9 needs to be read later, the memory will read the data from the 11 th memory cell.
4) Invalid data is caused by a delete operation or multiple write operations to the same address. For example, in fig. 1, when the address 9 is written twice, the data corresponding to the first write operation, that is, the data stored in the 9 th memory cell in fig. 1, becomes invalid data. Or when the memory receives a delete operation request for an address, the data corresponding to the address is marked as invalid data.
In the above description, the memory is taken as an example to explain "update mode from different places" and "invalid data". The manner of updating the file system in the different places and the description of the invalid data are similar to the memory, and are not repeated here.
5) The garbage collection processing of the file system means that when a small number of logical pages of a certain logical block in the file system store effective data, the file system considers that the logical block can be subjected to garbage collection processing, so that the effective data stored in the logical block is copied to other logical blocks, and then the logical block is erased to complete garbage collection processing.
6) In the embodiments of the present application, the term "plurality" refers to two or more, and in view of this, the term "plurality" may also be understood as "at least two" in the embodiments of the present application. "at least one" may be understood as one or more, for example as one, two or more. For example, including at least one means including one, two or more, and not limiting what is included, e.g., including at least one of A, B and C, then A, B, C, A and B, A and C, B and C, or A and B and C, may be included. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/", unless otherwise specified, generally indicates that the associated object is an "or" relationship. In the present embodiment, "node" and "node" may be used interchangeably.
Unless stated to the contrary, the embodiments of the present application refer to ordinal terms such as "first," "second," etc., for distinguishing between multiple objects and not for defining a sequence, timing, priority, or importance of the multiple objects.
The following describes a structure diagram of a terminal device according to an embodiment of the present application. Fig. 2 shows an exemplary structural diagram of a terminal device. As shown in fig. 2, the terminal device 200 includes: processor 210, memory 220, and communication interface 230. It will be appreciated by those skilled in the art that the structure of the terminal device shown in fig. 2 does not constitute a limitation of the terminal device, and that the terminal device provided by the embodiments of the present invention may include more or less components than those illustrated, or may combine certain components, or may have different arrangements of components.
These components may communicate via one or more buses 240 or signal lines, which may be divided into address buses, data buses, control buses, etc.
The processor 210 may be a central processing unit (central processing unit, CPU), a network processor (network processor, NP) or a combination of CPU and NP. Processor 210 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (programmable logic device, PLD), or a combination thereof. The PLD may be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), general-purpose array logic (generic array logic, GAL), or any combination thereof.
A memory 220 for storing computer programs, such as application programs, operating systems, and file systems; processor 210 may invoke the computer program stored in memory 220 to implement the functionality defined by the computer program.
For example, the processor 210 may execute an operating system to implement various functions of the operating system on the terminal device 200, and the processor 210 may also execute an application program to implement various functions of the application program on the terminal device 200. The operating system may be a Windows system, a MAC OS system, a Linux system, or an Android system, etc., and of course, may also be a future-oriented computer system, where the system described in the embodiments of the present application is for more clearly describing a technical solution of the embodiments of the present application, and does not constitute a limitation of the technical solution provided in the embodiments of the present application. For example, the application program may be a third party application program such as a WeChat application program or a hundred degree application program, or may be a system application program of the terminal device 200, such as a system service (system server) or a system interface (system ui).
The memory 220 may include a stored program area and a stored data area. The storage program area may store an operating system, various application programs, and the like. The storage data area is used to store other data than computer programs, such as data (e.g., various picture information, video information, etc.) generated during the operation of an operating system and application programs.
Memory 220 may include volatile memory (RAM), such as random-access memory (RAM); the memory 220 may also include a non-volatile memory (non-volatile memory), such as a flash memory (e.g., a NAND and NAND flash memory (flash), an embedded multimedia card (embedded multi media card, eMMC), etc.), a hard disk (HDD) or a Solid State Drive (SSD); memory 220 may also include a combination of the above types of memory. The number of the memories 220 may be one or more, and may be specifically set according to needs. Memory 220 may also be a memory in processor 210, without limitation.
The communication interface 230 is used to connect the terminal device 200 with other electronic devices, and the hardware that allows the terminal device 200 to communicate on a network may implement the hardware for transmitting and receiving data packets. For example, the communication interface 230 may be connected to a network by wire or wirelessly to connect to other electronic devices, such as external other terminal devices or servers. For example, the communication interface 230 may be embodied as a modem or an antenna or a wireless fidelity (wireless fidelity, wiFi) module, and when the terminal device 200 is a server-type terminal device, the communication interface 230 may be embodied as a radio frequency unit or an antenna.
Further, in one embodiment, taking the operating system of the terminal device 200 as a Linux system as an example, as shown in fig. 3, the terminal device 200 is logically divided into an application layer 21, an operating system layer 22, and a hardware layer 23. The hardware layer 23 may include the processor 210, the memory 220, and the communication interface 230 shown in fig. 2, among others; the application layer 21 includes one or more application programs (application program 201 and application program 202), and the specific application program may be any type of application program such as a social application, an e-commerce application, a browser, and the like. The operating system layer 22, which is a software middleware between the hardware layer 23 and the application layer 21, is a computer program that manages and controls hardware and software resources.
In one embodiment, the kernel of the operating system layer 22 is a kernel. Wherein the kernel is used to provide underlying system components and services, such as: power management, storage management, thread management, hardware drivers, etc.; the hardware drivers include block device drivers, sensor drivers, positioning module drivers, and the like. In the design of the operating system layer 22, some hardware-related (e.g., interrupt handlers, device drivers, etc.), basic, common, more frequently processed modules (e.g., clock management, process scheduling, etc.), and critical data are often separated so that they can reside in memory and be protected, often referred to as kernels. The essence of the kernel is a section of program code, and the processor calls the program code corresponding to the kernel to realize the function of the kernel.
As an example, referring to fig. 3, the kernel is configured to virtualize a memory included in the hardware layer 23 into a plurality of block devices, form a block device layer 2202, and provide the block device layer 2202 to the file system 2201 for use. The file system 2201 stores data generated by each application program in the application layer in a memory in the form of a file, when the file system 2201 receives a file access request sent by a certain application program, such as the application program 201, in the application layer 21, a block device access request corresponding to a block device in the block device layer 2202 is generated, then the block device access request is sent to the block device layer 2202, and the corresponding block device driver 2203 is driven by the scheduling management of the block device layer 2202, so that the access request is sent to the memory, thereby realizing the storage function of the terminal device 200 through the file system 2201, the block device layer 2202 and the block device driver 2203. In the embodiment of the present application, the file system 2201 may be an F2FS, or may be another file system that writes data in a manner of updating in a different place, which is not limited herein.
Due to the limited memory space of the block device layer 2202, it may be, for example, 100 Gigabytes (GB). As more and more data is generated by the application, the storage space of the block device layer 2202 will be smaller and smaller. Therefore, in order to be able to write data continuously into memory, the file system may perform garbage collection (garbage collection, GC) processing.
Referring to fig. 4, the memory provides a file system with a plurality of block devices, for example, including a block device 1 and a block device 2, wherein the block device 1 includes 2 logic blocks, namely, a logic block 1 and a logic block 2, and each logic block includes 4 logic pages. Assuming that the file system performs garbage collection, when the number of logical pages storing invalid data in one logical block is greater than 2, garbage collection is performed. When the file system determines that the data in 3 logical pages (e.g., logical page 1 to logical page 3) in the 4 logical pages are all invalid data, the file system determines that the logical block 1 needs garbage collection, so that the data in the logical page 4 is copied to other logical blocks, and then the logical block 1 is erased, so that the logical block is recovered. Thus, when data is later needed to be stored, it can be stored in the logic block 1.
Currently, the storage medium of the memory used in the terminal device is usually Nand Flash. The Nand Flash is composed of a plurality of Nand Flash particles, and a single Nand Flash particle comprises a plurality of physical blocks, and each physical block comprises a plurality of physical pages. The Nand Flash reads and writes according to physical pages, erases according to physical blocks, and the physical blocks can write data into the physical pages one by one according to a specific sequence after the physical blocks are erased.
Referring to fig. 5, the memory includes 2 Nand Flash granules, each Nand Flash granule includes 2 physical blocks, namely a physical block 1 and a physical block 2, and each physical block includes 8 physical pages. The controller of the memory will manage all physical blocks included in the storage medium through garbage collection, and if the condition that the memory performs garbage collection is that the number of physical pages storing invalid data in one physical block is greater than 4, garbage collection is performed. For example, if the controller finds that only a few physical pages of the physical block 1 are valid data, for example, only physical pages 6 to 8 among the physical pages 1 to 8 store valid data and other physical pages store invalid data, the controller determines that garbage collection needs to be performed on the physical block 1, so that the data in the physical pages 6 to 8 are copied into physical pages 9 to 11 in the physical block 2, and then the physical block 1 is erased to complete garbage collection on the physical block 1.
It should be noted that, the logical blocks and logical pages in the file system are just a logical concept, and the data stored in the file system is finally stored in the storage medium, that is, the logical blocks and logical pages in the file system have a certain mapping relationship with the plurality of physical blocks and physical pages in the storage medium. Referring to fig. 6, a logical block 1 and a logical block 2 in the file system correspond to a physical block 1 and a physical block 2 in the storage medium, respectively (in fig. 6, the logical block 1 and the physical block 1 are taken as an example), a logical page 1 corresponds to a physical page 1 and a physical page 2, a logical page 2 corresponds to a physical page 3 and a physical page 4, respectively, and so on. When the file system performs garbage collection as shown in fig. 4, it is actually to copy the data in the physical pages 7 and 8 to other physical pages.
As can be seen from the above process, when the file system and the memory both need garbage collection, the file access of the application program is delayed greatly, and even a card is generated.
In view of this, an embodiment of the present application provides a garbage collection method, in which objects and storage spaces in a terminal device have a correspondence relationship, each object only performs garbage collection operation on a storage space corresponding to the object, and when a plurality of objects exist in the terminal device, different objects (such as a memory and a processor) may perform garbage collection operations on different storage spaces in the memory respectively, so that a delay when an application accesses a file may be reduced.
In this way, garbage collection of the file system and garbage collection of the memory in the terminal device can be combined, for example, garbage collection processing can be uniformly performed on data stored in a part of the logical area of the file system and data stored in a physical block corresponding to the part of the logical area in the memory through a garbage collection mechanism in the file system, or garbage collection processing can be uniformly performed on data stored in the remaining logical area of the file system and data stored in the remaining physical block in the memory through a garbage collection mechanism in the memory, that is, garbage collection processing can be performed only once for the same data, so that the situation of repeatedly moving data when the file system and the memory perform garbage collection simultaneously can be avoided, and time delay of accessing files by an application program can be reduced.
The following describes the technical scheme provided by the embodiment of the application with reference to the accompanying drawings.
It should be noted that, as can be seen from the foregoing, the garbage collection of the file system and the garbage collection of the memory in the terminal device may be implemented by the garbage collection mechanism in the file system or may be implemented by the garbage collection mechanism in the memory, and therefore, hereinafter, the garbage collection method in the embodiment of the present application will be described in two embodiments, namely, the first embodiment and the second embodiment. In the first embodiment, the garbage collection method of the present application is implemented by a garbage collection mechanism in a file system, and in the second embodiment, the garbage collection method of the present application is implemented by a garbage collection mechanism in a memory.
Example 1
Referring to fig. 7, a flowchart of an example of a garbage collection method according to an embodiment of the present application is shown. In the following description, an application of the technical solution provided in the present application in the application scenario shown in fig. 3 is taken as an example to explain. As an example, the method may be performed by the processor 210 in the terminal device 200 as shown in fig. 3, and it may be understood that the processor 210 invokes a program in the file system 2201 to perform. The description of the flow chart is as follows:
S71, the processor 210 obtains the first information from the memory 220.
In this embodiment of the present application, the first information is used to indicate the size of a first unit processing unit, where the first unit processing unit is a unit processing unit that performs the garbage collection operation in the memory 220.
The unit processing unit of the memory 220 performing the garbage collection operation may also be referred to as granularity of the memory 220 performing the garbage collection operation, and it is understood that the memory 220 determines whether the garbage collection operation is required according to the unit processing unit. If the memory 220 determines that only a small amount of data is valid data in a storage space with a size equal to the unit processing unit, the memory 220 may perform garbage collection processing on the storage space, so as to copy the valid data stored in the storage space to other physical blocks, and then erase the storage space, thereby completing garbage collection operation.
As an example, the first unit processing unit may be the size of a physical block of memory 220, for example, 72 Megabytes (MB). As another example, the size of the first unit processing unit is a preset multiple of the size of the physical block of the memory 220, for example, 4 times, and if the size of the physical block of the memory 220 is 72MB, the size of the first unit processing unit is 72×4=288 MB. The size of the first unit processing unit may be set according to actual use requirements, which is not limited in the embodiment of the present application.
Processor 210 retrieves this first information from memory 220, which may include, but is not limited to, the following.
The first acquisition mode is as follows:
the processor 210 may send a query instruction to the memory 220 through an internal channel between the processor 210 and the memory 220, the query instruction being for obtaining the size of a unit processing unit of the memory 220. When the memory 220 receives the query instruction, a response message corresponding to the query instruction is sent to the processor 210 through the internal channel, where the response message carries the size of the first unit processing unit.
The internal channel may be a channel based on an embedded multimedia card (embedded multi media card, eMMC) protocol, a UNIX File System (UFS) protocol, or a custom private channel. The query instruction may be an instruction that is newly added and dedicated to querying the size of the first unit processing unit, or may be obtained by adding a new field to an existing query instruction, where the new field is used to indicate that the size of the first unit processing unit is reported, and the internal channel and the query instruction are not limited.
The second acquisition mode is as follows:
the memory 220 may actively report the size of the first unit processing element to the processor 210.
As an example, the attribute information set of the memory 220 may be customized, a field may be newly added in the attribute information set, and the memory 220 may store the size of the first unit processing unit in the field, so that the processor 210 may obtain the size of the first unit processing unit from the attribute information set. The attribute information may be reported to the processor 210 after the terminal device is in an operational state.
As another example, a preset driver for querying the size of the unit processing unit of the memory 220 and client software corresponding to the preset driver may be installed in the operating system layer 22, so that after the client software is started, the processor 210 may obtain the size of the first unit processing unit through the driver.
As another example, custom actions may be inserted through an automatic installation technique (e.g., autoYast) or an unattended batch installation operating system interface technique (e.g., key-start). The custom action may be: after detecting that the terminal device is in an operating state, the memory 220 reports the size of the first unit processing unit to the processor 210 through an internal channel between the processor 210 and the memory 220.
Of course, the processor 210 may retrieve the size of the first unit processing element from the memory 220 in other manners, which are not limited herein.
And S72, the processor 210 configures the size of a second unit processing unit used by the file system for garbage collection operation according to the size of the first unit processing unit.
Specifically, the processor 210 configures the size of the second unit processing unit to be the same as the size of the first unit processing unit, for example, the size of the first unit processing unit is 288MB, and the processor 210 configures the size of the second unit processing unit to be 288MB, or configures the size of the second unit processing unit to be an integer multiple of the size of the first unit processing unit, so that the file system performs garbage collection operation on data stored in the file system according to the size of the second unit processing unit configured by the processor 210.
S73, the processor 210 sends an address configuration instruction to the memory 220.
In this embodiment of the present application, the address configuration instruction includes a logical address of a block device occupied by a file system, where the address configuration instruction is used to instruct the memory 220 to not perform garbage collection processing on a physical storage space corresponding to the logical address.
In the embodiment of the present application, the logical address included in the address configuration instruction may be a logical address range. As an example, the logical address range may be indicated by a start logical address and a length of the address, for example, each logical address may be indicated by identification information (e.g., an index number or a number, etc.) of each logical address, and a segment of logical addresses 1 to 10 may be represented by "1+10", where "1" indicates that the start logical address is logical address 1 and "10" indicates that 10 logical addresses are included in the segment of logical addresses. Alternatively, the address configuration instruction includes a plurality of logical addresses, which are all logical addresses that need to be aligned with the physical address. In the above example, if the logical addresses 1 to 10 need to be aligned with the physical addresses, the address configuration instruction includes identification information of each of the plurality of logical addresses, for example, "1, 2, 3 … …" is included. Alternatively, the address configuration instruction includes only one logical address, where the logical address is a start address of a logical address range, and indicates all logical addresses located after the logical address.
It should be noted that, the logical storage space occupied by the file system may be divided into a metadata area and a main data area according to different stored contents, where the main data area is used for storing data, and the metadata area is used for storing metadata of the data. Taking the example that the address configuration instruction includes a logical address range, the logical address range may be a section of logical address corresponding to all the logical storage spaces occupied by the file system, or a section of logical address corresponding to the logical storage spaces occupied by the main data area of the file system, or when the file system further includes other partitions, the logical address range may also be a section of logical address corresponding to the other partitions, which is not limited in this embodiment of the present application. For convenience of explanation, the logical address range is taken as an example of a segment of logical address corresponding to the main data area of the file system.
In addition, the processor 210 may send the address configuration instruction to the memory 220 before the first data is stored in the file system or the memory 220, for example, during a preset period of time when the terminal device is detected to be in an operating state, or may send the address configuration instruction to the memory 220 after the data is stored in the file system or the memory 220, which is not limited herein.
S74, the memory 220 determines that the garbage collection operation is not performed on the physical memory space corresponding to the logical address included in the address configuration instruction.
As an example, the logical addresses included in the address configuration instruction are logical addresses 1 to 10, and the memory 220 calculates the physical address corresponding to each logical address according to a preset algorithm, such as a hash algorithm, for example, calculates that the physical addresses corresponding to the logical addresses 1 to 10 are physical addresses 3 to 12, respectively, and then the memory 220 determines that the garbage collection operation is not required for the memory space corresponding to the physical addresses 3 to 12.
In the embodiment of the present application, the execution order of steps S71 to S72 and steps S73 to S74 is not limited. For example, step S71 to step S72 may be performed first, then step S73 to step S74 may be performed first, then step S71 to step S72 may be performed, or step S71 to step S72 and step S73 to step S74 may be performed simultaneously. In fig. 7, step S71 to step S72 are performed first, and then step S73 to step S74 are performed.
S75, the processor 210 prohibits the storage space corresponding to the logical address included in the address configuration instruction from writing data in a local update mode.
In order to ensure consistency between the data stored in the logical storage space occupied by the file system and the data stored in the memory 220, the processor 210 will prohibit the storage space corresponding to the logical address included in the address configuration instruction from writing data in a local update manner.
In particular, the file system may write data in a locally updated manner or may write data in a remotely updated manner, in which case the processor 210 configures the file system to disable writing of data in a locally updated manner, e.g., the file system may include a plurality of configuration parameters including an attribute indicating that the file system supports writing of data in a locally updated manner, and the processor 210 may configure the file system to disable enabling of the attribute.
And S76, the processor 210 writes data into a logic storage space corresponding to the file system.
When the processor 210 receives the data, the data is written to the logical storage space corresponding to the file system in a mode of updating in different places, and is stored in the physical storage space corresponding to the memory 220.
As an example, the processor 210 receives a write data operation, where the write data operation includes data to be written, and the processor 210 may determine a logical address corresponding to the data to be written according to a preset rule, for example, determine to store the write data in the logical block 1. The processor 210 then sends a data storage instruction to the memory 220, where the instruction includes the write data and a logical address corresponding to the data to be written, e.g., an identification (number or index number, etc.) of logical block 1. After the memory 220 receives the instruction, it determines that the physical storage space corresponding to the logical block 1 is the physical block 1, and stores the data to be written into the physical block 1.
S77, the memory 220 establishes a mapping relationship between the logical address and the physical address.
After the memory 220 stores the data to the corresponding physical block, the memory 220 may then establish a mapping relationship between the logical address and the physical address. In the embodiment of the present application, the mapping relationship is used as a mapping relationship between a logical block and a physical block. For example, each logical block or physical block is represented by an identifier of each logical block or physical block, and as is known from step S76, logical block 1 corresponds to physical block 1, thereby obtaining the mapping relationship shown in table 1.
TABLE 1
Logic block Physical block
1 1
Table 1 records the mapping relationship between the logical blocks and the physical blocks stored in the memory 220, and the entries are increased as the number of data to be written increases. If no data is stored in a certain logical block, the mapping relation corresponding to the logical block is not stored in table 1.
In addition, in the embodiment of the present application, since table 1 only includes the mapping relationship between the logical blocks and the physical blocks, but does not have the mapping relationship between the logical pages or the physical pages, the memory space occupied by the table 1 is small, and memory resources can be saved.
S78, the processor 210 adopts a garbage collection mechanism of a file system to conduct garbage collection operation.
As more and more data is written in the file system, the processor 210 may execute a code or a program for performing garbage collection operation in the file system, perform garbage collection operation on the logical storage space indicated by the address configuration instruction, that is, determine whether the number of logical pages storing invalid data in each logical block included in the logical storage space is greater than a threshold, if so, perform garbage collection, that is, determine a physical block to be erased according to a mapping relationship between the logical block and the physical block, and issue an instruction for erasing data in the physical block to the memory 220, where a specific manner is similar to that in the prior art and is not repeated herein.
Since each logical block in the logical storage space indicated by the address configuration instruction corresponds to one physical block, after performing garbage collection operation on the logical storage space, the memory 220 does not need to perform garbage collection operation on the portion of the physical storage space. Therefore, the process of garbage collection operation of the memory 220 on the part of the physical storage space can be omitted, and the time delay of the application program when accessing the file can be reduced.
In the first embodiment, if in step S73, the logical address indicated by the address configuration instruction sent by the processor 210 is a logical address corresponding to a portion of the logical storage space of the file system, for example, a logical address corresponding to the main data area of the file system, the processor 210 only performs the garbage collection operation on the portion of the logical storage space of the file system. For other storage space in the terminal device, for example, a logical storage space corresponding to a metadata area of the file system, the garbage collection operation may be performed by the memory 220. Next, a procedure for implementing the garbage collection method in the embodiment of the present application by the garbage collection mechanism in the memory 220 will be described.
Example two
Referring to fig. 8, a flowchart of an example of a garbage collection method according to an embodiment of the present application is shown. In the following description, an application of the technical solution provided in the present application in the application scenario shown in fig. 3 is taken as an example to explain. As an example, the method may be performed by the memory 220 in the terminal device 200 as shown in fig. 3, and it may be understood that the control means or controller in the memory 220 is performed. The description of the flow chart is as follows:
s81, the processor 210 configures the target storage space of the memory 220 to write data in a locally updated manner.
In actual use, the memory 220 may be divided into a plurality of partitions according to the use requirements of the terminal device. For example, a boot (boot) partition, a playback protection data block (replay protected memory block, RPMB) partition, a User Data Area (UDA), and the like may be included. The boot partition is used for storing a starting program required by the terminal equipment; the RPMB partition is generally used for storing data required for preventing illegal tampering, such as a public key, a serial number and the like related to fingerprint payment on the terminal equipment; UDA partitions are typically used to store user data and the like. Of course, the partition of the terminal device is not limited in the embodiment of the present application.
Typically, the UDA partition of the terminal device will be configured with the file system, while other partitions may not be configured with the file system. If the logical storage space corresponding to the file system only comprises the main data area and the metadata area, the target storage space refers to the logical storage space corresponding to the metadata area of the file system and other partitions of the terminal device except the UDA partition. The processor 210 may configure the metadata area and other partitions of the terminal device than the UDA partition to write data in a locally updated manner.
It should be noted that step S81 is an optional step, i.e., it is not necessary to perform. For example, the metadata area and other partitions of the terminal device than the UDA partition may be default configured to write data in a locally updated manner, in which case the processor 210 does not have to perform step S81. This step is shown in fig. 8 in broken lines as an optional step.
S82, the processor 210 writes data into the target storage space of the memory 220.
After receiving the write data operation for the metadata area, the processor 210 determines, according to a preset rule, a logical address corresponding to the data to be written, for example, determines to store the write data in the logical page 3 of the logical block 1. The processor 210 then sends a data storage instruction to the memory 220, where the instruction includes the write data and a logical address corresponding to the data to be written, e.g., an identification (number or index number, etc.) of logical page 3, which is logical block 1. After the memory 220 receives the instruction, it determines that the physical storage space corresponding to the logical page 3 of the logical block 1 is the physical page 4 and the physical page 5 of the physical block 1, and stores the data to be written into the physical page 4 and the physical page 5 of the physical block 1.
S83, the memory 220 establishes a mapping relation between the logical address and the physical address.
In the embodiment of the application, the mapping relationship is used as the mapping relationship between the logical page and the physical page. For example, each logical page or physical page is represented by an identifier of each logical page or physical page, and as can be seen from step S82, logical page 3 of logical block 1 corresponds to physical page 4 and physical page 5 of physical block 1, thereby obtaining the mapping relationship shown in table 2.
TABLE 2
Logical page Physical page
Logical page 3 of logical block 1 Physical pages 4 and 5 of physical block 1
Note that, table 2 is similar to table 1, and entries are also increased as the number of data to be written increases. Table 2 records the mapping relationship between the logical page and the physical page of the destination storage space.
S84, the memory 220 determines invalid data according to the mapping relation.
As an example, if the same logical page corresponds to two different physical pages in the mapping relationship, it is determined that data stored in a previous physical page of the two different physical pages is invalid data.
As another example, other mappings may be included in the memory 220, including, for example, a reverse mapping with a physical page as an index, where the reverse mapping is a mapping between a physical page and a logical page, and the memory 220 determines whether data in a certain physical page is invalid data through the mapping between the logical page and the physical page and the reverse mapping.
Of course, the data in a certain physical page may be determined to be invalid data by other methods, which is not limited herein.
S85, the memory 220 performs garbage collection operation on the target storage space.
When the memory 220 determines that the physical page in the destination storage space meets the garbage collection condition, for example, the number of invalid data in the physical page is large and the threshold value, the garbage collection operation is performed on the physical page, and the specific manner is similar to that in the prior art, and is not repeated here.
It should be noted that, after the garbage collection operation is performed on the target storage space by the memory 220, the file system does not need to perform the garbage collection operation on the storage space corresponding to the metadata partition. Therefore, the process of garbage collection operation of the file system on part of the storage space can be omitted, and the time delay of the application program when accessing the file can be reduced.
It should be noted that, the first embodiment and the second embodiment may be implemented separately, that is, only one of the two embodiments may be implemented in a certain terminal device; alternatively, the first embodiment and the second embodiment may be implemented in combination, that is, both embodiments may be implemented in a certain terminal device.
In addition, the method in the embodiment of the application may be applied to other devices with file systems besides the terminal device, which is not limited herein.
In the embodiments provided in the present application, in order to implement each function in the method provided in the embodiments of the present application, the terminal device may include a hardware structure and/or a software module, and each function is implemented in the form of a hardware structure, a software module, or a hardware structure plus a software module. Some of the functions described above are performed in a hardware configuration, a software module, or a combination of hardware and software modules, depending on the specific application of the solution and design constraints.
Fig. 9 shows a schematic diagram of a garbage collection device 900. The garbage collection apparatus 900 may be used to implement the functions of a processor of a terminal device. Garbage collection device 900 may be a hardware structure, a software module, or a combination of hardware and software modules. The garbage collection device 900 may be implemented as a system-on-chip. In the embodiment of the application, the chip system may be formed by a chip, and may also include a chip and other discrete devices.
The garbage collection device 900 may include a processing module 901 and a communication module 902.
The processing module 901 may be used to perform step S72, steps S75-S76, and step S78 in the embodiment shown in fig. 7, or to perform step S81 in the embodiment shown in fig. 8, and/or to support other processes of the techniques described herein.
The communication module 902 may be used to perform step S71 and step S73 in the embodiment shown in fig. 7, or to perform step S82 in the embodiment shown in fig. 8, and/or to support other processes of the techniques described herein. The communication module 902 is used to communicate with the garbage collection device 900 and other modules, which may be circuits, devices, interfaces, buses, software modules, transceivers, or any other device capable of implementing communication.
All relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein.
Fig. 10 shows a schematic structure of a garbage collection device 1000. The garbage collection apparatus 1000 may be used to realize a function of a memory of a terminal device. Garbage collection apparatus 1000 may be a hardware structure, a software module, or a hardware structure plus a software module. The garbage collection apparatus 1000 may be implemented by a chip system. In the embodiment of the application, the chip system may be formed by a chip, and may also include a chip and other discrete devices.
The garbage collection apparatus 1000 may include a processing module 1001 and a communication module 1002.
The processing module 1001 may be for performing step S74 and step S77 in the embodiment shown in fig. 7, or for performing steps S83-S85 in the embodiment shown in fig. 8, and/or for supporting other processes of the techniques described herein.
The communication module 1002 may be used to perform step S71 and step S73 in the embodiment shown in fig. 7, or to perform step S82 in the embodiment shown in fig. 8, and/or to support other processes of the techniques described herein. The communication module 1002 is used for the garbage collection apparatus 1000 to communicate with other modules, which may be circuits, devices, interfaces, buses, software modules, transceivers, or any other means that can enable communication.
All relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein.
The division of the modules in the embodiments shown in fig. 9 or fig. 10 is schematic, which is merely a logic function division, and there may be another division manner in actual implementation, and in addition, each functional module in the embodiments of the present application may be integrated in one processor, or may exist separately and physically, or two or more modules may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. For example, the garbage collection apparatus shown in fig. 9 or fig. 10 may be a terminal device as shown in fig. 2, and the processing module 901 may correspond to the processor 210 of the terminal device shown in fig. 2, the processing module 1001 may correspond to the memory 220 of the terminal device shown in fig. 2, and the communication module 903 and the communication module 1002 may correspond to the communication interface 230 of the terminal device shown in fig. 2, which will not be described herein.
Also provided in embodiments of the present application is a computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method performed by the processor or memory of the embodiments shown in fig. 7 or 8.
There is also provided in an embodiment of the present application a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method performed by the processor or memory of the embodiment shown in fig. 7 or 8.
The embodiment of the application provides a chip system, which comprises a processor and can also comprise a memory, wherein the memory is used for realizing the functions of the processor or the memory in the method. The chip system may be formed of a chip or may include a chip and other discrete devices.
Embodiments of the present application provide a terminal device that includes a processor and/or memory in the embodiments shown in fig. 7 or fig. 8.
The method provided in the embodiments of the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, a network device, a user device, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL), or wireless (e.g., infrared, wireless, microwave, etc.) means, the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc., that contains an integration of one or more available media, the available media may be magnetic media (e.g., floppy disk, hard disk, tape), optical media (e.g., digital video disc (digital video disc, DVD)), or semiconductor media (e.g., SSD), etc.

Claims (19)

1. A method of recycling waste comprising:
the method comprises the steps that a first object determines a storage space corresponding to the first object from a terminal equipment memory; the memory comprises a memory space corresponding to at least one object, wherein the object comprises a memory of terminal equipment or a processor of the terminal equipment, and the first object is any one of the at least one object;
and the first object performs garbage collection operation on the storage space corresponding to the first object.
2. The method of claim 1, wherein the first object is a processor of a terminal device;
the method further comprises the steps of:
the processor of the terminal equipment acquires first information from a memory of the terminal equipment, wherein the first information is used for indicating the size of a first unit processing unit, and the first unit processing unit is a unit processing unit for garbage collection operation of the memory;
the processor configures the size of a second unit processing unit according to the size of the first unit processing unit, wherein the second unit processing unit is used for garbage collection operation of a file system of the terminal equipment;
The processor sends an address configuration instruction to the memory, wherein the address configuration instruction comprises a logic address of block equipment occupied by the file system, and the address configuration instruction is used for indicating the memory not to carry out garbage collection operation on a physical storage space corresponding to the logic address;
the garbage collection operation is carried out on the storage space corresponding to the first object by the first object, and the garbage collection operation comprises the following steps:
and the processor performs garbage collection operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
3. The method of claim 2, wherein the size of the second unit processing unit is the same as the size of the first unit processing unit or the size of the second unit processing unit is an integer multiple of the size of the first unit processing unit.
4. A method according to claim 2 or 3, wherein the file system comprises a main data area for storing data and a metadata area for storing metadata of the data, and the logical addresses are a set of logical addresses corresponding to the main data area.
5. The method according to any one of claims 2-4, further comprising:
and the processor prohibits the logic storage space corresponding to the logic address from writing data in a local updating mode.
6. The method of claim 1, wherein the first object is a memory of the terminal device;
the method further comprises the steps of:
the memory of the terminal equipment receives data;
the storage writes the received data into a target storage space, wherein the target storage space comprises a physical storage space corresponding to a metadata area of a file system of the terminal equipment and/or a physical storage space corresponding to a non-User Data (UDA) partition of the terminal equipment, the file system comprises a main data area and the metadata area, the main data area is used for storing data, and the metadata is used for storing metadata of the data;
the first object determines a storage space corresponding to the first object from a terminal device memory, and the method comprises the following steps:
and the memory performs garbage collection operation on the target storage space according to a preset garbage collection strategy and a preset unit processing unit.
7. The method of claim 6, wherein the method further comprises:
the memory establishes a mapping relation between a logical page of a logical storage space and a physical page of the target storage space, wherein the logical storage space is a logical storage space corresponding to the metadata area and/or the non-user data UDA partition;
the memory determines invalid data according to the mapping relation;
and if the quantity of invalid data in one physical page is large and the threshold value is high, the memory performs garbage collection operation on the physical page.
8. The method according to claim 6 or 7, wherein the writing of data into the target storage space by the memory of the terminal device comprises:
the memory writes the received data to the target storage space in a locally updated manner.
9. A garbage collection device, comprising:
the processing module is used for determining a storage space corresponding to the first object from a memory of the device; the memory comprises a memory space corresponding to at least one object, the object comprises a memory of the device or a processor of the device, and the first object is any one of the at least one object;
The processing module is further configured to perform garbage collection operation on the storage space corresponding to the first object.
10. The apparatus of claim 9, wherein the first object is a processor of the apparatus;
the device also comprises a communication module, a first processing module and a second processing module, wherein the communication module is used for acquiring first information from a memory of the device, the first information is used for indicating the size of a first unit processing unit, and the first unit processing unit is a unit processing unit for garbage collection operation of the memory;
the processing module is further configured to configure a size of a second unit processing unit according to the size of the first unit processing unit, where the second unit processing unit is a unit processing unit used by a file system of the device for garbage collection operation;
the communication module is further configured to send an address configuration instruction to the memory, where the address configuration instruction includes a logical address of a block device occupied by the file system, and the address configuration instruction is used to instruct the memory to not perform garbage collection operation on a physical storage space corresponding to the logical address;
and the processing module is also used for carrying out garbage recycling operation on the logic storage space corresponding to the logic address according to the size of the second unit processing unit.
11. The apparatus of claim 10, wherein the size of the second unit processing unit is the same as the size of the first unit processing unit or the size of the second unit processing unit is an integer multiple of the size of the first unit processing unit.
12. The apparatus according to claim 10 or 11, wherein the file system comprises a main data area for storing data and a metadata area for storing metadata of the data, and the logical address is a set of logical addresses corresponding to the main data area.
13. The apparatus of any one of claims 10-12, wherein the processing module is further to:
and prohibiting the logic storage space corresponding to the logic address from writing data in a local updating mode.
14. The apparatus of claim 9, wherein the first object is a memory of the apparatus; the communication module is also used for receiving data;
the processing module is further configured to write the received data into a target storage space, where the target storage space includes a physical storage space corresponding to a metadata area of a file system of the device and/or a physical storage space corresponding to a non-user data UDA partition of the device, and the file system includes a main data area and the metadata area, where the main data area is used to store data, and the metadata is used to store metadata of the data; the method comprises the steps of,
And carrying out garbage recycling operation on the target storage space according to a preset garbage recycling strategy and a preset unit processing unit.
15. The apparatus of claim 14, wherein the processing module is further configured to:
establishing a mapping relation between a logical page of a logical storage space and a physical page of the target storage space, wherein the logical storage space is a logical storage space corresponding to the metadata area and/or the non-user data UDA partition; and determining the invalid data according to the mapping relation; and if the quantity of invalid data in one physical page is large and the threshold value is high, performing garbage collection operation on the physical page.
16. The apparatus of claim 14 or 15, wherein the processing module is configured to:
and writing the received data into the target storage space in a local updating mode.
17. A computer storage medium having stored therein computer executable instructions for causing the computer to perform the method of any of the preceding claims 1-8 when invoked by the computer.
18. A computer program product containing instructions which, when run on a computer, cause the computer to perform the method of any of the preceding claims 1-8.
19. A terminal device comprising a processor and a memory having stored therein computer executable instructions which when invoked by the processor are adapted to cause the processor to perform the method of any of the preceding claims 1-8.
CN202211612816.0A 2019-07-31 2019-11-30 Garbage recycling method and device Pending CN116166570A (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
CN2019107193506 2019-07-31
CN201910719350 2019-07-31
CN201911209032.1A CN112306896B (en) 2019-07-31 2019-11-30 Garbage recycling method and device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201911209032.1A Division CN112306896B (en) 2019-07-31 2019-11-30 Garbage recycling method and device

Publications (1)

Publication Number Publication Date
CN116166570A true CN116166570A (en) 2023-05-26

Family

ID=74230234

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211612816.0A Pending CN116166570A (en) 2019-07-31 2019-11-30 Garbage recycling method and device

Country Status (2)

Country Link
CN (1) CN116166570A (en)
WO (1) WO2021018052A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020208B (en) * 2021-09-30 2023-08-22 苏州浪潮智能科技有限公司 Data garbage collection method, device, computer equipment and storage medium
CN114489489B (en) * 2021-12-30 2024-02-23 山东云海国创云计算装备产业创新中心有限公司 Garbage recycling method, device, equipment and medium for solid state disk

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102364474B (en) * 2011-11-17 2014-08-20 中国科学院计算技术研究所 Metadata storage system for cluster file system and metadata management method
US9367448B1 (en) * 2013-06-04 2016-06-14 Emc Corporation Method and system for determining data integrity for garbage collection of data storage systems
CN106293497B (en) * 2015-05-27 2019-03-19 华为技术有限公司 Watt record filesystem-aware in junk data recovery method and device
US20170017405A1 (en) * 2015-07-14 2017-01-19 HGST Netherlands B.V. Systems and methods for improving flash-oriented file system garbage collection
US9940028B2 (en) * 2015-11-13 2018-04-10 Samsung Electronics Co., Ltd Multimode storage device
CN107391774B (en) * 2017-09-15 2019-11-19 厦门大学 The rubbish recovering method of log file system based on data de-duplication
CN109376095B (en) * 2018-12-04 2023-06-13 中国航空工业集团公司西安航空计算技术研究所 Garbage recycling method based on FLASH region address mapping mechanism

Also Published As

Publication number Publication date
WO2021018052A1 (en) 2021-02-04

Similar Documents

Publication Publication Date Title
EP2989536B1 (en) Management of access to a hybrid drive in power saving mode
US10289349B2 (en) Data usage profiling by local storage device
WO2019201011A1 (en) System startup method and apparatus, electronic device and storage medium
CN110018998B (en) File management method and system, electronic equipment and storage medium
US9195581B2 (en) Techniques for moving data between memory types
KR20140042518A (en) Segment cleaning apparatus and method thereof
CN109804359A (en) For the system and method by write back data to storage equipment
JP6734768B2 (en) System, device and method including storage device for performing dual write
WO2021018052A1 (en) Garbage collection method and apparatus
CN109597707B (en) Clone volume data copying method, device and computer readable storage medium
CN111831215A (en) Apparatus for transferring mapping information in memory system
US20220107752A1 (en) Data access method and apparatus
CN113590501A (en) Data storage method and related equipment
KR20140042431A (en) Computing system and method for managing data in the system
CN112445766A (en) Terminal fragment sorting method and device and terminal
US10620867B2 (en) System and method for performing wear leveling at a non-volatile firmware memory
CN112306896B (en) Garbage recycling method and device
CN110058938B (en) Memory processing method and device, electronic equipment and readable medium
KR20200095010A (en) Apparatus and method for transmitting map information in memory system
CN108762985B (en) Data recovery method and related product
KR20140042428A (en) Computing system and data management method thereof
US20230093218A1 (en) Data storage method and system, and processor
CN113678102A (en) Memory efficient software patching for updating applications on a computing device
US20220300433A1 (en) Apparatus for transmitting map information in memory system
CN113609076A (en) File storage method and file reading method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination