CN112148631B - Garbage collection method, equipment and storage medium based on cache perception - Google Patents

Garbage collection method, equipment and storage medium based on cache perception Download PDF

Info

Publication number
CN112148631B
CN112148631B CN202011025007.0A CN202011025007A CN112148631B CN 112148631 B CN112148631 B CN 112148631B CN 202011025007 A CN202011025007 A CN 202011025007A CN 112148631 B CN112148631 B CN 112148631B
Authority
CN
China
Prior art keywords
cache
physical
page
garbage collection
block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011025007.0A
Other languages
Chinese (zh)
Other versions
CN112148631A (en
Inventor
潘玉彪
张惠臻
张忆文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huaqiao University
Original Assignee
Huaqiao University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huaqiao University filed Critical Huaqiao University
Priority to CN202011025007.0A priority Critical patent/CN112148631B/en
Publication of CN112148631A publication Critical patent/CN112148631A/en
Application granted granted Critical
Publication of CN112148631B publication Critical patent/CN112148631B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash 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
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0877Cache access modes
    • G06F12/0882Page mode
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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)
  • Memory System Of A Hierarchy Structure (AREA)
  • Memory System (AREA)

Abstract

The invention provides a garbage collection method, equipment and a storage medium based on cache perception, wherein the method comprises the steps that when garbage collection operation starts, a solid state disk scans all physical blocks and caches to obtain the number of effective pages contained in each physical block and the number of the effective pages stored in the caches by each physical block; subtracting the number of effective pages stored in the cache by the number of effective pages of each physical block to obtain the number of effective pages which each physical block really needs to move; selecting the physical block with the smallest numerical value as a target block for garbage collection; beginning scanning each physical page for the target block; and adopting a cache consistency method to complete all valid page movements of the target block which are not stored in a cache, namely completing one garbage collection operation; the method provided by the invention can obtain less effective page movement and good performance.

Description

Garbage collection method, equipment and storage medium based on cache perception
Technical Field
The present invention relates to the field of computer storage, and in particular, to a method, an apparatus, and a storage medium for garbage collection based on cache perception.
Background
Flash-based solid state disks have been used in a variety of consumer electronics and data centers because of their higher performance and lower power consumption. However, "erase before write" is a limitation based on flash solid state drives. Specifically, when updating a data page, the solid state disk needs to erase the entire data block where the data page is located, and then write data. This process will lead to degradation of the performance of the solid state disk because the erase operation is very time consuming.
In order to solve the above problems, a "remote update" mechanism is introduced inside the solid state disk. This mechanism allows updated data to be written to a blank data page and marks the data page where the old version data is located as invalid. In order to reclaim the physical space of these invalid pages occupied by older versions, a "garbage collection" operation must be deployed and triggered. Garbage collection firstly selects a physical block as a target block according to a specific algorithm, then reads out all valid page data of the target block, writes the valid page data into blank physical pages of other physical blocks, and finally erases the selected target block. The whole garbage recycling process introduces a large number of additional read-write operations of effective pages. Therefore, in order to obtain better garbage collection performance, the garbage collection mechanism typically uses a greedy algorithm to select a physical block with the least valid pages among all the physical blocks as a target block, but the algorithm does not achieve a good effect.
Disclosure of Invention
The main object of the present invention is to overcome the above drawbacks of the prior art, and to provide a garbage collection method based on cache perception, which can obtain less effective page movement and good performance.
The invention adopts the following technical scheme:
a garbage collection method based on cache awareness, comprising:
s1, starting garbage collection operation, and scanning all physical blocks by a solid state disk to obtain the number of effective pages contained in each physical block;
s2, scanning a high-speed cache corresponding to each physical block by the solid state disk, recording the number of effective pages of the physical block cached in the high-speed cache by using a counter, subtracting the value of the counter corresponding to each physical block from the number of the effective pages of each physical block, and obtaining the number of the effective pages which really need to be moved by each physical block;
s3, selecting a physical block with the minimum number of effective pages which really need to be moved as a target block for garbage recovery;
s4, starting to scan each physical page aiming at the target block;
s5, judging whether the physical page is an invalid page or not; if yes, jump to S9; otherwise, S6 is entered.
S6, judging whether the physical page is cached in a cache or not, wherein the physical page is an effective page; if yes, jumping to S8; otherwise, S7 is entered.
S7, reading the physical page from the flash memory to the cache, and if the cache is full, replacing by adopting an LRU algorithm.
S8, modifying or keeping the state of the physical page in the cache as dirty, and deleting the physical page address in the mapping relation.
S9, judging whether all physical pages in the target block are scanned; if yes, jump to S11; otherwise, S10 is entered.
S10, scanning the next physical page, and jumping to S5;
s11, completing effective page movement of the target block, and erasing the target block to complete garbage collection operation once.
Specifically, in step S2, the number of valid pages of each physical block is subtracted by the value of the counter corresponding to each physical block to obtain the number of valid pages actually required to be moved by each physical block, and the method for specifically obtaining the value of the counter includes:
when the solid state disk is initialized, the counters are all cleared;
reading a physical page from a flash memory by a read/write request of a normal user, and caching the physical page in a cache, wherein a counter corresponding to a physical block to which the physical page belongs is self-increased by 1;
the physical page in the cache is evicted from the cache due to page replacement, and the counter of the corresponding physical block is self-decremented by 1;
when one physical block is erased, the corresponding counter is cleared.
Specifically, step S8 modifies or maintains the state of the physical page in the cache as dirty, and deleting the physical page address in the mapping relationship specifically includes:
for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is "clean"; the garbage collection will not read the effective page from the flash memory, the consistency cache changes the state of the effective page in the cache into dirty, and the physical page address in the mapping relation is deleted;
for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is dirty; garbage collection will not read the valid page from flash memory, the consistency cache will keep the valid page in the dirty state in the cache, and delete the physical page address in its mapping relationship;
for a read operation triggered by garbage collection, if the valid page of the target block is not stored in the cache; garbage collection will read the valid page from flash memory, and the coherence cache will save the valid page data in cache and mark its state as dirty while deleting the physical page address in the mapping.
The invention also provides garbage collection equipment based on cache perception, which comprises a processor, wherein the processor is used for realizing the steps of the garbage collection method based on cache perception when executing a computer program stored in a memory.
The invention also provides a computer readable storage medium, on which a garbage collection program based on cache perception is stored, which when executed by a processor implements the steps of the garbage collection method based on cache perception as described above.
As can be seen from the above description of the present invention, compared with the prior art, the present invention has the following advantages:
(1) In combination with the effective page information of the cache to select the target blocks for garbage collection, compared with the traditional greedy algorithm which only considers the effective page number of the physical blocks of the flash memory as the consideration factor for selecting the target blocks, the method provided by the invention can effectively reduce the number of effective pages which need to be moved in the target blocks.
(2) The invention can accelerate the realization of the cache-aware garbage collection mechanism by setting the counter for each physical block.
(3) The cache state consistency method provided by the invention enables the cache to accurately and consistently finish normal user read-write and garbage collection read-write mixed processing.
Drawings
The invention is further described in detail below with reference to the drawings and the specific examples.
FIG. 1 is a flowchart of a garbage collection method based on cache perception according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention are clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention.
Modern solid state drives based on flash memory are equipped with a large-capacity RAM as a cache for the flash memory chip, for example, a 1TB capacity solid state drive will be equipped with approximately 1GB RAM. The RAM can hold hundreds of thousands of pages of physical page data if the physical page of the flash chip is 4 KB. The invention provides a garbage collection method based on cache perception based on the characteristic.
When the garbage collection operation is triggered in the solid state disk, the method provided by the invention can scan the number of the effective pages of all physical blocks; then, information of all effective pages in the cache is obtained, namely, how many effective pages are stored in the cache respectively for each physical block on the flash memory; then subtracting the effective page number stored in the cache by the effective page number of the physical block to obtain the number of effective pages which are really required to be moved in the garbage collection process of the physical block, wherein the effective pages in the cache do not need to be read from the flash memory; after the number of effective pages which all physical blocks really need to move is obtained, the physical block with the smallest value is selected as a target block of garbage collection operation.
FIG. 1 is an example of a detailed flow chart of a garbage collection method based on cache awareness.
101. When garbage collection operation starts, the solid state disk scans all physical blocks to obtain the number of effective pages contained in each physical block.
102. The method comprises the steps that a solid state disk scans a cache corresponding to each physical block, the number of effective pages of the physical block cached in the cache is recorded by using a counter, and the value of the counter corresponding to each physical block is subtracted from the number of the effective pages of each physical block, so that the number of the effective pages actually required to be moved by each physical block is obtained;
specifically, the method for acquiring the value of the counter comprises the following steps: when the solid state disk is initialized, the counters are all cleared;
reading a physical page from a flash memory by a read/write request of a normal user, and caching the physical page in a cache, wherein a counter corresponding to a physical block to which the physical page belongs is self-increased by 1;
the physical page in the cache is evicted from the cache due to page replacement, and the counter of the corresponding physical block is self-decremented by 1;
when one physical block is erased, the corresponding counter is cleared.
103. And selecting the physical block with the smallest value as a target block for garbage collection.
104. For this target block, scanning of each physical page begins.
105. Judging whether the physical page is an invalid page or not; if so, jump to 109; otherwise, go to 106.
106. The physical page is a valid page, and whether the physical page is cached in a cache is judged; if so, jump to 108; otherwise, go to 107.
107. The physical page is read from flash into the cache, and if the cache is full, the LRU algorithm is used for replacement.
108. The state of the physical page in the cache is modified or kept dirty, and the physical page address in the mapping relation is deleted.
The method specifically comprises the following steps: for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is "clean"; the garbage collection will not read the effective page from the flash memory, the consistency cache changes the state of the effective page in the cache into dirty, and the physical page address in the mapping relation is deleted;
for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is dirty; garbage collection will not read the valid page from flash memory, the consistency cache will keep the valid page in the dirty state in the cache, and delete the physical page address in its mapping relationship;
for a read operation triggered by garbage collection, if the valid page of the target block is not stored in the cache; garbage collection will read the valid page from flash memory, and the coherence cache will save the valid page data in cache and mark its state as dirty while deleting the physical page address in the mapping.
109. Judging whether all physical pages in the target block are scanned; if so, jump to 111; otherwise, go to 110.
110. Scanning the next physical page and jumping to 105;
111. and (3) completing the effective page movement of the target block, and erasing the target block to complete one garbage collection operation.
Based on the method, the garbage collection method based on cache perception provided by the invention comprises the following steps: the method comprises the steps that a solid state disk firstly scans all physical blocks to obtain the number of valid pages contained in all physical blocks; secondly, subtracting the value of a counter corresponding to each physical block (the number of the effective pages in the cache) from the effective page number of each physical block to obtain the number of the effective pages actually required to be moved by each physical block; then, selecting the physical block with the smallest value as a target block of garbage collection operation; next, scanning each physical page for the target block; if the physical page is an invalid page, no reading is required; otherwise, the physical page is a valid page if it is already stored in the cache and its state in the cache is "clean"; changing the state of the physical page in the cache to dirty, and deleting the physical page address in the mapping relation; if it is already held in the cache and its state in the cache is dirty; maintaining the dirty state of the physical page in the cache, and deleting the physical page address in the mapping relation; if it is not maintained in the cache, reading the physical page from flash into the cache; if the cache is full, performing cache replacement by using an LRU replacement algorithm; changing the state of the physical page in the cache into dirty, and deleting the physical page address in the mapping relation; and finally, erasing the target block to finish garbage collection operation once.
The embodiment of the invention also provides garbage collection equipment based on cache perception, which comprises a processor, wherein the processor is used for realizing the steps of the garbage collection method based on cache perception when executing a computer program stored in a memory.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a garbage collection program based on cache perception, and the garbage collection program based on cache perception realizes the steps of the garbage collection method based on cache perception when being executed by a processor.
The foregoing is merely illustrative of specific embodiments of the present invention, but the design concept of the present invention is not limited thereto, and any insubstantial modification of the present invention by using the design concept shall fall within the scope of the present invention.

Claims (3)

1. A method for garbage collection based on cache awareness, comprising:
s1, starting garbage collection operation, and scanning all physical blocks by a solid state disk to obtain the number of effective pages contained in each physical block;
s2, scanning a high-speed cache corresponding to each physical block by the solid state disk, recording the number of effective pages of the physical block cached in the high-speed cache by using a counter, subtracting the value of the counter corresponding to each physical block from the number of the effective pages of each physical block, and obtaining the number of the effective pages which really need to be moved by each physical block;
s3, selecting a physical block with the minimum number of effective pages which really need to be moved as a target block for garbage recovery;
s4, starting to scan each physical page aiming at the target block;
s5, judging whether the physical page is an invalid page or not; if yes, jump to S9; otherwise, entering S6;
s6, judging whether the physical page is cached in a cache or not, wherein the physical page is an effective page; if yes, jumping to S8; otherwise, entering S7;
s7, reading the physical page from the flash memory to a cache, and if the cache is full, adopting an LRU algorithm to replace;
s8, modifying or keeping the state of the physical page in the cache as dirty, and deleting the physical page address in the mapping relation;
s9, judging whether all physical pages in the target block are scanned; if yes, jump to S11; otherwise, enter S10;
s10, scanning the next physical page, and jumping to S5;
s11, completing effective page movement of the target block, and erasing the target block to complete garbage collection operation once;
in step S2, subtracting the value of the counter corresponding to each physical block from the number of effective pages of each physical block to obtain the number of effective pages actually required to be moved by each physical block, where the specific method for obtaining the value of the counter includes:
when the solid state disk is initialized, the counter is cleared;
reading a physical page from a flash memory by a read/write request of a user, and caching the physical page in a cache, wherein a counter corresponding to a physical block to which the physical page belongs is self-increased by 1;
the physical page in the cache is evicted from the cache due to page replacement, and the counter of the corresponding physical block is self-decremented by 1;
the physical block is erased, and the corresponding counter is cleared;
step S8, modifying or keeping the state of the physical page in the cache as dirty, and deleting the physical page address in the mapping relation specifically comprises the following steps:
for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is "clean"; the garbage collection will not read the effective page from the flash memory, the consistency cache changes the state of the effective page in the cache into dirty, and the physical page address in the mapping relation is deleted;
for garbage collection triggered read operations, if the valid page of the target block is already stored in the cache and its state in the cache is dirty; garbage collection will not read the valid page from flash memory, the consistency cache will keep the valid page in the dirty state in the cache, and delete the physical page address in its mapping relationship;
for a read operation triggered by garbage collection, if the valid page of the target block is not stored in the cache; garbage collection will read the valid page from flash memory, and the coherence cache will save the valid page data in cache and mark its state as dirty while deleting the physical page address in the mapping.
2. A cache-awareness based garbage collection device comprising a processor for implementing the steps of the cache-awareness based garbage collection method of claim 1 when executing a computer program stored in memory.
3. A computer readable storage medium, wherein a garbage collection program based on cache perception is stored on the computer readable storage medium, and the garbage collection program based on cache perception implements the steps of the garbage collection method based on cache perception according to claim 1 when executed by a processor.
CN202011025007.0A 2020-09-25 2020-09-25 Garbage collection method, equipment and storage medium based on cache perception Active CN112148631B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011025007.0A CN112148631B (en) 2020-09-25 2020-09-25 Garbage collection method, equipment and storage medium based on cache perception

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011025007.0A CN112148631B (en) 2020-09-25 2020-09-25 Garbage collection method, equipment and storage medium based on cache perception

Publications (2)

Publication Number Publication Date
CN112148631A CN112148631A (en) 2020-12-29
CN112148631B true CN112148631B (en) 2023-05-26

Family

ID=73897264

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011025007.0A Active CN112148631B (en) 2020-09-25 2020-09-25 Garbage collection method, equipment and storage medium based on cache perception

Country Status (1)

Country Link
CN (1) CN112148631B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013069859A1 (en) * 2011-11-09 2013-05-16 한양대학교 산학협력단 Device and method for controlling flash memory for storing mapping table of block to be erased
CN103136121A (en) * 2013-03-25 2013-06-05 中国人民解放军国防科学技术大学 Cache management method for solid-state disc
CN106528438A (en) * 2016-10-08 2017-03-22 华中科技大学 Segmented junk recovery method for solid-state storage device
CN108132890A (en) * 2017-12-20 2018-06-08 北京京存技术有限公司 Rubbish recovering method, device, equipment and the storage medium of storage chip
CN109582593A (en) * 2018-11-05 2019-04-05 华侨大学 A kind of FTL address mapping method and data read-write method based on calculating

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013069859A1 (en) * 2011-11-09 2013-05-16 한양대학교 산학협력단 Device and method for controlling flash memory for storing mapping table of block to be erased
CN103136121A (en) * 2013-03-25 2013-06-05 中国人民解放军国防科学技术大学 Cache management method for solid-state disc
CN106528438A (en) * 2016-10-08 2017-03-22 华中科技大学 Segmented junk recovery method for solid-state storage device
CN108132890A (en) * 2017-12-20 2018-06-08 北京京存技术有限公司 Rubbish recovering method, device, equipment and the storage medium of storage chip
CN109582593A (en) * 2018-11-05 2019-04-05 华侨大学 A kind of FTL address mapping method and data read-write method based on calculating

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
罗勇.基于混合缓存机制的垃圾回收策略研究.《中国优秀硕士学位论文全文数据库信息科技辑》.2019,全文. *

Also Published As

Publication number Publication date
CN112148631A (en) 2020-12-29

Similar Documents

Publication Publication Date Title
KR101446832B1 (en) Memory mapping techniques
TWI467369B (en) Hybrid density memory system and control method thereof
US9430376B2 (en) Priority-based garbage collection for data storage systems
US8843691B2 (en) Prioritized erasure of data blocks in a flash storage device
TWI590150B (en) Data storage device and method for managing blocks of a flash memory
US8825946B2 (en) Memory system and data writing method
TW201122812A (en) Page based management of flash storage
CN110427158B (en) Writing method of solid state disk and solid state disk
US20170075805A1 (en) Garbage collection in ssd drives
WO2012081731A1 (en) Semiconductor storage device
CN105955664B (en) A kind of reading/writing method of watt record conversion layer based on segment structure
KR20100115090A (en) Buffer-aware garbage collection technique for nand flash memory-based storage systems
KR100787856B1 (en) Method for changing page in flash memory storage
CN101727403A (en) Data storage system, equipment and method
CN109558075B (en) Method and device for storing data by using data cold and hot attributes
CN115129262A (en) Solid state disk garbage recycling method, device, equipment and medium
TWI381386B (en) Method for managing data and storage apparatus thereof and controller thereof
KR100941382B1 (en) Apparatus and method for managing page buffer linked with flash memory and apparatus and method for changing page of flash memory
CN112148631B (en) Garbage collection method, equipment and storage medium based on cache perception
TWI455131B (en) Data storage device and data writing method for a memory
CN116540950A (en) Memory device and control method for writing data thereof
CN115630001A (en) Garbage recycling method and solid state disk
CN110221774A (en) A method of the solid state hard disk garbage reclamation with abrasion equilibrium consciousness
US20200097215A1 (en) Adaptive solid state device management based on data expiration time
KR100745163B1 (en) Method for managing flash memory using dynamic mapping table

Legal Events

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