TW202105192A - Method and computer program product and apparatuse for handling sudden power off recovery - Google Patents

Method and computer program product and apparatuse for handling sudden power off recovery Download PDF

Info

Publication number
TW202105192A
TW202105192A TW108125982A TW108125982A TW202105192A TW 202105192 A TW202105192 A TW 202105192A TW 108125982 A TW108125982 A TW 108125982A TW 108125982 A TW108125982 A TW 108125982A TW 202105192 A TW202105192 A TW 202105192A
Authority
TW
Taiwan
Prior art keywords
page
current block
block
pages
last
Prior art date
Application number
TW108125982A
Other languages
Chinese (zh)
Other versions
TWI697780B (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 TW108125982A priority Critical patent/TWI697780B/en
Application granted granted Critical
Publication of TWI697780B publication Critical patent/TWI697780B/en
Publication of TW202105192A publication Critical patent/TW202105192A/en

Links

Images

Abstract

A method for handling sudden power off recovery (SPOR), performed by a processing unit, includes: reading pages of a current block sequentially after a power on subsequent to a sudden power off; identifying the last correct-page of the current block according to read statuses of the current block pages; configuring n1 pages subsequent to the next page of the last correct-page of the current block as dummy pages; and storing the last-correct page and its prior pages of the current block in empty pages subsequent to the last dummy page of the current block, wherein a total amount of the stored pages is n2.

Description

瞬間斷電回復處理方法及電腦程式產品以及裝置Instantaneous power failure recovery processing method, computer program product and device

本發明涉及快閃記憶裝置,尤指一種瞬間斷電回復處理方法及電腦程式產品以及裝置。The invention relates to a flash memory device, in particular to an instantaneous power failure recovery processing method and a computer program product and device.

快閃記憶裝置通常分為NOR快閃記憶裝置與NAND快閃記憶裝置。NOR快閃記憶裝置為隨機存取裝置,主機端(Host)可於位址腳位上提供任何存取NOR快閃記憶裝置的位址,並及時地從NOR快閃記憶裝置的資料腳位上獲得儲存於該位址上的資料。相反地,NAND快閃記憶裝置並非隨機存取,而是序列存取。NAND快閃記憶裝置無法像NOR快閃記憶裝置一樣,可以存取任何隨機位址,主機端反而需要寫入序列的位元組(Bytes)的值到NAND快閃記憶裝置中,用以定義請求命令(Command)的類型(如,讀取、寫入、抹除等),以及用在此命令上的位址。位址可指向一個頁面(快閃記憶裝置中寫入作業的最小資料塊)或一個區塊(快閃記憶裝置中抹除作業的最小資料塊)。Flash memory devices are generally divided into NOR flash memory devices and NAND flash memory devices. The NOR flash memory device is a random access device. The host can provide any address for accessing the NOR flash memory device on the address pin, and promptly retrieve it from the data pin of the NOR flash memory device Obtain the data stored at that address. On the contrary, NAND flash memory devices are not random access, but serial access. NAND flash memory devices cannot access any random address like NOR flash memory devices. Instead, the host side needs to write serial bytes (Bytes) into the NAND flash memory device to define the request The type of command (such as read, write, erase, etc.), and the address used for this command. The address can point to a page (the smallest data block for writing in a flash memory device) or a block (the smallest data block for erasing in a flash memory device).

由於自然或人為引起的瞬間斷電可能中斷NAND快閃記憶裝置的寫入操作,因此,本發明實施例提出一種的瞬間斷電回復處理方法及電腦程式產品以及裝置,用來回復中斷的寫入操作。Since the instantaneous power failure caused by nature or man-made may interrupt the writing operation of the NAND flash memory device, the embodiment of the present invention provides a instantaneous power failure recovery processing method and computer program product and device for recovering the interrupted writing operating.

有鑑於此,如何減輕或消除上述相關領域的缺失,實為有待解決的問題。In view of this, how to reduce or eliminate the deficiencies in the above-mentioned related fields is indeed a problem to be solved.

本發明提出一種瞬間斷電回復處理方法,該方法由處理單元於載入並執行韌體或軟體的程式碼時實施,包含:於瞬間斷電而重啟電源後,依序讀取當前塊的頁面;依據當前塊的頁面讀取狀態來標識當前塊中最後一個正確頁面;組態當前塊中最後一個正確頁面的下一個頁面之後n1個頁面為虛假頁面;以及將當前塊中最後一個正確頁面及之前的頁面儲存到當前塊中最後一個虛假頁面之後的空頁面,其中,儲存的頁面總數為n2個。The present invention provides an instantaneous power failure recovery processing method, which is implemented by a processing unit when loading and executing firmware or software code, including: reading the current block page sequentially after the instantaneous power failure and restarting the power supply ; Identify the last correct page in the current block according to the page read status of the current block; configure n1 pages after the next page of the last correct page in the current block as false pages; and set the last correct page in the current block and The previous page is stored to the empty page after the last fake page in the current block, where the total number of stored pages is n2.

本發明另提出一種瞬間斷電回復處理的電腦程式產品,包含被處理單元載入及執行時實施如上所述方法的程式碼。The present invention also provides a computer program product for instantaneous power failure recovery processing, which includes program code that implements the method described above when being loaded and executed by a processing unit.

本發明另提出一種瞬間斷電回復處理裝置,包含:閃存存取介面及處理單元。處理單元執行如上所述的方法。The present invention also provides an instantaneous power failure recovery processing device, which includes a flash memory access interface and a processing unit. The processing unit executes the method as described above.

上述實施例的優點之一,於瞬間斷電回復處理中,通過虛假頁面的組態以及最後一個正確頁面及之前的頁面的遷移,可避免發生瞬間斷電時所影響的鄰近實體字元線及頁面的記憶單元的可用性減損。One of the advantages of the above embodiment is that in the instantaneous power failure recovery process, the configuration of the false page and the migration of the last correct page and the previous page can avoid the occurrence of adjacent physical character lines and characters that are affected by the instantaneous power failure. The usability of the memory unit of the page is reduced.

以下說明為完成發明的較佳實現方式,其目的在於描述本發明的基本精神,但並不用以限定本發明。實際的發明內容必須參考之後的權利要求範圍。The following descriptions are preferred implementations for completing the invention, and their purpose is to describe the basic spirit of the invention, but not to limit the invention. The actual content of the invention must refer to the scope of the claims that follow.

必須了解的是,使用於本說明書中的”包含”、”包括”等詞,用以表示存在特定的技術特徵、數值、方法步驟、作業處理、元件以及/或組件,但並不排除可加上更多的技術特徵、數值、方法步驟、作業處理、元件、組件,或以上的任意組合。It must be understood that the words "including" and "including" used in this specification are used to indicate the existence of specific technical features, values, method steps, operations, elements, and/or components, but they do not exclude the possibility of adding More technical features, values, method steps, job processing, components, components, or any combination of the above.

於權利要求中使用如”第一”、”第二”、”第三”等詞是用來修飾權利要求中的元件,並非用來表示之間具有優先順序,前置關係,或者是一個元件先於另一個元件,或者是執行方法步驟時的時間先後順序,僅用來區別具有相同名字的元件。Words such as "first", "second", and "third" used in the claims are used to modify the elements in the claims, and are not used to indicate that there is a precedence, prerequisite relationship, or an element. Prior to another element, or the chronological order of execution of method steps, is only used to distinguish elements with the same name.

必須了解的是,當元件描述為”連接”或”耦接”至另一元件時,可以是直接連結、或耦接至其他元件,可能出現中間元件。相反地,當元件描述為”直接連接”或”直接耦接”至另一元件時,其中不存在任何中間元件。使用來描述元件之間關係的其他語詞也可類似方式解讀,例如”介於”相對於”直接介於”,或者是”鄰接”相對於”直接鄰接”等等。It must be understood that when an element is described as being “connected” or “coupled” to another element, it can be directly connected or coupled to other elements, and intermediate elements may appear. Conversely, when an element is described as being "directly connected" or "directly coupled" to another element, there are no intervening elements. Other terms used to describe the relationship between elements can also be interpreted in a similar manner, for example, "between" and "directly between", or "adjacent" and "directly adjacent" and so on.

參考圖1。快閃記憶系統架構100包含主機端(host)110、裝置端(device)130及儲存單元150。此系統架構可實施於個人電腦、筆記型電腦(Laptop PC)、平板電腦、手機、數位相機、數位攝影機等電子產品。裝置端130可包含處理單元133。主機端110及裝置端130間可以快閃記憶通訊協定(例如,通用快閃記憶儲存,Universal Flash Storage UFS)彼此通信。快閃記憶控制器133通過資料連結層132及實體層131電性連接(耦接)主機端110。快閃記憶控制器133可通過直接記憶體存取控制器(未顯示於圖1)從資料緩衝區(未顯示於圖1)讀取從儲存單元150取得的使用者資料,並通過驅動資料連結層132及實體層131依序敲出給主機端110。快閃記憶控制器133可通過直接記憶體存取控制器(未顯示於圖1)將主機端110欲寫入的使用者資料儲存至資料緩衝區。處理單元134可使用多種方式實施,例如使用通用硬體,如單一處理器、具平行處理能力的多處理器、圖形處理器、輕簡型通用目的處理器(Lightweight General-Purpose Processor)或其他具運算能力的處理器,並且在執行指令(Instructions)、宏碼(Macrocode)或微碼(Microcode)時,提供之後描述的功能。快閃記憶控制器133可為UFS控制器,透過UFS通訊協定與主機端110進行溝通。雖然本發明實施例以UFS通訊協定舉例,但本發明也可應用到其他的通訊協定,例如通用序列匯流排(Universal Serial Bus, USB)、先進技術附著(advanced technology attachment, ATA)、序列先進技術附著(serial advanced technology attachment, SATA)、快速周邊元件互聯(peripheral component interconnect express, PCI-E)或其他介面的通訊協定。Refer to Figure 1. The flash memory system architecture 100 includes a host 110, a device 130, and a storage unit 150. This system architecture can be implemented in personal computers, laptop PCs, tablets, mobile phones, digital cameras, digital cameras and other electronic products. The device 130 may include a processing unit 133. The host 110 and the device 130 can communicate with each other with a flash memory communication protocol (for example, Universal Flash Storage UFS). The flash memory controller 133 is electrically connected (coupled) to the host terminal 110 through the data link layer 132 and the physical layer 131. The flash memory controller 133 can read the user data obtained from the storage unit 150 from the data buffer (not shown in FIG. 1) through the direct memory access controller (not shown in FIG. 1), and connect it through the drive data The layer 132 and the physical layer 131 are knocked out to the host 110 in sequence. The flash memory controller 133 can store the user data to be written by the host terminal 110 into the data buffer through a direct memory access controller (not shown in FIG. 1). The processing unit 134 can be implemented in a variety of ways, such as the use of general-purpose hardware, such as a single processor, multi-processors with parallel processing capabilities, graphics processors, lightweight general-purpose processors (Lightweight General-Purpose Processor) or other tools. A processor with computing power, and when executing instructions, macrocodes or microcodes, it provides the functions described later. The flash memory controller 133 may be a UFS controller, which communicates with the host terminal 110 through the UFS communication protocol. Although the UFS communication protocol is used as an example in the embodiment of the present invention, the present invention can also be applied to other communication protocols, such as Universal Serial Bus (USB), advanced technology attachment (ATA), and advanced serial technology. Attachment (serial advanced technology attachment, SATA), peripheral component interconnect express (PCI-E) or other interface communication protocols.

裝置端130另包含閃存存取介面139,使得處理單元134可通過閃存存取介面139與儲存單元150溝通,詳細來說,可採用雙倍資料率(Double Data Rate DDR)通訊協定,例如,開放NAND快閃(Open NAND Flash Interface ONFI)、雙倍資料率開關(DDR Toggle)或其他介面。處理單元134透過閃存存取介面139寫入使用者資料到儲存單元150中的指定位址(目的位址),以及從儲存單元150中的指定位址(來源位址)讀取使用者資料。閃存存取介面139使用數個電子訊號來協調處理單元134與儲存單元150間的資料與命令傳遞,包含資料線(data line)、時脈訊號(clock signal)與控制訊號(control signal)。資料線可用以傳遞命令、位址、讀出及寫入的資料;控制訊號線可用以傳遞晶片致能(Chip Enable CE)、位址提取致能(Address Latch Enable ALE)、命令提取致能(Command Latch Enable CLE)、寫入致能(Write Enable WE)等控制訊號。The device side 130 further includes a flash memory access interface 139, so that the processing unit 134 can communicate with the storage unit 150 through the flash memory access interface 139. Specifically, the Double Data Rate (DDR) communication protocol can be used, for example, open NAND flash (Open NAND Flash Interface ONFI), double data rate switch (DDR Toggle) or other interfaces. The processing unit 134 writes user data to the designated address (destination address) in the storage unit 150 through the flash memory access interface 139, and reads the user data from the designated address (source address) in the storage unit 150. The flash memory access interface 139 uses several electronic signals to coordinate data and command transmission between the processing unit 134 and the storage unit 150, including data lines, clock signals, and control signals. The data line can be used to transfer commands, addresses, read and write data; the control signal line can be used to transfer Chip Enable CE, Address Latch Enable ALE, and Command Extraction Enable ( Control signals such as Command Latch Enable CLE and Write Enable WE.

儲存單元150可包含多個儲存子單元,每個儲存子單元,各自使用關聯的存取子介面與處理單元134進行溝通。一或多個儲存子單元可封裝在一個晶粒(Die)之中。閃存存取介面139可包含j個存取子介面,每一個存取子介面連接i個儲存子單元。存取子介面及其後連接的儲存子單元又可統稱為輸出入通道,每個儲存子單元可以邏輯單元編號(Logic Unit Number LUN)識別。換句話說,i個儲存子單元共享一個存取子介面。例如,裝置端130包含4個輸出入且每一個輸出入連接4個儲存子單元時,裝置端130可存取16個儲存子單元。處理單元134可驅動存取子介面中之一者,從指定的儲存子單元讀取,或寫入資料至指定的儲存子單元。每個儲存子單元擁有獨立的晶片致能(CE)控制訊號。換句話說,當欲對指定的儲存子單元進行資料讀取或寫入時,需要驅動關聯的存取子介面來致能此儲存子單元的晶片致能控制訊號。參考圖2。處理單元134可透過存取子介面139_0使用獨立的晶片致能控制訊號230_0至230_i從連接的儲存子單元150_0至150_i中選擇出其中一者,接著,透過共享的資料線210從選擇出的儲存子單元的指定位址讀取資料,或傳送欲寫入指定位址的使用者資料至選擇出的儲存子單元。The storage unit 150 may include a plurality of storage sub-units, and each storage sub-unit uses an associated access sub-interface to communicate with the processing unit 134. One or more storage sub-units can be packaged in a die. The flash memory access interface 139 may include j access sub-interfaces, and each access sub-interface is connected to i storage sub-units. The access sub-interface and subsequent storage sub-units can also be collectively referred to as input and output channels, and each storage sub-unit can be identified by a logical unit number (Logic Unit Number LUN). In other words, i storage sub-units share one access sub-interface. For example, when the device 130 includes 4 I/Os and each I/O is connected to 4 storage sub-units, the device 130 can access 16 storage sub-units. The processing unit 134 can drive one of the access sub-interfaces, read from the designated storage sub-unit, or write data to the designated storage sub-unit. Each storage sub-unit has an independent chip enable (CE) control signal. In other words, when data is to be read or written to a designated storage subunit, the associated access sub-interface needs to be driven to enable the chip enable control signal of this storage subunit. Refer to Figure 2. The processing unit 134 can use independent chip enable control signals 230_0 to 230_i to select one of the connected storage subunits 150_0 to 150_i through the access sub-interface 139_0, and then use the shared data line 210 from the selected storage Read data from the specified address of the subunit, or send user data to be written to the specified address to the selected storage subunit.

每個儲存子單元可包含多個資料平面(data planes),每個資料平面可包含多個塊(blocks),並且每個塊可包含多個頁面(pages)。參考圖3,以儲存子單元150_0為例。儲存子單元150_0包含兩個資料平面310及330。資料平面310包含塊310_0至310_m,且資料平面330包含塊330_0至330_m。每個塊包含n+1個頁面。每個塊可組態為單層式單元塊(Single Logical Cell SLC block)、多層式單元塊(Multi-Level Cell MLC block) 或三層式單元塊(Triple Level Cell TLC block)。SLC、MLC及TLC塊中的每個記憶體單元(memory cells)可分別儲存兩個、四個及八個狀態。SLC塊中的每個字元線(word line)可儲存一個頁面的資料。MLC塊中的每個字元線可儲存兩個頁面的資料,包含最高有效位頁面(Most Significant Bit MSB page)及最低有效位頁面(Least Significant Bit LSB page)。TLC塊中的每個字元線可儲存三個頁面的資料,包含最高有效位頁面、中間有效位頁面(Center Significant Bit CSB page)及最低有效位頁面。Each storage subunit may include multiple data planes, each data plane may include multiple blocks, and each block may include multiple pages. Referring to FIG. 3, take the storage subunit 150_0 as an example. The storage subunit 150_0 includes two data planes 310 and 330. The data plane 310 includes blocks 310_0 to 310_m, and the data plane 330 includes blocks 330_0 to 330_m. Each block contains n+1 pages. Each block can be configured as Single Logical Cell SLC block, Multi-Level Cell MLC block or Triple Level Cell TLC block. Each memory cell in the SLC, MLC, and TLC blocks can store two, four, and eight states, respectively. Each word line in the SLC block can store a page of data. Each character line in the MLC block can store two pages of data, including the Most Significant Bit MSB page and the Least Significant Bit LSB page. Each character line in the TLC block can store three pages of data, including the most significant bit page, the center significant bit page (Center Significant Bit CSB page), and the least significant bit page.

參考圖4。於直接寫入模式(direct-write mode),靜態隨機存取記憶體(Static Random Access Memory SRAM)136中沒有配置快取空間(cache)來緩存主機端110發出的大量主機寫命令(host write commands)及待寫入資料,只有配置有限空間的命令佇列及資料緩衝區(data buffer)410來儲存主機寫命令及待寫入資料。不同於快取模式(cache mode),處理單元134於直接寫入模式依據主機寫命令驅動閃存存取介面139將待寫入資料寫入儲存單元150後才算完成主機寫命令的處理。為了處理主機端110發出的各式各樣的主機寫命令,儲存子單元150_0可配置兩個塊:當前塊(current block)451及暫存塊(temporary block)453。當前塊451組態為MLC或TLC塊,而暫存塊453組態為SLC塊。假設主機端110管理資料的最小單位為4K位元組,且儲存子單元150_0中每個頁面儲存的資料長度為16K位元組:當主機寫命令指示寫入一或多個頁面長度的資料時,處理單元134驅動閃存存取介面139以MLC或TLC模式將資料寫入當前塊451中一或多個空頁面。當主機寫命令指示寫入少於頁面長度的資料時,處理單元134驅動閃存存取介面139以SLC模式將資料寫入暫存塊453中空頁面的一或多個區段(sectors),其中每個區段儲存4K位元組的資料。一旦暫存塊453中的任何頁面填滿資料,處理單元134可驅動閃存存取介面139以MLC或TLC模式將暫存塊453中的整頁資料寫入當前塊451中的一個空頁面。Refer to Figure 4. In direct-write mode, there is no cache in the Static Random Access Memory SRAM 136 to cache a large number of host write commands issued by the host 110. ) And data to be written, only a command queue and data buffer 410 with a limited space are allocated to store the host write commands and data to be written. Different from the cache mode, in the direct write mode, the processing unit 134 drives the flash access interface 139 according to the host write command to write the data to be written into the storage unit 150 before the host write command processing is completed. In order to process various host write commands issued by the host 110, the storage sub-unit 150_0 can be configured with two blocks: a current block 451 and a temporary block 453. The current block 451 is configured as an MLC or TLC block, and the temporary storage block 453 is configured as an SLC block. Assuming that the minimum unit of the host-side 110 management data is 4K bytes, and the data length of each page in the storage subunit 150_0 is 16K bytes: when the host write command instructs to write data of one or more page lengths The processing unit 134 drives the flash memory access interface 139 to write data into one or more empty pages in the current block 451 in the MLC or TLC mode. When the host write command instructs to write data less than the page length, the processing unit 134 drives the flash memory access interface 139 to write the data into one or more sectors of the empty page in the temporary storage block 453 in the SLC mode, each of which Each section stores 4K bytes of data. Once any page in the temporary storage block 453 is filled with data, the processing unit 134 can drive the flash memory access interface 139 to write the entire page of data in the temporary storage block 453 into an empty page in the current block 451 in MLC or TLC mode.

由於當前塊451為MLC或TLC塊,也就是說二或三個頁面的資料儲存於同一個字元線,若資料寫入當前塊451的過程發生瞬間斷電(sudden power off SPO),可能會損壞之前已經寫入的頁面資料。例如,參考圖3,當塊310_0為MLC塊(當前塊),其中的頁面P#0為一個字元線上的LSB頁面,且頁面P#3為同一個字元線上的MSB頁面,頁面P#0及P#3可稱為頁面對(page pair)。若資料寫入塊310_0的頁面P#3的過程發生瞬間斷電,可能連帶損壞之前已經寫入頁面P#0的資料。為了防止如上所述的問題,參考圖4,儲存子單元150_0可更配置備份塊455,組態為SLC塊。於寫入資料到當前塊(如塊310_0)中的一個MSB頁面(如頁面P#3)前,處理單元134驅動閃存存取介面139先將當前塊中此MSB頁面的相應LSB頁面(如頁面P#0)的資料儲存(備份)至備份塊455中的空頁面,之後再寫入資料到此MSB頁面。Since the current block 451 is an MLC or TLC block, that is to say, the data of two or three pages are stored on the same character line. If the data is written into the current block 451, a sudden power off (sudden power off SPO) may occur. The page data that has been written before is damaged. For example, referring to Figure 3, when block 310_0 is an MLC block (current block), page P#0 is the LSB page on one character line, and page P#3 is the MSB page on the same character line, page P# 0 and P#3 can be called a page pair. If an instantaneous power failure occurs during the process of writing data to page P#3 of block 310_0, the data written to page P#0 may be damaged. In order to prevent the above-mentioned problems, referring to FIG. 4, the storage sub-unit 150_0 may be further configured with a backup block 455, which is configured as an SLC block. Before writing data to an MSB page (such as page P#3) in the current block (such as block 310_0), the processing unit 134 drives the flash memory access interface 139 to first transfer the corresponding LSB page (such as page P#3) of this MSB page in the current block. The data of P#0) is stored (backed up) to the empty page in the backup block 455, and then the data is written to this MSB page.

類似地,針對當前塊為TLC塊的情況,處理單元134可驅動閃存存取介面139先將當前塊中此MSB頁面的相應CSB頁面的資料儲存(備份)至備份塊455中的空頁面,之後再寫入資料到此MSB頁面。或者,處理單元134可驅動閃存存取介面139先將當前塊中此CSB頁面的相應LSB頁面的資料儲存(備份)至備份塊455中的空頁面,之後再寫入資料到此CSB頁面。Similarly, for the case where the current block is a TLC block, the processing unit 134 can drive the flash memory access interface 139 to first store (backup) the data of the CSB page corresponding to this MSB page in the current block to the empty page in the backup block 455, and then Then write data to this MSB page. Alternatively, the processing unit 134 can drive the flash memory access interface 139 to store (backup) the data of the corresponding LSB page of the CSB page in the current block to the empty page in the backup block 455, and then write the data to the CSB page.

所屬技術領域人員可將當前塊451、暫存塊453及備份塊455中的任何一個實施於任何的資料平面上(如圖3所示的資料平面310或330)。Those skilled in the art can implement any one of the current block 451, the temporary storage block 453 and the backup block 455 on any data plane (the data plane 310 or 330 as shown in FIG. 3).

為了縮短瞬間斷電回復的處理時間,處理單元134盡可能不要花費時間來通過閃存存取介面139重新寫入資料到當前塊451,而是從暫存塊453及/或備份塊455中取得相應資料以重建當前塊451。本發明實施例利用當前塊451、暫存塊453及備份塊455中每個頁面的剩餘空間(spare space)來儲存保護資訊(protection information),讓未來可能的瞬間斷電回復處理(sudden power off recovery SPOR process)使用。為了維護當前塊451、暫存塊453及備份塊455中頁面資料的儲存順序,當前塊451的一個頁面的剩餘空間可紀錄於儲存此頁面資料當時指向暫存塊453的第一個空頁面的位址資訊(例如暫存塊453的編號及其中第一個空頁面的編號),而暫存塊453的一個頁面的剩餘空間可紀錄於儲存此頁面資料當時指向當前塊451的第一個空頁面的位址資訊(例如當前塊451的編號及其中第一個空頁面的編號)。又由於當前塊451的CSB頁面或LSB頁面(可稱為原始頁面)的資料可能備份到備份塊455中的一個頁面(可稱為備份頁面),因此,備份塊455的一個或多個頁面的剩餘空間可紀錄儲存此頁面資料當時指向當前塊451的第一個空頁面的位址資訊(例如當前塊451的編號及其中第一個空頁面的編號),以及指向暫存塊453的第一個空頁面的位址資訊(例如暫存塊453的編號及其中第一個空頁面的編號)。In order to shorten the processing time for instantaneous power failure recovery, the processing unit 134 should not spend as much time as possible to rewrite data to the current block 451 through the flash access interface 139, but obtain the corresponding data from the temporary storage block 453 and/or the backup block 455. Data to reconstruct the current block 451. The embodiment of the present invention uses the spare space of each page in the current block 451, the temporary storage block 453, and the backup block 455 to store protection information, so as to allow sudden power off recovery processing in the future. Recovery SPOR process) use. In order to maintain the storage order of page data in the current block 451, the temporary storage block 453, and the backup block 455, the remaining space of a page in the current block 451 can be recorded in the first empty page of the temporary storage block 453 at the time the page data is stored. Address information (such as the number of the temporary storage block 453 and the number of the first free page in it), and the remaining space of a page of the temporary storage block 453 can be recorded when the page data is stored and points to the first free page of the current block 451 The address information of the page (for example, the number of the current block 451 and the number of the first empty page in it). In addition, since the data of the CSB page or LSB page (which can be called the original page) of the current block 451 may be backed up to one page (which can be called the backup page) in the backup block 455, the data of one or more pages of the backup block 455 The remaining space can record the address information of the first empty page of the current block 451 (such as the number of the current block 451 and the number of the first empty page in the current block 451), and the first empty page of the temporary storage block 453. Address information of an empty page (for example, the number of the temporary storage block 453 and the number of the first empty page in it).

於一些實施例中,當前塊451、暫存塊453及備份塊455中每個頁面的剩餘空間能夠儲存指向兩個以上頁面的資訊。參考圖5,舉個使用案例,當前塊451的第N頁面中的資料備份到備份塊455的第O頁面。圖5中斜線的方塊代表空頁面。當前塊451的第N頁面的剩餘空間510可儲存指向暫存塊453的第M+1頁面的位址資訊。暫存塊453的第M頁面的剩餘空間530可儲存指向當前塊451的第N+1頁面的位址資訊。備份塊455的第O頁面的剩餘空間550a可儲存指向當前塊451的第N+1頁面的位址資訊,以及剩餘空間550b可儲存指向暫存塊453的第M+1頁面的位址資訊。In some embodiments, the remaining space of each page in the current block 451, the temporary storage block 453, and the backup block 455 can store information pointing to more than two pages. Referring to FIG. 5, for a use case, the data in the Nth page of the current block 451 is backed up to the Oth page of the backup block 455. The diagonal squares in Figure 5 represent empty pages. The remaining space 510 of the Nth page of the current block 451 can store address information pointing to the M+1th page of the temporary storage block 453. The remaining space 530 of the Mth page of the temporary storage block 453 can store the address information pointing to the N+1th page of the current block 451. The remaining space 550a of the 0th page of the backup block 455 can store the address information of the N+1th page of the current block 451, and the remaining space 550b can store the address information of the M+1th page of the temporary storage block 453.

於另一些實施例中,當前塊451、暫存塊453及備份塊455中每個頁面的剩餘空間只能夠儲存指向一個頁面的資訊。若要完整紀錄如上所述備份塊455的剩餘空間需要儲存的保護資訊,處理單元134以交替的方式將資料儲存到資料平面310及資料平面330的當前塊的空頁面,並且將資料平面310及資料平面330的兩個頁面視為頁面組(page group)。例如,參考圖4,假設塊310_1為資料平面310的當前塊,而塊330_1為資料平面330的當前塊:處理單元134可依序將資料寫入當前塊310_1的頁面P#0、當前塊330_1的頁面P#0、當前塊310_1的頁面P#1、當前塊330_1的頁面P#1,其中當前塊310_1及當前塊330_1的頁面P#0為一個頁面組,且當前塊310_1及當前塊330_1的頁面P#1為另一個頁面組。參考圖6,舉個使用案例,當前塊451a設置於資料平面310,而當前塊451b設置於資料平面330。當前塊451a的第N頁面的資料備份到備份塊455的第O頁面,並且當前塊451b的第N頁面的資料備份到備份塊455的第O+1頁面。圖6中斜線的方塊代表空頁面。當前塊451a及當前塊451b的第N頁面為頁面組。當前塊451a的第N頁面的剩餘空間510a可儲存指向暫存塊453的第M頁面的位址資訊,而當前塊451b的第N頁面的剩餘空間510b可不儲存任何位址資訊。暫存塊453的第M頁面的剩餘空間530可儲存指向當前塊451a的第N+1頁面的位址資訊。備份塊455的第O頁面的剩餘空間550a可儲存指向當前塊451a的第N+1頁面的位址資訊,以及備份塊455的第O+1頁面的剩餘空間550b可儲存指向暫存塊453的第M頁面的位址資訊。In other embodiments, the remaining space of each page in the current block 451, the temporary storage block 453, and the backup block 455 can only store information pointing to one page. To fully record the protection information that needs to be stored in the remaining space of the backup block 455 as described above, the processing unit 134 alternately stores the data in the empty pages of the current block of the data plane 310 and the data plane 330, and transfers the data plane 310 and The two pages of the data plane 330 are regarded as page groups. For example, referring to FIG. 4, it is assumed that block 310_1 is the current block of data plane 310, and block 330_1 is the current block of data plane 330: the processing unit 134 may sequentially write data to page P#0 and current block 330_1 of current block 310_1. Page P#0 of current block 310_1, page P#1 of current block 310_1, page P#1 of current block 330_1, where current block 310_1 and page P#0 of current block 330_1 are a page group, and current block 310_1 and current block 330_1 The page P#1 is another page group. Referring to FIG. 6, for a use case, the current block 451 a is set on the data plane 310, and the current block 451 b is set on the data plane 330. The data of the Nth page of the current block 451a is backed up to the 0th page of the backup block 455, and the data of the Nth page of the current block 451b is backed up to the 0+1th page of the backup block 455. The diagonal squares in Figure 6 represent empty pages. The Nth page of the current block 451a and the current block 451b is a page group. The remaining space 510a of the Nth page of the current block 451a can store address information pointing to the Mth page of the temporary storage block 453, and the remaining space 510b of the Nth page of the current block 451b may not store any address information. The remaining space 530 of the Mth page of the temporary storage block 453 can store the address information pointing to the N+1th page of the current block 451a. The remaining space 550a of the 0th page of the backup block 455 can store the address information of the N+1th page of the current block 451a, and the remaining space 550b of the 0+1th page of the backup block 455 can store the information pointing to the temporary storage block 453 Address information of page M.

參考圖7。圖7所示的方法可由處理單元134於載入並執行特定韌體或軟體指令時實施。處理單元134依據命令佇列中的主機寫指令準備寫入不滿一整頁長度的資料(如4K、8K、12K的資料)到暫存塊的一個空頁面後(步驟S710),產生暫存頁面的保護資訊,包含指向當前塊的第一個空頁面的位址資訊(步驟S730)。例如,處理單元134產生圖6中暫存塊453的剩餘空間530,或圖7中暫存塊453的剩餘空間530a或530b即將儲存的保護資訊。接著,處理單元134驅動閃存存取介面139將資料及保護資訊寫入到暫存塊的第一個空頁面(步驟S750)。Refer to Figure 7. The method shown in FIG. 7 can be implemented by the processing unit 134 when loading and executing specific firmware or software commands. The processing unit 134 prepares to write data less than a full page length (such as 4K, 8K, 12K data) to an empty page of the temporary storage block according to the host write command in the command queue (step S710), and then generates a temporary storage page The protection information of includes the address information pointing to the first empty page of the current block (step S730). For example, the processing unit 134 generates the remaining space 530 of the temporary storage block 453 in FIG. 6 or the protection information to be stored in the remaining space 530a or 530b of the temporary storage block 453 in FIG. 7. Next, the processing unit 134 drives the flash memory access interface 139 to write data and protection information into the first empty page of the temporary storage block (step S750).

參考圖8。圖8所示的方法可由處理單元134於載入並執行特定韌體或軟體指令時實施。處理單元134依據命令佇列中的主機寫指令準備寫入一整個頁面的資料到當前塊的一個空頁面(步驟S810)。所屬技術領域人員理解一整個頁面的資料可包含或不包含從暫存塊中取得的資料。接著,處理單元134判斷即將寫入頁面的字元線上是否存在已寫入的頁面資料(步驟S820)。例如,字元線上是否存在處理上一個主機寫命令時已寫入的LSB或CSB頁面資料。如果判斷為否(步驟S820中”否”的路徑),例如,即將寫入頁面為一個字元線的LSB頁面,或者是,已寫入的LSB或CSB頁面資料為處理同一個主機寫命令時寫入的資料,處理單元134產生當前頁面的保護資訊,包含指向暫存塊中的第一個空頁面的位址資訊 (步驟S830)。例如,處理單元134產生圖6中當前塊451的剩餘空間510,或圖7中當前塊451a的剩餘空間510a或當前塊451b的剩餘空間510b即將儲存的保護資訊。接著,處理單元134驅動閃存存取介面139將資料及保護資訊寫入當前塊的第一個空頁面(步驟S840)。Refer to Figure 8. The method shown in FIG. 8 can be implemented by the processing unit 134 when loading and executing specific firmware or software commands. The processing unit 134 prepares to write a whole page of data to an empty page of the current block according to the host write command in the command queue (step S810). Those skilled in the art understand that the data of an entire page may or may not include the data obtained from the temporary storage block. Next, the processing unit 134 determines whether there is already written page data on the character line of the page to be written (step S820). For example, whether there is the LSB or CSB page data that has been written when processing the last host write command on the character line. If the judgment is no (the “No” path in step S820), for example, the page will be written as an LSB page of a character line, or yes, when the written LSB or CSB page data is processing the same host write command For the written data, the processing unit 134 generates protection information of the current page, including address information pointing to the first empty page in the temporary storage block (step S830). For example, the processing unit 134 generates the remaining space 510 of the current block 451 in FIG. 6, or the remaining space 510a of the current block 451a or the remaining space 510b of the current block 451b in FIG. Next, the processing unit 134 drives the flash memory access interface 139 to write data and protection information into the first empty page of the current block (step S840).

若判斷為是(步驟S820中”是”的路徑),處理單元134產生備份頁面的保護資訊,包含指向當前塊的第一個空頁面的位址資訊,以及指向暫存塊的第一個空頁面的位址資訊(步驟S850)。例如,處理單元134產生圖6或圖7中備份塊455的剩餘空間550a及550b即將儲存的保護資訊。處理單元134驅動閃存存取介面139將已寫入的頁面資料及保護資訊寫入到備份塊的第一個空頁面(步驟S860)。接著,處理單元134執行如上所述步驟S830及S840的處理。If the judgment is yes (the path of "Yes" in step S820), the processing unit 134 generates protection information of the backup page, including the address information pointing to the first free page of the current block, and the first free page pointing to the temporary storage block. Address information of the page (step S850). For example, the processing unit 134 generates protection information to be stored in the remaining space 550a and 550b of the backup block 455 in FIG. 6 or FIG. 7. The processing unit 134 drives the flash memory access interface 139 to write the written page data and protection information to the first empty page of the backup block (step S860). Next, the processing unit 134 executes the processing of steps S830 and S840 as described above.

由於瞬間斷電可能傷害已經寫入或正在寫入的頁面資料,因此,於發生瞬間斷電後而重啟電源時,處理單元134可執行瞬間斷電回復處理,用來標識當前塊及暫存塊中的正確資料。參考圖9。圖9所示的方法可由處理單元134於載入並執行特定韌體或軟體指令時實施。處理單元134使用變數i來記錄當前塊中正在掃描的頁面編號,初始為0(步驟S910)。處理單元134反覆執行一個迴圈(步驟S920至S940),用來找出當前塊中因瞬間斷電而傷害到的頁面。於每個回合,處理單元134驅動閃存存取介面139讀取當前塊的第i頁面(步驟S920),並且執行兩個判斷(步驟S930及S940)。當讀取的頁面沒有出現無法修復的情形(步驟S930中”否”的路徑)或讀取的頁面雖然無法修復但已經備份於備份塊中(步驟S930中”是”的路徑接著步驟S940中”是”的路徑),判斷讀取頁面的資料為正確資料,將變數i加1以進行下一個頁面的判斷(步驟S935)。當讀取的頁面出現無法修復的情形(步驟S930中”是”的路徑)並且沒有備份於備份塊中(步驟S940中”否”的路徑),判斷讀取頁面的資料為不正確資料,並結束迴圈。讀取的頁面出現無法修復的情形指處理單元134使用讀取頁面資料中的錯誤校驗修正碼(error check and correction ECC code)仍然無法修復讀取資料中的錯誤位元。出現無法修復情形的頁面可稱為無法錯誤校驗修正的頁面(uncorrectable ECC—UECC page)。於迴圈結束後,處理單元134使用變數v1=i-1,用來記錄當前塊中最後一個正確頁面的編號,換句話說,當前塊中第i頁面以及之後的頁面都是被瞬間斷電傷害到的頁面。所屬技術領域人員可不在資料寫入至當前塊時加上備份塊的備份機制,使得如上所述的方法可不進行步驟S940的判斷。Since the instantaneous power failure may damage the page data that has been written or is being written, when the power is restarted after the instantaneous power failure, the processing unit 134 can perform the instantaneous power failure recovery process to identify the current block and the temporary storage block The correct information in the. Refer to Figure 9. The method shown in FIG. 9 can be implemented by the processing unit 134 when loading and executing specific firmware or software commands. The processing unit 134 uses the variable i to record the page number being scanned in the current block, which is initially 0 (step S910). The processing unit 134 repeatedly executes a loop (steps S920 to S940) to find the pages in the current block that are damaged by the instantaneous power failure. In each round, the processing unit 134 drives the flash memory access interface 139 to read the i-th page of the current block (step S920), and performs two judgments (steps S930 and S940). When the read page does not appear to be unable to be repaired (the "No" path in step S930) or the read page cannot be repaired but has been backed up in the backup block (the "Yes" path in step S930 is followed by step S940" Yes” path), it is judged that the data of the read page is the correct data, and the variable i is increased by 1 to judge the next page (step S935). When the read page cannot be repaired (the "Yes" path in step S930) and is not backed up in the backup block (the "No" path in step S940), it is judged that the data of the read page is incorrect data, and End the loop. The condition that the read page cannot be repaired means that the processing unit 134 uses the error check and correction ECC code in the read page data to still be unable to repair the error bit in the read data. Pages that cannot be repaired can be referred to as pages that cannot be corrected by error checking (uncorrectable ECC—UECC page). After the loop is over, the processing unit 134 uses the variable v1=i-1 to record the number of the last correct page in the current block. In other words, the i-th page and subsequent pages in the current block are instantly powered off The page that hurts. Those skilled in the art may not add the backup mechanism of the backup block when the data is written to the current block, so that the method described above does not need to perform the judgment in step S940.

接著,處理單元134使用變數j來記錄暫存塊中正在掃描的頁面編號,初始為0(步驟S960)。處理單元134反覆執行一個迴圈(步驟S970至S980),用來找出暫存塊中正確的頁面。於每個回合,處理單元134驅動閃存存取介面139讀取暫存塊的第j頁面的保護資訊(步驟S970),並且判斷保護資訊是否指向當前塊第v1頁面之後的頁面(步驟S980)。當讀取的保護資訊沒有指向當前塊第v1頁面之後的頁面,也就是說,指向當前塊第v1頁面或之前的頁面(步驟S980中”否”的路徑),判斷讀取頁面的資料為正確資料,將變數j加1以進行下一個頁面的判斷(步驟S975)。當讀取的保護資訊指向當前塊第v1頁面之後的頁面(步驟S980中”是”的路徑),判斷讀取頁面的資料為不正確資料,並結束迴圈。於迴圈結束後,處理單元134使用變數v2=j-1,用來記錄暫存塊中最後一個正確頁面的編號,換句話說,暫存塊中第j頁面(也就是暫存塊中的第一個不正確頁面)以及之後的頁面都是瞬間斷電後不可使用的暫存資料。Next, the processing unit 134 uses the variable j to record the number of the page being scanned in the temporary storage block, which is initially 0 (step S960). The processing unit 134 repeatedly executes a loop (steps S970 to S980) to find the correct page in the temporary storage block. In each round, the processing unit 134 drives the flash memory access interface 139 to read the protection information of the jth page of the temporary storage block (step S970), and determines whether the protection information points to the page after the v1 page of the current block (step S980). When the read protection information does not point to the page after the v1th page of the current block, that is, it points to the v1th page or the previous page of the current block (the "No" path in step S980), it is judged that the data of the read page is correct Data, the variable j is incremented by 1 to judge the next page (step S975). When the read protection information points to the page after the v1th page of the current block (the "Yes" path in step S980), it is determined that the data of the read page is incorrect data, and the loop is ended. After the loop is over, the processing unit 134 uses the variable v2=j-1 to record the number of the last correct page in the temporary storage block. In other words, the jth page in the temporary storage block (that is, the The first incorrect page) and the following pages are temporary data that cannot be used after a momentary power failure.

於一個面向來說,本發明實施例提出一種由裝置端130中的處理單元134執行相關程式碼所實施的方法步驟:於瞬間斷電而重啟電源後,驅動閃存存取介面139依序讀取當前塊451的頁面;依據當前塊451的頁面讀取狀態來標識當前塊451中最後一個正確頁面;驅動閃存存取介面139依序讀取暫存塊453的頁面的保護資訊以標識暫存塊453中第一個不正確頁面,其中,暫存塊453中第一個不正確頁面的保護資訊包含指向當前塊451中最後一個正確頁面之後的頁面的位址資訊;以及捨棄暫存塊453中第一個不正確頁面之後的頁面資料。於瞬間斷電回復處理中,通過根據暫存塊453中的保護資訊來捨棄暫存塊453中儲存時間晚於當前塊451中最後一個正確頁面的所有頁面資料,可確保當前塊451及暫存塊453中回復頁面的時間順序性,避免在回復後的正確頁面間夾雜了沒被回復的頁面資料。In one aspect, the embodiment of the present invention proposes a method step implemented by the processing unit 134 in the device 130 to execute the relevant code: after an instantaneous power failure and power cycle, the flash memory access interface 139 is driven to read sequentially The page of the current block 451; identify the last correct page in the current block 451 according to the page read status of the current block 451; drive the flash access interface 139 to sequentially read the protection information of the pages of the temporary storage block 453 to identify the temporary storage block The first incorrect page in 453, where the protection information of the first incorrect page in the temporary storage block 453 includes the address information of the page after the last correct page in the current block 451; and the temporary storage block 453 is discarded Page data after the first incorrect page. In the instantaneous power failure recovery process, by discarding all page data in the temporary storage block 453 whose storage time is later than the last correct page in the current block 451 according to the protection information in the temporary storage block 453, the current block 451 and the temporary storage can be ensured The chronological order of the reply pages in block 453 avoids the inclusion of unreplenished page data between the correct pages after the reply.

參考圖10所示的使用案例。假設當前塊451a設置於資料平面310,而當前塊451b設置於資料平面330,當前塊451a的第Q+1頁面儲存於備份塊455中的第P頁面,當前塊451b的第Q+1頁面儲存於備份塊455中的第P+1頁面,暫存塊453的第R頁面的保護資訊1030指向當前塊451a及451b的第Q+3頁面,暫存塊453的第R+1頁面的保護資訊1031指向當前塊451a及451b的第Q+4頁面。當處理單元134掃描到當前塊451a及451b第Q+1頁面為UECC頁面(步驟S930中”是”的路徑)但已經備份於備份塊455中(步驟S940中”是”的路徑),分別使用備份塊455中第P頁面及第P+1頁面的資料取代當前塊451a及451b第Q+1頁面的資料,並繼續往下掃描。當處理單元134掃描到當前塊451a及451b第Q+4頁面為UECC頁面(步驟S930中”是”的路徑)但沒有備份於備份塊455中(步驟S940中”否”的路徑),處理單元134判斷當前塊451a及451b中的最後正確頁面為第Q+3頁面(步驟S950)。Refer to the use case shown in Figure 10. Assuming that the current block 451a is set on the data plane 310, and the current block 451b is set on the data plane 330, the Q+1th page of the current block 451a is stored in the Pth page in the backup block 455, and the Q+1th page of the current block 451b is stored In the P+1th page in the backup block 455, the protection information 1030 of the Rth page of the temporary storage block 453 points to the Q+3th pages of the current blocks 451a and 451b, and the protection information of the R+1th page of the temporary storage block 453 1031 points to the Q+4 page of the current blocks 451a and 451b. When the processing unit 134 scans that the Q+1 page of the current block 451a and 451b is a UECC page (the path of "Yes" in step S930) but has been backed up in the backup block 455 (the path of "Yes" in step S940), use them respectively The data of the Pth page and the P+1th page in the backup block 455 replace the data of the Q+1th page of the current blocks 451a and 451b, and the scanning continues. When the processing unit 134 scans that the Q+4 pages of the current blocks 451a and 451b are UECC pages (the "yes" path in step S930) but are not backed up in the backup block 455 (the "no" path in step S940), the processing unit 134 determines that the last correct page in the current blocks 451a and 451b is the Q+3th page (step S950).

此外,當處理單元134掃描到暫存塊453第R+1頁面的保護資訊指向當前塊451a及451b中的最後正確頁面之後的頁面 (步驟S980中”是”的路徑),處理單元134判斷暫存塊453中的最後正確頁面為第R頁面(步驟S990)。In addition, when the processing unit 134 scans that the protection information of the R+1th page of the temporary storage block 453 points to the page after the last correct page in the current blocks 451a and 451b (the "Yes" path in step S980), the processing unit 134 determines that the temporary The last correct page in the storage block 453 is the Rth page (step S990).

雖然最終偵測到的UECC頁面之前頁面的資料都為正確資料,但是發生瞬間斷電時,UECC頁面鄰近的實體字元線及頁面有可能受到影響而減損其記憶單元的可用性,例如減少可正常讀取的次數等。參考圖11。圖11所示的方法可由處理單元134於載入並執行特定韌體或軟體指令時實施。處理單元134驅動閃存存取介面139將當前塊中最後正確頁面及之前的t個頁面的資料複製到暫存塊的空頁面(步驟S1110)。t可依據不同的系統需求設為2到5之間的任意整數。接著,處理單元134將當前塊中偵測到的UECC頁面之後的t個頁面組態為虛假頁面(dummy pages)(步驟S1130)。於一些實施例中,處理單元134可驅動閃存存取介面139將當前塊中偵測到的UECC頁面之後的t個頁面填滿虛假值(dummy values),例如0xFF。接著,處理單元134驅動閃存存取介面139將暫存塊中儲存的資料寫入到新的當前塊的空頁面或此當前塊中最後一個虛假頁面後的空頁面(步驟S1150)。Although the data on the previous page of the UECC page that is finally detected are all correct data, in the event of an instantaneous power failure, the physical character lines and pages adjacent to the UECC page may be affected and reduce the usability of its memory unit. For example, the reduction can be normal. The number of reads, etc. Refer to Figure 11. The method shown in FIG. 11 can be implemented by the processing unit 134 when a specific firmware or software command is loaded and executed. The processing unit 134 drives the flash memory access interface 139 to copy the data of the last correct page and the previous t pages in the current block to the empty pages of the temporary storage block (step S1110). t can be set to any integer between 2 and 5 according to different system requirements. Next, the processing unit 134 configures t pages after the UECC page detected in the current block as dummy pages (step S1130). In some embodiments, the processing unit 134 can drive the flash memory access interface 139 to fill the t pages after the UECC page detected in the current block with dummy values, such as 0xFF. Then, the processing unit 134 drives the flash memory access interface 139 to write the data stored in the temporary storage block to the empty page of the new current block or the empty page after the last dummy page in the current block (step S1150).

接續圖10的使用案例,參考圖12。當前塊451a及451b中第Q+1至Q+3頁面的資料及保護資訊1011a至1013c複製儲存到當前塊451a及451b中第Q+1至Q+3頁面(步驟S1110及S1150)。當前塊451a及451b中第Q+5至Q+7頁面組態為虛假頁面(步驟S1130)。Continuing the use case of Figure 10, refer to Figure 12. The data and protection information 1011a to 1013c of the Q+1 to Q+3 pages in the current blocks 451a and 451b are copied and stored to the Q+1 to Q+3 pages in the current blocks 451a and 451b (steps S1110 and S1150). The Q+5 to Q+7 pages in the current blocks 451a and 451b are configured as false pages (step S1130).

然而,相同當前塊於資料寫入過程中可能發生兩次或以上的瞬間斷電,使得先前被搬移走的頁面資料被誤判為正確的頁面資料。為解決這樣情況發生的問題,靜態隨機存取記憶體136中關聯於當前塊的閃存主機位址映射表(Flash-to-Host F2H table)中的每一筆紀錄加上有效欄位,用來指出當前塊的特定頁面中的資料為有效或無效。此外,圖11所示的方法可修改為圖13所示。於成功組態當前塊中的虛假頁面及遷移候選頁面的資料到當前塊中最後一個虛假頁面後的空頁面後(步驟S1110、S1130及S1310),將當前塊的F2H表中關聯於被遷移頁面、UECC頁面及虛假頁面的紀錄的有效欄位設為無效(步驟S1330)。例如,參考圖12,當前塊451a及451b的F2H表中關聯於第Q+1至Q+7頁面的紀錄的有效欄位設為無效。所屬技術領域人員理解,主機端110可發出主機抹除命令給處理單元134,指示抹除特定邏輯位址的資料。經過位址轉譯後,處理單元134知道邏輯位址映射到當前塊的哪個頁面中的哪個或哪些區段。當前塊中的一個頁面中所有區段的資料都因主機抹除命令而刪除後,處理單元134可將F2H表中關聯於此頁面的紀錄中的有效欄位設為無效。However, the same current block may have two or more instantaneous power failures during the data writing process, so that the page data that was previously removed is misjudged as the correct page data. To solve this problem, each record in the Flash-to-Host F2H table (Flash-to-Host F2H table) associated with the current block in the static random access memory 136 adds a valid field to indicate The data in the specific page of the current block is valid or invalid. In addition, the method shown in FIG. 11 can be modified as shown in FIG. 13. After successfully configuring the data of the fake page and migration candidate page in the current block to the empty page after the last fake page in the current block (steps S1110, S1130 and S1310), associate the F2H table of the current block with the migrated page The valid field of the record of the UECC page and the fake page is set to invalid (step S1330). For example, referring to FIG. 12, the valid fields of the records related to pages Q+1 to Q+7 in the F2H tables of the current blocks 451a and 451b are set to be invalid. Those skilled in the art understand that the host terminal 110 can issue a host erase command to the processing unit 134 to instruct to erase data at a specific logical address. After the address is translated, the processing unit 134 knows which section or sections in which page of the current block the logical address is mapped. After the data of all sections in a page in the current block are deleted due to the host erase command, the processing unit 134 may invalidate the valid field in the record associated with this page in the F2H table.

此外,圖11的步驟S1110修改為圖13的步驟S1300,處理單元1340更檢查F2H表中關聯於當前塊中最後正確頁面及之前的t-1個頁面的有效性。如果當前塊中最後正確頁面及之前的t-1個頁面為無效頁面,則處理單元1340不會進行如步驟S1310及S1330的遷移操作。換句話說,步驟S1330中所述的最後正確頁面及之前的t-1個頁面都是有效的。In addition, step S1110 in FIG. 11 is modified to step S1300 in FIG. 13, and the processing unit 1340 further checks the validity of the last correct page in the current block and the previous t-1 pages in the F2H table. If the last correct page and the previous t-1 pages in the current block are invalid pages, the processing unit 1340 will not perform the migration operations such as steps S1310 and S1330. In other words, the last correct page described in step S1330 and the previous t-1 pages are all valid.

雖然如上所述實施例中的遷移頁面及虛假頁面的數目是相同的,所屬技術領域人員可將遷移頁面及虛假頁面的數目組態為不同的數目,例如,遷移頁面的總數為n2個,虛假頁面的總數為n1個,n1及n2中的每一個可為介於2至5間的整數。Although the numbers of migrated pages and fake pages in the above-mentioned embodiments are the same, those skilled in the art can configure the number of migrated pages and fake pages to be different numbers. For example, the total number of migrated pages is n2. The total number of pages is n1, and each of n1 and n2 can be an integer between 2 and 5.

處理單元134所執行如圖7至圖9、圖11及圖13的方法步驟,可用一或多個功能模塊組成的電腦程式產品來實現。這些功能模塊存儲於非揮發性儲存裝置,並且可被處理單元134於特定時間點載入並執行。本發明所述的方法中的全部或部分步驟可以電腦程式實現,例如特定硬體的驅動程式、或韌體程式。此外,也可實現於如上所示的其他類型程式。所屬技術領域具有通常知識者可將本發明實施例的方法撰寫成電腦程式,為求簡潔不再加以描述。依據本發明實施例方法實施的電腦程式可儲存於適當的電腦可讀取資料載具,例如DVD、CD-ROM、USB碟、硬碟,亦可置於可通過網路(例如,網際網路,或其他適當載具)存取的網路伺服器。The method steps executed by the processing unit 134 as shown in FIGS. 7 to 9, 11 and 13 can be implemented by a computer program product composed of one or more functional modules. These functional modules are stored in a non-volatile storage device, and can be loaded and executed by the processing unit 134 at a specific time. All or part of the steps in the method of the present invention can be implemented by a computer program, such as a specific hardware driver or a firmware program. In addition, it can also be implemented in other types of programs as shown above. Those with ordinary knowledge in the technical field can write the method of the embodiment of the present invention into a computer program, which will not be described for brevity. The computer program implemented according to the method of the embodiment of the present invention can be stored in a suitable computer readable data carrier, such as DVD, CD-ROM, USB disk, hard disk, and can also be placed on a network (for example, the Internet). , Or other suitable vehicle).

雖然圖1、圖2及圖4中包含了以上描述的元件,但不排除在不違反發明的精神下,使用更多其他的附加元件,以達成更佳的技術效果。此外,雖然圖7至圖9、圖11及圖13的流程圖採用指定的順序來執行,但是在不違反發明精神的情況下,熟習此技藝人士可以在達到相同效果的前提下,修改這些步驟間的順序,所以,本發明並不侷限於僅使用如上所述的順序。此外,熟習此技藝人士亦可以將若干步驟整合為一個步驟,或者是除了這些步驟外,循序或平行地執行更多步驟,本發明亦不因此而侷限。Although FIG. 1, FIG. 2 and FIG. 4 include the above-described elements, it does not rule out the use of more other additional elements to achieve better technical effects without violating the spirit of the invention. In addition, although the flowcharts in Figures 7 to 9, Figure 11 and Figure 13 are executed in the specified order, those skilled in the art can modify these steps on the premise of achieving the same effect without violating the spirit of the invention. Therefore, the present invention is not limited to using only the order described above. In addition, those skilled in the art can also integrate several steps into one step, or in addition to these steps, perform more steps sequentially or in parallel, and the present invention is not limited thereby.

雖然本發明使用以上實施例進行說明,但需要注意的是,這些描述並非用以限縮本發明。相反地,此發明涵蓋了熟習此技藝人士顯而易見的修改與相似設置。所以,申請權利要求範圍須以最寬廣的方式解釋來包含所有顯而易見的修改與相似設置。Although the present invention is described using the above embodiments, it should be noted that these descriptions are not intended to limit the present invention. On the contrary, this invention covers modifications and similar arrangements that are obvious to those skilled in the art. Therefore, the scope of applied claims must be interpreted in the broadest way to include all obvious modifications and similar settings.

100:快閃記憶系統100: Flash memory system

110:主機端110: host side

130:裝置端130: device side

131:實體層131: physical layer

132:資料連結層132: Data Link Layer

133:快閃記憶控制器133: Flash memory controller

134:處理單元134: Processing Unit

136:靜態隨機存取記憶體136: Static random access memory

139:閃存存取介面139: Flash memory access interface

150:儲存單元150: storage unit

170:通用快閃記憶儲存互聯層170: Universal flash memory storage interconnection layer

139_0:存取子介面139_0: Access sub-interface

150_0~150_i:儲存子單元150_0~150_i: storage subunit

210:資料線210: data line

230_0~230_i:晶片致能控制訊號230_0~230_i: Chip enable control signal

310、330:資料平面310, 330: Data plane

310_0~310_m、330_0~330_m:塊310_0~310_m, 330_0~330_m: block

410:資料緩衝區410: data buffer

451:當前塊451: current block

453:暫存塊453: Temporary Block

455:備份塊455: backup block

510、510a、510b、530、550a、550b:剩餘空間510, 510a, 510b, 530, 550a, 550b: remaining space

S710~S730:方法步驟S710~S730: method steps

S810~S860:方法步驟S810~S860: method steps

S910~S990:方法步驟S910~S990: method steps

1010a~1014a、1010a~1014b、1050a~1050b、1030、1031:剩餘空間1010a~1014a, 1010a~1014b, 1050a~1050b, 1030, 1031: remaining space

S1110~S1150:方法步驟S1110~S1150: method steps

S1300~S1330:方法步驟S1300~S1330: Method steps

圖1為依據本發明實施例的快閃記憶體的系統架構示意圖。FIG. 1 is a schematic diagram of a system architecture of a flash memory according to an embodiment of the present invention.

圖2為依據本發明實施例的存取子介面與多個儲存子單元的連接示意圖。2 is a schematic diagram of the connection between an access sub-interface and a plurality of storage sub-units according to an embodiment of the present invention.

圖3為依據本發明實施例的資料組織示意圖。Fig. 3 is a schematic diagram of data organization according to an embodiment of the present invention.

圖4為依據本發明實施例的因應瞬間斷電回復的資料塊配置示意圖。FIG. 4 is a schematic diagram of data block configuration in response to instantaneous power failure response according to an embodiment of the present invention.

圖5及圖6為依據本發明實施例的當前塊、暫存塊及備份塊中儲存的保護資訊示意圖。5 and 6 are schematic diagrams of protection information stored in the current block, the temporary storage block, and the backup block according to an embodiment of the present invention.

圖7為依據本發明實施例的將不滿一整頁的資料寫入暫存塊的空頁面的方法流程圖。FIG. 7 is a flowchart of a method for writing data that is less than a full page into an empty page of a temporary storage block according to an embodiment of the present invention.

圖8為依據本發明實施例的將一整頁的資料寫入當前塊的空頁面的方法流程圖。FIG. 8 is a flowchart of a method for writing a full page of data into an empty page of the current block according to an embodiment of the present invention.

圖9為依據本發明實施例的於瞬間斷電回復處理中的標識正確頁面的方法流程圖。FIG. 9 is a flowchart of a method for identifying the correct page in the instantaneous power-off response processing according to an embodiment of the present invention.

圖10為依據本發明實施例的當前塊、暫存塊及備份塊中儲存的資料及保護資訊示意圖。FIG. 10 is a schematic diagram of data and protection information stored in the current block, the temporary storage block, and the backup block according to an embodiment of the present invention.

圖11為依據本發明實施例的於瞬間斷電回復處理中的遷移無法錯誤校驗修正頁面(uncorrectable ECC—UECC page)的鄰近頁面的方法流程圖。FIG. 11 is a flowchart of a method for migrating adjacent pages of an uncorrectable ECC-UECC page (uncorrectable ECC—UECC page) in an instantaneous power failure recovery process according to an embodiment of the present invention.

圖12為依據本發明實施例的UECC頁面的鄰近頁面處理的示意圖。Fig. 12 is a schematic diagram of adjacent page processing of a UECC page according to an embodiment of the present invention.

圖13為依據本發明實施例的於瞬間斷電回復處理中的遷移UECC頁面的鄰近頁面的方法流程圖。FIG. 13 is a flowchart of a method for migrating adjacent pages of a UECC page in an instantaneous power failure response process according to an embodiment of the present invention.

S1110~S1130:方法步驟 S1110~S1130: Method steps

Claims (15)

一種電腦程式產品,用於瞬間斷電回復處理,由一裝置端的一處理單元載入並執行,包含以下的程式碼: 於瞬間斷電而重啟電源後,驅動一閃存存取介面依序讀取一當前塊的頁面,其中,該當前塊為多層式單元塊或三層式單元塊; 依據該當前塊的頁面讀取狀態來標識該當前塊中最後一個正確頁面; 組態該當前塊中最後一個正確頁面的下一個頁面之後n1個頁面為虛假頁面;以及 驅動該閃存存取介面將該當前塊中該最後一個正確頁面及之前的頁面儲存到該當前塊中最後一個虛假頁面之後的空頁面,其中,儲存的頁面總數為n2個,n1及n2中的每一個為正整數。A computer program product used for instantaneous power failure recovery processing, loaded and executed by a processing unit on a device side, and contains the following code: After an instantaneous power failure and restart of the power supply, drive a flash memory access interface to sequentially read the pages of a current block, where the current block is a multi-layer cell block or a three-layer cell block; Identify the last correct page in the current block according to the page read status of the current block; Configure n1 pages after the next page of the last correct page in the current block as fake pages; and Drive the flash memory access interface to store the last correct page and the previous page in the current block to the empty page after the last false page in the current block, where the total number of pages stored is n2, among n1 and n2 Each one is a positive integer. 如請求項1所述的電腦程式產品,其中,該當前塊中該最後一個正確頁面的下一個頁面為無法錯誤校驗修正頁面。The computer program product according to claim 1, wherein the page next to the last correct page in the current block is a page that cannot be corrected for error verification. 如請求項1所述的電腦程式產品,其中,該當前塊中該最後一個正確頁面的下一個頁面為無法錯誤校驗修正頁面,且其中的資料沒有儲存於一備份塊,該備份塊為單層式單元塊。The computer program product according to claim 1, wherein the page next to the last correct page in the current block is a page that cannot be corrected by error verification, and the data in it is not stored in a backup block, and the backup block is a single Layered unit block. 如請求項1所述的電腦程式產品,其中,n1及n2中的每一個為介於2至5之間的整數。The computer program product according to claim 1, wherein each of n1 and n2 is an integer between 2 and 5. 如請求項1所述的電腦程式產品,包含以下的程式碼: 將該當前塊中該最後一個正確頁面及該之前的頁面成功儲存到該當前塊中最後一個虛假頁面之後的空頁面後,將一靜態隨機存取記憶體的一閃存主機位址映射表中關聯於該最後一個正確頁面及該之前的頁面及該虛假頁面的紀錄設為無效。The computer program product described in claim 1, including the following code: After successfully storing the last correct page in the current block and the previous page in the empty page after the last false page in the current block, associate a static random access memory with a flash host address mapping table The records on the last correct page, the previous page, and the fake page are invalidated. 如請求項5所述的電腦程式產品,其中,該當前塊中該最後一個正確頁面及該之前的頁面都是有效的。The computer program product according to claim 5, wherein the last correct page and the previous page in the current block are both valid. 一種瞬間斷電回復處理方法,由一裝置端的一處理單元執行,包含: 於瞬間斷電而重啟電源後,依序讀取一當前塊的頁面,其中,該當前塊為多層式單元塊或三層式單元塊; 依據該當前塊的頁面讀取狀態來標識該當前塊中最後一個正確頁面; 組態該當前塊中最後一個正確頁面的下一個頁面之後n1個頁面為虛假頁面;以及 將該當前塊中最後一個正確頁面及之前的頁面儲存到該當前塊中最後一個虛假頁面之後的空頁面,其中,儲存的頁面總數為n2個,n1及n2中的每一個為正整數。A method for responding to instantaneous power failure, executed by a processing unit on a device side, includes: After an instantaneous power failure and restart of the power supply, read the pages of a current block in sequence, where the current block is a multi-layer unit block or a three-layer unit block; Identify the last correct page in the current block according to the page read status of the current block; Configure n1 pages after the next page of the last correct page in the current block as fake pages; and The last correct page and the previous page in the current block are stored in the empty page after the last false page in the current block, where the total number of pages stored is n2, and each of n1 and n2 is a positive integer. 如請求項7所述的瞬間斷電回復處理方法,包含: 將該當前塊中該最後一個正確頁面及該之前的頁面成功儲存到該當前塊中最後一個虛假頁面之後的空頁面後,將一靜態隨機存取記憶體的一閃存主機位址映射表中關聯於該最後一個正確頁面及該之前的頁面及該虛假頁面的紀錄設為無效。The instantaneous power failure response processing method as described in claim 7, including: After successfully storing the last correct page in the current block and the previous page in the empty page after the last false page in the current block, associate a static random access memory with a flash host address mapping table The records on the last correct page, the previous page, and the fake page are invalidated. 如請求項8所述的瞬間斷電回復處理方法,其中,該當前塊中該最後一個正確頁面及該之前的頁面都是有效的。The instantaneous power failure response processing method described in claim 8, wherein the last correct page and the previous page in the current block are both valid. 一種瞬間斷電回復處理裝置,包含: 一閃存存取介面;以及 一處理單元,耦接該閃存存取介面,於瞬間斷電而重啟電源後,驅動該閃存存取介面依序讀取一當前塊的頁面,其中,該當前塊為多層式單元塊或三層式單元塊;依據該當前塊的頁面讀取狀態來標識該當前塊中最後一個正確頁面;組態該當前塊中最後一個正確頁面的下一個頁面之後n1個頁面為虛假頁面;以及驅動該閃存存取介面將該當前塊中該最後一個正確頁面及之前的頁面儲存到該當前塊中最後一個虛假頁面之後的空頁面,其中,儲存的頁面總數為n2個,n1及n2中的每一個為正整數。An instantaneous power failure recovery processing device, including: A flash memory access interface; and A processing unit, coupled to the flash memory access interface, drives the flash memory access interface to sequentially read the pages of a current block after the power is turned off for an instant, and the current block is a multi-layer cell block or three-layer Type unit block; identify the last correct page in the current block according to the page read status of the current block; configure n1 pages after the next page of the last correct page in the current block as false pages; and drive the flash memory The access interface stores the last correct page and the previous page in the current block to the empty page after the last false page in the current block, where the total number of pages stored is n2, and each of n1 and n2 is Positive integer. 如請求項10所述的瞬間斷電回復處理裝置,其中,該當前塊中該最後一個正確頁面的下一個頁面為無法錯誤校驗修正頁面。The instantaneous power failure response processing device according to claim 10, wherein the page next to the last correct page in the current block is a page that cannot be corrected for error verification. 如請求項10所述的瞬間斷電回復處理裝置,其中,該當前塊中該最後一個正確頁面的下一個頁面為無法錯誤校驗修正頁面,且其中的資料沒有儲存於一備份塊,該備份塊為單層式單元塊。For example, the instantaneous power failure recovery processing device according to claim 10, wherein the page next to the last correct page in the current block is a page that cannot be corrected by error verification, and the data therein is not stored in a backup block, the backup The block is a single-layer unit block. 如請求項10所述的瞬間斷電回復處理裝置,其中,n1及n2中的每一個為介於2至5之間的整數。The instantaneous power failure response processing device according to claim 10, wherein each of n1 and n2 is an integer between 2 and 5. 如請求項10所述的瞬間斷電回復處理裝置,包含: 一靜態隨機存取記憶體,耦接於該處理單元,儲存一閃存主機位址映射表, 其中,該處理單元將該當前塊中該最後一個正確頁面及該之前的頁面成功儲存到該當前塊中最後一個虛假頁面之後的空頁面後,將該閃存主機位址映射表中關聯於該最後一個正確頁面及該之前的頁面及該虛假頁面的紀錄設為無效。The instantaneous power failure response processing device described in claim 10 includes: A static random access memory, coupled to the processing unit, stores a flash host address mapping table, Wherein, after the processing unit successfully stores the last correct page in the current block and the previous page in the empty page after the last false page in the current block, it associates the flash memory host address mapping table with the last page. The records of a correct page, the previous page and the fake page are invalidated. 如請求項14所述的瞬間斷電回復處理裝置,其中,該當前塊中該最後一個正確頁面及該之前的頁面都是有效的。The instantaneous power failure response processing device according to claim 14, wherein the last correct page and the previous page in the current block are both valid.
TW108125982A 2019-07-23 2019-07-23 Method and computer program product and apparatuse for handling sudden power off recovery TWI697780B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW108125982A TWI697780B (en) 2019-07-23 2019-07-23 Method and computer program product and apparatuse for handling sudden power off recovery

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW108125982A TWI697780B (en) 2019-07-23 2019-07-23 Method and computer program product and apparatuse for handling sudden power off recovery

Publications (2)

Publication Number Publication Date
TWI697780B TWI697780B (en) 2020-07-01
TW202105192A true TW202105192A (en) 2021-02-01

Family

ID=72601789

Family Applications (1)

Application Number Title Priority Date Filing Date
TW108125982A TWI697780B (en) 2019-07-23 2019-07-23 Method and computer program product and apparatuse for handling sudden power off recovery

Country Status (1)

Country Link
TW (1) TWI697780B (en)

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073600B (en) * 2009-11-20 2012-10-17 群联电子股份有限公司 Data backup method, flash memory controller and flash memory storage system
US9164887B2 (en) * 2011-12-05 2015-10-20 Industrial Technology Research Institute Power-failure recovery device and method for flash memory
KR20160074237A (en) * 2014-12-18 2016-06-28 에스케이하이닉스 주식회사 Data storage device and operating method thereof
US9558839B2 (en) * 2015-03-09 2017-01-31 Toshiba Corporation Power fail saving modes in solid state drive with MLC memory
TWI606388B (en) * 2016-12-14 2017-11-21 慧榮科技股份有限公司 Data storage device and data maintenance method thereof
TWI628542B (en) * 2017-04-21 2018-07-01 慧榮科技股份有限公司 Methods for gc (garbage collection) por (power off recovery) of a flash memory device and apparatuses using the same
TWI668700B (en) * 2017-12-22 2019-08-11 慧榮科技股份有限公司 Data storage device and methods for processing data in the data storage device
CN109213772B (en) * 2018-09-12 2021-03-26 华东师范大学 Data storage method and NVMe storage system

Also Published As

Publication number Publication date
TWI697780B (en) 2020-07-01

Similar Documents

Publication Publication Date Title
TWI515735B (en) Data erasing method, memory control circuit unit and memory storage apparatus
US11281549B2 (en) Storage device and method of operating storage device
JP2012234363A (en) Memory system
TWI420308B (en) Block management method, memory controller and memory storage apparatus
CN112286721A (en) Instantaneous power failure recovery processing method, computer readable storage medium and device
TWI421870B (en) Data writing method for a flash memory, and controller and storage system using the same
TWI693518B (en) Data storage devices and methods for firmware failure prevention
TWI479315B (en) Memory storage device, memory controller thereof, and method for programming data thereof
TWI451439B (en) Memory storage device, memory controller thereof, and method for programming data thereof
US20200356491A1 (en) Data storage device and method for loading logical-to-physical mapping table thereof
TW201407349A (en) Data management method, memory controller and memory storage device
TWI489272B (en) Data protecting method, and memory controller and memory storage device using the same
TWI523030B (en) Method for managing buffer memory, memory controllor, and memory storage device
US11086561B2 (en) Integrated circuit memory devices with enhanced buffer memory utilization during read and write operations and methods of operating same
TWI591640B (en) Memory management method, memory control circuit unit and memory storage device
US11288183B2 (en) Operating method of memory system and host recovering data with write error
TWI509615B (en) Data storing method, and memory controller and memory storage apparatus using the same
CN112306742A (en) Instantaneous power failure recovery processing method, computer readable storage medium and device
TWI651650B (en) Memory management method and storage controller using the same
US9213597B2 (en) Memory storage device, memory controller thereof, and method for programming data thereof
US8738847B2 (en) Data writing method, and memory controller and memory storage apparatus using the same
TWI697780B (en) Method and computer program product and apparatuse for handling sudden power off recovery
TWI704450B (en) Method and computer program product and apparatuse for handling sudden power off recovery
TW202344970A (en) Risk assessment method based on data priority, memory storage device and memory control circuit unit
KR20210034456A (en) Storage device and method of operating the storage device