WO2019119833A1 - Storage management method and device, solid state drive and readable storage medium - Google Patents

Storage management method and device, solid state drive and readable storage medium Download PDF

Info

Publication number
WO2019119833A1
WO2019119833A1 PCT/CN2018/100884 CN2018100884W WO2019119833A1 WO 2019119833 A1 WO2019119833 A1 WO 2019119833A1 CN 2018100884 W CN2018100884 W CN 2018100884W WO 2019119833 A1 WO2019119833 A1 WO 2019119833A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage
list
block
storage block
channel
Prior art date
Application number
PCT/CN2018/100884
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 WO2019119833A1 publication Critical patent/WO2019119833A1/en

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

Abstract

A storage management method and device, a solid state drive and a readable storage medium. The method comprises: when it is detected that data transmitted by a storage channel needs to be stored, acquiring an available storage block and writing the transmitted data into the available storage block (S120); when data writing is completed, detecting whether a storage space state identifier indicates a non-overwritten state (S130); when same indicates the non-overwritten state, detecting whether a storage space reaches a fully-written state (S140); and when the storage space reaches the fully-written state, switching the storage space state identifier to an overwritten state, and starting a timer, and regularly carrying out storage space recovery allocation processing according to the storage life coefficient of each storage block in the storage space and the life balance policy of the storage block (S150). Thus, storage blocks in the storage space can be erased evenly, the overall service life of the solid state drive is improved, and the data read-write efficiency is improved.

Description

存储管理方法、装置、固态硬盘及可读存储介质Storage management method, device, solid state hard disk and readable storage medium
相关申请的交叉引用Cross-reference to related applications
本申请要求于2017年12月20日提交中国专利局的申请号为201711380674.9,名称为“存储管理方法、固态硬盘及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201711380674.9, entitled "Storage Management Method, Solid State Drive, and Readable Storage Media", filed on Dec. 20, 2017, the entire contents of In this application.
技术领域Technical field
本申请涉及存储技术领域,具体而言,涉及一种存储管理方法、装置、固态硬盘及可读存储介质。The present application relates to the field of storage technologies, and in particular, to a storage management method, apparatus, solid state hard disk, and readable storage medium.
背景技术Background technique
固态硬盘(SSD,Solid State Drives)是采用固态电子存储芯片阵列而制成的硬盘,通常由主控芯片和闪存芯片组成,主控芯片是固态硬盘中负责控制数据存储的控制单元,闪存芯片是固态硬盘中负责存储数据的存储单元。其中,主控芯片的核心是FTL(Flash Translation Layer,闪存转换层),FTL负责地址映射、垃圾回收、磨损均衡、坏块管理等业务,FTL算法策略的好坏决定了固态硬盘的性能、效率、寿命及稳定性的优劣。闪存芯片是一种长寿命的非易失性(在断电情况下仍能保持存储的数据信息)的存储器,数据删除是以固定的区块为单位。与机械硬盘不同,闪存芯片每次写入新数据时,需要先将原有数据擦除才能写入新数据。Solid State Drives (SSDs) are hard disks made of solid-state electronic storage chip arrays. They are usually composed of a main control chip and a flash memory chip. The main control chip is the control unit responsible for controlling data storage in the solid state drive. The flash memory chip is The storage unit responsible for storing data in the SSD. Among them, the core of the main control chip is FTL (Flash Translation Layer), FTL is responsible for address mapping, garbage collection, wear leveling, bad block management, etc. The quality of FTL algorithm determines the performance and efficiency of SSD. The pros and cons of life and stability. A flash chip is a long-lived non-volatile memory that retains stored data information in the event of a power outage. Data deletion is in fixed blocks. Unlike a mechanical hard disk, each time a flash chip writes new data, it needs to erase the original data before writing new data.
为了让固态硬盘拥有更长久的生命周期,避免不均衡擦写(也即,固态硬盘的一些存储块(Block)被频繁擦除,而另一些存储块极少被擦除)而导致固态硬盘的整体生命周期缩短,存储领域的技术人员提出了磨损均衡算法(Wear-Levelling)和垃圾回收策略(Garbage Collection)来解决这些问题。垃圾回收策略主要是固态硬盘中的磁盘整理程序,可将碎片化的存储空间合并成整块的存储空间。磨损均衡算法是固态硬盘中用于选择待擦除存储单元的算法,让所有存储块的擦除次数尽可能的均衡。In order to make SSDs have a longer life cycle, avoid unbalanced erasing (that is, some blocks of SSDs are frequently erased, while others are rarely erased), resulting in SSDs. The overall life cycle is shortened, and technicians in the storage space have proposed wear-leveling algorithms (Wear-Levelling) and garbage collection strategies (Garbage Collection) to solve these problems. The garbage collection strategy is mainly a defragmentation program in the SSD, which can combine the fragmented storage space into a whole block of storage space. The wear leveling algorithm is an algorithm for selecting a memory cell to be erased in a solid state hard disk, so that the erasure times of all memory blocks are as balanced as possible.
然而,在数据监控领域,由于执行监控任务的数据采集设备需要不断地将采集的数据写入固态硬盘,固态硬盘的存储空间始终处于邻近全满的存储状态,需要利用上述垃圾回收策略和上述磨损均衡算法对固态硬盘的存储块进行循环复写。虽然,传统的标准固态硬盘的主控芯片具备标准的垃圾回收策略和磨损均衡算法,但在标准固态硬盘出厂时,主控芯片的FTL架构已完成设置,不可随意更改。标准固态硬盘在执行监控存储业务时,标准的FTL架构无法满足实际的业务存储需求,存储性能不够优越。并且,垃圾回收和磨损均衡会影响固态硬盘的读写效率,当固态硬盘的存储空间接近满状态时,性能不够优越的垃圾回收策略和磨损均衡算法不但无法提高存储速度,反而会限制固态硬盘的存储效率。However, in the field of data monitoring, since the data acquisition device performing the monitoring task needs to continuously write the collected data to the solid state hard disk, the storage space of the solid state hard disk is always in a nearly full storage state, and it is necessary to utilize the above garbage collection strategy and the above-mentioned wear and tear. The equalization algorithm cyclically rewrites the memory blocks of the solid state drive. Although the standard chip of the traditional standard SSD has a standard garbage collection strategy and wear leveling algorithm, when the standard SSD is shipped from the factory, the FTL architecture of the main control chip has been set and cannot be changed at will. When a standard SSD is used to monitor storage services, the standard FTL architecture cannot meet the actual service storage requirements, and the storage performance is not superior. Moreover, garbage collection and wear leveling will affect the read/write efficiency of SSDs. When the storage space of SSDs is near full, the garbage recovery strategy and wear leveling algorithm with insufficient performance will not improve the storage speed, but will limit the SSD. Storage efficiency.
申请内容Application content
本申请实施例的目的包括,例如,提供一种存储管理方法、装置、固态硬盘及可读存储介质。The purpose of embodiments of the present application includes, for example, providing a storage management method, apparatus, solid state hard disk, and readable storage medium.
第一方面,本申请实施例提供一种存储管理方法,所述方法包括:In a first aspect, an embodiment of the present application provides a storage management method, where the method includes:
当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中;When it is detected that the data incoming by the storage channel needs to be stored, the available storage block is obtained, and the incoming data is written into the available storage block;
当数据写入完成时,检测存储空间状态标识是否为非复写状态;When the data writing is completed, detecting whether the storage space status identifier is a non-overwrite status;
在为非复写状态时,检测存储空间是否达到写满状态;When it is in the non-overwrite state, it is detected whether the storage space reaches the full state;
当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。When the storage space reaches the full state, the storage space state identifier is switched to a replication state, and a timer is started, and the storage space is periodically timed according to the storage life coefficient of each storage block in the storage space and the life balance balancing strategy of the storage block. Recycling distribution processing.
第二方面,本申请实施例提供一种存储管理装置,所述装置包括:In a second aspect, the embodiment of the present application provides a storage management apparatus, where the apparatus includes:
数据写入模块,配置成当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中;a data writing module configured to: when detecting that data to be input to the storage channel is to be stored, obtain an available storage block, and write the incoming data into the available storage block;
第一检测模块,配置成当数据写入完成时,检测存储空间状态标识是否为非复写状态;The first detecting module is configured to detect, when the data writing is completed, whether the storage space status identifier is in a non-overwritten state;
第二检测模块,配置成在为非复写状态时,检测存储空间是否达到写满状态;a second detecting module configured to detect whether the storage space reaches a full state when the state is non-overwritten;
回收分配模块,配置成当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。Recycling the allocation module, configured to switch the storage space state identifier to a replication state when the storage space reaches a full state, and start a timer according to a storage life coefficient of each storage block in the storage space and a life of the storage block The balancing strategy periodically performs storage space reclamation allocation processing.
第三方面,本申请实施例提供一种固态硬盘,包括控制单元及存储有若干计算机指令的非易失性存储单元,所述计算机指令被所述控制单元执行时,所述控制单元执行上述的存储管理方法。In a third aspect, an embodiment of the present application provides a solid state hard disk, including a control unit and a nonvolatile storage unit storing a plurality of computer instructions. When the computer instruction is executed by the control unit, the control unit performs the foregoing Storage management method.
第四方面,本申请实施例提供一种可读存储介质,所述可读存储介质包括计算机程序,所述计算机程序运行时控制所述可读存储介质所在的固态硬盘执行上述的存储管理方法。In a fourth aspect, an embodiment of the present application provides a readable storage medium, where the readable storage medium includes a computer program, and the computer program controls the SSD in which the readable storage medium is located to execute the foregoing storage management method.
相对于现有技术而言,本申请具有以下有益效果:Compared with the prior art, the present application has the following beneficial effects:
本申请提供一种存储管理方法、装置、固态硬盘及可读存储介质。所述方法包括:当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入数据写入所述可用存储块中。当数据写入完成时,检测存储空间状态标识是否为非复写状态。在为非复写状态时,检测存储空间是否达到写满状态。当存储空间达到写满状态时,将存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。由此,可对存储空间中的存储块进行均衡擦除,提升固态硬盘的整体使用寿命,提升数据读写效率。The application provides a storage management method, device, solid state hard disk and readable storage medium. The method includes, when it is detected that data incoming to the storage channel needs to be stored, obtaining an available storage block and writing the incoming data to the available storage block. When the data writing is completed, it is detected whether the storage space status flag is non-overwritten. When it is in the non-overwrite state, it detects whether the storage space has reached the full state. When the storage space reaches the full state, the storage space state identifier is switched to the replication state, and a timer is started, and the storage space collection and distribution process is performed according to the storage life coefficient of each storage block in the storage space and the life balance balancing policy of the storage block. Therefore, the memory blocks in the storage space can be erased evenly, the overall service life of the solid state hard disk is improved, and the data reading and writing efficiency is improved.
附图说明DRAWINGS
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings to be used in the embodiments will be briefly described below. It should be understood that the following drawings show only certain embodiments of the present application, and therefore It should be seen as a limitation on the scope, and those skilled in the art can obtain other related drawings according to these drawings without any creative work.
图1是本申请实施例提供的监控系统的方框示意图。FIG. 1 is a block schematic diagram of a monitoring system provided by an embodiment of the present application.
图2是本申请实施例提供的固态硬盘的方框示意图。2 is a block schematic diagram of a solid state drive provided by an embodiment of the present application.
图3是本申请实施例提供的存储管理方法的步骤流程图之一。FIG. 3 is a flow chart of steps of a storage management method provided by an embodiment of the present application.
图4是本申请实施例提供的存储管理方法的步骤流程图之二。FIG. 4 is a second flowchart of the steps of the storage management method provided by the embodiment of the present application.
图5是本申请实施例提供的图3所示的步骤S120的子步骤流程图。FIG. 5 is a flowchart of a sub-step of step S120 shown in FIG. 3 according to an embodiment of the present application.
图6是本申请实施例提供的图3所示的步骤S150的子步骤流程图之一。FIG. 6 is one of the flowcharts of the sub-steps of step S150 shown in FIG. 3 provided by the embodiment of the present application.
图7是本申请实施例提供的图3所示的步骤S150的子步骤流程图之二。FIG. 7 is a second flowchart of the sub-steps of step S150 shown in FIG. 3 provided by the embodiment of the present application.
图8是本申请实施例提供的图6所示的子步骤S1570的子步骤流程图。FIG. 8 is a flow chart showing the sub-steps of sub-step S1570 shown in FIG. 6 provided by the embodiment of the present application.
图9是本申请实施例提供的图6所示的子步骤S1580的子步骤流程图。FIG. 9 is a flow chart showing the sub-steps of sub-step S1580 shown in FIG. 6 provided by the embodiment of the present application.
图10是本申请实施例提供的图6所示的子步骤S1590的子步骤流程图。FIG. 10 is a flow chart showing the sub-steps of sub-step S1590 shown in FIG. 6 provided by the embodiment of the present application.
图11是本申请实施例提供的存储管理装置的结构框图之一。FIG. 11 is a structural block diagram of a storage management apparatus according to an embodiment of the present application.
图标:10-监控系统;100-存储设备;110-固态硬盘;111-控制单元;112-存储单元;200-数据采集设备。Icons: 10-monitoring system; 100-storage device; 110-solid state hard disk; 111-control unit; 112-storage unit; 200-data acquisition device.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in various different configurations. The detailed description of the embodiments of the present application, which is set forth in the claims All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that similar reference numerals and letters indicate similar items in the following figures, and therefore, once an item is defined in a drawing, it is not necessary to further define and explain it in the subsequent drawings.
请参照图1,图1是本申请实施例提供的监控系统10的方框示意图。所述监控系统10包括:至少一个数据采集设备200及存储设备100。所述数据采集设备200与所述存储设备100通信连接,具体通信连接方式可以采用有线连接方式或无线连接方式。图1简单示意出一个存储设备100和多个数据采集设备200,每个数据采集设备200可对应一个存储通道,每个数据采集设备200通过对应的存储通道可将需要存储的数据传输给存储设备100,以保存到所述固态硬盘110中。Please refer to FIG. 1. FIG. 1 is a block diagram of a monitoring system 10 according to an embodiment of the present application. The monitoring system 10 includes at least one data collection device 200 and a storage device 100. The data collection device 200 is in communication with the storage device 100, and the specific communication connection manner may be a wired connection manner or a wireless connection manner. FIG. 1 is a schematic diagram showing a storage device 100 and a plurality of data collection devices 200. Each data collection device 200 can correspond to one storage channel. Each data collection device 200 can transmit data to be stored to the storage device through a corresponding storage channel. 100 to save to the solid state hard disk 110.
在本实施例中,所述存储设备100包括至少一个配置成存储数据信息的固态硬盘110。执行监控任务的数据采集设备200需要不间断的采集数据信息,并将采集的数据信息通过存储通道传输给所述存储设备100,以将数据信息保存到所述固态硬盘110中。In this embodiment, the storage device 100 includes at least one solid state drive 110 configured to store data information. The data collection device 200 performing the monitoring task needs to continuously collect data information, and transmits the collected data information to the storage device 100 through the storage channel to save the data information to the solid state hard disk 110.
在本实施例中,所述数据采集设备200可以包括,但不限于,图像采集设备(比如,照相机、摄像机等)、音频采集设备(比如,录音机)等。In this embodiment, the data collection device 200 may include, but is not limited to, an image acquisition device (eg, a camera, a camera, etc.), an audio collection device (eg, a recorder), and the like.
请参照图2,图2是本申请实施例提供的固态硬盘110的方框示意图。所述固态硬盘110包括控制单元111及存储单元112。其中,所述控制单元111包括配置成控制数据存储的主控芯片,所述存储单元112包括配置成存储数据信息的非易失性闪存芯片。Please refer to FIG. 2. FIG. 2 is a schematic block diagram of a solid state hard disk 110 according to an embodiment of the present application. The solid state hard disk 110 includes a control unit 111 and a storage unit 112. Wherein, the control unit 111 includes a main control chip configured to control data storage, and the storage unit 112 includes a non-volatile flash memory chip configured to store data information.
对于消费级市场,由于需求的存储功能比较简单和统一,传统的标准固态硬盘即可满足需求。对于企业级市场,存储需求复杂,存在不同的操作系统和主板架构,传统的标准固态硬盘难以满足需求。用户希望能够自定义FTL,可根据自己的数据特点设计高效的FTL。比如,搜索引擎可以把索引表和SSD物理地址对应、日志数据可以直接流式写入SSD内部Flash通道、数据库希望key-value能对应到SSD物理地址等。在这个大背景前提下,CNEXlabs提出了Open Channel SSD的概念,SSD的控制单元把SSD内部的通道开放给用户使用,控制单元只负责Flash数据传输、ECC(Error Correcting Code,错误检查和纠正)、RAID(Redundant Arrays of Independent Disks,磁盘阵列)、垃圾回收、错误处理、坏块管理等工作,而FTL层的设计由用户根据自身需求实现。For the consumer market, traditional standard SSDs can meet demand due to the simple and uniform storage requirements. For the enterprise market, storage requirements are complex, there are different operating systems and motherboard architectures, and traditional standard SSDs are difficult to meet. Users want to be able to customize FTL and design efficient FTL based on their own data characteristics. For example, the search engine can associate the index table with the physical address of the SSD, and the log data can be directly streamed into the internal flash channel of the SSD, and the database hopes that the key-value can correspond to the physical address of the SSD. Under the premise of this background, CNEXlabs proposed the concept of Open Channel SSD. The control unit of SSD opens the internal channel of SSD to users. The control unit is only responsible for Flash data transmission, ECC (Error Correcting Code, error checking and correction). RAID (Redundant Arrays of Independent Disks), garbage collection, error handling, bad block management, etc., and the design of the FTL layer is implemented by users according to their own needs.
在本实施例中,本方案提供的固态硬盘110优选采用上述的Open Channel SSD架构实现。采用Open  Channel SSD架构的好处在于:主控芯片的FTL可以和产品驱动、文件系统高度融合,提升工作效率;存储业务根据需求定义FTL,FTL可以按照需求不断更新升级;针对不同应用可开发不同存储业务;可以集中管理多个SSD,组合高效的SSD阵列;可降低SSD主控芯片的负荷,可以使用更低的主频和更小的Memory(存储器),降低功耗和成本。In this embodiment, the solid state drive 110 provided by the solution is preferably implemented by using the Open Channel SSD architecture described above. The advantages of using the Open Channel SSD architecture are: the FTL of the main control chip can be highly integrated with the product driver and file system to improve work efficiency; the storage service defines the FTL according to the requirements, and the FTL can be continuously updated and upgraded according to requirements; different storage can be developed for different applications. Business; can centrally manage multiple SSDs, combine efficient SSD arrays; reduce the load on the SSD master chip, use lower frequency and smaller memory, reduce power consumption and cost.
在本实施例中,可以采用Open Channel SSD架构,结合监控业务需求,在主控芯片侧直接实现监控数据的循环复写,在循环复写的过程中实现高效的数据垃圾回收和磨损平衡。In this embodiment, the Open Channel SSD architecture can be adopted, combined with the monitoring service requirement, the cyclic rewriting of the monitoring data is directly implemented on the main control chip side, and efficient data garbage collection and wear balance are realized in the process of cyclic overwriting.
在本实施例中,所述存储单元112中存储有若干计算机指令。所述计算机指令被所述控制单元111执行时,所述控制单元111可执行下述的存储管理方法。In this embodiment, a plurality of computer instructions are stored in the storage unit 112. When the computer instruction is executed by the control unit 111, the control unit 111 may perform the storage management method described below.
本申请提供一种可读存储介质,所述可读存储介质包括计算机程序。所述计算机程序运行时控制所述可读存储介质所在固态硬盘110执行下面的存储管理方法。The application provides a readable storage medium comprising a computer program. The solid state hard disk 110 in which the readable storage medium is located is controlled to execute the following storage management method when the computer program is running.
本申请提供一种存储管理方法。请参照图3,图3是本申请实施例提供的存储管理方法的步骤流程图之一。所述存储管理方法应用于上述固态硬盘110。下面对存储管理方法流程进行详细阐述。The application provides a storage management method. Please refer to FIG. 3. FIG. 3 is a flow chart of the steps of the storage management method provided by the embodiment of the present application. The storage management method is applied to the above-described solid state hard disk 110. The storage management method flow is described in detail below.
步骤S120,当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中。如果可用存储块的数量为多个时,则可以从多个可用存储块中随机选取用于写入该数据的可用存储块,当然,还可以根据传入的数据量大小而确定用于写入该数据的可用存储块的数量。Step S120: When it is detected that the data incoming by the storage channel needs to be stored, the available storage block is obtained, and the incoming data is written into the available storage block. If the number of available storage blocks is multiple, the available storage blocks for writing the data may be randomly selected from the plurality of available storage blocks, and of course, the writing for the size of the incoming data may be determined for writing. The number of available storage blocks for this data.
通常固态硬盘的存储空间都会按照物理地址划分为若干等分的存储单元块(也即,存储块),存储块是数据管理的基本单位,所有待存储的数据都会保存在存储块中。通常情况下,存储块如下几种状态:Generally, the storage space of a solid state hard disk is divided into several equally divided storage unit blocks (that is, storage blocks) according to physical addresses. The storage block is a basic unit of data management, and all data to be stored is stored in the storage block. Normally, the storage block has the following states:
1)空闲状态:存储块中无有效数据,且存储块中的数据均已被擦除,该存储块可以写入新数据;1) Idle state: there is no valid data in the memory block, and the data in the memory block has been erased, and the memory block can write new data;
2)有效状态:存储块中保存着有效数据(索引、录像、图片、元数据、日志、报警记录等)。2) Valid status: The valid data (index, video, picture, metadata, log, alarm record, etc.) is stored in the memory block.
3)无效状态:存储块中的数据存储时长已经超出实际需要保存的时长,存储块可以被复写,但是由于存储块中的数据尚未被擦除,暂不能被用于写入新数据。3) Invalid state: The data storage duration in the memory block has exceeded the length of time actually needed to be saved, and the memory block can be overwritten, but since the data in the memory block has not been erased, it cannot be used to write new data.
存储块的大小可以根据实际需要而合理定义,由于不同存储通道的复写速度不一致,因此可以按照复写速度最慢的存储通道来定义存储块的大小。The size of the storage block can be reasonably defined according to actual needs. Since the rewriting speeds of different storage channels are inconsistent, the size of the storage block can be defined according to the storage channel with the slowest replication speed.
步骤S130,当数据写入完成时,检测存储空间状态标识是否为非复写状态。Step S130, when the data writing is completed, detecting whether the storage space status identifier is a non-overwrite status.
在本实施例中,在完成一次数据写入操作时,控制单元111需要检测存储空间状态标识是否为非复写状态。其中,存储空间状态标识可以采用数字和/或字符等形式表征,不同的数字和/或字符均表征不同的状态。控制单元111通过在指定位置中读取存储空间状态标识,可以确定存储空间的当前状态。控制单元111预先已知非复写状态对应的存储空间状态标识,通过比对当前的存储空间状态标识与已知的非复写状态对应的存储空间状态标识是否一致,即可判断当前的存储空间状态标识是否为非复写状态。在本实施例中,所述非复写状态是指初始启用固态硬盘110时,所述固态硬盘110的存储空间中存在较多的可用存储块,无需对存储块进行回收复写处理的初始化状态。In the present embodiment, when a data write operation is completed, the control unit 111 needs to detect whether the storage space status flag is a non-overwrite state. The storage space status identifier may be represented by numbers and/or characters, and different numbers and/or characters are used to represent different states. The control unit 111 can determine the current state of the storage space by reading the storage space status identification in the specified location. The control unit 111 knows in advance the storage space state identifier corresponding to the non-overwrite state, and can determine the current storage space state identifier by comparing whether the current storage space state identifier and the storage space state identifier corresponding to the known non-overwrite state are consistent. Whether it is non-overwritten. In the embodiment, the non-overwrite state refers to that when the SSD 110 is initially enabled, there are more available storage blocks in the storage space of the SSD 110, and the initialization state of the storage block is not required to be recycled and rewritten.
步骤S140,在为非复写状态时,检测存储空间是否达到写满状态。Step S140, when it is in the non-overwrite state, it is detected whether the storage space reaches the full state.
在本实施例中,在为非复写状态时,所述控制单元111需要检测存储空间是否达到写满状态。In this embodiment, when in the non-overwrite state, the control unit 111 needs to detect whether the storage space reaches the full state.
在本实施例中,所述控制单元111检测存储空间是否达到写满状态的方式可以包括,但不限于:1).检测存储空间中当前被数据占用的存储块数量是否超过存储满状态阈值,若超过存储满状态阈值,则可判定达到写满状态,反之则未达到写满状态。2).检测存储空间中当前处于空闲状态的存储块的数量是 否低于存储下限阈值,若低于存储下限阈值,则可判定达到写满状态,反之则未达到写满状态。其中,所述存储满状态阈值或存储下限阈值可根据实际需求进行设定。在实际应用中,可以灵活选用上述1)和/或2),或者选用其它写满状态的检测方式,在此不再赘述。In this embodiment, the manner in which the control unit 111 detects whether the storage space reaches the full state may include, but is not limited to: 1) detecting whether the number of storage blocks currently occupied by the data in the storage space exceeds the storage full state threshold. If the full state threshold is exceeded, it can be determined that the full state is reached, and if not, the full state is not reached. 2). Detect whether the number of memory blocks currently in the idle state in the storage space is lower than the storage lower threshold. If it is lower than the storage lower threshold, it can be determined that the full state is reached, otherwise the full state is not reached. The storage full state threshold or the storage lower threshold may be set according to actual needs. In the actual application, the above 1) and/or 2) can be flexibly selected, or other detection modes of the full state can be selected, and details are not described herein again.
步骤S150,当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。Step S150, when the storage space reaches the full state, the storage space state identifier is switched to a replication state, and a timer is started, according to a storage life coefficient of each storage block in the storage space and a life balance policy timing of the storage block. Perform storage space reclamation allocation processing.
在本实施例中,可对定时器的报警时刻进行设置,以便于在到达报警时刻时,在定时器的触发下进行存储空间回收分配处理。在对报警时刻进行设置时,可以预先设定报警时长,根据当前时刻以及报警时长,确定定时器的报警时刻。In this embodiment, the alarm time of the timer can be set so that the storage space collection and distribution process is performed under the trigger of the timer when the alarm time is reached. When setting the alarm time, the alarm duration can be set in advance, and the alarm time of the timer can be determined according to the current time and the alarm duration.
请参照图4,图4是本申请实施例提供的存储管理方法的步骤流程图之二。在进行数据写入的步骤S120之前,所述方法还需要对所述固态硬盘110进行初始化处理。进行初始化处理的步骤包括:步骤S110、步骤S112、步骤S114、步骤S116及步骤S118。Please refer to FIG. 4. FIG. 4 is a second flowchart of the steps of the storage management method provided by the embodiment of the present application. Before the step S120 of data writing, the method further needs to perform initialization processing on the solid state hard disk 110. The step of performing the initialization process includes: step S110, step S112, step S114, step S116, and step S118.
步骤S110,将存储空间划分为多个存储块。也即,将存储空间划分为多个存储区。In step S110, the storage space is divided into a plurality of storage blocks. That is, the storage space is divided into a plurality of storage areas.
在本实施例中,在进行固态硬盘110初始化处理时,首先需要将固态硬盘110的存储空间按照物理地址划分为多个若干等分的存储块。In this embodiment, when the SSD 110 initialization process is performed, the storage space of the SSD 110 needs to be divided into a plurality of halved storage blocks according to the physical address.
在本实施例中,存储块是数据管理的基本单位,所有待存储的数据都需要写入某个存储块中进行保存。其中,存储块主要包括三种状态:1.空闲状态:未保存数据,可写入数据。2.有效状态:保存有有效数据(比如,索引数据、录像数据、图片数据、元数据、日志数据、报警记录等),不可写入数据。3.无效状态:保存有无效数据(即数据的保存时间已超出实际需要的存储时间),可以被复写,但由于无效数据未被擦除,尚不能写入新数据。In this embodiment, the storage block is a basic unit of data management, and all data to be stored needs to be written into a certain storage block for storage. Among them, the memory block mainly includes three states: 1. idle state: data is not saved, and data can be written. 2. Valid status: Save valid data (for example, index data, video data, picture data, metadata, log data, alarm records, etc.), and data cannot be written. 3. Invalid state: Invalid data is saved (that is, the data storage time has exceeded the actual storage time required), and can be overwritten, but since the invalid data is not erased, new data cannot be written yet.
在本实施例中,监控系统10需要存储的监控数据可以包括,但不限于,业务数据(比如视频录像、抓拍图片、报警消息、日志记录等)、管理数据(比如,地址映射、存储块状态、存储通道状态等)以及业务数据对应的索引数据等。所述监控系统10中的每个数据采集设备200可对应一个存储通道,每个数据采集设备200通过对应的存储通道可将需要存储的数据传输给存储设备100,以保存到所述固态硬盘110中。In this embodiment, the monitoring data that the monitoring system 10 needs to store may include, but is not limited to, service data (such as video recording, snapshot pictures, alarm messages, log records, etc.), management data (eg, address mapping, storage block status). , storage channel status, etc.) and index data corresponding to business data. Each of the data collection devices 200 in the monitoring system 10 can correspond to one storage channel, and each data collection device 200 can transmit data to be stored to the storage device 100 through a corresponding storage channel to be saved to the solid state hard disk 110. in.
在本实施例中,当同时存在多个存储通道保存数据时,需要根据具体业务对存储块的大小进行定义合理,以使每个存储通道可根据需求灵活指定需要占用的存储空间。例如,如果不同存储通道的复写速度不一致,则可按照复写速度最慢的存储通道来定义存储块的大小。由此,每个存储通道可根据复写速度快慢选择存储块数量,比如,复写速度快的存储通道可获取较多的存储块,以便于快速完成数据写入处理,提升存储处理效率。In this embodiment, when multiple storage channels are saved at the same time, the size of the storage blocks needs to be defined according to specific services, so that each storage channel can flexibly specify the storage space to be occupied according to requirements. For example, if the rewriting speeds of different storage channels are inconsistent, the size of the storage block can be defined according to the storage channel with the slowest replication speed. Therefore, each storage channel can select the number of storage blocks according to the speed of the rewriting speed. For example, a storage channel with a fast rewriting speed can acquire more storage blocks, so as to quickly complete data writing processing and improve storage processing efficiency.
在本实施例中,索引数据的复写速度相比于业务数据要慢很多,若按照索引数据的复写速度定义存储块的大小,由于索引数据占用空间较少,存储块会变得非常小,从而影响存储效率,不利于管理。此时,本实施例提出了以下策略的一种或多种进行优化:In this embodiment, the rewriting speed of the index data is much slower than the service data. If the size of the storage block is defined according to the rewriting speed of the index data, since the index data occupies less space, the storage block becomes very small, thereby Affects storage efficiency and is not conducive to management. At this time, this embodiment proposes one or more of the following strategies for optimization:
策略1:索引数据不单独保存,可与业务数据合在一起进行存储。Strategy 1: Index data is not saved separately and can be stored together with business data.
策略2:将多个存储通道的索引合并在一起进行存储,增加复写速度。Strategy 2: Combine the indexes of multiple storage channels for storage, increasing the speed of replication.
策略3:采用冗余缓存块的方式实现数据循环复写和磨损平衡。比如,将B块作为A块的冗余缓存 块,将索引数据交替循环写入A、B块中。其中,每个存储通道都具有“可复写存储块数目”参数,每次复写时,都可以按照存储通道对应的可复写存储块数目而执行复写操作。其中,在一些实施方式中,可复写存储块数目=存储通道复写速度*复写周期/存储块容量。当然,也可以采用其它公式计算可复写存储块数目,在此不进行限定。在本实施例中,对于管理数据的保存可以采用以下策略的一种或多种进行优化:Strategy 3: Data cycle replication and wear leveling are implemented by means of redundant cache blocks. For example, the B block is used as the redundant buffer block of the A block, and the index data is alternately written into the A and B blocks. Each storage channel has a "number of rewritable memory blocks" parameter, and each time the overwrite is performed, the overwrite operation can be performed according to the number of rewritable memory blocks corresponding to the storage channel. Wherein, in some embodiments, the number of rewritable memory blocks = memory channel copy speed * copy cycle / memory block capacity. Of course, other formulas may also be used to calculate the number of rewritable memory blocks, which are not limited herein. In this embodiment, the saving of management data may be optimized by one or more of the following strategies:
策略1:在固态硬盘110的头部(head)独立划分一块配置成保存管理数据的专用存储区域,所述专用存储区域也可划分为同样大小的存储块。由于存储块数量较少,可按照一定周期定时与固态硬盘110其余存储区域的存储块进行冷热交换处理,从而保证整体的磨损平衡。Strategy 1: A dedicated storage area configured to hold management data is separately partitioned at the head of the solid state drive 110, and the dedicated storage area can also be divided into storage blocks of the same size. Since the number of storage blocks is small, the hot and cold exchange processing can be performed with the storage blocks of the remaining storage areas of the solid state hard disk 110 according to a certain period of time, thereby ensuring the overall wear balance.
策略2:单独采用额外的存储介质(比如,可采用擦除寿命较高、存储空间较小的SLC(Single-Level Cell,单层单元)或MLC(Multi-Level Cell,多层单元)闪存介质)保存管理数据。SLC的特点是成本高、容量小和速度快,MLC的特点是容量大、成本低和速度慢。Strategy 2: Use additional storage media separately (for example, SLC (Single-Level Cell) or MLC (Multi-Level Cell) flash media with higher erasure life and smaller storage space ) Save management data. SLC is characterized by high cost, small capacity and fast speed. MLC is characterized by large capacity, low cost and slow speed.
步骤S112,对存储空间状态标识进行初始化定义,将所述存储空间状态标识设置为非复写状态。Step S112, initializing a storage space status identifier, and setting the storage space status identifier to a non-overwrite status.
在本实施例中,为固态硬盘110的存储空间定义一个初始化的存储空间状态标识,将初始化的存储空间状态标识设置为非复写状态,即初始化状态。In this embodiment, an initial storage space state identifier is defined for the storage space of the solid state hard disk 110, and the initialized storage space state identifier is set to a non-overwrite state, that is, an initialization state.
步骤S114,为每个存储通道初始化配置一个可用存储块队列,并在每个可用存储块队列中添加可用存储块。Step S114, initializing one available storage block queue for each storage channel initialization, and adding available storage blocks in each available storage block queue.
在本实施例中,为每个存储通道配置一个可用存储块队列,并在每个可用存储块队列中添加若干个可用存储块。所述添加的可用存储块的数量可根据实际需求进行设定。其中,添加的可用存储块数量不宜太多,优选添加1-2个。In this embodiment, one available storage block queue is configured for each storage channel, and several available storage blocks are added to each available storage block queue. The number of available available storage blocks can be set according to actual needs. Among them, the number of available storage blocks added should not be too much, and it is preferable to add 1-2.
步骤S116,将每个存储通道加入复写通道列表,并按照复写周期从大到小进行排序。Step S116, adding each storage channel to the list of duplicate channels, and sorting according to the rewriting period from large to small.
在本实施例中,建立一张复写通道列表,将每个存储通道加入所述复写通道列表,并将每个存储通道按照复写周期从大到小或者从小到大的顺序进行排序。In this embodiment, a list of duplicate write channels is created, each storage channel is added to the list of duplicate write channels, and each storage channel is sorted in descending order of the replication cycle from large to small or from small to large.
步骤S118,计算所述复写通道列表中每个存储通道的可复写存储块数目,并将所述可复写存储块数目对应记录到所述复写通道列表中。Step S118, calculating a number of rewritable memory blocks of each memory channel in the list of duplicate write channels, and correspondingly recording the number of rewritable memory blocks into the list of duplicate write channels.
在本实施例中,计算可复写存储块数目的公式可以包括,但不限于:m=s×T÷k。其中,m表示可复写存储块数目,s表示存储通道复写速度,T表示复写周期,k表示存储块的大小。In this embodiment, the formula for calculating the number of rewritable memory blocks may include, but is not limited to, m=s×T÷k. Where m represents the number of rewritable memory blocks, s represents the memory channel copy speed, T represents the overwrite period, and k represents the size of the memory block.
下面结合上述描述对图3中的步骤S120及步骤S150进行说明。Step S120 and step S150 in Fig. 3 will be described below in conjunction with the above description.
对于步骤S120,请参照图5,图5是本申请实施例提供的图3所示的步骤S120的子步骤流程图。所述步骤S120包括子步骤S121、子步骤S122、子步骤S123、步骤S124、子步骤S125及子步骤S126。For the step S120, please refer to FIG. 5. FIG. 5 is a flowchart of the sub-steps of step S120 shown in FIG. 3 according to the embodiment of the present application. The step S120 includes a sub-step S121, a sub-step S122, a sub-step S123, a step S124, a sub-step S125, and a sub-step S126.
子步骤S121,当检测到所述存储通道对应的所述可用存储块队列中有可用存储块时,从所述可用存储块队列中获取预设数量的可用存储块,并将数据写入所述可用存储块中。Sub-step S121, when it is detected that there is an available storage block in the available storage block queue corresponding to the storage channel, obtain a preset number of available storage blocks from the available storage block queue, and write data into the Available in the memory block.
在本实施例中,控制单元111在检测到需要对存储通道传入的数据进行存储时,先检测所述存储通道对应的所述可用存储块队列中是否有可用存储块。在有可用存储块时,所述控制单元111可从所述可用存储块队列中获取预设数量的可用存储块,并将数据写入所述可用存储块中。其中,所述预设数量可根据所述可用存储块队列允许存放的可用存储块数量进行设定。In this embodiment, when detecting that the data incoming in the storage channel needs to be stored, the control unit 111 first detects whether there is an available storage block in the available storage block queue corresponding to the storage channel. When there are available storage blocks, the control unit 111 may obtain a preset number of available storage blocks from the available storage block queue and write data into the available storage blocks. The preset number may be set according to the number of available storage blocks allowed to be stored in the available storage block queue.
在本实施例中,若所述可用存储块队列中没有可用存储块,所述控制单元111可在存储空间中获取 处于空闲状态的存储块,将所述处于空闲状态的存储块作为可用存储块加入到所述可用存储块队列中。若所述存储空间中没有处于空闲状态的存储块,则表明当前固态硬盘110没有可用的数据存储空间,无法进行数据写入。In this embodiment, if there is no available storage block in the available storage block queue, the control unit 111 may acquire the storage block in the idle state in the storage space, and use the storage block in the idle state as the available storage block. Join the queue of available storage blocks. If there is no storage block in the storage space in the idle state, it indicates that the current solid state hard disk 110 has no available data storage space, and data writing cannot be performed.
在本实施例中,所述可用存储块队列中不会存放过多数量的可用存储块,本方案采用用完再取的策略,当所述可用存储块队列中的可用存储块用完时可重新添加,可有效避免存储资源的浪费。In this embodiment, the available storage block queue does not store an excessive number of available storage blocks, and the solution adopts a strategy of using up and fetching, when the available storage blocks in the available storage block queue are exhausted. Re-adding can effectively avoid the waste of storage resources.
子步骤S122,当检测到所述可用存储块写满时,将所述可用存储块从所述可用存储块队列中出队。Sub-step S122, when it is detected that the available storage block is full, the available storage block is dequeued from the available storage block queue.
在本实施例中,当一个可用存储块写满时,则变更为非可用存储块,所述控制单元111可将该非可用存储块移出所述可用存储块队列。In this embodiment, when one available memory block is full, it is changed to a non-available memory block, and the control unit 111 can move the non-available memory block out of the available memory block queue.
子步骤S123,检测数据写入操作是否完成。如果否,执行子步骤S124;如果是,则返回执行子步骤S121,也即,在数据写入操作完成时,控制单元111循环执行上述子步骤S121-子步骤S123。Sub-step S123, it is detected whether the data writing operation is completed. If not, sub-step S124 is performed; if yes, the execution sub-step S121 is returned, that is, when the data writing operation is completed, the control unit 111 cyclically executes the above-described sub-step S121 - sub-step S123.
在本实施例中,考虑到可用存储块的存储容量有限,当写完一个可用存储块时,所述控制单元111可检测所述存储通道本次的数据写入操作是否完成。In this embodiment, considering that the storage capacity of the available storage block is limited, when an available storage block is written, the control unit 111 may detect whether the current data write operation of the storage channel is completed.
子步骤S124,当数据写入未完成时,对所述存储空间状态标识的当前状态进行检测。控制单元111在确定数据写入未完成时,识别存储空间状态标识的当前状态时复写状态还是非复写状态;如果是非复写状态,执行子步骤S125,如果是复写状态,执行子步骤S126。Sub-step S124, when the data writing is not completed, the current state of the storage space status identifier is detected. The control unit 111 recognizes whether the current state of the storage space state identifier is the overwrite state or the non-overwrite state when it is determined that the data write is not completed; if it is the non-overwrite state, the sub-step S125 is performed, and if it is the overwrite state, the sub-step S126 is performed.
子步骤S125,当所述当前状态为非复写状态时,从存储空间中获取处于空闲状态的存储块加入所述可用存储块队列,并从所述可用存储块队列中获取新的可用存储块进行数据写入。处于非复写状态的存储空间中通常有空闲的存储块,因而可以进一步利用该存储空间中处于空闲状态的存储块,将空闲的存储块放置于可用存储块队列,以便于进行数据写入。Sub-step S125, when the current state is a non-overwrite state, acquiring a storage block in an idle state from the storage space to join the available storage block queue, and acquiring a new available storage block from the available storage block queue. Data is written. There is usually a free storage block in the storage space in the non-overwrite state, so that the storage block in the idle state in the storage space can be further utilized, and the free storage block is placed in the available storage block queue to facilitate data writing.
子步骤S126,当所述当前状态为复写状态时,从所述可用存储块队列中获取新的可用存储块进行数据写入。Sub-step S126, when the current state is a replication state, a new available storage block is obtained from the available storage block queue for data writing.
在本实施例中,基于所述存储空间状态标识的不同状态,所述可用存储块的获取方式也不同。In this embodiment, the available storage blocks are acquired in different manners based on different states of the storage space status identifier.
在本实施例中,当所述存储空间状态标识为非复写状态时,所述控制单元111可从存储空间中获取处于空闲状态的存储块加入所述可用存储块队列,并从所述可用存储块队列中获取新的可用存储块进行数据写入。In this embodiment, when the storage space status is identified as a non-overwrite status, the control unit 111 may acquire a storage block in an idle state from the storage space to join the available storage block queue, and from the available storage. A new available memory block is acquired in the block queue for data writing.
在本实施例中,当所述存储空间状态标识为复写状态时,所述控制单元111会定时进行存储空间回收分配处理,实现内存的动态管理。执行存储块回收分配的进程可将重新回收的存储块作为可用存储块自动放入所述可用存储块队列中。由此,所述控制单元111可从所述可用存储块队列中直接获取新的可用存储块进行数据写入。In this embodiment, when the storage space status identifier is a replication status, the control unit 111 periodically performs a storage space collection and allocation process to implement dynamic memory management. The process performing the memory block reclamation allocation can automatically place the reclaimed memory block as an available memory block into the available memory block queue. Thus, the control unit 111 can directly acquire a new available memory block from the available memory block queue for data writing.
在本实施例中,所述寿命平衡策略包括:热区分配策略、冷区分配策略及平衡区分配策略。热区分配策略即为本实施例提出的一种对存储寿命系数大于热区阈值的存储块进行回收分配处理的方式,冷区分配策略即为本实施例提出的一种对存储寿命系数小于冷区阈值的存储块进行回收分配处理的方式,平衡区分配策略即为本实施例提出的一种对存储寿命系数位于热区阈值与冷区阈值之间的存储块进行回收分配处理的方式。In this embodiment, the life balance strategy includes: a hot zone allocation strategy, a cold zone allocation strategy, and a balance zone allocation strategy. The hot zone allocation strategy is a method for recovering and distributing the storage blocks whose storage lifetime coefficient is greater than the hot zone threshold, and the cold zone allocation strategy is a storage lifetime coefficient smaller than that of the present embodiment. The storage block of the area threshold performs the process of collecting and distributing the processing. The balanced area allocation strategy is a method for collecting and distributing the storage block whose storage life coefficient is between the hot zone threshold and the cold zone threshold.
对于步骤S150,在一种实施方式中,可以参照如下步骤实现:(1)将无效状态的存储块记录在回收列表;(2)对记录在所述回收列表的存储块进行数据擦除处理,更新所述存储块的擦除次数,将所述存 储块的状态更新为空闲状态,并将记录到分配列表;(3)检测所述待处理通道列表中是否存在未处理的待处理通道;(4)当不存在时,根据所述分配列表中每个存储块的当前擦除次数和擦除次数上限计算每个存储块的存储寿命系数;(5)遍历所述分配列表,根据所述分配列表中每个存储块的存储寿命系数,将每个所述存储块加入至热区列表、冷区列表或平衡区列表;其中,所述热区列表中的存储块的存储寿命系数大于热区阈值;所述冷区列表中的存储块的存储寿命系数小于冷区阈值;所述平衡区列表中的存储块的存储寿命系数位于所述热区阈值与所述冷区阈值之间;(6)根据热区分配策略对所述热区列表中的存储块进行热区回收分配处理;(7)根据冷区分配策略对所述冷区列表中的存储块进行冷区回收分配处理;(8)根据平衡区分配策略对所述平衡区列表中的存储块进行平衡区回收分配处理。For step S150, in an embodiment, the following steps may be implemented: (1) recording the storage block in the invalid state in the collection list; (2) performing data erasing processing on the storage block recorded in the collection list, Updating the number of erasures of the storage block, updating the status of the storage block to an idle state, and recording to an allocation list; and (3) detecting whether there is an unprocessed pending channel in the to-be-processed channel list; 4) when not present, calculating a storage life coefficient of each storage block according to a current erasure number and an upper erasing number upper limit of each storage block in the allocation list; (5) traversing the allocation list, according to the allocation a storage life coefficient of each storage block in the list, adding each of the storage blocks to a hot zone list, a cold zone list, or a balance zone list; wherein a storage life coefficient of the storage block in the hot zone list is greater than a hot zone a threshold value; a storage life coefficient of the storage block in the cold zone list is smaller than a cold zone threshold; a storage life coefficient of the storage block in the balance zone list is located in the hot zone threshold and the cold zone threshold (6) performing hot zone collection and distribution processing on the storage blocks in the hot zone list according to the hot zone allocation policy; (7) performing cold zone recovery and distribution processing on the storage blocks in the cold zone list according to the cold zone allocation policy; (8) Performing a balance area recovery allocation process on the storage blocks in the balance area list according to the balance area allocation policy.
为便于理解,请参照图6,图6是本申请实施例提供的图3所示的步骤S150的子步骤流程图之一,详细的说明了一种根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理的具体流程。所述步骤S150包括子步骤S151、子步骤S152、子步骤S153、子步骤S154、子步骤S155、子步骤S156、子步骤S157、子步骤S1570、子步骤S158、子步骤S1580、子步骤S159及子步骤S1590。For ease of understanding, please refer to FIG. 6. FIG. 6 is a flowchart of a sub-step of step S150 shown in FIG. 3 according to an embodiment of the present application, and details a storage life coefficient according to each storage block in the storage space. And the life balance strategy of the storage block periodically performs the specific process of the storage space collection and distribution process. The step S150 includes a sub-step S151, a sub-step S152, a sub-step S153, a sub-step S154, a sub-step S155, a sub-step S156, a sub-step S157, a sub-step S1570, a sub-step S158, a sub-step S1580, a sub-step S159, and a sub-step. Step S1590.
子步骤S151,将正在执行存储业务的存储通道加入待处理通道列表。Sub-step S151, the storage channel that is performing the storage service is added to the to-be-processed channel list.
可以理解的是,监控系统中可能具有多个数据采集设备,每个数据采集设备都对应一个存储通道,并通过对应的存储通道可将需要存储的数据传输给存储设备。在实际应用中,可能在某一时段有一个或多个存储通道都在执行存储业务。通过监测存储通道的当前状态,即可找出在执行存储业务的存储通道。在本实施例中,所述控制单元111将每个正在执行存储业务的存储通道加入待处理通道列表。It can be understood that the monitoring system may have multiple data collection devices, and each data collection device corresponds to one storage channel, and the data to be stored may be transmitted to the storage device through the corresponding storage channel. In practical applications, one or more storage channels may be performing storage services during a certain period of time. By monitoring the current state of the storage channel, it is possible to find the storage channel in which the storage service is executed. In this embodiment, the control unit 111 adds each storage channel that is performing the storage service to the to-be-processed channel list.
子步骤S152,从所述待处理通道列表中获取一个待处理通道,对所述待处理通道对应的存储块进行遍历,查找处于有效状态的存储块。Sub-step S152: Obtain a channel to be processed from the to-be-processed channel list, and traverse the memory block corresponding to the to-be-processed channel to find a memory block in an active state.
在本实施例中,所述控制单元111可从所述待处理通道列表中获取一个待处理通道,然后获取该待处理通道的相关的通道信息,并对所述待处理通道对应的存储块进行遍历,查找处于有效状态的存储块。其中,所述控制单元111可以是随机获取,诸如可从所述待处理通道列表的表头、表尾或任意位置随机获取一个待处理通道;当然,所述控制单元111也可以是按照指定的通道标识而获取相应的待处理通道。In this embodiment, the control unit 111 may obtain a channel to be processed from the to-be-processed channel list, and then acquire related channel information of the to-be-processed channel, and perform a memory block corresponding to the to-be-processed channel. Traverse, find the memory block that is in a valid state. The control unit 111 may be randomly obtained, for example, a channel to be processed may be randomly obtained from a header, a footer or an arbitrary position of the to-be-processed channel list; of course, the control unit 111 may also be specified. The channel identifier is used to obtain the corresponding pending channel.
子步骤S153,在所述处于有效状态的存储块中,按照数据写入时间顺序获取数量为所述可复写存储块数目的存储块,将获取的所述存储块的状态设置为无效状态,并记录到回收列表。在设置无效状态时,可以检测获取的所述存储块中存储的数据的保存时长是否超出需存储时长;如果是,确定获取的所述存储块中存储的数据已失效,并将获取的所述存储块的状态设置为无效状态。Sub-step S153, in the storage block in the active state, acquiring a storage block whose number is the number of the rewritable storage blocks according to a data write time sequence, and setting the acquired state of the storage block to an invalid state, and Record to the recycle list. When the invalid state is set, it may be detected whether the saved duration of the data stored in the obtained storage block exceeds a required storage duration; if yes, it is determined that the acquired data stored in the storage block has expired, and the acquired The status of the memory block is set to an invalid state.
在本实施例中,所述控制单元111可在所述处于有效状态的存储块中,按照数据写入的时间顺序获取一定数量的存储块,获取的存储块的数量等于所述可复写存储块的数量,将获取的所述存储块的状态设置为无效状态,并记录到回收列表中。也即,将处于无效状态的存储块记录在回收列表中。In this embodiment, the control unit 111 may acquire a certain number of storage blocks in the storage block in the active state according to the time sequence of data writing, and the number of the obtained storage blocks is equal to the rewritable storage block. The number of the obtained storage block is set to an invalid state and recorded in the recycle list. That is, the memory block in the invalid state is recorded in the recycle list.
在本实施例中,在按照数据写入的时间顺序获取需要修改状态的存储块时,还可检测被获取的存储块中存储的数据是否已失效,在数据失效(即数据的保存时间超出实际需要的存储时间,比如,录像数据的保存时间超出实际需要保存的录像周期)时,才会修改该存储块的状态,并记录到回收列表中,以避免在后续的回收处理中将存储块中的有效数据擦除。In this embodiment, when the storage block requiring the modified state is acquired in the time sequence of data writing, it is also possible to detect whether the data stored in the acquired storage block has failed, and the data is invalid (that is, the data storage time exceeds the actual The required storage time, for example, when the recording data is saved for longer than the actual recording period to be saved, the state of the storage block is modified and recorded in the recycling list to avoid the storage block in the subsequent recycling process. Valid data erasure.
上述子步骤S151至子步骤S153,即为将无效状态的存储块记录在回收列表的一种具体实施方式。The above sub-step S151 to sub-step S153 are a specific embodiment for recording the storage block in an invalid state in the collection list.
子步骤S154,对记录在所述回收列表的存储块进行数据擦除处理,更新所述存储块的擦除次数,将所述存储块的状态更新为空闲状态,并将记录到分配列表。Sub-step S154, performing data erasing processing on the storage block recorded in the collection list, updating the erasure number of the storage block, updating the status of the storage block to an idle state, and recording to the allocation list.
在本实施例中,存储块每被擦除一次,就需要更新所述存储块的擦除次数,比如,将擦除次数加1。之后,再将所述存储块从无效状态切换为空闲状态,并将记录到分配列表中。In this embodiment, each time the memory block is erased, the number of erasures of the memory block needs to be updated, for example, the number of erasures is increased by one. Thereafter, the memory block is switched from the inactive state to the idle state and recorded in the allocation list.
子步骤S155,检测所述待处理通道列表中是否存在未处理的待处理通道。Sub-step S155, detecting whether there is an unprocessed pending channel in the to-be-processed channel list.
在本实施例中,在完成一个待处理通道的存储块擦除回收处理之后,所述控制单元111可检测所述待处理通道列表中是否存在未处理的待处理通道。若不存在,执行子步骤S156;若存在,则返回执行子步骤S152,也即,在仍存在未处理的待处理通道时,所述控制单元111重复执行上述子步骤S152、子步骤S153及子步骤S154,直到将所述待处理通道列表中的待处理通道均被处理完为止。In this embodiment, after completing the storage block erasure recovery process of a to-be-processed channel, the control unit 111 may detect whether there is an unprocessed to-be-processed channel in the to-be-processed channel list. If not, execute sub-step S156; if yes, return to execution sub-step S152, that is, when there is still an unprocessed pending channel, the control unit 111 repeatedly performs the above-mentioned sub-step S152, sub-step S153 and sub- Step S154, until all the to-be-processed channels in the to-be-processed channel list are processed.
子步骤S156,当不存在时,根据所述分配列表中每个存储块的当前擦除次数和擦除次数上限计算每个存储块的存储寿命系数。Sub-step S156, when not present, calculate the storage life coefficient of each storage block according to the current erasure number and the upper limit of the number of erasures of each storage block in the allocation list.
在本实施例中,所述存储寿命系数的计算方法可以是,但不限于:存储寿命系数=当前擦除次数÷擦除次数上限。其中,每个存储块均有对应的擦除次数上限,所述擦除次数上限可在进行初始化处理时设置。不同存储块的擦除次数上限可以相同,也可以不同。In this embodiment, the calculation method of the storage life coefficient may be, but not limited to, a storage life coefficient=the current erasure number ÷the erasure number upper limit. Each of the storage blocks has an upper limit of the number of erasures, and the upper limit of the number of erasures can be set when the initialization process is performed. The upper limit of the number of erasures of different memory blocks may be the same or different.
在本实施例中,采用存储块每被擦除一次,当前擦除次数加1的更新方式,由于擦除次数影响存储块的使用寿命,而每个存储块的擦除次数上限是一个固定值,当前擦除次数越多,该存储块的存储寿命系数就越大,由此,存储寿命系数越大表明存储块的可用寿命越短。In this embodiment, an update manner is adopted in which the memory block is erased once, and the current erasure count is increased by 1. Since the number of erasures affects the service life of the memory block, the upper limit of the erasure number of each memory block is a fixed value. The more the current erasure times, the larger the storage life coefficient of the memory block. Thus, the larger the storage life coefficient indicates that the usable life of the memory block is shorter.
子步骤S157,遍历所述分配列表,将所述存储寿命系数大于热区阈值的存储块加入热区列表,并基于所述存储寿命系数对所述热区列表中的存储块进行排序。Sub-step S157, traversing the allocation list, adding the storage block whose storage life coefficient is greater than the hot zone threshold to the hot zone list, and sorting the storage blocks in the hot zone list based on the storage life coefficient.
在本实施例中,所述控制单元111遍历所述分配列表,将存储寿命系数大于热区阈值的存储块加入热区列表,并按照存储寿命系数从高到低的顺序对存储块进行排序。当然,还可以按照存储寿命系数从低到高的顺序对存储块进行排序。In this embodiment, the control unit 111 traverses the allocation list, adds a storage block whose storage lifetime coefficient is greater than the hot zone threshold to the hot zone list, and sorts the storage blocks according to the storage life coefficient from high to low. Of course, the memory blocks can also be sorted in order of storage life factor from low to high.
子步骤S1570,根据热区分配策略对经过排序的所述热区列表中的存储块进行热区回收分配处理。热区列表中的存储块的存储寿命系数大于热区阈值,擦除次数接近于其可用总擦除次数,热区回收分配处理的目的在于将热区列表中的存储块(可简称为热区存储块)快速更新到平衡区。Sub-step S1570, performing hot zone collection and distribution processing on the stored blocks in the sorted hot zone list according to the hot zone allocation policy. The storage life coefficient of the storage block in the hot zone list is greater than the hot zone threshold, and the number of erasures is close to the total number of erasures available. The purpose of the hot zone recovery allocation process is to store the block in the hot zone list (which may be simply referred to as a hot zone). Memory block) Quickly update to the balance area.
子步骤S158,将所述存储寿命系数小于冷区阈值的存储块加入冷区列表,并基于所述存储寿命系数对所述冷区列表中的存储块进行排序。可以理解的是,子步骤S157中提及的热区阈值高于子步骤S158中提及的冷区阈值。Sub-step S158, adding the storage block whose storage life coefficient is smaller than the cold zone threshold to the cold zone list, and sorting the storage blocks in the cold zone list based on the storage life coefficient. It can be understood that the hot zone threshold mentioned in sub-step S157 is higher than the cold zone threshold mentioned in sub-step S158.
在本实施例中,所述控制单元111将存储寿命系数小于冷区阈值的存储块加入冷区列表,并按照存储寿命系数从低到高的顺序对存储块进行排序。当然,还可以按照存储寿命系数从高到低的顺序对存储块进行排序。In this embodiment, the control unit 111 adds a storage block whose storage life coefficient is smaller than the cold zone threshold to the cold zone list, and sorts the storage blocks in order of storage life coefficient from low to high. Of course, the memory blocks can also be sorted in descending order of the storage life factor.
子步骤S1580,根据冷区分配策略对经过排序的所述冷区列表中的存储块进行冷区回收分配处理。冷区列表中的存储块的存储寿命系数小于冷区阈值,擦除次数远小于其可用总擦除次数,冷区回收分配处理的目的在于将冷区列表中的存储块(可简称为冷区存储块)快速更新到平衡区。Sub-step S1580, performing cold zone collection and distribution processing on the stored blocks in the sorted cold zone list according to the cold zone allocation policy. The storage life coefficient of the storage block in the cold zone list is smaller than the cold zone threshold, and the number of erasures is much smaller than the total number of erasures available. The purpose of the cold zone recovery allocation process is to store the block in the cold zone list (which may be simply referred to as a cold zone). Memory block) Quickly update to the balance area.
子步骤S159,将所述存储寿命系数位于所述热区阈值与所述冷区阈值之间的存储块加入平衡区列 表,并基于所述擦除次数对所述平衡区列表中的存储块进行排序。Sub-step S159, adding a storage block whose storage life coefficient is between the hot zone threshold and the cold zone threshold to the balance zone list, and performing, on the storage block in the balance zone list, based on the number of erasures. Sort.
在本实施例中,所述控制单元111存储寿命系数位于所述热区阈值与所述冷区阈值之间的存储块加入平衡区列表,并按照所述擦除次数从高到低的顺序对所述平衡区列表中的存储块进行排序。除此之外,也可按照存储寿命系数从高到低的顺序进行排序。In this embodiment, the control unit 111 stores a storage block with a life coefficient between the hot zone threshold and the cold zone threshold to join the balance zone list, and in the order of the number of erasures from high to low. The storage blocks in the balance area list are sorted. In addition to this, sorting can be performed in descending order of storage life factor.
子步骤S1590,根据平衡区分配策略对经过排序的所述平衡区列表中的存储块进行平衡区回收分配处理。平衡区列表中的存储块的存储寿命系数位于热区阈值与冷区阈值之间,擦除次数接近于平均擦除次数。平衡区回收分配处理的目的在于:在热区分配和冷区分配之后,利用剩余的可分配资源尽量均衡的进行存储块分配。在本实施例中,除上述步骤之外,所述控制单元111还可定期对每个存储块的当前擦除次数进行统计,并计算得到平均擦除次数,对每个存储块的存储寿命系数进行统计,并计算得到平均存储寿命系数。Sub-step S1590, performing a balance area recovery allocation process on the stored blocks in the sorted balance area list according to the balance area allocation policy. The storage life factor of the storage block in the balance area list is between the hot zone threshold and the cold zone threshold, and the number of erasures is close to the average number of erasures. The purpose of the balance area recovery allocation process is to perform storage block allocation as evenly as possible after the hot zone allocation and the cold zone allocation using the remaining allocatable resources. In this embodiment, in addition to the above steps, the control unit 111 may also periodically count the current number of erasures of each memory block, and calculate the average number of erasures, and the storage life coefficient of each memory block. Statistics are performed and the average storage life factor is calculated.
上述子步骤S157至子步骤S159,即为根据所述分配列表中每个存储块的存储寿命系数,将每个所述存储块加入至热区列表、冷区列表或平衡区列表的一种具体实施方式。Sub-step S157 to sub-step S159, that is, a specific method of adding each of the storage blocks to the hot zone list, the cold zone list, or the balance zone list according to the storage life coefficient of each storage block in the allocation list. Implementation.
在本实施例中,所述控制单元111可基于当前擦除次数及存储寿命系数定期进行方差计算,并根据方差结果对擦除次数和/或使用寿命的离散程度进行评估。例如,可根据方差结果的离散程度设定热区阈值及冷区阈值。所述控制单元111可定义两个离散阈值(比如,R1,R2,R1>R2)。如果方差结果的离散程度小于R2,可使用默认的热区阈值和冷区阈值;如果方差结果的离散程度大于R1,或者离散程度在R1与R2之内,但离散程度有继续变大趋势,所述控制单元111可对热区阈值和冷区阈值记性动态调整,以增大热区范围和冷区范围。In this embodiment, the control unit 111 may periodically perform variance calculation based on the current number of erasures and the storage life coefficient, and evaluate the degree of dispersion of the number of erasures and/or the service life based on the variance result. For example, the hot zone threshold and the cold zone threshold can be set based on the degree of dispersion of the variance results. The control unit 111 can define two discrete thresholds (eg, R1, R2, R1 > R2). If the dispersion result is less than R2, the default hot zone threshold and cold zone threshold may be used; if the variance result is more discrete than R1, or the degree of dispersion is within R1 and R2, the degree of dispersion continues to increase. The control unit 111 can dynamically adjust the hot zone threshold and the cold zone threshold to increase the hot zone range and the cold zone range.
请参照图7,图7是本申请实施例提供的图3所示的步骤S150的子步骤流程图之二。在子步骤S157之前,所述步骤S150还可包括子步骤S1500。其中,所述子步骤S1500只需保证在子步骤S157之前执行即可,例如,所述子步骤S1500也可在子步骤S151之前执行。Please refer to FIG. 7. FIG. 7 is a second flowchart of the sub-steps of step S150 shown in FIG. 3 according to an embodiment of the present application. Step S150 may further include sub-step S1500 before sub-step S157. The sub-step S1500 only needs to be guaranteed to be executed before the sub-step S157. For example, the sub-step S1500 can also be performed before the sub-step S151.
子步骤S1500,对复写通道列表进行更新,将每个存储通道的分配计数设置为该存储通道的可复写存储块数目。Sub-step S1500, updating the list of duplicate channels, setting the allocation count of each storage channel to the number of rewritable memory blocks of the storage channel.
在本实施例中,所述控制单元111对复写通道列表进行更新,遍历经过更新的所述复写通道列表,更新计算表中每个存储通道的可复写存储块数目,并将每个存储通道的分配计数设置为该存储通道的可复写存储块数目,将该存储通道标记为待处理状态。In this embodiment, the control unit 111 updates the list of duplicate write channels, traverses the updated list of duplicate write channels, updates the number of rewritable memory blocks of each storage channel in the calculation table, and each storage channel The allocation count is set to the number of rewritable memory blocks of the memory channel, marking the memory channel as pending.
基于上述对子步骤S1500的描述,下面对子步骤S1570、子步骤S1580及子步骤S1590进行说明。Based on the above description of sub-step S1500, sub-step S1570, sub-step S1580, and sub-step S1590 are described below.
请参照图8,图8是本申请实施例提供的图6所示的子步骤S1570的子步骤流程图,详细说明了一种热区分配流程,该流程即为热区分配策略的体现。所述子步骤S1570包括子步骤S1571、子步骤S1572、子步骤S1573及步骤S1574。Please refer to FIG. 8. FIG. 8 is a flowchart of a sub-step of the sub-step S1570 shown in FIG. 6 according to the embodiment of the present application, and details a hot zone allocation process, which is an embodiment of a hot zone allocation strategy. The sub-step S1570 includes sub-step S1571, sub-step S1572, sub-step S1573, and step S1574.
子步骤S1571,从所述热区列表的表头获取一个热区存储块。在本实施例中,由于所述热区列表是按照存储寿命系数从高到低的顺序进行排序的,所述控制单元111从所述热区列表的表头依次获取热区存储块,即按照存储寿命系数从大到小的顺序获取待处理的存储块。Sub-step S1571, obtaining a hot zone storage block from the header of the hot zone list. In this embodiment, since the hot zone list is sorted according to the storage life coefficient from high to low, the control unit 111 sequentially obtains the hot zone storage block from the header of the hot zone list, that is, according to The storage block to be processed is obtained in order of storage life coefficient from large to small.
子步骤S1572,检测所述热区存储块是否已处理。Sub-step S1572, detecting whether the hot zone storage block has been processed.
在本实施例中,所述控制单元111检测所述热区存储块是否已处理的方式可以包括,但不限于:检测所述热区存储块的当前分配通道号字段中是否存在有效通道号,若存在,可判定所述热区存储块已处 理,反之则未处理;或者检测所述热区存储块的编号是否记录在已处理列表中,若已记录,可判定所述热区存储块已处理,反之则未处理。其中,所述有效通道号是指存储通道的通道号。In this embodiment, the manner in which the control unit 111 detects whether the hot zone storage block has been processed may include, but is not limited to, detecting whether a valid channel number exists in a current allocation channel number field of the hot zone storage block. If yes, it may be determined that the hot zone storage block has been processed, otherwise it is not processed; or whether the number of the hot zone storage block is recorded in the processed list, and if it is recorded, it may be determined that the hot zone storage block has been Processing, otherwise it is not processed. The valid channel number refers to the channel number of the storage channel.
子步骤S1573,当未处理时,从所述复写通道列表的表头开始遍历所述复写通道列表,选择一个分配计数大于零的存储通道,将所述存储通道的通道号写入所述热区存储块的当前分配通道号字段中,并更新所述分配计数。然后还可以将该存储通道标记为已处理。在实际应用中,更新分配计数的方式可以为分配计数减一。Sub-step S1573, when not processing, traversing the list of duplicate write channels starting from the header of the list of duplicate write channels, selecting a storage channel whose allocation count is greater than zero, and writing the channel number of the storage channel to the hot zone The current allocation channel number field of the storage block is updated and the allocation count is updated. The storage channel can then also be marked as processed. In practical applications, the way to update the allocation count can be one less than the allocation count.
在本实施例中,由于所述复写通道列表是按照复写周期从大到小进行排序的,所述控制单元111从所述复写通道列表的表头顺序选择分配计数大于零的存储通道,即按照复写周期从大到小的顺序获取存储通道。由此,所述控制单元111可将存储寿命系数大的存储块优先分配给复写周期长的存储通道,可使该存储块不被频繁擦除,延长该存储块的使用寿命。In this embodiment, since the list of duplicate write channels is sorted according to a rewrite period from large to small, the control unit 111 sequentially selects a storage channel whose allocation count is greater than zero from the header of the list of duplicate write channels, that is, according to The storage channels are obtained in descending order of the replication cycle. Therefore, the control unit 111 can preferentially allocate the storage block with a large storage life coefficient to the storage channel with a long replication period, so that the storage block can be not frequently erased, and the service life of the storage block is extended.
子步骤S1574,将所述热区存储块加入所述存储通道对应的可用存储块队列中。Sub-step S1574, the hot zone storage block is added to the available storage block queue corresponding to the storage channel.
在本实施例中,所述控制单元111在完成一个热区存储块处理后,可检测所述热区列表中是否还存在未处理的热区存储块,若不存在,则确定热区列表中的热区存储块均已进行热区回收分配处理;若存在,则返回至子步骤S1571;也即,所述控制单元111重复执行上述子步骤S1571-子步骤S1574,直至所述热区列表中的热区存储块均处理完毕为止。In this embodiment, after completing a hot zone storage block process, the control unit 111 may detect whether there is still an unprocessed hot zone storage block in the hot zone list, and if not, determine the hot zone list. The hot zone storage blocks have been subjected to the hot zone recovery allocation process; if yes, return to sub-step S1571; that is, the control unit 111 repeatedly performs the above sub-step S1571 - sub-step S1574 until the hot zone list The hot zone storage blocks are processed.
请参照图9,图9是本申请实施例提供的图6所示的子步骤S1580的子步骤流程图,详细说明了一种冷区分配流程,该流程即为冷区分配策略的体现。其中,所述子步骤S1580包括子步骤S1581、子步骤S1582、子步骤S1583及步骤S1584。Please refer to FIG. 9. FIG. 9 is a flow chart of the sub-steps of the sub-step S1580 shown in FIG. 6 according to the embodiment of the present application, and details a cold zone allocation process, which is an embodiment of the cold zone allocation strategy. The sub-step S1580 includes sub-step S1581, sub-step S1582, sub-step S1583, and step S1584.
子步骤S1581,从所述冷区列表的表头获取一个冷区存储块。Sub-step S1581, obtaining a cold zone storage block from the header of the cold zone list.
在本实施例中,由于所述冷区列表是按照存储寿命系数从低到高的顺序进行排序的,所述控制单元111从所述冷区列表的表头依次获取冷区存储块,即按照存储寿命系数从小到大的顺序获取待处理的存储块。In this embodiment, since the cold zone list is sorted according to the storage life coefficient from low to high, the control unit 111 sequentially acquires the cold zone storage block from the header of the cold zone list, that is, according to The storage blocks whose storage life coefficients are small to large are acquired.
子步骤S1582,检测所述冷区存储块是否已处理。Sub-step S1582, detecting whether the cold zone storage block has been processed.
在本实施例中,所述控制单元111检测所述冷区存储块是否已处理的方式与上述检测热区存储块的方式相似,在此不在赘述。In this embodiment, the manner in which the control unit 111 detects whether the cold zone storage block has been processed is similar to the manner in which the hot zone storage block is detected, and details are not described herein.
子步骤S1583,当未处理时,从所述复写通道列表的表尾开始遍历所述复写通道列表,选择一个分配计数大于零的存储通道,将所述存储通道的通道号写入所述冷区存储块的当前分配通道号字段中,并更新所述分配计数(诸如,将分配计数减一),将所述冷区存储块标记为已处理。Sub-step S1583, when unprocessed, traversing the list of duplicate write channels starting from the end of the list of duplicate write channels, selecting a storage channel whose allocation count is greater than zero, and writing the channel number of the storage channel to the cold zone The currently allocated channel number field of the memory block is updated, and the allocation count is updated (such as decrementing the allocation count by one), and the cold zone storage block is marked as processed.
在本实施例中,所述控制单元111从所述复写通道列表的表尾选择分配计数大于零的存储通道,即按照复写周期从小到大的顺序获取存储通道。由此,所述控制单元111可将存储寿命系数小的存储块优先分配给复写周期短的存储通道,即将使用寿命长的存储块优先分配给频繁进行复写的存储通道使用。In this embodiment, the control unit 111 selects a storage channel whose allocation count is greater than zero from the end of the list of the duplicate write channels, that is, acquires the storage channels in descending order of the rewrite period. Therefore, the control unit 111 can preferentially allocate a storage block with a small storage life coefficient to a storage channel with a short replication cycle, that is, preferentially allocate a storage block with a long service life to a storage channel that frequently performs overwriting.
子步骤S1584,将所述冷区存储块加入所述存储通道对应的可用存储块队列中。Sub-step S1584, adding the cold zone storage block to the available storage block queue corresponding to the storage channel.
在本实施例中,所述控制单元111在完成一个冷区存储块处理后,可检测所述冷区列表中是否还存在未处理的冷区存储块,若存在,所述控制单元111重复执行上述子步骤S1581-子步骤S1584,直至所述冷区列表中的冷区存储块均处理完毕为止。In this embodiment, after completing a cold zone storage block process, the control unit 111 may detect whether there is still an unprocessed cold zone storage block in the cold zone list, and if so, the control unit 111 repeatedly executes. Sub-step S1581 - sub-step S1584, until the cold zone storage blocks in the cold zone list are all processed.
请参照图10,图10是本申请实施例提供的图6所示的子步骤S1590的子步骤流程图,详细说明了 一种平衡区分配流程,该流程即为平衡区分配策略的体现。所述子步骤S1590包括子步骤S1591、子步骤S1592、子步骤S1593及步骤S1594。Referring to FIG. 10, FIG. 10 is a flowchart of a sub-step of the sub-step S1590 shown in FIG. 6 according to an embodiment of the present application, and details a balancing area allocation process, which is an embodiment of a balanced area allocation strategy. The sub-step S1590 includes sub-step S1591, sub-step S1592, sub-step S1593, and step S1594.
子步骤S1591,从所述复写通道列表的表头获取一个分配计数不为零的存储通道。诸如,可以从复写通道列表的表头顺序获取分配计数不为零的一个存储通道作为待处理通道。Sub-step S1591, obtaining a storage channel whose allocation count is not zero from the header of the duplicate channel list. For example, a memory channel whose allocation count is not zero can be obtained as a pending channel from the header order of the copy channel list.
子步骤S1592,从所述平衡区列表的表头开始遍历所述平衡区列表,依次获取数目等于所述存储通道的分配计数的平衡区存储块。Sub-step S1592, traversing the balance area list from the header of the balance area list, and sequentially acquiring a balance area storage block having a number equal to the allocation count of the storage channel.
子步骤S1593,将所述存储通道的通道号写入获取的所述平衡区存储块的当前分配通道号中,并将所述平衡区存储块标记为已处理,将所述存储通道的分配计数置零。Sub-step S1593, writing the channel number of the storage channel into the acquired current allocation channel number of the balance area storage block, and marking the balance area storage block as processed, and counting the allocation of the storage channel Zero.
子步骤S1594,将所述平衡区存储块加入所述存储通道对应的可用存储块队列中。Sub-step S1594, adding the balance area storage block to the available storage block queue corresponding to the storage channel.
如果复写通道列表中还有分配计数不为零的存储通道,则返回执行步骤子步骤S1591,反之则结束流程。If there is a storage channel in the duplicate channel list whose allocation count is not zero, the execution returns to step S1591, otherwise the flow ends.
在本实施例中,所述平衡区存储块的分配无需像热区存储块、冷区存储块一样按照存储寿命系数进行精细分配,所述平衡区存储块只要根据存储通道需求进行批量分配即可。In this embodiment, the allocation of the balance area storage block does not need to be finely distributed according to the storage life coefficient like the hot area storage block and the cold area storage block, and the balance area storage block can be batch-distributed according to the storage channel requirement. .
在本实施例中,本方案采用Open Channel SSD架构,用户可自行设计固态硬盘110的FTL,使固态硬盘110的垃圾回收算法和磨损均衡算法满足自身实际需求。本方案根据存储寿命系数将固态硬盘110的存储块划分为热区存储块、冷区存储块和平衡区存储块,不同区的存储块有对应的回收分配策略。可有效保证存储空间中所有存储块的擦除次数的均衡,提升固态硬盘110的整体使用寿命,提升数据读写效率。In this embodiment, the scheme adopts the Open Channel SSD architecture, and the user can design the FTL of the solid state hard disk 110 by itself, so that the garbage collection algorithm and the wear leveling algorithm of the solid state hard disk 110 meet their actual needs. According to the storage life factor, the storage block of the solid state hard disk 110 is divided into a hot zone storage block, a cold zone storage block and a balance zone storage block, and the storage blocks of different zones have a corresponding recycling allocation strategy. It can effectively ensure the equalization of the erasure times of all the storage blocks in the storage space, improve the overall service life of the solid state hard disk 110, and improve the data reading and writing efficiency.
进一步,本实施例提供了一种存储管理装置,该存储管理装置可以设置于固态硬盘侧,参见图11所示的一种存储管理装置的结构框图之一,所述装置包括:Further, the embodiment provides a storage management device, which may be disposed on the SSD side. Referring to one of the structural block diagrams of the storage management device shown in FIG. 11, the device includes:
数据写入模块1101,配置成当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中;The data writing module 1101 is configured to: when it is detected that data to be input to the storage channel is to be stored, obtain an available storage block, and write the incoming data into the available storage block;
第一检测模块1102,配置成当数据写入完成时,检测存储空间状态标识是否为非复写状态;The first detecting module 1102 is configured to detect, when the data writing is completed, whether the storage space status identifier is in a non-overwritten state;
第二检测模块1103,配置成在为非复写状态时,检测存储空间是否达到写满状态;The second detecting module 1103 is configured to detect whether the storage space reaches a full state when in a non-overwrite state;
回收分配模块1104,配置成当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。The recycling distribution module 1104 is configured to switch the storage space state identifier to a replication state when the storage space reaches a full state, and start a timer according to a storage life coefficient of each storage block in the storage space and a storage block. The life balance strategy periodically performs storage space reclamation allocation processing.
在一些实施方式中,所述装置还可以包括如下模块:In some embodiments, the apparatus may further include the following modules:
存储块划分模块,配置成将存储空间划分为多个存储块;a storage block dividing module configured to divide the storage space into a plurality of storage blocks;
状态设置模块,配置成对存储空间状态标识进行初始化定义,将所述存储空间状态标识设置为非复写状态;a state setting module configured to initialize an initialization of the storage space state identifier, and set the storage space state identifier to a non-overwrite state;
存储块添加模块,配置成为每个存储通道初始化配置一个可用存储块队列,并在每个可用存储块队列中添加可用存储块;The storage block adds a module, configured to initialize one storage block queue for each storage channel initialization, and add available storage blocks in each available storage block queue;
通道排序模块,配置成将每个存储通道加入复写通道列表,并按照复写周期从大到小进行排序;The channel sorting module is configured to add each storage channel to the list of duplicate channels, and sort according to a rewriting period from large to small;
数目记录模块,配置成计算所述复写通道列表中每个存储通道的可复写存储块数目,并将所述可复写存储块数目对应记录到所述复写通道列表中。The number recording module is configured to calculate a number of rewritable memory blocks of each of the memory channels in the list of duplicate write channels, and record the number of the rewritable memory blocks correspondingly into the list of duplicate write channels.
在具体实施时,所述数据写入模块配置成:In a specific implementation, the data writing module is configured to:
当检测到所述存储通道对应的所述可用存储块队列中有可用存储块时,从所述可用存储块队列中获取预设数量的可用存储块,并将数据写入所述可用存储块中;When a storage block is available in the available storage block queue corresponding to the storage channel, a preset number of available storage blocks are obtained from the available storage block queue, and data is written into the available storage block. ;
当检测到所述可用存储块写满时,将所述可用存储块从所述可用存储块队列中出队;Determining the available memory block from the available memory block queue when it is detected that the available memory block is full;
检测数据写入操作是否完成;Check if the data write operation is completed;
当数据写入未完成时,对所述存储空间状态标识的当前状态进行检测;When the data writing is not completed, detecting the current state of the storage space status identifier;
当所述当前状态为非复写状态时,从存储空间中获取处于空闲状态的存储块加入所述可用存储块队列,并从所述可用存储块队列中获取新的可用存储块进行数据写入;When the current state is a non-overwrite state, the storage block that is in the idle state is acquired from the storage space to join the available storage block queue, and a new available storage block is obtained from the available storage block queue for data writing;
当所述当前状态为复写状态时,从所述可用存储块队列中获取新的可用存储块进行数据写入。When the current state is a replication state, a new available memory block is obtained from the available memory block queue for data writing.
在一些实施方式中,所述寿命平衡策略包括:热区分配策略、冷区分配策略及平衡区分配策略,所述回收分配模块配置成:In some embodiments, the life balance strategy includes: a hot zone allocation strategy, a cold zone allocation policy, and a balance zone allocation policy, the recycling allocation module configured to:
将正在执行存储业务的存储通道加入待处理通道列表;Add the storage channel that is performing the storage service to the pending channel list.
从所述待处理通道列表中获取一个待处理通道,对所述待处理通道对应的存储块进行遍历,查找处于有效状态的存储块;Obtaining a to-be-processed channel from the to-be-processed channel list, traversing the storage block corresponding to the to-be-processed channel, and searching for a storage block in an active state;
在所述处于有效状态的存储块中,按照数据写入时间顺序获取数量为所述可复写存储块数目的存储块,将获取的所述存储块的状态设置为无效状态,并记录到回收列表;And storing, in the storage block in an active state, a storage block whose number is the number of the rewritable storage blocks according to a data write time sequence, setting the acquired state of the storage block to an invalid state, and recording to the collection list. ;
对记录在所述回收列表的存储块进行数据擦除处理,更新所述存储块的擦除次数,将所述存储块的状态更新为空闲状态,并将记录到分配列表;Performing data erasing processing on the storage blocks recorded in the collection list, updating the erasure times of the storage blocks, updating the status of the storage blocks to an idle state, and recording to the allocation list;
检测所述待处理通道列表中是否存在未处理的待处理通道;Detecting whether there is an unprocessed pending channel in the to-be-processed channel list;
当不存在时,根据所述分配列表中每个存储块的当前擦除次数和擦除次数上限计算每个存储块的存储寿命系数;When not present, calculating a storage life coefficient of each storage block according to a current erasure number and an upper erasing number upper limit of each storage block in the allocation list;
遍历所述分配列表,将所述存储寿命系数大于热区阈值的存储块加入热区列表,并基于所述存储寿命系数对所述热区列表中的存储块进行排序;Traversing the allocation list, adding the storage block whose storage lifetime coefficient is greater than the hot zone threshold to the hot zone list, and sorting the storage blocks in the hot zone list based on the storage life coefficient;
根据热区分配策略对经过排序的所述热区列表中的存储块进行热区回收分配处理;Performing hot zone collection and distribution processing on the storage blocks in the sorted hot zone list according to the hot zone allocation policy;
将所述存储寿命系数小于冷区阈值的存储块加入冷区列表,并基于所述存储寿命系数对所述冷区列表中的存储块进行排序;Adding the storage block whose storage life coefficient is smaller than the cold zone threshold to the cold zone list, and sorting the storage blocks in the cold zone list based on the storage life coefficient;
根据冷区分配策略对经过排序的所述冷区列表中的存储块进行冷区回收分配处理;Performing cold zone collection and distribution processing on the storage blocks in the sorted cold zone list according to the cold zone allocation policy;
将所述存储寿命系数位于所述热区阈值与所述冷区阈值之间的存储块加入平衡区列表,并基于所述擦除次数对所述平衡区列表中的存储块进行排序;And storing a storage block whose storage life coefficient is between the hot zone threshold and the cold zone threshold into a balance zone list, and sorting the storage blocks in the balance zone list based on the number of erasures;
根据平衡区分配策略对经过排序的所述平衡区列表中的存储块进行平衡区回收分配处理。The balanced area recovery allocation process is performed on the stored blocks in the sorted balance area list according to the balance area allocation policy.
本实施例所提供的装置,其实现原理及产生的技术效果和前述实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。The implementation principle and the technical effects of the device provided in this embodiment are the same as those in the foregoing embodiment. For the sake of brief description, where the device embodiment is not mentioned, reference may be made to the corresponding content in the foregoing method embodiment.
综上所述,本申请实施例提供一种存储管理方法、装置、固态硬盘及可读存储介质。所述方法包括:当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入数据写入所述可用存储块中。当数据写入完成时,检测存储空间状态标识是否为非复写状态。在为非复写状态时,检测存储空间是否达到写满状态。当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启 动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。由此,通过根据存储寿命将固态硬盘的存储块划分为热区存储块、冷区存储块和平衡区存储块,不同区的存储块有对应的回收分配策略。可均衡存储空间中存储块的擦除次数,提升固态硬盘的整体使用寿命,提升数据读写效率。In summary, the embodiments of the present application provide a storage management method, an apparatus, a solid state hard disk, and a readable storage medium. The method includes, when it is detected that data incoming to the storage channel needs to be stored, obtaining an available storage block and writing the incoming data to the available storage block. When the data writing is completed, it is detected whether the storage space status flag is non-overwritten. When it is in the non-overwrite state, it detects whether the storage space has reached the full state. When the storage space reaches the full state, the storage space state identifier is switched to a replication state, and a timer is started, and the storage space is periodically timed according to the storage life coefficient of each storage block in the storage space and the life balance balancing strategy of the storage block. Recycling distribution processing. Thus, by dividing the storage blocks of the solid state hard disk into hot zone storage blocks, cold zone storage blocks, and balance zone storage blocks according to the storage life, the storage blocks of different zones have corresponding recycling allocation policies. It can balance the number of erasures of memory blocks in the storage space, improve the overall life of the solid state drive, and improve data read and write efficiency.
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above description is only the preferred embodiment of the present application, and is not intended to limit the present application, and various changes and modifications may be made to the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this application are intended to be included within the scope of the present application.
工业实用性:Industrial applicability:
通过应用本申请的技术方案,可对存储空间中的存储块进行均衡擦除,提升固态硬盘的整体使用寿命,提升数据读写效率。By applying the technical solution of the present application, the storage blocks in the storage space can be uniformly erased, the overall service life of the solid state hard disk is improved, and the data reading and writing efficiency is improved.

Claims (19)

  1. 一种存储管理方法,其特征在于,所述方法包括:A storage management method, the method comprising:
    当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中;When it is detected that the data incoming by the storage channel needs to be stored, the available storage block is obtained, and the incoming data is written into the available storage block;
    当数据写入完成时,检测存储空间状态标识是否为非复写状态;When the data writing is completed, detecting whether the storage space status identifier is a non-overwrite status;
    在为非复写状态时,检测存储空间是否达到写满状态;When it is in the non-overwrite state, it is detected whether the storage space reaches the full state;
    当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。When the storage space reaches the full state, the storage space state identifier is switched to a replication state, and a timer is started, and the storage space is periodically timed according to the storage life coefficient of each storage block in the storage space and the life balance balancing strategy of the storage block. Recycling distribution processing.
  2. 根据权利要求1所述的方法,其特征在于,在所述获取可用存储块,并将传入的数据写入所述可用存储块中之前,所述方法还包括:The method of claim 1, wherein before the obtaining the available memory block and writing the incoming data to the available memory block, the method further comprises:
    将存储空间划分为多个存储块;Divide storage space into multiple storage blocks;
    对存储空间状态标识进行初始化定义,将所述存储空间状态标识设置为非复写状态;Initializing a storage space status identifier, and setting the storage space status identifier to a non-overwrite status;
    为每个存储通道初始化配置一个可用存储块队列,并在每个可用存储块队列中添加可用存储块;Configure an available block queue for each storage channel initialization and add available blocks to each available block queue;
    将每个存储通道加入复写通道列表,并按照复写周期从大到小进行排序;Add each storage channel to the list of replication channels and sort them from large to small according to the replication cycle;
    计算所述复写通道列表中每个存储通道的可复写存储块数目,并将所述可复写存储块数目对应记录到所述复写通道列表中。Calculating a number of rewritable memory blocks of each memory channel in the list of duplicate write channels, and recording the number of rewritable memory blocks correspondingly into the list of duplicate write channels.
  3. 根据权利要求2所述的方法,其特征在于,所述获取可用存储块,并将传入的数据写入所述可用存储块中,包括:The method of claim 2, wherein the obtaining an available storage block and writing the incoming data to the available storage block comprises:
    当检测到所述存储通道对应的所述可用存储块队列中有可用存储块时,从所述可用存储块队列中获取预设数量的可用存储块,并将数据写入所述可用存储块中;When a storage block is available in the available storage block queue corresponding to the storage channel, a preset number of available storage blocks are obtained from the available storage block queue, and data is written into the available storage block. ;
    当检测到所述可用存储块写满时,将所述可用存储块从所述可用存储块队列中出队;Determining the available memory block from the available memory block queue when it is detected that the available memory block is full;
    检测数据写入操作是否完成;Check if the data write operation is completed;
    当数据写入未完成时,对所述存储空间状态标识的当前状态进行检测;When the data writing is not completed, detecting the current state of the storage space status identifier;
    当所述当前状态为非复写状态时,从存储空间中获取处于空闲状态的存储块加入所述可用存储块队列,并从所述可用存储块队列中获取新的可用存储块进行数据写入;When the current state is a non-overwrite state, the storage block that is in the idle state is acquired from the storage space to join the available storage block queue, and a new available storage block is obtained from the available storage block queue for data writing;
    当所述当前状态为复写状态时,从所述可用存储块队列中获取新的可用存储块进行数据写入。When the current state is a replication state, a new available memory block is obtained from the available memory block queue for data writing.
  4. 根据权利要求1所述的方法,其特征在于,所述检测存储空间是否达到写满状态,包括:The method according to claim 1, wherein the detecting whether the storage space reaches a full state comprises:
    检测存储空间中当前被数据占用的存储块数量是否超过存储满状态阈值;如果是,确定存储空间达到写满状态;Detecting whether the number of memory blocks currently occupied by the data in the storage space exceeds a storage full state threshold; if yes, determining that the storage space is full;
    或者,检测存储空间中当前处于空闲状态的存储块的数量是否低于存储下限阈值;如果是,确定存储空间达到写满状态。Alternatively, it is detected whether the number of memory blocks currently in the idle state in the storage space is lower than the storage lower threshold; if so, it is determined that the storage space reaches the full state.
  5. 根据权利要求2或3任意一项所述的方法,其特征在于,所述寿命平衡策略包括:热区分配策略、冷区分配策略及平衡区分配策略,所述根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理,包括:The method according to any one of claims 2 or 3, wherein the life balance strategy comprises: a hot zone allocation strategy, a cold zone allocation strategy, and a balance zone allocation policy, according to each storage block in the storage space. The storage life factor and the life balance strategy of the storage block are periodically scheduled to perform storage space collection and distribution processing, including:
    将无效状态的存储块记录在回收列表;Recording the invalid storage block in the recycle list;
    对记录在所述回收列表的存储块进行数据擦除处理,更新所述存储块的擦除次数,将所述存储块的状态更新为空闲状态,并将记录到分配列表;Performing data erasing processing on the storage blocks recorded in the collection list, updating the erasure times of the storage blocks, updating the status of the storage blocks to an idle state, and recording to the allocation list;
    检测待处理通道列表中是否存在未处理的待处理通道;Check whether there are unprocessed pending channels in the pending channel list.
    当不存在时,根据所述分配列表中每个存储块的当前擦除次数和擦除次数上限计算每个存储块的存储寿命系数;When not present, calculating a storage life coefficient of each storage block according to a current erasure number and an upper erasing number upper limit of each storage block in the allocation list;
    遍历所述分配列表,根据所述分配列表中每个存储块的存储寿命系数,将每个所述存储块加入至热区列表、冷区列表或平衡区列表;其中,所述热区列表中的存储块的存储寿命系数大于热区阈值;所述冷区列表中的存储块的存储寿命系数小于冷区阈值;所述平衡区列表中的存储块的存储寿命系数位于所述热区阈值与所述冷区阈值之间;Traversing the allocation list, adding each of the storage blocks to a hot zone list, a cold zone list, or a balance zone list according to a storage life coefficient of each storage block in the allocation list; wherein, in the hot zone list The storage life coefficient of the storage block is greater than the hot zone threshold; the storage life coefficient of the storage block in the cold zone list is smaller than the cold zone threshold; the storage lifetime coefficient of the storage block in the balance zone list is located in the hot zone threshold and Between the cold zone thresholds;
    根据热区分配策略对所述热区列表中的存储块进行热区回收分配处理;根据冷区分配策略对所述冷区列表中的存储块进行冷区回收分配处理;And performing hot zone collection and distribution processing on the storage blocks in the hot zone list according to the hot zone allocation policy; performing cold zone collection and distribution processing on the storage blocks in the cold zone list according to the cold zone allocation policy;
    根据平衡区分配策略对所述平衡区列表中的存储块进行平衡区回收分配处理。The balance area recovery allocation process is performed on the storage blocks in the balance area list according to the balance area allocation policy.
  6. 根据权利要求5所述的方法,其特征在于,所述将无效状态的存储块记录在回收列表,包括:The method according to claim 5, wherein the recording the invalid state storage block in the collection list comprises:
    将正在执行存储业务的存储通道加入待处理通道列表;Add the storage channel that is performing the storage service to the pending channel list.
    从所述待处理通道列表中获取一个待处理通道,对所述待处理通道对应的存储块进行遍历,查找处于有效状态的存储块;Obtaining a to-be-processed channel from the to-be-processed channel list, traversing the storage block corresponding to the to-be-processed channel, and searching for a storage block in an active state;
    在所述处于有效状态的存储块中,按照数据写入时间顺序获取数量为所述可复写存储块数目的存储块,将获取的所述存储块的状态设置为无效状态,并记录到回收列表。And storing, in the storage block in an active state, a storage block whose number is the number of the rewritable storage blocks according to a data write time sequence, setting the acquired state of the storage block to an invalid state, and recording to the collection list. .
  7. 根据权利要求5所述的方法,其特征在于,所述根据所述分配列表中每个存储块的存储寿命系数,将每个所述存储块加入至热区列表、冷区列表或平衡区列表,包括:The method according to claim 5, wherein said adding said said storage block to a hot zone list, a cold zone list or a balance zone list according to a storage life coefficient of each of said storage blocks in said allocation list ,include:
    将所述存储寿命系数大于热区阈值的存储块加入热区列表,并基于所述存储寿命系数对所述热区列表中的存储块进行排序;Adding the storage block whose storage life coefficient is greater than the hot zone threshold to the hot zone list, and sorting the storage blocks in the hot zone list based on the storage life coefficient;
    将所述存储寿命系数小于冷区阈值的存储块加入冷区列表,并基于所述存储寿命系数对所述冷区列表中的存储块进行排序;Adding the storage block whose storage life coefficient is smaller than the cold zone threshold to the cold zone list, and sorting the storage blocks in the cold zone list based on the storage life coefficient;
    将所述存储寿命系数位于所述热区阈值与所述冷区阈值之间的存储块加入平衡区列表,并基于所述擦除次数对所述平衡区列表中的存储块进行排序。And storing a storage block whose storage life coefficient is between the hot zone threshold and the cold zone threshold into a balance zone list, and sorting the storage blocks in the balance zone list based on the number of erasures.
  8. 根据权利要求6所述的方法,其特征在于,所述将获取的所述存储块的状态设置为无效状态,包括:The method according to claim 6, wherein the setting the acquired state of the storage block to an invalid state comprises:
    检测获取的所述存储块中存储的数据的保存时长是否超出需存储时长;Detecting whether the saved duration of the data stored in the obtained storage block exceeds a required storage time;
    如果是,确定获取的所述存储块中存储的数据已失效,并将获取的所述存储块的状态设置为无效状态。If so, it is determined that the data stored in the acquired storage block has expired, and the acquired state of the storage block is set to an invalid state.
  9. 根据权利要求5所述的方法,其特征在于,在所述遍历所述分配列表之前,所述根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理,还包括:The method according to claim 5, wherein before the traversing the allocation list, the storage space recovery allocation processing is performed according to a storage life coefficient of each storage block in the storage space and a life balance policy timing of the storage block. ,Also includes:
    对复写通道列表进行更新,将每个存储通道的分配计数设置为该存储通道的可复写存储块数目。The list of duplicate channel is updated, and the allocation count of each storage channel is set to the number of rewritable memory blocks of the storage channel.
  10. 根据权利要求9所述的方法,其特征在于,所述根据热区分配策略对所述热区列表中的存储块进 行热区回收分配处理,包括:The method according to claim 9, wherein the performing hot zone collection and distribution processing on the storage blocks in the hot zone list according to the hot zone allocation policy comprises:
    从所述热区列表的表头获取一个热区存储块;Obtaining a hot zone storage block from a header of the hot zone list;
    检测所述热区存储块是否已处理;Detecting whether the hot zone storage block has been processed;
    当未处理时,从所述复写通道列表的表头开始遍历所述复写通道列表,选择一个分配计数大于零的存储通道,将所述存储通道的通道号写入所述热区存储块的当前分配通道号字段中,并更新所述分配计数;When not processed, traverse the list of duplicate write channels from the header of the list of duplicate write channels, select a storage channel whose allocation count is greater than zero, and write the channel number of the storage channel to the current storage block of the hot zone Assign a channel number field and update the allocation count;
    将所述热区存储块加入所述存储通道对应的可用存储块队列中。Adding the hot zone storage block to the available storage block queue corresponding to the storage channel.
  11. 根据权利要求10所述的方法,其特征在于,所述检测所述热区存储块是否已处理,包括:The method according to claim 10, wherein the detecting whether the hot zone storage block has been processed comprises:
    检测所述热区存储块的当前分配通道号字段中是否存在有效通道号,如果是,确定所述热区存储块已处理;Detecting whether a valid channel number exists in a current allocation channel number field of the hot zone storage block, and if so, determining that the hot zone storage block has been processed;
    或者,or,
    检测所述热区存储块的编号是否记录在已处理列表中,如果是,确定所述热区存储块已处理。It is detected whether the number of the hot zone storage block is recorded in the processed list, and if so, it is determined that the hot zone storage block has been processed.
  12. 根据权利要求9所述的方法,其特征在于,所述根据冷区分配策略对所述冷区列表中的存储块进行冷区回收分配处理,包括:The method according to claim 9, wherein the performing cold zone collection and distribution processing on the storage blocks in the cold zone list according to the cold zone allocation policy comprises:
    从所述冷区列表的表头获取一个冷区存储块;Obtaining a cold zone storage block from a header of the cold zone list;
    检测所述冷区存储块是否已处理;Detecting whether the cold zone storage block has been processed;
    当未处理时,从所述复写通道列表的表尾开始遍历所述复写通道列表,选择一个分配计数大于零的存储通道,将所述存储通道的通道号写入所述冷区存储块的当前分配通道号字段中,并更新所述分配计数,将所述冷区存储块标记为已处理;When not processed, traversing the list of duplicate write channels from the end of the list of duplicate write channels, selecting a storage channel whose allocation count is greater than zero, and writing the channel number of the storage channel to the current storage block of the cold storage block Allocating the channel number field, and updating the allocation count, marking the cold zone storage block as processed;
    将所述冷区存储块加入所述存储通道对应的可用存储块队列中。Adding the cold zone storage block to the available storage block queue corresponding to the storage channel.
  13. 根据权利要求9所述的方法,其特征在于,所述根据平衡区分配策略对所述平衡区列表中的存储块进行平衡区回收分配处理,包括:The method according to claim 9, wherein the balancing area allocation processing is performed on the storage blocks in the balance area list according to the balance area allocation policy, including:
    从所述复写通道列表的表头获取一个分配计数不为零的存储通道;Obtaining, from a header of the list of duplicate write channels, a storage channel whose allocation count is not zero;
    从所述平衡区列表的表头开始遍历所述平衡区列表,依次获取数目等于所述存储通道的分配计数的平衡区存储块;Traversing the balance area list from the header of the balance area list, and sequentially acquiring a balance area storage block equal to the allocation count of the storage channel;
    将所述存储通道的通道号写入获取的所述平衡区存储块的当前分配通道号中,并将所述平衡区存储块标记为已处理,将所述存储通道的分配计数置零;Writing a channel number of the storage channel into the acquired current allocation channel number of the balance area storage block, and marking the balance area storage block as processed, and setting the allocation count of the storage channel to zero;
    将所述平衡区存储块加入所述存储通道对应的可用存储块队列中。Adding the balance area storage block to the available storage block queue corresponding to the storage channel.
  14. 一种存储管理装置,其特征在于,所述装置包括:A storage management device, characterized in that the device comprises:
    数据写入模块,配置成当检测到需要对存储通道传入的数据进行存储时,获取可用存储块,并将传入的数据写入所述可用存储块中;a data writing module configured to: when detecting that data to be input to the storage channel is to be stored, obtain an available storage block, and write the incoming data into the available storage block;
    第一检测模块,配置成当数据写入完成时,检测存储空间状态标识是否为非复写状态;The first detecting module is configured to detect, when the data writing is completed, whether the storage space status identifier is in a non-overwritten state;
    第二检测模块,配置成在为非复写状态时,检测存储空间是否达到写满状态;a second detecting module configured to detect whether the storage space reaches a full state when the state is non-overwritten;
    回收分配模块,配置成当所述存储空间达到写满状态时,将所述存储空间状态标识切换为复写状态,并启动定时器,根据存储空间中各存储块的存储寿命系数及存储块的寿命平衡策略定时进行存储空间回收分配处理。Recycling the allocation module, configured to switch the storage space state identifier to a replication state when the storage space reaches a full state, and start a timer according to a storage life coefficient of each storage block in the storage space and a life of the storage block The balancing strategy periodically performs storage space reclamation allocation processing.
  15. 根据权利要求14所述的装置,其特征在于,所述装置还包括:The device according to claim 14, wherein the device further comprises:
    存储块划分模块,配置成将存储空间划分为多个存储块;a storage block dividing module configured to divide the storage space into a plurality of storage blocks;
    状态设置模块,配置成对存储空间状态标识进行初始化定义,将所述存储空间状态标识设置为非复写状态;a state setting module configured to initialize an initialization of the storage space state identifier, and set the storage space state identifier to a non-overwrite state;
    存储块添加模块,配置成为每个存储通道初始化配置一个可用存储块队列,并在每个可用存储块队列中添加可用存储块;The storage block adds a module, configured to initialize one storage block queue for each storage channel initialization, and add available storage blocks in each available storage block queue;
    通道排序模块,配置成将每个存储通道加入复写通道列表,并按照复写周期从大到小进行排序;The channel sorting module is configured to add each storage channel to the list of duplicate channels, and sort according to a rewriting period from large to small;
    数目记录模块,配置成计算所述复写通道列表中每个存储通道的可复写存储块数目,并将所述可复写存储块数目对应记录到所述复写通道列表中。The number recording module is configured to calculate a number of rewritable memory blocks of each of the memory channels in the list of duplicate write channels, and record the number of the rewritable memory blocks correspondingly into the list of duplicate write channels.
  16. 根据权利要求15所述的装置,其特征在于,所述数据写入模块配置成:The apparatus according to claim 15, wherein said data writing module is configured to:
    当检测到所述存储通道对应的所述可用存储块队列中有可用存储块时,从所述可用存储块队列中获取预设数量的可用存储块,并将数据写入所述可用存储块中;When a storage block is available in the available storage block queue corresponding to the storage channel, a preset number of available storage blocks are obtained from the available storage block queue, and data is written into the available storage block. ;
    当检测到所述可用存储块写满时,将所述可用存储块从所述可用存储块队列中出队;Determining the available memory block from the available memory block queue when it is detected that the available memory block is full;
    检测数据写入操作是否完成;Check if the data write operation is completed;
    当数据写入未完成时,对所述存储空间状态标识的当前状态进行检测;When the data writing is not completed, detecting the current state of the storage space status identifier;
    当所述当前状态为非复写状态时,从存储空间中获取处于空闲状态的存储块加入所述可用存储块队列,并从所述可用存储块队列中获取新的可用存储块进行数据写入;When the current state is a non-overwrite state, the storage block that is in the idle state is acquired from the storage space to join the available storage block queue, and a new available storage block is obtained from the available storage block queue for data writing;
    当所述当前状态为复写状态时,从所述可用存储块队列中获取新的可用存储块进行数据写入。When the current state is a replication state, a new available memory block is obtained from the available memory block queue for data writing.
  17. 根据权利要求15或16任意一项所述的装置,其特征在于,所述寿命平衡策略包括:热区分配策略、冷区分配策略及平衡区分配策略,所述回收分配模块配置成:The device according to any one of claims 15 or 16, wherein the life balance strategy comprises: a hot zone allocation strategy, a cold zone allocation strategy, and a balance zone allocation policy, wherein the recycling allocation module is configured to:
    将正在执行存储业务的存储通道加入待处理通道列表;Add the storage channel that is performing the storage service to the pending channel list.
    从所述待处理通道列表中获取一个待处理通道,对所述待处理通道对应的存储块进行遍历,查找处于有效状态的存储块;Obtaining a to-be-processed channel from the to-be-processed channel list, traversing the storage block corresponding to the to-be-processed channel, and searching for a storage block in an active state;
    在所述处于有效状态的存储块中,按照数据写入时间顺序获取数量为所述可复写存储块数目的存储块,将获取的所述存储块的状态设置为无效状态,并记录到回收列表;And storing, in the storage block in an active state, a storage block whose number is the number of the rewritable storage blocks according to a data write time sequence, setting the acquired state of the storage block to an invalid state, and recording to the collection list. ;
    对记录在所述回收列表的存储块进行数据擦除处理,更新所述存储块的擦除次数,将所述存储块的状态更新为空闲状态,并将记录到分配列表;Performing data erasing processing on the storage blocks recorded in the collection list, updating the erasure times of the storage blocks, updating the status of the storage blocks to an idle state, and recording to the allocation list;
    检测所述待处理通道列表中是否存在未处理的待处理通道;Detecting whether there is an unprocessed pending channel in the to-be-processed channel list;
    当不存在时,根据所述分配列表中每个存储块的当前擦除次数和擦除次数上限计算每个存储块的存储寿命系数;When not present, calculating a storage life coefficient of each storage block according to a current erasure number and an upper erasing number upper limit of each storage block in the allocation list;
    遍历所述分配列表,将所述存储寿命系数大于热区阈值的存储块加入热区列表,并基于所述存储寿命系数对所述热区列表中的存储块进行排序;Traversing the allocation list, adding the storage block whose storage lifetime coefficient is greater than the hot zone threshold to the hot zone list, and sorting the storage blocks in the hot zone list based on the storage life coefficient;
    根据热区分配策略对经过排序的所述热区列表中的存储块进行热区回收分配处理;Performing hot zone collection and distribution processing on the storage blocks in the sorted hot zone list according to the hot zone allocation policy;
    将所述存储寿命系数小于冷区阈值的存储块加入冷区列表,并基于所述存储寿命系数对所述冷区列表中的存储块进行排序;Adding the storage block whose storage life coefficient is smaller than the cold zone threshold to the cold zone list, and sorting the storage blocks in the cold zone list based on the storage life coefficient;
    根据冷区分配策略对经过排序的所述冷区列表中的存储块进行冷区回收分配处理;Performing cold zone collection and distribution processing on the storage blocks in the sorted cold zone list according to the cold zone allocation policy;
    将所述存储寿命系数位于所述热区阈值与所述冷区阈值之间的存储块加入平衡区列表,并基于所述擦除次数对所述平衡区列表中的存储块进行排序;And storing a storage block whose storage life coefficient is between the hot zone threshold and the cold zone threshold into a balance zone list, and sorting the storage blocks in the balance zone list based on the number of erasures;
    根据平衡区分配策略对经过排序的所述平衡区列表中的存储块进行平衡区回收分配处理。The balanced area recovery allocation process is performed on the stored blocks in the sorted balance area list according to the balance area allocation policy.
  18. 一种固态硬盘,包括控制单元及存储有若干计算机指令的非易失性存储单元,其特征在于,所述计算机指令被所述控制单元执行时,所述控制单元执行权利要求1-13中任意一项所述的存储管理方法。A solid state hard disk comprising a control unit and a non-volatile storage unit storing a plurality of computer instructions, wherein the control unit performs any of claims 1-13 when the computer instruction is executed by the control unit A storage management method as described.
  19. 一种可读存储介质,所述可读存储介质包括计算机程序,其特征在于:A readable storage medium, the readable storage medium comprising a computer program, characterized by:
    所述计算机程序运行时控制所述可读存储介质所在的固态硬盘执行权利要求1-13中任意一项所述的存储管理方法。The solid state hard disk in which the readable storage medium is located is executed to execute the storage management method according to any one of claims 1-13.
PCT/CN2018/100884 2017-12-20 2018-08-16 Storage management method and device, solid state drive and readable storage medium WO2019119833A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711380674.9A CN109947353B (en) 2017-12-20 2017-12-20 Storage management method, solid state disk and readable storage medium
CN201711380674.9 2017-12-20

Publications (1)

Publication Number Publication Date
WO2019119833A1 true WO2019119833A1 (en) 2019-06-27

Family

ID=66992413

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/100884 WO2019119833A1 (en) 2017-12-20 2018-08-16 Storage management method and device, solid state drive and readable storage medium

Country Status (2)

Country Link
CN (1) CN109947353B (en)
WO (1) WO2019119833A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651126B (en) * 2020-06-04 2023-05-16 重庆芯讯通无线科技有限公司 Memory writing operation method, system, electronic device and medium
CN111832087B (en) * 2020-06-28 2022-07-29 福建捷宇电脑科技有限公司 Key management method and device for prolonging service life of flash
CN112463048B (en) * 2020-11-26 2022-08-30 新华三技术有限公司成都分公司 Compact processing speed adjusting method and device, electronic equipment and medium
CN114546267B (en) * 2022-02-14 2022-11-18 深圳源创存储科技有限公司 Solid state disk based on big data calculation and solid state disk system
CN115623151B (en) * 2022-12-20 2023-03-03 苏州万店掌网络科技有限公司 Audio and video storage method and network video recording equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101727396A (en) * 2008-10-10 2010-06-09 群联电子股份有限公司 Memory management method for nonvolatile memory and controller thereof
CN102081576A (en) * 2011-03-01 2011-06-01 华中科技大学 Flash memory wear balance method
CN102222046A (en) * 2011-06-09 2011-10-19 清华大学 Abrasion equilibrium method and device
CN102880556A (en) * 2012-09-12 2013-01-16 浙江大学 Wear leveling method and system of Nand Flash

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101441599B (en) * 2008-11-28 2011-11-02 成都市华为赛门铁克科技有限公司 Solid hard disk and equilibrium method of the same
CN103577336B (en) * 2013-10-23 2017-03-08 华为技术有限公司 A kind of stored data processing method and device
US9996297B2 (en) * 2014-11-14 2018-06-12 SK Hynix Inc. Hot-cold data separation method in flash translation layer
CN104461393B (en) * 2014-12-09 2017-05-17 华中科技大学 Mixed mapping method of flash memory
CN107220185A (en) * 2017-05-23 2017-09-29 建荣半导体(深圳)有限公司 Date storage method, device and flash chip based on flash memory

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101727396A (en) * 2008-10-10 2010-06-09 群联电子股份有限公司 Memory management method for nonvolatile memory and controller thereof
CN102081576A (en) * 2011-03-01 2011-06-01 华中科技大学 Flash memory wear balance method
CN102222046A (en) * 2011-06-09 2011-10-19 清华大学 Abrasion equilibrium method and device
CN102880556A (en) * 2012-09-12 2013-01-16 浙江大学 Wear leveling method and system of Nand Flash

Also Published As

Publication number Publication date
CN109947353A (en) 2019-06-28
CN109947353B (en) 2021-03-09

Similar Documents

Publication Publication Date Title
TWI740110B (en) Workload-adaptive overprovisioning in solid state storage drive arrays
US10996863B1 (en) Nonvolatile memory with configurable zone/namespace parameters and host-directed copying of data across zones/namespaces
WO2019119833A1 (en) Storage management method and device, solid state drive and readable storage medium
US11481144B1 (en) Techniques for directed data migration
US10430084B2 (en) Multi-tiered memory with different metadata levels
US8521949B2 (en) Data deleting method and apparatus
US9946642B2 (en) Distributed multimode storage management
US9042181B2 (en) Periodic erase operation for a non-volatile medium
US7120729B2 (en) Automated wear leveling in non-volatile storage systems
US9489297B2 (en) Pregroomer for storage array
US8103820B2 (en) Wear leveling method and controller using the same
WO2019178845A1 (en) Garbage collection method for storage media, storage medium, and program product
JP2017021805A (en) Interface providing method capable of utilizing data attribute reference data arrangement in nonvolatile memory device and computer device
US9513822B2 (en) Unmap storage space
EP3168736A1 (en) Storage device including multi-partitions for multimode operations, and operation method thereof
JP2017021804A (en) Interface providing method for utilizing data characteristic base data arrangement in nonvolatile memory device, system and nonvolatile memory device, and data characteristic base data arrangement method
US11249652B1 (en) Maintenance of nonvolatile memory on host selected namespaces by a common memory controller
US9666244B2 (en) Dividing a storage procedure
US10997080B1 (en) Method and system for address table cache management based on correlation metric of first logical address and second logical address, wherein the correlation metric is incremented and decremented based on receive order of the first logical address and the second logical address
CN110362499B (en) Electronic machine and control method thereof, computer system and control method thereof, and control method of host
US11392309B2 (en) Memory system for performing migration operation and operating method thereof
CA2978845A1 (en) Storage system and system garbage collection method
US11269771B2 (en) Storage device for improving journal replay, operating method thereof, and electronic device including the storage device
US11016889B1 (en) Storage device with enhanced time to ready performance
TWI718710B (en) Data storage device and non-volatile memory control method

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: 18890374

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: 18890374

Country of ref document: EP

Kind code of ref document: A1