[go: up one dir, main page]

TWI656475B - Electronic system with data storage device - Google Patents

Electronic system with data storage device Download PDF

Info

Publication number
TWI656475B
TWI656475B TW106128024A TW106128024A TWI656475B TW I656475 B TWI656475 B TW I656475B TW 106128024 A TW106128024 A TW 106128024A TW 106128024 A TW106128024 A TW 106128024A TW I656475 B TWI656475 B TW I656475B
Authority
TW
Taiwan
Prior art keywords
page
data
temporary block
controller
block
Prior art date
Application number
TW106128024A
Other languages
Chinese (zh)
Other versions
TW201821972A (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 TW106128024A priority Critical patent/TWI656475B/en
Publication of TW201821972A publication Critical patent/TW201821972A/en
Application granted granted Critical
Publication of TWI656475B publication Critical patent/TWI656475B/en

Links

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

本發明提供一電子系統。該電子系統上運行有一主機,用於操作電子系統中配備的一資料儲存裝置。該資料儲存裝置包括一快閃記憶體以及一控制器。快閃記憶體包括複數區塊,並且區塊中包括一目前區塊以及一暫時區塊。控制器將相應於一第一邏輯位址之一第一資料寫入目前區塊,判斷暫時區塊中是否具有同樣相應於第一邏輯位址之一第二資料,其中當暫時區塊中具有同樣相應於第一邏輯位址之第二資料時,控制器更將一第一暫時區塊表寫入暫時區塊中。 The present invention provides an electronic system. The electronic system runs a host for operating a data storage device provided in the electronic system. The data storage device includes a flash memory and a controller. The flash memory includes a plurality of blocks, and the block includes a current block and a temporary block. The controller writes the first data corresponding to one of the first logical addresses into the current block, and determines whether the temporary block has the second data corresponding to one of the first logical addresses, where the temporary block has When corresponding to the second data of the first logical address, the controller further writes a first temporary block table into the temporary block.

Description

具資料儲存裝置的電子系統 Electronic system with data storage device

本發明係關於一種資料儲存裝置,特別係關於可自斷電事件回復資料狀態之資料儲存裝置。 The present invention relates to a data storage device, and more particularly to a data storage device for recovering data status from a self-power failure event.

快閃記憶體為一種普遍的非揮發性資料儲存裝置,係以電性方式抹除與程式化。以非及閘型的快閃記憶體(即NAND FLASH)為例,常用作記憶卡(memory card)、通用序列匯流排閃存裝置(USB flash device)、固態硬碟(SSD)、嵌入式快閃記憶體模組(eMMC)…等使用。 Flash memory is a popular non-volatile data storage device that is electrically erased and programmed. For example, NAND FLASH, which is not a gate type, is often used as a memory card, a universal flash memory device, a solid state drive (SSD), and an embedded flash. Memory module (eMMC)...etc.

快閃記憶體(如,NAND FLASH)的儲存陣列包括複數個區塊(blocks),其中浮置閘極電晶體可用以構成快閃記憶體。浮置閘極電晶體中之浮置閘極,可捕捉的電荷以儲存資料。另外,快閃記憶體中之實體頁面與主機裝置所指定之邏輯頁面的轉換關係需要一個表來紀錄。當非預期之斷電事件發生時,儲存於隨機記憶體中之表會丟失。如何有效重建丟失的表是一個重要的課題。 A flash memory (eg, NAND FLASH) storage array includes a plurality of blocks, wherein a floating gate transistor can be used to form a flash memory. A floating gate in a floating gate transistor that captures charge to store data. In addition, the conversion relationship between the physical page in the flash memory and the logical page specified by the host device requires a table to record. When an unexpected power outage event occurs, the table stored in random memory is lost. How to effectively reconstruct lost tables is an important issue.

本發明所提供之資料儲存裝置以及資料維護方法可獨立將系統資料儲存在暫時區塊中,並且藉由暫時區塊表區隔相同邏輯位址之資料何者為有效資料。 The data storage device and the data maintenance method provided by the invention can independently store the system data in the temporary block, and the data of the same logical address is separated by the temporary block table as the valid data.

一種實施方式提供一電子系統,其中包括一主機 以及該主機所操控的一資料儲存裝置。 An embodiment provides an electronic system including a host And a data storage device controlled by the host.

本發明提供一種資料儲存裝置包括一快閃記憶體以及一控制器。快閃記憶體包括複數區塊,並且區塊中包括一目前區塊以及一暫時區塊。控制器將相應於一第一邏輯位址之一第一資料寫入目前區塊,判斷暫時區塊中是否具有同樣相應於第一邏輯位址之一第二資料,其中當暫時區塊中具有同樣相應於第一邏輯位址之第二資料時,控制器更將一第一暫時區塊表寫入暫時區塊中。 The invention provides a data storage device comprising a flash memory and a controller. The flash memory includes a plurality of blocks, and the block includes a current block and a temporary block. The controller writes the first data corresponding to one of the first logical addresses into the current block, and determines whether the temporary block has the second data corresponding to one of the first logical addresses, where the temporary block has When corresponding to the second data of the first logical address, the controller further writes a first temporary block table into the temporary block.

在一實施例中,第一資料係為一主機之一寫入命令所指示的資料,或者第一資料為暫時區塊中之冷資料。第一暫時區塊表中紀錄了暫時區塊中所有頁面之資訊。 In an embodiment, the first data is data indicated by one of the host write commands, or the first data is cold data in the temporary block. The first temporary block table records information about all pages in the temporary block.

又一實施例中,在控制器在儲存於一隨機存取記憶體中之一目前暫時區塊表中,解除第二資料與邏輯位址的關係,以更新目前暫時區塊表。控制器系將更新後之目前暫時區塊表作為第一暫時區塊表以寫入暫時區塊之頁面中之一特定頁面,其中特定頁面不具有使用者資料。 In another embodiment, the controller releases the relationship between the second data and the logical address in a current temporary block table stored in a random access memory to update the current temporary block table. The controller uses the updated current temporary block table as the first temporary block table to write to one of the pages of the temporary block, wherein the specific page does not have the user profile.

又另一實施例中,每一區塊包括依照一第一順序排列之複數頁面。控制器用以在資料儲存裝置自一斷電事件回復後,根據暫時區塊中之第X個頁面所儲存之一第二暫時區塊表,判斷暫時區塊與目前區塊中具有相同邏輯位址之資料何者為有效資料,其中第X個頁面是暫時區塊中在斷電事件前最後一個被寫入之頁面,並且X為一正整數。另外,在暫時區塊中之每一頁面係用以儲存長度小於一既定長度之系統資料,除了系統資料外之其他資料皆係寫入目前區塊中,並且每一頁面皆 具有一使用者資料空間以及一備用空間。在資料儲存裝置自斷電事件回復後,控制器係用以使用一尋找程序來獲得第X個頁面,其中在尋找程序中,控制器自暫時區塊中之第1個頁面開始,依照第一順序讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。在讀取到不具有有效資料的備用空間後,控制器更自所讀取到不具有有效資料之備用空間所相應之頁面的下一個開始,依照一第二順序逐一讀取暫時區塊中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止,其中控制器依照第二順序讀取到具有有效資料之備用空間所屬之頁面為一第一空白頁面,並且第二順序與第一順序相反。控制器更讀取第一空白頁面中之使用者資料空間,並且判斷第一空白頁面中之使用者資料空間是否具有有效資料,以確認第一空白頁面為暫時區塊中第一個不具有使用者資料的頁面,其中當第一空白頁面中之使用者資料空間具有有效資料時,控制器更自第一空白頁面開始依照第一順序逐一讀取暫時區塊中之頁面的使用者資料空間,直到所讀取之使用者資料空間不具有有效資料為止,其中使用者資料空間不具有有效資料的頁面取代原第一空白頁面成為新的第一空白頁面。控制器更自第一空白頁面的上一個頁面或者新的第一空白頁面的上一個頁面開始,依照第二順序逐一讀取暫時區塊中之頁面之使用者資料空間,並且判斷所讀取之頁面之使用者空間是否具有有效資料,其中反序所讀取具有有效資料之使用者資料空間所相應之頁面,為暫時區塊中最後一個具有有效資料之頁面,並且為第X個頁面。 In still another embodiment, each block includes a plurality of pages arranged in a first order. The controller is configured to determine, according to a second temporary block table stored in the Xth page in the temporary block, after the data storage device recovers from a power-off event, that the temporary block has the same logical address as the current block. The data is valid, and the Xth page is the last page written in the temporary block before the power-off event, and X is a positive integer. In addition, each page in the temporary block is used to store system data whose length is less than a predetermined length, and other materials except the system data are written into the current block, and each page is It has a user data space and a spare space. After the data storage device recovers from the power-off event, the controller uses a search program to obtain the Xth page, wherein in the search process, the controller starts from the first page in the temporary block, according to the first The spare space of a predetermined number of pages in the temporary block is sequentially read until the read spare space does not have valid data. After reading the spare space without valid data, the controller starts from the next page of the page corresponding to the spare space that does not have valid data, and reads the temporary block one by one according to a second order. The spare space of the page until the read spare space has valid data, wherein the controller reads the page to which the spare space having the valid data belongs according to the second order is a first blank page, and the second order is first The order is reversed. The controller further reads the user data space in the first blank page, and determines whether the user data space in the first blank page has valid data, so as to confirm that the first blank page is the first one in the temporary block. The page of the user data, wherein when the user data space in the first blank page has valid data, the controller further reads the user data space of the page in the temporary block one by one according to the first order from the first blank page. Until the read user data space does not have valid data, the page in which the user data space does not have valid data replaces the original first blank page to become the new first blank page. The controller further starts from the previous page of the first blank page or the previous page of the new first blank page, reads the user data space of the page in the temporary block one by one according to the second order, and judges that the read is performed. Whether the user space of the page has valid data, wherein the page corresponding to the user data space with valid data is read in reverse order, which is the last page in the temporary block with valid data, and is the Xth page.

本發明另提供一種資料維護方法,適用於具有一快閃記憶體之一資料儲存裝置,其中快閃記憶體包括複數區塊,並且區塊中包括一目前區塊以及一暫時區塊。資料維護方法包括:將相應於一第一邏輯位址之一第一資料寫入目前區塊;判斷暫時區塊中是否具有同樣相應於第一邏輯位址之一第二資料;以及當暫時區塊中具有同樣相應於第一邏輯位址之第二資料時,將一第一暫時區塊表寫入暫時區塊中。 The present invention further provides a data maintenance method, which is suitable for a data storage device having a flash memory, wherein the flash memory includes a plurality of blocks, and the block includes a current block and a temporary block. The data maintenance method includes: writing a first data corresponding to one of the first logical addresses to the current block; determining whether the temporary block has the second data corresponding to one of the first logical addresses; and when the temporary area When the block has the second data corresponding to the first logical address, a first temporary block table is written into the temporary block.

在一實施例中,在儲存於一隨機存取記憶體中之一目前暫時區塊表中,解除第二資料與邏輯位址的關係,以更新目前暫時區塊表。將第一暫時區塊表寫入暫時區塊中的步驟更包括將更新後之目前暫時區塊表作為第一暫時區塊表,以寫入暫時區塊之頁面中之一特定頁面,其中特定頁面不具有使用者資料。 In one embodiment, the relationship between the second data and the logical address is released in one of the current temporary block tables stored in a random access memory to update the current temporary block table. The step of writing the first temporary block table into the temporary block further includes using the updated current temporary block table as the first temporary block table to write one of the pages of the temporary block, wherein the specific page The page does not have user data.

另一實施例中,每一區塊包括依照一第一順序排列之複數頁面。資料維護方法更包括在資料儲存裝置自一斷電事件回復後,根據暫時區塊中之第X個頁面所儲存之一第二暫時區塊表,判斷暫時區塊與目前區塊中具有相同邏輯位址之資料何者為有效資料,其中第X個頁面是暫時區塊中在斷電事件前最後一個被寫入之頁面,並且X為一正整數,並且第X個頁面是暫時區塊中在斷電事件前最後一個被寫入之頁面,並且X為一正整數。在暫時區塊中之每一頁面係用以儲存長度小於一既定長度之系統資料,並且除了系統資料外之其他資料皆係寫入目前區塊中。另外,每一頁面皆具有一使用者資料空間以及一備用空間,並且資料維護方法更包括在資料儲存裝置自斷電 事件回復後,使用一尋找程序來獲得第X個頁面。 In another embodiment, each block includes a plurality of pages arranged in a first order. The data maintenance method further comprises: after the data storage device recovers from a power-off event, determining that the temporary block has the same logic as the current block according to a second temporary block table stored in the Xth page in the temporary block. The information of the address is the valid data, wherein the Xth page is the last page written in the temporary block before the power-off event, and X is a positive integer, and the Xth page is in the temporary block. The last page written before the power down event, and X is a positive integer. Each page in the temporary block is used to store system data having a length less than a predetermined length, and other data except the system data is written into the current block. In addition, each page has a user data space and a spare space, and the data maintenance method further includes self-powering in the data storage device. After the event is replied, use a search program to get the Xth page.

尋找程序包括:自暫時區塊中之第1個頁面開始,依照第一順序讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止;在讀取到不具有有效資料的備用空間後,自所讀取到不具有有效資料之備用空間所相應之頁面的下一個開始,依照一第二順序逐一讀取暫時區塊中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止,其中依照第二順序讀取到具有有效資料之備用空間所屬之頁面為一第一空白頁面,並且第二順序與第一順序相反;自第一空白頁面開始依照第一順序逐一讀取暫時區塊中之頁面的使用者資料空間,直到所讀取之使用者資料空間不具有有效資料為止,其中使用者資料空間不具有有效資料的頁面取代原第一空白頁面成為新的第一空白頁面;以及自第一空白頁面的上一個頁面或者新的第一空白頁面的上一個頁面開始,依照第二順序逐一讀取暫時區塊中之頁面之使用者資料空間,並且判斷所讀取之頁面之使用者空間是否具有有效資料,其中反序所讀取具有有效資料之使用者資料空間所相應之頁面,為暫時區塊中最後一個具有有效資料之頁面,並且為第X個頁面。 The searching program includes: starting from the first page in the temporary block, reading the spare space of the predetermined number of pages in the temporary block according to the first sequence until the read spare space does not have valid data; After reading the spare space without valid data, the backup space of the page in the temporary block is read one by one according to a second sequence starting from the next page of the page corresponding to the spare space that does not have valid data. Until the read spare space has valid data, wherein the page to which the spare space having the valid data belongs according to the second order belongs to a first blank page, and the second order is opposite to the first order; The blank page begins to read the user data space of the page in the temporary block one by one in the first order until the read user data space does not have valid data, and the user data space does not have valid data. The first blank page becomes the new first blank page; and the previous page from the first blank page or the new first blank Starting from the previous page of the page, the user data space of the page in the temporary block is read one by one according to the second order, and it is determined whether the user space of the read page has valid data, wherein the reverse reading is effective. The page corresponding to the user data space of the data is the last page in the temporary block with valid data, and is the Xth page.

100‧‧‧電子系統 100‧‧‧Electronic system

120‧‧‧主機 120‧‧‧Host

140‧‧‧資料儲存裝置 140‧‧‧Data storage device

160‧‧‧控制器 160‧‧‧ Controller

162‧‧‧運算單元 162‧‧‧ arithmetic unit

164‧‧‧永久記憶體 164‧‧‧Permanent memory

166‧‧‧隨機存取記憶體 166‧‧‧ random access memory

180‧‧‧快閃記憶體 180‧‧‧Flash memory

P1~PN‧‧‧頁面 P1~PN‧‧‧ page

B0~BN‧‧‧區塊 B0~BN‧‧‧ Block

DAA1~DAAN‧‧‧使用者資料空間 DAA1~DAAN‧‧‧ User Data Space

SPA1~SPAN‧‧‧備用空間 SPA1~SPAN‧‧‧ spare space

D1‧‧‧第一順序 D1‧‧‧ first order

D2‧‧‧第二順序 D2‧‧‧ second order

DA1~DA12‧‧‧資料 DA1~DA12‧‧‧Information

TP1~TP12‧‧‧暫時區塊表 TP1~TP12‧‧‧ Temporary Block Table

SP1~SP12‧‧‧備份資料 SP1~SP12‧‧‧Backup data

S600~S604、S700~S702、S800~S806‧‧‧步驟 S600~S604, S700~S702, S800~S806‧‧‧ steps

第1圖為本發明所提供之一電子系統之一種實施例的方塊圖。 BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a block diagram of one embodiment of an electronic system provided by the present invention.

第2圖為本發明所提供之一快閃記憶體之一種實施例的方塊圖。 Figure 2 is a block diagram of one embodiment of a flash memory provided by the present invention.

第3圖為本發明所提供之一暫時區塊之一種實施例的示意圖。 Figure 3 is a schematic illustration of one embodiment of a temporary block provided by the present invention.

第4圖為本發明所提供之一暫時區塊之另一種實施例的示意圖。 Figure 4 is a schematic illustration of another embodiment of a temporary block provided by the present invention.

第5圖為本發明所提供之一暫時區塊之另一種實施例的示意圖。 Figure 5 is a schematic diagram of another embodiment of a temporary block provided by the present invention.

第6圖為本發明所提供之一資料維護方法之一種實施例的流程圖。 Figure 6 is a flow chart of an embodiment of a data maintenance method provided by the present invention.

第7圖為本發明所提供之一資料維護方法之另一種實施例的流程圖。 Figure 7 is a flow chart of another embodiment of a data maintenance method provided by the present invention.

第8圖為本發明所提供之一尋找程序之一種實施例的流程圖。 Figure 8 is a flow diagram of one embodiment of a search procedure provided by the present invention.

以下將詳細討論本發明各種實施例之裝置及使用方法。然而值得注意的是,本發明所提供之許多可行的發明概念可實施在各種特定範圍中。這些特定實施例僅用於舉例說明本發明之裝置及使用方法,但非用於限定本發明之範圍。 The apparatus and method of use of various embodiments of the present invention are discussed in detail below. However, it is to be noted that many of the possible inventive concepts provided by the present invention can be implemented in various specific ranges. These specific examples are only intended to illustrate the apparatus and methods of use of the present invention, but are not intended to limit the scope of the invention.

第1圖為本發明所提供之一電子系統之一種實施例的方塊圖。電子系統100包括一主機120以及一資料儲存裝置140。資料儲存裝置140包括一快閃記憶體180以及一控制器160,且可根據主機120所下達的命令操作。控制器160包括一運算單元162、一永久記憶體(如,唯讀記憶體ROM)164以及隨機存取記憶體(RAM)166。永久記憶體164與所載之程式碼、資料組成韌體(firmware),由運算單元162執行,使控制器160基 於該韌體控制該快閃記憶體180。隨機存取記憶體(RAM)166用以載入程式碼與參數以提供控制器160根據所載入的程式碼與參數動作。快閃記憶體180包括複數區塊,每一區塊包括依照一第一順序D1排列之複數頁面P1~PN,其中每一頁面P1~PN具有一使用者資料空間DAA1~DAAN以及一備用空間(Spare Area)SPA1~SPAN,如第2圖所示。值得注意的是,快閃記憶體180以區塊為最小單位進行抹除,並且頁面為最小單位進行寫入。另外,備用空間SPA1~SPAN可在其所相應之頁面的前方或者後方,本發明不限於此。在其他實施例中,備用空間SPA1~SPAN亦可位於區塊B0~BN之前端或者後端。值得注意的是,在一實施例中,具有有效資料之每一頁面的備用空間中包括所處之頁面的資料,例如相應之邏輯位址、資料狀態等等。 BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a block diagram of one embodiment of an electronic system provided by the present invention. The electronic system 100 includes a host 120 and a data storage device 140. The data storage device 140 includes a flash memory 180 and a controller 160, and is operable according to commands issued by the host 120. The controller 160 includes an arithmetic unit 162, a permanent memory (e.g., read only memory ROM) 164, and a random access memory (RAM) 166. The permanent memory 164 and the stored code and data constitute a firmware, which is executed by the operation unit 162 to make the controller 160 base. The flash memory 180 is controlled by the firmware. Random access memory (RAM) 166 is used to load code and parameters to provide controller 160 to act upon the loaded code and parameters. The flash memory 180 includes a plurality of blocks, each of which includes a plurality of pages P1 to PN arranged in a first order D1, wherein each page P1 PN has a user data space DAA1~DAAN and a spare space ( Spare Area) SPA1~SPAN, as shown in Figure 2. It is worth noting that the flash memory 180 is erased in the smallest unit of the block, and the page is written in the smallest unit. In addition, the spare space SPA1~SPAN may be in front of or behind the corresponding page, and the present invention is not limited thereto. In other embodiments, the spare space SPA1~SPAN may also be located at the front end or the back end of the block B0~BN. It should be noted that in an embodiment, the spare space of each page having valid data includes the data of the page in which it is located, such as the corresponding logical address, data status, and the like.

在一實施例中,控制器160會自快閃記憶體180之區塊B0~BN中選取一個可使用之區塊以作為一目前區塊,並且在隨機存取記憶體166中建立一實體轉邏輯對應表以紀錄目前區塊之頁面之實體位址與資料之頁面的邏輯位址的對應關係。當目前區塊已經被使用者資料寫滿(無法再寫入新的資料時),控制器160將實體轉邏輯對應表整理至儲存於快閃記憶體180中之一資料鏈結關係表,並且將目前區塊定義為資料母區塊,重新自快閃記憶體180之區塊B0~BN中選取一個可使用之區塊以作為新的目前區塊,並且在隨機存取記憶體166中建立新的一實體轉邏輯對應表以紀錄新的目前區塊之頁面之實體位址與資料之頁面的邏輯位址的對應關係。 In an embodiment, the controller 160 selects a usable block from the blocks B0 B BN of the flash memory 180 as a current block, and establishes an entity transfer in the random access memory 166. The logical correspondence table records the correspondence between the physical address of the page of the current block and the logical address of the page of the data. When the current block has been filled with the user data (when the new data cannot be written again), the controller 160 sorts the entity-to-logical correspondence table into a data link relationship table stored in the flash memory 180, and The current block is defined as a data parent block, and a usable block is selected from the blocks B0 to BN of the flash memory 180 as a new current block, and is established in the random access memory 166. The new entity-to-logic correspondence table records the correspondence between the physical address of the page of the new current block and the logical address of the page of the data.

然而,在被寫入快閃記憶體180之使用者資料中, 有些類型的資料會重複地被寫入相同的邏輯位址,造成先前在同個邏輯位址的資料被無效。當區塊B0~BN中之資料母區塊具有太多無效資料時,會導致控制器160頻繁的執行整理工作,以釋放可用的記憶體空間。然而,頻繁的整理工作會降低資料儲存裝置140的效能。 However, in the user data written to the flash memory 180, Some types of data are repeatedly written to the same logical address, causing data previously in the same logical address to be invalidated. When the data parent block in the blocks B0~BN has too much invalid data, the controller 160 frequently performs the sorting work to release the available memory space. However, frequent finishing efforts can degrade the performance of the data storage device 140.

有鑑於此,在一實施例中,由於系統資料通常會對同個邏輯位址重複地進行寫入,因此控制器160會將系統資料儲存於另一個區塊(暫時區塊)之中。另外,控制器160亦在隨機存取記憶體166中,建立一暫時區塊表,以記錄暫時區塊之頁面之實體位址與資料之頁面的邏輯位址的對應關係。值得注意的是,暫時區塊表中紀錄了暫時區塊中所有頁面之資訊。換言之,暫時區塊表中紀錄了暫時區塊中所有頁面位址對應關係。 In view of this, in an embodiment, since the system data is usually repeatedly written to the same logical address, the controller 160 stores the system data in another block (temporary block). In addition, the controller 160 also creates a temporary block table in the random access memory 166 to record the correspondence between the physical address of the page of the temporary block and the logical address of the page of the data. It is worth noting that the temporary block table records information about all pages in the temporary block. In other words, all page address correspondences in the temporary block are recorded in the temporary block table.

在本實施例中,快閃記憶體180具有一暫時區塊以及一目前區塊,其中暫時區塊是用以儲存系統資料,目前區塊是用以儲存系統資料以外的資料。換言之,暫時區塊中之每一頁面中的使用者資料空間係用以儲存長度小於一既定長度之系統資料,除了系統資料外之其他資料皆係寫入目前區塊中的使用者資料空間。值得注意的是,系統資料指的是主機120或者資料儲存裝置140為了操作上的需求而寫入快閃記憶體180之資料,並且系統資料也屬於使用者資料的一種。在一實施例中,系統資料皆小於既定長度。舉例而言,在一實施例中,系統資料的長度皆小於12K位元組,但本發明不限於此。在其他實施例中,既定長度亦可為9K位元組、10K位元組、11K位元 組、13K位元組、14K位元組等等。值得注意的是,在本實施例中,系統資料的長度皆小於一個頁面中使用者資料空間的長度。在一實施例中,每個頁面P0~PN中之使用者資料空間DDA0~DDAN的大小為16K位元組,但本發明不限於此。另外,控制器160可根據資料的長度以及資料所相應之邏輯位址來判斷所需寫入之資料是否屬於系統資料。 In this embodiment, the flash memory 180 has a temporary block and a current block, wherein the temporary block is used to store system data, and the current block is used to store data other than system data. In other words, the user data space in each page in the temporary block is used to store system data whose length is less than a predetermined length, and other data except the system data is written into the user data space in the current block. It should be noted that the system data refers to the data written by the host 120 or the data storage device 140 to the flash memory 180 for operational requirements, and the system data also belongs to the user data. In one embodiment, the system data is less than a predetermined length. For example, in an embodiment, the length of the system data is less than 12K bytes, but the invention is not limited thereto. In other embodiments, the predetermined length may also be 9K bytes, 10K bytes, and 11K bits. Group, 13K bytes, 14K bytes, and so on. It should be noted that in this embodiment, the length of the system data is less than the length of the user data space in one page. In an embodiment, the size of the user data spaces DDA0~DDAN in each page P0~PN is 16K bytes, but the invention is not limited thereto. In addition, the controller 160 can determine whether the data to be written belongs to the system data according to the length of the data and the logical address corresponding to the data.

在某些實施例中,目前區塊以及暫時區塊中之資料會具有重複之邏輯位址。舉例而言,當暫時區塊塊被填滿時,控制器160會將暫時區塊中之資料移到目前區塊中。換言之,控制器160會將暫時區塊中之資料無效,並且把資料寫入目前區塊中。值得注意的是,在一實施例中,控制器160是將暫時區塊中之冷資料搬移到目前區塊中,其中冷資料為暫時區塊中較少(或者最少)被讀取或者更新的資料。在控制器160將冷資料寫入目前區塊之一頁面後,控制器160接著修改在隨機存取記憶體166中之目前的暫時區塊表,以解除原儲存冷資料之頁面與邏輯位址的映射關係。換言之,控制器160會將暫時區塊中之冷資料無效掉,並且把冷資料寫入目前區塊中,其中目前區塊中之冷資料為有效資料(最新的資料)。然而,雖然邏輯位址與原儲存冷資料之頁面的映射關係在暫時區塊表中被抹除,但冷資料以及其所相應之邏輯位址還是儲存在暫時區塊之原頁面中。另外,冷資料以及其所相應之邏輯位址也同時儲存在目前區塊之一頁面中。換言之,控制器160需要藉由隨機存取記憶體166中之目前的暫時區塊表,才能判斷目前區塊以及暫時區塊中之資料何者為有效資料。在另一實施例中,當主機 120之寫入命令指示之資料的邏輯位址與暫時區塊中任一頁面所儲存之資料的邏輯位址相同,並且寫入命令所指示之資料並非系統資料時,控制器160會將資料寫入目前區塊後,再將暫時區塊中之資料無效。詳細而言,在控制器160將資料寫入目前區塊之一頁面後,控制器160接著修改在隨機存取記憶體166中之目前的暫時區塊表,以解除原儲存資料之頁面與重複之邏輯位址的映射關係,使得相應於該邏輯位址之頁面僅有最新寫入目前區塊之資料為有效資料。同樣地,雖然邏輯位址與原儲存被無效之資料之頁面的映射關係在暫時區塊表中被抹除,但被無效之資料以及其所相應之邏輯位址還是儲存在暫時區塊之原頁面中。另外,新的資料以及其所相應之邏輯位址也同時儲存在目前區塊之一頁面中。因此,控制器160也是需要藉由隨機存取記憶體166中之目前的暫時區塊表,才能判斷目前區塊以及暫時區塊中之資料何者為有效資料。 In some embodiments, the current block and the data in the temporary block will have duplicate logical addresses. For example, when the temporary block is filled, the controller 160 moves the data in the temporary block to the current block. In other words, the controller 160 invalidates the data in the temporary block and writes the data into the current block. It should be noted that, in an embodiment, the controller 160 moves the cold data in the temporary block to the current block, wherein the cold data is less (or least) read or updated in the temporary block. data. After the controller 160 writes the cold data to one of the pages of the current block, the controller 160 then modifies the current temporary block table in the random access memory 166 to release the page and logical address of the original stored cold data. Mapping relationship. In other words, the controller 160 invalidates the cold data in the temporary block and writes the cold data into the current block, wherein the cold data in the current block is valid data (latest data). However, although the mapping relationship between the logical address and the page storing the cold data is erased in the temporary block table, the cold data and its corresponding logical address are stored in the original page of the temporary block. In addition, the cold data and its corresponding logical address are also stored in one of the current blocks. In other words, the controller 160 needs to determine the data in the current block and the temporary block as valid data by randomly accessing the current temporary block table in the memory 166. In another embodiment, when the host The logical address of the data indicated by the write command of 120 is the same as the logical address of the data stored in any page in the temporary block, and when the data indicated by the write command is not the system data, the controller 160 writes the data. After entering the current block, the data in the temporary block will be invalid. In detail, after the controller 160 writes the data to one of the pages of the current block, the controller 160 then modifies the current temporary block table in the random access memory 166 to release the page and the duplicate of the original stored data. The logical address mapping relationship is such that the page corresponding to the logical address only has the latest data written in the current block as valid data. Similarly, although the mapping relationship between the logical address and the page of the original stored data is invalidated in the temporary block table, the invalidated data and its corresponding logical address are still stored in the temporary block. In the page. In addition, the new data and its corresponding logical address are also stored in one of the current blocks. Therefore, the controller 160 also needs to determine whether the data in the current block and the temporary block is valid data by using the current temporary block table in the random access memory 166.

當發生一斷電事件時,隨機存取記憶體166中所儲存之實體轉邏輯對應表及暫時區塊表會因為電力消失而丟失。因此當發生一斷電事件並且資料儲存裝置140恢復電力後,控制器160需要依序讀取暫時區塊以及目前區塊中之頁面以重新在隨機存取記憶體166中建立一實體轉邏輯對應表以及及暫時區塊表。然而,上述方法需要很長的時間一一對所有暫時區塊以及目前區塊中之頁面進行讀取,並且需要特定的演算法來辨別資料的寫入順序或者新舊。 When a power down event occurs, the entity-to-logical correspondence table and the temporary block table stored in the random access memory 166 are lost due to power loss. Therefore, after a power-off event occurs and the data storage device 140 resumes power, the controller 160 needs to sequentially read the temporary block and the page in the current block to re-establish a physical-to-logical correspondence in the random access memory 166. Table and temporary block table. However, the above method requires a long time to read a pair of all temporary blocks and pages in the current block, and requires a specific algorithm to discriminate the writing order of the data or the old and new.

有鑑於此,在一實施例中,由於系統資料的長度會小於使用者資料空間DDA1~DDAN,故控制器160在對暫時區 塊中之頁面進行寫入的同時,會將目前的暫時區塊表也一起寫入該頁面中,以備份目前的暫時區塊表。另外,當控制器160將相應於一第一邏輯位址之一第一資料寫入目前區塊後,會判斷暫時區塊中是否具有同樣相應於第一邏輯位址之一第二資料。當暫時區塊中具有同樣相應於第一邏輯位址之第二資料時,控制器160也會將最新的暫時區塊表寫入暫時區塊中。詳細而言,在一實施例中,在將第一資料寫入目前區塊後,控制器160在儲存於一隨機存取記憶體166中之目前暫時區塊表中,解除第二資料與邏輯位址的關係,以更新目前暫時區塊表。接著,控制器160係將更新後之目前暫時區塊表寫入暫時區塊之一頁面中之一特定頁面。值得注意的是,被寫入第一暫時區塊表之特定頁為暫時區塊中空白頁面中之任一者,並且特定頁面不會被寫入其他使用者資料。舉例而言,特定頁面為暫時區塊中最後一個被寫入之頁面的下一個頁面。另外,如上所述,第一資料可能為為一主機120之一寫入命令所指示的資料,或者第一資料為暫時區塊中之冷資料。 In view of this, in an embodiment, since the length of the system data is smaller than the user data spaces DDA1 D DDAN, the controller 160 is in the temporary area. When the page in the block is written, the current temporary block table is also written into the page to back up the current temporary block table. In addition, when the controller 160 writes the first data corresponding to one of the first logical addresses to the current block, it is determined whether the temporary block has the second data corresponding to one of the first logical addresses. When there is a second material in the temporary block that also corresponds to the first logical address, the controller 160 also writes the latest temporary block table into the temporary block. In detail, in an embodiment, after the first data is written into the current block, the controller 160 releases the second data and logic in the current temporary block table stored in a random access memory 166. The relationship of the addresses to update the current temporary block table. Next, the controller 160 writes the updated current temporary block table to one of the specific pages in one of the temporary blocks. It is worth noting that the specific page written to the first temporary block table is any one of the blank pages in the temporary block, and the specific page is not written to other user data. For example, a particular page is the next page of the last page written in the temporary block. In addition, as described above, the first data may be the data indicated by the write command for one of the hosts 120, or the first data is the cold data in the temporary block.

因此,當資料儲存裝置140自斷電事件回復時,控制器160可直接讀取在斷電事件發生前暫時區塊中最後一個被寫入的頁面,即可獲得最新的暫時區塊表,並且藉由最新的暫時區塊表來判斷暫時區塊與目前區塊中具有相同邏輯位址之資料何者為有效資料。 Therefore, when the data storage device 140 recovers from the power-off event, the controller 160 can directly read the last page written in the temporary block before the power-off event occurs, and obtain the latest temporary block table, and The latest temporary block table is used to determine which data has the same logical address in the temporary block and the current block as valid data.

詳細而言,當該資料儲存裝置140自一斷電事件回復時,控制器160執行一尋找程序以獲得暫時區塊中的第X個頁面,其中第X個頁面是暫時區塊中在斷電事件前最後一個被寫 入之頁面,並且X為一正整數。接著,控制器160將第X個頁面中所儲存之一第二暫時區塊表載入隨機存取記憶體166中,以作為目前之暫時區塊表。換言之,控制器160可根據暫時區塊中之第X個頁面所儲存之第二暫時區塊表,判斷暫時區塊與目前區塊中具有相同邏輯位址之資料何者為有效資料。 In detail, when the data storage device 140 replies from a power-off event, the controller 160 executes a seek program to obtain the X-th page in the temporary block, wherein the X-th page is in the temporary block and is powered off. The last one before the event was written Enter the page, and X is a positive integer. Next, the controller 160 loads one of the second temporary block tables stored in the Xth page into the random access memory 166 as the current temporary block table. In other words, the controller 160 may determine, according to the second temporary block table stored in the Xth page in the temporary block, which of the data having the same logical address in the current block and the current block is valid data.

在一實施例之尋找程序中,控制器160係自暫時區塊中之第1個頁面開始,依照第一順序D1讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。在讀取到不具有有效資料的備用空間後,控制器160更自所讀取到不具有有效資料之備用空間所相應之頁面的下一個頁面開始,依照一第二順序D2逐一讀取暫時區塊中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止,其中控制器160依照第二順序D2讀取到具有有效資料之備用空間所屬之頁面為一第一空白頁面,並且第二順序D2與第一順序D1相反。在獲得了第一空白頁面後,控制器160更讀取第一空白頁面中之使用者資料空間,並且判斷第一空白頁面中之使用者資料空間是否具有有效資料,以確認第一空白頁面為暫時區塊中第一個不具有使用者資料的頁面。當第一空白頁面中之使用者資料空間具有有效資料時,控制器160更自第一空白頁面開始依照第一順序D1逐一讀取暫時區塊中之頁面的使用者資料空間,直到所讀取之使用者資料空間不具有有效資料為止,其中所讀取到使用者資料空間不具有有效資料的頁面取代原第一空白頁面成為新的第一空白頁面。最後,控制器160自第一空白頁面的上一個頁面或者新的第一空白頁面的上一個頁 面開始,依照第二順序D2逐一讀取暫時區塊中之頁面之使用者資料空間,並且判斷所讀取之頁面之使用者空間是否具有有效資料,以獲得暫時區塊中最後一個寫入之頁面,其中反序所讀取具有有效資料之使用者資料空間所相應之頁面,為暫時區塊中最後一個具有有效資料之頁面(第X個頁面)。 In a search procedure of an embodiment, the controller 160 starts from the first page in the temporary block and reads the spare space of a predetermined number of pages in the temporary block according to the first sequence D1 until the read is performed. The spare space does not have valid data. After reading the spare space that does not have valid data, the controller 160 starts from the next page of the page corresponding to the spare space that does not have the valid data, and reads the temporary area one by one according to a second sequence D2. The spare space of the page in the block until the read spare space has valid data, wherein the controller 160 reads the page to which the spare space having the valid data belongs according to the second sequence D2 as a first blank page, and The second order D2 is opposite to the first order D1. After obtaining the first blank page, the controller 160 further reads the user data space in the first blank page, and determines whether the user data space in the first blank page has valid data to confirm that the first blank page is The first page in the temporary block that does not have user data. When the user data space in the first blank page has valid data, the controller 160 further reads the user data space of the page in the temporary block one by one according to the first sequence D1 from the first blank page until the read The user data space does not have valid data, and the page that reads the user data space without valid data replaces the original first blank page to become the new first blank page. Finally, the controller 160 is from the previous page of the first blank page or the previous page of the new first blank page. Starting from the beginning, the user data space of the page in the temporary block is read one by one according to the second sequence D2, and it is determined whether the user space of the read page has valid data to obtain the last write in the temporary block. The page, in which the page corresponding to the user data space with valid data is read in reverse order, is the last page in the temporary block with valid data (the Xth page).

第3圖為本發明所提供之一暫時區塊之一種實施例的示意圖。在本實施例中,暫時區塊B2具有依照第一順序D1排列之17個頁面P1~P17,其中第3圖所示為斷電事件發生後,暫時區塊B2中頁面P1~P17的狀態。詳細而言,暫時區塊B2中之第1~12個頁面P1~P12中之使用者資料空間DAA1~DAA12皆已被寫入有效資料(使用者資料DA1~DA12以及暫時區塊表TP1~TP12),並且第1~12個頁面P1~P12中之備份空間SP1~SP12也皆已被寫入有效資料(備份資料SP1~SP12)。 Figure 3 is a schematic illustration of one embodiment of a temporary block provided by the present invention. In the present embodiment, the temporary block B2 has 17 pages P1 to P17 arranged in the first order D1, and the third figure shows the state of the pages P1 to P17 in the temporary block B2 after the power-off event occurs. In detail, the user data spaces DAA1 to DAA12 in the first to the twelfth pages P1 to P12 in the temporary block B2 have been written into the valid data (user data DA1 to DA12 and temporary block tables TP1 to TP12). ), and the backup spaces SP1 to SP12 in the first to the twelfth pages P1 to P12 have also been written into the valid data (backup data SP1 to SP12).

在尋找程序中,控制器160先自暫時區塊B2中之第1個頁面P1開始,依照第一順序D1讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。在本實施例中,既定數量為3,但本發明不限於此。換言之,控制器160先讀取暫時區塊B2中之第1個頁面P1的備用空間SPA1。由於備用空間SPA1已具有有效資料SP1,因此控制器160繼續依照第一順序D1的方向,讀取與第1個頁面P1間隔3個頁面之第5個頁面P5的備用空間SPA5。由於備用空間SPA5已具有有效資料SP5,因此控制器160繼續依照第一順序D1的方向,讀取與第5個頁面P5間隔3個頁面之第14個頁面P14的備用空間SPA14。由於頁面P14的備用空間SPA14不具有有效資料, 故控制器160停止依照第一順序D1讀取暫時區塊B2中間隔一既定數量之頁面的備用空間。在獲得了不具有有效資料之備用空間SPA14的頁面P14後,控制器160更自第14個頁面P14開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止。換言之,控制器160接著依照第二順序D2的方向,讀取在第14個頁面P14之前的第13個頁面P13的備份空間SPA13。由於備用空間SPA13不具有有效資料,因此控制器160繼續依照第二順序D2的方向,讀取在第13個頁面P13之前的第12個頁面P12的備份空間SPA12。由於備份空間SPA12具有有效資料SP12,因此控制器160停止依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間。值得注意的是,到目前為止,控制器160假設第12個頁面P12為暫時區塊B2中第一個空白之頁面(第一空白頁面)。接著,控制器160更讀取第12個頁面P12(第一空白頁面)中之使用者資料空間DDA12,並且判斷第12個頁面P12中之使用者資料空間DDA12是否具有有效資料,以確認第12個頁面P12為暫時區塊B2中第一個不具有使用者資料的頁面。在本實施例中,由於第12個頁面P12之使用者資料空間DDA12具有有效資料DA12以及TP12。因此,控制器160判斷第12個頁面P12不是暫時區塊B2中第一個不具有使用者資料的頁面。接著,控制器160更自第12個頁面P12的下一個頁面開始依照第一順序D1逐一讀取暫時區塊B2中之頁面的使用者資料空間,直到所讀取之使用者資料空間不具有有效資料為止。換言之,控制器160首先讀取第13個頁面P13的使用者資料空間DDA13。由於使用者資料 空間DDA13不具有有效資料,因此控制器160將第13個頁面P13取代原第一空白頁面(第12頁面P12)成為新的第一空白頁面。換言之,控制器160確認第13個頁面P13為暫時區塊B2中第一個空白之頁面。最後,控制器160開始尋找暫時區塊B2中最後一個被寫入之頁面。換言之,控制器160自第13個頁面P13之上一個頁面(第12個頁面P12)開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之使用者資料空間。在本實施例中,第12個頁面P12之使用者資料空間DAA12具有有效資料DA12以及TP12。因此,控制器160獲得暫時區塊B2中最後一個被寫入之頁面為第12個頁面P12,並且第12個頁面P12為第X個頁面。 In the search procedure, the controller 160 first reads from the first page P1 in the temporary block B2, and reads the spare space of a predetermined number of pages in the temporary block according to the first sequence D1 until the read is read. Space does not have valid data. In the present embodiment, the predetermined number is 3, but the present invention is not limited thereto. In other words, the controller 160 first reads the spare space SPA1 of the first page P1 in the temporary block B2. Since the spare space SPA1 already has the valid data SP1, the controller 160 continues to read the spare space SPA5 of the fifth page P5 of the three pages spaced from the first page P1 in accordance with the direction of the first sequence D1. Since the spare space SPA5 already has the valid data SP5, the controller 160 continues to read the spare space SPA14 of the 14th page P14 of the 3 pages spaced from the fifth page P5 in accordance with the direction of the first sequence D1. Since the spare space SPA14 of page P14 does not have valid data, Therefore, the controller 160 stops reading the spare space of the predetermined number of pages in the temporary block B2 in accordance with the first sequence D1. After obtaining the page P14 of the spare space SPA14 without valid data, the controller 160 further reads from the 14th page P14, and reads the spare space of the page in the temporary block B2 one by one according to the second sequence D2 until the read Take the spare space with valid data. In other words, the controller 160 then reads the backup space SPA13 of the thirteenth page P13 before the 14th page P14 in accordance with the direction of the second sequence D2. Since the spare space SPA13 does not have valid material, the controller 160 continues to read the backup space SPA12 of the 12th page P12 before the 13th page P13 in the direction of the second sequence D2. Since the backup space SPA12 has the valid data SP12, the controller 160 stops reading the spare space of the page in the temporary block B2 one by one in accordance with the second order D2. It is worth noting that, so far, the controller 160 assumes that the 12th page P12 is the first blank page (first blank page) in the temporary block B2. Next, the controller 160 further reads the user data space DDA12 in the 12th page P12 (first blank page), and determines whether the user data space DDA12 in the 12th page P12 has valid data to confirm the 12th. The page P12 is the first page in the temporary block B2 that does not have user data. In this embodiment, since the user data space DDA12 of the 12th page P12 has the valid data DA12 and TP12. Therefore, the controller 160 determines that the 12th page P12 is not the first page in the temporary block B2 that does not have user data. Then, the controller 160 reads the user data space of the page in the temporary block B2 one by one according to the first sequence D1 from the next page of the 12th page P12 until the read user data space is not valid. Information up to now. In other words, the controller 160 first reads the user profile space DDA13 of the thirteenth page P13. User data The space DDA 13 does not have valid material, so the controller 160 replaces the original first blank page (page 12 P12) with the 13th page P13 as the new first blank page. In other words, the controller 160 confirms that the thirteenth page P13 is the page of the first blank in the temporary block B2. Finally, the controller 160 begins looking for the last page written in the temporary block B2. In other words, the controller 160 starts from one page (the 12th page P12) on the 13th page P13, and reads the user data space of the page in the temporary block B2 one by one according to the second sequence D2. In this embodiment, the user profile space DAA12 of the 12th page P12 has valid data DA12 and TP12. Therefore, the controller 160 obtains that the last page written in the temporary block B2 is the 12th page P12, and the 12th page P12 is the Xth page.

當控制器160判斷第12個頁面P12可被成功讀取時,控制器160將第12個頁面P12中所儲存之暫時區塊表TP12載入隨機存取記憶體166中,以作為目前之暫時區塊表。其中,當控制器160使用了兩個以上之讀取電壓才成功讀取第12個頁面P12時,控制器160將資料DA12以及TP12重複再寫入第12個頁面P12中,以穩定第12個頁面P12中之資料。另外,在暫時區塊表TP12載入隨機存取記憶體166以做為目前暫時區塊表後,控制器160更用以根據目前暫時區塊之狀態更新目前暫時區塊表,並且將更新後之目前暫時區塊表寫入暫時區塊B2中的第13個頁面P13。 When the controller 160 determines that the 12th page P12 can be successfully read, the controller 160 loads the temporary block table TP12 stored in the 12th page P12 into the random access memory 166 as the current temporary. Block table. When the controller 160 successfully reads the 12th page P12 by using more than two read voltages, the controller 160 repeatedly writes the data DA12 and TP12 into the 12th page P12 to stabilize the 12th. The information in page P12. In addition, after the temporary block table TP12 is loaded into the random access memory 166 as the current temporary block table, the controller 160 is further configured to update the current temporary block table according to the current temporary block status, and the updated block table will be updated. The current temporary block table is written to the thirteenth page P13 in the temporary block B2.

當控制器160判斷第12個頁面P12無法被成功讀取時,控制器160則讀取暫時區塊B2中的第11個頁面P11,並且將第11個頁面P11中所儲存之暫時區塊表TP11載入隨機存取記憶體166中,以作為目前的暫時區塊表。另外,控制器160更用以 選擇一個新的區塊(例如,區塊B5)取代原本之暫時區塊B2。詳細而言,當第12個頁面P12無法被成功讀取時,控制器160更捨棄暫時區塊B2,選取區塊B5作為一新的暫時區塊,並且將暫時區塊B2之第1~11個頁面P1~P11中所儲存之資料DA1~DA11以及TP1~TP11寫入暫時區塊B5中。 When the controller 160 determines that the 12th page P12 cannot be successfully read, the controller 160 reads the 11th page P11 in the temporary block B2, and stores the temporary block table stored in the 11th page P11. The TP 11 is loaded into the random access memory 166 as the current temporary block table. In addition, the controller 160 is further used A new block (e.g., block B5) is selected to replace the original temporary block B2. In detail, when the 12th page P12 cannot be successfully read, the controller 160 discards the temporary block B2, selects the block B5 as a new temporary block, and sets the first block 11 of the temporary block B2. The data DA1~DA11 and TP1~TP11 stored in the pages P1~P11 are written in the temporary block B5.

第4圖為本發明所提供之一暫時區塊之一種實施例的示意圖。在本實施例中,暫時區塊B2具有依照第一順序D1排列之17個頁面P1~P17,其中第4圖所示為斷電事件發生後,暫時區塊B2中頁面P1~P17的狀態。詳細而言,暫時區塊B2中之第1~11個頁面P1~P11中之使用者資料空間DAA1~DAA11皆已被寫入有效資料(使用者資料DA1~DA11以及暫時區塊表TP1~TP11),並且第1~12個頁面P1~P12中之備份空間SP1~SP12也皆已被寫入有效資料(備份資料SP1~SP12)。 Figure 4 is a schematic illustration of one embodiment of a temporary block provided by the present invention. In the present embodiment, the temporary block B2 has 17 pages P1 to P17 arranged in the first order D1, and FIG. 4 shows the state of the pages P1 to P17 in the temporary block B2 after the power-off event occurs. In detail, the user data spaces DAA1 to DAA11 in the first to eleventh pages P1 to P11 in the temporary block B2 have been written into the valid data (user data DA1 to DA11 and temporary block tables TP1 to TP11). ), and the backup spaces SP1 to SP12 in the first to the twelfth pages P1 to P12 have also been written into the valid data (backup data SP1 to SP12).

在尋找程序中,控制器160先自暫時區塊B2中之第1個頁面P1開始,依照第一順序D1讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。在本實施例中,既定數量為3,但本發明不限於此。換言之,控制器160先讀取暫時區塊B2中之第1個頁面P1的備用空間SPA1。由於備用空間SPA1已具有有效資料SP1,因此控制器160繼續依照第一順序D1的方向,讀取與第1個頁面P1間隔3個頁面之第5個頁面P5的備用空間SPA5。由於備用空間SPA5已具有有效資料SP5,因此控制器160繼續依照第一順序D1的方向,讀取與第5個頁面P5間隔3個頁面之第9個頁面P9的備用空間SPA9。由於備用空間SPA9已具有有效資料SP9,因此控制器 160繼續依照第一順序D1的方向,讀取與第9個頁面P9間隔3個頁面之第14個頁面P14的備用空間SPA14。由於頁面P14的備用空間SPA14不具有有效資料,故控制器160停止依照第一順序D1讀取暫時區塊B2中間隔一既定數量之頁面的備用空間。在獲得了不具有有效資料之備用空間SPA14的頁面P14後,控制器160更自第14個頁面P14開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止。換言之,控制器160接著依照第二順序D2的方向,讀取在第14個頁面P14之前的第13個頁面P13的備份空間SPA13。由於備用空間SPA13不具有有效資料,因此控制器160繼續依照第二順序D2的方向,讀取在第13個頁面P13之前的第12個頁面P12的備份空間SPA12。由於備份空間SPA12具有有效資料SP12,因此控制器160停止依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間。值得注意的是,到目前為止,控制器160假設第12個頁面P12為暫時區塊B2中第一個空白之頁面(第一空白頁面)。接著,控制器160更讀取第12個頁面P12(第一空白頁面)中之使用者資料空間DDA12,並且判斷第12個頁面P12中之使用者資料空間DDA12是否具有有效資料,以確認第12個頁面P12為暫時區塊B2中第一個不具有使用者資料的頁面。在本實施例中,由於第12個頁面P12之使用者資料空間DDA12不具有有效資料。因此,控制器160判斷第12個頁面P12為暫時區塊B2中第一個不具有使用者資料的頁面。最後,控制器160開始尋找暫時區塊B2中最後一個被寫入之頁面。換言之,控制器160自第12個頁面P12之上一個頁面(第11個頁面P11) 開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之使用者資料空間。在本實施例中,第11個頁面P11之使用者資料空間DAA11具有有效資料DA11以及TP11。因此,控制器160獲得暫時區塊B2中最後一個被寫入之頁面為第11個頁面P11,並且第11個頁面P11為第X個頁面。 In the search procedure, the controller 160 first reads from the first page P1 in the temporary block B2, and reads the spare space of a predetermined number of pages in the temporary block according to the first sequence D1 until the read is read. Space does not have valid data. In the present embodiment, the predetermined number is 3, but the present invention is not limited thereto. In other words, the controller 160 first reads the spare space SPA1 of the first page P1 in the temporary block B2. Since the spare space SPA1 already has the valid data SP1, the controller 160 continues to read the spare space SPA5 of the fifth page P5 of the three pages spaced from the first page P1 in accordance with the direction of the first sequence D1. Since the spare space SPA5 already has the valid data SP5, the controller 160 continues to read the spare space SPA9 of the ninth page P9 of the three pages spaced from the fifth page P5 in accordance with the direction of the first sequence D1. Since the spare space SPA9 already has a valid data SP9, the controller 160 continues to read the spare space SPA14 of the 14th page P14 of the 3 pages spaced from the ninth page P9 in accordance with the direction of the first sequence D1. Since the spare space SPA14 of the page P14 does not have valid data, the controller 160 stops reading the spare space of the predetermined number of pages in the temporary block B2 in accordance with the first order D1. After obtaining the page P14 of the spare space SPA14 without valid data, the controller 160 further reads from the 14th page P14, and reads the spare space of the page in the temporary block B2 one by one according to the second sequence D2 until the read Take the spare space with valid data. In other words, the controller 160 then reads the backup space SPA13 of the thirteenth page P13 before the 14th page P14 in accordance with the direction of the second sequence D2. Since the spare space SPA13 does not have valid material, the controller 160 continues to read the backup space SPA12 of the 12th page P12 before the 13th page P13 in the direction of the second sequence D2. Since the backup space SPA12 has the valid data SP12, the controller 160 stops reading the spare space of the page in the temporary block B2 one by one in accordance with the second order D2. It is worth noting that, so far, the controller 160 assumes that the 12th page P12 is the first blank page (first blank page) in the temporary block B2. Next, the controller 160 further reads the user data space DDA12 in the 12th page P12 (first blank page), and determines whether the user data space DDA12 in the 12th page P12 has valid data to confirm the 12th. The page P12 is the first page in the temporary block B2 that does not have user data. In this embodiment, since the user data space DDA12 of the 12th page P12 does not have valid data. Therefore, the controller 160 determines that the 12th page P12 is the first page in the temporary block B2 that does not have user data. Finally, the controller 160 begins looking for the last page written in the temporary block B2. In other words, the controller 160 is one page above the 12th page P12 (11th page P11) Initially, the user data space of the page in the temporary block B2 is read one by one according to the second sequence D2. In this embodiment, the user profile space DAA11 of the eleventh page P11 has valid data DA11 and TP11. Therefore, the controller 160 obtains that the last page written in the temporary block B2 is the eleventh page P11, and the eleventh page P11 is the Xth page.

當控制器160判斷第11個頁面P11可被成功讀取時,控制器160將第11個頁面P11中所儲存之暫時區塊表TP11載入隨機存取記憶體166中,以作為目前之暫時區塊表。其中,當控制器160使用了兩個以上之讀取電壓才成功讀取第11個頁面P11時,控制器160將資料DA11以及TP11重複再寫入第11個頁面P11中,以穩定第11個頁面P11中之資料。另外,在暫時區塊表TP11載入隨機存取記憶體166以做為目前暫時區塊表後,控制器160更用以根據目前暫時區塊之狀態更新目前暫時區塊表,並且將更新後之目前暫時區塊表寫入暫時區塊B2中的第12個頁面P12之使用者資料空間DAA12中,並且更新第12個頁面P12之備份資料SP12。 When the controller 160 determines that the eleventh page P11 can be successfully read, the controller 160 loads the temporary block table TP11 stored in the eleventh page P11 into the random access memory 166 as the current temporary. Block table. When the controller 160 successfully reads the eleventh page P11 by using more than two read voltages, the controller 160 repeatedly writes the data DA11 and TP11 into the eleventh page P11 to stabilize the eleventh. The information in page P11. In addition, after the temporary block table TP11 is loaded into the random access memory 166 as the current temporary block table, the controller 160 is further configured to update the current temporary block table according to the current temporary block status, and after updating The current temporary block table is written in the user profile space DAA12 of the 12th page P12 in the temporary block B2, and the backup data SP12 of the 12th page P12 is updated.

當控制器160判斷第11個頁面P11無法被成功讀取時,控制器160則讀取暫時區塊B2中的第10個頁面P10,並且將第10個頁面P10中所儲存之暫時區塊表TP10載入隨機存取記憶體166中,以作為目前的暫時區塊表。另外,控制器160更用以選擇一個新的區塊(例如,區塊B5)取代原本之暫時區塊B2。詳細而言,當第11個頁面P11無法被成功讀取時,控制器160更捨棄暫時區塊B2,選取區塊B5作為一新的暫時區塊,並且將暫時區塊B2之第1~10個頁面P1~P10中所儲存之資料DA1~DA10以 及TP1~TP10寫入暫時區塊B5中。 When the controller 160 determines that the eleventh page P11 cannot be successfully read, the controller 160 reads the tenth page P10 in the temporary block B2, and stores the temporary block table stored in the tenth page P10. The TP 10 is loaded into the random access memory 166 as the current temporary block table. In addition, the controller 160 is further configured to select a new block (for example, block B5) instead of the original temporary block B2. In detail, when the 11th page P11 cannot be successfully read, the controller 160 discards the temporary block B2, selects the block B5 as a new temporary block, and sets the first block 10 of the temporary block B2. The data DA1~DA10 stored in pages P1~P10 are And TP1~TP10 are written in the temporary block B5.

第5圖為本發明所提供之一暫時區塊之一種實施例的示意圖。在本實施例中,暫時區塊B2具有依照第一順序D1排列之17個頁面P1~P17,其中第5圖所示為斷電事件發生後,暫時區塊B2中頁面P1~P17的狀態。詳細而言,暫時區塊B2中之第1~12個頁面P1~P12中之使用者資料空間DAA1~DAA12皆已被寫入有效資料(使用者資料DA1~DA12以及暫時區塊表TP1~TP12),並且第1~11個頁面P1~P11中之備份空間SP1~SP11也皆已被寫入有效資料(備份資料SP1~SP11)。 Figure 5 is a schematic diagram of an embodiment of a temporary block provided by the present invention. In the present embodiment, the temporary block B2 has 17 pages P1 to P17 arranged in the first order D1, and FIG. 5 shows the state of the pages P1 to P17 in the temporary block B2 after the power-off event occurs. In detail, the user data spaces DAA1 to DAA12 in the first to the twelfth pages P1 to P12 in the temporary block B2 have been written into the valid data (user data DA1 to DA12 and temporary block tables TP1 to TP12). ), and the backup spaces SP1 to SP11 in the first to eleventh pages P1 to P11 have also been written into the valid data (backup data SP1 to SP11).

在尋找程序中,控制器160先自暫時區塊B2中之第1個頁面P1開始,依照第一順序D1讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。在本實施例中,既定數量為3,但本發明不限於此。換言之,控制器160先讀取暫時區塊B2中之第1個頁面P1的備用空間SPA1。由於備用空間SPA1已具有有效資料SP1,因此控制器160繼續依照第一順序D1的方向,讀取與第1個頁面P1間隔3個頁面之第5個頁面P5的備用空間SPA5。由於備用空間SPA5已具有有效資料SP5,因此控制器160繼續依照第一順序D1的方向,讀取與第5個頁面P5間隔3個頁面之第9個頁面P9的備用空間SPA9。由於備用空間SPA9已具有有效資料SP9,因此控制器160繼續依照第一順序D1的方向,讀取與第9個頁面P9間隔3個頁面之第14個頁面P14的備用空間SPA14。由於頁面P14的備用空間SPA14不具有有效資料,故控制器160停止依照第一順序D1讀取暫時區塊B2中間隔一既定數量之頁面的備用空間。在 獲得了不具有有效資料之備用空間SPA14的頁面P14後,控制器160更自第14個頁面P14開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止。換言之,控制器160接著依照第二順序D2的方向,讀取在第14個頁面P14之前的第13個頁面P13的備份空間SPA13。由於備用空間SPA13不具有有效資料,因此控制器160繼續依照第二順序D2的方向,讀取在第13個頁面P13之前的第12個頁面P12的備份空間SPA12。由於備份空間SPA12也不具有有效資料SP12,因此控制器160繼續依照第二順序D2的方向,讀取在第12個頁面P12之前的第11個頁面P11的備份空間SPA11。由於備份空間SPA11具有有效資料SP11,因此控制器160停止依照第二順序D2逐一讀取暫時區塊B2中之頁面之備用空間。值得注意的是,到目前為止,控制器160假設第11個頁面P11為暫時區塊B2中第一個空白之頁面(第一空白頁面)。接著,控制器160更讀取第11個頁面P11(第一空白頁面)中之使用者資料空間DDA11,並且判斷第11個頁面P11中之使用者資料空間DDA11是否具有有效資料,以確認第11個頁面P11為暫時區塊B1中第一個不具有使用者資料的頁面。在本實施例中,由於第11個頁面P11之使用者資料空間DDA11具有有效資料DA11以及TP11。因此,控制器160判斷第11個頁面P11不是暫時區塊B2中第一個不具有使用者資料的頁面。接著,控制器160更自第11個頁面P11的下一個頁面開始依照第一順序D1逐一讀取暫時區塊B2中之頁面的使用者資料空間,直到所讀取之使用者資料空間不具有有效資料為止。換言之,控制器160首先讀 取第12個頁面P12的使用者資料空間DDA12。由於使用者資料空間DDA12具有有效資料DA12以及TP12,因此控制器160繼續讀取第13個頁面P13的使用者資料空間DDA13,由於使用者資料空間DDA13不具有有效資料,因此控制器160將第13個頁面P13取代原第一空白頁面(第11頁面P11)成為新的第一空白頁面。換言之,控制器160確認第13個頁面P13為暫時區塊B2中第一個空白之頁面。最後,控制器160開始尋找暫時區塊B2中最後一個被寫入之頁面。換言之,控制器160自第13個頁面P13之上一個頁面(第12個頁面P12)開始,依照第二順序D2逐一讀取暫時區塊B2中之頁面之使用者資料空間。在本實施例中,第12個頁面P12之使用者資料空間DAA12具有有效資料DA12以及TP12。因此,控制器160獲得暫時區塊B2中最後一個被寫入之頁面為第12個頁面P12,並且第12個頁面P12為第X個頁面。 In the search procedure, the controller 160 first reads from the first page P1 in the temporary block B2, and reads the spare space of a predetermined number of pages in the temporary block according to the first sequence D1 until the read is read. Space does not have valid data. In the present embodiment, the predetermined number is 3, but the present invention is not limited thereto. In other words, the controller 160 first reads the spare space SPA1 of the first page P1 in the temporary block B2. Since the spare space SPA1 already has the valid data SP1, the controller 160 continues to read the spare space SPA5 of the fifth page P5 of the three pages spaced from the first page P1 in accordance with the direction of the first sequence D1. Since the spare space SPA5 already has the valid data SP5, the controller 160 continues to read the spare space SPA9 of the ninth page P9 of the three pages spaced from the fifth page P5 in accordance with the direction of the first sequence D1. Since the spare space SPA9 already has the valid data SP9, the controller 160 continues to read the spare space SPA14 of the 14th page P14 of the 3 pages spaced apart from the ninth page P9 in accordance with the direction of the first sequence D1. Since the spare space SPA14 of the page P14 does not have valid data, the controller 160 stops reading the spare space of the predetermined number of pages in the temporary block B2 in accordance with the first order D1. in After obtaining the page P14 of the spare space SPA14 without valid data, the controller 160 further reads the spare space of the page in the temporary block B2 one by one according to the second sequence D2 until the read. The spare space has valid data. In other words, the controller 160 then reads the backup space SPA13 of the thirteenth page P13 before the 14th page P14 in accordance with the direction of the second sequence D2. Since the spare space SPA13 does not have valid material, the controller 160 continues to read the backup space SPA12 of the 12th page P12 before the 13th page P13 in the direction of the second sequence D2. Since the backup space SPA12 does not have the valid data SP12, the controller 160 continues to read the backup space SPA11 of the eleventh page P11 before the twelfth page P12 in the direction of the second sequence D2. Since the backup space SPA11 has the valid data SP11, the controller 160 stops reading the spare space of the page in the temporary block B2 one by one in accordance with the second order D2. It is worth noting that, so far, the controller 160 assumes that the eleventh page P11 is the first blank page (first blank page) in the temporary block B2. Next, the controller 160 further reads the user data space DDA11 in the eleventh page P11 (first blank page), and determines whether the user data space DDA11 in the eleventh page P11 has valid data to confirm the 11th. The page P11 is the first page in the temporary block B1 that does not have user data. In the present embodiment, since the user data space DDA11 of the eleventh page P11 has valid data DA11 and TP11. Therefore, the controller 160 determines that the eleventh page P11 is not the first page in the temporary block B2 that does not have user data. Then, the controller 160 reads the user data space of the page in the temporary block B2 one by one according to the first sequence D1 from the next page of the eleventh page P11 until the read user data space does not have valid. Information up to now. In other words, the controller 160 first reads Take the user data space DDA12 of the 12th page P12. Since the user data space DDA12 has the valid data DA12 and TP12, the controller 160 continues to read the user data space DDA13 of the thirteenth page P13. Since the user data space DDA13 does not have valid data, the controller 160 will be the 13th. The page P13 replaces the original first blank page (page 11 P11) to become the new first blank page. In other words, the controller 160 confirms that the thirteenth page P13 is the page of the first blank in the temporary block B2. Finally, the controller 160 begins looking for the last page written in the temporary block B2. In other words, the controller 160 starts from one page (the 12th page P12) on the 13th page P13, and reads the user data space of the page in the temporary block B2 one by one according to the second sequence D2. In this embodiment, the user profile space DAA12 of the 12th page P12 has valid data DA12 and TP12. Therefore, the controller 160 obtains that the last page written in the temporary block B2 is the 12th page P12, and the 12th page P12 is the Xth page.

第6圖為本發明所提供之一資料維護方法之一種實施例的流程圖。資料維護方法適用於第1圖所示之資料儲存裝置140,用以將資料寫入目前區塊中。流程開始於步驟S600。 Figure 6 is a flow chart of an embodiment of a data maintenance method provided by the present invention. The data maintenance method is applied to the data storage device 140 shown in FIG. 1 for writing data into the current block. The flow begins in step S600.

在步驟S600中,控制器160將相應於一第一邏輯位址之一第一資料寫入目前區塊。 In step S600, the controller 160 writes the first data corresponding to one of the first logical addresses to the current block.

接著,在步驟S602中,控制器160判斷暫時區塊中是否具有同樣相應於第一邏輯位址之一第二資料。當暫時區塊中具有同樣相應於第一邏輯位址之第二資料時,流程進行至步驟S604;否則,流程結束於步驟S600。 Next, in step S602, the controller 160 determines whether there is a second material in the temporary block that also corresponds to one of the first logical addresses. When the temporary block has the second material corresponding to the first logical address, the flow proceeds to step S604; otherwise, the flow ends at step S600.

在步驟S604中,控制器160將最新的暫時區塊表寫入暫時區塊中。詳細而言,在一實施例中,控制器160在儲存 於一隨機存取記憶體166中之目前暫時區塊表中,解除第二資料與邏輯位址的關係,以更新目前暫時區塊表。接著,控制器160係將更新後之目前暫時區塊表寫入暫時區塊之一頁面中之一特定頁面。值得注意的是,被寫入第一暫時區塊表之特定頁為暫時區塊中空白頁面中之任一者,並且特定頁面不會被寫入其他使用者資料。舉例而言,特定頁面為暫時區塊中最後一個被寫入之頁面的下一個頁面。在一實施例中,當第一資料的邏輯位址重複出現在暫時區塊中時,第一資料可能為為一主機120之一寫入命令所指示的資料,或者第一資料為暫時區塊中之冷資料。流程結束於步驟S604。 In step S604, the controller 160 writes the latest temporary block table into the temporary block. In detail, in an embodiment, the controller 160 is storing In the current temporary block table in the random access memory 166, the relationship between the second data and the logical address is released to update the current temporary block table. Next, the controller 160 writes the updated current temporary block table to one of the specific pages in one of the temporary blocks. It is worth noting that the specific page written to the first temporary block table is any one of the blank pages in the temporary block, and the specific page is not written to other user data. For example, a particular page is the next page of the last page written in the temporary block. In an embodiment, when the logical address of the first material is repeatedly displayed in the temporary block, the first data may be the data indicated by the command written by one of the hosts 120, or the first data is a temporary block. The cold information in the middle. The flow ends in step S604.

第7圖為本發明所提供之一資料維護方法之另一種實施例的流程圖。資料維護方法適用於第1圖所示之資料儲存裝置140,用以在資料儲存裝置140發生一斷電事件並且資料儲存裝置140恢復電力後重建資料狀態。流程開始於步驟S700。 Figure 7 is a flow chart of another embodiment of a data maintenance method provided by the present invention. The data maintenance method is applicable to the data storage device 140 shown in FIG. 1 for reconstructing the data state after a power failure event occurs in the data storage device 140 and the data storage device 140 recovers power. The flow begins in step S700.

在步驟S700中,當資料儲存裝置140發生一斷電事件並且資料儲存裝置140恢復電力後,控制器160執行一尋找程序以獲得暫時區塊中的第X個頁面,其中第X個頁面是暫時區塊中在斷電事件前最後一個被寫入之頁面,並且X為一正整數。 In step S700, after the data storage device 140 generates a power-off event and the data storage device 140 resumes power, the controller 160 executes a seek program to obtain the X-th page in the temporary block, wherein the X-th page is temporary The last page written in the block before the power down event, and X is a positive integer.

接著,在步驟S702中,控制器160將第X個頁面中所儲存之一第二暫時區塊表載入隨機存取記憶體166中,以作為目前之暫時區塊表。值得注意的是,控制器160可根據暫時區塊中之第X個頁面所儲存之第二暫時區塊表,判斷暫時區塊與目前區塊中具有相同邏輯位址之資料何者為有效資料。流程結束於步驟S702。 Next, in step S702, the controller 160 loads one of the second temporary block tables stored in the Xth page into the random access memory 166 as the current temporary block table. It should be noted that the controller 160 may determine, according to the second temporary block table stored in the Xth page in the temporary block, which data has the same logical address in the current block as the valid data. The flow ends in step S702.

第8圖為本發明所提供之一尋找程序之一種實施例的流程圖。尋找程序適用於第1圖所示之資料儲存裝置140、第7圖中之步驟S700,用以在資料儲存裝置140自斷電事件回復後找到最後一個被寫入之頁面。流程開始於步驟S800。 Figure 8 is a flow diagram of one embodiment of a search procedure provided by the present invention. The search program is applied to the data storage device 140 shown in FIG. 1 and the step S700 in FIG. 7 to find the last page to be written after the data storage device 140 recovers from the power-off event. The flow begins in step S800.

在步驟S800中,控制器160係自暫時區塊中之第1個頁面開始,依照第一順序D1讀取暫時區塊中間隔一既定數量之頁面的備用空間,直到所讀取之備用空間不具有有效資料為止。 In step S800, the controller 160 starts from the first page in the temporary block, and reads the spare space of a predetermined number of pages in the temporary block according to the first sequence D1 until the read spare space is not read. Have valid data so far.

接著,在步驟S802中,控制器160自所讀取到不具有有效資料之備用空間所相應之頁面的下一個頁面開始,依照一第二順序D2逐一讀取暫時區塊中之頁面之備用空間,直到所讀取之備用空間具有有效資料為止,其中控制器160依照第二順序D2之方向讀取到具有有效資料之備用空間所屬之頁面為目前控制器160所假設之第一空白頁面,並且第二順序D2與第一順序D1相反。 Next, in step S802, the controller 160 starts from the next page of the page corresponding to the spare space that does not have the valid data, and reads the spare space of the page in the temporary block one by one according to a second sequence D2. Until the read spare space has valid data, wherein the controller 160 reads the page to which the spare space having the valid data belongs according to the direction of the second sequence D2 is the first blank page assumed by the current controller 160, and The second sequence D2 is opposite to the first sequence D1.

接著,在步驟S804中,控制器160自假設之第一空白頁面開始,依照第一順序D1逐一讀取暫時區塊中之頁面的使用者資料空間,以尋找暫時區塊中第一個不具有使用者資料的頁面。 Next, in step S804, the controller 160 starts the first blank page of the hypothesis, and reads the user data space of the page in the temporary block one by one according to the first sequence D1, so as to find that the first one of the temporary blocks does not have User profile page.

接著,控制器160自暫時區塊中第一個不具有使用者資料的頁面的上一個頁面開始,依照第二順序D2逐一讀取暫時區塊中之頁面之使用者資料空間,並且判斷所讀取之頁面之使用者空間是否具有有效資料,以獲得暫時區塊中最後一個寫入之頁面,其中反序所讀取具有有效資料之使用者資料空間所 相應之頁面,為暫時區塊中最後一個具有有效資料之頁面(第X個頁面)。 Next, the controller 160 starts from the previous page of the first page in the temporary block that does not have the user profile, and reads the user data space of the page in the temporary block one by one according to the second sequence D2, and judges that the read is performed. Whether the user space of the page has valid data to obtain the last written page in the temporary block, wherein the user data space with valid data is read in reverse order The corresponding page is the last page in the temporary block with valid data (Xth page).

本發明所提供之資料儲存裝置以及資料維護方法可獨立將系統資料儲存在暫時區塊中,並且藉由暫時區塊表區隔相同邏輯位址之資料何者為有效資料。 The data storage device and the data maintenance method provided by the invention can independently store the system data in the temporary block, and the data of the same logical address is separated by the temporary block table as the valid data.

本發明之方法,或特定型態或其部份,可以以程式碼的型態存在。程式碼可儲存於實體媒體,如軟碟、光碟片、硬碟、或是任何其他機器可讀取(如電腦可讀取)儲存媒體,亦或不限於外在形式之電腦程式產品,其中,當程式碼被機器,如電腦載入且執行時,此機器變成用以參與本發明之裝置。程式碼也可透過一些傳送媒體,如電線或電纜、光纖、或是任何傳輸型態進行傳送,其中,當程式碼被機器,如電腦接收、載入且執行時,此機器變成用以參與本發明之裝置。當在一般用途處理單元實作時,程式碼結合處理單元提供一操作類似於應用特定邏輯電路之獨特裝置。 The method of the invention, or a particular type or portion thereof, may exist in the form of a code. The code can be stored in a physical medium such as a floppy disk, a CD, a hard disk, or any other machine readable (such as computer readable) storage medium, or is not limited to an external form of computer program product, wherein When the code is loaded and executed by a machine, such as a computer, the machine becomes a device for participating in the present invention. The code can also be transmitted via some transmission medium, such as a wire or cable, fiber optics, or any transmission type, where the machine becomes part of the program when it is received, loaded, and executed by a machine, such as a computer. Invented device. When implemented in a general purpose processing unit, the code combination processing unit provides a unique means of operation similar to application specific logic.

惟以上所述者,僅為本發明之較佳實施例而已,當不能以此限定本發明實施之範圍,即大凡依本發明申請專利範圍及發明說明內容所作之簡單的等效變化與修飾,皆仍屬本發明專利涵蓋之範圍內。另外本發明的任一實施例或申請專利範圍不須達成本發明所揭露之全部目的或優點或特點。此外,摘要部分和標題僅是用來輔助專利文件搜尋之用,並非用來限制本發明之權利範圍。 The above is only the preferred embodiment of the present invention, and the scope of the invention is not limited thereto, that is, the simple equivalent changes and modifications made by the scope of the invention and the description of the invention are All remain within the scope of the invention patent. In addition, any of the objects or advantages or features of the present invention are not required to be achieved by any embodiment or application of the invention. In addition, the abstract sections and headings are only used to assist in the search of patent documents and are not intended to limit the scope of the invention.

Claims (12)

一種電子系統,包括:一主機;以及一資料儲存裝置,根據該主機所下達的命令操作,其中包括一快閃記憶體以及一控制器,其中:該快閃記憶體包括複數區塊,並且該等區塊中包括一目前區塊以及一暫時區塊;該控制器在將相應於一第一邏輯位址之一第一資料寫入該目前區塊時,判斷該暫時區塊中是否具有同樣相應於該第一邏輯位址之一第二資料;且該控制器判定該暫時區塊中具有同樣相應於該第一邏輯位址之該第二資料時,更將一第一暫時區塊表寫入該暫時區塊中。 An electronic system comprising: a host; and a data storage device, operating according to a command issued by the host, comprising a flash memory and a controller, wherein: the flash memory comprises a plurality of blocks, and the The equal block includes a current block and a temporary block; the controller determines whether the temporary block has the same when writing the first data corresponding to one of the first logical addresses to the current block Corresponding to the second data of the first logical address; and the controller determines that the temporary data block has the second data corresponding to the first logical address, and further includes a first temporary block table Write to this temporary block. 根據申請專利範圍第1項之電子系統,其中該第一資料係為該主機之一寫入命令所指示的資料,或者該第一資料為該暫時區塊中之冷資料。 According to the electronic system of claim 1, wherein the first data is data indicated by one of the host write commands, or the first data is cold data in the temporary block. 根據申請專利範圍第1項之電子系統,其中每一該等區塊包括複數頁面,該第一暫時區塊表中紀錄了該暫時區塊中所有該等頁面之資訊。 The electronic system of claim 1, wherein each of the blocks comprises a plurality of pages in which information of all of the pages in the temporary block is recorded. 根據申請專利範圍第1項之電子系統,其中該控制器在儲存於一隨機存取記憶體中之一目前暫時區塊表中,解除該第二資料與該邏輯位址的關係,以更新該目前暫時區塊表。 The electronic system of claim 1, wherein the controller is stored in a current temporary block table in a random access memory, and the relationship between the second data and the logical address is released to update the Currently the temporary block table. 根據申請專利範圍第4項之電子系統,其中該控制器係將更 新後之該目前暫時區塊表作為該第一暫時區塊表以寫入該暫時區塊之一特定頁面。 According to the electronic system of claim 4, wherein the controller system will be more The current current temporary block table is used as the first temporary block table to write to a specific page of the temporary block. 根據申請專利範圍第5項之電子系統,其中該特定頁面不具有使用者資料。 An electronic system according to item 5 of the patent application, wherein the specific page does not have user data. 根據申請專利範圍第1項之電子系統,其中每一該等區塊包括依照一第一順序排列之複數頁面,其中該控制器係用以在該資料儲存裝置自一斷電事件回復後,根據該暫時區塊中之第X個頁面所儲存之一第二暫時區塊表,判斷該暫時區塊與該目前區塊中具有相同邏輯位址之資料何者為有效資料,其中該第X個頁面是該暫時區塊中在該斷電事件前最後一個被寫入之頁面,並且X為一正整數。 The electronic system of claim 1, wherein each of the blocks comprises a plurality of pages arranged in a first order, wherein the controller is configured to: after the data storage device recovers from a power outage event, A second temporary block table stored in the Xth page of the temporary block determines whether the temporary block and the current logical block having the same logical address in the current block are valid data, wherein the Xth page Is the last page written in the temporary block before the power-down event, and X is a positive integer. 根據申請專利範圍第7項之電子系統,其中在該暫時區塊中之每一該等頁面係用以儲存長度小於一既定長度之系統資料,並且除了系統資料外之其他資料皆係寫入該目前區塊中。 An electronic system according to claim 7 wherein each of the pages in the temporary block is for storing system data having a length less than a predetermined length, and other materials other than the system data are written Currently in the block. 根據申請專利範圍第8項之電子系統,其中每一該等頁面皆具有一使用者資料空間以及一備用空間,在該資料儲存裝置自該斷電事件回復後,該控制器係用以使用一尋找程序來獲得該第X個頁面,其中在該尋找程序中,該控制器自該暫時區塊中之第1個頁面開始,依照該第一順序讀取該暫時區塊中間隔一既定數量之該等頁面的該等備用空間,直到所讀取之該備用空間不具有有效資料為止。 According to the electronic system of claim 8, wherein each of the pages has a user data space and a spare space, and the controller is used to use the data storage device after the power failure event is restored. Searching for a program to obtain the Xth page, wherein in the finding program, the controller starts from the first page in the temporary block, and reads a predetermined number of intervals in the temporary block according to the first sequence The spare space of the pages until the spare space read does not have valid data. 根據申請專利範圍第9項之電子系統,其中在讀取到不具有有效資料的該備用空間後,該控制器更自所讀取到不具有 有效資料之該備用空間所相應之該頁面的下一個開始,依照一第二順序逐一讀取該暫時區塊中之該等頁面之該等備用空間,直到所讀取之該備用空間具有有效資料為止,其中該控制器依照該第二順序讀取到具有有效資料之該備用空間所屬之該頁面為一第一空白頁面,並且該第二順序與該第一順序相反。 According to the electronic system of claim 9, wherein the controller reads from the spare space that does not have valid data, The next start of the page corresponding to the spare space of the valid data, and the spare spaces of the pages in the temporary block are read one by one according to a second sequence until the read spare space has valid data So far, the controller reads, according to the second sequence, the page to which the spare space having valid data belongs is a first blank page, and the second sequence is opposite to the first order. 根據申請專利範圍第10項之電子系統,其中該控制器更讀取該第一空白頁面中之該使用者資料空間,並且判斷該第一空白頁面中之該使用者資料空間是否具有有效資料,以確認該第一空白頁面為該暫時區塊中第一個不具有使用者資料的頁面,其中當該第一空白頁面中之該使用者資料空間具有有效資料時,該控制器更自該第一空白頁面開始依照該第一順序逐一讀取該暫時區塊中之該等頁面的該等使用者資料空間,直到所讀取之該使用者資料空間不具有有效資料為止,其中該使用者資料空間不具有有效資料的該頁面取代原該第一空白頁面成為新的第一空白頁面。 The electronic system of claim 10, wherein the controller further reads the user data space in the first blank page, and determines whether the user data space in the first blank page has valid data. To confirm that the first blank page is the first page in the temporary block that does not have user data, wherein when the user data space in the first blank page has valid data, the controller is further from the first a blank page begins to read the user data spaces of the pages in the temporary block one by one according to the first sequence until the read user data space does not have valid data, wherein the user data The page that does not have valid material in space replaces the original blank page to become the new first blank page. 根據申請專利範圍第11項之電子系統,其中該控制器更自該第一空白頁面的上一個頁面或者該新的第一空白頁面的上一個頁面開始,依照該第二順序逐一讀取該暫時區塊中之該等頁面之該等使用者資料空間,並且判斷所讀取之該頁面之該使用者空間是否具有有效資料,其中反序所讀取具有有效資料之該使用者資料空間所相應之該頁面,為該暫時區塊中最後一個具有有效資料之該頁面,並且為該第X個頁面。 The electronic system of claim 11, wherein the controller further reads the temporary one by one according to the second page of the first blank page or the previous page of the new first blank page. The user data spaces of the pages in the block, and determining whether the user space of the page read has valid data, wherein the user data space with valid data is read in reverse order The page is the last page in the temporary block with valid data, and is the Xth page.
TW106128024A 2016-12-13 2016-12-13 Electronic system with data storage device TWI656475B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW106128024A TWI656475B (en) 2016-12-13 2016-12-13 Electronic system with data storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW106128024A TWI656475B (en) 2016-12-13 2016-12-13 Electronic system with data storage device

Publications (2)

Publication Number Publication Date
TW201821972A TW201821972A (en) 2018-06-16
TWI656475B true TWI656475B (en) 2019-04-11

Family

ID=63258393

Family Applications (1)

Application Number Title Priority Date Filing Date
TW106128024A TWI656475B (en) 2016-12-13 2016-12-13 Electronic system with data storage device

Country Status (1)

Country Link
TW (1) TWI656475B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070106919A1 (en) * 2002-10-28 2007-05-10 Sandisk Corporation Power Management Block for Use in a Non-Volatile Memory System
US20110141808A1 (en) * 2008-07-22 2011-06-16 Lsi Corporation Methods and Apparatus for Programming Multiple Program Values Per Signal Level in Flash Memories
TWI433157B (en) * 2009-09-04 2014-04-01 Silicon Motion Inc Method for accessing a flash memory and associated memory device
TWI519956B (en) * 2009-10-16 2016-02-01 三星電子股份有限公司 Nonvolatile memory system and related method of preserving stored data during power interruption
US20160268000A1 (en) * 2015-03-09 2016-09-15 Ocz Storage Solutions, Inc. Power fail saving modes in solid state drive with mlc memory
TWI596480B (en) * 2011-12-05 2017-08-21 財團法人工業技術研究院 Memory storage system, and central control device, management method and recovery method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070106919A1 (en) * 2002-10-28 2007-05-10 Sandisk Corporation Power Management Block for Use in a Non-Volatile Memory System
US20110141808A1 (en) * 2008-07-22 2011-06-16 Lsi Corporation Methods and Apparatus for Programming Multiple Program Values Per Signal Level in Flash Memories
TWI433157B (en) * 2009-09-04 2014-04-01 Silicon Motion Inc Method for accessing a flash memory and associated memory device
TWI519956B (en) * 2009-10-16 2016-02-01 三星電子股份有限公司 Nonvolatile memory system and related method of preserving stored data during power interruption
TWI596480B (en) * 2011-12-05 2017-08-21 財團法人工業技術研究院 Memory storage system, and central control device, management method and recovery method
US20160268000A1 (en) * 2015-03-09 2016-09-15 Ocz Storage Solutions, Inc. Power fail saving modes in solid state drive with mlc memory

Also Published As

Publication number Publication date
TW201821972A (en) 2018-06-16

Similar Documents

Publication Publication Date Title
TWI606388B (en) Data storage device and data maintenance method thereof
CN108733510B (en) Data storage device and mapping table reconstruction method
TWI597605B (en) Method of wear leveling for data storage device
TWI613652B (en) Data storage device and operating method therefor
US8046528B2 (en) Data writing method for flash memory, and flash memory controller and storage device thereof
CN105683897B (en) Data storage systems with stale data mechanism and its operating method
TWI645404B (en) Data storage device and control method for non-volatile memory
CN107291378B (en) Data storage device and data maintenance method thereof
TWI646535B (en) Data storage device and non-volatile memory operation method
TWI609323B (en) Data storing method and system thereof
TWI604373B (en) Data storage device and data maintenance method thereof
CN109426441B (en) Data storage device and method of operation thereof
KR20200120113A (en) Memory system and operating method thereof
CN106708422B (en) Data storage device and data maintenance method thereof
TWI656475B (en) Electronic system with data storage device
CN109002265B (en) Data processing method and related device
TW201337553A (en) Data writing method, memory controller and memory storage apparatus
TWI854482B (en) Data backup and restoration method and data backup and restoration device thereof
CN107025062B (en) Data storage method and system thereof
TWI669610B (en) Data storage device and control method for non-volatile memory
TWI652572B (en) Data storage device
JP2024134441A (en) MEMORY SYSTEM AND METHOD FOR CONTROLLING NON-VOLATILE MEMORY - Patent application