CN102033945A - Method and device for recovering garbage - Google Patents

Method and device for recovering garbage Download PDF

Info

Publication number
CN102033945A
CN102033945A CN2010105993116A CN201010599311A CN102033945A CN 102033945 A CN102033945 A CN 102033945A CN 2010105993116 A CN2010105993116 A CN 2010105993116A CN 201010599311 A CN201010599311 A CN 201010599311A CN 102033945 A CN102033945 A CN 102033945A
Authority
CN
China
Prior art keywords
dirty
recovery
initiatively
task
threshold values
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2010105993116A
Other languages
Chinese (zh)
Inventor
冯骏
陆小飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN2010105993116A priority Critical patent/CN102033945A/en
Publication of CN102033945A publication Critical patent/CN102033945A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a method and a device for recovering garbage based on a second edition flash-memory log file system, which are used for improving the disk writing rate of the second edition flash-memory log file system (jffs2). The method comprises the following steps of: starting an active recovery task, and executing the operation of garbage recovery actively by utilizing the active recovery task.

Description

A kind of method and device that reclaims dirty
Technical field
The present invention relates to field of computer technology, be meant a kind of method and device that reclaims dirty especially.
Background technology
The characteristics of second edition flash memory log type file system (jffs2) are not revise legacy data entity on the flash when writing new data entity, and are " out-of-date " with its kernel descriptor flag just.If available erase block is less than certain threshold value (being idle threshold values) among the Flash, then system rubbish collection process (GC) is waken up and is used to discharge all out-of-date data after operation a period of time in system.
System rubbish collection process (GC) only just can be activated when the user writes dish, when the user carries out writing disk manipulation, finds that available erase block then activates rubbish system rubbish collection process (GC) and carries out garbage reclamation less than certain threshold values among the Flash.System rubbish collection process (GC) is recovered to the mark of " dirty " on the rubbish postposition, and real erase operation is carried out by the process that refreshes (pdflush) of system, and said process also can be called dirty removal process.After this, second edition flash memory log type file system (jffs2) can reuse these erase blocks.
As shown in Figure 1, detailed process is as follows:
Step 101~102: receive the user and initiate writing disk manipulation, call kernel and write interface, wait to be recycled.
Step 103: activation system garbage reclamation process (GC) reclaims the rubbish piece, and puts the mark of " dirty " in corresponding position, and here, the rubbish piece that will put the mark of " dirty " is called dirty.
Step 104: the process that refreshes (pdflush) of system is wiped dirty.
Step 105: user written data is in Flash.
Step 106: writing disk manipulation finishes.
Flash certainly exists a lot of out-of-date data after use after a while.User's writing disk manipulation must need to comprise following several operation: system rubbish collection process (GC) reclaims the rubbish piece, and the process that refreshes (pdflush) of system is wiped dirty, and user written data is to Flash.Because the writing disk manipulation process need is waited for garbage reclamation, deletes dirty and finishes, and directly carries out writing disk manipulation compared with the user, the speed that the user operates Flash has reduced by one times.
Summary of the invention
The embodiment of the invention provides a kind of method and device that reclaims dirty, writes dish speed in order to raising.
A kind of method that reclaims dirty that the embodiment of the invention provides may further comprise the steps:
Start initiatively recovery task, utilize described active recovery task to carry out dirty reclaimer operation.
A kind of device based on second edition flash memory log type file system recovery rubbish piece that the embodiment of the invention provides comprises:
Start unit is used for starting initiatively recovery task;
Initiatively reclaim control module, be used for after starting active recovery task, utilizing described active recovery task to carry out dirty reclaimer operation.
The embodiment of the invention is initiatively carried out dirty reclaimer operation by starting active recovery task, writes dish speed thereby improve greatly.
Description of drawings
Fig. 1 is a recovery process synoptic diagram of the prior art;
Fig. 2 is the present invention's active recovery process synoptic diagram;
Fig. 3 is the present invention's active recovery process synoptic diagram (comprising deterministic process);
Fig. 4 triggers the GC schematic flow sheet for the user who uses the inventive method writes the FLASH operation;
Fig. 5 is for adopting the speed contrast synoptic diagram after initiatively reclaiming;
Fig. 6 is the structural representation of apparatus of the present invention.
Embodiment
Write dish speed in order to improve, the embodiment of the invention utilizes active recovery task initiatively to carry out dirty reclaimer operation by starting initiatively recovery task.Wherein, initiatively the recovery task is the task of a new settings, initiatively carries out dirty recovery, be different from when utilizing GC to carry out dirty recovery in the prior art can only be when writing disk manipulation passive carrying out.
Further, in actual applications, the priority that the embodiment of the invention can initiatively reclaim task is set to be lower than the priority of writing disk manipulation, by under the situation of non-writing disk manipulation, carrying out dirty recovery by active recovery task, make to need not when carrying out writing disk manipulation to wipe dirty, thereby improve the dish speed of writing while writing.
Referring to shown in Figure 2, a kind of method that reclaims dirty of the embodiment of the invention specifically may further comprise the steps:
Step 201: start initiatively recovery task.
Here, can judge that dirty number is more than or equal to the recovery threshold values of the task of setting that initiatively reclaims, if dirty number, then can activate active recovery task more than or equal to the recovery threshold values of the task of setting that initiatively reclaims.Deterministic process can regularly start, and also can carry out in real time at one's leisure.
Certainly, further, if dirty number less than described recovery threshold values, then initiatively the recovery task enters dormant state, over time, carries out the judgement of dirty number once more, to confirm to activate whether once more initiatively recovery task.
Step 202: utilize initiatively dirty reclaimer operation of recovery task execution.
The described priority that initiatively reclaims task is lower than the priority of writing disk manipulation, like this can be by carry out dirty recovery by active recovery task under the situation of non-writing disk manipulation.
And, in order better to realize system compatible, can be with system rubbish collection process (GC) as the assisted process that reclaims dirty, like this, can be when writing dish, further judge whether the number of available erase block is less than or equal to the idle threshold values of setting, if the number of available erase block is less than or equal to the idle threshold values of setting, then activation system garbage reclamation process is carried out dirty recovery.Can frequently write dish and remaining available erase block number the user like this is lower than under the situation of certain threshold values and carries out dirty recovery.
In the present embodiment, initiatively the recovery task can obtain superblock information from second edition flash memory log type file system, and obtain dirty number of second edition flash memory log type according to superblock information, wherein, superblock information comprises dirty block size, the deletion queue size, deleted erase block number, each erase block sizes.
3 couples of the present invention program carry out comparatively detailed explanation below in conjunction with accompanying drawing.
Present embodiment illustrates and initiatively reclaims dirty method that it comprises following base conditioning step to be example based on second edition flash memory log type file system (jffs2):
Step 301: start initiatively recovery task, the priority that initiatively reclaims task is lower than the writing disk manipulation task that the user creates.
Step 302: the recovery threshold values that obtains second edition flash memory log type file system (jffs2).
Here, reclaiming threshold values can be to preestablish and be kept in the storage unit of system, also can from the superblock information of second edition flash memory log type file system (jffs2), obtain, such as: directly from the superblock information of second edition flash memory log type file system (jffs2), read dirty and reclaim threshold values (nospc_dirty_size), dirty is reclaimed threshold values and is called for short the recovery threshold values, the size that reclaims threshold values can be set at 1% of Flash size and add an erase block sizes, certainly, also can be set at other values according to system's needs.
When execution in step 302, obtain to reclaim threshold values by storage unit or outside node from system.And, reclaim threshold values and also can carry out upgrading at any time or at set intervals according to system's needs.
Step 303: whether judge current dirty number more than or equal to the recovery threshold values, if greater than, then execution in step 304, otherwise, execution in step 305.
Step 304: initiatively carry out an once dirty recovery.
Step 305: after dormancy a period of time, return step 303.
Active in the embodiment of the invention is reclaimed, be different from dirty removal process of second edition flash memory log type file system (jffs2) itself, system rubbish collection process (GC) is to be triggered by user's writing disk manipulation, and the process of dirty recovery must be accompanied by the process of user's writing disk manipulation.
In above-mentioned steps 301, initiatively the recovery task need accomplish following some: can not cause very big influence to system, can not carry out simultaneously with user's writing disk manipulation, its trigger process more can not depend on user's writing disk manipulation.So it is lower initiatively to reclaim the priority ratio of task, its priority must be lower than the task that the user creates.Priority determined this task could carry out system's free time and reclaimed action, in case when user initiated tasks was carried out writing disk manipulation, the recovery task will be write the dish task preemption and can not get scheduling, does not exert an influence thereby can not write dish to the user.And this task is the flow process that regularly circulation is reclaimed, and does not rely on user's writing disk manipulation.
System rubbish collection process (GC) does not need to discard, initiatively reclaim the operation of task, system rubbish collection process (GC) will become the assisted process of dirty of recovery, under the usual situation, system rubbish collection process (GC) will can not obtain scheduling again, dirty recovery is mainly carried out by active recovery task, have only the user of working as frequently to write dish, initiatively the erase block that is recovered to is less than user's consumption, cause remaining available erase block number to be lower than certain threshold values, just can activating system garbage reclamation process (GC) reclaim by force.
Initiatively reclaim not is to carry out always, in step 302, the threshold values of the recovery of superblock information acquisition second edition flash memory log type file system (jffs2) that can be by reading second edition flash memory log type file system (jffs2), superblock information comprises its dirty block size (dirty_size), deletion queue size (erasing_size), deleted erase block number (nr_erasing_blocks), each erase block sizes (sector_size).Dirty number has not only comprised the dirty block size of second edition flash memory log type file system (jffs2), also should comprise queue size to be deleted.If a dirty quilt is really deleted certainly, it just can not be calculated as dirty more so.Real deleted erase block sizes is embodied in piece number (nr_erasing_blocks) the inside of having wiped.So dirty number of current second edition flash memory log type file system (jffs2) can be calculated by following formula:
dirty=dirty_size+erasing_size-nr_erasing_blocks*sector_size
When this dirty number greater than reclaiming threshold values (nospc_dirty_size), then initiatively reclaim still and regularly carry out, if dirty number less than this value, recovering effect can be very poor again, be difficult to be recovered to enough available erase blocks, initiatively reclaim this moment and can stop.
In step 302, if dirty number is less than reclaiming threshold values, the kernel function jffs2_garbage_collect_pass that then calls Linux initiatively carries out once dirty recovery.By initiatively reclaiming, the available erase block of second edition flash memory log type file system (jffs2) will increase greatly, when the user carries out actual writing disk manipulation, need not to come dirty recovery process of concurrent execution again by system rubbish collection process (GC) again.
Referring to shown in Figure 4, write in the FLASH operating process that to trigger the GC detailed process as follows:
Step 400: the user initiates to write the FLASH operation.
Step 401: trigger GC.
Step 402: judge whether available erase block is less than or equal to the threshold values of setting, if then execution in step 403, otherwise, execution in step 405.
Step 403: activate GC and carry out garbage reclamation, promptly utilize GC to carry out the operation of reclaiming the rubbish piece, and the rubbish piece is put the mark of " dirty ".
Step 404: refresh process (pdflush) and wipe dirty, promptly wipe dirty of being recovered to and obtain available erase block, return step 402.
Step 405: user written data is to available erase block.
After the embodiment of the invention is introduced active recovery task, not not discarded second edition flash memory log type file system (jffs2) garbage reclamation flow process originally, that is to say that the above-mentioned process of writing the FLASH operation shown in Figure 4 does not change, and because after introducing active recovery task, thereby can carry out initiatively reclaiming when not having writing disk manipulation has obtained a large amount of available erase blocks.And when writing disk manipulation, owing to obtained enough available erase blocks, therefore, can directly write data in the available erase block of second edition flash memory log type file system (jffs2), thereby improve writing speed greatly.Simultaneously, when carrying out a large amount of writing disk manipulation, can also utilize that GC is auxiliary to carry out dirty reclaimer operation, like this, the garbage reclamation process of second edition flash memory log type file system (jffs2) become auxiliary garbage reclamation means.
The inventor has carried out one and has write the dish velocity test.In the test model 1, write the 64k random data at every turn, write 20M altogether.In the test model 2, write 1k at every turn, write 20M altogether.Two kinds of test models are respectively to adopting system rubbish to reclaim and adopting the speed under dirty recovery of active to compare.In the former test process, system rubbish collection process (GC) frequently is activated, and in latter's test process, system rubbish collection process (GC) number of run is constant, shows that the system rubbish collection process is not activated in writing the dish process.Number of run can directly read under the proc file system in Linux.
Test the results are shown in Figure 5, series 1 shown in Figure 5 and series 2 have represented two kinds to write the dish pattern respectively, series 1 is to write 64K at every turn, series 2 is to write 1k at every turn.。Wherein, the A of every kind of series partly is depicted as the reclaim mechanism that adopts second edition flash memory log type file system (jffs2) itself, and B partly is depicted as to adopt and writes dish speed after initiatively reclaiming.As can be seen from the figure, initiatively recovery is doubled the speed of writing dish.
Referring to shown in Figure 6, the embodiment of the invention a kind of reclaims dirty device based on second edition flash memory log type file system and comprises: start unit 61 and initiatively reclaim control module 62.
Start unit 61 is used for starting initiatively recovery task;
Initiatively reclaim control module 62, be used for after starting active recovery task, utilizing described active recovery task to carry out dirty reclaimer operation.
Described start unit 61 is used for if dirty number more than or equal to the startup threshold values of the task of setting that initiatively reclaims, then starts initiatively recovery task.
The described priority that initiatively reclaims task is lower than the priority of writing disk manipulation.
The described control module 62 that initiatively reclaims, whether the number that is used to judge dirty is less than the recovery threshold values that obtains; When dirty number during, then carry out dirty reclaimer operation more than or equal to the recovery threshold values that obtains; Further, when dirty number during less than the recovery threshold values set, then initiatively the recovery task enters dormant state, over time, obtains dirty number again, and whether carries out the judgement of dirty reclaimer operation according to the dirty number of obtaining again.
In order better to realize system compatible, this device may further include: the garbage reclamation control module is used for judging that the number of available erase block is less than or equal to the idle threshold values of setting that when writing dish then activation system garbage reclamation process is carried out dirty recovery.
The described control module 62 that initiatively reclaims, being used for utilizing initiatively, the recovery task obtains superblock information from second edition flash memory log type file system, and obtain dirty number of second edition flash memory log type according to superblock information, wherein, superblock information comprises dirty block size, the deletion queue size, deleted erase block number, each erase block sizes.
In embodiments of the present invention, create the task that initiatively reclaims of a low priority, by reading the information of Flash, thereby judged whether to carry out the action of initiatively reclaiming.When dirty number when reclaiming threshold values, then call kernel function and initiatively carry out dirty recovery.This initiatively reclaims task and both can have been avoided system is produced considerable influence, also makes to reclaim and write two operations of dish and independently carry out.Initiatively reclaim to be no longer dependent on and write dish and trigger.Need to prove that initiatively the recovery task is not to have discarded second edition flash memory log type file system (jffs2) garbage reclamation flow process originally, and just the garbage reclamation process of second edition flash memory log type file system (jffs2) has been become auxiliary garbage reclamation means.Because it is separate that initiatively garbage reclamation and user write dish, thereby make user's writing disk manipulation no longer need to wait for dirty recovery,, the dish speed of writing of second edition flash memory log type file system (jffs2) file system is doubled by the reality test.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.

Claims (10)

1. method that reclaims dirty is characterized in that this method may further comprise the steps:
Start initiatively recovery task, utilize described active recovery task to carry out dirty reclaimer operation.
2. method according to claim 1 is characterized in that, described startup initiatively recovery task also comprises:
The number of judging dirty then starts initiatively recovery task more than or equal to the recovery threshold values of setting.
3. method according to claim 2 is characterized in that, described method also comprises:
The number of judging dirty is less than described recovery threshold values, and then initiatively the recovery task enters dormant state, over time, judges once more.
4. according to claim 1,2 or 3 described methods, it is characterized in that,
When writing dish, judge that the number of available erase block is less than or equal to the idle threshold values of setting, then activation system garbage reclamation process GC carries out dirty recovery.
5. according to claim 1,2 or 3 described methods, it is characterized in that the described priority that initiatively reclaims task is lower than the priority of writing disk manipulation.
6. device that reclaims dirty is characterized in that this device comprises:
Start unit is used for starting initiatively recovery task;
Initiatively reclaim control module, be used for after starting active recovery task, utilizing described active recovery task to carry out dirty reclaimer operation.
7. device according to claim 6 is characterized in that, described start unit is used for starting active recovery task when dirty number during more than or equal to the recovery threshold values of the task of setting that initiatively reclaims.
8. device according to claim 7, it is characterized in that, the described control module that initiatively reclaims, also be used for when dirty number during less than the recovery threshold values set, then initiatively the recovery task enters dormant state, over time, obtain dirty number again, and whether carry out the judgement of dirty reclaimer operation according to the dirty number of obtaining again.
9. according to claim 6,7 or 8 described devices, it is characterized in that this device further comprises:
The garbage reclamation control module when being used to write dish, judges that the number of available erase block is less than or equal to the idle threshold values of setting, and then activation system garbage reclamation process GC carries out dirty recovery.
10. according to claim 6,7 or 8 described devices, it is characterized in that the described priority that initiatively reclaims task is lower than the priority of writing disk manipulation.
CN2010105993116A 2010-12-21 2010-12-21 Method and device for recovering garbage Pending CN102033945A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2010105993116A CN102033945A (en) 2010-12-21 2010-12-21 Method and device for recovering garbage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2010105993116A CN102033945A (en) 2010-12-21 2010-12-21 Method and device for recovering garbage

Publications (1)

Publication Number Publication Date
CN102033945A true CN102033945A (en) 2011-04-27

Family

ID=43886838

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2010105993116A Pending CN102033945A (en) 2010-12-21 2010-12-21 Method and device for recovering garbage

Country Status (1)

Country Link
CN (1) CN102033945A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104903841A (en) * 2012-12-31 2015-09-09 桑迪士克科技股份有限公司 Storage device and method for reallocating storage device resources based on an estimated fill level of a host buffer
CN105045850A (en) * 2015-07-06 2015-11-11 西北工业大学 Method for recovering junk data in cloud storage log file system
CN106095342A (en) * 2016-06-15 2016-11-09 华中科技大学 Watt recording disc array construction method and the system of a kind of dynamically changeable long strip
WO2021047398A1 (en) * 2019-09-09 2021-03-18 Oppo广东移动通信有限公司 Method and device for storage block reclaiming, storage medium, and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1815629A (en) * 2005-11-25 2006-08-09 康佳集团股份有限公司 Dirty block recovery method for flash memory device
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN101369252A (en) * 2008-09-16 2009-02-18 浙江大学 Method for static data loss equalization based on NAND flash memory file system
US20090287874A1 (en) * 2008-05-13 2009-11-19 Microsoft Corporation Flash Recovery Employing Transaction Log
CN101833512A (en) * 2010-04-22 2010-09-15 中兴通讯股份有限公司 Method and device thereof for reclaiming memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1815629A (en) * 2005-11-25 2006-08-09 康佳集团股份有限公司 Dirty block recovery method for flash memory device
US20090287874A1 (en) * 2008-05-13 2009-11-19 Microsoft Corporation Flash Recovery Employing Transaction Log
CN101281458A (en) * 2008-05-14 2008-10-08 华为技术有限公司 Apparatus, system and for recycling rubbish
CN101369252A (en) * 2008-09-16 2009-02-18 浙江大学 Method for static data loss equalization based on NAND flash memory file system
CN101833512A (en) * 2010-04-22 2010-09-15 中兴通讯股份有限公司 Method and device thereof for reclaiming memory

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104903841A (en) * 2012-12-31 2015-09-09 桑迪士克科技股份有限公司 Storage device and method for reallocating storage device resources based on an estimated fill level of a host buffer
US9703527B2 (en) 2012-12-31 2017-07-11 Sandisk Technologies Llc Storage device and method for reallocating storage device resources based on an estimated fill level of a host buffer
CN104903841B (en) * 2012-12-31 2018-01-05 桑迪士克科技有限责任公司 Estimation filling rank for Intrusion Detection based on host buffer redistributes the storage device and method of storage device resource
CN105045850A (en) * 2015-07-06 2015-11-11 西北工业大学 Method for recovering junk data in cloud storage log file system
CN105045850B (en) * 2015-07-06 2018-08-14 西北工业大学 Junk data recovery method in cloud storage log file system
CN106095342A (en) * 2016-06-15 2016-11-09 华中科技大学 Watt recording disc array construction method and the system of a kind of dynamically changeable long strip
CN106095342B (en) * 2016-06-15 2019-05-14 华中科技大学 A kind of watt recording disc array construction method and the system of dynamically changeable long strip
WO2021047398A1 (en) * 2019-09-09 2021-03-18 Oppo广东移动通信有限公司 Method and device for storage block reclaiming, storage medium, and electronic device

Similar Documents

Publication Publication Date Title
CN106484472B (en) Memory recovery method and terminal
US8880775B2 (en) System and method of garbage collection in a memory device
CN105868122A (en) Data processing method and device for quick flashing storage equipment
KR100843543B1 (en) System comprising flash memory device and data recovery method thereof
KR100725410B1 (en) Apparatus and method for executing garbage collection of non volatile memory according to power state
US9032139B2 (en) Memory allocation for fast platform hibernation and resumption of computing systems
US20190369892A1 (en) Method and Apparatus for Facilitating a Trim Process Using Auxiliary Tables
JP2007058840A5 (en)
JP2006235960A (en) Method for increasing speed of garbage collection
CN109671458A (en) The method of management flash memory module and relevant flash controller
US11467645B2 (en) Storage device and method for sudden power off recovery thereof
CN102033945A (en) Method and device for recovering garbage
CN109144428B (en) Garbage recycling method, device and medium applied to solid state disk
CN109582216A (en) Data storage device and data processing method of memory device
CN108874574A (en) A kind of garbage reclamation processing method and relevant apparatus
CN112230962B (en) BIOS configuration storage method and system for processor platform
CN110647294B (en) Storage block recovery method and device, storage medium and electronic equipment
CN105653466A (en) Data storage device and flash memory control method
KR102282006B1 (en) Computer device and storage device
KR100994723B1 (en) selective suspend resume method of reducing initial driving time in system, and computer readable medium thereof
WO2019128542A1 (en) Application processing method, electronic device, computer readable storage medium
KR101691091B1 (en) Computing system and hibernation method thereof
CN114995756A (en) Virtual disk space recovery method, device and medium
CN109086001A (en) A kind of NAND Flash rubbish recovering method and system
US20210157524A1 (en) Memory system and operating method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20110427