TWI818762B - Method and computer program product and apparatus for scheduling and executing host data-update commands - Google Patents

Method and computer program product and apparatus for scheduling and executing host data-update commands Download PDF

Info

Publication number
TWI818762B
TWI818762B TW111138323A TW111138323A TWI818762B TW I818762 B TWI818762 B TW I818762B TW 111138323 A TW111138323 A TW 111138323A TW 111138323 A TW111138323 A TW 111138323A TW I818762 B TWI818762 B TW I818762B
Authority
TW
Taiwan
Prior art keywords
host
host data
data update
command
update command
Prior art date
Application number
TW111138323A
Other languages
Chinese (zh)
Other versions
TW202416108A (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 TW111138323A priority Critical patent/TWI818762B/en
Application granted granted Critical
Publication of TWI818762B publication Critical patent/TWI818762B/en
Publication of TW202416108A publication Critical patent/TW202416108A/en

Links

Images

Abstract

The invention is related to a method, a computer program product and an apparatus for scheduling and executing host data-update commands. The method, performed by a processing unit, includes: generating third host data-update command and labeling the third host data-update command as a first-type of host data-update command according to a type and parameters of a host command for updating data from a host-side; popping out and executing all first host data-update commands of a first queue in response to a third logical address of the third host data-update command being equal to a first logical address in one of the first host data-update commands in the first queue; popping out and executing all first host data-update commands of the first queue and all second host data-update commands of a second queue in response to the third logical address of the third host data-update command being equal to a second logical address in one of the second host data-update commands in the second queue; and pushing the third host data-update command into the first queue. With the aforementioned method, errors of dirty write would be avoided.

Description

排程和執行主機資料更新命令的方法及電腦程式產品及裝置 Methods and computer program products and devices for scheduling and executing host data update commands

本發明涉及儲存裝置,尤指一種排程和執行主機資料更新命令的方法、電腦程式產品及裝置。 The present invention relates to storage devices, and in particular, to a method, computer program product and device for scheduling and executing host data update commands.

閃存通常分為NOR閃存與NAND閃存。NOR閃存為隨機存取裝置,主機端(Host Side)可於位址腳位上提供任何存取NOR閃存的位址,並及時地從NOR閃存的資料腳位上獲得儲存於該位址上的資料。相反地,NAND閃存並非隨機存取,而是序列存取。NAND閃存無法像NOR閃存一樣,可以存取任何隨機位址,主機端反而需要寫入序列的位元組(Bytes)的值到NAND閃存中,用於定義請求命令(Command)的類型(如,讀取、寫入、丟棄、抹除等),以及用在此命令上的位址。位址可指向一個頁面(閃存中寫入作業的最小資料塊)或一個區塊(閃存中抹除作業的最小資料塊)。然而,為了提昇閃存模組的資料更新效能,主機資料更新命令的執行順序可能和主機端發出的用於更新資料的相應主機命令的順序不同,因而可能發生髒寫入(Dirty Write)的情況。本發明提出一種排程和執行主機資料更新命令的方法、電腦程式產品及裝置,用於避免髒寫入的錯誤。 Flash memory is usually divided into NOR flash memory and NAND flash memory. NOR flash memory is a random access device. The host side can provide any address to access the NOR flash memory on the address pin and obtain the data stored at that address from the data pin of the NOR flash memory in a timely manner. material. On the contrary, NAND flash memory does not have random access, but sequential access. NAND flash memory cannot access any random address like NOR flash memory. Instead, the host needs to write a sequence of Bytes values into the NAND flash memory to define the type of request command (Command) (for example, read, write, discard, erase, etc.), and the address used on this command. The address can point to a page (the smallest block of data for a write operation in flash memory) or a block (the smallest block of data for an erase operation in flash memory). However, in order to improve the data update performance of the flash memory module, the execution order of host data update commands may be different from the order of corresponding host commands issued by the host to update data, so dirty writes may occur. The present invention proposes a method, computer program product and device for scheduling and executing host data update commands to avoid dirty writing errors.

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

本說明書涉及一種排程和執行主機資料更新命令的方法,由處理單元執行,包含:依據從主機端接收的用於更新資料的主機命令的類型和參數,產生第三主機資料更新命令,並且標記為第一類型的主機資料更新命令;因應第三主機資料更新命令中的第三邏輯位址相同於第一佇列中的多個第一主機資料更新命令中的一個的第一邏輯位址的情況,推出並執行第一佇列中的所有第一主機資料更新命令;因應第三邏輯位址相同於第二佇列中的多個第二主機資料更新命令中的一個的第二邏輯位址的情況,推出並執行第一佇列中的所有第一主機資料更新命令和第二佇列中的所有第二主機資料更新命令;以及將第三主機更新命令推入第一佇列。 This description relates to a method for scheduling and executing a host data update command, which is executed by a processing unit and includes: generating a third host data update command according to the type and parameters of the host command received from the host for updating data, and marking It is a first type of host data update command; in response to the third logical address in the third host data update command being the same as the first logical address of one of the plurality of first host data update commands in the first queue. situation, launch and execute all the first host data update commands in the first queue; in response to the third logical address being the same as the second logical address of one of the plurality of second host data update commands in the second queue In this case, push out and execute all the first host data update commands in the first queue and all the second host data update commands in the second queue; and push the third host update command into the first queue.

本說明書另涉及一種電腦程式產品,包含程式碼。當處理單元執行所述程式碼時,實施如上所述的排程和執行主機資料更新命令的方法。 This manual also relates to a computer program product, including program code. When the processing unit executes the program code, the method of scheduling and executing the host data update command as described above is implemented.

本說明書還另涉及一種排程和執行主機資料更新命令的裝置,包含:隨機存取記憶體,配置空間給第一佇列和第二佇列;以及處理單元,耦接隨機存取記憶體。處理單元用於依據從主機端接收的用於更新資料的主機命令的類型和參數,產生第三主機資料更新命令,並且標記為第一類型的主機資料更新命令;因應第三主機資料更新命令中的第三邏輯位址相同於第一佇列中的多個第一主機資料更新命令中的一個的第一邏輯位址的情況,推出並執行第一佇列中的所有第一主機資料更新命令;因應第三邏輯位址相同於第二佇列中的多個第二主機資料更新命令中的一個的第二邏輯位址的情況,推出並執行第一佇列中的所有第一主機資料更新命令和第二佇列中的所有第二主機資料更新命令;以及將第三主機更新命令推入第一佇列。 This specification also relates to a device for scheduling and executing host data update commands, including: a random access memory configured to configure space for the first queue and the second queue; and a processing unit coupled to the random access memory. The processing unit is configured to generate a third host data update command according to the type and parameters of the host command for updating data received from the host, and mark it as a first type of host data update command; in response to the third host data update command When the third logical address is the same as the first logical address of one of the plurality of first host data update commands in the first queue, launch and execute all the first host data update commands in the first queue. ; In response to the situation that the third logical address is the same as the second logical address of one of the plurality of second host data update commands in the second queue, launch and execute all first host data updates in the first queue command and all second host data update commands in the second queue; and pushing the third host update command into the first queue.

上述實施例的優點之一,通過如上所述的排程和執行主機資料更新命令的方法,可避免因為主機資料更新命令的執行順序和主機端發出的用於更新資料的相應主機命令的順序不同,而發生髒寫入的錯 誤。 One of the advantages of the above embodiment is that by scheduling and executing the host data update command as described above, it can be avoided that the execution sequence of the host data update command is different from the sequence of the corresponding host command issued by the host for updating data. , and a dirty write error occurs Wrong.

本發明的其他優點將搭配以下的說明和圖式進行更詳細的解說。 Other advantages of the present invention will be explained in more detail in conjunction with the following description and drawings.

10:電子裝置 10: Electronic devices

110:主機端 110: Host side

130:閃存控制器 130:Flash controller

131:主機介面 131:Host interface

132:匯流排 132:Bus

134:處理單元 134: Processing unit

136:隨機存取記憶體 136: Random access memory

138:直接記憶體存取控制器 138: Direct Memory Access Controller

139:閃存介面 139:Flash memory interface

150:閃存模組 150:Flash memory module

151:介面 151:Interface

153#0~153#15:NAND閃存單元 153#0~153#15: NAND flash memory unit

CH#0~CH#3:通道 CH#0~CH#3: Channel

CE#0~CE#3:致能訊號 CE#0~CE#3: enable signal

310:順序更新命令佇列 310: Sequential update command queue

330:隨機更新命令佇列 330: Random update command queue

S412~S462:方法步驟 S412~S462: Method steps

S512~S562:方法步驟 S512~S562: Method steps

圖1為依據本發明實施例的電子裝置的系統架構圖。 FIG. 1 is a system architecture diagram of an electronic device according to an embodiment of the present invention.

圖2為依據本發明實施例的閃存模組的示意圖。 FIG. 2 is a schematic diagram of a flash memory module according to an embodiment of the present invention.

圖3為依據本發明實施例的隨機更新命令佇列和順序更新命令佇列的示意圖。 FIG. 3 is a schematic diagram of a random update command queue and a sequential update command queue according to an embodiment of the present invention.

圖4為依據本發明實施例的排程和執行主機資料更新命令方法的流程圖。 FIG. 4 is a flow chart of a method for scheduling and executing host data update commands according to an embodiment of the present invention.

圖5為依據本發明實施例的排程和執行主機資料更新命令方法的流程圖。 FIG. 5 is a flow chart of a method for scheduling and executing host data update commands according to an embodiment of the present invention.

以下說明為完成發明的較佳實現方式,其目的在於描述本發明的基本精神,但並不用以限定本發明。實際的發明內容必須參考之後的權利要求範圍。 The following description is a preferred implementation manner for completing the invention, and its purpose is to describe the basic spirit of the invention, but is not intended to limit the invention. For the actual invention, reference must be made to the following claims.

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

於權利要求中使用如「第一」、「第二」、「第三」等詞是用來修飾權利要求中的元件,並非用來表示之間具有優先順序,前置關係,或者是一個元件先於另一個元件,或者是執行方法步驟時的時間先後順序,僅用來區別具有相同名字的元件。 The use of words such as "first", "second" and "third" in the claims is used to modify the elements in the claims, and is not used to indicate a priority, precedence relationship, or a single element. Prior to another element, or the chronological order in which method steps are performed, it 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 the other element, and intervening elements may also be present. In contrast, when an element is described as being "directly connected" or "directly coupled" to another element, there are no intervening elements present. Other words used to describe the relationship between components may also be similar Interpretation methods, such as "between" versus "directly between", or "adjacent" versus "directly adjacent", etc.

參考圖1。電子裝置10包含主機端(Host Side)110、閃存控制器130及閃存模組150,並且閃存控制器130及閃存模組150可合稱為裝置端(Device Side)。電子裝置10可實施於個人電腦、筆記型電腦(Laptop PC)、平板電腦、手機、數位相機、數位攝影機、智慧電視、智慧電冰箱等電子產品之中。主機端110與閃存控制器130的主機介面(Host Interface)137可以通用序列匯流排(Universal Serial Bus,USB)、先進技術附著(advanced technology attachment,ATA)、序列先進技術附著(serial advanced technology attachment,SATA)、快速周邊元件互聯(peripheral component interconnect express,PCI-E)、通用快閃記憶儲存(Universal Flash Storage,UFS)、嵌入式多媒體卡(Embedded Multi-Media Card,eMMC)等通訊協定彼此溝通。閃存控制器130的閃存介面(Flash Interface)139與閃存模組150可以雙倍資料率(Double Data Rate,DDR)通訊協定彼此溝通,例如,開放NAND快閃(Open NAND Flash Interface,ONFI)、雙倍資料率開關(DDR Toggle)或其他通訊協定。閃存控制器130包含處理單元134,可使用多種方式實施,如使用通用硬體(例如,單一處理器、具平行處理能力的多處理器、圖形處理器或其他具運算能力的處理器),並且在執行軟體以及/或韌體指令時,提供之後描述的功能。處理單元134通過主機介面131接收主機命令,例如寫入命令(Write Command)、丟棄命令(Discard Command)、抹寫命令(Erase Command)等,依據主機命令的類型和其中攜帶參數產生主機資料更新命令(Host Data-update Command),排程並執行這些命令。閃存控制器130另包含隨機存取記憶體(Random Access Memory,RAM)136,可實施為動態隨機存取記憶體(Dynamic Random Access Memory,DRAM)、靜態隨機存取記憶 體(Static Random Access Memory,SRAM)或上述兩者的結合,用於配置空間作為資料緩衝區,儲存從主機端110讀取並即將寫入閃存模組150的使用者資料(也可稱為主機資料),以及從閃存模組150讀取並即將輸出給主機端110的使用者資料。隨機存取記憶體136另可儲存執行過程中需要的資料,例如,變數、資料表、主機-閃存對照表(Host-to-Flash/H2F Table)、閃存-主機對照表(Flash-to-Host/F2H Table)等。閃存介面139包含NAND閃存控制器(NAND Flash Controller,NFC),提供存取閃存模組150時需要的功能,例如命令序列器(Command Sequencer)、低密度奇偶校驗(Low Density Parity Check,LDPC)等。 Refer to Figure 1. The electronic device 10 includes a host side (Host Side) 110, a flash memory controller 130 and a flash memory module 150, and the flash memory controller 130 and the flash memory module 150 can be collectively referred to as a device side (Device Side). The electronic device 10 can be implemented in electronic products such as personal computers, laptop computers (Laptop PC), tablet computers, mobile phones, digital cameras, digital video cameras, smart TVs, smart refrigerators, etc. The host interface (Host Interface) 137 between the host 110 and the flash controller 130 can be a Universal Serial Bus (USB), an advanced technology attachment (ATA), or a serial advanced technology attachment (ATA). Communication protocols such as SATA), peripheral component interconnect express (PCI-E), Universal Flash Storage (UFS), and embedded multi-media card (eMMC) communicate with each other. The flash interface (Flash Interface) 139 of the flash memory controller 130 and the flash memory module 150 can communicate with each other using a double data rate (Double Data Rate, DDR) communication protocol, such as Open NAND Flash (Open NAND Flash Interface, ONFI), dual Double data rate switch (DDR Toggle) or other communication protocols. The flash memory controller 130 includes a processing unit 134, which can be implemented in a variety of ways, such as using general-purpose hardware (eg, a single processor, multiple processors with parallel processing capabilities, a graphics processor, or other processors with computing capabilities), and When executing software and/or firmware instructions, the functions described later are provided. The processing unit 134 receives host commands through the host interface 131, such as write command (Write Command), discard command (Discard Command), erase command (Erase Command), etc., and generates a host data update command according to the type of the host command and the parameters carried therein. (Host Data-update Command), schedules and executes these commands. The flash memory controller 130 also includes a random access memory (Random Access Memory, RAM) 136, which can be implemented as a dynamic random access memory (Dynamic Random Access Memory, DRAM) or a static random access memory. Static Random Access Memory (SRAM) or a combination of the above two is used to configure space as a data buffer to store user data read from the host 110 and about to be written to the flash memory module 150 (also called the host data), and user data read from the flash memory module 150 and about to be output to the host 110 . The random access memory 136 can also store data needed in the execution process, such as variables, data tables, host-to-flash/H2F table, flash-to-host comparison table (Flash-to-Host /F2H Table) etc. The flash memory interface 139 includes a NAND Flash Controller (NFC), which provides functions required to access the flash memory module 150, such as a command sequencer (Command Sequencer) and a low density parity check (LDPC). wait.

閃存控制器130中可配置匯流排架構(Bus Architecture)132,用於讓元件之間彼此耦接以傳遞資料、位址、控制訊號等,這些元件包含主機介面131、處理單元134、RAM 136、直接記憶體存取(Direct Memory Access,DMA)控制器138、閃存介面139等。DMA控制器138可依據處理單元134的指令,通過匯流排架構132在元件間遷移資料,例如,將主機介面131或閃存介面139中特定資料緩存器(Data Buffer)的資料搬到RAM 136中的特定位址,將RAM 136中特定位址的資料搬到將主機介面131或閃存介面139中的特定資料緩存器等。 The flash memory controller 130 can be configured with a bus architecture (Bus Architecture) 132 for coupling components to each other to transmit data, addresses, control signals, etc. These components include the host interface 131, the processing unit 134, the RAM 136, Direct Memory Access (DMA) controller 138, flash memory interface 139, etc. The DMA controller 138 can migrate data between components through the bus architecture 132 according to the instructions of the processing unit 134, for example, move the data from a specific data buffer (Data Buffer) in the host interface 131 or the flash memory interface 139 to the RAM 136. At a specific address, the data at a specific address in the RAM 136 is moved to a specific data register in the host interface 131 or the flash memory interface 139, etc.

閃存模組150提供大量的儲存空間,通常是數百個千兆位元組(Gigabytes,GB),甚至是數個萬億位元組(Terabytes,TB),用於儲存大量的使用者資料,例如高解析度圖片、影片等。閃存模組150中包含控制電路以及記憶體陣列,記憶體陣列中的記憶單元可組態為單層式單元(Single Level Cells,SLCs)、多層式單元(Multiple Level Cells,MLCs)三層式單元(Triple Level Cells,TLCs)、四層式單元(Quad-Level Cells QLCs)或上述的任意組合。處理單元134通過閃存介面139寫入使用者資料到閃存模組150中的 指定位址(目的位址),以及從閃存模組150中的指定位址(來源位址)讀取使用者資料。閃存介面139使用數個電子訊號來協調閃存控制器130與閃存模組150間的資料與命令傳遞,包含資料線(Data Line)、時脈訊號(Clock Signal)與控制訊號(Control Signal)。資料線可用於傳遞命令、位址、讀出及寫入的資料;控制訊號線可用於傳遞晶片致能(Chip Enable,CE)、位址提取致能(Address Latch Enable,ALE)、命令提取致能(Command Latch Enable,CLE)、寫入致能(Write Enable,WE)等控制訊號。 The flash memory module 150 provides a large amount of storage space, usually hundreds of gigabytes (GB) or even several terabytes (TB), for storing a large amount of user data. For example, high-resolution pictures, videos, etc. The flash memory module 150 includes a control circuit and a memory array. The memory cells in the memory array can be configured as single-level cells (Single Level Cells, SLCs) and multi-level cells (Multiple Level Cells, MLCs). (Triple Level Cells, TLCs), Quad-Level Cells QLCs, or any combination of the above. The processing unit 134 writes user data into the flash memory module 150 through the flash memory interface 139 Specify an address (destination address), and read user data from the specified address (source address) in the flash memory module 150 . The flash memory interface 139 uses several electronic signals to coordinate the transmission of data and commands between the flash memory controller 130 and the flash memory module 150, including data lines (Data Line), clock signals (Clock Signal) and control signals (Control Signal). Data lines can be used to transmit commands, addresses, read and write data; control signal lines can be used to transmit chip enable (Chip Enable, CE), address extraction enable (Address Latch Enable, ALE), command extraction enable Control signals such as Command Latch Enable (CLE) and Write Enable (WE).

參考圖2,閃存模組150中的介面151可包含四個輸出入通道(I/O channels,以下簡稱通道)CH#0至CH#3,每一個通道連接四個NAND閃存單元,例如,通道CH#0連接NAND閃存單元153#0、153#4、153#8及153#12。每個NAND閃存單元可封裝為獨立的芯片(die)。閃存介面139可通過介面151發出致能訊號CE#0至CE#3中的一個來致能NAND閃存單元153#0至153#3、153#4至153#7、153#8至153#11、或153#12至153#15,接著以並行的方式從致能的NAND閃存單元讀取使用者資料,或者寫入使用者資料至致能的NAND閃存單元。 Referring to Figure 2, the interface 151 in the flash memory module 150 may include four input/output channels (I/O channels, hereinafter referred to as channels) CH#0 to CH#3, each channel is connected to four NAND flash memory units, for example, channel CH#0 is connected to NAND flash memory cells 153#0, 153#4, 153#8 and 153#12. Each NAND flash memory cell can be packaged as an independent chip (die). The flash memory interface 139 can send one of the enable signals CE#0 to CE#3 through the interface 151 to enable the NAND flash memory units 153#0 to 153#3, 153#4 to 153#7, and 153#8 to 153#11. , or 153#12 to 153#15, and then read user data from the enabled NAND flash memory unit in a parallel manner, or write user data to the enabled NAND flash memory unit.

為了提升資料更新的效率,閃存控制器130可將資料更新的長而連續的主機命令和短而分散的主機命令分開排程及執行。閃存控制器130依據主機命令的類型和其中攜帶參數產生主機資料更新命令,並且主機資料更新命令可表示為以下的資料結構:{SN,LA,Len,PA},其中,SN代表主機命令的序號,LA代表開始邏輯位址,Len代表邏輯位址的長度,PA代表開始實體位址。主機命令的序號可代表主機命令到達閃存控制器130的時間順序,數字越小代表越早到達閃存控制器130。邏輯位址可為邏輯區塊位址(Logical Block Address,LBA)、主機頁面編號(Host Page Number)等。一個邏輯區塊位址可指向512K位元組的資料,而一個主機頁面可指向八個 連續的邏輯區塊位址(也就是4K位元組)的資料。實體位址可包含通道編號、邏輯單位號(Logical Unit Number,LUN)、頁面編號、區段編號,或者以上的任意組合的資訊,能夠讓閃存介面139解譯來和閃存模組150進行一系列的訊號交互,完成特定的資料寫入操作。當實體位址為全“0”(也就是空值NULL)時,代表此資料更新命令是根據主機丟棄命令或者主機抹寫命令所產生的。當實體位址能夠被閃存介面139解譯出時,代表此資料更新命令是根據主機寫入命令所產生的。舉例來說,根據LBA#100~LBA#115的主機寫入命令,可產生主機資料更新命令{1,100,16,PA={CH#0,LUN#1,P#0~P#1}},其中的實體位址可由閃存控制器130依據閃存模組150的實體設置和預設的規則來指派。根據LBA#100~LBA#115的主機丟棄或者抹寫命令,可產生資料更新命令{2,100,16,PA=NULL}。 In order to improve the efficiency of data update, the flash memory controller 130 can separately schedule and execute long and continuous host commands and short and scattered host commands for data update. The flash memory controller 130 generates a host data update command according to the type of the host command and the parameters carried therein, and the host data update command can be expressed as the following data structure: {SN, LA, Len, PA}, where SN represents the sequence number of the host command. , LA represents the starting logical address, Len represents the length of the logical address, and PA represents the starting physical address. The sequence number of the host command may represent the time sequence in which the host command reaches the flash memory controller 130 . The smaller the number, the earlier it reaches the flash memory controller 130 . The logical address may be a logical block address (Logical Block Address, LBA), host page number (Host Page Number), etc. A logical block address can point to 512K bytes of data, and a host page can point to eight Data of continuous logical block addresses (that is, 4K bytes). The physical address may include a channel number, a logical unit number (LUN), a page number, a segment number, or any combination of the above information, allowing the flash memory interface 139 to interpret and perform a series of operations with the flash memory module 150 Signal interaction to complete specific data writing operations. When the physical address is all "0" (that is, the null value NULL), it means that the data update command is generated based on the host discard command or the host erase command. When the physical address can be interpreted by the flash memory interface 139, it means that the data update command is generated according to the host write command. For example, according to the host write command of LBA#100~LBA#115, the host data update command {1,100,16,PA={CH#0,LUN#1,P#0~P#1}} can be generated. The physical address may be assigned by the flash memory controller 130 according to the physical settings of the flash memory module 150 and preset rules. According to the host discard or erase command of LBA#100~LBA#115, the data update command {2,100,16,PA=NULL} can be generated.

參考圖3,RAM 136配置空間給順序更新命令佇列(Sequential-update Command Queue,SCQ)310,用於依照到達閃存控制器130的時間順序儲存主機端110發送的順序主機資料更新命令,例如邏輯區塊位址長度(Logical Block Address,LBA Length)大於1的主機資料更新命令。RAM 136還配置空間給隨機更新命令佇列(Random-update Command Queue,RCQ)330,用於依照到達閃存控制器130的時間順序儲存主機端110發送的隨機主機資料更新命令,例如LBA長度等於1的主機資料更新命令。順序更新命令佇列310和隨機更新命令佇列330中的任何一個可儲存數百或者數千筆的主機資料更新命令。順序更新命令佇列310和隨機更新命令佇列330可為循環式佇列(Cyclical Queue),其操作基本原則是由結束位置(如指標T所指的位置)新增主機資料更新命令(可稱為入列),並且由開始位置(如指標H所指的位置)移出主機資料更新命令(可稱為出列)。也就是說,第一個新增至佇列的命令,也將會是第一個被移出和處理的,符合先進先出(First-In First-Out,FIFO)的原則。 Referring to Figure 3, the RAM 136 configures space for a Sequential-update Command Queue (SCQ) 310, which is used to store sequential host data update commands sent by the host 110 according to the time sequence when they arrive at the flash controller 130, such as logical Host data update command with block address length (Logical Block Address, LBA Length) greater than 1. The RAM 136 also configures space for a Random-update Command Queue (RCQ) 330, which is used to store random host data update commands sent by the host 110 according to the time sequence when they arrive at the flash controller 130. For example, the LBA length is equal to 1. Host data update command. Either of the sequential update command queue 310 and the random update command queue 330 can store hundreds or thousands of host data update commands. The sequential update command queue 310 and the random update command queue 330 can be cyclic queues (Cyclical Queue), and the basic principle of their operation is to add a host data update command (which can be called is enqueuing), and the host data update command is moved out from the starting position (such as the position pointed by pointer H) (which can be called dequeuing). In other words, the first command added to the queue will also be the first to be removed and processed, complying with the First-In First-Out (FIFO) principle.

舉例來說,處理單元134在執行韌體轉換層(Firmware Translation Layer,FTL)的程式碼時,完成如下的主機資料更新命令的產生和入列:首先,通過主機介面131依序收到5個主機寫入命令:W1={LBA#200~215,D1};W2={LBA#300,D2}:W3={LBA#400~415,D3}:W4={LBA#300~315,D4}:W5={LBA#200,D5}。主機寫入命令W1指示寫入邏輯位址LBA#200~215的資料D1,主機寫入命令W2指示寫入邏輯位址LBA#300的資料D2,主機寫入命令W3指示寫入邏輯位址LBA#400~415的資料D3,主機寫入命令W4指示寫入邏輯位址LBA#300~315的資料D4,主機寫入命令W5指示寫入邏輯位址LBA#200的資料D5。接著,分別為主機寫入命令W1至W5產生主機資料更新命令DU1={1,200,16,PA#1};DU2={2,300,1,PA#2};DU3={3,400,16,PA#3};DU4={4,300,16,PA#4};DU5={5,200,1,PA#5}。經過更新類型的判斷,依序將主機資料更新命令DU1、DU3、DU4(可稱為順序更新命令,Sequential Update Command,SUC)推入順序更新命令佇列310,將主機資料更新命令DU2、DU5(可稱為隨機更新命令,Random Update Command,RUC)推入隨機更新命令佇列330。 For example, when the processing unit 134 executes the program code of the Firmware Translation Layer (FTL), it completes the generation and enqueuing of the host data update command as follows: First, five commands are received sequentially through the host interface 131 Host write command: W1={LBA#200~215,D1}; W2={LBA#300,D2}: W3={LBA#400~415,D3}: W4={LBA#300~315,D4} :W5={LBA#200,D5}. The host write command W1 instructs the writing of data D1 at logical address LBA#200~215, the host write command W2 instructs the writing of data D2 at logical address LBA#300, and the host write command W3 instructs the writing of logical address LBA The data D3 of #400~415, the host write command W4 instructs to write the data D4 of the logical address LBA#300~315, and the host write command W5 instructs the write of the data D5 of the logical address LBA#200. Then, the host data update commands DU1={1,200,16,PA#1}; DU2={2,300,1,PA#2}; DU3={3,400,16,PA#3 are generated for the host write commands W1 to W5 respectively. }; DU4={4,300,16,PA#4}; DU5={5,200,1,PA#5}. After judging the update type, the host data update commands DU1, DU3, and DU4 (which can be called sequential update commands, Sequential Update Command, SUC) are pushed into the sequential update command queue 310 in sequence, and the host data update commands DU2, DU5 ( A random update command (RUC), which may be called a random update command (RUC), is pushed into the random update command queue 330 .

主機資料更新命令DU2={2,300,1,PA#2}和主機資料更新命令DU4={4,300,16,PA#4}中含有相同的邏輯位址LBA#300,而且DU2必須早於DU4被執行。主機資料更新命令DU1={1,200,16,PA#1}和主機資料更新命令DU5={5,200,1,PA#5}中含有相同的邏輯位址LBA#200,而且DU1必須早於DU5被執行。 The host data update command DU2={2,300,1,PA#2} and the host data update command DU4={4,300,16,PA#4} contain the same logical address LBA#300, and DU2 must be executed earlier than DU4 . The host data update command DU1={1,200,16,PA#1} and the host data update command DU5={5,200,1,PA#5} contain the same logical address LBA#200, and DU1 must be executed earlier than DU5 .

在一些實施方式中,閃存控制器130可採取順序更新優先(Sequential-update First)的原則來移出和處理順序更新命令佇列310和隨機更新命令佇列330中的主機資料更新命令。也就是說,閃存控制器130先執行完主機資料更新命令DU1、DU3、DU4之後,再 執行主機資料更新命令DU2、DU5。然而,因為DU2的執行晚於DU4,造成邏輯位址LBA#300的最終更新結果並不是主機端110期望的執行完主機資料更新命令DU4的結果,發生髒寫入的情況。 In some embodiments, the flash memory controller 130 may adopt a Sequential-update First principle to remove and process the host data update commands in the sequential update command queue 310 and the random update command queue 330 . That is to say, the flash memory controller 130 first executes the host data update commands DU1, DU3, and DU4, and then Execute the host data update commands DU2 and DU5. However, because DU2 is executed later than DU4, the final update result of the logical address LBA#300 is not the result expected by the host end 110 after executing the host data update command DU4, and a dirty write occurs.

在另一些實施方式中,閃存控制器130可採取隨機更新(Random-update First)優先的原則來移出和處理順序更新命令佇列310和隨機更新命令佇列330中的主機資料更新命令。也就是說,閃存控制器130先執行完主機資料更新命令DU2、DU5之後,再執行主機資料更新命令DU1、DU3、DU4。然而,因為DU1的執行晚於DU5,造成邏輯位址LBA#200的最終更新結果並不是主機端110期望的執行完主機資料更新命令DU5的結果,發生髒寫入的情況。 In other embodiments, the flash memory controller 130 may adopt a random update (Random-update First) principle to remove and process the host data update commands in the sequential update command queue 310 and the random update command queue 330 . That is to say, the flash memory controller 130 first executes the host data update commands DU2 and DU5, and then executes the host data update commands DU1, DU3, and DU4. However, because DU1 is executed later than DU5, the final update result of the logical address LBA#200 is not the result expected by the host end 110 after executing the host data update command DU5, and a dirty write occurs.

為了解決如上所述實施方式所產生的髒寫入的問題,本發明實施例提出一種主機資料更新命令的排程機制。參考圖4所示的方法流程圖,此方法由處理單元134在載入和執行FTL時執行,不斷地從主機端110接收資料更新的主機命令,根據主機命令的類型和其中攜帶的參數產生主機資料更新命令,並且使用順序更新命令佇列310和隨機更新命令佇列330來排程這些主機資料更新命令,並且使用預設的規則來執行這些主機資料更新命令。詳細說明如下: In order to solve the problem of dirty writing caused by the above embodiments, embodiments of the present invention propose a scheduling mechanism for host data update commands. Referring to the method flow chart shown in Figure 4, this method is executed by the processing unit 134 when loading and executing FTL, continuously receiving host commands for data update from the host terminal 110, and generating host commands according to the type of the host command and the parameters carried therein. data update commands, and use the sequential update command queue 310 and the random update command queue 330 to schedule these host data update commands, and use preset rules to execute these host data update commands. The details are as follows:

步驟S412:判斷是否通過主機介面131從主機端110接收到資料更新的主機命令,例如主機寫入、丟棄、抹寫命令等。如果是,流程繼續進行步驟S422的處理;否則,流程繼續進行步驟S414的處理。 Step S412: Determine whether a host command for data update is received from the host 110 through the host interface 131, such as a host write, discard, erase command, etc. If yes, the process continues to the process of step S422; otherwise, the process continues to the process of step S414.

步驟S414:如果目前沒有待處理的資料更新的主機命令時,等待一段預設的時間。 Step S414: If there is currently no pending data update host command, wait for a preset period of time.

步驟S422:獲取資料更新的主機命令的內容。 Step S422: Obtain the content of the host command for data update.

步驟S424:根據主機命令的類型和其中攜帶的參數產生主機資料更新命令,並且依據主機命令中攜帶的邏輯位址長度將此主機資料更新命令標記為順序更新命令(SUC)或者隨機更新命令(RUC)。主機資料更新命令的資料結構和產生細節,以及標記為SUC或者 RUC的判斷細節,可參考如上段落的說明,為求簡明不再贅述。 Step S424: Generate a host data update command according to the type of the host command and the parameters carried therein, and mark the host data update command as a sequential update command (SUC) or a random update command (RUC) according to the logical address length carried in the host command. ). The data structure and generation details of the host data update command, and whether it is marked as SUC or For the details of RUC's judgment, please refer to the description in the above paragraph, and will not be repeated for the sake of simplicity.

步驟S432:判斷此主機資料更新命令是否為SUC且SCQ 310已經滿了,或者此主機資料更新命令中的邏輯位址是否已經存在於SCQ 310的其他主機資料更新命令之中。如果是,流程繼續進行步驟S434的處理;否則,流程繼續進行步驟S442的處理。 Step S432: Determine whether the host data update command is SUC and the SCQ 310 is full, or whether the logical address in the host data update command already exists in other host data update commands of the SCQ 310. If yes, the flow continues to the processing of step S434; otherwise, the flow continues to the processing of step S442.

步驟S434:依序推出和執行SCQ 310中的所有SUC。例如,針對一個或多個寫入資料的SUC,處理單元134可從RAM 136的緩衝區讀取待寫入的主機資料,驅動閃存介面139以將主機資料寫入特定實體位址,接著,更新F2H表和/或H2F表中的相應紀錄以反映已執行的資料寫入操作。針對一個或多個丟棄資料的SUC,處理單元134可從RAM 136的暫存H2F中刪除特定邏輯位址的紀錄。針對一個或多個抹寫資料的SUC,處理單元134可驅動閃存介面139以抹寫特定實體位址,接著,更新H2F表中的相應紀錄以反映已執行的資料抹寫操作。步驟S434可確保SCQ 310中具有全部或者部分相同邏輯位址的SUC的執行早於此主機資料更新命令的執行。 Step S434: Launch and execute all SUCs in SCQ 310 sequentially. For example, for one or more SUCs that write data, the processing unit 134 may read the host data to be written from the buffer of the RAM 136, drive the flash memory interface 139 to write the host data to a specific physical address, and then update Corresponding records in the F2H table and/or H2F table to reflect the data write operations that have been performed. For one or more SUCs that discard data, the processing unit 134 may delete the record of the specific logical address from the temporary storage H2F of the RAM 136 . For one or more SUCs that erase data, the processing unit 134 can drive the flash memory interface 139 to erase the specific physical address, and then update the corresponding record in the H2F table to reflect the data erase operation that has been performed. Step S434 can ensure that the SUC with all or part of the same logical address in SCQ 310 is executed earlier than the execution of the host data update command.

步驟S442:判斷此主機資料更新命令是否為RUC且RCQ 330已經滿了,或者此主機資料更新命令中的邏輯位址是否已經存在於RCQ 330的其他主機資料更新命令之中。如果是,流程繼續進行步驟S444的處理;否則,流程繼續進行步驟S452的處理。 Step S442: Determine whether the host data update command is RUC and the RCQ 330 is full, or whether the logical address in the host data update command already exists in other host data update commands of the RCQ 330. If yes, the flow continues to the processing of step S444; otherwise, the flow continues to the processing of step S452.

步驟S444:依序推出和執行RCQ 330中的所有RUC。例如,針對一個或多個寫入資料的RUC,處理單元134可從RAM 136的緩衝區讀取待寫入的主機資料,驅動閃存介面139以將主機資料寫入特定實體位址,接著,更新F2H表和/或H2F表中的相應紀錄以反映已執行的資料寫入操作。針對一個或多個丟棄資料的RUC,處理單元134可從RAM 136的暫存H2F中刪除特定邏輯位址的紀錄。針對一個或多個抹寫資料的RUC,處理單元134可驅動閃存介面139以抹寫特定實體位址,接著,更新H2F表中的相應紀錄以反映已執行的資料抹 寫操作。步驟S444可確保RCQ 330中具有全部或者部分相同邏輯位址的RUC的執行早於此主機資料更新命令的執行。 Step S444: Launch and execute all RUCs in RCQ 330 in sequence. For example, for one or more RUCs that write data, the processing unit 134 may read the host data to be written from the buffer of the RAM 136, drive the flash memory interface 139 to write the host data to a specific physical address, and then update Corresponding records in the F2H table and/or H2F table to reflect the data write operations that have been performed. In response to one or more RUCs that discard data, the processing unit 134 may delete the record of the specific logical address from the temporary H2F of the RAM 136 . In response to one or more RUCs that erase data, the processing unit 134 can drive the flash memory interface 139 to erase the specific physical address, and then update the corresponding record in the H2F table to reflect the data erase that has been performed. write operation. Step S444 can ensure that the RUC with all or part of the same logical address in RCQ 330 is executed earlier than the execution of the host data update command.

步驟S452:判斷此主機資料更新命令是否為SUC且其中的邏輯位址已經存在於RCQ 330的其他主機資料更新命令之中,或者此主機資料更新命令是否為RUC且其中的邏輯位址已經存在於SCQ 310的其他主機資料更新命令之中。如果是,流程繼續進行步驟S454的處理;否則,流程繼續進行步驟S462的處理。 Step S452: Determine whether the host data update command is SUC and the logical address in it already exists in other host data update commands of RCQ 330, or whether the host data update command is RUC and the logical address in it already exists in Among other host data update commands of SCQ 310. If yes, the flow continues to the processing of step S454; otherwise, the flow continues to the processing of step S462.

步驟S454:依序推出和執行SCQ 310中的所有SUC,以及RCQ 330中的所有RUC。執行SUC和RUC的技術細節可參考步驟S434和S444的說明,為求簡明不再贅述。步驟S454可確保SCQ 310或RCQ 330中具有全部或者部分相同邏輯位址的SUC或RUC的執行早於此主機資料更新命令的執行。 Step S454: Launch and execute all SUCs in SCQ 310 and all RUCs in RCQ 330 in sequence. For technical details of executing SUC and RUC, please refer to the description of steps S434 and S444, which will not be described again for the sake of simplicity. Step S454 can ensure that the SUC or RUC with all or part of the same logical address in the SCQ 310 or RCQ 330 is executed earlier than the execution of the host data update command.

步驟S462:將此主機資料更新命令推入SCQ 310和RCQ 330中的相應一個。如果此主機資料更新命令為SUC,則推入SCQ 310。如果此主機資料更新命令為RUC,則推入RCQ 330。 Step S462: Push the host information update command to the corresponding one of SCQ 310 and RCQ 330. If this host data update command is SUC, SCQ 310 is pushed. If this host profile update command is RUC, RCQ 330 is pushed.

以下舉實例來說明圖4的方法執行。一開始,SCQ 310和RCQ 330為空的佇列。 An example is given below to illustrate the execution of the method in Figure 4. Initially, SCQ 310 and RCQ 330 have empty queues.

處理單元134在時間點t1收到主機寫入命令W1={LBA#200~215,D1}(步驟S422),根據W1的內容產生主機資料更新命令DU1={1,200,16,PA#1}並標記為SUC(步驟S424)。因為三個判斷都不符合,主機資料更新命令DU1={1,200,16,PA#1}推入SCQ 310,此時SCQ 310包含{DU1},而RCQ 330為空佇列(步驟S462)。 The processing unit 134 receives the host write command W1={LBA#200~215,D1} at time point t1 (step S422), generates the host data update command DU1={1,200,16,PA#1} according to the content of W1 and Marked as SUC (step S424). Because the three judgments are not consistent, the host data update command DU1={1,200,16,PA#1} is pushed into the SCQ 310. At this time, the SCQ 310 contains {DU1}, and the RCQ 330 is an empty queue (step S462).

處理單元134在時間點t2收到主機寫入命令W2={LBA#300,D2}(步驟S422),根據W2的內容產生主機資料更新命令DU2={2,300,1,PA#2}並標記為RUC(步驟S424)。因為三個判斷都不符合,主機資料更新命令DU2={2,300,1,PA#2}推入RCQ 330,此時SCQ 310包含{DU1},而RCQ 330包含{DU2}(步驟S462)。 The processing unit 134 receives the host write command W2={LBA#300,D2} at time point t2 (step S422), generates the host data update command DU2={2,300,1,PA#2} according to the content of W2 and marks it as RUC (step S424). Because the three judgments are not consistent, the host data update command DU2={2,300,1,PA#2} is pushed into RCQ 330. At this time, SCQ 310 contains {DU1}, and RCQ 330 contains {DU2} (step S462).

處理單元134在時間點t3收到主機寫入命令W3={LBA#400~415,D3}(步驟S422),根據W3的內容產生主機資料更新命令DU3={3,400,16,PA#3}並標記為SUC(步驟S424)。因為三個判斷都不符合,主機資料更新命令DU3={3,400,16,PA#3}推入SCQ 310,此時SCQ 310包含{DU1,DU3},而RCQ 330包含{DU2}(步驟S462)。 The processing unit 134 receives the host write command W3={LBA#400~415,D3} at time point t3 (step S422), generates the host data update command DU3={3,400,16,PA#3} according to the content of W3 and Marked as SUC (step S424). Because the three judgments are not consistent, the host data update command DU3={3,400,16,PA#3} is pushed into SCQ 310. At this time, SCQ 310 contains {DU1, DU3}, and RCQ 330 contains {DU2} (step S462) .

處理單元134在時間點t4收到主機寫入命令W4={LBA#300~315,D4}(步驟S422),根據W4的內容產生主機資料更新命令DU4={4,300,16,PA#4}並標記為SUC(步驟S424)。因為主機資料更新命令DU4中的邏輯位址LBA#300~315部分相同於RCQ 330中的DU2中的邏輯位址LBA#300(步驟S452中”是”的路徑),依序推出和執行SCQ 310中的主機資料更新命令DU1和DU3,以及RCQ 330中的主機資料更新命令DU2(步驟S454)。接著,將主機資料更新命令DU4={4,300,16,PA#4}推入SCQ 310,此時SCQ 310包含{DU4},而RCQ 330為空佇列(步驟S462)。 The processing unit 134 receives the host write command W4={LBA#300~315,D4} at time point t4 (step S422), generates the host data update command DU4={4,300,16,PA#4} according to the content of W4 and Marked as SUC (step S424). Because the logical address LBA#300~315 in the host data update command DU4 is partially the same as the logical address LBA#300 in DU2 in the RCQ 330 (the "yes" path in step S452), SCQ 310 is launched and executed in sequence. The host data update commands DU1 and DU3 in RCQ 330, and the host data update command DU2 in RCQ 330 (step S454). Next, the host data update command DU4={4,300,16,PA#4} is pushed into the SCQ 310. At this time, the SCQ 310 contains {DU4} and the RCQ 330 is an empty queue (step S462).

處理單元134在時間點t5收到主機寫入命令W5={LBA#200,D5}(步驟S422),根據W5的內容產生主機資料更新命令DU5={5,200,1,PA#5}並標記為RUC(步驟S424)。因為三個判斷都不符合,主機資料更新命令DU5={5,200,1,PA#5}推入RCQ 330,此時SCQ 310包含{DU4},而RCQ 330包含{DU5}(步驟S462)。 The processing unit 134 receives the host write command W5={LBA#200,D5} at time point t5 (step S422), generates the host data update command DU5={5,200,1,PA#5} according to the content of W5 and marks it as RUC (step S424). Because the three judgments are not consistent, the host data update command DU5={5,200,1,PA#5} is pushed into RCQ 330. At this time, SCQ 310 contains {DU4} and RCQ 330 contains {DU5} (step S462).

為了解決如上所述實施方式所產生的髒寫入的問題,本發明實施例提出另一種主機資料更新命令的排程機制。參考圖5所示的方法流程圖,此方法由處理單元134在載入和執行FTL時執行,不斷地從主機端110接收資料更新的主機命令,根據主機命令的類型和其中攜帶的參數產生主機資料更新命令,並且使用順序更新命令佇列310和隨機更新命令佇列330來排程這些主機資料更新命令,並且使用預設的規則來執行這些主機資料更新命令。詳細說明如下:步驟S512、S514、S522、S524的技術內容分別類似於步驟S412、 S414、S422、S424,為求簡明,不再贅述。 In order to solve the problem of dirty writing caused by the above embodiments, embodiments of the present invention propose another scheduling mechanism for host data update commands. Referring to the method flow chart shown in Figure 5, this method is executed by the processing unit 134 when loading and executing FTL, continuously receiving host commands for data update from the host terminal 110, and generating host commands according to the type of the host command and the parameters carried therein. data update commands, and use the sequential update command queue 310 and the random update command queue 330 to schedule these host data update commands, and use preset rules to execute these host data update commands. The detailed description is as follows: The technical contents of steps S512, S514, S522, and S524 are respectively similar to steps S412, S414, S422, and S424 will not be described in detail for the sake of simplicity.

步驟S532:判斷SCQ 310是否已經滿了。如果是,流程繼續進行步驟S534的處理;否則,流程繼續進行步驟S542的處理。 Step S532: Determine whether SCQ 310 is full. If yes, the flow continues to the processing of step S534; otherwise, the flow continues to the processing of step S542.

步驟S534的技術內容類似於步驟S434,為求簡明,不再贅述。 The technical content of step S534 is similar to step S434, and will not be described again for simplicity.

步驟S542:判斷RCQ 330是否已經滿了。如果是,流程繼續進行步驟S544的處理;否則,流程繼續進行步驟S552的處理。 Step S542: Determine whether RCQ 330 is full. If yes, the flow continues to the processing of step S544; otherwise, the flow continues to the processing of step S552.

步驟S544的技術內容類似於步驟S444,為求簡明,不再贅述。 The technical content of step S544 is similar to step S444, and will not be described again for simplicity.

步驟S552:判斷此主機資料更新命令中的邏輯位址是否和SCQ 310和RCQ 330中的任何SUC或RUC的邏輯位址相同。如果是,流程繼續進行步驟S554的處理;否則,流程繼續進行步驟S562的處理。 Step S552: Determine whether the logical address in the host data update command is the same as the logical address of any SUC or RUC in SCQ 310 and RCQ 330. If yes, the flow continues to the processing of step S554; otherwise, the flow continues to the processing of step S562.

步驟S554:將重複的邏輯位址從SCQ 310和RCQ 330中的相應主機資料更新命令刪除。 Step S554: Delete the duplicate logical addresses from the corresponding host data update commands in SCQ 310 and RCQ 330.

步驟S562的技術內容類似於步驟S462,為求簡明,不再贅述。 The technical content of step S562 is similar to step S462, and will not be described again for simplicity.

以下舉實例來說明圖5的方法執行。一開始,SCQ 310和RCQ 330為空的佇列。處理單元134分別在時間點t1、t2、t3收到主機寫入命令W1={LBA#200~215,D1}、W2={LBA#300,D2}、W3={LBA#400~415,D3}(步驟S522),分別根據W1、W2、W3的內容產生主機資料更新命令DU1={1,200,16,PA#1}、DU2={2,300,1,PA#2}、DU3={3,400,16,PA#3},並分別標記為SUC、RUC、SUC(步驟S524)。因為主機資料更新命令DU1、DU2、DU3都無法通過三個判斷,主機資料更新命令DU1、DU3推入SCQ 310,主機更新命令DU2推入RCQ 330(步驟S562)。在主機寫入命令W3處理完後,SCQ 310包含{DU1,DU3},而RCQ 330包含{DU2}。 An example is given below to illustrate the execution of the method in Figure 5. Initially, SCQ 310 and RCQ 330 have empty queues. The processing unit 134 receives the host write commands W1={LBA#200~215,D1}, W2={LBA#300,D2}, and W3={LBA#400~415,D3 at time points t1, t2, and t3 respectively. } (step S522), generate host data update commands DU1={1,200,16,PA#1}, DU2={2,300,1,PA#2}, and DU3={3,400,16 based on the contents of W1, W2, and W3 respectively. ,PA#3}, and marked as SUC, RUC, and SUC respectively (step S524). Because the host data update commands DU1, DU2, and DU3 cannot pass the three judgments, the host data update commands DU1 and DU3 are pushed into the SCQ 310, and the host update command DU2 is pushed into the RCQ 330 (step S562). After the host write command W3 is processed, SCQ 310 contains {DU1, DU3}, and RCQ 330 contains {DU2}.

處理單元134在時間點t4收到主機寫入命令W4={LBA#300~315,D4}(步驟S522),根據W4的內容產生主機資料更新命令DU4={4,300,16,PA#4}並標記為SUC(步驟S524)。因為主機資料更新命令DU4中的邏輯位址LBA#300~315相同於RCQ 330中的DU2中的邏輯位址 LBA#300(步驟S552中”是”的路徑),將重複的邏輯位址從RCQ 330中的DU2刪除,使得原本的主機資料更新命令DU2={2,300,1,PA#2},改變成為DU2’={2,NULL,0,NULL}(步驟S554)。接著,將主機資料更新命令DU4={4,300,16,PA#4}推入SCQ 310,此時SCQ 310包含{DU1,DU3,DU4},而RCQ 330包含{DU2’}(步驟S562)。在這裡需要注意的是,由於主機資料更新命令DU2’的邏輯位址為NULL,此命令將來從RCQ 330推出後,並不會被執行。 The processing unit 134 receives the host write command W4={LBA#300~315,D4} at time point t4 (step S522), generates the host data update command DU4={4,300,16,PA#4} according to the content of W4 and Marked as SUC (step S524). Because the logical addresses LBA#300~315 in the host data update command DU4 are the same as the logical addresses in DU2 in RCQ 330 LBA#300 (the "Yes" path in step S552) deletes the duplicate logical address from DU2 in RCQ 330, so that the original host data update command DU2={2,300,1,PA#2} is changed to DU2 '={2,NULL,0,NULL} (step S554). Next, the host data update command DU4={4,300,16,PA#4} is pushed into the SCQ 310. At this time, the SCQ 310 contains {DU1, DU3, DU4}, and the RCQ 330 contains {DU2'} (step S562). It should be noted here that since the logical address of the host data update command DU2’ is NULL, this command will not be executed after it is launched from RCQ 330 in the future.

處理單元134在時間點t5收到主機寫入命令W5={LBA#200,D5}(步驟S522),根據W5的內容產生主機資料更新命令DU5={5,200,1,PA#5}並標記為RUC(步驟S524)。因為主機資料更新命令DU5中的邏輯位址LBA#200部分相同於RCQ 330中的DU1中的邏輯位址LBA#200~215(步驟S552中”是”的路徑),將重複的邏輯位址從SCQ 310中的DU1刪除,使得原本的主機資料更新命令DU1={1,200,16,PA#1},改變成為DU1’={1,201,15,PA#1’}(步驟S554)。接著,將主機資料更新命令DU5={5,200,1,PA#5}推入RCQ 330,此時SCQ 310包含{DU1’,DU3,DU4},而RCQ 330包含{DU2’,DU5}(步驟S562)。 The processing unit 134 receives the host write command W5={LBA#200,D5} at time point t5 (step S522), generates the host data update command DU5={5,200,1,PA#5} according to the content of W5 and marks it as RUC (step S524). Because the logical address LBA#200 in the host data update command DU5 is partially the same as the logical address LBA#200~215 in DU1 in RCQ 330 (the path of "Yes" in step S552), the duplicate logical address is changed from DU1 in SCQ 310 is deleted, so that the original host data update command DU1={1,200,16,PA#1} is changed to DU1'={1,201,15,PA#1'} (step S554). Next, push the host data update command DU5={5,200,1,PA#5} into RCQ 330. At this time, SCQ 310 contains {DU1', DU3, DU4}, and RCQ 330 contains {DU2', DU5} (step S562 ).

邏輯位址的更新操作和主機資料更新命令的入列操作會不斷的執行,直到SCQ 310或RCQ 330滿了。一旦SCQ 310滿了(步驟S532中“是”的路徑),依序推出和執行SCQ 310中的所有主機資料更新命令(步驟S534)。一旦RCQ 330滿了(步驟S542中“是”的路徑),依序推出和執行RCQ 330中的所有主機資料更新命令(步驟S544)。 The logical address update operation and the enqueuing operation of the host data update command will be continuously executed until the SCQ 310 or RCQ 330 is full. Once the SCQ 310 is full (the "YES" path in step S532), all host data update commands in the SCQ 310 are sequentially pushed out and executed (step S534). Once the RCQ 330 is full (the "YES" path in step S542), all host data update commands in the RCQ 330 are sequentially pushed out and executed (step S544).

本發明所述的方法中的全部或部分步驟可以計算機指令實現,例如儲存裝置中的韌體轉換層(Firmware Translation Layer,FTL)、特定硬體的驅動程式等。此外,也可實現於其他類型程式。所屬技術領域具有通常知識者可將本發明實施例的方法撰寫成計算機指令,為求簡潔不再加以描述。依據本發明實施例方法實施的計算機指令 可儲存於適當的電腦可讀取媒體,例如DVD、CD-ROM、USB碟、硬碟,亦可置於可通過網路(例如,網際網路,或其他適當載具)存取的網路伺服器。 All or part of the steps in the method of the present invention can be implemented by computer instructions, such as a firmware translation layer (FTL) in a storage device, a driver for a specific hardware, etc. In addition, it can also be implemented in other types of programs. Those with ordinary skill in the art can write the methods of the embodiments of the present invention as computer instructions, which will not be described again for the sake of simplicity. Computer instructions implemented according to methods of embodiments of the present invention Can be stored on appropriate computer-readable media, such as DVD, CD-ROM, USB disk, hard drive, or can be placed on a network accessible through a network (such as the Internet, or other appropriate vehicles) server.

雖然圖1、圖2中包含了以上描述的元件,但不排除在不違反發明的精神下,使用更多其他的附加元件,已達成更佳的技術效果。此外,雖然圖4至圖5的流程圖採用指定的順序來執行,但是在不違反發明精神的情況下,熟習此技藝人士可以在達到相同效果的前提下,修改這些步驟間的順序,所以,本發明並不侷限於僅使用如上所述的順序。此外,熟習此技藝人士亦可以將若干步驟整合為一個步驟,或者是除了這些步驟外,循序或平行地執行更多步驟,本發明亦不因此而侷限。 Although Figures 1 and 2 contain the components described above, it does not rule out the use of more other additional components to achieve better technical effects without violating the spirit of the invention. In addition, although the flow charts of Figures 4 to 5 are executed in a specified order, those skilled in the art can modify the order of these steps while achieving the same effect without violating the spirit of the invention. Therefore, The present invention is not limited to the use of only the sequence 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 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 which will be obvious to one skilled in the art. Therefore, the scope of the claims of the application must be interpreted in the broadest manner to include all obvious modifications and similar arrangements.

S412~S462:方法步驟 S412~S462: Method steps

Claims (15)

一種排程和執行主機資料更新命令的方法,由處理單元執行,上述方法包含:提供第一佇列和第二佇列,其中,所述第一佇列包含多個第一主機資料更新命令,每個所述第一主機資料更新命令為第一類型的主機資料更新命令並且包含第一邏輯位址,所述第二佇列包含多個第二主機資料更新命令,以及每個所述第二主機資料更新命令為第二類型的主機資料更新命令並且包含第二邏輯位址;依據從主機端接收的用於更新資料的主機命令的類型和參數,產生第三主機資料更新命令,並且標記所述第三主機資料更新命令為所述第一類型的主機資料更新命令,其中,所述第三主機資料更新命令包含第三邏輯位址;因應所述第三邏輯位址相同於所述多個第一主機資料更新命令中的一個的所述第一邏輯位址的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令;因應所述第三邏輯位址相同於所述多個第二主機資料更新命令中的一個的所述第二邏輯位址的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令和所述第二佇列中的所有所述第二主機資料更新命令;以及將所述第三主機更新命令推入所述第一佇列。 A method for scheduling and executing host data update commands, executed by a processing unit. The method includes: providing a first queue and a second queue, wherein the first queue includes a plurality of first host data update commands, Each of the first host data update commands is a first type of host data update command and includes a first logical address, the second queue includes a plurality of second host data update commands, and each of the second The host data update command is a second type of host data update command and includes a second logical address; a third host data update command is generated according to the type and parameters of the host command received from the host for updating data, and the flag is The third host data update command is the first type of host data update command, wherein the third host data update command includes a third logical address; in response to the third logical address being the same as the plurality of In the case of the first logical address of one of the first host data update commands, launch and execute all the first host data update commands in the first queue; in response to the same third logical address In the case of the second logical address of one of the plurality of second host data update commands, launch and execute all of the first host data update commands and the second host data update commands in the first queue. queue all the second host data update commands; and push the third host update command into the first queue. 如請求項1所述的排程和執行主機資料更新命令的方法,其中,所述第一類型的主機資料更新命令為順序主機更新命令,以及所述第二類型的主機資料更新命令為隨機主機更新命令。 The method for scheduling and executing host data update commands as described in claim 1, wherein the first type of host data update command is a sequential host update command, and the second type of host data update command is a random host Update command. 如請求項2所述的排程和執行主機資料更新命令的方法,其中, 所述順序主機更新命令的邏輯區塊位址長度大於1,以及所述隨機主機更新命令的邏輯區塊位址長度等於1。 The method of scheduling and executing host data update commands as described in request item 2, wherein, The logical block address length of the sequential host update command is greater than 1, and the logical block address length of the random host update command is equal to 1. 如請求項1所述的排程和執行主機資料更新命令的方法,其中,所述第一類型的主機資料更新命令為隨機主機更新命令,以及所述第二類型的主機資料更新命令為順序主機更新命令。 The method for scheduling and executing host data update commands as described in claim 1, wherein the first type of host data update command is a random host update command, and the second type of host data update command is a sequential host Update command. 如請求項4所述的排程和執行主機資料更新命令的方法,其中,所述順序主機更新命令的邏輯區塊位址長度大於1,以及所述隨機主機更新命令的邏輯區塊位址長度等於1。 The method for scheduling and executing host data update commands as described in claim 4, wherein the logical block address length of the sequential host update command is greater than 1, and the logical block address length of the random host update command is greater than 1. equal to 1. 如請求項1所述的排程和執行主機資料更新命令的方法,包含:因應所述第一佇列已滿的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令。 The method of scheduling and executing a host data update command as described in claim 1 includes: in response to the situation that the first queue is full, launching and executing all the first host data in the first queue. Update command. 如請求項6所述的排程和執行主機資料更新命令的方法,其中,所述第一佇列為順序更新命令佇列或隨機更新命令佇列。 The method of scheduling and executing host data update commands as described in claim 6, wherein the first queue is a sequential update command queue or a random update command queue. 一種排程和執行主機資料更新命令的電腦程式產品,包含程式碼,其中,當處理單元執行所述程式碼時,實施如請求項1至7中任一項所述的排程和執行主機資料更新命令的方法。 A computer program product for scheduling and executing host data update commands, comprising program code, wherein when a processing unit executes the program code, scheduling and executing host data as described in any one of claims 1 to 7 is performed Method for updating commands. 一種排程和執行主機資料更新命令的裝置,包含:隨機存取記憶體,配置空間給第一佇列和第二佇列,其中,所述第一佇列包含多個第一主機資料更新命令,每個所述第一主機資料更新命令為第一類型的主機資料更新命令並且包含第一邏輯位址,所述第二佇列包含多個第二主機資料更新命令,以及每 個所述第二主機資料更新命令為第二類型的主機資料更新命令並且包含第二邏輯位址;以及處理單元,耦接所述隨機存取記憶體,用於依據從主機端接收的用於更新資料的主機命令的類型和參數,產生第三主機資料更新命令,並且標記所述第三主機資料更新命令為所述第一類型的主機資料更新命令,其中,所述第三主機資料更新命令包含第三邏輯位址;因應所述第三邏輯位址相同於所述多個第一主機資料更新命令中的一個的所述第一邏輯位址的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令;因應所述第三邏輯位址相同於所述多個第二主機資料更新命令中的一個的所述第二邏輯位址的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令和所述第二佇列中的所有所述第二主機資料更新命令;以及將所述第三主機更新命令推入所述第一佇列。 A device for scheduling and executing host data update commands, including: a random access memory, configuring space for a first queue and a second queue, wherein the first queue contains a plurality of first host data update commands , each of the first host data update commands is a first type of host data update command and includes a first logical address, the second queue includes a plurality of second host data update commands, and each The second host data update command is a second type of host data update command and includes a second logical address; and a processing unit coupled to the random access memory, configured to receive a request from the host according to the second host data update command. The type and parameters of the host command to update the data, generate a third host data update command, and mark the third host data update command as the first type of host data update command, wherein the third host data update command Comprise a third logical address; in response to the situation that the third logical address is the same as the first logical address of one of the plurality of first host data update commands, launch and execute the first queue all the first host data update commands in; in response to the situation that the third logical address is the same as the second logical address of one of the plurality of second host data update commands, derive and execute all all first host data update commands in the first queue and all second host data update commands in the second queue; and push the third host update command into the first Queue. 如請求項9所述的排程和執行主機資料更新命令的裝置,其中,所述第一類型的主機資料更新命令為順序主機更新命令,以及所述第二類型的主機資料更新命令為隨機主機更新命令。 The device for scheduling and executing host data update commands as described in claim 9, wherein the first type of host data update command is a sequential host update command, and the second type of host data update command is a random host Update command. 如請求項10所述的排程和執行主機資料更新命令的裝置,其中,所述順序主機更新命令的邏輯區塊位址長度大於1,以及所述隨機主機更新命令的邏輯區塊位址長度等於1。 The device for scheduling and executing host data update commands as described in claim 10, wherein the logical block address length of the sequential host update command is greater than 1, and the logical block address length of the random host update command is greater than 1. equal to 1. 如請求項9所述的排程和執行主機資料更新命令的裝置,其中,所述第一類型的主機資料更新命令為隨機主機更新命令,以及所述第二類型的主機資料更新命令為順序主機更新命令。 The device for scheduling and executing host data update commands as described in claim 9, wherein the first type of host data update command is a random host update command, and the second type of host data update command is a sequential host Update command. 如請求項12所述的排程和執行主機資料更新命令的裝置,其中,所述順序主機更新命令的邏輯區塊位址長度大於1,以及所述隨機主機更新命令的邏輯區塊位址長度等於1。 The device for scheduling and executing host data update commands as described in claim 12, wherein the logical block address length of the sequential host update command is greater than 1, and the logical block address length of the random host update command is greater than 1. equal to 1. 如請求項9所述的排程和執行主機資料更新命令的裝置,其中,所述處理單元用於因應所述第一佇列已滿的情況,推出並執行所述第一佇列中的所有所述第一主機資料更新命令。 The device for scheduling and executing host data update commands as described in claim 9, wherein the processing unit is used to push out and execute all the commands in the first queue in response to the situation that the first queue is full. The first host data update command. 如請求項14所述的排程和執行主機資料更新命令的裝置,其中,所述主機命令為主機寫入命令、主機丟棄命令或者主機抹寫命令。 The device for scheduling and executing host data update commands as described in claim 14, wherein the host command is a host write command, a host discard command, or a host erase command.
TW111138323A 2022-10-11 2022-10-11 Method and computer program product and apparatus for scheduling and executing host data-update commands TWI818762B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW111138323A TWI818762B (en) 2022-10-11 2022-10-11 Method and computer program product and apparatus for scheduling and executing host data-update commands

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW111138323A TWI818762B (en) 2022-10-11 2022-10-11 Method and computer program product and apparatus for scheduling and executing host data-update commands

Publications (2)

Publication Number Publication Date
TWI818762B true TWI818762B (en) 2023-10-11
TW202416108A TW202416108A (en) 2024-04-16

Family

ID=89857546

Family Applications (1)

Application Number Title Priority Date Filing Date
TW111138323A TWI818762B (en) 2022-10-11 2022-10-11 Method and computer program product and apparatus for scheduling and executing host data-update commands

Country Status (1)

Country Link
TW (1) TWI818762B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200641602A (en) * 2005-02-16 2006-12-01 Sandisk Corp Direct data file storage in flash memories
TWI584125B (en) * 2011-08-09 2017-05-21 Lsi公司 I/o device and computing host interoperation
TWI656445B (en) * 2017-05-26 2019-04-11 慧榮科技股份有限公司 Methods for scheduling and executing commands in a flash memory and apparatuses using the same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200641602A (en) * 2005-02-16 2006-12-01 Sandisk Corp Direct data file storage in flash memories
TWI584125B (en) * 2011-08-09 2017-05-21 Lsi公司 I/o device and computing host interoperation
TWI656445B (en) * 2017-05-26 2019-04-11 慧榮科技股份有限公司 Methods for scheduling and executing commands in a flash memory and apparatuses using the same
CN108932108B (en) * 2017-05-26 2021-07-06 慧荣科技股份有限公司 Method for scheduling and executing commands of flash memory and device using the same

Similar Documents

Publication Publication Date Title
CN107430493B (en) Sequential write stream management
US8332579B2 (en) Data storage apparatus and method of writing data
US20150186068A1 (en) Command queuing using linked list queues
TWI678618B (en) Method and apparatus for performing operations to namespaces of a flash memory device
US20220100425A1 (en) Storage device, operating method of storage device, and operating method of computing device including storage device
CN104281413A (en) Command queue management method, memorizer controller and memorizer storage device
CN115113799A (en) Host command execution method and device
TWI818762B (en) Method and computer program product and apparatus for scheduling and executing host data-update commands
TWI805505B (en) Method and computer program product and apparatus for scheduling and executing host data-update commands
TWI747660B (en) Method and apparatus and computer program product for reading data from multiple flash dies
TWI835027B (en) Method and computer program product and apparatus for updating host-to-flash address mapping table
TWI822517B (en) Method and computer program product and apparatus for executing host write commands
TWI822516B (en) Method and computer program product and apparatus for executing host write commands
CN117909251A (en) Storage medium, method and device for scheduling and executing host data update command
CN117909252A (en) Storage medium, method and device for scheduling and executing host data update command
TWI648629B (en) Mapping table updating method, memory control circuit unit and memory storage device
CN114625307A (en) Computer readable storage medium, and data reading method and device of flash memory chip
US20240118832A1 (en) Method and non-transitory computer-readable storage medium and apparatus for scheduling and executing host data-update commands
TWI814647B (en) Method and computer program product and apparatus for executing host commands
US20240118833A1 (en) Method and non-transitory computer-readable storage medium and apparatus for scheduling and executing host data-update commands
TWI758745B (en) Computer program product and method and apparatus for scheduling executions of host commands
TWI774277B (en) Method and apparatus for executing host commands
TW202321921A (en) Method and computer program product and apparatus for updating host-to-flash address mapping table
TWI799221B (en) Method and apparatus for programming data into flash memory
TWI810876B (en) Method and computer program product and apparatus for data access in response to host discard commands