WO2015055020A1 - Method and apparatus for writing data - Google Patents

Method and apparatus for writing data Download PDF

Info

Publication number
WO2015055020A1
WO2015055020A1 PCT/CN2014/080509 CN2014080509W WO2015055020A1 WO 2015055020 A1 WO2015055020 A1 WO 2015055020A1 CN 2014080509 W CN2014080509 W CN 2014080509W WO 2015055020 A1 WO2015055020 A1 WO 2015055020A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
valid data
sectors
valid
cache
Prior art date
Application number
PCT/CN2014/080509
Other languages
French (fr)
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 华为技术有限公司
Publication of WO2015055020A1 publication Critical patent/WO2015055020A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0871Allocation or management of cache space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0804Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with main memory updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1032Reliability improvement, data loss prevention, degraded operation etc
    • G06F2212/1036Life time enhancement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/21Employing a record carrier using a specific recording technology
    • G06F2212/214Solid state disk

Definitions

  • the present invention relates to communications technologies, and in particular, to a method and apparatus for writing data. Background technique
  • the current Solid State Device is basically a flash-based medium. Inside an SSD, there are multiple flash granules. Each flash granule is internally divided into several blocks. Each block consists of blocks. Divided into several pages. Flash media cannot convert 0/1 bits to any bit (Wt) bits, and can only be erased and programmed with a certain granularity.
  • the erased granularity is a block, which means that all the Wt bits in the specified block are set to 1;
  • the programmed granularity is a page, which means that the bit specified in the page is set to 0.
  • the page is the minimum granularity for reading and writing inside the SSD, but the SSD is compatible with the hard disk drive (HDD).
  • HDD hard disk drive
  • the process of writing data to the SSD by the host is as follows:
  • the data to be written by the host is first given to the storage array, and the storage array sends the data to the cache in the storage array, and the cache sends the response to the host.
  • the SSD may have a problem of excessive write penalty and write amplification times.
  • write penalty means that the amount of data written to the flash memory is greater than the amount of data written to the SSD, and the write penalty is a special write amplification.
  • write amplification means that the amount of data written to the flash memory is greater than the amount of data written to the SSD, and the write penalty is a special write amplification.
  • Embodiments of the present invention provide a method and apparatus for writing data, which are used to solve the problem of increasing the amount of data written into an SSD due to too many write amplification and write penalty times.
  • a first aspect of the embodiments of the present invention provides a method for writing data, where the method is applied to a storage device, where the storage device includes a controller and a solid state hard disk, and the controller includes a cache, the cache Include multiple pages, each page including multiple sectors, the method includes:
  • the data in the target valid data block is written to the solid state hard disk.
  • the determining, by the cache, the first valid data block includes:
  • a maximum contiguous valid data block is obtained as the first valid data block, the first valid data block including a maximum of consecutive valid sectors.
  • the dirty sector includes data to be written to a solid state hard disk, where the clean sector includes Write data to the solid state drive.
  • a second aspect of the embodiments of the present invention provides an apparatus for writing data, where the storage device includes a controller and a solid state hard disk, the controller includes a cache, and the cache includes a plurality of pages, and each page includes Multiple sectors, including:
  • a determining module configured to determine a first valid data block in the cache, the first valid data block includes a plurality of consecutive valid sectors, and the wired sector holds data; Determining a second valid data block in the valid data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, the target valid data block Contains multiple pages, any of which contains dirty sectors;
  • a write module configured to write data in the target valid data block to the solid state hard disk.
  • the determining module is specifically configured to: traverse all sectors of the preset designated area in the buffer; and obtain a maximum continuous valid data block as The first valid data block includes the most consecutive valid sectors in the first valid data block.
  • the dirty sector includes data to be written to the solid state hard disk, where the clean sector includes Write data to the solid state drive.
  • the first valid data block including the consecutive effective sectors is determined in the cache, and then the valid data block including the dirty sector is determined in the first valid data block, and finally determined in the second valid data block.
  • Target data block each page contained in the target data block has a dirty sector, and the target data block is written into the SSD, thereby reducing the clean sectors written in the SSD as much as possible, thereby reducing the write SSD The amount of data has been extended to extend the life of the SSD.
  • Embodiment 1 is a schematic flowchart of Embodiment 1 of a method for writing data according to the present invention
  • FIG. 2 is a schematic diagram of a sector structure of a method for writing data according to a second embodiment of the present invention
  • FIG. 3 is a schematic diagram of a sector structure of a method for writing data according to a third embodiment of the present invention
  • FIG. 5 is a schematic diagram of a sector structure of a method for writing data according to Embodiment 5 of the present invention
  • FIG. 6 is a schematic diagram of a structure of a device for writing data according to Embodiment 1 of the present invention; Schematic;
  • FIG. 7 is a schematic structural diagram of Embodiment 1 of a storage device according to the present invention. detailed description
  • the embodiment of the present invention is applied to a storage device, where the storage device includes a controller and an SSD.
  • the controller includes a cache, and the cache further includes a plurality of pages, and each page includes multiple sectors. If the data is stored in the sector, the sector is a valid sector, and if no data is saved, it is an invalid sector.
  • the effective sector includes a dirty sector and a clean sector, wherein the dirty sector includes data to be written to the SSD, and the clean sector includes data that has been written into the SSD.
  • FIG. 1 is a schematic flowchart of a first embodiment of a method for writing data according to the present invention.
  • FIG. 2 is a schematic structural diagram of a sector of a method for writing data according to a second embodiment of the present invention. As shown in FIG. 1, the method includes:
  • the first valid data block includes a plurality of consecutive valid sectors in which data is stored.
  • the cache contains a large number of sectors, which can divide a continuous effective sector into a valid data block, and one or more first valid data blocks can be determined in the cache.
  • the dirty sector indicates that the data in the sector is actually written to the SSD, and the data in the dirty sector is different from the current data in the corresponding location in the SSD, and the dirty sector cannot be written new before being erased.
  • the data in the clean sector is the data read by the host from the SSD, and is left in the cache, so the data in the clean sector is the same as the data in the corresponding location in the SSD.
  • Both dirty and clean sectors are valid sectors.
  • the invalid sector can be a blank sector without any content, that is, the host does not read the data of the corresponding sector from the SSD, and there is currently no data in the invalid sector in the cache.
  • the determined first valid data block does not contain an invalid sector.
  • the first valid data block in which the dirty sector is not included is culled, and the remaining first valid data block is taken as the second valid data block.
  • the target valid data block contains multiple pages, any of which contains dirty sectors.
  • Each of the foregoing second valid data blocks may include a plurality of pages. If there are pages in the plurality of pages in which all sectors are clean sectors, such pages are removed from the second valid data block to form The new valid data block is used as the target valid data block, so that each page contained in the target valid data block contains dirty sectors.
  • At least one first valid data block is determined in the cache, and then the first valid data block containing only the clean sector is removed, and then the page containing only the clean sector is removed, and finally the target data block is obtained.
  • the target data block is written to the SSD, which reduces the clean sectors written into the SSD as much as possible, thereby reducing the amount of data written to the SSD and realizing the extended service life of the SSD.
  • FIG. 3 is a schematic diagram of a sector structure of a method for writing data according to a third embodiment of the present invention
  • FIG. 4 is a schematic diagram of a sector structure of a method for writing data according to a fourth embodiment of the present invention
  • FIG. 3, FIG. 4, and FIG. 5, for six consecutive pages it is assumed that one page contains eight sectors, wherein each square represents one sector, and the blank square represents a clean sector, "twill "The shaded squares represent dirty sectors, and the "dot" shaded squares indicate invalid sectors.
  • determining the first valid data block in the cache is: traversing all the sectors of the preset designated area in the cache; acquiring the largest continuous valid data block as the first valid data block, the maximum continuous validity
  • the data block includes the most consecutive valid sectors.
  • the largest contiguous block of data here refers to including as many valid sectors as possible.
  • the capacity of the cache is generally large.
  • the cache does not directly manage the page or sector, but manages a larger granularity. For example, it can manage a page group (page group). ), the above preset designated area refers to the page selected by the preset algorithm.
  • the designated area is six consecutive pages as shown in FIG. 3.
  • the 48 sectors are traversed, and three largest consecutive valid data blocks are obtained as the first valid data block.
  • data blocks A, B, and C are data blocks A, B, and C, respectively.
  • Data block A includes a total of 4 sectors of a3-a6, data block B includes a total of 20 a8-d3, and data block C includes a total of 19 sectors of d6-f8.
  • the 3 first valid data blocks are all included in the most consecutive valid sectors, and there are no invalid sectors.
  • the second valid data block is determined in the three first valid data blocks, that is, the data blocks in which all sectors in the three largest consecutive valid data blocks are clean sectors are culled, that is, the data block A is culled because a3 -a6 are all clean sectors.
  • the remaining data blocks B and C are the second valid data blocks, and the data blocks B and C contain dirty sectors. Further processing the second valid data blocks B and C, processing in units of pages, culling pages in which all sectors in the second valid data block are clean sectors, and data blocks B and C spanning multiple pages As shown in FIG. 4, the data block B spans 4 pages.
  • block C spans 3 pages, but the portions of the 3 pages spanned contain dirty sectors, d8 in d6-d8 is dirty, and el in el-e8 is dirty, fl- In f8, fl, f2, ⁇ , and f8 are dirty sectors, and the resulting target continuous valid data block F is the same as the data block C, that is, the sector in the data block C is not culled.
  • the target data blocks thus determined are data blocks D, E, and F, and finally the data in data blocks D, E, and F are written to the SSD.
  • each data block generates an input/output (Input/Output, I/O for short) when writing to the SSD.
  • I/O input/output
  • an I/O indicates a write request or a read request.
  • the preset designated area in the cache for example, the preset designated area shown in FIG. 3, if the prior art is used, one can simply write the dirty sector directly to the SSD, so that five I/ are generated.
  • the two I/Os of d2 and d8-el may be written.
  • the SSD generates unnecessary junk pages, which will cause write amplification.
  • the two I/Os of fl- ⁇ and f8 will also generate write amplification.
  • the clean sectors written in the SSD are reduced as much as possible, and the write amplification and the write penalty are reduced, thereby reducing the amount of data written into the SSD, thereby realizing the extension of the service life of the SSD, and also Reduce I/O generation and reduce overall overhead.
  • FIG. 6 is a schematic structural diagram of Embodiment 1 of a device for writing data according to the present invention.
  • the storage device includes a controller and a solid state hard disk, and the controller includes a cache, and the cache includes multiple pages. Each page includes multiple sectors.
  • the apparatus includes: a determining module 601 and a writing module 602, wherein:
  • a determining module 601 configured to determine a first valid data block in the cache, the first valid data block includes a plurality of consecutive valid sectors, the wired sector holds data; Determining a second valid data block in the data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, in the target valid data block Contains multiple pages, any of which contains dirty sectors.
  • the writing module 602 is configured to write data in the target valid data block to the solid state hard disk.
  • the determining module 601 is configured to: traverse all sectors in the preset designated area in the buffer; and obtain a maximum continuous valid data block as the first valid data block, where the first The valid data block includes the most consecutive valid sectors. .
  • the dirty sector includes data to be written into the solid state hard disk
  • the clean sector includes data that has been written into the solid state hard disk.
  • FIG. 7 is a schematic structural diagram of Embodiment 1 of a storage device according to the present disclosure.
  • the storage device 110 includes: a processor 701, a memory 702, a system bus (abbreviated as bus) 703, and a communication interface 704, a processor 701, a memory 702, and a communication interface. 704 are connected by system bus 703 and communicate with each other.
  • a processor 701, a memory 702, and a communication interface. 704 are connected by system bus 703 and communicate with each other.
  • Processor 701 can be a central processing unit.
  • the memory 702 is used to store instruction information.
  • Communication interface 704 is used to communicate with external devices.
  • the processor 701 runs the instruction information in the memory 702, and the method flow described in FIG. 1 can be performed.
  • the processor 701 is configured to determine, in the cache, a first valid data block, where the first valid data block includes a plurality of consecutive valid sectors, and the wired sector stores data; Determining a second valid data block in the first valid data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, The target valid data block contains a plurality of pages, and any one of the pages contains a dirty sector. It is also used to write data in the target valid data block to the solid state hard disk.
  • the processor 701 is specifically configured to: traverse all sectors of the preset designated area in the buffer; and obtain a maximum continuous valid data block as the first valid data block, where the first The valid data block includes the most consecutive valid sectors.
  • the dirty sector includes data to be written into the solid state hard disk
  • the clean sector includes data that has been written into the solid state hard disk.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

A method and apparatus for writing data, the method comprising: determining in a cache a first valid data block comprising a plurality of contiguous valid sectors where data is saved; determining in the first valid data block a second valid data block referring to a valid data block containing dirty sectors; determining in the second valid data block a target valid data block containing a plurality of pages, wherein any page contains dirty data; and writing the data in the target valid data block into a solid state disk (SSD). The number of clean sectors written into the SSD is reduced as much as possible, and therefore the volume of data written into the SSD is reduced to prolong the service life of the SSD.

Description

写入数据的方法及装置  Method and device for writing data
本申请要求于 2013年 10月 18日提交中国专利局、 申请号为  This application is submitted to the Chinese Patent Office on October 18, 2013, and the application number is
201310495179.8、 发明名称为 "写入数据的方法及装置" 的中国专利申请 的优先权, 其全部内容通过引用结合在本申请中。 201310495179.8, the entire disclosure of which is incorporated herein by reference in its entirety in its entirety in its entirety in the the the the the the the the the
技术领域 本发明涉及通信技术, 尤其涉及一种写入数据的方法及装置。 背景技术 TECHNICAL FIELD The present invention relates to communications technologies, and in particular, to a method and apparatus for writing data. Background technique
当前的固态硬盘 (Solid State Device, 简称 SSD) 基本都是基于闪存 的介质, 一个 SSD 内部, 有多片闪存颗粒, 每一个闪存颗粒内部, 又分 为若干的块 (block) , 每个块由分为若干的页 (page) 。 闪存介质不能对 任意比特 (Wt) 位进行 0/1的相互转换, 只能按照一定的颗粒度进行擦除 和编程操作。 其中, 擦除的颗粒度为块, 是指将指定块中所有的 Wt位全 部设置为 1 ; 编程的颗粒度为页, 是指将页中指定的 bit为设置为 0。 页是 SSD内部进行读和写的最小粒度,但是 SSD为了与硬盘驱动器(Hard Disk Drive, 简称 HDD) 相兼容, SSD对外提供的接口是以扇区 (sector) 为访 问粒度的。  The current Solid State Device (SSD) is basically a flash-based medium. Inside an SSD, there are multiple flash granules. Each flash granule is internally divided into several blocks. Each block consists of blocks. Divided into several pages. Flash media cannot convert 0/1 bits to any bit (Wt) bits, and can only be erased and programmed with a certain granularity. The erased granularity is a block, which means that all the Wt bits in the specified block are set to 1; the programmed granularity is a page, which means that the bit specified in the page is set to 0. The page is the minimum granularity for reading and writing inside the SSD, but the SSD is compatible with the hard disk drive (HDD). The interface provided by the SSD is granular by the sector.
现有技术中, 主机往 SSD 中写数据的过程为: 主机将要写的数据先 给存储阵列,存储阵列将该数据给存储阵列中的高速缓存器(cache) , cache 向主机发出响应后将数据写入 SSD。如果主机给存储阵列的数据大小小于 一个页的大小, 则 cache可以执行补齐, 即补足一个页的大小, 然后写入 硬盘。  In the prior art, the process of writing data to the SSD by the host is as follows: The data to be written by the host is first given to the storage array, and the storage array sends the data to the cache in the storage array, and the cache sends the response to the host. Write to the SSD. If the size of the data given by the host to the storage array is less than the size of one page, the cache can perform a fill, that is, fill the size of one page and then write to the hard disk.
但是, 采用现有技术, 由于 SSD 内部读写粒度和对外提供的访问粒 度大小的差异, SSD会存在写惩罚和写放大次数过多的问题, 具体地, 对 于主机的写请求, 上述 cache补齐的过程叫做 "写惩罚" ; 写放大是指写 入闪存的数据量大于写入 SSD 的数据量, 写惩罚是一种特殊的写放大。 还有其他原因也会造成写放大,例如写入 SSD的数据没有按照闪存的"页" 对齐, 会进行补齐后再以页的粒度写入闪存。 也就是说采用现有技术会增 加写入 SSD的数据量, 从而会减少 SSD的使用寿命。 发明内容 However, with the prior art, due to the difference between the internal read/write granularity of the SSD and the external access granularity, the SSD may have a problem of excessive write penalty and write amplification times. Specifically, for the write request of the host, the above cache is completed. The process is called "write penalty"; write amplification means that the amount of data written to the flash memory is greater than the amount of data written to the SSD, and the write penalty is a special write amplification. There are other reasons that can cause write amplification, such as writing data to an SSD without following the "page" of the flash. Align, it will be filled in and then written to the flash at the granularity of the page. That is to say, the use of the prior art will increase the amount of data written to the SSD, thereby reducing the useful life of the SSD. Summary of the invention
本发明实施例提供一种写入数据的方法及装置, 用于解决由于写放大和 写惩罚次数太多增加写入 SSD的数据量的问题。  Embodiments of the present invention provide a method and apparatus for writing data, which are used to solve the problem of increasing the amount of data written into an SSD due to too many write amplification and write penalty times.
本发明实施例第一方面提供一种写入数据的方法, 所述方法应用于存储 设备中, 所述存储设备包括控制器和固态硬盘, 所述控制器包括高速缓存器, 所述高速缓存器包括多个页, 每个页包括多个扇区, 该方法包括:  A first aspect of the embodiments of the present invention provides a method for writing data, where the method is applied to a storage device, where the storage device includes a controller and a solid state hard disk, and the controller includes a cache, the cache Include multiple pages, each page including multiple sectors, the method includes:
在所述高速缓存器中确定第一有效数据块, 所述第一有效数据块包括多 个连续的有效扇区, 所述有效扇区保存有数据;  Determining, in the cache, a first valid data block, the first valid data block includes a plurality of consecutive valid sectors, and the valid sector holds data;
在所述第一有效数据块中确定第二有效数据块, 所述第二有效数据块是 指包含脏扇区的有效数据块;  Determining a second valid data block in the first valid data block, where the second valid data block refers to a valid data block including a dirty sector;
在所述第二有效数据块中确定目标有效数据块, 所述目标有效数据块中 包含多个页, 其中任意一个页包含有脏扇区;  Determining a target valid data block in the second valid data block, where the target valid data block includes a plurality of pages, wherein any one of the pages includes a dirty sector;
将所述目标有效数据块中的数据写入固态硬盘。  The data in the target valid data block is written to the solid state hard disk.
结合第一方面, 在第一方面的第一种可能的实施方式中, 所述在所述高 速缓存器中确定第一有效数据块, 包括:  With reference to the first aspect, in a first possible implementation manner of the first aspect, the determining, by the cache, the first valid data block includes:
遍历所述高速缓存器中预设指定区域的所有扇区;  Traversing all sectors of the cache in a predetermined designated area;
获取最大连续有效数据块作为所述第一有效数据块, 所述第一有效数据 块包括最多的连续有效扇区。  A maximum contiguous valid data block is obtained as the first valid data block, the first valid data block including a maximum of consecutive valid sectors.
结合第一方面的第一种可能的实施方式, 在第一方面的第二种可能的实 施方式中, 所述脏扇区中包括将要写入固态硬盘的数据, 所述干净扇区中包 括已经写入固态硬盘的数据。  With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the dirty sector includes data to be written to a solid state hard disk, where the clean sector includes Write data to the solid state drive.
本发明实施例第二方面提供一种写入数据的装置, 所述存储设备包括控 制器和固态硬盘, 所述控制器包括高速缓存器, 所述高速缓存器包括多个页, 每个页包括多个扇区, 包括:  A second aspect of the embodiments of the present invention provides an apparatus for writing data, where the storage device includes a controller and a solid state hard disk, the controller includes a cache, and the cache includes a plurality of pages, and each page includes Multiple sectors, including:
确定模块, 用于在上述高速缓存器中确定第一有效数据块, 所述第一有 效数据块包括多个连续有效的扇区, 所述有线扇区保存有数据; 在所述第一 有效数据块中确定第二有效数据块, 所述第二有效数据块是指包含脏扇区的 有效数据块; 在所述第二有效数据块中确定目标有效数据块, 所述目标有效 数据块中包含多个页, 其中任意一个页包含有脏扇区; a determining module, configured to determine a first valid data block in the cache, the first valid data block includes a plurality of consecutive valid sectors, and the wired sector holds data; Determining a second valid data block in the valid data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, the target valid data block Contains multiple pages, any of which contains dirty sectors;
写入模块, 用于将所述目标有效数据块中的数据写入固态硬盘。  And a write module, configured to write data in the target valid data block to the solid state hard disk.
结合第二方面, 在第二方面的第一种可能的实施方式中, 所述确定模块, 具体用于遍历所述告诉缓存器中预设指定区域的所有扇区; 获取最大连续有 效数据块作为所述第一有效数据块, 所述第一有效数据块中包括最多的连续 有效扇区。  With reference to the second aspect, in a first possible implementation manner of the second aspect, the determining module is specifically configured to: traverse all sectors of the preset designated area in the buffer; and obtain a maximum continuous valid data block as The first valid data block includes the most consecutive valid sectors in the first valid data block.
结合第二方面的第一种可能的实施方式, 在第二方面的第二种可能的实 施方式中, 所述脏扇区中包括将要写入固态硬盘的数据, 所述干净扇区中包 括已经写入固态硬盘的数据。  With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the dirty sector includes data to be written to the solid state hard disk, where the clean sector includes Write data to the solid state drive.
本发明实施例中, 在 cache中确定包含连续有效扇区的第一有效数据块, 然后再第一有效数据块中确定包含脏扇区的有效数据块, 最后在第二有效数 据块中确定出目标数据块, 该目标数据块中包含的每个页都有脏扇区, 将该 目标数据块写入 SSD, 这样尽可能的减少了写入 SSD中的干净扇区, 从而减 少了写入 SSD的数据量, 实现了 SSD的使用寿命的延长。 附圏说明  In the embodiment of the present invention, the first valid data block including the consecutive effective sectors is determined in the cache, and then the valid data block including the dirty sector is determined in the first valid data block, and finally determined in the second valid data block. Target data block, each page contained in the target data block has a dirty sector, and the target data block is written into the SSD, thereby reducing the clean sectors written in the SSD as much as possible, thereby reducing the write SSD The amount of data has been extended to extend the life of the SSD. Appendix
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作一简单地介绍, 显而易见地, 下 面描述中的附图是本发明的一些实施例, 对于本领域普通技术人员来讲, 在 不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。  In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any inventive labor.
图 1为本发明提供的写入数据的方法实施例一的流程示意图;  1 is a schematic flowchart of Embodiment 1 of a method for writing data according to the present invention;
图 2为本发明提供的写入数据的方法实施例二的扇区结构示意图; 图 3为本发明提供的写入数据的方法实施例三的扇区结构示意图; 图 4为本发明提供的写入数据的方法实施例四的扇区结构示意图; 图 5为本发明提供的写入数据的方法实施例五的扇区结构示意图; 图 6为本发明提供的写入数据的装置实施例一的结构示意图;  2 is a schematic diagram of a sector structure of a method for writing data according to a second embodiment of the present invention; FIG. 3 is a schematic diagram of a sector structure of a method for writing data according to a third embodiment of the present invention; FIG. 5 is a schematic diagram of a sector structure of a method for writing data according to Embodiment 5 of the present invention; FIG. 6 is a schematic diagram of a structure of a device for writing data according to Embodiment 1 of the present invention; Schematic;
图 7为本发明提供的存储设备实施例一的结构示意图。 具体实施方式 FIG. 7 is a schematic structural diagram of Embodiment 1 of a storage device according to the present invention. detailed description
为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本发 明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于 本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提下所获 得的所有其他实施例, 都属于本发明保护的范围。  The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例应用于存储设备中, 该存储设备包括控制器和 SSD, 该控 制器包括 cache, cache中又包含多个页, 每个页包含多个扇区。 其中, 扇区 中如果保存有数据, 则该扇区是有效扇区, 如果没有保存数据, 则是无效扇 区。 本发明实施例中, 有效扇区包含脏扇区和干净扇区, 其中, 脏扇区中包 括将要写入 SSD的数据, 干净扇区中包括已经写入 SSD的数据。  The embodiment of the present invention is applied to a storage device, where the storage device includes a controller and an SSD. The controller includes a cache, and the cache further includes a plurality of pages, and each page includes multiple sectors. If the data is stored in the sector, the sector is a valid sector, and if no data is saved, it is an invalid sector. In the embodiment of the present invention, the effective sector includes a dirty sector and a clean sector, wherein the dirty sector includes data to be written to the SSD, and the clean sector includes data that has been written into the SSD.
图 1为本发明提供的写入数据的方法实施例一的流程示意图, 图 2为本 发明提供的写入数据的方法实施例二的扇区结构示意图, 如图 1所示, 该方 法包括:  1 is a schematic flowchart of a first embodiment of a method for writing data according to the present invention. FIG. 2 is a schematic structural diagram of a sector of a method for writing data according to a second embodiment of the present invention. As shown in FIG. 1, the method includes:
S101、 在 cache 中确定第一有效数据块。 该第一有效数据块包括多个连 续的有效扇区, 该有效扇区中保存有数据。 cache中包含很多的扇区, 可以将 连续的有效扇区划分为一个有效数据块, 在 cache 中可以确定出一个或多个 第一有效数据块。  S101. Determine a first valid data block in the cache. The first valid data block includes a plurality of consecutive valid sectors in which data is stored. The cache contains a large number of sectors, which can divide a continuous effective sector into a valid data block, and one or more first valid data blocks can be determined in the cache.
具体地, 脏扇区表示该扇区中的数据是实际要写入 SSD的, 该脏扇区中 的数据与 SSD中对应位置当前的数据不同, 脏扇区在被擦除前不能写入新的 数据。 干净扇区中的数据是主机从 SSD中读取过的数据, 留在 cache中, 因 而干净扇区中的数据与 SSD中对应位置的数据相同。脏扇区和干净扇区都为 有效扇区。 无效扇区可以为没有任何内容的空白扇区, 即主机没有从 SSD中 读取过对应扇区的数据, cache中该无效扇区内当前没有任何数据。确定出的 第一有效数据块中都不包含无效扇区。  Specifically, the dirty sector indicates that the data in the sector is actually written to the SSD, and the data in the dirty sector is different from the current data in the corresponding location in the SSD, and the dirty sector cannot be written new before being erased. The data. The data in the clean sector is the data read by the host from the SSD, and is left in the cache, so the data in the clean sector is the same as the data in the corresponding location in the SSD. Both dirty and clean sectors are valid sectors. The invalid sector can be a blank sector without any content, that is, the host does not read the data of the corresponding sector from the SSD, and there is currently no data in the invalid sector in the cache. The determined first valid data block does not contain an invalid sector.
如图 2所示, 假设一个页包含 8各扇区, 其中, 每一个方格代表一个扇 区, 空白的方格表示干净扇区, "斜纹" 阴影的方格表示脏扇区, "点" 阴影 的方格表示无效扇区, ml-m8这 8个扇区表示一个页, nl-n8这 8各扇区表 示另一个页, 这两个页是 SSD中连续的两个页。可以看出 m5-n3连续扇区构 成的数据块 M中包含 7个连续有效数据块, 其中没有无效扇区, 可以被确定 为上述第一有效数据块。 As shown in Figure 2, suppose a page contains 8 sectors, where each square represents a sector, blank squares indicate clean sectors, and "twill" shaded squares indicate dirty sectors, "dot" The shaded squares indicate invalid sectors, the 8 sectors of ml-m8 represent one page, and the 8 sectors of nl-n8 represent another page, which are two consecutive pages in the SSD. It can be seen that m5-n3 continuous sector structure The resulting data block M contains seven consecutive valid data blocks, wherein there are no invalid sectors, which can be determined as the first valid data block.
5102、 在上述第一有效数据块中确定第二有效数据块, 该第二有效数据 块是指包含脏扇区的有效数据块。  5102. Determine a second valid data block in the first valid data block, where the second valid data block refers to a valid data block that includes a dirty sector.
也就是, 若 S101中确定多个第一有效数据块, 将其中不包含脏扇区的第 一有效数据块剔除, 将剩下的第一有效数据块作为第二有效数据块。  That is, if a plurality of first valid data blocks are determined in S101, the first valid data block in which the dirty sector is not included is culled, and the remaining first valid data block is taken as the second valid data block.
5103、 在上述第二有效数据块中确定目标有效数据块。 该目标有效数据 块中包含多个页, 其中任意一个页包含有脏扇区。  5103. Determine a target valid data block in the second valid data block. The target valid data block contains multiple pages, any of which contains dirty sectors.
每个上述第二有效数据块中可以包含多个页, 如果这多个页中存在有所 有扇区都为干净扇区的页, 则将这种页从上述第二有效数据块中剔除, 形成 新的有效数据块, 作为目标有效数据块, 这样目标有效数据块中包含的每个 页中都包含脏扇区。  Each of the foregoing second valid data blocks may include a plurality of pages. If there are pages in the plurality of pages in which all sectors are clean sectors, such pages are removed from the second valid data block to form The new valid data block is used as the target valid data block, so that each page contained in the target valid data block contains dirty sectors.
5104、 将上述目标数据块中的数据写入 SSD。  5104. Write data in the target data block to the SSD.
本实施例中, 在 cache 中确定至少一个第一有效数据块, 然后剔除只包 含干净扇区的第一有效数据块, 再进一歩剔除只包含干净扇区的页, 最后得 到目标数据块, 将目标数据块写入 SSD, 这样尽可能的减少了写入 SSD中的 干净扇区, 从而减少了写入 SSD的数据量, 实现了 SSD的使用寿命的延长。  In this embodiment, at least one first valid data block is determined in the cache, and then the first valid data block containing only the clean sector is removed, and then the page containing only the clean sector is removed, and finally the target data block is obtained. The target data block is written to the SSD, which reduces the clean sectors written into the SSD as much as possible, thereby reducing the amount of data written to the SSD and realizing the extended service life of the SSD.
图 3为本发明提供的写入数据的方法实施例三的扇区结构示意图, 图 4 为本发明提供的写入数据的方法实施例四的扇区结构示意图, 图 5为本发明 提供的写入数据的方法实施例五的扇区结构示意图。如图 3、图 4、图 5所示, 为连续的 6个页, 假设一个页包含 8各扇区, 其中, 每一个方格代表一个扇 区, 空白的方格表示干净扇区, "斜纹" 阴影的方格表示脏扇区, "点" 阴影 的方格表示无效扇区。  3 is a schematic diagram of a sector structure of a method for writing data according to a third embodiment of the present invention, and FIG. 4 is a schematic diagram of a sector structure of a method for writing data according to a fourth embodiment of the present invention. FIG. A schematic diagram of the sector structure of the fifth embodiment of the method for entering data. As shown in FIG. 3, FIG. 4, and FIG. 5, for six consecutive pages, it is assumed that one page contains eight sectors, wherein each square represents one sector, and the blank square represents a clean sector, "twill "The shaded squares represent dirty sectors, and the "dot" shaded squares indicate invalid sectors.
进一歩地, 上述在上述 cache 中确定第一有效数据块, 具体为: 遍历上 述 cache 中预设指定区域的所有扇区; 获取最大连续有效数据块作为上述第 一有效数据块, 上述最大连续有效数据块包括最多的连续有效扇区。 这里最 大连续有效数据块是指将尽可能多的有效扇区包含进来。  Further, the foregoing determining the first valid data block in the cache is: traversing all the sectors of the preset designated area in the cache; acquiring the largest continuous valid data block as the first valid data block, the maximum continuous validity The data block includes the most consecutive valid sectors. The largest contiguous block of data here refers to including as many valid sectors as possible.
需要说明的是, cache 的容量一般都比较大, 为了减小管理开销, cache 不会直接管理到页或扇区, 而是会管理一个更大的粒度, 例如可以是管理一 个页面组 (page group) , 上述预设指定区域是指采用预设算法选择出的 page grou It should be noted that the capacity of the cache is generally large. To reduce the management overhead, the cache does not directly manage the page or sector, but manages a larger granularity. For example, it can manage a page group (page group). ), the above preset designated area refers to the page selected by the preset algorithm. Grou
举例说明上述流程, 如图 3所示, 指定区域为图 3所示的 6个连续的页, 首先遍历这 48个扇区, 获取到 3个最大连续有效数据块, 作为上述第一有效 数据块, 分别是数据块 A、 B、 C, 数据块 A包括 a3-a6共 4个扇区、 数据块 B包括 a8-d3共 20个、数据块 C包括 d6-f8共 19个扇区, 可以看出这 3第一 有效数据块都是包括了最多的连续有效扇区, 其中没有无效扇区。 然后, 在 上述 3个第一有效数据块中确定第二有效数据块, 即将上述 3个最大连续有 效数据块中所有扇区都为干净扇区的数据块剔除,即剔除数据块 A,因为 a3-a6 都为干净扇区, 如图 4所示, 剩余的数据块 B和 C作为第二有效数据块, 数 据块 B和 C中都包含有脏扇区。 进一歩对第二有效数据块 B和 C进行处理, 以页为单位进行处理, 剔除第二有效数据块中所有扇区都为干净扇区的页, 数据块 B和 C都跨越了多个页, 如图 4所示, 数据块 B跨越了 4个页, 第一 个页 al-a8中, 只有 a8属于该数据块 B, a8为干净的扇区, 将 a8剔除, 第 二个页 cl-c8都为干净扇区, 将 cl-c8这整个页删除, 获取目标数据块, 如图 5所示, 处理后, 原数据块 B现在切成数据块 D和数据块£。 同理, 数据块 C跨越了 3个页, 但是所跨越的这 3个页的部分都包含脏扇区, d6-d8中 d8 为脏扇区, el-e8中 el为脏扇区, fl-f8中 fl、 f2、 β、 f8为脏扇区, 于是最 后得到的目标连续有效数据块 F与数据块 C一样, 即没有剔除数据块 C中的 扇区。 这样确定出的目标数据块为数据块 D、 E、 F, 最后将数据块 D、 E、 F 中的数据都写入 SSD。  For example, as shown in FIG. 3, the designated area is six consecutive pages as shown in FIG. 3. First, the 48 sectors are traversed, and three largest consecutive valid data blocks are obtained as the first valid data block. , are data blocks A, B, and C, respectively. Data block A includes a total of 4 sectors of a3-a6, data block B includes a total of 20 a8-d3, and data block C includes a total of 19 sectors of d6-f8. The 3 first valid data blocks are all included in the most consecutive valid sectors, and there are no invalid sectors. Then, the second valid data block is determined in the three first valid data blocks, that is, the data blocks in which all sectors in the three largest consecutive valid data blocks are clean sectors are culled, that is, the data block A is culled because a3 -a6 are all clean sectors. As shown in Figure 4, the remaining data blocks B and C are the second valid data blocks, and the data blocks B and C contain dirty sectors. Further processing the second valid data blocks B and C, processing in units of pages, culling pages in which all sectors in the second valid data block are clean sectors, and data blocks B and C spanning multiple pages As shown in FIG. 4, the data block B spans 4 pages. In the first page a-a8, only a8 belongs to the data block B, a8 is a clean sector, and a8 is eliminated, and the second page cl- C8 is a clean sector, and the entire page of cl-c8 is deleted to obtain the target data block. As shown in FIG. 5, after processing, the original data block B is now cut into data block D and data block £. Similarly, block C spans 3 pages, but the portions of the 3 pages spanned contain dirty sectors, d8 in d6-d8 is dirty, and el in el-e8 is dirty, fl- In f8, fl, f2, β, and f8 are dirty sectors, and the resulting target continuous valid data block F is the same as the data block C, that is, the sector in the data block C is not culled. The target data blocks thus determined are data blocks D, E, and F, and finally the data in data blocks D, E, and F are written to the SSD.
需要说明的是每个数据块在写入 SSD 时都会产生一个输入 /输出 (Input/Output, 简称 I/O), 本发明实施例中一个 I/O表示一次写请求或读请 求。  It should be noted that each data block generates an input/output (Input/Output, I/O for short) when writing to the SSD. In the embodiment of the present invention, an I/O indicates a write request or a read request.
对于 cache中的预设指定区域, 例如图 3所示的预设指定区域, 如果采 用现有技术, 一种可以是简单的将脏扇区直接写入 SSD, 这样的话就会产生 5个 I/O:将 b6写入 SSD产生一个 I/O、将 d2写入 SSD产生一个 I/O、将 d8-el 写入 SSD产生一个 I/O、将 fl-β写入 SSD产生一个 I/O、将 f8—个写入 SSD 产生一个 1/0, 而且这 5个 I/O写入 SSD时都需要补齐, 会产生写惩罚, d2 和 d8-el这两个 I/O可能会在写入 SSD产生不必要的垃圾页, 即会产生写放 大, 同样, fl-β和 f8这两个 I/O写入时也会产生写放大。 本实施例中, 尽可能的减少了写入 SSD中的干净扇区, 实现了写放大和 写惩罚减少,从而减少了写入 SSD的数据量,实现了 SSD的使用寿命的延长, 同时还可以减少 I/O的产生, 减小了整体开销。 For the preset designated area in the cache, for example, the preset designated area shown in FIG. 3, if the prior art is used, one can simply write the dirty sector directly to the SSD, so that five I/ are generated. O: Write b6 to SSD to generate an I/O, write d2 to SSD to generate an I/O, write d8-el to SSD to generate an I/O, and write fl-β to SSD to generate an I/O. Write f8-write to SSD to generate a 1/0, and these 5 I/Os need to be filled when writing to SSD, which will generate write penalty. The two I/Os of d2 and d8-el may be written. The SSD generates unnecessary junk pages, which will cause write amplification. Similarly, the two I/Os of fl-β and f8 will also generate write amplification. In this embodiment, the clean sectors written in the SSD are reduced as much as possible, and the write amplification and the write penalty are reduced, thereby reducing the amount of data written into the SSD, thereby realizing the extension of the service life of the SSD, and also Reduce I/O generation and reduce overall overhead.
图 6为本发明提供的写入数据的装置实施例一的结构示意图, 该装置应 用与存储设备中, 该存储设备包括控制器和固态硬盘, 该控制器包括 cache, 该 cache包括多个页, 每个页包括多个扇区。 如图 6所示, 该装置包括: 确 定模块 601和写入模块 602, 其中:  FIG. 6 is a schematic structural diagram of Embodiment 1 of a device for writing data according to the present invention. In the device application and storage device, the storage device includes a controller and a solid state hard disk, and the controller includes a cache, and the cache includes multiple pages. Each page includes multiple sectors. As shown in FIG. 6, the apparatus includes: a determining module 601 and a writing module 602, wherein:
确定模块 601, 用于在上述高速缓存器中确定第一有效数据块, 所述第 一有效数据块包括多个连续有效的扇区, 所述有线扇区保存有数据; 在所述 第一有效数据块中确定第二有效数据块, 所述第二有效数据块是指包含脏扇 区的有效数据块; 在所述第二有效数据块中确定目标有效数据块, 所述目标 有效数据块中包含多个页, 其中任意一个页包含有脏扇区。  a determining module 601, configured to determine a first valid data block in the cache, the first valid data block includes a plurality of consecutive valid sectors, the wired sector holds data; Determining a second valid data block in the data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, in the target valid data block Contains multiple pages, any of which contains dirty sectors.
写入模块 602, 用于将所述目标有效数据块中的数据写入固态硬盘。 在上述实施例的基础上, 确定模块 601, 具体用于遍历所述告诉缓存器 中预设指定区域的所有扇区; 获取最大连续有效数据块作为所述第一有效数 据块, 所述第一有效数据块中包括最多的连续有效扇区。 。  The writing module 602 is configured to write data in the target valid data block to the solid state hard disk. On the basis of the foregoing embodiment, the determining module 601 is configured to: traverse all sectors in the preset designated area in the buffer; and obtain a maximum continuous valid data block as the first valid data block, where the first The valid data block includes the most consecutive valid sectors. .
需要说明的是, 所述脏扇区中包括将要写入固态硬盘的数据, 所述干净 扇区中包括已经写入固态硬盘的数据。  It should be noted that the dirty sector includes data to be written into the solid state hard disk, and the clean sector includes data that has been written into the solid state hard disk.
上述各模块用于执行前述方法实施例, 其实现原理和技术效果类似, 在 此不再赘述。  The foregoing modules are used to implement the foregoing method embodiments, and the implementation principles and technical effects are similar, and details are not described herein again.
图 7为本发明提供的存储设备实施例一的结构示意图, 该存储设备 110 包括: 处理器 701、 存储器 702、 系统总线 (简称总线) 703和通信接口 704, 处理器 701、 存储器 702和通信接口 704之间通过系统总线 703连接并完成 相互间的通信。  FIG. 7 is a schematic structural diagram of Embodiment 1 of a storage device according to the present disclosure. The storage device 110 includes: a processor 701, a memory 702, a system bus (abbreviated as bus) 703, and a communication interface 704, a processor 701, a memory 702, and a communication interface. 704 are connected by system bus 703 and communicate with each other.
处理器 701可以为中央处理单元。 存储器 702用于存储指令信息。 通信 接口 704用于与外部设备进行通信。  Processor 701 can be a central processing unit. The memory 702 is used to store instruction information. Communication interface 704 is used to communicate with external devices.
具体实现过程中, 处理器 701运行存储器 702中的指令信息, 可以执行 图 1所述的方法流程。  In a specific implementation process, the processor 701 runs the instruction information in the memory 702, and the method flow described in FIG. 1 can be performed.
具体地, 该处理器 701, 用于在上述高速缓存器中确定第一有效数据块, 所述第一有效数据块包括多个连续有效的扇区, 所述有线扇区保存有数据; 在所述第一有效数据块中确定第二有效数据块, 所述第二有效数据块是指包 含脏扇区的有效数据块; 在所述第二有效数据块中确定目标有效数据块, 所 述目标有效数据块中包含多个页, 其中任意一个页包含有脏扇区。 还用于将 所述目标有效数据块中的数据写入固态硬盘。 Specifically, the processor 701 is configured to determine, in the cache, a first valid data block, where the first valid data block includes a plurality of consecutive valid sectors, and the wired sector stores data; Determining a second valid data block in the first valid data block, the second valid data block refers to a valid data block including a dirty sector; determining a target valid data block in the second valid data block, The target valid data block contains a plurality of pages, and any one of the pages contains a dirty sector. It is also used to write data in the target valid data block to the solid state hard disk.
在上述实施例的基础上, 处理器 701, 具体用于遍历所述告诉缓存器中 预设指定区域的所有扇区; 获取最大连续有效数据块作为所述第一有效数据 块, 所述第一有效数据块中包括最多的连续有效扇区。  On the basis of the foregoing embodiment, the processor 701 is specifically configured to: traverse all sectors of the preset designated area in the buffer; and obtain a maximum continuous valid data block as the first valid data block, where the first The valid data block includes the most consecutive valid sectors.
其中, 所述脏扇区中包括将要写入固态硬盘的数据, 所述干净扇区中包 括已经写入固态硬盘的数据。  The dirty sector includes data to be written into the solid state hard disk, and the clean sector includes data that has been written into the solid state hard disk.
本领域普通技术人员可以理解: 实现上述各方法实施例的全部或部分歩 骤可以通过程序指令相关的硬件来完成。 前述的程序可以存储于一计算机可 读取存储介质中。 该程序在执行时, 执行包括上述各方法实施例的歩骤; 而 前述的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码 的介质。  One of ordinary skill in the art will appreciate that all or a portion of the steps of implementing the various method embodiments described above can be accomplished by hardware associated with the program instructions. The aforementioned program can be stored in a computer readable storage medium. The program, when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并 不使相应技术方案的本质脱离本发明各实施例技术方案的范围。  Finally, it should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting thereof; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims

权利要求书 claims
1、 一种写入数据的方法, 所述方法应用于存储设备中, 所述存储设备包 括控制器和固态硬盘, 所述控制器包括高速缓存器, 所述高速缓存器包括多 个页, 每个页包括多个扇区, 其特征在于, 所述方法包括: 1. A method of writing data. The method is applied to a storage device. The storage device includes a controller and a solid-state drive. The controller includes a cache. The cache includes multiple pages. Each page Each page includes multiple sectors, characterized in that the method includes:
在所述高速缓存器中确定第一有效数据块, 所述第一有效数据块包括多 个连续的有效扇区, 所述有效扇区保存有数据; Determine a first valid data block in the cache, the first valid data block includes a plurality of consecutive valid sectors, and the valid sectors store data;
在所述第一有效数据块中确定第二有效数据块, 所述第二有效数据块是 指包含脏扇区的有效数据块; Determine a second valid data block in the first valid data block, where the second valid data block refers to a valid data block including dirty sectors;
在所述第二有效数据块中确定目标有效数据块, 所述目标有效数据块中 包含多个页, 其中任意一个页包含有脏扇区; Determine a target valid data block in the second valid data block, where the target valid data block contains multiple pages, any one of which contains dirty sectors;
将所述目标有效数据块中的数据写入固态硬盘。 Write the data in the target valid data block to the solid state drive.
2、 根据权利要求 1所述的方法, 其特征在于, 所述在所述高速缓存器中 确定第一有效数据块, 包括: 2. The method of claim 1, wherein determining the first valid data block in the cache includes:
遍历所述高速缓存器中预设指定区域的所有扇区; Traverse all sectors of the preset designated area in the cache;
获取最大连续有效数据块作为所述第一有效数据块, 所述第一有效数据 块包括最多的连续有效扇区。 The largest continuous valid data block is obtained as the first valid data block, and the first valid data block includes the most continuous valid sectors.
3、 根据权利要求 2所述的方法, 其特征在于, 所述脏扇区中包括将要写 入固态硬盘的数据, 所述干净扇区中包括已经写入固态硬盘的数据。 3. The method according to claim 2, wherein the dirty sectors include data to be written to the solid state drive, and the clean sectors include data that have been written to the solid state drive.
4、 一种写入数据的装置, 该装置应用于存储设备中, 所述存储设备包括 控制器和固态硬盘, 所述控制器包括高速缓存器, 所述高速缓存器包括多个 页, 每个页包括多个扇区, 其特征在于, 包括: 4. A device for writing data. The device is used in a storage device. The storage device includes a controller and a solid-state drive. The controller includes a cache. The cache includes a plurality of pages. Each page A page includes multiple sectors, which are characterized by:
确定模块, 用于在上述高速缓存器中确定第一有效数据块, 所述第一有 效数据块包括多个连续有效的扇区, 所述有线扇区保存有数据; 在所述第一 有效数据块中确定第一.有效数据块, 所述第一.有效数据块是指包含脏扇区的 有效数据块; 在所述第二有效数据块中确定目标有效数据块, 所述目标有效 数据块中包含多个页, 其中任意一个页包含有脏扇区; Determining module, used to determine a first valid data block in the above-mentioned cache memory, the first valid data block includes a plurality of continuous valid sectors, the wired sectors store data; in the first valid data Determine the first valid data block in the block, the first valid data block refers to the valid data block containing dirty sectors; determine the target valid data block in the second valid data block, the target valid data block Contains multiple pages, any one of which contains dirty sectors;
写入模块, 用于将所述目标有效数据块中的数据写入固态硬盘。 A writing module, configured to write the data in the target valid data block to the solid state disk.
5、 根据权利要求 4所述的装置, 其特征在于, 所述确定模块, 具体用于 遍历所述告诉缓存器中预设指定区域的所有扇区; 获取最大连续有效数据块 作为所述第一有效数据块,所述第一有效数据块中包括最多的连续有效扇区。 5. The device according to claim 4, characterized in that the determining module is specifically used to Traverse all sectors in the preset designated area in the notification buffer; obtain the largest continuous valid data block as the first valid data block, and the first valid data block includes the most continuous valid sectors.
6、 根据权利要求 5所述的装置, 其特征在于, 所述脏扇区中包括将要写 入固态硬盘的数据, 所述干净扇区中包括已经写入固态硬盘的数据。 6. The device according to claim 5, wherein the dirty sectors include data to be written to the solid state drive, and the clean sectors include data that have been written to the solid state drive.
PCT/CN2014/080509 2013-10-18 2014-06-23 Method and apparatus for writing data WO2015055020A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310495179.8A CN103513941B (en) 2013-10-18 2013-10-18 The method and device of write data
CN201310495179.8 2013-10-18

Publications (1)

Publication Number Publication Date
WO2015055020A1 true WO2015055020A1 (en) 2015-04-23

Family

ID=49896741

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080509 WO2015055020A1 (en) 2013-10-18 2014-06-23 Method and apparatus for writing data

Country Status (2)

Country Link
CN (1) CN103513941B (en)
WO (1) WO2015055020A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103513941B (en) * 2013-10-18 2016-08-17 华为技术有限公司 The method and device of write data
CN111399783B (en) * 2020-04-22 2024-01-16 Oppo广东移动通信有限公司 Data writing method and device of storage device, electronic device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156753A (en) * 2011-04-29 2011-08-17 中国人民解放军国防科学技术大学 Data page caching method for file system of solid-state hard disc
CN102725752A (en) * 2011-10-20 2012-10-10 华为技术有限公司 Method and device for processing dirty data
CN102999441A (en) * 2012-11-15 2013-03-27 清华大学 Fine granularity memory access method
CN103513941A (en) * 2013-10-18 2014-01-15 华为技术有限公司 Method and device for writing data

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8266501B2 (en) * 2009-09-29 2012-09-11 Micron Technology, Inc. Stripe based memory operation
CN101819509A (en) * 2010-04-19 2010-09-01 清华大学深圳研究生院 Solid state disk read-write method
CN103279561A (en) * 2013-06-13 2013-09-04 三珠数码软件开发(上海)有限公司 Method for increasing random database data read-write speed

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156753A (en) * 2011-04-29 2011-08-17 中国人民解放军国防科学技术大学 Data page caching method for file system of solid-state hard disc
CN102725752A (en) * 2011-10-20 2012-10-10 华为技术有限公司 Method and device for processing dirty data
CN102999441A (en) * 2012-11-15 2013-03-27 清华大学 Fine granularity memory access method
CN103513941A (en) * 2013-10-18 2014-01-15 华为技术有限公司 Method and device for writing data

Also Published As

Publication number Publication date
CN103513941A (en) 2014-01-15
CN103513941B (en) 2016-08-17

Similar Documents

Publication Publication Date Title
US9910597B2 (en) Memory system having a plurality of writing modes
US10127166B2 (en) Data storage controller with multiple pipelines
US10114578B2 (en) Solid state disk and data moving method
JP6163532B2 (en) Device including memory system controller
KR101491943B1 (en) Transaction log recovery
EP2778888B1 (en) Selecting between non-volatile memory units having different minimum addressable data unit sizes
KR101643273B1 (en) Method of storing data in storage media, data storage device using the same, and system including the same
CN102122235B (en) RAID4 (redundant array of independent disks) system and data reading and writing method thereof
KR101678868B1 (en) Apparatus for flash address translation apparatus and method thereof
CN113971104A (en) System and method for parity-based fault protection of storage devices
US9400603B2 (en) Implementing enhanced performance flash memory devices
KR101663066B1 (en) Solid state memory command queue in hybrid device
JP2011505046A (en) Increasing spare area in memory to extend memory life
JP2008015769A (en) Storage system and writing distribution method
US20120159050A1 (en) Memory system and data transfer method
JP2009163647A (en) Disk array device
US9933955B1 (en) Power safe write buffer for data storage device
CN105005510A (en) Error correction protection architecture and method applied to resistive random access memory cache of solid state disk
WO2015055020A1 (en) Method and apparatus for writing data
US10083117B2 (en) Filtering write request sequences
CN114510435A (en) Programming command processing method and device
KR101653999B1 (en) Storage system based on nand flash and data retention improving method
US20110264848A1 (en) Data recording device
JP5953245B2 (en) Information processing system
WO2016194979A1 (en) Storage system, storage control device, storage control method, and program

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14854111

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14854111

Country of ref document: EP

Kind code of ref document: A1