WO2021018052A1 - 一种垃圾回收方法及装置 - Google Patents

一种垃圾回收方法及装置 Download PDF

Info

Publication number
WO2021018052A1
WO2021018052A1 PCT/CN2020/104599 CN2020104599W WO2021018052A1 WO 2021018052 A1 WO2021018052 A1 WO 2021018052A1 CN 2020104599 W CN2020104599 W CN 2020104599W WO 2021018052 A1 WO2021018052 A1 WO 2021018052A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
data
garbage collection
storage space
processing unit
Prior art date
Application number
PCT/CN2020/104599
Other languages
English (en)
French (fr)
Inventor
童朝柱
Original Assignee
华为技术有限公司
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
Priority claimed from CN201911209032.1A external-priority patent/CN112306896B/zh
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021018052A1 publication Critical patent/WO2021018052A1/zh

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]

Definitions

  • This application relates to the field of computer technology, in particular to a garbage collection method and device.
  • data is stored in the memory of the terminal device in the form of files, and the stored files are managed through the file system of the terminal device.
  • the file system of the terminal device After the file system of the terminal device receives the file access request of the application, it will convert the access request into read and write operations on the data stored in the memory, and then send it to the memory through the block device layer and device driver, so as to achieve File access.
  • the memory used in the terminal device is a flash memory (flash memory), for example, not and (NAND) flash memory (flash).
  • flash memory uses the remote update method to write data
  • the file system of the terminal device is required to also use the file system of the data writing method as the remote update method.
  • the file system of the terminal device can be flash friendly File system (flash friendly file system, F2FS).
  • the present application provides a garbage collection method and device to reduce the time delay for application programs to access files.
  • a garbage collection method In a first aspect, a garbage collection method is provided.
  • a processor of a terminal device first obtains first information indicating the size of a first unit processing unit from a memory of the terminal device, and the first unit
  • the processing unit is a unit processing unit of the memory for garbage collection operations, and according to the size of the first unit processing unit, the size of the second unit processing unit used by the file system of the terminal device for garbage collection operations is configured.
  • the processor sends an address configuration instruction to the memory.
  • the address configuration instruction includes the logical address of the block device occupied by the file system.
  • the address configuration instruction is used to instruct the memory not to store the physical storage corresponding to the logical address.
  • the space performs a garbage collection operation, and finally, the processor performs a garbage collection operation on the logical storage space corresponding to the logical address according to the size of the second unit processing unit.
  • the processor uniformly performs garbage collection on the logical storage space and the physical storage space, that is, the memory does not need to perform garbage collection operations on this part of the physical storage space, so that the memory can omit this part of the physical storage space.
  • the process of garbage collection operation can reduce the time delay when the application program accesses the file.
  • 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 less than the size of the first unit processing unit Integer multiples.
  • the size of the unit processing unit of the file system for garbage collection operations is unified with the size of the unit processing unit of the memory for garbage collection operations.
  • the unit of processing unit for the memory for garbage collection operations is relatively large. This is equivalent to increasing the size of the unit processing unit of the file system for garbage collection operations, which can improve the efficiency of the file system for garbage collection operations.
  • the file system includes a main data area and a metadata area, the main data area is used to store data, the metadata is used to store metadata of the data, and the logical address is the The logical address set corresponding to the main data area.
  • the main data area of the file system occupies a relatively large storage space, so that the garbage collection operation can be performed only for the main data area of the file system, and the efficiency of the garbage collection operation can be improved.
  • the processor prohibits the logical storage space corresponding to the logical address from writing data in a local update manner.
  • the logical storage space corresponding to the logical address is updated to write data in a remotely updated manner, which can ensure the consistency of the data stored in the logical storage space occupied by the file system and the data stored in the memory.
  • a garbage collection method is provided.
  • the memory of the terminal device writes the received data into a target storage space that includes the file system of the terminal device.
  • the physical storage space corresponding to the metadata area and/or the physical storage space corresponding to the 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 to store data.
  • Data is used to store metadata of data.
  • the memory performs a garbage collection operation on the target storage space according to a preset garbage collection strategy and a preset unit processing unit.
  • the file system after the memory performs the garbage collection operation on the destination storage space, the file system does not need to perform the garbage collection operation on the storage space corresponding to the metadata partition, so that the file system can omit the garbage collection operation of part of the storage space.
  • the operation process can reduce the time delay when the application program accesses the file.
  • the memory establishes a mapping relationship between the logical page of the logical storage space and the physical page of the target storage space, and the logical storage space corresponds to the metadata area and/or the non-user data UDA partition Then, the memory can determine invalid data according to the mapping relationship. If the number of invalid data in a physical page is greater than the threshold, the memory will perform a garbage collection operation on the physical page.
  • the manner in which the memory determines invalid data is not limited.
  • the memory writes data into the target storage space in a local update manner.
  • a garbage collection device may be a terminal device or a device in the terminal device.
  • the garbage collection device includes a processor for implementing the method described in the first aspect.
  • the garbage collection device may also include a memory for storing program instructions and data.
  • the memory is coupled with the processor, and the processor can call and execute the program instructions stored in the memory for implementing any one of the methods described in the first aspect.
  • the garbage collection device may also include an interface for communication between the garbage collection device and other devices or modules.
  • the garbage collection device processor and interface where:
  • the processor is configured to obtain first information from a memory of the terminal device, the first information is used to indicate the size of a first unit processing unit, and the first unit processing unit performs garbage collection for the memory Operating unit processing unit; and, according to the size of the first unit processing unit, configure the size of the second unit processing unit, and the second unit processing unit is used by the file system of the terminal device for garbage collection operations Unit processing unit
  • the interface is configured to send an address configuration instruction to the memory under the control of the processor.
  • the address configuration instruction includes the logical address of the block device occupied by the file system, and the address configuration instruction is used for To instruct the memory not to perform garbage collection operations on the physical storage space corresponding to the logical address;
  • the processor is further configured to perform a garbage collection operation on the logical storage space corresponding to the logical address according to the size of the second unit processing unit.
  • a garbage collection device may be a terminal device or a device in the terminal device.
  • the garbage collection device includes a processor for implementing the method described in the second aspect.
  • the garbage collection device may also include a memory for storing program instructions and data.
  • the memory is coupled with the processor, and the processor can call and execute the program instructions stored in the memory to implement any one of the methods described in the second aspect.
  • the garbage collection device may also include an interface for communication between the garbage collection device and other devices or modules.
  • the garbage collection device processor and interface where:
  • the interface is used to receive data
  • the processor is configured to write the received data into a target storage space, the target storage space including the physical storage space corresponding to the metadata area of the file system of the terminal device and/or the non-volatile memory of the terminal device
  • the physical storage space corresponding to the user data UDA partition, the file system includes a main data area and the metadata area, the main data area is used to store data, and the metadata is used to store metadata of the data;
  • a garbage collection operation is performed on the target storage space.
  • the processor is also used to:
  • a mapping relationship between a logical page of a 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; Determine invalid data according to the mapping relationship; and, if the number of invalid data in a physical page is greater than the threshold, the memory performs a garbage collection operation on the physical page.
  • the processor writes data to the target storage space in a local update manner.
  • a garbage collection device in a fourth aspect, can be a terminal device or a device in a terminal device.
  • the garbage collection device can include a processing module and a communication module. These modules can perform any of the above-mentioned first aspect. The corresponding function performed in a design example, specifically:
  • the communication module is configured to obtain first information from the memory of the device, the first information is used to indicate the size of a first unit processing unit, and the first unit processing unit is a unit of the memory for garbage collection operations Processing unit
  • a processing module configured to configure the size of a second unit processing unit according to the size of the first unit processing unit, the second unit processing unit being a unit processing unit used by the file system of the device for garbage collection operations;
  • the communication module is further configured to send an address configuration instruction to the memory, the address configuration instruction includes the logical address of the block device occupied by the file system, and the address configuration instruction is used to instruct the memory not to The physical storage space corresponding to the logical address performs a garbage collection operation;
  • the processing module is further configured to perform a garbage collection operation on the logical storage space corresponding to the logical address according to the size of the second unit processing unit.
  • a garbage collection device can be a terminal device or a device in a terminal device.
  • the garbage collection device can include a processing module and a communication module. These modules can perform any of the above-mentioned first aspect. The corresponding function performed in a design example, specifically:
  • the processing module is used to write the received data into a target storage space, the target storage space including the physical storage space corresponding to the metadata area of the file system of the device and/or the non-user data UDA partition of the device
  • the file system includes a main data area and the metadata area, the main data area is used to store data, and the metadata is used to store metadata of the data;
  • a garbage collection operation is performed on the target storage space.
  • the embodiments of the present application also provide a computer-readable storage medium, including instructions, which when run on a computer, cause the computer to execute the method described in the first aspect or the second aspect.
  • the embodiments of the present application also provide a computer program product, including instructions, which when run on a computer, cause the computer to execute the method described in the first aspect or the second aspect.
  • an embodiment of the present application provides a chip system.
  • the chip system includes a processor and may also include a memory for implementing the method described in the first aspect or the second aspect.
  • the chip system can be composed of chips, or can include chips and other discrete devices.
  • Figure 1 is a schematic diagram of an example of a remote update method
  • FIG. 2 is an exemplary structural diagram of a terminal device in an embodiment of the application
  • FIG. 3 is a logical block diagram of an example of terminal equipment in an embodiment of this application.
  • Figure 4 is a schematic diagram of an example of garbage collection processing performed by a file system
  • Figure 5 is a schematic diagram of an example of garbage collection processing performed by the memory
  • FIG. 6 is a schematic diagram of an example of the mapping relationship between logical pages or physical pages
  • FIG. 7 is a flowchart of an example of a garbage collection method provided by an embodiment of the application.
  • FIG. 8 is a flowchart of another example of a garbage collection method provided by an embodiment of the application.
  • FIG. 9 is a flowchart of an example of a garbage collection device provided by an embodiment of the application.
  • FIG. 10 is a flowchart of another example of a garbage collection device provided by an embodiment of the application.
  • 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 also be a server-type terminal device.
  • it may include mobile phones or smart phones, portable game devices, personal communication service (PCS) phones, session initiation protocol (SIP) phones, wireless local loop (wireless local loop, WLL) stations, Personal digital assistants (PDAs), portable Internet devices, music players, data storage devices, other handheld devices, and wearable devices.
  • PCS personal communication service
  • SIP session initiation protocol
  • WLL wireless local loop
  • PDAs Personal digital assistants
  • portable Internet devices music players, data storage devices, other handheld devices, and wearable devices.
  • the terminal device may also include restricted devices, such as devices with low power consumption, or devices with limited storage capabilities, or devices with limited computing capabilities. Examples include barcodes, radio frequency identification (RFID), sensors, global positioning system (GPS), laser scanners and other information sensing equipment.
  • restricted devices such as devices with low power consumption, or devices with limited storage capabilities, or devices with limited computing capabilities. Examples include barcodes, radio frequency identification (RFID), sensors, global positioning system (GPS), laser scanners and other information sensing equipment.
  • RFID radio frequency identification
  • GPS global positioning system
  • laser scanners and other information sensing equipment.
  • the terminal device can also be a smart wearable device, which is a general term for the application of wearable technology to intelligently design daily wear and develop wearable devices, such as glasses, gloves, watches, clothing and shoes.
  • it can also be virtual reality (VR) equipment, augmented reality (AR) equipment, wireless terminal equipment in industrial control, wireless terminal equipment in driverless, and remote Wireless terminal equipment in surgery (remote medical surgery), wireless terminal equipment in smart grid (smart grid), wireless terminal equipment in transportation safety (transportation safety), wireless terminal equipment in smart city (smart city), smart home (smart home) wireless terminal equipment, etc.
  • VR virtual reality
  • AR augmented reality
  • wireless terminal equipment in industrial control wireless terminal equipment in driverless
  • remote Wireless terminal equipment in surgery remote medical surgery
  • wireless terminal equipment in smart grid smart grid
  • wireless terminal equipment in transportation safety transportation safety
  • wireless terminal equipment in smart city smart home
  • smart home smart home
  • the local update method means that when a write operation request is received, the operation address corresponding to the write operation request is determined first, and then the data carried in the write operation request is written to the address. If the address is stored Original data, the data included in the write operation instruction will overwrite the original data.
  • the remote update method means that when a write operation request is received, it will be sequentially written into the storage space, instead of directly performing a write operation on the operation address corresponding to the write operation request.
  • the memory maintains the mapping relationship between address identification and storage space.
  • the initial mapping relationship between address identification and storage space is that address 1 is mapped to the first storage unit (such as physical block or physical Page), address 2 is mapped to the second storage unit, and so on. If the first 10 memory cells in the memory store data, when the memory receives a write operation request for address 9, the memory will store the data corresponding to the write operation request in the 11th memory cell. Then, the memory will map the mapping relationship between the address and the storage unit, and map the address 9 to the 11th storage unit, so that when the data in the address 9 needs to be read later, the memory will read the data from the 11th storage unit .
  • Invalid data is caused by delete operation or multiple write operations to the same address. For example, in FIG. 1, two write operations are performed on address 9, and the data corresponding to the first write operation, that is, the data stored in the ninth memory cell in FIG. 1, becomes invalid data. Or, when the memory receives a delete operation request for a certain address, the data mark corresponding to the address is invalid data.
  • the memory is taken as an example to explain the "remote update method” and "invalid data".
  • the description of the remote update method of the file system and the invalid data is similar to the memory, and will not be repeated here.
  • the garbage collection processing of the file system means that when there are only a small number of logical pages in the multiple logical pages of a logical block in the file system, valid data is stored in the logical block, the file system considers that the logical block can be garbage collected , So as to copy the valid data stored in the logic block to other logic blocks, and then erase the logic block to complete garbage collection processing.
  • multiple refers to two or more than two. In view of this, “multiple” may also be understood as “at least two” in the embodiments of the present application. "At least one" can be understood as one or more, for example, one, two or more. For example, including at least one refers to including one, two or more, and does not limit which ones are included. For example, including at least one of A, B, and C, then the included can be A, B, C, A and B, A and C, B and C, or A and B and C.
  • ordinal numbers such as “first” and “second” mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the order, timing, priority, or importance of multiple objects.
  • Fig. 2 shows an exemplary structure diagram of a terminal device.
  • the terminal device 200 includes components such as a processor 210, a memory 220, and a communication interface 230.
  • the structure of the terminal device shown in FIG. 2 does not constitute a limitation on the terminal device.
  • the terminal device provided in the embodiment of the present invention may include more or less components than those shown in the figure, or a combination of certain components. Some components, or different component arrangements.
  • buses 240 can be divided into address buses, data buses, control buses, and so on.
  • the processor 210 may be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.
  • the processor 210 may further include a hardware chip.
  • the aforementioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof.
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
  • the memory 220 is used to store computer programs, such as application programs, operating systems, and file systems; the processor 210 can call the computer programs stored in the memory 220 to implement functions defined by the computer programs.
  • the processor 210 may execute an operating system to implement various functions of the operating system on the computing device 200, and the processor 210 may also execute an application program to implement various functions of the application on the computing device 200.
  • the operating system can be a Windows system, a MAC OS system, a Linux system, an Android system, etc., of course, it can also be a future-oriented computer system.
  • the system described in the embodiments of this application is to illustrate the technical solutions of the embodiments of this application more clearly. It does not constitute a limitation to the technical solutions provided in the embodiments of the present application.
  • the application program may be a third-party application program such as a WeChat application program or a Baidu application program, and may also be a system application program of the computing device 200, such as a system service (system server) or a system interface (system ui).
  • system server system service
  • system ui system interface
  • the memory 220 may include a storage program area and a storage data area.
  • the storage program area can store the operating system and various application programs.
  • the storage data area is used to store other data besides the computer program, for example, data generated during the operation of the operating system and application programs (such as various picture information, video information, etc.).
  • the memory 220 may include a volatile memory (volatile memory), such as a random-access memory (random-access memory, RAM); the memory 220 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory). memory) (for example, NAND flash memory (flash), embedded multimedia card (eMMC), etc.), hard disk drive (HDD) or solid-state drive, SSD); the storage 220 may also include a combination of the above-mentioned types of storage. The number of the memories 220 may be one or more, which may be specifically set as required. The memory 220 may also be a memory in the processor 210, which is not limited here.
  • the communication interface 230 is used to connect the terminal device 200 with other electronic devices, allows the terminal device 200 to communicate on the network hardware, and can implement the hardware for sending and receiving data packets.
  • the communication interface 230 may be wired or wirelessly connected to a network to connect to other electronic devices, such as other external terminal devices or servers.
  • the communication interface 230 may specifically be a modem or an antenna or a wireless fidelity (WiFi) module.
  • WiFi wireless fidelity
  • the communication interface 230 may specifically be a radio frequency unit or an antenna.
  • the terminal device 200 can be 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;
  • the application layer 21 includes one or more applications (application 201 and application 202), and the specific application may be social Any type of application such as applications, e-commerce applications, browsers, etc.
  • the operating system layer 22, as 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.
  • the core of the operating system layer 22 is the kernel.
  • the kernel is used to provide underlying system components and services, such as: power management, storage management, thread management, hardware drivers, etc.; hardware drivers include block device drivers, sensor drivers, positioning module drivers, etc.
  • some modules that are closely related to the hardware for example, interrupt handlers, device drivers, etc.
  • basic, common, and higher processing frequency for example, clock management, process scheduling, etc.
  • critical data are separated, so that these contents can reside in memory and protect them.
  • This part is usually called the kernel.
  • the essence of the kernel is a piece of program code.
  • the function of the kernel is realized by the processor calling the program code corresponding to the kernel.
  • the kernel is used to virtualize the memory included in the hardware layer 23 into multiple block devices to form a block device layer 2201, and provide the block device layer 2201 to the file system 2202 for use.
  • the file system 2202 stores the data generated by each application in the application layer in the memory in the form of a file.
  • the file system 2202 When the file system 2202 receives a file access request sent by an application in the application layer 21, such as application 201 , The block device access request corresponding to the block device in the block device layer 2201 will be generated, and then the block device access request will be sent to the block device layer 2201, and the corresponding block device driver will be driven through the scheduling management of the block device layer 2201 2203, so as to issue the access request to the memory, so as to realize the storage function of the terminal device 200 through the file system 2202, the block device layer 2201, and the block device driver 2203.
  • the file system 2201 may be F2FS, or may also be another file system that writes data in a remote update manner, which is not limited here.
  • the storage space of the block device layer 2201 is limited, for example, it may be 100 gigabytes (GB). As the data generated by the application program increases, the storage space of the block device layer 2201 will become smaller and smaller. Therefore, in order to be able to continuously write data into the memory, the file system will perform garbage collection (GC) processing.
  • GC garbage collection
  • the memory provides several block devices to the file system, for example, including block device 1 and block device 2.
  • block device 1 includes two logical blocks, namely logical block 1 and logical block 2, and each The logic block includes 4 logic pages.
  • the condition for the file system to perform garbage collection is that when the number of logical pages storing invalid data in a logical block is greater than 2, garbage collection is performed.
  • the file system determines that the data in the three logical pages (for example, logical page 1 to logical page 3) of the four logical pages are invalid data, the file system determines that the logical block 1 needs to be garbage collected, so that the logical page The data in 4 is copied to other logic blocks, and then the logic block 1 is erased, and the logic block is recovered. In this way, when data needs to be stored later, it can be stored in the logic block 1.
  • Nand Flash consists of multiple Nand Flash particles.
  • a single Nand Flash particle includes multiple physical blocks, and each physical block includes multiple physical pages.
  • Nand Flash reads and writes according to physical pages, and erases according to physical blocks, and the physical blocks must be erased before they can write data one by one in a specific order.
  • This specific data operation method requires continuous data writing in the memory In the process, the memory controller needs to perform garbage collection processing on the data stored in the Flash.
  • the storage medium included in the memory is 2 Nand Flash particles, and each Nand Flash particle includes 2 physical blocks, namely physical block 1 and physical block 2, and each physical block includes 8 physical pages.
  • the memory controller manages all physical blocks included in the storage medium through garbage collection. It is assumed that the condition for garbage collection of the memory is that when the number of physical pages storing invalid data in a physical block is greater than 4, garbage collection is performed.
  • the controller finds that only a few physical pages in physical block 1 are valid data, for example, only physical page 6 to physical page 8 store valid data in physical page 1 to physical page 8, and other physical pages If invalid data is stored in physical block 1, the controller determines that physical block 1 needs to be garbage collected, so that the data in physical page 6 to physical page 8 is copied to physical page 9 to physical page 11 in physical block 2, and then Erase physical block 1, and complete the garbage collection of physical block 1.
  • logical blocks and logical pages in the file system are just a logical concept.
  • the data stored in the file system is ultimately stored in the storage medium, that is, the logical blocks and logical pages in the file system and the storage medium
  • logical block 1 and logical block 2 in the file system respectively correspond to physical block 1 and physical block 2 in the storage medium (in Figure 6 take logical block 1 and physical block 1 as examples), logical page 1 respectively Corresponding to physical page 1 and physical page 2, logical page 2 corresponds to physical page 3 and physical page 4, and so on.
  • garbage collection processing as shown in FIG. 4, it actually copies the data in physical page 7 and physical page 8 to other physical pages.
  • the embodiments of the present application provide a garbage collection method.
  • the garbage collection of the file system in the terminal device and the garbage collection of the memory are combined.
  • the garbage collection mechanism in the file system can be used to unify the garbage collection.
  • the data stored in part of the logical area of the file system and the data stored in the physical block corresponding to the part of the logical area in the memory are garbage collected, or, through the garbage collection mechanism in the memory, the data stored in the file system is unified
  • the data in the remaining logical area and the data stored in the remaining physical blocks in the memory are garbage collected, that is, the same data will only be garbage collected once, which can avoid the existence of the file system and the memory when garbage collection is performed at the same time
  • the repeated movement of data can reduce the time delay for applications to access files.
  • the combination of the garbage collection of the file system in the terminal device and the garbage collection of the memory can be achieved through the garbage collection mechanism in the file system or through the garbage collection mechanism in the memory.
  • Embodiment 1 it will be divided into two embodiments, namely Embodiment 1 and Embodiment 2, to describe the garbage collection method in the embodiments of the present application.
  • the garbage collection method of the present application is realized through the garbage collection mechanism in the file system
  • the garbage collection method in the embodiment of the present application is realized through the garbage collection mechanism in the memory.
  • FIG. 7 is a flowchart of an example of a garbage collection method provided in an embodiment of this application.
  • the application of the technical solution provided by this application in the application scenario shown in FIG. 3 is taken as an example for description.
  • the method may be executed by the processor 210 in the computing device 200 as shown in FIG. 3, and it can be understood that the processor 210 calls a program in the file system 2201 to execute.
  • the description of the flowchart is as follows:
  • the processor 210 obtains first information from the memory 220.
  • the first information is used to indicate the size of the first unit processing unit, and the first unit processing unit is the unit processing unit of the memory 220 for garbage collection operations.
  • the unit processing unit in which the memory 220 performs garbage collection operations can also be referred to as the granularity of the garbage collection operation performed by the memory 220. It can be understood that the memory 220 determines whether a garbage collection operation needs to be performed according to the unit processing unit. If the memory 220 determines that there is only a small amount of valid data in a certain storage space whose size is the size of the unit processing unit, the memory 220 may perform garbage collection processing on the storage space, so as to store the valid data in the storage space. The data is copied to other physical blocks, and then the storage space is erased to complete the garbage collection operation.
  • the size of the first unit processing unit may be the size of a physical block of the memory 220, for example, 72 megabytes (MB).
  • the size of the first unit processing unit can be set according to actual usage requirements, and is not limited in the embodiment of the present application.
  • the processor 210 obtains the first information from the memory 220, including but not limited to the following manners.
  • the processor 210 may send a query instruction to the memory 220 through an internal channel between the processor 210 and the memory 220, and the query instruction is used to obtain the size of a unit processing unit of the memory 220.
  • the memory 220 After the memory 220 receives the query instruction, it sends a response message corresponding to the query instruction to the processor 210 through the internal channel, and 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 (eMMC) protocol, a UNIX file system (UNIX file system, UFS) protocol, or a custom private channel.
  • the query instruction may be a newly added instruction dedicated to query the size of the first unit processing unit, or it may be obtained by adding a new field to an existing query instruction, and the new field is used to indicate The size of the processing unit of the first unit is reported, and the internal channel and the query command are not restricted here.
  • the memory 220 may actively report the size of the first unit processing unit to the processor 210.
  • the attribute information set of the memory 220 can be customized, and a new field can be added to the attribute information set.
  • the memory 220 can store the size of the first unit processing unit in the field, so that the processor 210 can read from The size of the first unit processing unit is obtained from the attribute information set.
  • the attribute information may be reported to the processor 210 after the terminal device is in a working state.
  • a preset driver and client software corresponding to the preset driver may be installed in the operating system layer 22, and the preset driver is used to query the size of the unit processing unit of the memory 220 In this way, after the engineer starts the client software, the processor 210 can obtain the size of the first unit processing unit through the driver.
  • a custom action can be inserted through automatic installation technology (for example, AutoYast) or unattended batch installation of operating system interface technology (for example, kick-start).
  • the custom action may be: after detecting that the terminal device is in the running state, the memory 220 reports the size of the first unit processing unit to the processor 210 through the internal channel between the processor 210 and the memory 220.
  • processor 210 may use other methods to obtain the size of the first unit processing unit from the memory 220, which is not limited here.
  • the processor 210 configures the size of the second unit processing unit used by the file system for garbage collection operations according to the size of the first unit processing unit.
  • 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, if the size of the first unit processing unit is 288 MB, the processor 210 configures the second unit processing unit. The size of the unit is 288MB, or the size of the second unit processing unit can also be configured to be an integer multiple of the size of the first unit processing unit. In this way, the file system is based on the size of the second unit processing unit configured by the processor 210 To perform garbage collection on the data stored in the file system.
  • the processor 210 sends an address configuration instruction to the memory 220.
  • the address configuration instruction includes the logical address of the block device occupied by the file system, and the address configuration instruction is used to instruct the memory 220 not to perform garbage collection processing on the physical storage space corresponding to the logical address.
  • the logical address included in the address configuration instruction may be a logical address range.
  • the logical address range can be indicated by the starting logical address and the length of the address.
  • each logical address can be indicated by the identification information (for example, index number or serial number, etc.) of each logical address, then
  • the logical address from logical address 1 to logical address 10 can be represented by "1+10", where "1" means that the starting logical address is logical address 1, and "10" means that this logical address includes 10 logical addresses.
  • the address configuration instruction includes multiple logical addresses, and the multiple logical addresses are all logical addresses that need to be aligned with physical addresses.
  • the address configuration instruction includes the identification information of each logical address in the plurality of logical addresses, for example, including "1, 2, 3... ...10". Or, the address configuration instruction includes only one logical address, and the logical address is the starting address of a logical address range, and is used to indicate all logical addresses located after the logical address.
  • the logical storage space occupied by the file system can be divided into a metadata area and a main data area according to different storage contents. Among them, the main data area is used to store data, and the metadata area is used to store metadata. data.
  • the logical address range included in the address configuration instruction can be a segment of logical addresses corresponding to all the logical storage spaces occupied by the file system, or the logical storage space occupied by the main data area of the file system.
  • the corresponding segment of logical addresses, or when the file system also includes other partitions, the logical address range may also be a segment of logical addresses corresponding to other partitions, which is not limited in the embodiment of the present application.
  • the logical address range is taken as an example of a logical address corresponding to the main data area of the file system.
  • the processor 210 may send the address configuration instruction to the memory 220 before storing the first data in the file system or the memory 220, for example, within a preset time period of detecting that the terminal device is in the running state, or The address configuration instruction may be sent to the memory 220 after the data is stored in the file system or the memory 220, which is not limited here.
  • the memory 220 determines not to perform a garbage collection operation on the physical storage space corresponding to the logical address included in the address configuration instruction.
  • the logical address included in the address configuration instruction is logical address 1 to logical address 10.
  • the memory 220 calculates the physical address corresponding to each logical address according to a preset algorithm, such as a hash algorithm, for example,
  • the physical addresses corresponding to the logical address 1 to logical address 10 are calculated to be physical address 3 to physical address 12, respectively, and the memory 220 determines that the storage space corresponding to the physical address 3 to physical address 12 does not need to be garbage collected.
  • step S71 to step S72 and step S73 to step S74 is not limited.
  • step S71 to step S72 can be executed first, and then step S73 to step S74, or step S73 to step S74 can be executed first, and then step S71 to step S72 can be executed, or step S71 to step S72 and step S73 to can be executed simultaneously.
  • Step S74 In FIG. 7, it is taken as an example that steps S71 to S72 are executed first, and then steps S73 to S74 are executed.
  • 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 manner.
  • the processor 210 prohibits the storage space corresponding to the logical address included in the address configuration instruction from being written in a local update manner. data.
  • the file system can write data in a local update mode, or write data in a remote update mode.
  • the processor 210 configures the file system to prohibit writing data in a local update mode.
  • the file system may include a plurality of configuration parameters, where the configuration parameter includes an attribute for indicating that the file system supports writing data in a local update manner, and the processor 210 may configure the file system to disable and enable the attribute.
  • the processor 210 writes data into the logical storage space corresponding to the file system.
  • the processor 210 After the processor 210 receives the data, it writes the data to the logical storage space corresponding to the file system in a remote update manner, and stores the data in the physical storage space corresponding to the memory 220.
  • the processor 210 receives a data write operation, and the data write operation includes data to be written.
  • the processor 210 may determine a logical address corresponding to the data to be written according to a preset rule, for example, determine Store the write data in logic block 1.
  • the processor 210 sends a data storage instruction to the memory 220.
  • the instruction includes the write data and the logical address corresponding to the data to be written, for example, the identification (number or index number, etc.) of the logical block 1.
  • the processor 220 determines that the physical storage space corresponding to the logical block 1 is the physical block 1, and then stores the data to be written in the physical block 1.
  • the memory 220 establishes a mapping relationship between a logical address and a physical address.
  • the memory 220 can establish a mapping relationship between the logical address and the physical address.
  • the mapping relationship is the mapping relationship between the logical block and the physical block. For example, using the identifier of each logical block or physical block to represent each logical block or physical block, it can be known from step S76 that logical block 1 corresponds to physical block 1, so that the mapping relationship shown in Table 1 is obtained.
  • Table 1 will increase table entries as the data to be written increases.
  • Table 1 records the mapping relationship between logical blocks and physical blocks stored in the memory 220. If no data is stored in a certain logic block, the mapping relationship corresponding to the logic block will not be stored in Table 1.
  • Table 1 since Table 1 only includes the mapping relationship between logical blocks and physical blocks, and does not have a mapping relationship with logical pages or physical pages, the storage space occupied by Table 1 is relatively small. , Can save storage resources.
  • the processor 210 uses a garbage collection mechanism of the file system to perform a garbage collection operation.
  • the processor 210 can run the code or program for garbage collection in the file system to perform garbage collection 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 the threshold. If yes, then garbage collection is performed, that is, according to the mapping relationship between the logical block and the physical block , Determine the physical block that needs to be erased, and issue an instruction to erase the data in the physical block to the memory 220. The specific manner is similar to that in the prior art, and will not be repeated here.
  • each logical block in the logical storage space indicated by the foregoing address configuration instruction corresponds to a physical block, after garbage collection is performed on the logical storage space, the memory 220 does not need to perform garbage collection on this part of the physical storage space. Therefore, the process of the memory 220 performing the garbage collection operation on the part of the physical storage space can be omitted, and the time delay when the application program accesses the file can be reduced.
  • the logical address indicated by the address configuration instruction sent by the processor 210 is a logical address corresponding to part of the logical storage space of the file system, for example, the logical address corresponding to the main data area of the file system. Then the processor 210 only performs a garbage collection operation on part of the logical storage space of the file system. For other storage spaces in the terminal device, for example, the logical storage space corresponding to the metadata area of the file system, the memory 220 may perform the garbage collection operation.
  • the process of implementing the garbage collection method in the embodiment of the present application through the garbage collection mechanism in the memory 220 will be introduced.
  • FIG. 8 is a flowchart of an example of a garbage collection method provided by an embodiment of this application.
  • the application of the technical solution provided by this application in the application scenario shown in FIG. 3 is taken as an example for description.
  • the method may be executed by the memory 220 in the computing device 200 as shown in FIG. 3, which can be understood as being executed by a control device or a controller in the memory 220.
  • the description of the flowchart is as follows:
  • the processor 210 configures the target storage space of the memory 220 to write data in a locally updated manner.
  • the memory 220 may be divided into multiple partitions according to the use requirements of the terminal device.
  • it may include a boot partition, a replay protected memory block (RPMB) partition, a user data area (UDA), and so on.
  • the boot partition is used to store the startup program required by the terminal device;
  • the RPMB partition is usually used to store data that needs to prevent illegal tampering, such as the public key and serial number related to fingerprint payment on the terminal device;
  • the UDA partition is usually used Store user data, etc.
  • the embodiment of this application does not limit the partition of the terminal device.
  • the UDA partition of the terminal device will be configured with a file system, while other partitions may not have a file system configured. If the logical storage space corresponding to the file system only includes 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 except the UDA partition to write data in a local update manner.
  • step S81 is an optional step, that is, it is not necessary to be performed.
  • the metadata area and other partitions of the terminal device other than the UDA partition may be configured to write data in a local update manner by default.
  • the processor 210 does not need to perform step S81.
  • the dotted line in FIG. 8 indicates that this step is optional.
  • the processor 210 writes data into the target storage space of the memory 220.
  • the processor 210 After the processor 210 receives the data write operation for the metadata area, it determines the logical address corresponding to the data to be written according to a preset rule, for example, determines to store the written data in the logic of logic block 1. Page 3. Then, the processor 210 sends a data storage instruction to the memory 220.
  • the instruction includes the write data and the logical address corresponding to the data to be written, for example, the identification (number or index number) of the logical page 3 of the logical block 1. Wait).
  • the processor 220 After receiving the instruction, the processor 220 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 in the physical page of the physical block 1. 4 and physical page 5.
  • the memory 220 establishes a mapping relationship between a logical address and a physical address.
  • the mapping relationship is used as the mapping relationship between logical pages and physical pages. For example, using the identifier of each logical page or physical page to indicate each logical page or physical page, it can be seen from step S82 that the logical page 3 of the logical block 1 corresponds to the physical page 4 and the physical page 5 of the physical block 1, thereby obtaining the following table 2 shows the mapping relationship.
  • Table 2 is similar to Table 1, and entries will be added as the data written increases.
  • Table 2 records the mapping relationship between logical pages and physical pages of the destination storage space.
  • the memory 220 determines invalid data according to the mapping relationship.
  • the memory 220 may also include other mapping relationships, for example, including a reverse mapping relationship indexed by a physical page.
  • the reverse mapping relationship is a mapping relationship between a physical page and a logical page. The memory 220 Through the mapping relationship between the logical page and the physical page and the reverse mapping relationship, it is determined whether the data in a certain physical page is invalid data.
  • the storage 220 performs a garbage collection operation on the target storage space.
  • 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, then the physical page is garbage collected.
  • the garbage collection condition for example, the number of invalid data in the physical page is large and the threshold, then the physical page is garbage collected.
  • the specific method is similar to that in the prior art. This will not be repeated here.
  • 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 of part of the storage space by the file system can be omitted, and the time delay when the application program accesses the file can be reduced.
  • Embodiment 1 and Embodiment 2 can be implemented separately, that is, only one of the above two embodiments can be implemented in a certain terminal device; or, Embodiment 1 and Embodiment 2 can also be implemented. Combined implementation, that is, these two embodiments can be implemented in a certain terminal device.
  • the method in the embodiments of the present application can also be applied to other devices with file systems, which is not limited here.
  • the terminal device may include a hardware structure and/or a software module, and a hardware structure, a software module, or a hardware structure plus a software module Form to achieve the above functions. Whether one of the above-mentioned functions is executed in a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraint conditions of the technical solution.
  • FIG. 9 shows a schematic structural diagram of a garbage collection device 900.
  • the garbage collection device 900 may be used to implement the function of the processor of the terminal device.
  • the garbage collection device 900 may be a hardware structure, a software module, or a hardware structure plus a software module.
  • the garbage collection device 900 may be implemented by a chip system.
  • the chip system may be composed of chips, or may include chips and other discrete devices.
  • the garbage collection device 900 may include a processing module 901 and a communication module 902.
  • the processing module 901 can be used to perform step S72, step S75 to step S76, and step S78 in the embodiment shown in FIG. 7, or used to perform step S81 in the embodiment shown in FIG. 8, and/or used to support Other processes of the technique described in this article.
  • the communication module 902 may be used to perform step S71 and step S73 in the embodiment shown in FIG. 7, or used to perform step S82 in the embodiment shown in FIG. 8, and/or used to support the technology described herein. Other processes.
  • the communication module 902 is used for communication between the garbage collection device 900 and other modules, and it may be a circuit, a device, an interface, a bus, a software module, a transceiver, or any other device that can realize communication.
  • FIG. 10 shows a schematic structural diagram of a garbage collection device 1000.
  • the garbage collection device 1000 may be used to implement the memory function of the terminal device.
  • the garbage collection device 1000 may be a hardware structure, a software module, or a hardware structure plus a software module.
  • the garbage collection device 1000 may be implemented by a chip system.
  • the chip system may be composed of chips, or may include chips and other discrete devices.
  • the garbage collection device 1000 may include a processing module 1001 and a communication module 1002.
  • the processing module 1001 may be used to perform step S74 and step S77 in the embodiment shown in FIG. 7, or used to perform step S83 to step S85 in the embodiment shown in FIG. 8, and/or used to support the description herein Other processes of the technology.
  • the communication module 1002 may be used to perform step S71 and step S73 in the embodiment shown in FIG. 7, or used to perform step S82 in the embodiment shown in FIG. 8, and/or used to support the technology described herein. Other processes.
  • the communication module 1002 is used for communication between the garbage collection device 1000 and other modules, and it may be a circuit, a device, an interface, a bus, a software module, a transceiver, or any other device that can realize communication.
  • the division of modules in the embodiment shown in FIG. 9 or FIG. 10 is schematic, and is only a logical function division. In actual implementation, there may be other division methods. In addition, each function in each embodiment of the present application
  • the module can be integrated in a processor, it can also exist alone physically, or two or more modules can be integrated in one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.
  • the garbage collection device shown in FIG. 9 or FIG. 10 may also be the terminal device shown in FIG. 2, and the processing module 901 may correspond to the processor 210 of the terminal device shown in FIG. 2, and the processing module 1001 may correspond to FIG. 2.
  • the memory 220, the communication module 903, and the communication module 1002 of the terminal device shown may correspond to the communication interface 230 of the terminal device shown in FIG. 2, which will not be repeated here.
  • An embodiment of the present application also provides a computer-readable storage medium, including instructions, which when run on a computer, cause the computer to execute the method executed by the processor or the memory in the embodiment shown in FIG. 7 or FIG. 8.
  • An embodiment of the present application also provides a computer program product, including instructions, which when run on a computer, cause the computer to execute the method executed by the processor or the memory in the embodiment shown in FIG. 7 or FIG. 8.
  • the embodiment of the present application provides a chip system.
  • the chip system includes a processor and may also include a memory for realizing the functions of the processor or the memory in the foregoing method.
  • the chip system can be composed of chips, or can include chips and other discrete devices.
  • the embodiment of the present application provides a terminal device, and the terminal device includes the processor and/or the memory in the embodiment shown in FIG. 7 or FIG. 8.
  • the methods provided in the embodiments of the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software When implemented by software, it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a dedicated computer, a computer network, network equipment, user equipment, or other programmable devices.
  • 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 a website, computer, server, or data center.
  • a 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., integrated with one or more available media.
  • the available medium may be a magnetic medium (for example, a floppy disk, hard disk, Magnetic tape), optical media (for example, digital video disc (DVD for short)), or semiconductor media (for example, SSD).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System (AREA)

Abstract

一种垃圾回收方法及装置,在该方法中,将终端设备中文件系统的垃圾回收和存储器的垃圾回收进行合并,例如,可以通过文件系统中的垃圾回收机制,统一对存储在文件系统的部分逻辑区域中的数据和存储在存储器中与该部分逻辑区域对应的物理块中的数据进行垃圾回收处理,或者,通过存储器中的垃圾回收机制,统一对存储在文件系统的剩余逻辑区域中的数据和存储在存储器中剩余物理块中的数据进行垃圾回收处理,从而针对同一数据只会进行一次垃圾回收处理,可以避免文件系统和存储器同时进行垃圾回收时存在的重复搬移数据的情况,可以减少应用程序访问文件的时延。

Description

一种垃圾回收方法及装置
相关申请的交叉引用
本申请要求在2019年07月31日提交中国专利局、申请号为201910719350.6、申请名称为“一种文件系统管理的方法”的中国专利申请的优先权,其全部内容通过引用结合在本申请中;本申请要求在2019年11月30日提交中国专利局、申请号为201911209032.1、申请名称为“一种垃圾回收方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种垃圾回收方法及装置。
背景技术
在终端设备中,数据以文件的方式保存在终端设备的存储器上,并通过终端设备的文件系统对存储的文件进行管理。终端设备的文件系统接收到应用程序的文件访问请求后,会将该访问请求转化为对存储器中存储的数据的读写操作,然后通过块设备层以及设备驱动,下发到存储器中,从而实现文件访问。
目前,终端设备中采用的存储器为快闪存储器(flash memory),例如,与非(not and,NAND)闪存(flash)。由于快闪存储器采用异地更新方式写入数据,因此,为了对存储器友好,要求终端设备的文件系统也使用数据写入方式为异地更新方式的文件系统,例如,终端设备的文件系统可以为闪存友好文件系统(flash friendly file system,F2FS)。
采用异地更新方式写入数据会使得存储器或者文件系统中的存储空间逐渐减少,为了能够持续地将应用程序产生的数据写入到存储器中,文件系统和存储器都会进行垃圾回收处理。然而,文件系统和存储器都进行垃圾回收处理时,会使得应用程序的文件访问产生较大的延迟,甚至产生卡顿。
发明内容
本申请提供一种垃圾回收方法及装置,用以减少应用程序访问文件的时延。
第一方面,提供了一种垃圾回收方法,在该方法中,终端设备的处理器首先从该终端设备的存储器中获取用于指示第一单位处理单元的大小的第一信息,该第一单位处理单元为该存储器进行垃圾回收操作的单位处理单元,并根据该第一单位处理单元的大小,配置终端设备的文件系统进行垃圾回收操作所使用的第二单位处理单元的大小。然后,该处理器向该存储器发送地址配置指令,该地址配置指令中包括该文件系统所占用的块设备的逻辑地址,通过该地址配置指令用于指示存储器不用对与该逻辑地址对应的物理存储空间进行垃圾回收操作,最后,由处理器根据该第二单位处理单元的大小,对与该逻辑地址对应的逻辑存储空间进行垃圾回收操作。
在上述技术方案中,由处理器统一对逻辑存储空间和物理存储空间进行垃圾回收,也就是说,存储器不用再对该部分物理存储空间进行垃圾回收操作,从而可以省略存储器对 该部分物理存储空间进行垃圾回收操作的过程,可以减少应用程序访问文件时的时延。
在一种可能的设计中,该第二单位处理单元的大小与所述第一单位处理单元的大小相同,或,所述第二单位处理单元的大小为所述第一单位处理单元的大小的整数倍。
在上述技术方案中,将文件系统进行垃圾回收操作的单位处理单元的大小与存储器进行垃圾回收操作的单位处理单元的大小进行统一,通常情况下,存储器进行垃圾回收操作的单位处理单元较大,从而相当于增加了文件系统进行垃圾回收操作的单位处理单元的大小,可以提高文件系统进行垃圾回收操作的效率。
在一种可能的设计中,所述文件系统包括主数据区和元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据,所述逻辑地址为所述主数据区对应的逻辑地址集合。
在上述技术方案中,文件系统的主数据区占用的存储空间较大,从而可以只针对文件系统的主数据区进行上述垃圾回收操作,可以提高垃圾回收操作的效率。
在一种可能的设计中,该处理器禁止与该逻辑地址对应的逻辑存储空间采用本地更新的方式写入数据。
也就是说,该逻辑地址对应的逻辑存储空间采用异地更新的方式写入数据,可以保证文件系统所占用的逻辑存储空间中存储的数据与存储器中存储的数据的一致性。
第二方面,提供一种垃圾回收方法,在该方法中,终端设备的存储器在接收数据后,将接收到的数据写入到目标存储空间中,该目标存储空间包括该终端设备的文件系统的元数据区对应的物理存储空间和/或该终端设备的非用户数据UDA分区对应的物理存储空间,该文件系统包括主数据区和该元数据区,该主数据区用于存储数据,该元数据用于存储数据的元数据。然后,该存储器则根据预设的垃圾回收策略以及预设的单位处理单元,对该目标存储空间进行垃圾回收操作。
在上述技术方案中,在存储器对该目的存储空间进行垃圾回收操作后,文件系统不用再对该其元数据分区对应的存储空间进行垃圾回收操作,从而可以省略文件系统对部分存储空间进行垃圾回收操作的过程,可以减少应用程序访问文件时的时延。
在一种可能的设计中,存储器建立逻辑存储空间的逻辑页与该目标存储空间的物理页之间的映射关系,该逻辑存储空间为与该元数据区和/或该非用户数据UDA分区对应的逻辑存储空间,然后,存储器可以根据该映射关系确定无效数据,若一个物理页中无效数据的数量大与阈值,则存储器对该物理页进行垃圾回收操作。
在本申请实施例中,不限制存储器确定无效数据的方式。
在一种可能的设计中,存储器以本地更新的方式,向该目标存储空间中写入数据。
第二方面,提供一种垃圾回收装置,该垃圾回收装置可以是终端设备,也可以是终端设备中的装置。该垃圾回收装置包括处理器,用于实现上述第一方面描述的方法。该垃圾回收装置还可以包括存储器,用于存储程序指令和数据。该存储器与该处理器耦合,该处理器可以调用并执行该存储器中存储的程序指令,用于实现上述第一方面描述的方法中的任意一种方法中。该垃圾回收装置还可以包括接口,该接口用于该垃圾回收装置与其它装置或模块进行通信。
在一种可能的设计中,该垃圾回收装置处理器和接口,其中:
所述处理器,用于从所述终端设备的存储器中获取第一信息,所述第一信息用于指示第一单位处理单元的大小,所述第一单位处理单元为所述存储器进行垃圾回收操作的单位 处理单元;以及,根据所述第一单位处理单元的大小,配置第二单位处理单元的大小,所述第二单位处理单元为所述终端设备的文件系统进行垃圾回收操作所使用的单位处理单元;
所述接口,用于在所述处理器的控制下,向所述存储器发送地址配置指令,所述地址配置指令中包括所述文件系统所占用的块设备的逻辑地址,所述地址配置指令用于指示所述存储器不用对与所述逻辑地址对应的物理存储空间进行垃圾回收操作;
所述处理器,还用于根据所述第二单位处理单元的大小,对与所述逻辑地址对应的逻辑存储空间进行垃圾回收操作。
其中,对第二单位处理单元的大小的配置、逻辑地址以及数据写入方式的说明,与第一方面中相应的内容相似,在此不再赘述。
第三方面,提供一种垃圾回收装置,该垃圾回收装置可以是终端设备,也可以是终端设备中的装置。该垃圾回收装置包括处理器,用于实现上述第二方面描述的方法。该垃圾回收装置还可以包括存储器,用于存储程序指令和数据。该存储器与该处理器耦合,该处理器可以调用并执行该存储器中存储的程序指令,用于实现上述第二方面描述的方法中的任意一种方法中。该垃圾回收装置还可以包括接口,该接口用于该垃圾回收装置与其它装置或模块进行通信。
在一种可能的设计中,该垃圾回收装置处理器和接口,其中:
所述接口,用于接收数据;
所述处理器,用于将接收的数据写入到目标存储空间中,所述目标存储空间包括所述终端设备的文件系统的元数据区对应的物理存储空间和/或所述终端设备的非用户数据UDA分区对应的物理存储空间,所述文件系统包括主数据区和所述元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据;以及,
根据预设的垃圾回收策略以及预设的单位处理单元,对所述目标存储空间进行垃圾回收操作。
在一种可能的设计中,所述处理器还用于:
建立逻辑存储空间的逻辑页与所述目标存储空间的物理页之间的映射关系,所述逻辑存储空间为与所述元数据区和/或所述非用户数据UDA分区对应的逻辑存储空间;根据所述映射关系确定无效数据;以及,若一个物理页中无效数据的数量大与阈值,则所述存储器对所述物理页进行垃圾回收操作。
在一种可能的设计中,所述处理器以本地更新的方式,向所述目标存储空间中写入数据。
第四方面,提供一种垃圾回收装置,该垃圾回收装置可以是终端设备,也可以是终端设备中的装置,该垃圾回收装置可以包括处理模块和通信模块,这些模块可以执行上述第一方面任一种设计示例中的所执行的相应功能,具体的:
通信模块,用于从所述装置的存储器中获取第一信息,所述第一信息用于指示第一单位处理单元的大小,所述第一单位处理单元为所述存储器进行垃圾回收操作的单位处理单元;
处理模块,用于根据所述第一单位处理单元的大小,配置第二单位处理单元的大小,所述第二单位处理单元为所述装置的文件系统进行垃圾回收操作所使用的单位处理单元;
所述通信模块,还用于向所述存储器发送地址配置指令,所述地址配置指令中包括所 述文件系统所占用的块设备的逻辑地址,所述地址配置指令用于指示所述存储器不用对与所述逻辑地址对应的物理存储空间进行垃圾回收操作;
所述处理模块,还用于根据所述第二单位处理单元的大小,对与所述逻辑地址对应的逻辑存储空间进行垃圾回收操作。
第五方面,提供一种垃圾回收装置,该垃圾回收装置可以是终端设备,也可以是终端设备中的装置,该垃圾回收装置可以包括处理模块和通信模块,这些模块可以执行上述第一方面任一种设计示例中的所执行的相应功能,具体的:
通信模块,用于接收数据;
处理模块,用于将接收的数据写入到目标存储空间中,所述目标存储空间包括所述装置的文件系统的元数据区对应的物理存储空间和/或所述装置的非用户数据UDA分区对应的物理存储空间,所述文件系统包括主数据区和所述元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据;以及,
根据预设的垃圾回收策略以及预设的单位处理单元,对所述目标存储空间进行垃圾回收操作。
第六方面,本申请实施例中还提供一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行第一方面或第二方面所述的方法。
第七方面,本申请实施例中还提供一种计算机程序产品,包括指令,当其在计算机上运行时,使得计算机执行第一方面或第二方面所述的方法。
第八方面,本申请实施例提供了一种芯片系统,该芯片系统包括处理器,还可以包括存储器,用于实现第一方面或第二方面所述的方法。该芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
上述第二方面至第八方面及其实现方式的有益效果可以参考对第一方面或第二方面的方法及其实现方式的有益效果的描述。
附图说明
图1为异地更新的方式的一种示例的示意图;
图2为本申请实施例中终端设备的一个示例性的结构示意图;
图3为本申请实施例中终端设备的一种示例的逻辑框图;
图4为文件系统进行垃圾回收处理的一种示例的示意图;
图5为存储器进行垃圾回收处理的一种示例的示意图;
图6为逻辑页或物理页的映射关系的一种示例的示意图;
图7为本申请实施例提供的垃圾回收方法的一种示例的流程图;
图8为本申请实施例提供的垃圾回收方法的另一种示例的流程图;
图9为本申请实施例提供的垃圾回收装置的一种示例的流程图;
图10为本申请实施例提供的垃圾回收装置的另一种示例的流程图。
具体实施方式
为了使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施例作进一步地详细描述。
1)终端设备,可以是移动式或便携式并执行无线通信的各种类型的计算机系统或设备中的任一个计算机系统或设备,或者也可以是服务器式终端设备。例如可包括移动电话或智能电话、便携式游戏设备、个人通信业务(personal communication service,PCS)电话、会话发起协议(session initiation protocol,SIP)话机、无线本地环路(wireless local loop,WLL)站、个人数码助理(personal digital assistant,PDA)、便携式互联网设备、音乐播放器、数据存储设备、其他手持设备以及可穿戴设备。
或者,终端设备还可以包括受限设备,例如功耗较低的设备,或存储能力有限的设备,或计算能力有限的设备等。例如包括条码、射频识别(radio frequency identification,RFID)、传感器、全球定位系统(global positioning system,GPS)、激光扫描器等信息传感设备。
或者,该终端设备还可以是智能穿戴式设备,是应用穿戴式技术对日常穿戴进行智能化设计、开发出可以穿戴的设备的总称,如眼镜、手套、手表、服饰及鞋等。或者,也可以是虚拟现实(virtual reality,VR)设备、增强现实(augmented reality,AR)设备、工业控制(industrial control)中的无线终端设备、无人驾驶(driverless)中的无线终端设备、远程手术(remote medical surgery)中的无线终端设备、智能电网(smart grid)中的无线终端设备、运输安全(transportation safety)中的无线终端设备、智慧城市(smart city)中的无线终端设备、智慧家庭(smart home)中的无线终端设备等。
2)本地更新的方式,是指当接收到写操作请求后,首先确定该写操作请求对应的操作地址,然后将写操作请求中携带的数据写入到该地址中,若该地址上存储有原始数据,则将该写操作指令中包括的数据覆盖原始数据。
3)异地更新的方式,是指当接收到写操作请求后,会顺序写入到存储空间中,而不是在该写操作请求对应的操作地址上直接进行写操作。作为一种示例,请参考图1,存储器会维护地址标识以及存储空间的映射关系,例如,初始的地址标识与存储空间的映射关系为地址1映射到第一个存储单元(例如物理块或者物理页),地址2映射到第二个存储单元,以此类推。若存储器中前10个存储单元存储有数据,当存储器接收到针对地址9的写操作请求后,存储器会将该写操作请求对应的数据存储到第11个存储单元中。然后,存储器会地址与存储单元的映射关系,将地址9映射到第11个存储单元中,这样,当后续需要读取地址9中的数据时,存储器会从第11个存储单元中读取数据。
4)无效数据,是由于删除操作或针对同一地址的多次写操作造成的。例如,在图1中,对地址9进行了两次写操作,则第一次写操作对应的数据,即图1中的第9个存储单元中存储的数据,则变成无效数据。或者,当存储器接收到对某个地址的删除操作请求,则该地址对应的数据标则为无效数据。
需要说明的是,上述内容中,是以存储器为例来解释“异地更新的方式”以及“无效数据”。针对文件系统的异地更新的方式以及无效数据的说明,与存储器类似,在此不再赘述。
5)文件系统的垃圾回收处理,是指当文件系统中的某一个逻辑块的多个逻辑页中,只有少量的逻辑页中存储有效数据,则文件系统认为可以对该逻辑块进行垃圾回收处理,从而将该逻辑块中存储的有效数据复制到其他逻辑块中,然后将该逻辑块擦除,完成垃圾回收处理。
6)本申请实施例中“多个”是指两个或两个以上,鉴于此,本申请实施例中也可以将“多个”理解为“至少两个”。“至少一个”,可理解为一个或多个,例如理解为一个、 两个或更多个。例如,包括至少一个,是指包括一个、两个或更多个,而且不限制包括的是哪几个,例如,包括A、B和C中的至少一个,那么包括的可以是A、B、C、A和B、A和C、B和C、或A和B和C。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,字符“/”,如无特殊说明,一般表示前后关联对象是一种“或”的关系。在本申请实施例中,“节点”和“节点”可以互换使用。
除非有相反的说明,本申请实施例提及“第一”、“第二”等序数词用于对多个对象进行区分,不用于限定多个对象的顺序、时序、优先级或者重要程度。
下面介绍本申请实施例的一种终端设备的结构图。图2示出了终端设备的一个示例性的结构示意图。如图2所示,终端设备200包括:处理器210、存储器220和通信接口230等部件。本领域技术人员可以理解,图2中示出的终端设备的结构并不构成对终端设备的限定,本发明实施例提供的终端设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
这些部件可通过一根或多根总线240或信号线进行通信,总线可以分为地址总线、数据总线、控制总线等。
处理器210可以是中央处理器(central processing unit,CPU),网络处理器(network processor,NP)或者CPU和NP的组合。处理器210还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,CPLD),现场可编程逻辑门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。
存储器220,用于存储计算机程序,例如应用程序、操作系统以及文件系统等;处理器210可调用存储器220存储的计算机程序,从而实现该计算机程序定义的功能。
例如处理器210可以执行操作系统从而在计算设备200上实现操作系统的各种功能,处理器210也可以执行应用程序从而在计算设备200上实现该应用程序的各种功能。操作系统可以为Windows系统、MAC OS系统、Linux系统或者Android系统等,当然也可以是面向未来的计算机系统,本申请实施例描述的系统是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定。举例来说,应用程序可以为微信应用程序或百度应用程序等第三方应用程序,还可以为计算设备200的系统应用程序,例如系统服务(system server)或系统界面(system ui)。
存储器220可以包括存储程序区和存储数据区。存储程序区可存储操作系统以及各种应用程序等。存储数据区用于存储有除计算机程序之外的其他数据,例如,操作系统和应用程序运行过程中产生的数据(例如各种图片信息、视频信息等)。
存储器220可以包括易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);存储器220也可以包括非易失性存储器(non-volatile memory),例如快闪存储器(flash memory)(例如,与非(not and,NAND)闪存(flash),嵌入式多媒体卡(embedded multi media card,eMMC)等),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD);存储器220还可以包括上述种类的存储器的组合。存储器220的个数可以为一个或者多个,具体可以根据需要进行设置。存储器220也可以是处理器210中的存储器,在此不做限制。
通信接口230用于将终端设备200与其它电子设备连接,允许终端设备200在网络上进行通讯的硬件,可以实现数据包的发送与接收的硬件。例如,通信接口230可以通过有线或无线连接到网络以连接到其他电子设备,例如外部其它的终端设备或服务器。例如,通信接口230可以具体为调制解调器或者天线或者无线保真(wireless fidelity,WiFi)模块,在终端设备200为服务器式终端设备时,通信接口230可以具体为射频单元或者天线。
进一步地,在一个实施例中,以终端设备200的操作系统为Linux系统为例,如图3所示,终端设备200从逻辑上可划分为应用层21、操作系统层22和硬件层23。其中,硬件层23可包括图2所示的处理器210、存储器220和通信接口230;应用层21包括一个或多个应用程序(应用程序201和应用程序202),具体应用程序可以为社交类应用、电子商务类应用、浏览器等任意类型的应用程序。操作系统层22作为硬件层23和应用层21之间的软件中间件,是管理和控制硬件与软件资源的计算机程序。
在一个实施例中,操作系统层22的核心是内核。其中,内核用于提供底层系统组件和服务,例如:电源管理、存储管理、线程管理、硬件驱动程序等;硬件驱动程序包括块设备驱动、传感器驱动、定位模块驱动等。在操作系统层22的设计中,往往将一些与硬件紧密相关的(例如,中断处理程序、设备驱动程序等)、基本的、公共的、处理频率较高的模块(例如时钟管理、进程调度等)以及关键性数据独立开来,使这些内容可以常驻内存,并对他们进行保护,通常将这一部分称之为内核。内核的实质是一段程序代码,通过处理器调用内核对应的程序代码来实现内核的功能。
作为一种示例,请参考图3,内核用于将硬件层23中包括的存储器虚拟成多个块设备,形成块设备层2201,并将该块设备层2201提供给文件系统2202使用。文件系统2202将应用层中各个应用程序产生的数据,以文件的形式存储在存储器中的,当文件系统2202接收到应用层21中某个应用程序,例如应用程序201,发送的文件访问请求时,则将生成对块设备层2201中的块设备对应的块设备访问请求,然后,将该块设备访问请求发送到块设备层2201,通过块设备层2201的调度管理,驱动对应的块设备驱动2203,从而将该访问请求下发到存储器中,从而通过文件系统2202、块设备层2201以及块设备驱动2203实现终端设备200的存储功能。在本申请实施例中,文件系统2201可以是F2FS,或者,也可以是其他的以异地更新的方式写入数据的文件系统,在此不作限制。
由于块设备层2201的存储空间有限,例如,可以为100吉字节(gigabyte,GB)。随着应用程序产生的数据越来越多,块设备层2201的存储空间会越来越小。因此,为了能够将持续地将数据写入到存储器中,文件系统会进行垃圾回收(garbage collection,GC)处理。
请参考图4,存储器向文件系统提供若干个块设备,例如包括块设备1和块设备2,其中,块设备1中包括2个逻辑块,分别为逻辑块1和逻辑块2,且每个逻辑块中包括4个逻辑页。假设文件系统进行垃圾回收的条件是,当一个逻辑块中有存储无效数据的逻辑页的数量大于2时,则进行垃圾回收。当文件系统确定该4个逻辑页中的3个逻辑页(例如逻辑页1~逻辑页3)中的数据都是无效数据,则文件系统确定该逻辑块1需要进行垃圾回收,从而将逻辑页4中的数据复制到其他逻辑块中,然后,将该逻辑块1擦除,进而实现回收该逻辑块。这样,当后续需要存储数据时,则可以存储在该逻辑块1中。
目前,在终端设备中使用的存储器的存储介质通常为Nand Flash。Nand Flash由多个Nand Flash颗粒组成,单个Nand Flash颗粒包括多个物理块,每个物理块包括多个物理页。 Nand Flash按照物理页进行读写,按照物理块进行擦除,且物理块必须在擦除之后才能按照特定顺序逐个物理页写入数据,这种特定的数据操作方式要求存储器在持续的数据写入过程中,需要由存储器的控制器,对Nand Flash中存储的数据进行垃圾回收处理。
请参考图5,存储器包括的存储介质为2个Nand Flash颗粒,每个Nand Flash颗粒中包括2个物理块,分别为物理块1和物理块2,每个物理块中包括8个物理页。存储器的控制器会通过垃圾回收来管理所有的存储介质包括的物理块,假设存储器进行垃圾回收的条件是,当一个物理块中存储无效数据的物理页的数量大于4时,则进行垃圾回收。例如,如果控制器发现的物理块1中只有少数的物理页的数据为有效数据,例如,物理页1~物理页8中间只有物理页6~物理页8中存储的是有效数据,其他物理页中存储的是无效数据,则控制器确定需要对物理块1进行垃圾回收,从而,将物理页6~物理页8中的数据复制到物理块2中的物理页9~物理页11中,然后擦除物理块1,完成对物理块1的垃圾回收。
需要说明的是,文件系统中的逻辑块和逻辑页只是一个逻辑概念,文件系统中存储的数据最终存储在存储介质中的,也就是说,文件系统中的逻辑块和逻辑页与存储器介质中的多个物理块和物理页存在一定的映射关系。请参考图6,文件系统中的逻辑块1和逻辑块2分别对应存储介质中的物理块1和物理块2(在图6中以逻辑块1和物理块1为例),逻辑页1分别对应物理页1和物理页2,逻辑页2分别对应物理页3和物理页4,以此类推。则当文件系统进行如图4所示的垃圾回收处理时,实际是将物理页7和物理页8中的数据复制到其他物理页中。
由上述过程可知,当文件系统和存储器都需要进行垃圾回收处理时,会使得应用程序的文件访问产生较大的延迟,甚至产生卡顿。
鉴于此,本申请实施例提供一种垃圾回收方法,在该方法中,将终端设备中文件系统的垃圾回收和存储器的垃圾回收进行合并,例如,可以通过文件系统中的垃圾回收机制,统一对存储在文件系统的部分逻辑区域中的数据和存储在存储器中与该部分逻辑区域对应的物理块中的数据进行垃圾回收处理,或者,通过存储器中的垃圾回收机制,统一对存储在文件系统的剩余逻辑区域中的数据和存储在存储器中剩余物理块中的数据进行垃圾回收处理,也就是说,针对同一数据只会进行一次垃圾回收处理,从而可以避免文件系统和存储器同时进行垃圾回收时存在的重复搬移数据的情况,可以减少应用程序访问文件的时延。
下面结合附图介绍本申请实施例提供的技术方案。
需要说明的是,由前述内容可知,将终端设备中文件系统的垃圾回收和存储器的垃圾回收进行合并,可以通过文件系统中的垃圾回收机制实现,也可以通过存储器中的垃圾回收机制实现,因此,在下文中,将分为两个实施例,即实施例一和实施例二,对本申请实施例中的垃圾回收方法进行说明。其中,在实施例一中,通过文件系统中的垃圾回收机制来实现本申请的垃圾回收方法,在实施例二中,通过存储器中的垃圾回收机制,实现本申请实施例中的垃圾回收方法。
实施例一
请参考图7,为本申请实施例提供的垃圾回收方法的一种示例的流程图。在下面的介绍过程中,以本申请提供的技术方案应用在图3所示的应用场景中为例进行说明。作为一种示例,该方法可由如图3所示的计算设备200中的处理器210执行,可以理解为,由处理器210调用文件系统2201中的程序来执行。该流程图的描述如下:
S71、处理器210从存储器220获取第一信息。
在本申请实施例中,该第一信息用于指示第一单位处理单元的大小,该第一单位处理单元为存储器220进行垃圾回收操作的单位处理单元。
存储器220进行垃圾回收操作的单位处理单元,也可以称为存储器220进行垃圾回收操作的粒度,可以理解为,存储器220根据单位处理单元来判断是否需要进行垃圾回收操作。若存储器220确定某一个大小为该单位处理单元的大小的存储空间中,只有少量的数据为有效数据时,则存储器220可以对该存储空间进行垃圾回收处理,从而将该存储空间中存储的有效数据复制到其他物理块中,然后将该存储空间擦除,完成垃圾回收操作。
作为一种示例,第一单位处理单元的大小可以为存储器220的物理块的大小,例如,为72兆字节(megabyte,MB)。作为另一种示例,第一单位处理单元的大小为存储器220的物理块的大小的预设倍数,例如,该预设倍数为4倍,若存储器220的物理块的大小为72MB,则第一单位处理单元的大小为72*4=288MB。该第一单位处理单元的大小可以根据实际使用需求进行设置,在本申请实施例中不作限制。
处理器210从存储器220获取该第一信息,可以包括但不限于如下方式。
第一种获取方式:
处理器210可以通过处理器210与存储器220之间的内部通道,向存储器220发送查询指令,该查询指令用于获取存储器220的单位处理单元的大小。当存储器220接收该查询指令后,则通过该内部通道向处理器210发送与该查询指令对应的响应消息,该响应消息中携带该第一单位处理单元的大小。
该内部通道可以是基于嵌入式多媒体卡(embedded multi media card,eMMC)协议、UNIX文件系统(UNIX file system,UFS)协议的通道,或者,自定义的私有通道。该查询指令可以是在新增的专用于查询该第一单位处理单元的大小的指令,或者,也可以是通过在已有的查询指令中增加新的字段得到的,该新的字段用于指示上报该第一单位处理单元的大小,在此不对该内部通道以及查询指令作限制。
第二种获取方式:
存储器220可以主动向处理器210上报该第一单位处理单元的大小。
作为一种示例,可以对存储器220的属性信息集合进行自定义,在属性信息集合中新增字段,存储器220可以将该第一单位处理单元的大小存储在该字段中,从而处理器210可以从该属性信息集合中获取该第一单位处理单元的大小。该属性信息可以在终端设备处于工作状态后上报给处理器210。
作为另一种示例,可以在操作系统层22中安装预设的驱动程序以及与该预设的驱动程序对应的客户端软件,该预设的驱动程序用于查询存储器220的单位处理单元的大小,这样,工程人员在开启该客户端软件后,则处理器210可以通过该驱动程序获取该第一单位处理单元的大小。
作为另一种示例,可以通过自动安装技术(例如,AutoYast)或者无人值守批量安装操作系统接口技术(例如,kick-start),插入自定义动作。该自定义动作可以是:在检测到终端设备处于运行状态后,存储器220通过处理器210与存储器220之间的内部通道,向处理器210上报该第一单位处理单元的大小。
当然,处理器210可以采用其他方式,从存储器220中获取该第一单位处理单元的大小,在此不作限制。
S72、处理器210根据第一单位处理单元的大小,配置文件系统进行垃圾回收操作所使用的第二单位处理单元的大小。
具体来讲,处理器210将第二单位处理单元的大小配置为与第一单位处理单元的大小相同,例如,该第一单位处理单元的大小为288MB,则处理器210配置该第二单位处理单元的大小为288MB,或者,也可以配置该第二单位处理单元的大小为该第一单位处理单元的大小的整数倍,这样,文件系统则根据处理器210配置的第二单位处理单元的大小,对文件系统中存储的数据进行垃圾回收操作。
S73、处理器210向存储器220发送地址配置指令。
在本申请实施例中,该地址配置指令中包括文件系统所占用的块设备的逻辑地址,该地址配置指令用于指示存储器220不用对与该逻辑地址对应的物理存储空间进行垃圾回收处理。
在本申请实施例中,该地址配置指令中包括的逻辑地址可以是一个逻辑地址范围。作为一种示例,可以通过起始逻辑地址以及地址的长度来指示该逻辑地址范围,例如,可以通过每个逻辑地址的标识信息(例如,索引号或者编号等)来指示每个逻辑地址,则逻辑地址1~逻辑地址10这一段逻辑地址可以通过“1+10”表示,其中,“1”表示起始逻辑地址为逻辑地址1,“10”表示这一段逻辑地址中包括10个逻辑地址。或者,该地址配置指令中包括多个逻辑地址,该多个逻辑地址是需要与物理地址对齐的所有的逻辑地址。沿用上述例子,若需要将逻辑地址1~逻辑地址10与物理地址对齐,则该地址配置指令中则包括该多个逻辑地址中每个逻辑地址的标识信息,例如包括“1、2、3……10”。或者,该地址配置指令中只包括一个逻辑地址,该逻辑地址为一个逻辑地址范围的起始地址,用于指示位于该逻辑地址之后的所有的逻辑地址。
需要说明的是,文件系统所占用的逻辑存储空间,可以根据存储的内容不同,分为元数据区和主数据区,其中,主数据区用于存储数据,元数据区用于存储数据的元数据。以地址配置指令中包括逻辑地址范围为例,该逻辑地址范围,可以是文件系统所占用的所有的逻辑存储空间对应的一段逻辑地址,也可以是文件系统的主数据区所占用的逻辑存储空间对应的一段逻辑地址,或者,当文件系统还包括其他分区时,该逻辑地址范围也可以是其他分区对应的一段逻辑地址,在本申请实施例中不作限制。为方便说明,下文中,以该逻辑地址范围为文件系统的主数据区对应的一段逻辑地址为例。
另外,处理器210可以是在文件系统或者存储器220中存储第一个数据之前,例如,检测到终端设备处于运行状态的预设时间段内,便向存储器220发送该地址配置指令,或者,也可以是在文件系统或者存储器220中存储数据之后,才向存储器220发送该地址配置指令,在此不作限制。
S74、存储器220确定不对与该地址配置指令所包括的逻辑地址对应的物理存储空间进行垃圾回收操作。
作为一种示例,该地址配置指令中包括的逻辑地址为逻辑地址1~逻辑地址10,存储器220根据预设的算法,例如哈希算法等,计算与每个逻辑地址对应的物理地址,例如,计算得到与该逻辑地址1~逻辑地址10对应的物理地址分别为物理地址3~物理地址12,则存储器220确定不需要对物理地址3~物理地址12对应的存储空间进行垃圾回收操作。
在本申请实施例中,不限制步骤S71~步骤S72与步骤S73~步骤S74的执行顺序。例如,可以先执行步骤S71~步骤S72,再执行步骤S73~步骤S74,也可以先执行步骤S73~ 步骤S74,再执行步骤S71~步骤S72,也可以同时执行步骤S71~步骤S72与步骤S73~步骤S74。在图7中,以先执行步骤S71~步骤S72,再执行步骤S73~步骤S74为例。
S75、处理器210禁止该地址配置指令所包括的逻辑地址对应的存储空间采用本地更新的方式写入数据。
为了保证文件系统所占用的逻辑存储空间中存储的数据与存储器220中存储的数据的一致性,处理器210将禁止该地址配置指令所包括的逻辑地址对应的存储空间采用本地更新的方式写入数据。
具体来讲,文件系统可以以本地更新的方式写入数据,也可以以异地更新的方式写入数据,在这种情况下,处理器210则配置文件系统禁止以本地更新的方式写入数据,例如,文件系统可以包括多个配置参数,其中,该配置参数中包括用于指示该文件系统支持以本地更新的方式写入数据的属性,则处理器210可以配置该文件系统禁用启用该属性。
S76、处理器210向文件系统对应的逻辑存储空间中写入数据。
当处理器210接收到数据后,则以异地更新的方式向文件系统对应的逻辑存储空间中写数据,并存储到存储器220对应的物理存储空间中。
作为一种示例,处理器210接收到写数据操作,该写数据操作中包括待写入数据,处理器210可以根据预设的规则,确定与该待写入数据对应的逻辑地址,例如,确定将该写数据存储到逻辑块1中。然后,处理器210向存储器220发送数据存储指令,该指令中包括该写入数据,以及该待写入数据对应的逻辑地址,例如,为逻辑块1的标识(编号或者索引号等)。处理器220接收该指令后,确定与逻辑块1对应的物理存储空间为物理块1,则将该待写入数据存储到物理块1中。
S77、存储器220建立逻辑地址与物理地址的映射关系。
当存储器220将数据存储到对应的物理块之后,存储器220则可以建立逻辑地址与物理地址的映射关系。在本申请实施例中,以该映射关系为逻辑块和物理块之间的映射关系。例如,使用每个逻辑块或者物理块的标识来表示各个逻辑块或者物理块,由步骤S76可知,逻辑块1对应物理块1,从而得到如表1所示映射关系。
表1
逻辑块 物理块
1 1
需要说明的是,表1会随着写入的数据的增多而增加表项,表1记录了存储在存储器220的逻辑块与物理块之间的映射关系。若某一个逻辑块中未存储数据,则表1中不会存储与该逻辑块对应的映射关系。
另外,在本申请实施例中,由于表1只包括逻辑块与物理块之间的映射关系,而没有与逻辑页或者物理页之间的映射关系,所以该表1所占用的存储空间较小,可以节省存储资源。
S78、处理器210采用文件系统的垃圾回收机制进行垃圾回收操作。
随着文件系统中写入的数据越来越多,处理器210则可以运行文件系统中用于进行垃圾回收操作的代码或程序,对前述由地址配置指令所指示的逻辑存储空间进行垃圾回收操作,即确定该逻辑存储空间所包括的每一个逻辑块中,存储无效数据的逻辑页的数量是否大于阈值,若为是,则进行垃圾回收,即根据该逻辑块和物理块之间的映射关系,确定需 要擦除的物理块,并对存储器220下发擦除该物理块中的数据的指令,具体方式与现有技术中相似,在此不再赘述。
由于前述地址配置指令所指示的逻辑存储空间中每个逻辑块对应一个物理块,因此,对该逻辑存储空间进行垃圾回收操作后,存储器220不用再对该部分物理存储空间进行垃圾回收操作。从而可以省略存储器220对该部分物理存储空间进行垃圾回收操作的过程,可以减少应用程序访问文件时的时延。
在实施例一中,若步骤S73中,处理器210发送的地址配置指令所指示的逻辑地址为文件系统的部分逻辑存储空间对应的逻辑地址,例如为文件系统的主数据区对应的逻辑地址,则处理器210只针对文件系统的部分逻辑存储空间进行了垃圾回收操作。对于终端设备中的其他存储空间,例如,文件系统的元数据区对应的逻辑存储空间,则可以由存储器220来执行垃圾回收操作。下面,将介绍通过存储器220中的垃圾回收机制,实现本申请实施例中的垃圾回收方法的过程。
实施例二
请参考图8,为本申请实施例提供的垃圾回收方法的一种示例的流程图。在下面的介绍过程中,以本申请提供的技术方案应用在图3所示的应用场景中为例进行说明。作为一种示例,该方法可由如图3所示的计算设备200中的存储器220执行,可以理解为,存储器220中的控制装置或者控制器来执行。该流程图的描述如下:
S81、处理器210配置存储器220的目标存储空间以本地更新的方式写入数据。
在实际使用过程中,存储器220可以根据终端设备的使用需求,分为多个分区。例如,可以包括启动(boot)分区、重放保护数据块(replay protected memory block,RPMB)分区、用户数据分区(user data area,UDA)等。其中,boot分区用于存储终端设备所需的启动程序;RPMB分区中通常用于存储有防止非法篡改需求的数据,例如终端设备上指纹支付相关的公钥、序列号等;UDA分区通常用于存储用户数据等。当然,本申请实施例中不对终端设备的分区进行限制。
通常情况下,终端设备的UDA分区会配置文件系统,而其他分区可能没有配置文件系统。若文件系统对应的逻辑存储空间仅包括主数据区和元数据区,则该目标存储空间是指文件系统的元数据区对应的逻辑存储空间和终端设备的除UDA分区之外的其他分区。处理器210可以将元数据区和终端设备的除UDA分区之外的其他分区配置为以本地更新的方式写入数据。
需要说明的是,步骤S81是可选步骤,即不是必须要执行的。例如,元数据区和终端设备的除UDA分区之外的其他分区可以是默认配置为以本地更新的方式写入数据,在这种情况下,则处理器210不用执行步骤S81。在图8中以虚线表示该步骤为可选步骤。
S82、处理器210向存储器220的目标存储空间中写入数据。
处理器210接收到针对该元数据区的写数据操作后,则根据预设的规则,确定与该待写入数据对应的逻辑地址,例如,确定将该写入数据存储到逻辑块1的逻辑页3中。然后,处理器210向存储器220发送数据存储指令,该指令中包括该写入数据,以及该待写入数据对应的逻辑地址,例如,为逻辑块1的逻辑页3的标识(编号或者索引号等)。处理器220接收该指令后,确定与逻辑块1的逻辑页3对应的物理存储空间为物理块1的物理页4和物理页5,则将该待写入数据存储到物理块1的物理页4和物理页5中。
S83、存储器220建立逻辑地址与物理地址的映射关系。
在本申请实施例中,以该映射关系为逻辑页和物理页之间的映射关系。例如,使用每个逻辑页或者物理页的标识来表示各个逻辑页或者物理页,由步骤S82可知,逻辑块1的逻辑页3对应物理块1的物理页4和物理页5,从而得到如表2所示映射关系。
表2
逻辑页 物理页
逻辑块1的逻辑页3 物理块1的物理页4和物理页5
需要说明的是,表2与表1相似,也会随着写入的数据的增多而增加表项。表2记录了该目的存储空间的逻辑页与物理页之间的映射关系。
S84、存储器220根据所述映射关系,确定无效数据。
作为一种示例,若该映射关系中,同一个逻辑页对应两个不同的物理页,则确定该两个不同的物理页中在先的物理页中存储的数据为无效数据。
作为另一种示例,存储器220中还可以包括其他的映射关系,例如,包括以物理页为索引的反向映射关系,该反向映射关系为物理页和逻辑页之间的映射关系,存储器220通过逻辑页和物理页之间的映射关系以及该反向映射关系,一起确定某个物理页中的数据是否为无效数据。
当然,也可以通过其他方式确定某一个物理页中的数据为无效数据,在此不作限制。
S85、存储器220对目的存储空间进行垃圾回收操作。
当存储器220确定目的存储空间中的物理页满足垃圾回收条件时,例如物理页中的无效数据的数量大与阈值,则对该物理页进行垃圾回收操作,具体方式与现有技术中相似,在此不再赘述。
需要说明的是,在存储器220对该目的存储空间进行垃圾回收操作后,文件系统不用再对该其元数据分区对应的存储空间进行垃圾回收操作。从而可以省略文件系统对部分存储空间进行垃圾回收操作的过程,可以减少应用程序访问文件时的时延。
需要说明的是,实施例一和实施例二可以单独实施,也就是说,某一个终端设备中可以只实现上述两种实施例中的其中一种;或者,实施例一和实施例二也可以结合实施,也就是说,某一个终端设备中可以实现这两种实施例。
另外,本申请实施例中的方法除了可以应用在终端设备上,还可以应用在其他具有文件系统的设备中,在此不作限制。
上述本申请提供的实施例中,为了实现上述本申请实施例提供的方法中的各功能,终端设备可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。
图9示出了一种垃圾回收装置900的结构示意图。其中,垃圾回收装置900可以用于实现终端设备的处理器的功能。垃圾回收装置900可以是硬件结构、软件模块、或硬件结构加软件模块。垃圾回收装置900可以由芯片系统实现。本申请实施例中,芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
垃圾回收装置900可以包括处理模块901和通信模块902。
处理模块901可以用于执行图7所示的实施例中的步骤S72、步骤S75~步骤S76以及 步骤S78,或用于执行图8所示的实施例中的步骤S81,和/或用于支持本文所描述的技术的其它过程。
通信模块902可以用于执行图7所示的实施例中的步骤S71和步骤S73,或用于执行图8所示的实施例中的步骤S82,和/或用于支持本文所描述的技术的其它过程。通信模块902用于垃圾回收装置900和其它模块进行通信,其可以是电路、器件、接口、总线、软件模块、收发器或者其它任意可以实现通信的装置。
其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
图10示出了一种垃圾回收装置1000的结构示意图。其中,垃圾回收装置1000可以用于实现终端设备的存储器的功能。垃圾回收装置1000可以是硬件结构、软件模块、或硬件结构加软件模块。垃圾回收装置1000可以由芯片系统实现。本申请实施例中,芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
垃圾回收装置1000可以包括处理模块1001和通信模块1002。
处理模块1001可以用于执行图7所示的实施例中的步骤S74以及步骤S77,或用于执行图8所示的实施例中的步骤S83~步骤S85,和/或用于支持本文所描述的技术的其它过程。
通信模块1002可以用于执行图7所示的实施例中的步骤S71和步骤S73,或用于执行图8所示的实施例中的步骤S82,和/或用于支持本文所描述的技术的其它过程。通信模块1002用于垃圾回收装置1000和其它模块进行通信,其可以是电路、器件、接口、总线、软件模块、收发器或者其它任意可以实现通信的装置。
其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
图9或图10所示的实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,另外,在本申请各个实施例中的各功能模块可以集成在一个处理器中,也可以是单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。例如,图9或图10所示的垃圾回收装置也可以是如图2所示的终端设备,则处理模块901可以对应图2所示的终端设备的处理器210,处理模块1001可以对应图2所示的终端设备的存储器220,通信模块903和通信模块1002可以对应图2所示的终端设备的通信接口230,在此不再赘述。
本申请实施例中还提供一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行图7或图8所示的实施例中处理器或存储器执行的方法。
本申请实施例中还提供一种计算机程序产品,包括指令,当其在计算机上运行时,使得计算机执行图7或图8所示的实施例中处理器或存储器执行的方法。
本申请实施例提供了一种芯片系统,该芯片系统包括处理器,还可以包括存储器,用于实现前述方法中处理器或存储器的功能。该芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
本申请实施例提供了一种终端设备,该终端设备包括图7或图8所示的实施例中处理器和/或存储器。
本申请实施例提供的方法中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计 算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、网络设备、用户设备或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,简称DSL)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机可以存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,数字视频光盘(digital video disc,简称DVD))、或者半导体介质(例如,SSD)等。

Claims (17)

  1. 一种垃圾回收方法,其特征在于,包括:
    终端设备的处理器从所述终端设备的存储器中获取第一信息,所述第一信息用于指示第一单位处理单元的大小,所述第一单位处理单元为所述存储器进行垃圾回收操作的单位处理单元;
    所述处理器根据所述第一单位处理单元的大小,配置第二单位处理单元的大小,所述第二单位处理单元为所述终端设备的文件系统进行垃圾回收操作所使用的单位处理单元;
    所述处理器向所述存储器发送地址配置指令,所述地址配置指令中包括所述文件系统所占用的块设备的逻辑地址,所述地址配置指令用于指示所述存储器不用对与所述逻辑地址对应的物理存储空间进行垃圾回收操作;
    所述处理器根据所述第二单位处理单元的大小,对与所述逻辑地址对应的逻辑存储空间进行垃圾回收操作。
  2. 根据权利要求1所述的方法,其特征在于,所述第二单位处理单元的大小与所述第一单位处理单元的大小相同,或,所述第二单位处理单元的大小为所述第一单位处理单元的大小的整数倍。
  3. 根据权利要求1或2所述的方法,其特征在于,所述文件系统包括主数据区和元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据,所述逻辑地址为所述主数据区对应的逻辑地址集合。
  4. 根据权利要求1-3中任一项所述的方法,其特征在于,所述方法还包括:
    所述处理器禁止与所述逻辑地址对应的逻辑存储空间采用本地更新的方式写入数据。
  5. 一种垃圾回收方法,其特征在于,所述方法还包括:
    终端设备的存储器接收数据;
    所述存储器将接收的数据写入到目标存储空间中,所述目标存储空间包括所述终端设备的文件系统的元数据区对应的物理存储空间和/或所述终端设备的非用户数据UDA分区对应的物理存储空间,所述文件系统包括主数据区和所述元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据;
    所述存储器根据预设的垃圾回收策略以及预设的单位处理单元,对所述目标存储空间进行垃圾回收操作。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    所述存储器建立逻辑存储空间的逻辑页与所述目标存储空间的物理页之间的映射关系,所述逻辑存储空间为与所述元数据区和/或所述非用户数据UDA分区对应的逻辑存储空间;
    所述存储器根据所述映射关系确定无效数据;
    若一个物理页中无效数据的数量大与阈值,则所述存储器对所述物理页进行垃圾回收操作。
  7. 根据权利要求5或6所述的方法,其特征在于,所述终端设备的存储器向目标存储空间中写入数据,包括:
    所述存储器以本地更新的方式,将接收的数据写入到所述目标存储空间中。
  8. 一种垃圾回收装置,其特征在于,包括:
    通信模块,用于从所述装置的存储器中获取第一信息,所述第一信息用于指示第一单位处理单元的大小,所述第一单位处理单元为所述存储器进行垃圾回收操作的单位处理单元;
    处理模块,用于根据所述第一单位处理单元的大小,配置第二单位处理单元的大小,所述第二单位处理单元为所述装置的文件系统进行垃圾回收操作所使用的单位处理单元;
    所述通信模块,还用于向所述存储器发送地址配置指令,所述地址配置指令中包括所述文件系统所占用的块设备的逻辑地址,所述地址配置指令用于指示所述存储器不用对与所述逻辑地址对应的物理存储空间进行垃圾回收操作;
    所述处理模块,还用于根据所述第二单位处理单元的大小,对与所述逻辑地址对应的逻辑存储空间进行垃圾回收操作。
  9. 根据权利要求8所述的装置,其特征在于,所述第二单位处理单元的大小与所述第一单位处理单元的大小相同,或,所述第二单位处理单元的大小为所述第一单位处理单元的大小的整数倍。
  10. 根据权利要求8或9所述的装置,其特征在于,所述文件系统包括主数据区和元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据,所述逻辑地址为所述主数据区对应的逻辑地址集合。
  11. 根据权利要求8-10中任一项所述的装置,其特征在于,所述处理模块还用于:
    禁止与所述逻辑地址对应的逻辑存储空间采用本地更新的方式写入数据。
  12. 一种垃圾回收装置,其特征在于,包括:
    通信模块,用于接收数据;
    处理模块,用于将接收的数据写入到目标存储空间中,所述目标存储空间包括所述装置的文件系统的元数据区对应的物理存储空间和/或所述装置的非用户数据UDA分区对应的物理存储空间,所述文件系统包括主数据区和所述元数据区,所述主数据区用于存储数据,所述元数据用于存储数据的元数据;以及,
    根据预设的垃圾回收策略以及预设的单位处理单元,对所述目标存储空间进行垃圾回收操作。
  13. 根据权利要求12所述的装置,其特征在于,所述处理模块还用于:
    建立逻辑存储空间的逻辑页与所述目标存储空间的物理页之间的映射关系,所述逻辑存储空间为与所述元数据区和/或所述非用户数据UDA分区对应的逻辑存储空间;以及,根据所述映射关系确定所述无效数据;若一个物理页中无效数据的数量大与阈值,则对所述物理页进行垃圾回收操作。
  14. 根据权利要求12或13所述的装置,其特征在于,所述处理模块用于:
    以本地更新的方式,将接收的数据写入到所述目标存储空间中。
  15. 一种计算机存储介质,其特征在于,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令在被所述计算机调用时用于使所述计算机执行上述权利要求1-4或5-7中任一项所述的方法。
  16. 一种包含指令的计算机程序产品,其特征在于,当其在计算机上运行时,使得计算机执行上述权利要求1-4或5-7中任一项所述的方法。
  17. 一种终端设备,其特征在于,所述终端设备包括处理器和存储器,所述存储器中存储有计算机可执行指令,所述计算机可执行指令在被所述处理器调用时用于使所述处理 器执行上述权利要求1-4或5-7中任一项所述的方法。
PCT/CN2020/104599 2019-07-31 2020-07-24 一种垃圾回收方法及装置 WO2021018052A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201910719350.6 2019-07-31
CN201910719350 2019-07-31
CN201911209032.1 2019-11-30
CN201911209032.1A CN112306896B (zh) 2019-07-31 2019-11-30 一种垃圾回收方法及装置

Publications (1)

Publication Number Publication Date
WO2021018052A1 true WO2021018052A1 (zh) 2021-02-04

Family

ID=74230234

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/104599 WO2021018052A1 (zh) 2019-07-31 2020-07-24 一种垃圾回收方法及装置

Country Status (2)

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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020208A (zh) * 2021-09-30 2022-02-08 苏州浪潮智能科技有限公司 数据垃圾回收方法、装置、计算机设备以及存储介质
CN114489489A (zh) * 2021-12-30 2022-05-13 山东云海国创云计算装备产业创新中心有限公司 一种用于固态硬盘的垃圾回收方法、装置、设备及介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102364474A (zh) * 2011-11-17 2012-02-29 中国科学院计算技术研究所 用于机群文件系统的元数据存储系统和管理方法
US9367448B1 (en) * 2013-06-04 2016-06-14 Emc Corporation Method and system for determining data integrity for garbage collection of data storage systems
CN106293497A (zh) * 2015-05-27 2017-01-04 华为技术有限公司 瓦记录感知文件系统中垃圾数据的回收方法和装置
US20170017405A1 (en) * 2015-07-14 2017-01-19 HGST Netherlands B.V. Systems and methods for improving flash-oriented file system garbage collection
CN106708751A (zh) * 2015-11-13 2017-05-24 三星电子株式会社 包括用于多模操作的多分区的存储装置及其操作方法
CN107391774A (zh) * 2017-09-15 2017-11-24 厦门大学 基于重复数据删除的日志文件系统的垃圾回收方法
CN109376095A (zh) * 2018-12-04 2019-02-22 中国航空工业集团公司西安航空计算技术研究所 一种基于flash区域地址映射机制的垃圾回收方法
CN109960663A (zh) * 2017-12-22 2019-07-02 三星电子株式会社 执行垃圾回收的存储装置和存储装置的垃圾回收方法

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102364474A (zh) * 2011-11-17 2012-02-29 中国科学院计算技术研究所 用于机群文件系统的元数据存储系统和管理方法
US9367448B1 (en) * 2013-06-04 2016-06-14 Emc Corporation Method and system for determining data integrity for garbage collection of data storage systems
CN106293497A (zh) * 2015-05-27 2017-01-04 华为技术有限公司 瓦记录感知文件系统中垃圾数据的回收方法和装置
US20170017405A1 (en) * 2015-07-14 2017-01-19 HGST Netherlands B.V. Systems and methods for improving flash-oriented file system garbage collection
CN106708751A (zh) * 2015-11-13 2017-05-24 三星电子株式会社 包括用于多模操作的多分区的存储装置及其操作方法
CN107391774A (zh) * 2017-09-15 2017-11-24 厦门大学 基于重复数据删除的日志文件系统的垃圾回收方法
CN109960663A (zh) * 2017-12-22 2019-07-02 三星电子株式会社 执行垃圾回收的存储装置和存储装置的垃圾回收方法
CN109376095A (zh) * 2018-12-04 2019-02-22 中国航空工业集团公司西安航空计算技术研究所 一种基于flash区域地址映射机制的垃圾回收方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020208A (zh) * 2021-09-30 2022-02-08 苏州浪潮智能科技有限公司 数据垃圾回收方法、装置、计算机设备以及存储介质
CN114020208B (zh) * 2021-09-30 2023-08-22 苏州浪潮智能科技有限公司 数据垃圾回收方法、装置、计算机设备以及存储介质
CN114489489A (zh) * 2021-12-30 2022-05-13 山东云海国创云计算装备产业创新中心有限公司 一种用于固态硬盘的垃圾回收方法、装置、设备及介质
CN114489489B (zh) * 2021-12-30 2024-02-23 山东云海国创云计算装备产业创新中心有限公司 一种用于固态硬盘的垃圾回收方法、装置、设备及介质

Also Published As

Publication number Publication date
CN116166570A (zh) 2023-05-26

Similar Documents

Publication Publication Date Title
US11099937B2 (en) Implementing clone snapshots in a distributed storage system
US20190213085A1 (en) Implementing Fault Domain And Latency Requirements In A Virtualized Distributed Storage System
US9626126B2 (en) Power saving mode hybrid drive access management
WO2019062574A1 (zh) 一种元数据查询方法及装置
US9946495B2 (en) Dirty data management for hybrid drives
KR20140042518A (ko) 세그먼트 클리닝 장치 및 방법
US9195581B2 (en) Techniques for moving data between memory types
WO2021018052A1 (zh) 一种垃圾回收方法及装置
CN112799696B (zh) 固件升级方法和相关设备
US11829621B2 (en) File system and host performance booster for flash memory
US20220107752A1 (en) Data access method and apparatus
KR20140042431A (ko) 컴퓨팅 시스템 및 컴퓨팅 시스템의 데이터 관리 방법
WO2014100954A1 (zh) 数据控制方法及系统
US20140280396A1 (en) Operating method for user system including host and memory system
US20220261354A1 (en) Data access method and apparatus and storage medium
CN112711564A (zh) 合并处理方法以及相关设备
WO2016187831A1 (zh) 存取文件的方法、装置和存储系统
CN112306896B (zh) 一种垃圾回收方法及装置
US10678453B2 (en) Method and device for checking false sharing in data block deletion using a mapping pointer and weight bits
US20230093218A1 (en) Data storage method and system, and processor
KR20140042428A (ko) 컴퓨팅 시스템 및 그 데이터 관리 방법
WO2023201648A1 (zh) 文件的操作装置、计算机设备和操作设备
WO2022126534A1 (zh) 数据处理方法及相关设备
WO2024082702A1 (zh) 数据处理方法、装置、芯片以及计算机可读存储介质
US11853593B2 (en) Shared memory protection method for securing MMIO commands

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20846606

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20846606

Country of ref document: EP

Kind code of ref document: A1