CN113138719A - 一种实现ssd快速随机写并避免写重复的方法 - Google Patents

一种实现ssd快速随机写并避免写重复的方法 Download PDF

Info

Publication number
CN113138719A
CN113138719A CN202110473629.8A CN202110473629A CN113138719A CN 113138719 A CN113138719 A CN 113138719A CN 202110473629 A CN202110473629 A CN 202110473629A CN 113138719 A CN113138719 A CN 113138719A
Authority
CN
China
Prior art keywords
lba
write
array
index array
ssd
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.)
Granted
Application number
CN202110473629.8A
Other languages
English (en)
Other versions
CN113138719B (zh
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.)
Shandong Sinochip Semiconductors Co Ltd
Original Assignee
Shandong Sinochip Semiconductors Co Ltd
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 Shandong Sinochip Semiconductors Co Ltd filed Critical Shandong Sinochip Semiconductors Co Ltd
Priority to CN202110473629.8A priority Critical patent/CN113138719B/zh
Publication of CN113138719A publication Critical patent/CN113138719A/zh
Application granted granted Critical
Publication of CN113138719B publication Critical patent/CN113138719B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

本发明公开一种种实现SSD快速随机写并避免写重复的方法,在对SSD设备进行数据随机写的场景中,申请一大小为N的数组作为LBA的索引数组;将SSD设备文件大小除以LBA索引数组长度,得到索引数组的循环遍历次数n;通过随机算法将索引数组随机化;创建个数与索引数组循环遍历次数相同的线程作为随机写的执行单元,在每个线程中,遍历随机化后的索引数组;遍历过程中,通过libaio库函数实现异步非阻塞的提交IO。本发明实现了在占用少量内存,对大容量SSD设备实现全盘的快速随机写入、避免写重复的测试需求。

Description

一种实现SSD快速随机写并避免写重复的方法
技术领域
本发明涉及存储领域,具体是一种实现SSD快速随机写并避免写重复的方法。
背景技术
对SSD存储设备的数据一致性校验测试中,包含随机读写校验测试。针对随机写过程,目前行业内在用的主流测试工具fio,能够通过参数—norandommap的设置,判断是否使用一段内存(bitmap)来记录是不是随机到重复的位置,进而决定是否使用重复的位置进行写操作。Bitmap占用内存较大,并且现在的随机写是对SSD全盘进行,速度较慢。
发明内容
本发明要解决的技术问题是提供一种实现SSD快速随机写并避免写重复的方法,实现了在占用少量内存,对大容量SSD设备,实现全盘的快速随机写入、避免写重复的测试需求。
为了解决所述技术问题,本发明采用的技术方案是:一种实现SSD快速随机写并避免写重复的方法,包括以下步骤:
S01)、在对SSD设备进行数据随机写的场景中,申请一大小为N的数组作为LBA的索引数组;
S02)、将SSD设备文件大小除以LBA索引数组长度,得到索引数组的循环遍历次数n;
S03)、通过随机算法将索引数组随机化;
S04)、创建个数与索引数组循环遍历次数相同的线程作为随机写的执行单元,在每个线程中,遍历随机化后的索引数组;
S05)、遍历过程中,通过libaio库函数实现异步非阻塞的提交IO,每个IO的LBA地址通过以下公式求得:lba_offset = rand_lba_array[i] + group_num_array[j] *GROUP_LBA_NUM;其中lba_offset为待求的IO LBA地址,rand_lba_array[i]为io_lba索引数组随机化后的数组某元素,group_num_array[j]为io_lba索引数组循环遍历次数的某次,GROUP_LBA_NUM为 io_lba索引数组的大小。
进一步的,执行步骤S01)之前,规定写读轮数,执行完步骤S05)之后,判断是否完成写读轮数,若否,重复执行步骤S03至S05,若是,则循环结束。
进一步的,写读轮数等于目标写入量除以设备文件大小,目标写入量通过写入命令参数获取。
进一步的,LBA索引数组的大小N根据主机资源确定。
进一步的,LBA索引数组的大小N为4096*1024=4M。
进一步的,通过洗牌算法将索引数组随机化。
进一步的,通过libaio库中的io_sunmit()、io_getevents()函数实现异步非阻塞的提交io。
本发明的有益效果:相对于行业内主流测试工具fio的实现方案,本发明有如下优点:
1)占用内存小。如果要实现对全盘随机写不随机到重复的位置,fio需占用较大内存实现bitmap的存储,对机器要求较高,但本发明仅需申请4M(4096*1024)大小内存即可实现全盘不重复随机写。
2)提升随机写性能。通过科学、准确的对比测试,对一块4G大小的NVME SSD的namespace进行随机写,fio大约用时11s,而本发明设计方案约用时3s。
3)对数据校验pattern可定制化设计。对每一个LBA的数据内容,分为verify_header和data两部分。verify_header可包含魔法数、时间种子、lba位置、写入时间等,data可定义为lba的字节位置等,通过对数据校验pattern的定制化设计,实现对数据的有效校验。
综上所述,本发明提高了SSD设备的随机写性能,并避免了随机写重复,有益于随机读写校验测试,对测试机器的内存占用低,提高了测试的效率和质量,有效降低了测试成本。
附图说明
图1为实施例的流程图。
具体实施方式
下面结合附图和具体实施例对本发明作进一步的限定。
实施例1
本实施例公开一种实现SSD快速随机写并避免写重复的方法,本方法在对大容量SSD设备进行数据随机写场景中,申请4096*1024的数组(仅占用4M内存大小),作为lba的索引数组。将SSD设备文件大小除以LBA索引数组长度,得到索引数组的循环遍历次数。将索引数组通过“洗牌算法”进行随机化。然后,通过创建与循环遍历次数相同的线程作为随机写的执行单元,遍历随机化后的索引数组,通过libaio库函数io_submit()、io_getevents()等实现异步非阻塞的提交io,实现快速随机写并避免写重复,完成随机写数据校验测试过程中的全盘随机写操作。
如图1所示,本方法实现的具体过程为:
1、获取命令参数中目标写入量。通过目标写入量 / 设备文件大小 = 写读轮数。
2、准备GROUP_LBA_NUM =4096*1024的数组,作为lba的索引数组,记作rand_lba_array[GROUP_LBA_NUM].
3、将设备文件大小 / (4096*1024) 的值作为索引数组的遍历次数,记作group_num,并将其数组化,记作group_num_arra[]。
4、通过“洗牌算法”将索引数组随机化。
5、通过pthread_create函数创建group_num数目的线程,在每个线程中,遍历随机化后的索引数组。
6、在遍历过程中,通过libaio库中的io_sunmit(),io_getevents()函数实现异步非阻塞的提交IO。而每个IO的LBA地址,则通过以下公式求得。即lba_offset = rand_lba_array[i] + group_num_array[j] * GROUP_LBA_NUM。
7、每个IO的数据pattern可实现定制化设计。根据既定的规则生成,方便之后根据既定的规则进行校验。
8、等待线程结束后,继续进行下一轮,直到完成写&读轮数循环。
9、循环结束,完成写入要求。
以上,即实现了SSD快速随机写并避免写重复的功能。
LBA索引数组的大小N根据主机资源确定,在其他实施例中,LBA索引数组的大小N可设置成另外的值。
在其他实施例中,也可以通过其它随机算法将索引数组随机化。
该方法,实现了在占用少量内存,对大容量SSD设备,实现全盘的快速随机写入、避免写重复的测试需求。
相对于行业内主流测试工具fio的实现方案,本发明有如下优点:
1)占用内存小。如果要实现对全盘随机写不随机到重复的位置,fio需占用较大内存实现bitmap的存储,对机器要求较高,但本发明仅需申请4M(4096*1024)大小内存即可实现全盘不重复随机写。
2)提升随机写性能。通过科学、准确的对比测试,对一块4G大小的NVME SSD的namespace进行随机写,fio大约用时11s,而本发明设计方案约用时3s。
3)对数据校验pattern可定制化设计。对每一个LBA的数据内容,分为verify_header和data两部分。verify_header可包含魔法数、时间种子、lba位置、写入时间等,data可定义为lba的字节位置等,通过对数据校验pattern的定制化设计,实现对数据的有效校验。
综上所述,本发明提高了SSD设备的随机写性能,并避免了随机写重复,有益于随机读写校验测试,对测试机器的内存占用低,提高了测试的效率和质量,有效降低了测试成本。
以上描述的仅是本发明的基本原理和优选实施例,本领域技术人员根据本发明做出的改进和替换,属于本发明的保护范围。

Claims (7)

1.一种实现SSD快速随机写并避免写重复的方法,其特征在于:包括以下步骤:
S01)、在对SSD设备进行数据随机写的场景中,申请一大小为N的数组作为LBA的索引数组;
S02)、将SSD设备文件大小除以LBA索引数组长度,得到索引数组的循环遍历次数n;
S03)、通过随机算法将索引数组随机化;
S04)、创建个数与索引数组循环遍历次数相同的线程作为随机写的执行单元,在每个线程中,遍历随机化后的索引数组;
S05)、遍历过程中,通过libaio库函数实现异步非阻塞的提交IO,每个IO的LBA地址通过以下公式求得:lba_offset = rand_lba_array[i] + group_num_array[j] * GROUP_LBA_NUM;其中lba_offset为待求的IO LBA地址,rand_lba_array[i]为io_lba索引数组随机化后的数组某元素,group_num_array[j]为io_lba索引数组循环遍历次数的某次,GROUP_LBA_NUM为 io_lba索引数组的大小。
2.根据权利要求1所述的实现SSD快速随机写并避免写重复的方法,其特征在于:执行步骤S01)之前,规定写读轮数,执行完步骤S05)之后,判断是否完成写读轮数,若否,重复执行步骤S03至S05,若是,则循环结束。
3.根据权利要求2所述的实现SSD快速随机写并避免写重复的方法,其特征在于:写读轮数等于目标写入量除以设备文件大小,目标写入量通过写入命令参数获取。
4.根据权利要求1所述的实现SSD快速随机写并避免写重复的方法,其特征在于:LBA索引数组的大小N根据主机资源确定。
5.根据权利要求1或4所述的实现SSD快速随机写并避免写重复的方法,其特征在于:LBA索引数组的大小N为4096*1024=4M。
6.根据权利要求1所述的实现SSD快速随机写并避免写重复的方法,其特征在于:通过洗牌算法将索引数组随机化。
7.根据权利要求1所述的实现SSD快速随机写并避免写重复的方法,其特征在于:通过libaio库中的io_sunmit()、io_getevents()函数实现异步非阻塞的提交io。
CN202110473629.8A 2021-04-29 2021-04-29 一种实现ssd快速随机写并避免写重复的方法 Active CN113138719B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110473629.8A CN113138719B (zh) 2021-04-29 2021-04-29 一种实现ssd快速随机写并避免写重复的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110473629.8A CN113138719B (zh) 2021-04-29 2021-04-29 一种实现ssd快速随机写并避免写重复的方法

Publications (2)

Publication Number Publication Date
CN113138719A true CN113138719A (zh) 2021-07-20
CN113138719B CN113138719B (zh) 2022-11-01

Family

ID=76817640

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110473629.8A Active CN113138719B (zh) 2021-04-29 2021-04-29 一种实现ssd快速随机写并避免写重复的方法

Country Status (1)

Country Link
CN (1) CN113138719B (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024060709A1 (zh) * 2022-09-24 2024-03-28 华为技术有限公司 一种数据访问方法、系统以及节点

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201916A (zh) * 2016-07-25 2016-12-07 中国人民解放军国防科学技术大学 一种面向ssd的非易失缓存机制
CN106649131A (zh) * 2016-12-29 2017-05-10 郑州云海信息技术有限公司 一种固态硬盘及其逻辑地址范围冲突监控方法、系统
CN106681663A (zh) * 2016-12-29 2017-05-17 记忆科技(深圳)有限公司 一种固态硬盘多流写入的方法
CN107295117A (zh) * 2017-06-16 2017-10-24 杭州迪普科技股份有限公司 一种地址池的分配方法及装置
CN109032512A (zh) * 2018-07-10 2018-12-18 郑州云海信息技术有限公司 一种实现数据追加写的方法、装置及设备
CN109358804A (zh) * 2015-09-29 2019-02-19 华为技术有限公司 一种数据处理方法、装置及闪存设备
CN109448778A (zh) * 2018-11-06 2019-03-08 郑州云海信息技术有限公司 一种固态硬盘性能测试方法、系统、装置及可读存储介质
CN110297603A (zh) * 2019-06-25 2019-10-01 深圳忆联信息系统有限公司 基于固态硬盘的随机写性能提升方法、装置和计算机设备

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109358804A (zh) * 2015-09-29 2019-02-19 华为技术有限公司 一种数据处理方法、装置及闪存设备
CN106201916A (zh) * 2016-07-25 2016-12-07 中国人民解放军国防科学技术大学 一种面向ssd的非易失缓存机制
CN106649131A (zh) * 2016-12-29 2017-05-10 郑州云海信息技术有限公司 一种固态硬盘及其逻辑地址范围冲突监控方法、系统
CN106681663A (zh) * 2016-12-29 2017-05-17 记忆科技(深圳)有限公司 一种固态硬盘多流写入的方法
CN107295117A (zh) * 2017-06-16 2017-10-24 杭州迪普科技股份有限公司 一种地址池的分配方法及装置
CN109032512A (zh) * 2018-07-10 2018-12-18 郑州云海信息技术有限公司 一种实现数据追加写的方法、装置及设备
CN109448778A (zh) * 2018-11-06 2019-03-08 郑州云海信息技术有限公司 一种固态硬盘性能测试方法、系统、装置及可读存储介质
CN110297603A (zh) * 2019-06-25 2019-10-01 深圳忆联信息系统有限公司 基于固态硬盘的随机写性能提升方法、装置和计算机设备

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
荣益麟: ""面向SSD的重复数据删除机制设计与实现"", 《中国优秀硕士学位论文全文数据库》 *
荣益麟: ""面向SSD的重复数据删除机制设计与实现"", 《中国优秀硕士学位论文全文数据库》, no. 6, 30 June 2014 (2014-06-30) *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024060709A1 (zh) * 2022-09-24 2024-03-28 华为技术有限公司 一种数据访问方法、系统以及节点

Also Published As

Publication number Publication date
CN113138719B (zh) 2022-11-01

Similar Documents

Publication Publication Date Title
US11392488B2 (en) Optimizing storage of application data in memory
CN107704194B (zh) 无锁io处理方法及其装置
CN110335635A (zh) 用来管理一记忆装置的方法以及记忆装置与控制器
CN113868039B (zh) 一种测试方法、装置及相关设备
CN113138719B (zh) 一种实现ssd快速随机写并避免写重复的方法
CN109815160A (zh) 最后写入页搜索
CN110851074B (zh) 嵌入式参考计数器和特殊数据模式自动检测
CN108039190A (zh) 一种测试方法及装置
DE102020132762A1 (de) Eingebaute Selbsttest-Stromausfallabschwächung für dynamischen Direktzugriffsspeicher
CN113157512B (zh) 实现大容量ssd在小内存机器上进行数据校验测试的方法
CN109144419A (zh) 一种固态硬盘内存读写方法及系统
CN109213423A (zh) 基于地址屏障无锁处理并发io命令
CN114281265A (zh) 一种存储介质失效的处理方法、装置和固态硬盘
US11461238B2 (en) Storage device, memory controller, and method for fetching write commands from submission queues to perform full page writes
US8688898B2 (en) Memory device configured to execute plural access commands in parallel and memory access method therefor
CN110990207A (zh) 基于Whitley平台的BPS内存测试方法、系统、终端及存储介质
CN113345510B (zh) 一种flash的容量识别方法及容量识别系统
CN115509442A (zh) 闪存颗粒调试方法、闪存颗粒调试设备和可读存储介质
CN112802532A (zh) Dram测试方法、装置、可读存储介质及电子设备
CN113488100A (zh) Dram测试方法、装置、计算机可读存储介质及电子设备
CN113176974B (zh) 用于验证ip核的方法、装置及系统
CN116820333B (zh) 一种基于多线程的ssdraid-5持续写入方法
CN111435285B (zh) 存储卷写数据方法、装置、电子设备及机器可读存储介质
CN103366825B (zh) 一种nand闪存芯片及其棋盘格检查的芯片编程方法
CN109213424A (zh) 并发io命令的无锁处理方法

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant