CN102981963B - A kind of implementation method of flash translation layer (FTL) of solid-state disk - Google Patents

A kind of implementation method of flash translation layer (FTL) of solid-state disk Download PDF

Info

Publication number
CN102981963B
CN102981963B CN201210427484.9A CN201210427484A CN102981963B CN 102981963 B CN102981963 B CN 102981963B CN 201210427484 A CN201210427484 A CN 201210427484A CN 102981963 B CN102981963 B CN 102981963B
Authority
CN
China
Prior art keywords
mapping
page
page number
logical
cache
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201210427484.9A
Other languages
Chinese (zh)
Other versions
CN102981963A (en
Inventor
吴非
谢长生
周健
朱胜本
陈克
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huazhong University of Science and Technology
Original Assignee
Huazhong University of Science and Technology
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 Huazhong University of Science and Technology filed Critical Huazhong University of Science and Technology
Priority to CN201210427484.9A priority Critical patent/CN102981963B/en
Publication of CN102981963A publication Critical patent/CN102981963A/en
Application granted granted Critical
Publication of CN102981963B publication Critical patent/CN102981963B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7201Logical to physical mapping or translation of blocks or pages

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

本发明公开了一种固态盘的闪存转换层的实现方法,包括:接收文件系统发出的读写请求,该读写请求对应于逻辑地址为K的页面,判断逻辑地址K是否在缓存映射表中命中,如果不是,则判断缓存映射表中是否能够再容得下一次调入缓存映射表的映射关系数目n,如果不能够容得下,则找出在缓存映射表中找出一个最近最少使用的一个映射关系的逻辑页号Victim_Num,在缓存映射表中找出和Victim_Num的映射关系在映射表中存储在同一页中的所有逻辑页号,并从这些逻辑页号对应的映射关系中找出n个最近最少使用的映射关系,根据Victim_Num在全局转换目录中寻找到相应的映射关系。本发明读写效率更高,并提高了系统的性能,延长固态盘的寿命。

The invention discloses a method for realizing a flash conversion layer of a solid-state disk, comprising: receiving a read-write request sent by a file system, the read-write request corresponds to a page with a logical address K, and judging whether the logical address K is in a cache mapping table Hit, if not, then judge whether the cache mapping table can accommodate the number n of mapping relations transferred into the cache mapping table next time, if not, find out a least recently used one in the cache mapping table The logical page number Victim_Num of a mapping relationship, find out the mapping relationship with Victim_Num in the cache mapping table, store all logical page numbers in the same page in the mapping table, and find out from the mapping relationship corresponding to these logical page numbers For the n least recently used mappings, find the corresponding mappings in the global conversion directory according to Victim_Num. The invention has higher reading and writing efficiency, improves the performance of the system, and prolongs the service life of the solid state disk.

Description

一种固态盘的闪存转换层的实现方法A method for implementing a flash conversion layer of a solid state disk

技术领域technical field

本发明属于固态盘存储技术领域,更具体地,涉及一种固态盘的闪存转换层的实现方法。The invention belongs to the technical field of solid-state disk storage, and more particularly relates to a method for realizing a flash conversion layer of a solid-state disk.

背景技术Background technique

近年来,闪存(Flash)技术引领存储领域新的变革。凭借着其体积小、速度快、功耗低、无噪声抗震动等许多优点已经在渐渐取代传统的机械硬盘。In recent years, flash memory (Flash) technology has led new changes in the storage field. With its small size, fast speed, low power consumption, no noise and anti-vibration and many other advantages, it has gradually replaced the traditional mechanical hard disk.

和传统硬盘完全不同,如图1所示,现有技术中的闪存芯片(FlashChip)101由多个块(Block)102组成,一个块102由多个页(Page)103组成,通常为64个,而一个页103中分为两个区域,分别为数据区104(DataArea)和OOB区(Out-ofBandarea)105组成。一般一个页103中数据区为512B,OOB则为16B。其中OOB的主要功能是记录海明校验码、逻辑页码和当前页面的状态,即空闲/有效/无效(Free/Valid/Invalid)。Completely different from traditional hard disks, as shown in Figure 1, a flash memory chip (FlashChip) 101 in the prior art is composed of multiple blocks (Block) 102, and one block 102 is composed of multiple pages (Page) 103, usually 64 , and a page 103 is divided into two areas, which are composed of a data area 104 (DataArea) and an OOB area (Out-ofBandarea) 105 respectively. Generally, the data area in a page 103 is 512B, and the OOB is 16B. Among them, the main function of OOB is to record the Hamming check code, the logical page number and the status of the current page, that is, Free/Valid/Invalid (Free/Valid/Invalid).

正是基于闪存自身的这种结构特点,其也有其不利的一面,主要表现在四个方面:1、读写的时候要以页为单位,不能以数据为单位;2、写之前要以Block为单位进行擦除,即不能够覆盖写(Over-write),当一个数据需要修改时,不能像磁盘那样直接原地修改,而需要将该数据块擦除后再重新写入数据;3、Block的擦除次数是有限的,即闪存的寿命有限。因此闪存不能像机械磁盘储存器一样被传统文件系统直接使用。Based on the structural characteristics of flash memory itself, it also has its disadvantages, which are mainly manifested in four aspects: 1. When reading and writing, use the page as the unit, not the data; 2. Before writing, use the block Erase as a unit, that is, it cannot overwrite (Over-write). When a piece of data needs to be modified, it cannot be directly modified in situ like a disk, but the data block needs to be erased and then rewritten into the data; 3. The erasing times of the Block are limited, that is, the lifetime of the flash memory is limited. Therefore, flash memory cannot be directly used by traditional file systems like mechanical disk storage.

为了充分利用传统磁盘领域积累的技术和产品,各大厂商都将一个或多个闪存芯片组合封装成一个类似磁盘的固态盘(SolidStateDrive,简称SSD),为上层应用提供和传统磁盘一样的接口,而不需要修改文件系统和应用。因此,需要一个闪存转换层(Flashtranslationlayer,简称FTL)将固态盘模拟成标准的块设备以屏蔽其特性,使得上层文件系统在使用它的时候就像在使用一个普通的磁盘存储器。In order to make full use of the technologies and products accumulated in the field of traditional disks, major manufacturers have combined and packaged one or more flash memory chips into a solid state drive (SSD) similar to a disk, providing upper-layer applications with the same interface as traditional disks. Without the need to modify the file system and applications. Therefore, a flash translation layer (Flash translation layer, referred to as FTL) is needed to simulate the solid-state disk into a standard block device to shield its characteristics, so that the upper-level file system uses it like an ordinary disk storage.

如图2所示,现有技术的固态盘系统从上到下包括文件系统(以扇区为单位)、FTL、闪存驱动和闪存芯片,其中FTL又包括三大块,地址映射即将上层文件系统以扇区为单位的逻辑地址转换成固态盘的物理地址,这是FTL中最主要的部分,垃圾回收和磨损均衡实现各闪存在磨损均衡的情况下对失效的闪存块进行回收。As shown in Fig. 2, the solid-state disk system of the prior art includes file system (in sector unit), FTL, flash drive and flash memory chip from top to bottom, and wherein FTL includes three big blocks again, and address mapping is about upper file system The logical address in units of sectors is converted into the physical address of the solid state disk, which is the most important part of FTL. Garbage collection and wear leveling enable each flash memory to recycle failed flash memory blocks under wear leveling conditions.

在现有的FTL中,虽然能够对上层系统屏蔽其写前需要擦除的特性,但是还是存在明显的不足之处:1、里面的缓存调度算法没有很好地结合固态盘的读写特性;例如,现在比较常用的页级映射FTL在调入映射关系到缓存中使用的传统文件系统中常用的LRU算法,即每次只调入一条映射关系,但是固态盘是以页为读写单位,调入一条映射关系需要读整个映射页面,调出更新一条映射关系需要写整个映射页面。说明这种缓存管理机制不适用于固态盘;2、现有的FTL中的缓存调度利用的是数据的空间局部性,而对顺序局部性的利用尚不成熟。在实际存储系统中可能会有多层缓存,而固态盘的缓存处于最底层。系统的I/O请求经过上层各级缓存的过滤后到达固态盘的缓存时,几乎已经没有空间局部性。因此现有的FTL的调出算法运用在固态盘上命中率并不理想。而固态盘缓存不命中开销非常大(如果需要更新映射,不命中开销包括两次读操作和一次写操作),严重缩减硬盘的寿命。In the existing FTL, although the feature of erasing before writing can be shielded from the upper system, there are still obvious deficiencies: 1. The cache scheduling algorithm in it is not well combined with the read and write characteristics of the solid state disk; For example, the commonly used page-level mapping FTL now uses the LRU algorithm commonly used in the traditional file system used in the transfer of the mapping relationship to the cache, that is, only one mapping relationship is transferred at a time, but the SSD uses pages as read and write units. Calling in a mapping relationship requires reading the entire mapping page, and calling out to update a mapping relationship requires writing the entire mapping page. It shows that this cache management mechanism is not suitable for solid-state disks; 2. The cache scheduling in the existing FTL utilizes the spatial locality of data, but the utilization of sequence locality is not yet mature. There may be multiple layers of cache in an actual storage system, and the cache of the solid-state disk is at the bottom layer. When the I/O requests of the system reach the cache of the solid-state disk after being filtered by the caches of the upper layers, there is almost no spatial locality. Therefore, the hit rate of the existing FTL call-out algorithm applied to the solid-state disk is not ideal. The SSD cache miss overhead is very high (if the mapping needs to be updated, the miss overhead includes two read operations and one write operation), which seriously reduces the life of the hard disk.

发明内容Contents of the invention

针对现有技术的缺陷,本发明的目的在于提供一种固态盘的闪存转换层的实现方法,其读写效率更高,更加适合于固态盘,并通过多表向前调度和批量更新有效提高缓存命中率和减少闪存的更新次数,进而提高系统的性能,延长固态盘的寿命。Aiming at the defects of the prior art, the object of the present invention is to provide a method for implementing the flash memory conversion layer of a solid-state disk, which has higher read and write efficiency and is more suitable for solid-state disks, and effectively improves the performance through multi-table forward scheduling and batch update Improve the cache hit rate and reduce the update times of the flash memory, thereby improving the performance of the system and prolonging the life of the solid-state disk.

为实现上述目的,本发明提供了一种固态盘的闪存转换层的实现方法,包括以下步骤:In order to achieve the above object, the present invention provides a method for implementing a flash conversion layer of a solid-state disk, comprising the following steps:

(1)接收文件系统发出的读写请求,该读写请求对应于逻辑地址为K的页面,其中K为正整数;(1) Receive the read-write request sent by the file system, the read-write request corresponds to the page whose logical address is K, where K is a positive integer;

(2)判断逻辑地址K是否在缓存映射表中命中,如果是则进入步骤(13),否则进入步骤(3);(2) judge whether logical address K hits in the cache mapping table, if it is then enter step (13), otherwise enter step (3);

(3)判断缓存映射表中是否能够再容得下一次调入缓存映射表的映射关系数目n,如果能够容得下,则转步骤(11),否则转步骤(4);(3) judge whether the mapping relation number n that can be transferred into the cache mapping table next time can be accommodated in the cache mapping table again, if it can accommodate, then turn to step (11), otherwise turn to step (4);

(4)在缓存映射表中找出一个最近最少使用的一个映射关系的逻辑页号Victim_Num;(4) Find out a logical page number Victim_Num of a least recently used mapping relationship in the cache mapping table;

(5)在缓存映射表中找出和Victim_Num的映射关系在映射表中存储在同一页中的所有逻辑页号,并从这些逻辑页号对应的映射关系中找出n个最近最少使用的映射关系;(5) Find out the mapping relationship with Victim_Num in the cache mapping table and store all logical page numbers in the same page in the mapping table, and find n least recently used mappings from the mapping relationship corresponding to these logical page numbers relation;

(6)根据Victim_Num在全局转换目录中寻找到相应的映射关系,具体而言,用Victim_Num整除512后为E,余数为F,说明逻辑页号为Victim_Num的映射关系存储在逻辑映射页号为E、偏移为F的位置,通过全局转换目录查找到逻辑映射页号为E的页面存储在物理映射页号为B的位置;(6) Find the corresponding mapping relationship in the global conversion directory according to Victim_Num. Specifically, after dividing 512 by Victim_Num, it is E, and the remainder is F, indicating that the mapping relationship with the logical page number Victim_Num is stored in the logical mapping page number E , the offset is F, and the page whose logical mapping page number is E is stored in the location where the physical mapping page number is B through the global conversion directory;

(7)在映射表中找到物理映射页号为B的页面,并和缓存映射表中的映射关系相比较,判断是否有逻辑页号相同但是对应的物理页号不同,如果有,则转步骤(8);否则转步骤(10);(7) Find the page whose physical mapping page number is B in the mapping table, and compare it with the mapping relationship in the cache mapping table to determine whether there is a logical page number that is the same but the corresponding physical page number is different. If so, go to step (8); otherwise go to step (10);

(8)在映射表中找到一个可用页,其物理映射页号为C,把物理映射页号B出现在缓存映射表中的映射关系更新到这个可用页C中,并把物理映射页号B中没有出现在缓存映射表中的映射关系复制到这个可用页C中,将物理映射页号为B的页面设置为无效,等待回收,并将物理映射页号为C的页面由可用设置为有效;(8) Find an available page in the mapping table, whose physical mapping page number is C, update the mapping relationship that the physical mapping page number B appears in the cache mapping table to this available page C, and put the physical mapping page number B Copy the mapping relationship that does not appear in the cache mapping table to this available page C, set the page with the physical mapping page number B as invalid, wait for recycling, and set the page with the physical mapping page number C from available to valid ;

(9)在全局转换目录中将逻辑映射页号E对应的物理映射页号B更改为C;(9) Change the physical mapping page number B corresponding to the logical mapping page number E to C in the global conversion directory;

(10)在缓存映射表中去掉n个最近最少使用的页面映射关系;(10) remove n least recently used page mapping relationships in the cache mapping table;

(11)确定逻辑地址K整除512后为G,余数为H,并在全局转换目录中找到逻辑映射页号G对应的物理映射页号M;(11) After determining that the logical address K is divided by 512, it is G, and the remainder is H, and finds the physical mapping page number M corresponding to the logical mapping page number G in the global translation directory;

(12)在映射表中找到物理映射页号为M的页面,再找到其偏移H的映射关系,将其和后面的在同一页中的连续n-1条映射关系调出来,加入到缓存映射表中;(12) Find the page whose physical mapping page number is M in the mapping table, and then find the mapping relationship of its offset H, call it and the following consecutive n-1 mapping relationships in the same page, and add it to the cache in the mapping table;

(13)在缓存映射表中找到逻辑页号为K的记录,得到其物理页号J;(13) Find the record whose logical page number is K in the cache mapping table, and obtain its physical page number J;

(14)在数据块中找到物理页号为J的页面,并将该页面的地址返回给文件系统。(14) Find the page whose physical page number is J in the data block, and return the address of this page to the file system.

一次调入缓存映射表的映射关系数目n的取值为4-16。The value of the number n of mapping relations transferred into the cache mapping table at one time is 4-16.

通过本发明所构思的以上技术方案,与现有技术相比,本发明具有以下的有益效果:Through the above technical solutions conceived by the present invention, compared with the prior art, the present invention has the following beneficial effects:

1、提高了缓存命中率:因为在步骤(13)中,进行了多表向前调度,一次读操作调入多个连续的映射关系,从分利用了底层缓存的顺序局部性。1. The cache hit rate is improved: because in step (13), multi-table forward scheduling is carried out, and multiple consecutive mapping relationships are transferred into one read operation, and the sequential locality of the underlying cache is fully utilized.

2、减少闪存的读写次数:因为在步骤(5)和(10)中采用了批量更新的技术,在不增加读写次数的前提下进行批量更新。2. Reduce the number of reads and writes of the flash memory: because the batch update technology is adopted in steps (5) and (10), batch updates can be performed without increasing the number of reads and writes.

3、延长了闪存的寿命:因为采用了步骤(5)和(10),使得Flash的读写次数减少,从而延长其使用寿命。3. The life-span of the flash memory is extended: because the steps (5) and (10) are adopted, the number of reads and writes of the Flash memory is reduced, thereby prolonging its service life.

4、利用了顺序局部性:因为采用了步骤(13),调入CMT中的映射关系是连续的在同一页中的n条记录。调入当前需要的映射的同时,调入以后很可能要用到的的映射,不但利用了空间局部性(上层缓存中),也有效利用了顺序局部性,即便经过上层I/O的过滤后也可进一步大大提高缓存命中率。4. Sequence locality is utilized: because step (13) is adopted, the mapping relationship transferred into the CMT is consecutive n records in the same page. At the same time as the currently required mapping is loaded, the mapping that is likely to be used in the future is loaded, not only using the spatial locality (in the upper cache), but also effectively using the sequential locality, even after the filtering of the upper layer I/O It can further greatly improve the cache hit ratio.

附图说明Description of drawings

图1是现有技术的闪存芯片的结构示意图。FIG. 1 is a schematic structural diagram of a flash memory chip in the prior art.

图2是现有技术的固态盘系统的结构示意图。FIG. 2 is a schematic structural diagram of a solid state disk system in the prior art.

图3是本发明固态盘的闪存转换层的实现方法的设计结构图。Fig. 3 is a design structure diagram of the implementation method of the flash conversion layer of the solid state disk of the present invention.

图4是本发明方法中读写流程示意图。Fig. 4 is a schematic diagram of the flow of reading and writing in the method of the present invention.

图5是本发明固态盘的闪存转换层的实现方法的流程图。Fig. 5 is a flow chart of the implementation method of the flash conversion layer of the solid state disk of the present invention.

图6是现有技术的闪存转换方法与本发明方法读写次数的对比。FIG. 6 is a comparison of the read and write times between the flash memory conversion method of the prior art and the method of the present invention.

图7是现有技术的闪存转换方法与本发明方法擦除次数的对比。FIG. 7 is a comparison of the erasing times between the flash conversion method of the prior art and the method of the present invention.

图8是现有技术的闪存转换方法与本发明方法缓存命中率的对比。FIG. 8 is a comparison of the cache hit rate between the flash conversion method of the prior art and the method of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

以下首先对本发明的技术术语进行解释和说明。The technical terms of the present invention are firstly explained and illustrated below.

缓存映射表:CacheMappingTable,此后简称CMT,用来存储活动中映射表;Cache mapping table: CacheMappingTable, hereinafter referred to as CMT, is used to store the active mapping table;

映射表:TranslationBlocks,存储所有逻辑页号到物理页号的映射关系;Mapping table: TranslationBlocks, which stores the mapping relationship between all logical page numbers and physical page numbers;

数据块:DataBlocks,用来存储用户的真实数据;Data block: DataBlocks, used to store the user's real data;

全局转换目录:GlobalTranslationDirectory,用来追踪逻辑地址号的映射关系存在映射表中的哪一个页面;Global translation directory: GlobalTranslationDirectory, which is used to track which page in the mapping table the mapping relationship of the logical address number exists;

DLPN:LogicalDataPageNumber,逻辑页号;D LPN : LogicalDataPageNumber, logical page number;

DPPN:PhysicalDataPageNumber,物理页号;D PPN : PhysicalDataPageNumber, physical page number;

MVPN:VirtualTranslationPageNumber,逻辑映射页号;M VPN : VirtualTranslationPageNumber, logical mapping page number;

MPPN::PhysicalTranslationPageNumber,物理映射页号;M PPN :: PhysicalTranslationPageNumber, physical mapping page number;

下面将结合本发明实施实例中的附图,对本发明实例中的技术方案进行清楚、完整的描述,显然,所描述的实施例是本发明的一部分实例,而不是全部的实施例。基于本发明的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the examples of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the implementation examples of the present invention. Apparently, the described embodiments are some examples of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts fall within the protection scope of the present invention.

如图3所示,本发明固态盘的闪存转换层的实现方法所应用到的闪存芯片总共分为四个大块,缓存映射表(CachedMappingTable,简称CMT)用来存储活动中的映射表;全局转换目录(GlobalTranslationDirectory,简称GTD),用来追踪逻辑地址号的映射关系存在映射表的哪个页面中;CMT和GTD都存放在SRAM中;数据块(DataBlock)和映射表(TranslationBlock),其均位于闪存中,其中数据块占绝大部分,数据块存储的是真实地用户数据,而映射表则存储数据块中的所有逻辑地址到物理地址的映射关系。As shown in Figure 3, the flash memory chip that the method for implementing the flash conversion layer of the solid-state disk of the present invention is applied is divided into four large blocks altogether, and the cache mapping table (CachedMappingTable, referred to as CMT) is used for storing the mapping table in the activity; The translation directory (GlobalTranslationDirectory, referred to as GTD), is used to track which page of the mapping table the mapping relationship of the logical address number exists in; both CMT and GTD are stored in the SRAM; the data block (DataBlock) and the mapping table (TranslationBlock), which are located in In the flash memory, the data block accounts for the vast majority, and the data block stores real user data, while the mapping table stores the mapping relationship from all logical addresses in the data block to physical addresses.

本发明充分考虑到固态盘的读写特性,在缓存映射表已满需要调出一部分映射关系的同时,将和在映射表中和这条记录在同一个页中的其它映射关系全部更新(简称批量更新技术),这样在没有增加读写次数的情况下,减少了映射表的写次数,进而延长固态盘寿命。The present invention fully considers the read-write characteristics of the solid-state disk. When the cache mapping table is full and needs to call out a part of the mapping relationship, it will update all the other mapping relationships in the mapping table and this record in the same page (referred to as Batch update technology), so that without increasing the number of reads and writes, the number of writes to the mapping table is reduced, thereby prolonging the life of the SSD.

此外,本发明中在调入策略上充分考虑了与上层缓存的结合。由于上层缓存中已经充分利用了空间局部性,考虑上层缓存的过滤作用,在固态盘中用LRU命中率会大大下降,故本发明在调入策略中利用顺序局部性,即一次调入多个连续的映射关系在缓存映射表中(简称多表向前调度),实验得出,这样大大提高了缓存命中率。In addition, in the present invention, the combination with the upper layer cache is fully considered in the call-in strategy. Since the spatial locality has been fully utilized in the upper-level cache, considering the filtering effect of the upper-level cache, the LRU hit rate in the solid-state disk will be greatly reduced, so the present invention utilizes sequential locality in the call-in strategy, that is, multiple The continuous mapping relationship is in the cache mapping table (referred to as multi-table forward scheduling). Experiments show that this greatly improves the cache hit rate.

另外,当缓存映射表已满需要调入多个映射关系时,必然需要在缓存中调出多个映射关系。此时先在CMT中找出最近最少使用的一个映射关系的逻辑页号Victim_Num,然后找出映射表中与Victim_Num在同一页的所有出现在CMT中的映射关系,再从中找出n-1(其中n为一次调入CMT的映射关系数)个最近最少使用的映射关系调出。In addition, when the cache mapping table is full and multiple mapping relationships need to be called in, it is necessary to call out multiple mapping relationships in the cache. At this time, first find out the logical page number Victim_Num of the least recently used mapping relationship in the CMT, then find out all the mapping relationships that appear in the CMT on the same page as Victim_Num in the mapping table, and then find out n-1( Where n is the number of mapping relationships transferred into the CMT once) and the least recently used mapping relationships are called out.

如图4和5所示,本发明固态盘的闪存转换层的实现方法包括以下步骤:As shown in Figures 4 and 5, the implementation method of the flash conversion layer of the solid state disk of the present invention comprises the following steps:

(1)接收文件系统发出的读写请求,该读写请求对应于逻辑地址为K(K为正整数)的页面,如图4中(1)所示,在图示的实例中,K=1280;(1) Receive the read-write request sent by the file system, the read-write request corresponds to the page whose logical address is K (K is a positive integer), as shown in (1) in Figure 4, in the illustrated example, K= 1280;

(2)判断逻辑地址K是否在CMT中命中,如果是则进入步骤(13),否则进入步骤(3);(2) judge whether logic address K hits in CMT, if then enter step (13), otherwise enter step (3);

(3)判断CMT中是否能够再容得下n,其中n为一次调入CMT的映射关系数目,如果能够容得下,则转步骤(11),否则转步骤(4);通常n的取值为4-16,在图示的实例中,n=4;(3) Judging whether n can be accommodated in the CMT, where n is the number of mapping relationships transferred into the CMT at one time, if it can be accommodated, then go to step (11), otherwise go to step (4); usually n is taken The value is 4-16, in the illustrated example, n=4;

(4)在CMT中找出一个最近最少使用的一个映射关系的逻辑页号Victim_Num,如图4中(4)所示,在图示的实例中,取VictimNum=1;(4) find out the logical page number Victim_Num of a mapping relation that uses least recently in CMT, as shown in (4) among Fig. 4, in the example shown in figure, get VictimNum=1;

(5)在CMT中找出和Victim_Num的映射关系在映射表中存储在同一页中的所有逻辑页号(由于在映射表中逻辑页号是顺序的,比如逻辑号0-511是在同一页,512-1024在同一页),并从这些逻辑页号对应的映射关系中找出n个最近最少使用的映射关系,如图4中(5)所示,n个逻辑页号分别为1、2、4、7;(5) Find out the mapping relationship with Victim_Num in CMT and store all logical page numbers in the same page in the mapping table (because the logical page numbers in the mapping table are sequential, such as logical numbers 0-511 are on the same page , 512-1024 on the same page), and find n least recently used mapping relationships from the mapping relationships corresponding to these logical page numbers, as shown in (5) in Figure 4, n logical page numbers are respectively 1, 2, 4, 7;

(6)根据Victim_Num在GTD中寻找到相应的映射关系(在GTD中,映射的关系记录是顺序存放的),具体而言,图中Victim_Num整除512后为E,余数为F,说明逻辑页号为Victim_Num的映射关系存储在逻辑映射页号为E、偏移为F的位置,通过GTD查找到逻辑映射页号为E的页面存储在物理映射页号为B的位置;举例而言,如图4中(7)所示,B=21,Victim_Num整除512后为0,余数为1,说明逻辑页号为Victim_Num的映射关系存储在逻辑映射页号为0、偏移为1的位置,通过GTD查找到逻辑映射页号为0的页面存储在物理映射页号为21的位置;(6) Find the corresponding mapping relationship in GTD according to Victim_Num (in GTD, the mapping relationship records are stored sequentially). Specifically, after Victim_Num is divided by 512 in the figure, it is E, and the remainder is F, indicating the logical page number The mapping relationship of Victim_Num is stored in the position where the logical mapping page number is E and the offset is F, and the page whose logical mapping page number is found through GTD is stored in the position where the physical mapping page number is B; for example, as shown in As shown in (7) in 4, B=21, Victim_Num is 0 after being divided by 512, and the remainder is 1, indicating that the mapping relationship with the logical page number Victim_Num is stored at the position where the logical mapping page number is 0 and the offset is 1, through GTD Find the page whose logical mapping page number is 0 and store it in the location where the physical mapping page number is 21;

(7)在映射表中找到物理映射页号为B的页面,并和CMT中的映射关系相比较,判断是否有逻辑页号相同但是对应的物理页号不同,如果有,则转步骤(8);否则转步骤(10);(7) Find the page whose physical mapping page number is B in the mapping table, and compare it with the mapping relationship in the CMT, and judge whether there is a logical page number that is the same but the corresponding physical page number is different, if so, go to step (8 ); otherwise go to step (10);

(8)在映射表中找到一个可用页,其物理映射页号为C,把物理映射页号B出现在CMT中的映射关系更新到这个可用页C中,并把物理映射页号B中没有出现在CMT中的映射关系复制到这个可用页C中,将物理映射页号为B的页面设置为无效,等待回收,并将物理映射页号为C的页面由可用设置为有效,如图4中(8)所示,在图示的实例中,取C=23;(8) Find an available page in the mapping table, whose physical mapping page number is C, update the mapping relationship that the physical mapping page number B appears in the CMT to this available page C, and update the physical mapping page number B that does not have The mapping relationship that appears in the CMT is copied to the available page C, and the page with the physical mapping page number B is set to be invalid, waiting for recycling, and the page with the physical mapping page number C is set from available to valid, as shown in Figure 4 Shown in (8), in the illustrated example, get C=23;

(9)在GTD中将逻辑映射页号E对应的物理映射页号B更改为C,举例而言,如图4中(9)所示,在GTD中将逻辑映射页号0对应的物理映射页号21更改为23;(9) Change the physical mapping page number B corresponding to the logical mapping page number E to C in GTD, for example, as shown in (9) in Figure 4, the physical mapping corresponding to the logical mapping page number 0 in GTD Page number 21 changed to 23;

(10)在CMT中去掉n个最近最少使用的页面映射关系,在图示的实例中,是逻辑页号为1、2、4、10的四条记录;(10) remove n least recently used page mapping relationships in CMT, in the illustrated example, be four records that logical page numbers are 1, 2, 4, 10;

(11)确定逻辑地址K整除512后为G,余数为H,并在GTD中找到逻辑映射页号G对应的物理映射页号M,如图4中(11)所示,逻辑地址1280整除512后G=2,余数H=256,M=15;(11) Determine the logical address K divided by 512 is G, and the remainder is H, and find the physical mapped page number M corresponding to the logical mapped page number G in GTD, as shown in (11) in Figure 4, the logical address 1280 divided by 512 Back G=2, remainder H=256, M=15;

(12)在映射表中找到物理映射页号为M的页面,再找到其偏移H的映射关系,将其和后面的在同一页中的连续n-1条映射关系调出来,加入到CMT中,如图4中(12)所示;(12) Find the page whose physical mapping page number is M in the mapping table, and then find the mapping relationship of its offset H, call it and the following consecutive n-1 mapping relationships in the same page, and add it to the CMT In, as shown in (12) among Fig. 4;

(13)在CMT中找到逻辑页号为K的记录,得到其物理页号J,如图4中(13)所示,J=660;(13) find the record that logical page number is K in CMT, obtain its physical page number J, as shown in (13) among Fig. 4, J=660;

(14)在数据块中找到物理页号为J的页面,并将该页面的地址返回给文件系统。(14) Find the page whose physical page number is J in the data block, and return the address of this page to the file system.

图6和图7分别是现有的闪存转换方法与本发明方法的读写性能与擦除次数的对比,从图中可以看出,本发明的方法能够有效减少读写次数和擦除次数,其中,读次数较少了54.21%,写次数较少了15.74%,擦除次数较少了15.75%。Fig. 6 and Fig. 7 are respectively the contrast of reading and writing performance and erasing times of existing flash memory conversion method and the method of the present invention, as can be seen from the figure, the method of the present invention can effectively reduce the times of reading and writing and erasing times, Among them, the number of reads is less by 54.21%, the number of writes is less by 15.74%, and the number of erasures is less by 15.75%.

图8是现有的闪存转换方法与本发明方法的缓存命中率的对比,从图中可以看出缓存命中率提高了20.1%。FIG. 8 is a comparison of the cache hit rate between the existing flash memory conversion method and the method of the present invention. It can be seen from the figure that the cache hit rate has increased by 20.1%.

本领域的技术人员容易理解,以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。It is easy for those skilled in the art to understand that the above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention, All should be included within the protection scope of the present invention.

Claims (2)

1.一种固态盘的闪存转换层的实现方法,其特征在于,包括以下步骤:1. an implementation method of the flash conversion layer of solid-state disk, is characterized in that, comprises the following steps: (1)接收文件系统发出的读写请求,该读写请求对应于逻辑地址为K的页面,其中K为正整数;(1) Receive the read-write request sent by the file system, the read-write request corresponds to the page whose logical address is K, where K is a positive integer; (2)判断逻辑地址K是否在缓存映射表中命中,如果是则进入步骤(13),否则进入步骤(3);(2) judge whether logical address K hits in the cache mapping table, if it is then enter step (13), otherwise enter step (3); (3)判断缓存映射表中是否能够再容得下一次调入缓存映射表的映射关系数目n,如果能够容得下,则转步骤(11),否则转步骤(4);(3) judge whether the mapping relation number n that can be transferred into the cache mapping table next time can be accommodated in the cache mapping table again, if it can accommodate, then turn to step (11), otherwise turn to step (4); (4)在缓存映射表中找出一个最近最少使用的一个映射关系的逻辑页号Victim_Num;(4) Find out a logical page number Victim_Num of a least recently used mapping relationship in the cache mapping table; (5)在缓存映射表中找出和逻辑页号Victim_Num的映射关系在映射表中存储在同一页中的所有逻辑页号,并从这些逻辑页号对应的映射关系中找出n个最近最少使用的映射关系;(5) Find out the mapping relationship with the logical page number Victim_Num in the cache mapping table. Store all logical page numbers in the same page in the mapping table, and find out n least recent from the mapping relationship corresponding to these logical page numbers The mapping relationship used; (6)根据逻辑页号Victim_Num在全局转换目录中寻找到相应的映射关系,具体而言,用逻辑页号Victim_Num整除512后为E,余数为F,说明逻辑页号为逻辑页号Victim_Num的映射关系存储在逻辑映射页号为E、偏移为F的位置,通过全局转换目录查找到逻辑映射页号为E的页面存储在物理映射页号为B的位置;(6) Find the corresponding mapping relationship in the global conversion directory according to the logical page number Victim_Num. Specifically, after dividing 512 by the logical page number Victim_Num, it is E, and the remainder is F, indicating that the logical page number is the mapping of the logical page number Victim_Num The relationship is stored at the position where the logical mapping page number is E and the offset is F, and the page with the logical mapping page number E found through the global conversion directory is stored at the position where the physical mapping page number is B; (7)在映射表中找到物理映射页号为B的页面,并和缓存映射表中的映射关系相比较,判断是否有逻辑页号相同但是对应的物理页号不同,如果有,则转步骤(8);否则转步骤(10);(7) Find the page whose physical mapping page number is B in the mapping table, and compare it with the mapping relationship in the cache mapping table to determine whether there is a logical page number that is the same but the corresponding physical page number is different. If so, go to step (8); otherwise go to step (10); (8)在映射表中找到一个可用页,其物理映射页号为C,把物理映射页号B出现在缓存映射表中的映射关系更新到这个可用页C中,并把物理映射页号B中没有出现在缓存映射表中的映射关系复制到这个可用页C中,将物理映射页号为B的页面设置为无效,等待回收,并将物理映射页号为C的页面由可用设置为有效;(8) Find an available page in the mapping table, whose physical mapping page number is C, update the mapping relationship that the physical mapping page number B appears in the cache mapping table to this available page C, and put the physical mapping page number B Copy the mapping relationship that does not appear in the cache mapping table to this available page C, set the page with the physical mapping page number B as invalid, wait for recycling, and set the page with the physical mapping page number C from available to valid ; (9)在全局转换目录中将逻辑映射页号E对应的物理映射页号B更改为C;(9) Change the physical mapping page number B corresponding to the logical mapping page number E to C in the global conversion directory; (10)在缓存映射表中去掉n个最近最少使用的页面映射关系;(10) remove n least recently used page mapping relationships in the cache mapping table; (11)确定逻辑地址K整除512后为G,余数为H,并在全局转换目录中找到逻辑映射页号G对应的物理映射页号M;(11) After determining that the logical address K is divided by 512, it is G, and the remainder is H, and finds the physical mapping page number M corresponding to the logical mapping page number G in the global conversion directory; (12)在映射表中找到物理映射页号为M的页面,再找到其偏移H的映射关系,将其和后面的在同一页中的连续n-1条映射关系调出来,加入到缓存映射表中;(12) Find the page whose physical mapping page number is M in the mapping table, and then find the mapping relationship of its offset H, call it and the following consecutive n-1 mapping relationships in the same page, and add it to the cache in the mapping table; (13)在缓存映射表中找到逻辑页号为K的记录,得到其物理页号J;(13) Find the record whose logical page number is K in the cache mapping table, and obtain its physical page number J; (14)在数据块中找到物理页号为J的页面,并将该页面的地址返回给文件系统。(14) Find the page whose physical page number is J in the data block, and return the address of this page to the file system. 2.根据权利要求1所述的实现方法,其特征在于,一次调入缓存映射表的映射关系数目n的取值为4-16。2. The implementation method according to claim 1, characterized in that, the value of the number n of mapping relationships transferred into the cache mapping table at one time is 4-16.
CN201210427484.9A 2012-10-30 2012-10-30 A kind of implementation method of flash translation layer (FTL) of solid-state disk Active CN102981963B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210427484.9A CN102981963B (en) 2012-10-30 2012-10-30 A kind of implementation method of flash translation layer (FTL) of solid-state disk

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210427484.9A CN102981963B (en) 2012-10-30 2012-10-30 A kind of implementation method of flash translation layer (FTL) of solid-state disk

Publications (2)

Publication Number Publication Date
CN102981963A CN102981963A (en) 2013-03-20
CN102981963B true CN102981963B (en) 2015-12-02

Family

ID=47856015

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210427484.9A Active CN102981963B (en) 2012-10-30 2012-10-30 A kind of implementation method of flash translation layer (FTL) of solid-state disk

Country Status (1)

Country Link
CN (1) CN102981963B (en)

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103136121B (en) * 2013-03-25 2014-04-16 中国人民解放军国防科学技术大学 Cache management method for solid-state disc
US20140304453A1 (en) * 2013-04-08 2014-10-09 The Hong Kong Polytechnic University Effective Caching for Demand-based Flash Translation Layers in Large-Scale Flash Memory Storage Systems
CN103425600B (en) * 2013-08-23 2016-01-20 中国人民解放军国防科学技术大学 Address mapping method in a kind of solid-state disk flash translation layer (FTL)
CN104166634A (en) * 2014-08-12 2014-11-26 华中科技大学 Management method of mapping table caches in solid-state disk system
CN104268094B (en) * 2014-09-23 2017-05-03 浪潮电子信息产业股份有限公司 Optimized flash memory address mapping method
CN106155579A (en) * 2015-04-27 2016-11-23 广明光电股份有限公司 Method for dynamically storing data of conversion layer in solid state disk
CN106326134B (en) * 2015-06-30 2019-10-01 华为技术有限公司 The method and device of FTL address of cache
KR102580820B1 (en) * 2016-03-10 2023-09-20 에스케이하이닉스 주식회사 Data storage device and operating method thereof
US20170344575A1 (en) * 2016-05-27 2017-11-30 Netapp, Inc. Methods for facilitating external cache in a cloud storage environment and devices thereof
US10289544B2 (en) * 2016-07-19 2019-05-14 Western Digital Technologies, Inc. Mapping tables for storage devices
CN106502928B (en) * 2016-09-29 2019-08-20 华为技术有限公司 A kind of storage system power-off protection method, storage control and electronic equipment
CN106815152B (en) * 2016-12-27 2019-05-31 华中科技大学 A method of optimization page grade flash translation layer (FTL)
CN107368436B (en) * 2017-06-29 2020-08-18 西安交通大学 Flash memory cold and hot data separated storage method combined with address mapping table
CN109725825B (en) * 2017-10-27 2022-03-11 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for managing a cache
CN110007876A (en) * 2019-04-15 2019-07-12 苏州浪潮智能科技有限公司 A kind of solid state hard disk date storage method, device, equipment and medium
CN110059021A (en) * 2019-04-18 2019-07-26 深圳市时创意电子有限公司 A kind of algorithm for reducing write-in magnifying power and promoting random writing performance
CN110262982A (en) * 2019-05-05 2019-09-20 杭州电子科技大学 A kind of method of solid state hard disk address of cache
CN112882663B (en) * 2021-03-25 2022-10-14 湖南国科微电子股份有限公司 Random writing method, electronic equipment and storage medium
CN113220241A (en) * 2021-05-27 2021-08-06 衢州学院 Cross-layer design-based hybrid SSD performance and service life optimization method
CN116010298B (en) * 2023-03-24 2023-09-22 温州市特种设备检测科学研究院(温州市特种设备应急处置中心) Method, device, electronic device and storage medium for NAND flash memory address mapping

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043721A (en) * 2010-05-12 2011-05-04 中颖电子股份有限公司 Memory management method for flash memory
CN102521156A (en) * 2011-12-12 2012-06-27 云海创想信息技术(天津)有限公司 Mapping relation access method and mapping relation access device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043721A (en) * 2010-05-12 2011-05-04 中颖电子股份有限公司 Memory management method for flash memory
CN102521156A (en) * 2011-12-12 2012-06-27 云海创想信息技术(天津)有限公司 Mapping relation access method and mapping relation access device

Also Published As

Publication number Publication date
CN102981963A (en) 2013-03-20

Similar Documents

Publication Publication Date Title
CN102981963B (en) A kind of implementation method of flash translation layer (FTL) of solid-state disk
CN103425600B (en) Address mapping method in a kind of solid-state disk flash translation layer (FTL)
CN103049397B (en) A kind of solid state hard disc inner buffer management method based on phase transition storage and system
CN107066393B (en) A method for improving the density of mapping information in the address mapping table
CN103631536B (en) A kind of method utilizing the invalid data of SSD to optimize RAID5/6 write performance
US9256527B2 (en) Logical to physical address mapping in storage systems comprising solid state memory devices
CN104572478B (en) Data access method and data access device
CN104166634A (en) Management method of mapping table caches in solid-state disk system
CN102521160B (en) Write buffer detector and parallel channel write method
CN105930282B (en) A kind of data cache method for NAND FLASH
CN103645859B (en) A kind of magnetic disk array buffer storage method of virtual SSD and SSD isomery mirror image
US10740251B2 (en) Hybrid drive translation layer
US20130198439A1 (en) Non-volatile storage
US20140129758A1 (en) Wear leveling in flash memory devices with trim commands
CN106547703A (en) A kind of FTL optimization methods based on block group structure
KR101297442B1 (en) Nand flash memory including demand-based flash translation layer considering spatial locality
CN109582593B (en) FTL address mapping reading and writing method based on calculation
CN109446117B (en) Design method for page-level flash translation layer of solid state disk
CN106815152A (en) A kind of method for optimizing page level flash translation layer (FTL)
KR20100115090A (en) Buffer-aware garbage collection technique for nand flash memory-based storage systems
CN114063921B (en) Solid state disk mapping record cache management method based on reinforcement learning
CN103309815A (en) Method and system for increasing available capacity and service life of solid state disc
CN107589908A (en) The merging method that non-alignment updates the data in a kind of caching system based on solid-state disk
CN115203079A (en) Method for writing data into solid state disk
CN102681792B (en) Solid-state disk memory partition method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant