TWI644207B - Method for garbage collection of data storage device - Google Patents

Method for garbage collection of data storage device Download PDF

Info

Publication number
TWI644207B
TWI644207B TW106146458A TW106146458A TWI644207B TW I644207 B TWI644207 B TW I644207B TW 106146458 A TW106146458 A TW 106146458A TW 106146458 A TW106146458 A TW 106146458A TW I644207 B TWI644207 B TW I644207B
Authority
TW
Taiwan
Prior art keywords
data
block
data block
mapping table
bit map
Prior art date
Application number
TW106146458A
Other languages
Chinese (zh)
Other versions
TW201931126A (en
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
Application filed by 國科美國研究實驗室 filed Critical 國科美國研究實驗室
Priority to TW106146458A priority Critical patent/TWI644207B/en
Application granted granted Critical
Publication of TWI644207B publication Critical patent/TWI644207B/en
Publication of TW201931126A publication Critical patent/TW201931126A/en

Links

Landscapes

  • Memory System (AREA)

Abstract

一個資料貯存裝置用一種垃圾回收方法。該資料貯存裝置包括一個NAND快閃記憶體,該NAND快閃記憶體包括若干資料區塊,每一個資料區塊包括若干資料頁。在該垃圾回收方法中,從該等資料區塊選一個目的資料區塊。把使用者資料寫入該目的資料區塊以前,為該目的資料建立若干映射表來記錄使用者資料的邏輯地址與實體地址之關係,並建立一個關聯性位元圖。該關聯性位元圖中的每一個位元對應一個映射表。然後,選擇一個待回收資料區塊。然後,依該待回收資料區塊的關聯性位元圖讀取相關映射表。然後,逐一判斷該待回收資料區塊的全部資料頁是否在相關映射表裡。若該待回收資料區塊的一資料頁在相關映射表裡,則把該資料頁設為有效資料頁。然後,把該等有效資料頁的資料寫入該目的資料區塊。 A data storage device uses a garbage collection method. The data storage device includes a NAND flash memory, and the NAND flash memory includes a plurality of data blocks, each of which includes a plurality of data pages. In the garbage collection method, a destination data block is selected from the data blocks. Before the user data is written into the destination data block, a number of mapping tables are created for the destination data to record the relationship between the logical address of the user data and the physical address, and an associated bitmap is created. Each bit in the associated bit map corresponds to a mapping table. Then, select a block of data to be recycled. Then, the relevant mapping table is read according to the associated bit map of the to-be-recovered data block. Then, it is judged one by one whether all the data pages of the to-be-recovered data block are in the relevant mapping table. If a data page of the to-be-recovered data block is in the related mapping table, the data page is set as a valid data page. Then, the data of the valid data pages is written into the destination data block.

Description

資料貯存裝置的垃圾回收方法 Method for garbage collection of data storage device

本發明有關於資料貯存裝置,特別有關於資料貯存裝置的垃圾回收方法。 The invention relates to a data storage device, in particular to a garbage collection method for a data storage device.

快閃記憶體轉換層(Flash Translation Layer:FTL)泛指實現於快閃記憶體的韌體演算法。快閃記憶體分為NOR和NAND快閃記憶體。以下主要討論NAND快閃記憶體的FTL(或稱NFTL)。NAND快閃記憶體的快閃記憶體,不論SLC(Single-Level Chip)或MLC(Multi-Level Chip),有三個物理特性。第一,寫過的地址須抹除後方能再寫。第二,一次讀或寫的單位小而一次抹除的單位大。舉例而言,一次讀或寫的單位是一資料頁(Page)而一次抹除的單位是一資料區塊(Block)。通常,一資料區塊包括許多資料頁。第三,每一資料區塊的抹除次數受限。舉例而言,SLC的抹除次數之限制是約100000次,MLC的抹除次數之限制是約10000次。 Flash Translation Layer (FTL) refers to the firmware algorithm implemented in flash memory. Flash memory is divided into NOR and NAND flash memory. The following mainly discusses the FTL (or NFTL) of NAND flash memory. The flash memory of NAND flash memory has three physical characteristics regardless of SLC (Single-Level Chip) or MLC (Multi-Level Chip). First, the written address must be erased before it can be written. Second, the unit that reads or writes once is small and the unit that is erased at one time is large. For example, the unit of one read or write is a page and the unit erased at one time is a block. Typically, a data block includes a number of data pages. Third, the number of erasures per data block is limited. For example, the limit of the number of erasures of the SLC is about 100,000 times, and the limit of the number of erasures of the MLC is about 10,000 times.

如第1圖所示,一個FTL管理一個NAND快閃記憶體,並連接一個檔案系統。NAND快閃記憶體被分成若干資料區塊。 As shown in Figure 1, an FTL manages a NAND flash memory and connects to a file system. The NAND flash memory is divided into a number of data blocks.

如第2圖所示,每一資料區塊有若干資料頁及若干備用部(Spare)。如上所述,對FTL而言,讀及寫的最小單位是一資料頁,抹除的最小單位是一資料區塊。資料頁貯存使 用者資料。備用部,又稱作元資料(Metadata),貯存關於對應資料頁的資訊,例如這資料頁對應的邏輯位置及ECC資訊。 As shown in Figure 2, each data block has several data pages and a number of spare parts (Spare). As mentioned above, for FTL, the smallest unit of read and write is a data page, and the smallest unit of erasure is a data block. Data page storage User information. The spare part, also known as Metadata, stores information about the corresponding data page, such as the logical location and ECC information corresponding to the data page.

FTL的主要工作是處理邏輯地址(Logic Address)與實體地址(Physical Address)的映射關係(Mapping)。所以,FTL會用一些表格記錄這些關係,方便查表及寫入。FTL在寫入後,更新表格。FTL在記憶體裡配置表格空間,並在寫滿表格後,把資料從該表格下刷到NAND快閃記憶體。NAND快閃記憶體的資料區塊簡單被分為資料區塊及表格區塊。資料區塊貯存使用者資料,表格區塊貯存表格。 The main job of FTL is to handle the mapping between Logic Address and Physical Address. Therefore, FTL will use some forms to record these relationships for easy table lookup and writing. After the FTL is written, the table is updated. The FTL configures the tablespace in the memory and, after filling the form, flushes the data from the table to the NAND flash memory. The data blocks of NAND flash memory are simply divided into data blocks and table blocks. The data block stores user data and table block storage form.

第3圖到第5圖顯示寫入及回收的簡單範例。圖中的表格為實體頁碼(Physical Page Number:PPN)及資料的對應。 Figures 3 through 5 show a simple example of writing and recycling. The table in the figure is the correspondence between the physical page number (Physical Page Number: PPN) and the data.

如第3圖所示,資料區塊1000有三筆資料x、y及z。資料區塊2000是一個空閒的(free)資料區塊,裡面沒任何資料。 As shown in Figure 3, data block 1000 has three pieces of data x, y, and z. Data block 2000 is a free data block with no data in it.

如第4圖所示,更新x的資料,也就是為同一個邏輯地址(圖未示)把一筆新的資料x’寫入PPN是3的那資料頁。此時,PPN是0的那資料頁的資料就變成無效資料(invalid data)。寫滿資料區塊1000時,它包含有效資料(valid data)及無效資料。 As shown in Fig. 4, the data of x is updated, that is, a new data x' is written to the data page whose PPN is 3 for the same logical address (not shown). At this time, the data of the data page whose PPN is 0 becomes invalid data. When the data block 1000 is filled, it contains valid data and invalid data.

如第5圖所示,資料區塊1000被回收以前,資料區塊1000的有效資料頁會被寫入資料區塊2000。然後,資料區塊1000就被抹除,變回空閒資料區塊。 As shown in FIG. 5, before the data block 1000 is recycled, the valid data page of the data block 1000 is written to the data block 2000. The data block 1000 is then erased and changed back to the free data block.

當NAND快閃記憶體的可用的空間降到一個水位,FTL就會執行垃圾回收(Garbage Collection:GC)。垃圾回收有幾個步驟。首先,從一個資料區塊區域(Data Block Area:DBA)挑選一個待回收資料區塊(victim block),例如圖4所示的 資料區塊1000。其次,挑選一個目的資料區塊(destination block),例如圖4所示的資料區塊2000。接著,搬該待回收資料區塊中有效資料頁到該目的資料區塊。最後,抹除並釋放該待回收資料區塊。這流程會一直被執行,直到空閒資料區塊數目回到另一個水位之上為止。 When the available space of the NAND flash memory drops to a water level, the FTL performs Garbage Collection (GC). There are several steps in garbage collection. First, select a victim block to be recovered from a Data Block Area (DBA), such as shown in Figure 4. Data block 1000. Next, a destination data block is selected, such as data block 2000 shown in FIG. Then, the valid data page in the to-be-recovered data block is moved to the destination data block. Finally, erase and release the data block to be recycled. This process is executed until the number of free data blocks returns above another water level.

要判斷待回收資料區塊裡的某一資料頁是有效資料頁或無效資料頁,做法是檢查該資料頁的實體地址是否在一張映射表(Mapping Table)裡。若是,則表示該資料頁是有效資料頁。 To determine whether a data page in the data block to be recycled is a valid data page or an invalid data page, the method is to check whether the physical address of the data page is in a mapping table. If yes, it means that the data page is a valid data page.

當控制器用小尺寸的RAM,FTL不能把全部映射表貯存在RAM裡,以致它只能把一定數量的映射表暫存(CACHE)於RAM裡。有兩種方法可比較實體地址與映射表。 When the controller uses a small size of RAM, FTL cannot store all the mapping tables in RAM, so that it can only temporarily cache (CACHE) a certain number of mapping tables in RAM. There are two ways to compare entity addresses with mapping tables.

第一種做法是FTL把全部映射表逐一從NAND快閃記憶體寫入RAM,並把它的內容與實體地址相比。舉例而言,若在NAND快閃記憶體裡有M張映射表,則FTL須花映射表載入時間的M倍。這時間很長。 The first approach is that FTL writes all mapping tables one by one from the NAND flash memory to RAM and compares its contents to the physical address. For example, if there are M mapping tables in the NAND flash memory, the FTL must take M times the loading time of the mapping table. This is a long time.

第二種做法是FTL從待回收資料區塊的每一資料頁的元資料讀取邏輯地址,並由這些邏輯地址得知應從NAND快閃記憶體讀取那些映射表。舉例而言,若一個資料區塊有K資料頁,且須從NAND快閃記憶體讀取L張映射表,則FTL須花元資料讀取時間的K倍加映射表載入時間L倍。L小於或等於K。這時間不短。 The second method is that the FTL reads the logical addresses from the metadata of each data page of the data block to be recovered, and the logical addresses know that the mapping tables should be read from the NAND flash memory. For example, if a data block has a K data page and the L mapping table needs to be read from the NAND flash memory, the FTL must spend K times the data reading time plus the mapping table loading time L times. L is less than or equal to K. This time is not short.

有鑑於上述習知技術之問題與缺失,本發明之目的在於為一個資料貯存裝置提供一種只需要很少資源的垃圾 回收方法。 In view of the above problems and deficiencies of the prior art, the object of the present invention is to provide a data storage device with a garbage requiring only a small amount of resources. Recycling method.

為達成上述目的,該資料貯存裝置包括一個NAND快閃記憶體,該NAND快閃記憶體包括若干資料區塊,每一個資料區塊包括若干資料頁。在該垃圾回收方法中,從該等資料區塊選一個目的資料區塊。把使用者資料寫入該目的資料區塊以前,為該目的資料建立若干映射表來記錄使用者資料的邏輯地址與實體地址之關係,並建立一個關聯性位元圖。該關聯性位元圖中的每一個位元對應一個映射表。然後,選擇一個待回收資料區塊。然後,依該待回收資料區塊的關聯性位元圖讀取相關映射表。然後,逐一判斷該待回收資料區塊的全部資料頁是否在相關映射表裡。若該待回收資料區塊的一資料頁在相關映射表裡,則把該資料頁設為有效資料頁。然後,把該等有效資料頁的資料寫入另一個資料區塊。 To achieve the above object, the data storage device includes a NAND flash memory, and the NAND flash memory includes a plurality of data blocks, each of which includes a plurality of data pages. In the garbage collection method, a destination data block is selected from the data blocks. Before the user data is written into the destination data block, a number of mapping tables are created for the destination data to record the relationship between the logical address of the user data and the physical address, and an associated bitmap is created. Each bit in the associated bit map corresponds to a mapping table. Then, select a block of data to be recycled. Then, the relevant mapping table is read according to the associated bit map of the to-be-recovered data block. Then, it is judged one by one whether all the data pages of the to-be-recovered data block are in the relevant mapping table. If a data page of the to-be-recovered data block is in the related mapping table, the data page is set as a valid data page. Then, the data of the valid data pages is written into another data block.

10‧‧‧主機 10‧‧‧Host

12‧‧‧SSD控制器 12‧‧‧SSD Controller

14‧‧‧SSD記憶體 14‧‧‧SSD memory

16‧‧‧NAND快閃記憶體 16‧‧‧NAND flash memory

18‧‧‧處理器 18‧‧‧ processor

20‧‧‧有效資料頁位元圖 20‧‧‧ Effective data page bitmap

22‧‧‧映射表 22‧‧‧ mapping table

24‧‧‧關聯性位元圖 24‧‧‧ Relevance bit map

26‧‧‧資料緩衝區 26‧‧‧Data buffer

28‧‧‧表格索引一維陣列 28‧‧‧Table index one-dimensional array

30‧‧‧資料區塊 30‧‧‧Information block

32‧‧‧表格區塊 32‧‧‧Form block

34‧‧‧表格索引區塊 34‧‧‧Form Index Block

第1圖是典型的資料貯存系統的方塊圖;第2圖是第1圖所示的資料貯存系統的NAND快閃記憶體的簡化的方塊圖;第3圖到第5圖是第2圖所示的NAND快閃記憶體的兩個資料區塊在不同狀態的方塊圖;第6圖是本發明的較佳實施例的資料貯存系統在書寫子程序裡的方塊圖;第7圖是第6圖所示的資料貯存系統在回收子程序裡的方塊圖; 第8圖是第6圖所示的資料貯存系統所執行的書寫子程序的流程圖;第9圖是第7圖所示的資料貯存系統所執行的回收子程序的流程圖;及第10圖是第9圖所示的回收子程序的部分的流程圖。 1 is a block diagram of a typical data storage system; FIG. 2 is a simplified block diagram of a NAND flash memory of the data storage system shown in FIG. 1; FIGS. 3 to 5 are a second diagram A block diagram of two data blocks of the NAND flash memory in different states; FIG. 6 is a block diagram of the data storage system of the preferred embodiment of the present invention in a writing subroutine; The block diagram of the data storage system shown in the figure in the recycling subroutine; Figure 8 is a flow chart of a writing subroutine executed by the data storage system shown in Figure 6; and Figure 9 is a flow chart of the recycling subroutine executed by the data storage system shown in Figure 7; and Figure 10 It is a flowchart of a part of the recycling subroutine shown in Fig. 9.

以下,參考相關圖式,進一步說明本發明的資料貯存裝置的垃圾回收方法的實施例,相同元件係採相同符號。 Hereinafter, embodiments of the garbage collection method of the data storage device of the present invention will be further described with reference to the related drawings, and the same components are denoted by the same reference numerals.

如第6圖及第7圖所示,一個資料貯存系統包括一個主機10、一個SSD控制器12、一個SSD記憶體14及一個NAND快閃記憶體16。該資料貯存系統可用本發明的較佳實施例的垃圾回收方法。該垃圾回收方法包括一道書寫子程序及一道回收子程序。 As shown in FIGS. 6 and 7, a data storage system includes a host 10, an SSD controller 12, an SSD memory 14 and a NAND flash memory 16. The data storage system can be used in the garbage collection method of the preferred embodiment of the present invention. The garbage collection method includes a writing subroutine and a recycling subroutine.

第6圖顯示該資料貯存系統在該書寫子程序中的狀態。首先,主機10提供書寫指令。一個書寫指令包括將被貯存於NAND快閃記憶體16的使用者資料。 Figure 6 shows the state of the data storage system in the writing subroutine. First, the host 10 provides a writing instruction. A write command includes user data to be stored in NAND flash memory 16.

SSD控制器12有一個處理器18。處理器18執行FTL。SSD記憶體14貯存映射表22、一張關聯性位元圖(Relevance Bit Map)24、一個資料緩衝區(Data Buffer)26及一個表格索引一維陣列(Map Index Array)28。NAND快閃記憶體16包括若干資料區塊30、若干表格區塊32及一個表格索引區塊34。該等資料區塊30本質上相同,但因在本發明的垃圾回收方法中某階段扮演不同角色而冠上不同形容詞。空閒(free)資料區塊30是不含任何使用者資料的資料區塊30。目的資料區塊30是使用者資料要進入的資料區塊30。待回收資料區塊30是即將 被抹除並回收的資料區塊30。 The SSD controller 12 has a processor 18. The processor 18 executes the FTL. The SSD memory 14 stores a mapping table 22, a Relevance Bit Map 24, a Data Buffer 26, and a Table Index Array 28. The NAND flash memory 16 includes a plurality of data blocks 30, a plurality of table blocks 32, and a table index block 34. The data blocks 30 are essentially identical, but are distinguished by adjectives because they play different roles at some stage in the garbage collection method of the present invention. The free data block 30 is a data block 30 that does not contain any user data. The destination data block 30 is a data block 30 to which the user data is to be entered. The data block to be recycled 30 is about to be The data block 30 is erased and recovered.

映射表22貯存邏輯地址與實體地址對應關係。映射表22的大小及數目取決於SSD記憶體14的大小。 The mapping table 22 stores the correspondence between the logical address and the physical address. The size and number of the mapping table 22 depends on the size of the SSD memory 14.

關聯性位元圖24貯存一個對應的資料區塊30與多張映射表22的關聯。關聯性位元圖24的每一個位元代表一張映射表22。若目前系統有N張映射表22,則關聯性位元圖24至少會有N個位元。關聯性位元圖24被初始化時,其全部位元被設為「0」。若此對應的資料區塊30與第M張映射表22有關聯,則關聯性位元圖24的第M個位元會被設為「1」。 The associative bit map 24 stores the association of a corresponding data block 30 with a plurality of mapping tables 22. Each bit of the associated bit map 24 represents a mapping table 22. If the current system has N mapping tables 22, then the associated bit map 24 will have at least N bits. When the associative bit map 24 is initialized, all of its bits are set to "0". If the corresponding data block 30 is associated with the Mth mapping table 22, the Mth bit of the associated bit map 24 is set to "1".

資料緩衝區26暫時貯存將從主機10被寫入NAND快閃記憶體16的使用者資料。一旦地址轉換(Address Translation)完成而確定這些使用者資料的實體地址,這些使用者資料會由資料緩衝區26被搬入NAND快閃記憶體16的一個資料區塊30。 The data buffer 26 temporarily stores user data that will be written to the NAND flash memory 16 from the host 10. Once the address translation is completed and the physical address of the user data is determined, the user data is carried into the data block 30 of the NAND flash memory 16 by the data buffer 26.

表格索引一維陣列28是一張表,並紀錄映射表22及關聯性位元圖24的實體地址的一維陣列。若目前系統有N張映射表22及K張關聯性位元圖24,則這個一維陣列的大小為N+K列。表格索引一維陣列28貯存各張表在NAND快閃記憶體16裡的實體地址。 The table index one-dimensional array 28 is a table and records a one-dimensional array of the physical addresses of the mapping table 22 and the associated bit map 24. If the current system has N mapping tables 22 and K association bitmaps 24, the size of the one-dimensional array is N+K columns. The table index one-dimensional array 28 stores the physical addresses of the individual tables in the NAND flash memory 16.

寫滿一張映射表22時,把它的內容下刷到NAND快閃記憶體16的表格區塊32,並在表格索引一維陣列28裡更新這張映射表22在NAND快閃記憶體16裡的實體地址。 When a mapping table 22 is written, its contents are swiped to the table block 32 of the NAND flash memory 16, and this mapping table 22 is updated in the table index one-dimensional array 28 in the NAND flash memory 16 The physical address in .

寫滿一資料區塊30時,就把它的關聯性位元圖24的內容下刷到NAND快閃記憶體16的表格區塊32,且在表格索引一維陣列28裡更新這張關聯性位元圖24在NAND快閃記憶體16裡的實體地址。 When a data block 30 is written, the content of its associated bit map 24 is swiped to the table block 32 of the NAND flash memory 16, and the association is updated in the table index one-dimensional array 28. The physical address of the bit map 24 in the NAND flash memory 16.

每隔一段固定時間,會把表格索引一維陣列28下刷到NAND快閃記憶體16的特定地址。 At regular intervals, the table index one-dimensional array 28 is swiped to a specific address of the NAND flash memory 16.

資料區塊30貯存從主機10而來的使用者資料。表格區塊32貯存各種表,主要是映射表22及關聯性位元圖24。表格索引區塊34貯存各種表的實體地址,位在NAND快閃記憶體16的特定地址。 The data block 30 stores user data from the host computer 10. Table block 32 stores various tables, primarily mapping table 22 and associated bit map 24. Table index block 34 stores the physical addresses of the various tables, located at a particular address of NAND flash memory 16.

第7圖顯示該資料貯存系統在該回收子程序中的狀態。第7圖所示的狀態與第6圖所示的狀態相似,但有幾項差異。第一項差異是資料流向為雙向。第二項差異是資料緩衝區26貯存從待回收資料區塊30回收的資料,且把這些資料寫入目標資料區塊30。第三項差異是增加一個有效資料頁位元圖20。 Figure 7 shows the state of the data storage system in the recycling subroutine. The state shown in Figure 7 is similar to the state shown in Figure 6, but with a few differences. The first difference is that the data flow is two-way. The second difference is that the data buffer 26 stores the data recovered from the data block to be recovered 30 and writes the data to the target data block 30. The third difference is the addition of a valid data page bitmap.

在SSD記憶體14裡,會初始化一張新關聯性位元圖24,該關聯性位元圖24將標示該待回收資料區塊30的有效資料頁。舉例而言,若一資料區塊30有M資料頁,則它的關聯性位元圖24至少有M個位元。若確認該待回收資料區塊30的第K資料頁是有效的,則把它的關聯性位元圖24的第K位元設為「1」。在初始時,關聯性位元圖24的全部位元被設為「0」。垃圾回收結束時,被關聯性位元圖24佔用的空間將被釋放。 In the SSD memory 14, a new associated bit map 24 is initialized, which will indicate the valid data page of the data block 30 to be recovered. For example, if a data block 30 has an M data page, its associated bit map 24 has at least M bits. If it is confirmed that the Kth data page of the to-be-recovered data block 30 is valid, the Kth bit of its associated bit map 24 is set to "1". At the initial stage, all the bits of the associated bit map 24 are set to "0". At the end of garbage collection, the space occupied by the associated bit map 24 will be released.

第8圖是該書寫子程序的流程圖。在S10,主機10提供一個書寫指令。該書寫指令包括一筆使用者資料。 Figure 8 is a flow chart of the writing subroutine. At S10, host 10 provides a writing command. The writing instruction includes a piece of user data.

把一筆使用者資料寫入NAND快閃記憶體16以前,在S12,判斷是否把這筆使用者資料寫入一空閒資料區塊30,亦即判斷目的資料區塊30是否一空閒資料區塊30。若要把這書使用者資料寫入一空閒資料區塊30,則走到S14,否則走到S16。要把一筆使用者資料寫入空閒資料區塊30,有兩個原 因。第一,這個NAND快閃記憶體16從來沒被寫過,這筆使用者資料是第一筆資料。第二,前一目的資料區塊30已滿。不論那個原因,在S14,都須在SSD記憶體14裡初始化一張新的映射表22及一張關聯性位元圖24。若目標資料區塊非一空閒資料區塊30,則不必初始化新表。 Before writing a piece of user data into the NAND flash memory 16, at S12, it is determined whether the user data is written into an idle data block 30, that is, whether the destination data block 30 is a free data block 30. . To write the book user data to a free data block 30, go to S14, otherwise go to S16. To write a user data into the free data block 30, there are two originals. because. First, this NAND flash memory 16 has never been written. This user data is the first data. Second, the previous destination data block 30 is full. For that reason, in S14, a new mapping table 22 and an associated bit map 24 must be initialized in the SSD memory 14. If the target data block is not an idle data block 30, it is not necessary to initialize a new table.

在S16,把使用者資料寫入資料緩衝區26,並在FTL完成轉換且確定要寫入的實體地址以後,把使用者資料從資料緩衝區26下刷到NAND快閃記憶體16的目的資料區塊30。 At S16, the user data is written into the data buffer 26, and after the FTL completes the conversion and determines the physical address to be written, the user data is swiped from the data buffer 26 to the destination data of the NAND flash memory 16. Block 30.

在S18,更新在SSD記憶體14裡的映射表22及關聯性位元圖24。 At S18, the mapping table 22 and the associated bit map 24 in the SSD memory 14 are updated.

在S20,判斷目的資料區塊30是否已滿。若此目的資料區塊30已滿,則走到在S22,否則走到S24。 At S20, it is judged whether or not the destination material block 30 is full. If the destination data block 30 is full, then go to S22, otherwise go to S24.

在S22,把關聯性位元圖24下刷到NAND快閃記憶體16。 At S22, the associated bit map 24 is swiped down to the NAND flash memory 16.

在S24,判斷此映射表22是否已滿。若此映射表22已滿,則走到S26,否則走到S28。 At S24, it is judged whether or not this mapping table 22 is full. If the mapping table 22 is full, then go to S26, otherwise go to S28.

在S26,把此映射表22下刷到NAND快閃記憶體16,且FTL把此映射表22的實體地址寫入表格索引一維陣列28。 At S26, the mapping table 22 is swiped down to the NAND flash memory 16, and the FTL writes the physical address of this mapping table 22 to the table index one-dimensional array 28.

在S28,書寫子程序結束。 At S28, the writing subroutine ends.

參考第9圖,在S30,偵測到空閒資料區塊30的數目降到一定的水位時,執行該回收子程序。 Referring to Fig. 9, at S30, when the number of free data blocks 30 is detected to fall to a certain water level, the recycling subroutine is executed.

在S32,挑選含最少有效資料頁的資料區塊30當待回收資料區塊30。 At S32, the data block 30 containing the least valid data page is selected as the data block 30 to be recycled.

在S34,查詢表格索引一維陣列28而找到待回收資料區塊30對應的關聯性位元圖24的實體地址,並把此關聯性 位元圖24的資料從對應的表格區塊32載入SSD記憶體14。 At S34, the query table indexes the one-dimensional array 28 and finds the entity address of the associated bit map 24 corresponding to the data block to be recovered 30, and associates the association. The data of the bit map 24 is loaded from the corresponding table block 32 into the SSD memory 14.

在S36,掃瞄關聯性位元圖24,可以得知待回收資料區塊30與哪些映射表22有關聯,逐一查找這些映射表22的實體地址,並把它們從NAND快閃記憶體16載入SSD記憶體14。從映射表22的資料,可以得知待回收資料區塊30的那些資料頁還是有效的。 At S36, scanning the associated bit map 24, it can be known that the to-be-recovered data block 30 is associated with which mapping table 22, and the physical addresses of the mapping tables 22 are searched one by one, and they are loaded from the NAND flash memory 16 Into the SSD memory 14. From the data of the mapping table 22, it can be known that those data pages of the data block 30 to be recovered are still valid.

在S38,建立有一張有效資料頁位元圖20。把與有效資料頁對應的有效資料頁位元圖20的位元設為「1」。稍後,將參考第10圖,詳細描述如何建立有效資料頁位元圖20。 At S38, a valid data page bit map 20 is created. The bit of the valid data page bit map 20 corresponding to the valid material page is set to "1". A method of how to create a valid material page bit map 20 will be described in detail later with reference to FIG.

在S52,判斷是否已運載並掃描全部有關聯的映射表22。若已運載並掃描全部有關聯的映射表22,則走到S54,否則回到S36。 At S52, it is judged whether or not all associated mapping tables 22 have been carried and scanned. If all of the associated mapping tables 22 have been carried and scanned, then go to S54, otherwise go back to S36.

在S54,已建立有效資料頁位元圖20,從此有效資料頁位元圖20得知那些資料頁的實體地址是有效的,並把使用者資料從NAND快閃記憶體16的待回收資料區塊30載入SSD記憶體14的資料緩衝區26。稍後,把這些使用者資料下刷到該目的資料區塊30。 At S54, a valid data page bit map 20 has been created. From this valid data page bit map 20, it is known that the physical address of those data pages is valid, and the user data is from the NAND flash memory 16 to be recovered. Block 30 loads the data buffer 26 of the SSD memory 14. Later, these user profiles are swiped to the destination data block 30.

在S56,已回收待回收資料區塊30的全部有效資料頁,這個垃圾回收作業完成。 At S56, all valid data pages of the data block to be recovered 30 have been recovered, and the garbage collection operation is completed.

參考第10圖,詳細描述如何建立有效資料頁位元圖20。在S40,掃描映射表22。 Referring to Figure 10, a detailed description of how to create a valid data page bitmap 20 is described. At S40, the mapping table 22 is scanned.

在S42,讀取在映射表22的各個條目(entry)的值,此值為實體地址。 At S42, the value of each entry in the mapping table 22 is read, and this value is the physical address.

在S44,判斷該實體地址是否在待回收資料區塊30之內。若該實體地址在待回收資料區塊30之內,則走到S46,否則走到S48。 At S44, it is determined whether the physical address is within the to-be-recovered data block 30. If the physical address is within the to-be-recovered data block 30, then go to S46, otherwise go to S48.

在S46,把在有效資料頁位元圖20中,與該實體地址對應的位元設為「1」。 At S46, in the valid material page bit map 20, the bit corresponding to the physical address is set to "1".

在S48,判斷目前的條目是否最後一個條目。若目前的條目是最後一個條目,則走到S50,否則走回S42。 At S48, it is judged whether the current entry is the last entry. If the current entry is the last entry, go to S50, otherwise go back to S42.

在S50,掃瞄結束。此時,已掃描目前的映射表22的全部條目,並已完成有效資料頁位元圖20。 At S50, the scan ends. At this point, all entries of the current mapping table 22 have been scanned and the valid data page bitmap 20 has been completed.

本發明的垃圾回收方法特別適用於SSD記憶體有限的資料貯存裝置。建立關聯性位元圖24來減少掃瞄的映射表22的數量,並因此快速找到有效的資料頁。另外,建立有效資料頁位元圖20來標示有效資料頁,並因此快速把有效資料頁從待回收資料區塊30寫入一個新的資料區塊30。 The garbage collection method of the present invention is particularly suitable for a data storage device having limited SSD memory. The associated bit map 24 is established to reduce the number of scanned maps 22 and thus quickly find valid pages. In addition, a valid data page bit map 20 is created to indicate the valid data page, and thus the valid data page is quickly written from the to-be-recovered data block 30 to a new data block 30.

以上所述說明,僅為本發明的較佳實施方式而已,意在明確本發明的特徵,非用以限定本發明實施例的範圍,本技術領域內的一般技術人員根據本發明所作的均等變化,及本領域內技術人員熟知的改變,仍應屬本發明涵蓋的範圍。 The above description is only for the preferred embodiment of the present invention, and is intended to clarify the features of the present invention, and is not intended to limit the scope of the embodiments of the present invention. Changes that are well known to those skilled in the art are still within the scope of the invention.

Claims (6)

一種資料貯存裝置的垃圾回收方法,其包括以下步驟:(a)提供一種資料貯存裝置,該資料貯存裝置包括一個NAND快閃記憶體(16),該NAND快閃記憶體(16)包括若干資料區塊(30),每一個資料區塊(30)包括若干資料頁;(b)從該等資料區塊(30)選一個目的資料區塊(30);(c)把使用者資料寫入該目的資料區塊(30)以前,為該目的資料建立若干映射表(22)來記錄使用者資料的邏輯地址與實體地址之關係,並建立一個關聯性位元圖(24),該關聯性位元圖(24)中的每一個位元對應一個映射表(22);(d)從該等資料區塊(30)選一個待回收資料區塊(30);(e)依該待回收資料區塊(30)的關聯性位元圖(24)讀取相關映射表(22);(f)逐一判斷該待回收資料區塊(30)的全部資料頁是否在相關映射表(22)裡;(g)若該待回收資料區塊(30)的一資料頁在相關映射表(22)裡,則把該資料頁設為有效資料頁;及(h)把該等有效資料頁的資料寫入另一個資料區塊(30)。 A garbage collection method for a data storage device, comprising the steps of: (a) providing a data storage device, the data storage device comprising a NAND flash memory (16), the NAND flash memory (16) comprising a plurality of materials Block (30), each data block (30) includes a number of data pages; (b) selects a destination data block (30) from the data blocks (30); (c) writes user data Before the destination data block (30), a plurality of mapping tables (22) are created for the purpose data to record the relationship between the logical address of the user data and the physical address, and an associated bit map (24) is established, the association Each bit in the bit map (24) corresponds to a mapping table (22); (d) a data block to be recovered (30) is selected from the data blocks (30); (e) The correlation bit map (24) of the data block (30) reads the related mapping table (22); (f) determines one by one whether all the data pages of the to-be-recovered data block (30) are in the related mapping table (22) (g) if a data page of the data block to be recycled (30) is in the relevant mapping table (22), the data page is set as a valid data page; and (h) The data of the valid data page is written into another data block (30). 如第1請求項所述之資料貯存裝置的垃圾回收方法,其中步驟(g)包括以下步驟:(g1)建立一個有效資料頁位元圖(20),該有效資料頁位元圖(20)中每一個位元對應該待回收資料區塊(30)的一資料頁。 The garbage collection method of the data storage device according to claim 1, wherein the step (g) comprises the steps of: (g1) establishing a valid data page bitmap (20), and the valid data page bitmap (20) Each bit in the pair corresponds to a data page of the data block (30) to be recycled. 如第2請求項所述之資料貯存裝置的垃圾回收方法,其中該 步驟(g1)包括以下步驟:(g1A)把該有效資料頁位元圖(20)中對應有效資料頁的位元設為「1」;及(g1B)把該有效資料頁位元圖(20)中其他位元設為「0」。 A method of garbage collection of a data storage device according to claim 2, wherein Step (g1) includes the steps of: (g1A) setting the bit of the corresponding valid data page in the valid data page bit map (20) to "1"; and (g1B) setting the valid data page bit map (20) The other bits in the ) are set to "0". 如第1請求項所述之資料貯存裝置的垃圾回收方法,其中步驟(c)依序包括以下步驟:(c1)判斷該目的資料區塊(30)是否新資料區塊(30);(c2)若該目的資料區塊(30)是新資料區塊(30),則初始化一張新的關聯性位元圖(24)及一張新的映射圖(22);(c3)把使用者資料寫入該目的資料區塊(30);及(c4)更新該關聯性位元圖(24)及該映射圖(22)。 The method for garbage collection of a data storage device according to claim 1, wherein the step (c) comprises the following steps: (c1) determining whether the destination data block (30) is a new data block (30); (c2) If the destination data block (30) is a new data block (30), a new associated bit map (24) and a new map (22) are initialized; (c3) the user is The data is written into the destination data block (30); and (c4) the associated bit map (24) and the map (22) are updated. 如第4請求項所述之資料貯存裝置的垃圾回收方法,其中步驟(c)依序包括以下步驟:(c5)判斷該目的資料區塊(30)是否已滿;(c6)若該目的資料區塊(30)已滿,則把該關聯性位元圖(24)寫入該NAND快閃記憶體(16);(c7)判斷該映射表(22)是否已滿;(c8)若該映射表(22)已滿,則把該映射表(22)寫入該NAND快閃記憶體(16);及(c9)結束書寫。 The method for garbage collection of a data storage device according to claim 4, wherein the step (c) comprises the steps of: (c5) determining whether the destination data block (30) is full; (c6) if the destination data When the block (30) is full, the associated bit map (24) is written into the NAND flash memory (16); (c7) determines whether the mapping table (22) is full; (c8) if When the mapping table (22) is full, the mapping table (22) is written to the NAND flash memory (16); and (c9) is written. 如第1請求項所述之資料貯存裝置的垃圾回收方法,其中步驟(c)包括以下步驟:(c10)把該關聯性位元圖(24)中對應該等映射表(22)的位元設為「1」;及(c11)把該關聯性位元圖(24)中其他位元設為「0」。 The garbage collection method of the data storage device according to claim 1, wherein the step (c) comprises the step of: (c10) locating the bit corresponding to the mapping table (22) in the associated bit map (24). Set to "1"; and (c11) set the other bits in the associated bit map (24) to "0".
TW106146458A 2017-12-29 2017-12-29 Method for garbage collection of data storage device TWI644207B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW106146458A TWI644207B (en) 2017-12-29 2017-12-29 Method for garbage collection of data storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW106146458A TWI644207B (en) 2017-12-29 2017-12-29 Method for garbage collection of data storage device

Publications (2)

Publication Number Publication Date
TWI644207B true TWI644207B (en) 2018-12-11
TW201931126A TW201931126A (en) 2019-08-01

Family

ID=65432097

Family Applications (1)

Application Number Title Priority Date Filing Date
TW106146458A TWI644207B (en) 2017-12-29 2017-12-29 Method for garbage collection of data storage device

Country Status (1)

Country Link
TW (1) TWI644207B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111090595A (en) * 2019-11-19 2020-05-01 中国航空工业集团公司西安航空计算技术研究所 NAND FLASH garbage recovery balance optimization method

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070186032A1 (en) * 2005-08-03 2007-08-09 Sinclair Alan W Flash Memory Systems With Direct Data File Storage Utilizing Data Consolidation and Garbage Collection
US20080034175A1 (en) * 2006-08-04 2008-02-07 Shai Traister Methods for phased garbage collection
TW201245960A (en) * 2011-05-06 2012-11-16 Genesys Logic Inc Flash memory system and managing and collection methods for flash memory with invalid page information thereof
TW201413451A (en) * 2012-09-27 2014-04-01 Skymedi Corp Method of data collection in a non-volatile memory
TW201510723A (en) * 2009-09-03 2015-03-16 Pioneer Chip Technology Ltd Page based management of flash storage
US20160232088A1 (en) * 2014-07-17 2016-08-11 Sandisk Enterprise Ip Llc Garbage Collection in Storage System with Distributed Processors
TW201738751A (en) * 2016-04-29 2017-11-01 群聯電子股份有限公司 Mapping table loading method, memory control circuit unit and memory storage apparatus
US9811462B2 (en) * 2015-04-30 2017-11-07 Toshiba Memory Corporation Memory system executing garbage collection

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070186032A1 (en) * 2005-08-03 2007-08-09 Sinclair Alan W Flash Memory Systems With Direct Data File Storage Utilizing Data Consolidation and Garbage Collection
US20080034175A1 (en) * 2006-08-04 2008-02-07 Shai Traister Methods for phased garbage collection
TW201510723A (en) * 2009-09-03 2015-03-16 Pioneer Chip Technology Ltd Page based management of flash storage
TW201245960A (en) * 2011-05-06 2012-11-16 Genesys Logic Inc Flash memory system and managing and collection methods for flash memory with invalid page information thereof
TW201413451A (en) * 2012-09-27 2014-04-01 Skymedi Corp Method of data collection in a non-volatile memory
US20160232088A1 (en) * 2014-07-17 2016-08-11 Sandisk Enterprise Ip Llc Garbage Collection in Storage System with Distributed Processors
US9811462B2 (en) * 2015-04-30 2017-11-07 Toshiba Memory Corporation Memory system executing garbage collection
TW201738751A (en) * 2016-04-29 2017-11-01 群聯電子股份有限公司 Mapping table loading method, memory control circuit unit and memory storage apparatus

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111090595A (en) * 2019-11-19 2020-05-01 中国航空工业集团公司西安航空计算技术研究所 NAND FLASH garbage recovery balance optimization method

Also Published As

Publication number Publication date
TW201931126A (en) 2019-08-01

Similar Documents

Publication Publication Date Title
US10489291B2 (en) Garbage collection method for a data storage apparatus by finding and cleaning a victim block
CN110058796B (en) Data storage device
US10649910B2 (en) Persistent memory for key-value storage
US10698809B2 (en) Method, associated flash controller and electronic device for accessing flash module with data validity verification
US8438361B2 (en) Logical block storage in a storage device
US8117406B2 (en) Method of storing data into flash memory in a DBMS-independent manner using the page-differential
US8478796B2 (en) Uncorrectable error handling schemes for non-volatile memories
US9367451B2 (en) Storage device management device and method for managing storage device
US20080120488A1 (en) Apparatus and method of managing nonvolatile memory
US10740251B2 (en) Hybrid drive translation layer
CN108228471B (en) Method and system for managing entity information of memory unit in memory device
US8838937B1 (en) Methods, systems and computer readable medium for writing and reading data
TW201349101A (en) Data storage device and method for managing blocks of a flash memory
US20200098423A1 (en) Data storage device and control method for non-volatile memory
US20150186259A1 (en) Method and apparatus for storing data in non-volatile memory
WO2006028283B1 (en) Storage device, memory management method and program
US8892816B1 (en) System and method for writing data to a memory
TW201917581A (en) Method for managing flash memory module and associated flash memory controller
US20100318726A1 (en) Memory system and memory system managing method
US20100287330A1 (en) Method for writing data into flash memory
CN112463647A (en) Reducing the size of the forward mapping table using hashing
TWI388986B (en) Flash memory apparatus and method for operating a flash memory apparatus
TWI644207B (en) Method for garbage collection of data storage device
CN116540950B (en) Memory device and control method for writing data thereof
CN108304145A (en) The rubbish recovering method of data container device