TWI822516B - Method and computer program product and apparatus for executing host write commands - Google Patents

Method and computer program product and apparatus for executing host write commands Download PDF

Info

Publication number
TWI822516B
TWI822516B TW111147881A TW111147881A TWI822516B TW I822516 B TWI822516 B TW I822516B TW 111147881 A TW111147881 A TW 111147881A TW 111147881 A TW111147881 A TW 111147881A TW I822516 B TWI822516 B TW I822516B
Authority
TW
Taiwan
Prior art keywords
write command
host
logical address
random
queue
Prior art date
Application number
TW111147881A
Other languages
Chinese (zh)
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 TW111147881A priority Critical patent/TWI822516B/en
Application granted granted Critical
Publication of TWI822516B publication Critical patent/TWI822516B/en

Links

Images

Abstract

The invention is related to a method, a computer program product and an apparatus for executing host write commands. The method, performed by a processing unit, includes: providing a sequential write-command queue, a random write-command queue and a mark queue; receiving a host write command from a host side; and pushing a record into the mark queue, and pushing the host write command into the sequential write-command queue or the random write-command queue according to a length of the first logical address range carried in the host write command when detecting that a first logical address range carried in the host write command conflicts with a second logical address range carried in at least one sequential write command and/or a third logical address range carried in at least one random write command. The record indicates that the conflicted sequential write command(s) and/or the conflicted random write command(s) require to be processed in advance. With the above method, the data write performance would be improved without the occurrence of dirty writes.

Description

執行主機寫入命令的方法及電腦程式產品及裝置 Methods and computer program products and devices for executing host write commands

本發明涉及儲存裝置,尤指一種執行主機寫入命令的方法、電腦程式產品及裝置。 The present invention relates to a storage device, and in particular, to a method, computer program product and device for executing a host write command.

閃存通常分為NOR閃存與NAND閃存。NOR閃存為隨機存取裝置,主機端(Host Side)可於位址腳位上提供任何存取NOR閃存的位址,並及時地從NOR閃存的資料腳位上獲得儲存於該位址上的資料。相反地,NAND閃存並非隨機存取,而是序列存取。NAND閃存無法像NOR閃存一樣,可以存取任何隨機位址,主機端反而需要寫入序列的位元組(Bytes)的值到NAND閃存中,用於定義請求命令(Command)的類型(如,讀取、寫入、丟棄、抹除等),以及用在此命令上的位址。位址可指向一個頁面(閃存中寫入作業的最小資料塊)或一個區塊(閃存中抹除作業的最小資料塊)。 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).

然而,在預存模式(Cache Mode)下,欲循序寫入或者隨機寫入的資料可先暫存在閃存控制器中的隨機存取記憶體一段時間,直到適當的時機再寫入閃存模組。然而,寫入暫存資料到閃存模組的時間點和長度,將影響整體的系統效能。因此,本發明提出一種執行主機寫入命令的方法、電腦程式產品及裝置。 However, in Cache Mode, data to be written sequentially or randomly can be temporarily stored in the random access memory in the flash memory controller for a period of time until the appropriate time is reached and then written to the flash memory module. However, the time and length of writing temporary data to the flash memory module will affect the overall system performance. Therefore, the present invention provides a method, computer program product and device for executing a host write command.

有鑑於此,如何減輕或消除上述相關領域的缺失,實為有待解決的問題。 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 specification relates to a method for executing host write commands, which is executed by a processing unit and includes: providing a sequential write command queue, a random write command queue, and a label queue; receiving a host write command from the host; and when detecting It is detected that the first logical address range carried in the host write command conflicts with the second logical address range carried in at least one sequential write command and/or the third logical address range carried in at least one random write command. When the record is pushed to the mark queue, and the host write command is pushed into the sequential write command queue or the random write command queue according to the length of the first logical address interval carried by the host write command. , so that when the conditions are met, based on the content of this record, the second logical address range indicated by the conflicting sequence write command and/or the third logical address interval indicated by the conflicting random write command can be written earlier than the host write command. User data in the logical address range to the flash memory module.

順序寫入命令佇列儲存多個順序寫入命令,隨機寫入命令佇列儲存多個隨機寫入命令,此紀錄指出衝突的順序寫入命令和/或衝突的隨機寫入命令需要較主機寫入命令優先被處理的資訊。 The sequential write command queue stores multiple sequential write commands, and the random write command queue stores multiple random write commands. This record indicates that conflicting sequential write commands and/or conflicting random write commands require more time than the host writes. Information that input commands are processed with priority.

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

本說明書還涉及一種執行主機命令的裝置,包含:主機介面;隨機存取記憶體;和處理單元。隨機存取記憶體配置空間給順序寫入命令佇列、隨機寫入命令佇列和標註佇列。處理單元設置以通過主機介面從主機端接收主機寫入命令;以及當偵測到主機寫入命令中攜帶的第一邏輯位址區間和至少一個所述順序寫入命令中攜帶的第二邏輯位址區間和/或至少一個隨機寫入命令中攜帶的第三邏輯位址區間衝突時,推入紀錄至標註佇列,以及依據主機寫入命令所攜帶的第一邏輯位址區間的長度,將主機寫入命令推入順序寫入命令佇列或者隨機寫入命令佇列,使得在條件滿足時能依據紀錄的內容,較主機寫入命令早寫入衝突的順序寫入命令所指出的第二邏輯位址區間和/或衝突的隨機寫入命令所指出的第三邏輯位址區間的使用者資 料至閃存模組。 This specification also relates to a device for executing host commands, including: a host interface; a random access memory; and a processing unit. The random access memory allocates space for the sequential write command queue, the random write command queue, and the label queue. The processing unit is configured to receive a host write command from the host through the host interface; and when detecting a first logical address range carried in the host write command and at least one second logical bit carried in the sequential write command When the address range and/or the third logical address range carried in at least one random write command conflict, the record is pushed to the mark queue, and the record is pushed according to the length of the first logical address range carried in the host write command. The host write command pushes the sequential write command queue or the random write command queue, so that when the conditions are met, based on the content of the record, the conflicting sequential write command can be written earlier than the host write command. The user information of the logical address range and/or the third logical address range indicated by the conflicting random write command Supplied to the flash memory module.

上述實施例的優點之一,通過如上所述的方法,可在不發生髒寫入的情況下提升資料寫入效能。 One of the advantages of the above embodiment is that through the above method, data writing performance can be improved without dirty writing occurring.

本發明的其他優點將搭配以下的說明和圖式進行更詳細的解說。 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

135,135#0~135#7:搜索引擎 135,135#0~135#7: Search engine

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: Sequentially write command queue

330:隨機寫入命令佇列 330: Random write command queue

610:命令排程模組 610:Command scheduling module

630:資料寫入模組 630: Data writing module

650:標註佇列 650: Mark queue

S710~S760:方法步驟 S710~S760: Method steps

S810~S850:方法步驟 S810~S850: 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 schematic diagram of an initial enqueuing result according to an embodiment of the present invention.

圖5為依據本發明實施例的中間入列結果的示意圖。 FIG. 5 is a schematic diagram of an intermediate enqueuing result according to an embodiment of the present invention.

圖6為依據本發明實施例的韌體轉換層的方塊圖。 FIG. 6 is a block diagram of a firmware conversion layer according to an embodiment of the present invention.

圖7為依據本發明實施例的主機寫入命令的處理方法的流程圖。 FIG. 7 is a flow chart of a method for processing a host write command according to an embodiment of the present invention.

圖8為依據本發明實施例的主機寫入命令的資料寫入方法的流程圖。 FIG. 8 is a flow chart of a data writing method of a host write command according to an embodiment of the present invention.

圖9至圖13為依據本發明實施例的中間入列結果的示意圖。 9 to 13 are schematic diagrams of intermediate enqueuing results according to embodiments 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 elements could be interpreted in a similar fashion, 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)、平板電腦、手機、數位相機、數位攝影機、智慧電視、智慧電冰箱、車用電子系統(Automotive Electronics System)等電子產品之中。主機端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接收主機命令,例如讀取命令(Read Command)、寫入命令(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)或上述兩者的結合,用於配置空間作為資料緩存器(Data Buffer),儲存從主機端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, and automotive electronic systems (Automotive Electronics Systems). 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), Double Data Rate DDR. 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 a read command (Read Command), a write command (Write Command), and a discard command (Discard command). Command), erase command (Erase Command), etc., generate a host data-update command (Host Data-update Command) according to the type of the host command and the parameters carried therein, schedule and execute 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 (Data Buffer) to store user data (also called host data) read from the host 110 and about to be written to the flash memory module 150. and user data read from the flash memory module 150 and 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), queue, etc. The flash memory interface 139 includes a NAND flash memory controller (NAND Flash Controller NFC), which provides functions required for accessing the flash memory module 150, such as command sequencer (Command Sequencer), low density parity check (Low Density Parity Check LDPC), etc.

閃存控制器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 trillion bytes (Terabytes, TB). Used to store large amounts of user data, such as high-resolution images, 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 to a specified address (destination address) in the flash memory module 150 through the flash memory interface 139, and reads user data from a 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可設置專屬的搜索引擎135,包含如寄存器、比較器、輸出邏輯等數位電路,用於讓處理單元134驅動以判斷一個主機寫入命令的邏輯位址區間是否和順序寫入命令佇列310或隨機寫入命令佇列330中紀錄的邏輯位址區間發生衝突(或 者部分重疊)。由於邏輯位址區間的比對需要大量的運算時間,讓處理單元134在設定一個主機寫入命令的邏輯位址區間到搜索引擎135的輸入寄存器之後,就可以離開去執行其他的操作。在一段預設的時間後,處理單元134可讀取搜索引擎135的輸出寄存器的值,以判斷搜索是否結束,判斷輸入的邏輯位址區間是否和順序寫入命令佇列310或隨機寫入命令佇列330中紀錄的邏輯位址區間發生衝突,以及順序寫入命令佇列310或隨機寫入命令佇列330中發生衝突的節點。在另一些實施例中,多個邏輯位址區間的比對可使用搜索程式碼實施,並且在處理單元134載入並執行搜索程式碼時,完成如上所述的判斷,以及輸出搜索結果。 In some embodiments, the flash memory controller 130 can set up a dedicated search engine 135, including digital circuits such as registers, comparators, output logic, etc., for driving the processing unit 134 to determine the logical address range of a host write command. Does it conflict with the logical address range recorded in the sequential write command queue 310 or the random write command queue 330 (or or partially overlap). Since the comparison of logical address ranges requires a large amount of computing time, the processing unit 134 can leave to perform other operations after setting the logical address range of a host write command to the input register of the search engine 135 . After a preset period of time, the processing unit 134 can read the value of the output register of the search engine 135 to determine whether the search is completed, and to determine whether the input logical address range is consistent with the sequential write command queue 310 or the random write command. The logical address ranges recorded in the queue 330 conflict, and the nodes in the sequential write command queue 310 or the random write command queue 330 conflict. In other embodiments, the comparison of multiple logical address intervals can be implemented using a search program code, and when the processing unit 134 loads and executes the search program code, it completes the above-mentioned determination and outputs the search results.

參考圖3,RAM 136配置空間給順序寫入命令佇列(Sequential-write Command Queue,SCQ)310,用於依照到達閃存控制器130的時間順序儲存主機端110發送的順序主機寫入命令,例如邏輯區塊位址長度(Logical Block Address,LBA Length)大於1的主機資料更新命令。RAM 136還配置空間給隨機寫入命令佇列(Random-write 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-write Command Queue (SCQ) 310, which is used to store sequential host write commands sent by the host end 110 according to the time sequence when they arrive at the flash memory controller 130, for example A host data update command with a logical block address (LBA Length) greater than 1. The RAM 136 also configures space for a Random-write Command Queue (RCQ) 330, which is used to store random host write commands sent by the host end 110 according to the time sequence when they arrive at the flash memory controller 130. For example, the LBA length is equal to 1 host write command. Either the sequential write command queue 310 or the random write command queue 330 may store hundreds or thousands of host write commands. The sequential write command queue 310 and the random write command queue 330 can be cyclic queues (Cyclical Queue), and the basic principle of their operation is to add a host write command from the end position (such as the position indicated by the indicator T) ( may be called enqueuing), and the host write command is moved out from the starting position (such as the position indicated by pointer H) (which may 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依序從主機端110收到8個主機寫入命令:W0={LBA#0~499,D0};W1={LBA#1000~1499,D1};W2={LBA#2000~2499,D2};W3={LBA#3000~3499,D3};W4={LBA#500,D4};W5={LBA#1500,D5};W6={LBA#2500,D6};W7={LBA#3500,D7}。主機寫入命令W0指示寫入邏輯位址LBA#0~499的資料D0,主機寫入命令W1指示寫入邏輯位址LBA#1000~1499的資料D1,主機寫入命令W2指示寫入邏輯位址LBA#2000~2499的資料D2,主機寫入命令W3指示寫入邏輯位址LBA#3000~3499的資料D3,主機寫入命令W4指示寫入邏輯位址LBA#500的資料D4,主機寫入命令W5指示寫入邏輯位址LBA#1500的資料D5,主機寫入命令W6指示寫入邏輯位址LBA#2500的資料D6,主機寫入命令W7指示寫入邏輯位址LBA#3500的資料D7。參考圖4的入列結果示意圖,接著,FTL依據資料的LBA長度將主機寫入命令W0至W3(可稱為順序寫入命令)推入順序寫入命令佇列310,以及將主機寫入命令W4至W7(可稱為隨機寫入命令)推入隨機寫入命令佇列330。 For example, when the processing unit 134 executes the program code of the Firmware Translation Layer (FTL), it completes the enqueuing of the host write command as follows: First, Eight host write commands are received sequentially from the host side 110 through the host interface 131: W0={LBA#0~499,D0}; W1={LBA#1000~1499,D1}; W2={LBA#2000~ 2499,D2}; W3={LBA#3000~3499,D3}; W4={LBA#500,D4}; W5={LBA#1500,D5}; W6={LBA#2500,D6}; W7={ LBA#3500,D7}. The host write command W0 instructs the writing of data D0 at logical addresses LBA#0~499, the host write command W1 instructs the writing of data D1 at logical addresses LBA#1000~1499, and the host write command W2 instructs the writing of logical bits Data D2 at address LBA#2000~2499, host write command W3 instructs to write data D3 at logical address LBA#3000~3499, host write command W4 instructs data D4 at logical address LBA#500 to be written, host write The input command W5 instructs the writing of data D5 at logical address LBA#1500, the host write command W6 instructs the writing of data D6 at logical address LBA#2500, and the host write command W7 instructs the writing of data at logical address LBA#3500. D7. Referring to the schematic diagram of the enqueuing result in Figure 4, FTL then pushes the host write commands W0 to W3 (which can be called sequential write commands) into the sequential write command queue 310 according to the LBA length of the data, and writes the host write commands W4 to W7 (which may be referred to as random write commands) push the random write command queue 330 .

為了提昇閃存模組150的資料寫入效能,閃存控制器130可使用特定政策來處理順序寫入命令和隨機寫入命令。然而,這可能造成主機寫入命令的資料的實際寫入順序和主機端發出的順序不同,因而發生髒寫入(Dirty Write)的情況。例如,接續圖4所示的範例,FTL通過主機介面131收到主機寫入命令W8={LBA#100,D8},指示寫入邏輯位址LBA#100的資料D8。主機寫入命令W8的入列結果如圖5所示。假設閃存控制器130採取隨機寫入優先(Random-write First)的原則來移出和處理順序寫入命令佇列310和隨機寫入命令佇列330中的主機寫入命令:也就是說,閃存控制器130先執行完主機寫入命令W4~W8之後,再執行主機寫入命令W0~W3。因為主機寫入命令W0的執行晚於主機寫入命令W8,造成閃存模組150中所儲存的邏 輯位址LBA#100的資料是D0,並不是主機端110期望的資料D8,發生髒寫入的情況。 In order to improve the data writing performance of the flash memory module 150, the flash memory controller 130 may use specific policies to process sequential write commands and random write commands. However, this may cause the actual writing order of the data in the host write command to be different from the order issued by the host, thus causing a dirty write (Dirty Write) situation. For example, following the example shown in FIG. 4 , FTL receives the host write command W8={LBA#100,D8} through the host interface 131, instructing to write the data D8 at the logical address LBA#100. The enqueuing result of the host write command W8 is shown in Figure 5. Assume that the flash memory controller 130 adopts the Random-write First principle to remove and process the host write commands in the sequential write command queue 310 and the random write command queue 330: that is, the flash memory controller After the processor 130 first executes the host write commands W4~W8, it then executes the host write commands W0~W3. Because the host write command W0 is executed later than the host write command W8, the logic stored in the flash memory module 150 is The data at edit address LBA#100 is D0, which is not the data D8 expected by the host 110, and a dirty write occurs.

參考圖6,為了在不發生髒寫入的情況下提升資料寫入效能,本發明實施例提出在FTL中設置獨立執行的命令排程模組610和資料寫入模組630,以及在RAM 136中配置空間來儲存標註佇列(Mark Queue)650。 Referring to Figure 6, in order to improve the data writing performance without dirty writing, the embodiment of the present invention proposes to set up an independently executed command scheduling module 610 and a data writing module 630 in the FTL, and in the RAM 136 Configure space to store Mark Queue (Mark Queue) 650.

命令排程模組610包含程式碼,用於在被處理單元134執行時,偵測每個通過主機介面131從主機端110所接收到的主機寫入命令的邏輯位址區間(可稱為第一邏輯位址區間)是否和順序寫入命令佇列310中的至少一個順序寫入命令中攜帶的邏輯位址區間(可稱為第二邏輯位址區間)和/或隨機寫入命令佇列330中至少一個隨機寫入命令中攜帶的邏輯位址區間(可稱為第三邏輯位址區間)衝突。一但發現衝突,則命令排程模組610在標註佇列650中推入一個紀錄,用於指出衝突的順序寫入命令和/或衝突的隨機寫入命令需要較接收到的主機寫入命令優先被處理的資訊,以及根據主機寫入命令所攜帶的邏輯位址區間的長度,將接收到的主機寫入命令推入順序寫入命令佇列310或者隨機寫入命令佇列330,使得在特定條件滿足時能依據標註佇列650的此紀錄的內容,較此主機寫入命令早寫入衝突的順序寫入命令所指出的邏輯位址區間和/或衝突的隨機寫入命令所指出的邏輯位址區間的使用者資料至閃存模組150。 The command scheduling module 610 includes program code for detecting the logical address range (which may be referred to as the third host write command) of each host write command received from the host 110 through the host interface 131 when executed by the processing unit 134 . a logical address interval) and at least one logical address interval (which may be called a second logical address interval) carried in the sequential write command in the sequential write command queue 310 and/or a random write command queue The logical address range (which may be called the third logical address range) carried in at least one random write command in step 330 conflicts. Once a conflict is found, the command scheduling module 610 pushes a record in the annotation queue 650 to indicate that the conflicting sequential write command and/or the conflicting random write command requires more time than the received host write command. Information that is processed first, and according to the length of the logical address range carried by the host write command, the received host write command is pushed into the sequential write command queue 310 or the random write command queue 330, so that in When certain conditions are met, the logical address range indicated by the conflicting sequence write command and/or the conflicting random write command may be written earlier than the host write command based on the content of this record in the annotation queue 650. The user data in the logical address range is sent to the flash memory module 150 .

資料寫入模組630包含程式碼,用於在被處理單元134執行時依據標註佇列650中的紀錄的內容,從順序寫入命令佇列310獲取衝突的順序寫入命令及之前的順序寫入命令中所攜帶的邏輯位址區間(可稱為第一邏輯位址區間),和/或從隨機寫入命令佇列330獲取衝突的隨機寫入命令及之前的隨機寫入命令中所攜帶的邏輯位址區間(可稱為第二邏輯位址區間);從隨機存取記憶體136的指定位址(可稱為第一位址)讀取第一邏輯位址區間的使用者資料,和/或從隨機 存取記憶體136的指定位址(可稱為第二位址)讀取第二邏輯位址區間的使用者資料;以及寫入第一邏輯位址區間的使用者資料,和/或第二邏輯位址區間的使用者資料至閃存模組150。資料寫入模組630會在滿足特定條件時被觸發,完成實際的資料寫入操作。此外,為了讓不同主機命令的延遲時間(Latency)儘可能一致且滿足規範的要求,資料寫入模組630也可控制一次寫入閃存模組150的資料量。 The data writing module 630 includes program code for obtaining the conflicting sequential writing command and the previous sequential writing command from the sequential writing command queue 310 according to the content of the record in the annotation queue 650 when executed by the processing unit 134 Enter the logical address interval carried in the command (which may be called the first logical address interval), and/or obtain the conflicting random write command from the random write command queue 330 and the information carried in the previous random write command. a logical address range (which can be called a second logical address range); read the user data of the first logical address range from a specified address (which can be called a first address) of the random access memory 136, and/or from random Access the designated address of the memory 136 (which may be referred to as the second address) to read the user data in the second logical address range; and write the user data in the first logical address range, and/or the second logical address range. The user data in the logical address range is sent to the flash memory module 150 . The data writing module 630 will be triggered when specific conditions are met to complete the actual data writing operation. In addition, in order to make the latency of different host commands as consistent as possible and meet the requirements of the specification, the data writing module 630 can also control the amount of data written to the flash memory module 150 at one time.

標註佇列650可實施為符合先進先出原則的循環式佇列,用於儲存多筆紀錄。每筆紀錄儲存順序寫入命令佇列310或隨機寫入命令佇列330的特定節點及其之前節點的所有主機寫入命令所關聯的使用者資料需要優先被寫入到閃存模組150的資訊。 The annotation queue 650 can be implemented as a cyclic queue that conforms to the first-in-first-out principle and is used to store multiple records. Each record stores the information that user data associated with all host write commands of a specific node in the sequential write command queue 310 or the random write command queue 330 and its previous nodes needs to be written to the flash memory module 150 first. .

資料寫入模組630的觸發條件可為:從主機端110接收到進入休眠模式(Sleep Mode)、省電模式(Power Saving Mode)或其他類似模式的指令,但還沒有從主機端110接收到離開休眠模式、省電模式或其他類似模式的指令的期間;或者順序寫入命令佇列310、隨機寫入命令佇列330或標註佇列650中被佔用的節點數超過特定閾值。閾值可設為順序寫入命令佇列310、隨機寫入命令佇列330或標註佇列650的指定百分比的節點總數,例如,可設為60%到90%中的任意百分比。 The trigger condition of the data writing module 630 may be: receiving an instruction to enter sleep mode (Sleep Mode), power saving mode (Power Saving Mode) or other similar modes from the host end 110, but has not yet received an instruction from the host end 110. During the instruction to leave sleep mode, power saving mode, or other similar modes; or the number of occupied nodes in the sequential write command queue 310, the random write command queue 330, or the label queue 650 exceeds a specific threshold. The threshold may be set to a specified percentage of the total number of nodes in the sequential write command queue 310, the random write command queue 330, or the label queue 650, for example, may be set to any percentage from 60% to 90%.

參考圖7所示的主機寫入命令的處理方法流程圖,此方法由處理單元134在載入和執行命令排程模組610時實施,用以反覆地從主機端110接收主機寫入命令,依據欲寫入資料的邏輯位址長度將主機寫入命令推入順序寫入命令佇列310或隨機寫入命令佇列330,並且視情況推入紀錄到標註佇列650。詳細說明如下: Referring to the flow chart of the host write command processing method shown in Figure 7, this method is implemented by the processing unit 134 when loading and executing the command scheduling module 610 to repeatedly receive the host write command from the host end 110, The host write command is pushed into the sequential write command queue 310 or the random write command queue 330 according to the length of the logical address of the data to be written, and the record is pushed into the label queue 650 as appropriate. The details are as follows:

步驟S710:通過主機介面131從主機端110接收主機寫入命令,包含開始邏輯位址和長度等資訊,此開始邏輯位址和長度可定義一段連續的邏輯位址區間。除了主機寫入命令外,命令排程模組610還通過主機介面131從主機端110接收此主機寫入命令所指示寫入的使用 者資料,並且驅動DMA控制器138將使用者資料儲存到RAM 136中的指定位址。 Step S710: Receive a host write command from the host terminal 110 through the host interface 131, including information such as a starting logical address and a length. The starting logical address and length can define a continuous logical address interval. In addition to the host write command, the command scheduling module 610 also receives the write usage indicated by the host write command from the host end 110 through the host interface 131 user data, and drives the DMA controller 138 to store the user data into the specified address in the RAM 136.

步驟S720:判斷主機寫入命令中攜帶的任何邏輯位址是否和順序寫入命令佇列310或隨機寫入命令佇列330中紀錄的邏輯位址衝突。如果是,則流程繼續進行步驟S730的處理;否則,流程繼續進行步驟S740的處理。命令排程模組610可驅動專屬的搜索引擎135,或者載入並執行搜索程式碼來完成判斷。 Step S720: Determine whether any logical address carried in the host write command conflicts with the logical address recorded in the sequential write command queue 310 or the random write command queue 330. If yes, the process continues to the process of step S730; otherwise, the process continues to the process of step S740. The command scheduling module 610 can drive a dedicated search engine 135, or load and execute search code to complete the determination.

步驟S730:推入至少一個記錄到標註佇列650。新入列的紀錄數目等於和順序寫入命令佇列310及隨機寫入命令佇列330中發生衝突的主機寫入命令的數目。每個新增加的紀錄關聯於順序寫入命令佇列310或隨機寫入命令佇列330中的發生衝突的一個主機寫入命令,並且這些紀錄依據衝突的主機寫入命令的入列時間從先到後依序入列到標註佇列650。 Step S730: Push at least one record to the annotation queue 650. The number of newly queued records is equal to the number of host write commands that conflict with the sequential write command queue 310 and the random write command queue 330 . Each newly added record is associated with a conflicting host write command in the sequential write command queue 310 or the random write command queue 330, and the records are sequentially updated based on the enqueue time of the conflicting host write command. After arriving, they are queued in the annotation queue 650.

步驟S740:依據主機寫入命令中所攜帶的長度判斷此主機寫入命令是否為順序寫入命令。例如,如果長度大於預設閾值,則判斷此主機寫入命令為順序寫入命令.流程繼續進行步驟S750的處理。如果長度等於或小於預設閾值,則判斷此主機寫入命令不是順序寫入命令(也就是隨機寫入命令).流程繼續進行步驟S760的處理。在一些實施例中.預設閾值可設為1。 Step S740: Determine whether the host write command is a sequential write command based on the length carried in the host write command. For example, if the length is greater than the preset threshold, the host write command is judged to be a sequential write command. The flow continues with the processing of step S750. If the length is equal to or less than the preset threshold, it is determined that the host write command is not a sequential write command (that is, a random write command). The flow continues with the processing of step S760. In some embodiments. The preset threshold can be set to 1.

步驟S750:將此主機寫入命令推入順序寫入命令佇列310。除了此順序寫入命令外,還可以在入列節點中紀錄RAM 136中的位址,用於儲存此順序寫入命令的欲寫入的使用者資料。 Step S750: Push the host write command into the sequential write command queue 310. In addition to the sequential write command, the address in the RAM 136 may also be recorded in the enqueuing node for storing the user data to be written by the sequential write command.

步驟S760:將此主機寫入命令推入隨機寫入命令佇列330。除了此隨機寫入命令外,還可以在入列節點中紀錄RAM 136的位址,用於儲存此隨機寫入命令的欲寫入的使用者資料。 Step S760: Push the host write command into the random write command queue 330. In addition to this random write command, the address of the RAM 136 can also be recorded in the enqueuing node for storing the user data to be written by this random write command.

參考圖8所示的主機寫入命令的資料寫入方法的流程圖,此方法由處理單元134在載入和執行資料寫入模組630時實施,用以參考順序 寫入命令佇列310和隨機寫入命令佇列330的主機寫入命令,以及標註佇列650的紀錄來完成實際的資料寫入操作。詳細說明如下: Referring to the flow chart of the data writing method of the host write command shown in FIG. 8 , this method is implemented by the processing unit 134 when loading and executing the data writing module 630 for reference sequence. The host write commands of the write command queue 310 and the random write command queue 330, and the records of the tag queue 650 are used to complete the actual data writing operation. The details are as follows:

步驟S810:判斷標註佇列650中是否存在任何的紀錄。如果是,代表已經存在需要優先被處理的主機寫入命令,則流程繼續進行步驟S820的處理;否則,代表不存在需要優先被處理的主機寫入命令,流程繼續進行步驟S830的處理。 Step S810: Determine whether there are any records in the annotation queue 650. If yes, it means that there is already a host write command that needs to be processed with priority, and the process continues with step S820; otherwise, it means that there is no host write command that needs to be processed with priority, and the process continues with step S830.

步驟S820:參考標註佇列650中的內容,以從順序寫入命令佇列310或隨機寫入命令佇列330中獲取需要優先被處理的主機寫入命令。 Step S820: Refer to the content in the annotation queue 650 to obtain the host write command that needs to be processed with priority from the sequential write command queue 310 or the random write command queue 330.

步驟S830:依據特定政策從順序寫入命令佇列310或隨機寫入命令佇列330中獲取主機寫入命令。特定政策可以指,例如,順序寫入命令優先、隨機寫入命令優先、到達時間優先或其他類似的排程政策。 Step S830: Obtain the host write command from the sequential write command queue 310 or the random write command queue 330 according to a specific policy. A specific policy may refer to, for example, sequential write commands first, random write commands first, arrival time first, or other similar scheduling policies.

步驟S840:通過DMA控制器138從RAM 136的指定位址讀取相應於獲取的主機寫入命令的使用者資料,並且驅動閃存介面139以寫入使用者資料到閃存模組150。 Step S840: Read the user data corresponding to the obtained host write command from the specified address of the RAM 136 through the DMA controller 138, and drive the flash memory interface 139 to write the user data to the flash memory module 150.

步驟S850:判斷閃存控制器130是否還有運算資源可以執行後續的資料寫入操作。如果是,則流程繼續進行步驟S810的處理;否則,流程結束,直到下一次觸發條件成立。閃存控制器130還有運算資源的情況,例如:閃存控制器130還沒有從主機端110接到指令,指示閃存控制器130離開休眠模式、省電模式或其他類似模式;或者,沒有比寫入操作更高優先級的任務,正等待閃存控制器130執行。 Step S850: Determine whether the flash memory controller 130 still has computing resources to perform subsequent data writing operations. If yes, the process continues to step S810; otherwise, the process ends until the next trigger condition is established. The flash memory controller 130 still has computing resources. For example, the flash memory controller 130 has not received an instruction from the host 110 to instruct the flash memory controller 130 to leave the sleep mode, power saving mode or other similar modes; Operations on higher priority tasks are waiting for execution by the flash memory controller 130 .

以下舉出更多使用個案來說明圖7和圖8所示方法的運行:接續圖4所示的範例,當接收到主機寫入命令W8後(步驟S710),命令排程模組610偵測到主機寫入命令W8中攜帶的邏輯位址LBA#100和順序寫入命令佇列310的第0個節點中的主機寫入命令W0中攜帶的邏輯位址區間LBA#0~499發生衝突(步驟S720中“是”的路徑),推入紀錄:M0=Q0[0]到標註佇列650,其中Q0[0]代表順序寫入命令佇列 310中的第0個節點(步驟S730),並且將主機寫入命令W8推入隨機寫入命令佇列330(步驟S760)。執行後的佇列內容如圖9所示。 The following are more use cases to illustrate the operation of the methods shown in Figures 7 and 8: Continuing the example shown in Figure 4, after receiving the host write command W8 (step S710), the command scheduling module 610 detects The logical address LBA#100 carried in the host write command W8 conflicts with the logical address range LBA#0~499 carried in the host write command W0 in the 0th node of the sequential write command queue 310 ( path "Yes" in step S720), push the record: M0=Q0[0] to the annotation queue 650, where Q0[0] represents the sequential write command queue The 0th node in 310 (step S730), and the host write command W8 is pushed into the random write command queue 330 (step S760). The queue content after execution is shown in Figure 9.

接著,當接收到主機寫入命令W9={LBA#1200~1299,D9}後(步驟S710),命令排程模組610偵測到主機寫入命令W9中攜帶的邏輯位址區間LBA#1200~1299和順序寫入命令佇列310的第1個節點中的主機寫入命令W1中攜帶的邏輯位址區間LBA#1000~1499發生衝突(步驟S720中“是”的路徑),推入紀錄:M1=Q0[1]到標註佇列650,其中Q0[1]代表順序寫入命令佇列310中的第1個節點(步驟S730),並且將主機寫入命令W8推入順序寫入命令佇列310(步驟S750)。執行後的佇列內容如圖10所示。 Next, after receiving the host write command W9={LBA#1200~1299,D9} (step S710), the command scheduling module 610 detects the logical address range LBA#1200 carried in the host write command W9. ~1299 conflicts with the logical address interval LBA#1000~1499 carried in the host write command W1 in the first node of the sequential write command queue 310 (the path of "Yes" in step S720), and the record is pushed : M1=Q0[1] to the label queue 650, where Q0[1] represents the 1st node in the sequential write command queue 310 (step S730), and the host write command W8 is pushed into the sequential write command Queue 310 (step S750). The queue content after execution is shown in Figure 10.

接著,當接收到主機寫入命令W10={LBA#2300~2799,D10}後(步驟S710),命令排程模組610偵測到主機寫入命令W10中攜帶的邏輯位址區間LBA#2300~2799和順序寫入命令佇列310的第2個節點中的主機寫入命令W2中攜帶的邏輯位址區間LBA#2000~2499以及隨機寫入命令佇列330的第2個節點中的主機寫入命令W6中攜帶的邏輯位址LBA#2500發生衝突(步驟S720中“是”的路徑),推入紀錄:M2=Q0[2]+Q1[2]到標註佇列650,其中Q0[2]代表順序寫入命令佇列310中的第2個節點,Q1[2]代表隨機寫入命令佇列330中的第2個節點(步驟S730),並且將主機寫入命令W10推入順序寫入命令佇列310(步驟S750)。執行後的佇列內容如圖11所示。 Next, after receiving the host write command W10={LBA#2300~2799,D10} (step S710), the command scheduling module 610 detects the logical address range LBA#2300 carried in the host write command W10. ~2799 and the host in the second node of the sequential write command queue 310 write the logical address range LBA#2000~2499 carried in the write command W2 and the host in the second node of the random write command queue 330 The logical address LBA#2500 carried in the write command W6 conflicts (the path of "Yes" in step S720), and the record: M2=Q0[2]+Q1[2] is pushed to the mark queue 650, where Q0[ 2] represents the second node in the sequential write command queue 310, Q1[2] represents the second node in the random write command queue 330 (step S730), and the host write command W10 is pushed into the sequence Write command queue 310 (step S750). The queue content after execution is shown in Figure 11.

接著,假設觸發資料寫入操作的條件滿足,資料寫入模組630發現標註佇列650中存在紀錄(步驟S810中“是”的路徑),根據預設的最大寫入資料量從順序寫入命令佇列310推出主機寫入命令W0和W1,而主機寫入命令W0和W1的待寫入資料是標註佇列650的最上面兩個紀錄M0和M1所指出需要優先寫入的資料,從RAM 136的指定位置依序讀取主機寫入命令W0和W1所指示寫入的使用者資料D0和D1(步驟S820)。資料寫入模組630驅動閃存介面139以依序寫入 使用資料D0和D1到閃存模組150(步驟S840)。執行後的佇列內容如圖12所示。 Next, assuming that the conditions for triggering the data writing operation are met, the data writing module 630 finds that there is a record in the annotation queue 650 (the "Yes" path in step S810), and writes sequentially according to the preset maximum amount of data to be written. The command queue 310 launches the host write commands W0 and W1, and the data to be written in the host write commands W0 and W1 is the data that needs to be written first as indicated by the top two records M0 and M1 of the queue 650. From The user data D0 and D1 instructed to be written by the host write commands W0 and W1 are sequentially read from the designated location of the RAM 136 (step S820). The data writing module 630 drives the flash memory interface 139 to write sequentially Use data D0 and D1 to the flash memory module 150 (step S840). The queue content after execution is shown in Figure 12.

接著,當接收到主機寫入命令W11={LBA#4000~4499,D11}後(步驟S710),命令排程模組610偵測到主機寫入命令W11中攜帶的邏輯位址區間LBA#4000~4499沒有和順序寫入命令佇列310以及隨機寫入命令佇列330中的任何主機寫入命令中攜帶的邏輯位址區間或邏輯位址發生衝突(步驟S720中“否”的路徑)將主機寫入命令W11推入順序寫入命令佇列310(步驟S750)。執行後的佇列內容如圖13所示。 Next, after receiving the host write command W11={LBA#4000~4499,D11} (step S710), the command scheduling module 610 detects the logical address range LBA#4000 carried in the host write command W11. ~4499 does not conflict with the logical address range or logical address carried in any host write command in the sequential write command queue 310 and the random write command queue 330 (the "No" path in step S720) will The host write command W11 pushes the sequential write command queue 310 (step S750). The queue content after execution is shown in Figure 13.

本發明所述的方法中的全部或部分步驟可以計算機指令實現,例如儲存裝置中的韌體轉換層(Firmware Translation Layer,FTL)、特定硬體的驅動程式等。此外,也可實現於其他類型程式。所屬技術領域具有通常知識者可將本發明實施例的方法撰寫成計算機指令,為求簡潔不再加以描述。依據本發明實施例方法實施的計算機指令可儲存於適當的電腦可讀取媒體,亦可置於可通過網路(例如,網際網路,或其他適當載具)存取的網路伺服器。 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 the methods of embodiments of the present invention can be stored in appropriate computer-readable media, or placed in a network server accessible through a network (such as the Internet, or other appropriate vehicles).

電腦可讀取儲存媒體包含揮發性和非揮發性、可卸載和不可卸載的媒體,其以任何方法或技術來實現資訊的儲存,如電腦可讀取指令、資料結構、程式模組、或其他資料。電腦可讀取儲存媒體包含但不限於RAM、ROM、EEPROM、閃存或其他記憶體、CD-ROM、DVD、藍光碟或其他光儲存體、磁卡、磁帶、磁碟或其他磁性儲存體,或者其他可以用以儲存讓指令執行系統所需要和存取的資訊的載具。需要注意的是,電腦可讀取儲存媒體可以是紙張或者其他適當媒體,用以印出程式碼,使其程式碼能夠通過電性方式獲取,例如通過光學掃描紙張或其他媒體,接著在必需的情況下,編譯、解譯或以其他適當方法處理後,接著再儲存到電腦的記憶體中。 Computer-readable storage media includes volatile and non-volatile, removable and non-removable media that use any method or technology to store information, such as computer-readable instructions, data structures, program modules, or other material. Computer-readable storage media includes but is not limited to RAM, ROM, EEPROM, flash memory or other memory, CD-ROM, DVD, Blu-ray disk or other optical storage, magnetic card, tape, magnetic disk or other magnetic storage, or other A vehicle that can be used to store information needed and accessed by the command execution system. It should be noted that the computer-readable storage medium can be paper or other appropriate media, which is used to print out the program code so that the program code can be obtained electronically, such as by optically scanning the paper or other media, and then printing the program code when necessary. In this case, it is compiled, interpreted, or otherwise processed by other appropriate methods, and then stored in the computer's memory.

雖然圖1至圖2中包含了以上描述的元件,但不排除在不違反發明的 精神下,使用更多其他的附加元件,已達成更佳的技術效果。此外,雖然圖7至圖8的流程圖採用指定的順序來執行,但是在不違反發明精神的情況下,熟習此技藝人士可以在達到相同效果的前提下,修改這些步驟間的順序,所以,本發明並不侷限於僅使用如上所述的順序。此外,熟習此技藝人士亦可以將若干步驟整合為一個步驟,或者是除了這些步驟外,循序或平行地執行更多步驟,本發明亦不因此而侷限。 Although the above-described elements are included in Figures 1 to 2, it does not exclude the possibility of In spirit, using more other add-on components has achieved better technical results. In addition, although the flowcharts of Figures 7 to 8 are executed in a specified order, those skilled in the art can modify the order of these steps without violating the spirit of the invention and achieving the same effect. 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.

S710~S760:方法步驟 S710~S760: Method steps

Claims (11)

一種執行主機寫入命令的方法,由處理單元執行,上述方法包含:提供順序寫入命令佇列、隨機寫入命令佇列和標註佇列,其中,所述順序寫入命令佇列儲存多個順序寫入命令,所述隨機寫入命令佇列儲存多個隨機寫入命令;從主機端接收主機寫入命令;當偵測到所述主機寫入命令中攜帶的第一邏輯位址區間和至少一個所述順序寫入命令中攜帶的第二邏輯位址區間和/或至少一個所述隨機寫入命令中攜帶的第三邏輯位址區間衝突時,推入紀錄至所述標註佇列,以及依據所述主機寫入命令所攜帶的所述第一邏輯位址區間的長度,將所述主機寫入命令推入所述順序寫入命令佇列或者所述隨機寫入命令佇列,其中,所述紀錄指出衝突的順序寫入命令和/或衝突的隨機寫入命令需要較所述主機寫入命令優先被處理的資訊;依據所述標註佇列中的所述紀錄的內容,從所述順序寫入命令佇列獲取所述衝突的順序寫入命令及之前的順序寫入命令中所攜帶的所述第二邏輯位址區間,和/或從所述隨機寫入命令佇列獲取所述衝突的隨機寫入命令及之前的隨機寫入命令中所攜帶的所述第三邏輯位址區間;從隨機存取記憶體的第二位址讀取所述第二邏輯位址區間的使用者資料,和/或從所述隨機存取記憶體的第三位址讀取所述第三邏輯位址區間的使用者資料;以及寫入所述第二邏輯位址區間的使用者資料,和/或所述第三邏輯位址區間的使用者資料至所述閃存模組。 A method for executing host write commands, executed by a processing unit. The method includes: providing a sequential write command queue, a random write command queue, and a label queue, wherein the sequential write command queue stores a plurality of Sequential write commands, the random write command queue stores a plurality of random write commands; receiving a host write command from the host; when detecting the first logical address range carried in the host write command and When the second logical address interval carried in at least one of the sequential write commands and/or the third logical address interval carried in at least one of the random write commands conflicts, push a record to the annotation queue, and pushing the host write command into the sequential write command queue or the random write command queue according to the length of the first logical address interval carried by the host write command, wherein , the record indicates information that conflicting sequential write commands and/or conflicting random write commands need to be processed prior to the host write command; according to the content of the record in the annotation queue, from all Obtain the second logical address interval carried in the conflicting sequential write command and the previous sequential write command from the sequential write command queue, and/or obtain the second logical address interval from the random write command queue. The third logical address interval carried in the conflicting random write command and the previous random write command; the use of reading the second logical address interval from the second address of the random access memory user data, and/or read user data of the third logical address range from the third address of the random access memory; and write user data of the second logical address range, and/or the user data of the third logical address range to the flash memory module. 如請求項1所述的執行主機寫入命令的方法,包含: 當偵測到所述主機寫入命令中攜帶的所述第一邏輯位址區間沒有和任何所述順序寫入命令中攜帶的所述第二邏輯位址區間以及沒有和任何所述隨機寫入命令中攜帶的所述第三邏輯位址區間衝突時,依據所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度,將所述主機寫入命令推入所述順序寫入命令佇列或者所述隨機寫入命令佇列。 The method of executing host write commands as described in request item 1 includes: When it is detected that the first logical address range carried in the host write command does not match any of the second logical address range carried in the sequential write command and does not match any of the random writes When the third logical address interval carried in the command conflicts, the host write command is pushed into the sequence according to the length of the first logical address interval carried by the host write command. Write command queue or the random write command queue. 如請求項1所述的執行主機寫入命令的方法,包含:當所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度大於閾值時,將所述主機寫入命令推入所述順序寫入命令佇列;以及當所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度小於或等於所述閾值時,將所述主機寫入命令推入所述隨機寫入命令佇列。 The method for executing a host write command as described in request item 1, including: when the length of the first logical address interval carried by the host write command is greater than a threshold, executing the host write command Pushing the sequential write command queue; and when the length of the first logical address interval carried by the host write command is less than or equal to the threshold, pushing the host write command Enter the random write command queue. 如請求項3所述的執行主機寫入命令的方法,其中,所述閾值設為1。 The method for executing a host write command as described in request item 3, wherein the threshold is set to 1. 如請求項3所述的執行主機寫入命令的方法,包含:將所述主機寫入命令所攜帶的所述第一邏輯位址區間的關聯使用者資料儲存至所述隨機存取記憶體的第一位址;以及在所述順序寫入命令佇列或所述隨機寫入命令佇列中的入列節點,紀錄所述隨機存取記憶體的所述第一位址。 The method for executing a host write command as described in claim 3 includes: storing the associated user data of the first logical address range carried by the host write command into the random access memory. a first address; and an enqueuing node in the sequential write command queue or the random write command queue records the first address of the random access memory. 一種執行主機命令的電腦程式產品,包含程式碼,其中,當處理單元執行所述程式碼時,實施如請求項1至5中任一項所述的執行主機寫入命令的方法。 A computer program product for executing host commands, including program code, wherein when a processing unit executes the program code, the method for executing host write commands described in any one of claims 1 to 5 is implemented. 一種執行主機寫入命令的裝置,包含:主機介面,耦接主機端;閃存介面,耦接閃存模組;隨機存取記憶體,配置空間給順序寫入命令佇列、隨機寫入命令佇列和標註佇列,其中,所述順序寫入命令佇列儲存多個順序寫入命令,所述隨機寫入命令佇列儲存多個隨機寫入命令;以及處理單元,耦接所述隨機存取記憶體和所述主機介面,設置以通過所述主機介面從所述主機端接收主機寫入命令;當偵測到所述主機寫入命令中攜帶的第一邏輯位址區間和至少一個所述順序寫入命令中攜帶的第二邏輯位址區間和/或至少一個所述隨機寫入命令中攜帶的第三邏輯位址區間衝突時,推入紀錄至所述標註佇列,以及依據所述主機寫入命令所攜帶的所述第一邏輯位址區間的長度,將所述主機寫入命令推入所述順序寫入命令佇列或者所述隨機寫入命令佇列,其中,所述紀錄指出衝突的順序寫入命令和/或衝突的隨機寫入命令需要較所述主機寫入命令優先被處理的資訊;依據所述紀錄的內容,從所述順序寫入命令佇列獲取所述衝突的順序寫入命令及之前的順序寫入命令中所攜帶的所述第二邏輯位址區間,和/或從所述隨機寫入命令佇列獲取所述衝突的隨機寫入命令及之前的隨機寫入命令中所攜帶的所述第三邏輯位址區間;從所述隨機存取記憶體的第二位址讀取所述第二邏輯位址區間的使用者資料,和/或從所述隨機存取記憶體的第三位址讀取所述第三邏輯位址區間的使用者資料;以及驅動所述閃存介面以寫入所述第二邏輯位址區間的使用者資料,和/或所述第三邏輯位址區間的使用者資料至所述閃存模組。 A device for executing host write commands, including: a host interface coupled to the host; a flash memory interface coupled to a flash memory module; a random access memory configured with space for sequential write command queues and random write command queues and a label queue, wherein the sequential write command queue stores a plurality of sequential write commands, and the random write command queue stores a plurality of random write commands; and a processing unit coupled to the random access The memory and the host interface are configured to receive a host write command from the host through the host interface; when detecting the first logical address range carried in the host write command and at least one of the When the second logical address interval carried in the sequential write command and/or the third logical address interval carried in at least one of the random write commands conflicts, push the record to the mark queue, and according to the The length of the first logical address interval carried by the host write command pushes the host write command into the sequential write command queue or the random write command queue, wherein the record Information indicating that conflicting sequential write commands and/or conflicting random write commands need to be processed prior to the host write command; obtaining the conflict from the sequential write command queue based on the content of the record the second logical address interval carried in the sequential write command and the previous sequential write command, and/or obtain the conflicting random write command and the previous random write command from the random write command queue Write the third logical address range carried in the command; read the user data of the second logical address range from the second address of the random access memory, and/or read the user data from the second logical address range. The third address of the random access memory reads the user data of the third logical address range; and drives the flash memory interface to write the user data of the second logical address range, and/or The user data in the third logical address range is transferred to the flash memory module. 如請求項7所述的執行主機寫入命令的裝置,其中,所述處理單元設置以當偵測到所述主機寫入命令中攜帶的所述第一邏輯位址區間沒有和任何所述順序寫入命令中攜帶的所述第二邏輯位址區間以及沒有和任何所述隨機寫入命令中攜帶的所述第三邏輯位址區間衝突時,依據所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度,將所述主機寫入命令推入所述順序寫入命令佇列或者所述隨機寫入命令佇列。 The device for executing a host write command as described in claim 7, wherein the processing unit is configured to detect that the first logical address range carried in the host write command does not correspond to any of the sequences. When the second logical address interval carried in the write command does not conflict with the third logical address interval carried in any of the random write commands, according to the said host write command carried The length of the first logical address interval pushes the host write command into the sequential write command queue or the random write command queue. 如請求項7所述的執行主機寫入命令的裝置,其中,所述處理單元設置以當所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度大於閾值時,將所述主機寫入命令推入所述順序寫入命令佇列;以及當所述主機寫入命令所攜帶的所述第一邏輯位址區間的所述長度小於或等於所述閾值時,將所述主機寫入命令推入所述隨機寫入命令佇列。 The device for executing a host write command as described in claim 7, wherein the processing unit is configured to: when the length of the first logical address interval carried by the host write command is greater than a threshold, The host write command is pushed into the sequential write command queue; and when the length of the first logical address interval carried by the host write command is less than or equal to the threshold, the host write command is The host write command is pushed into the random write command queue. 如請求項9所述的執行主機寫入命令的裝置,其中,所述閾值設為1。 The device for executing a host write command as described in claim 9, wherein the threshold is set to 1. 如請求項9所述的執行主機寫入命令的裝置,其中,所述處理單元設置以將所述主機寫入命令所攜帶的所述第一邏輯位址區間的關聯使用者資料儲存至所述隨機存取記憶體的第一位址;以及在所述順序寫入命令佇列或所述隨機寫入命令佇列中的入列節點,紀錄所述隨機存取記憶體的所述第一位址。 The device for executing a host write command according to claim 9, wherein the processing unit is configured to store the associated user data of the first logical address range carried by the host write command to the the first address of random access memory; and an enqueue node in the sequential write command queue or the random write command queue, recording the first address of the random access memory site.
TW111147881A 2022-12-14 2022-12-14 Method and computer program product and apparatus for executing host write commands TWI822516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW111147881A TWI822516B (en) 2022-12-14 2022-12-14 Method and computer program product and apparatus for executing host write commands

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW111147881A TWI822516B (en) 2022-12-14 2022-12-14 Method and computer program product and apparatus for executing host write commands

Publications (1)

Publication Number Publication Date
TWI822516B true TWI822516B (en) 2023-11-11

Family

ID=89722667

Family Applications (1)

Application Number Title Priority Date Filing Date
TW111147881A TWI822516B (en) 2022-12-14 2022-12-14 Method and computer program product and apparatus for executing host write commands

Country Status (1)

Country Link
TW (1) TWI822516B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201828307A (en) * 2017-01-19 2018-08-01 大陸商鵬鼎控股(深圳)股份有限公司 Resistance material
TW202134861A (en) * 2020-02-07 2021-09-16 美商谷歌有限責任公司 Interleaving memory requests to accelerate memory accesses
CN113874826A (en) * 2019-06-14 2021-12-31 美光科技公司 Multi-pass data programming in a memory subsystem having multiple dies and planes
US20220057953A1 (en) * 2020-08-18 2022-02-24 SK Hynix Inc. Memory controller and method of operating the same

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW201828307A (en) * 2017-01-19 2018-08-01 大陸商鵬鼎控股(深圳)股份有限公司 Resistance material
CN113874826A (en) * 2019-06-14 2021-12-31 美光科技公司 Multi-pass data programming in a memory subsystem having multiple dies and planes
TW202134861A (en) * 2020-02-07 2021-09-16 美商谷歌有限責任公司 Interleaving memory requests to accelerate memory accesses
US20220057953A1 (en) * 2020-08-18 2022-02-24 SK Hynix Inc. Memory controller and method of operating the same
US11494106B2 (en) * 2020-08-18 2022-11-08 SK Hynix Inc. Memory controller and method of ordering sequential data and random data

Similar Documents

Publication Publication Date Title
CN107430493B (en) Sequential write stream management
EP2715729B1 (en) Apparatus including memory system controllers and related methods
TWI512609B (en) Methods for scheduling read commands and apparatuses using the same
KR20140032789A (en) Controller of nonvolatile memory device and command scheduling method thereof
CN108932106B (en) Solid state disk access method and device using same
CN111796759A (en) Computer readable storage medium and method for fragment data reading on multiple planes
US20220300203A1 (en) Method and apparatus for executing host commands
US9733832B2 (en) Buffer memory accessing method, memory controller and memory storage device
TWI822516B (en) Method and computer program product and apparatus for executing host write commands
TWI822517B (en) Method and computer program product and apparatus for executing host write commands
TWI613656B (en) Methods for priority writes in a ssd (solid state disk) system and apparatuses using the same
TWI747660B (en) Method and apparatus and computer program product for reading data from multiple flash dies
US11494113B2 (en) Computer program product and method and apparatus for scheduling execution of host commands
CN113495850B (en) Method, apparatus and computer readable storage medium for managing garbage collection program
TWI758745B (en) Computer program product and method and apparatus for scheduling executions of host commands
CN114625307A (en) Computer readable storage medium, and data reading method and device of flash memory chip
TWI818762B (en) Method and computer program product and apparatus for scheduling and executing host data-update commands
TWI835027B (en) Method and computer program product and apparatus for updating host-to-flash address mapping table
TWI805505B (en) Method and computer program product and apparatus for scheduling and executing host data-update commands
TWI774277B (en) Method and apparatus for executing host commands
TWI814647B (en) Method and computer program product and apparatus for executing host commands
TWI740446B (en) Computer program product and method and apparatus for managing garbage collection (gc) processes
TWI810876B (en) Method and computer program product and apparatus for data access in response to host discard commands
TWI749490B (en) Computer program product and method and apparatus for programming flash administration tables
TW202321921A (en) Method and computer program product and apparatus for updating host-to-flash address mapping table