Data deleting method and device, electronic equipment and storage medium

文档序号:1296030 发布日期:2020-08-07 浏览:11次 中文

阅读说明:本技术 一种数据删除方法、装置、电子设备及存储介质 (Data deleting method and device, electronic equipment and storage medium ) 是由 林起芊 叶敏 林鹏 王伟 于 2019-01-30 设计创作,主要内容包括:本发明实施例提供了一种数据删除方法、装置电子设备及存储介质,该方法包括:获得待处理的数据区的时间索引;确定所述数据区的时间索引是否与预定时间范围存在重叠;如果存在重叠,从所述数据区中,确定写入时间在目标时间范围内的目标对象块;在所述数据区对应的主索引区中,查找所述目标对象块对应的目标区域;将所述目标区域中的主索引数据删除。本发明实施例可以解决现有技术中由于磁头的频繁移动而降低HM-SMR硬盘的存储性能的问题。(The embodiment of the invention provides a data deleting method, device electronic equipment and a storage medium, wherein the method comprises the following steps: obtaining a time index of a data area to be processed; determining whether a time index of the data area overlaps a predetermined time range; if the overlap exists, determining a target object block with the writing time within the target time range from the data area; searching a target area corresponding to the target object block in a main index area corresponding to the data area; deleting the main index data in the target area. The embodiment of the invention can solve the problem that the storage performance of the HM-SMR hard disk is reduced due to the frequent movement of the magnetic head in the prior art.)

1. A method for deleting data, comprising:

obtaining a time index of a data area to be processed; wherein the time index of the data area is: determining a time range according to the writing time of each object block in the data area;

determining whether a time index of the data area overlaps a predetermined time range; the preset time range is set for deleting the main index data corresponding to the object block in the data area;

if the overlap exists, determining a target object block with the writing time within the target time range from the data area; wherein the target time range is an overlapping range of the time index of the data area and the predetermined time range;

searching a target area corresponding to the target object block in a main index area corresponding to the data area; the main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored;

deleting the main index data in the target area.

2. The method according to claim 1, wherein the finding a target area corresponding to the target object block in the primary index area corresponding to the data area comprises:

and searching a target area corresponding to the target object block in the main index area corresponding to the data area based on the storage position of the main index data corresponding to the target object block.

3. The method according to claim 2, wherein when the number of the target object blocks is multiple, the searching for the target area corresponding to the target object block in the primary index area corresponding to the data area based on the storage location of the primary index data corresponding to the target object block comprises:

determining a first target object block with the earliest writing time and a second target object block with the latest writing time in a plurality of target object blocks;

determining a first starting position of main index data corresponding to the first target object block in the main index area and a first ending position of main index data corresponding to the second target object block in the main index area;

and determining the area between the first starting position and the first ending position in the main index area corresponding to the data area as a target area.

4. The method according to claim 2, wherein when the number of the target object blocks is one, the searching for the target area corresponding to the target object block in the primary index area corresponding to the data area based on the storage location of the primary index data corresponding to the target object block comprises:

determining a second starting position and a second ending position of main index data corresponding to the target object block in the main index area;

and determining the area between the second starting position and the second ending position in the main index area corresponding to the data area as a target area.

5. The method of claim 1, wherein the time index of the data region is determined by:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

and determining the time range from the earliest writing time to the latest writing time as the time index of the data area.

6. The method according to claim 1, wherein the data area is located in the same or different storage medium as a main index area corresponding to the data area.

7. The method of claim 1, wherein deleting the primary index data in the target region comprises:

and deleting the main index data in the target area by executing one I/O operation in the storage medium of the main index area.

8. A data deletion apparatus, comprising:

an obtaining module, configured to obtain a time index of a data area to be processed; wherein the time index of the data area is: determining a time range according to the writing time of each object block in the data area;

a first determining module, configured to determine whether a time index of the data area overlaps with a predetermined time range; the preset time range is set for deleting the main index data corresponding to the object block in the data area; if there is overlap, triggering a second determining module;

a second determining module, configured to determine, from the data area, a target object block whose writing time is within a target time range; wherein the target time range is an overlapping range of the time index of the data area and the predetermined time range;

the searching module is used for searching a target area corresponding to the target object block in a main index area corresponding to the data area; the main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored;

and the deleting module is used for deleting the main index data in the target area.

9. The apparatus of claim 8,

the searching module is specifically configured to search, in the main index area corresponding to the data area, a target area corresponding to the target object block based on a storage location of main index data corresponding to the target object block.

10. The apparatus of claim 9, wherein the lookup module comprises:

a first determination unit configured to determine, among a plurality of the target object blocks, a first target object block whose write time is earliest and a second target object block whose write time is latest when the number of the target object blocks is plural;

a second determining unit, configured to determine a first starting position of the main index data corresponding to the first target object block in the main index area, and a first ending position of the main index data corresponding to the second target object block in the main index area;

and a third determining unit, configured to determine, as a target area, an area between the first start position and the first end position in a main index area corresponding to the data area.

11. The apparatus of claim 9, wherein the lookup module comprises:

a fourth determining unit, configured to determine, when the number of the target object blocks is one, a second start position and a second end position of the main index data corresponding to the target object block in the main index area;

and a fifth determining unit, configured to determine, as a target area, an area between the second start position and the second end position in the main index area corresponding to the data area.

12. The apparatus of claim 8, wherein the time index of the data region is determined by:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

and determining the time range from the earliest writing time to the latest writing time as the time index of the data area.

13. The apparatus of claim 8, wherein the data area is located in the same or different storage medium as a main index area corresponding to the data area.

14. The apparatus of claim 8,

the deleting module is specifically configured to delete the main index data in the target area by performing an I/O operation in the storage medium in which the main index area is located.

15. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;

a memory for storing a computer program;

a processor for implementing the method steps of any of claims 1 to 7 when executing a program stored in the memory.

16. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 7.

Technical Field

The present invention relates to the field of data processing technologies, and in particular, to a data deleting method and apparatus, an electronic device, and a storage medium.

Background

In recent years, with the continuous development of video monitoring technology, the data volume of video data required to be processed is increasing, for example, in the security industry, the video data is collected in real time, the collected video data has continuity on a time axis, and the video data is infinitely increased along with the time, and this type of data is generally called streaming data.

The shingled hard disk as a recently introduced storage medium has the characteristics of high storage density, stable storage, low price and the like, and is very suitable for being used in the security industry. In particular, the method is very suitable for storing streaming data in the security industry. Currently, an HM-SMR (Host Managed-shifted magnetic Recording) hard disk is a type of Shingled hard disk that is used more often. In an HM-SMR hard disk, a CMR (conventional magnetic recording) area and an SMR area are included, and the SMR area is divided into a plurality of fixed-size areas, and among the plurality of fixed-size areas, one or more data areas may be included. In general, streaming data is stored as object data in a data area of an SMR area in the form of object blocks, each object block corresponding to main index data and spare index data having consistent contents and corresponding to each other in a backup manner, wherein the main index data is stored in a main index data area of a CMR area, and the spare index data is stored in a data area of the SMR area.

In practical applications, the object block often needs to be logically deleted, that is, the object block needs to be marked as deleted. Marking an object block as deleted may be accomplished by: and deleting the main index data corresponding to the object block. Because the streaming data has the characteristics of large data volume, less writing and reading, and fast coverage frequency, in a one-time logical deletion process, a plurality of object blocks are often required to be logically deleted, that is, a plurality of main index data are required to be deleted. In the HM-SMR hard disk, however, an I/O (read/write) operation is required every time one main index data is deleted. When deleting a plurality of main index data, a plurality of I/O operations are required. This causes frequent movement of the head in the hard disk, which degrades the storage performance of the HM-SMR hard disk.

Disclosure of Invention

Embodiments of the present invention provide a data deletion method, an apparatus, an electronic device, and a storage medium, so as to solve the problem in the prior art that the storage performance of an HM-SMR hard disk is reduced due to frequent movement of a magnetic head. The specific technical scheme is as follows:

in a first aspect, the present invention provides a data deleting method, including:

obtaining a time index of a data area to be processed; wherein the time index of the data area is: determining a time range according to the writing time of each object block in the data area;

determining whether a time index of the data area overlaps a predetermined time range; the preset time range is set for deleting the main index data corresponding to the object block in the data area;

if the overlap exists, determining a target object block with the writing time within the target time range from the data area; wherein the target time range is an overlapping range of the time index of the data area and the predetermined time range;

searching a target area corresponding to the target object block in a main index area corresponding to the data area; the main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored;

deleting the main index data in the target area.

Optionally, the searching for the target area corresponding to the target object block in the main index area corresponding to the data area includes:

and searching a target area corresponding to the target object block in the main index area corresponding to the data area based on the storage position of the main index data corresponding to the target object block.

Optionally, when the number of the target object blocks is multiple, the searching, in the primary index area corresponding to the data area, for the target area corresponding to the target object block based on the storage location of the primary index data corresponding to the target object block includes:

determining a first target object block with the earliest writing time and a second target object block with the latest writing time in a plurality of target object blocks;

determining a first starting position of main index data corresponding to the first target object block in the main index area and a first ending position of main index data corresponding to the second target object block in the main index area;

and determining the area between the first starting position and the first ending position in the main index area corresponding to the data area as a target area.

Optionally, when the number of the target object blocks is one, the searching, in the primary index area corresponding to the data area, for the target area corresponding to the target object block based on the storage location of the primary index data corresponding to the target object block includes:

determining a second starting position and a second ending position of main index data corresponding to the target object block in the main index area;

and determining the area between the second starting position and the second ending position in the main index area corresponding to the data area as a target area.

Optionally, the time index of the data area is determined by:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

and determining the time range from the earliest writing time to the latest writing time as the time index of the data area.

Optionally, the data area and the main index area corresponding to the data area are located in the same or different storage media.

Optionally, the deleting the main index data in the target area includes:

and deleting the main index data in the target area by executing one I/O operation in the storage medium of the main index area.

In a second aspect, an embodiment of the present invention provides a data deleting apparatus, including:

an obtaining module, configured to obtain a time index of a data area to be processed; wherein the time index of the data area is: determining a time range according to the writing time of each object block in the data area;

a first determining module, configured to determine whether a time index of the data area overlaps with a predetermined time range; the preset time range is set for deleting the main index data corresponding to the object block in the data area; if there is overlap, triggering a second determining module;

a second determining module, configured to determine, from the data area, a target object block whose writing time is within a target time range; wherein the target time range is an overlapping range of the time index of the data area and the predetermined time range;

the searching module is used for searching a target area corresponding to the target object block in a main index area corresponding to the data area; the main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored;

and the deleting module is used for deleting the main index data in the target area.

Optionally, the searching module is specifically configured to search, based on a storage location of the main index data corresponding to the target object block, a target area corresponding to the target object block in the main index area corresponding to the data area.

Optionally, the search module includes:

a first determination unit configured to determine, among a plurality of the target object blocks, a first target object block whose write time is earliest and a second target object block whose write time is latest when the number of the target object blocks is plural;

a second determining unit, configured to determine a first starting position of the main index data corresponding to the first target object block in the main index area, and a first ending position of the main index data corresponding to the second target object block in the main index area;

and a third determining unit, configured to determine, as a target area, an area between the first start position and the first end position in a main index area corresponding to the data area.

Optionally, the search module includes:

a fourth determining unit, configured to determine, when the number of the target object blocks is one, a second start position and a second end position of the main index data corresponding to the target object block in the main index area;

and a fifth determining unit, configured to determine, as a target area, an area between the second start position and the second end position in the main index area corresponding to the data area.

Optionally, the time index of the data area is determined by:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

and determining the time range from the earliest writing time to the latest writing time as the time index of the data area.

Optionally, the data area and the main index area corresponding to the data area are located in the same or different storage media.

Optionally, the deleting module is specifically configured to delete the main index data in the target area by performing an I/O operation in a storage medium in which the main index area is located.

In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;

a memory for storing a computer program;

a processor, configured to implement the steps of the data deletion method according to the first aspect when executing the program stored in the memory.

In a fourth aspect, the present invention provides a computer-readable storage medium, in which a computer program is stored, and when executed by a processor, the computer program implements the data deletion method steps described in the first aspect.

According to the scheme provided by the embodiment of the invention, the time index of the data area to be processed is obtained firstly, and then whether the time index of the data area is overlapped with the preset time range or not is determined. If the data areas are overlapped, determining a target object block with the writing time within the target time range from the data areas, searching a target area corresponding to the target object block in a main index area corresponding to the data areas, and deleting the main index data in the target area. In the scheme of the embodiment of the present invention, because the main index data corresponding to each object block in the data area to be processed is continuously stored in the main index area corresponding to the data area, when the main index data corresponding to the object block with the writing time within the predetermined time range in the data area needs to be deleted, the target area in which the main index data corresponding to the object block is stored can be searched in the main index area corresponding to the data area, so that the main index data in the target area can be deleted at one time. Since the magnetic head does not move frequently when the main index data in the target area is deleted at one time, the problem that the storage performance of the HM-SMR hard disk is reduced due to the frequent movement of the magnetic head in the prior art can be solved.

Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.

Fig. 1 is a schematic flowchart of a data deleting method according to an embodiment of the present invention;

FIG. 2a is a region division diagram of an HM-SMR hard disk;

FIG. 2b is a layout view of various areas of an HM-SMR hard disk;

FIG. 2c is a diagram of the storage structure of the primary index data area in the CMR area;

FIG. 2d is a diagram of a storage structure of a spare index block in the SMR area;

fig. 3 is a schematic structural diagram of a data deleting device according to an embodiment of the present invention;

fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The shingled magnetic recording technique overlaps the data tracks on the disks of the hard disk, just like roof tiles, which can greatly increase the storage density of the hard disk. The shingled hard disk realized based on the shingled magnetic recording technology has the characteristics of high storage density, stable storage, low price and the like, and is very suitable for being used in the security industry. In particular, the method is very suitable for storing streaming data in the security industry.

Currently, an HM-SMR (Host Managed-shifted magnetic Recording) hard disk is a type of Shingled hard disk that is used more often. As shown in fig. 2a, an area division diagram of an HM-SMR hard disk is shown, and as can be seen from fig. 2a, the HM-SMR hard disk includes a CMR (conventional magnetic recording) area and an SMR area. Wherein the CMR area may support random read and write operations, and the SMR area only supports sequential read and write operations. Both the CMR area and the SMR area are divided into a plurality of fixed-size areas. Specifically, in the CMR area, read and write operations can be performed in parallel for a plurality of areas, and random read and write operations can be performed in each area. In the SMR area, reading and writing operations can be performed in parallel for a plurality of areas as well, but only sequential reading and writing can be performed in each area. Since the SMR area supports only sequential read and write operations, in one area of the SMR area, the area can be reused only after the area is fully written with data and reset when the data in the area needs to be deleted. That is, for an area of the SMR area where data is written, the area must be reset before being reused.

The layout of the various areas of the HM-SMR hard disk is given below by figure 2 b.

As shown in fig. 2b, the plurality of regions of the SMR region include: a data area, a spare metadata area and a reserved area. The data area is used for storing the object data and the standby index data corresponding to the object data. Specifically, in the data area, the storage form of the object data is an object block, and the storage form of the standby index data corresponding to the object data is a standby index block. Generally, a plurality of object blocks are stored in one data area, and each object block is followed by an index block corresponding to the object block. The spare metadata area is used for storing metadata information. The reserved area is used as an intermediate medium when the object block is retrieved.

As shown in FIG. 2b, the CMR area includes, in a plurality of zones: a main metadata area and a main index data area. Wherein the main metadata area is used for storing main metadata information. The main index data area is used for storing main index data which is backup to the standby index data, and the storage form of the main index data is a main index block. Then, for an object block in the data area, a spare index block corresponding to the object block is stored in the data area, and in addition, a main index block corresponding to the object block is stored in the main index data area.

The main metadata information and the backup metadata information have consistent contents and are backups of each other, and the backup metadata information may include: the size of the CMR area, the size of the SMR area, the number of the middle areas in the SMR area, the size of a single main/standby index block, the size of a single object block, the initialization time of a file system, the total number of available blocks of the file system and the like. In a specific application, the last region in the SMR region may be used as a spare metadata region for storing metadata information, so that the metadata information is prevented from being lost after the CMR region is damaged.

The contents of the main index data and the backup index data corresponding to any object block are consistent and backup to each other, and may include: file system management data and Unit _ key. And the Unit _ key is an object key value corresponding to the object block. The file system management data may include: the number of the object block, the length of the Unit _ key, the storage state of the object block (for example, free, used or deleted), the length of valid data stored in the object block, the check value of data stored in the object block, and the write time of the object block. The writing time of the object block refers to: and writing time of object data corresponding to the object block.

FIG. 2c is a storage structure diagram of the main index data area in the CMR area. The main index data area in the CMR area may be one area of the CMR area, or may be a combination of a plurality of continuous areas of the CMR area. As can be seen from fig. 2c, in the main index data area, the respective main index blocks (main index block 1 to main index block N) are stored consecutively. That is, for one data area in the SMR area, in the primary index data area, primary index data corresponding to each object block in the data area is continuously stored, and then, an area in which primary index data corresponding to each object block in the data area is continuously stored may be referred to as a primary index area corresponding to the data area. Obviously, the main index area corresponding to one data area is a part of the main index data area in the CMR area, that is: the CMR area includes the main index data area: and the main index area corresponds to each data area.

FIG. 2d is a diagram of a storage structure of a spare index block in the SMR area. As can be seen in FIG. 2d, the spare index chunk corresponding to each object chunk is stored immediately after the object chunk.

As can be seen from fig. 2c and fig. 2d, the continuous storage of each main index block means: for a plurality of object blocks in a plurality of continuously stored object block groups (an object block group comprises an object block and a standby index block corresponding to the object block), main index blocks corresponding to the object blocks are continuously stored in a main index data area. That is, the main index data corresponding to each of the plurality of object blocks is continuously stored in the main index data area.

In general, streaming data is stored as object data in a data area of an SMR area in the form of object blocks, each object block corresponding to main index data and spare index data having consistent contents and corresponding to each other in a backup manner, wherein the main index data is stored in a main index data area of a CMR area, and the spare index data is stored in a data area of the SMR area. For a specific storage form, refer to fig. 2 a-2 d.

In practical applications, the object block often needs to be logically deleted, that is, the object block needs to be marked as deleted. Marking an object block as deleted may be accomplished by: and deleting the main index data corresponding to the object block. Because the streaming data has the characteristics of large data volume, less writing and reading, and fast coverage frequency, in a one-time logical deletion process, a plurality of object blocks are often required to be logically deleted, that is, a plurality of main index data are required to be deleted. In the HM-SMR hard disk, however, an I/O (read/write) operation is required every time one main index data is deleted. When deleting a plurality of main index data, a plurality of I/O operations are required. This causes frequent movement of the head in the hard disk, which degrades the storage performance of the HM-SMR hard disk.

In order to solve the above technical problem, embodiments of the present invention provide a data deleting method and apparatus, an electronic device, and a storage medium.

Next, a data deleting method provided in the embodiment of the present application is first described.

It should be noted that the data deleting method provided by the embodiment of the present invention may be applied to an electronic device. The electronic device may be a device that can access the HM-SMR hard disk, specifically, a terminal device, or a server, which is not limited herein. Illustratively, the terminal device may be: smart phones, tablet computers, desktop computers, and the like.

Fig. 1 is a flowchart of a data deleting method according to an embodiment of the present invention. As shown in fig. 1, the method may include the steps of:

s101, obtaining the time index of the data area to be processed.

Wherein, the time index of the data area is: and determining a time range according to the writing time of each object block in the data area.

In this embodiment, the streaming data may be stored as object data in the form of object blocks: in the data area of the SMR area of the HM-SMR hard disk. When the object block is stored in the data area, the object block corresponds to a write time, where the write time is: and writing time of object data corresponding to the object block. When the target block needs to be logically deleted, a time range may be set, and the main index data corresponding to the target block whose writing time is within the time range may be deleted.

Since the SMR area includes a plurality of data areas and each data area can write data in parallel, the time indexes of the data areas are not necessarily continuous. Then, when the object block needs to be logically deleted, each data area in the SMR area needs to be used as a data area to be processed, and the object block that needs to be logically deleted in the data area is determined. That is to say, in each deleting process, after the time range is set, the steps of the data deleting method provided by the embodiment of the present invention need to be executed for each data area.

The time index of the data area can be obtained for the data area to be processed, and further, the time index is used to determine the object block which needs to be logically deleted in the data area.

In this embodiment, the time index of the data area is determined in the following manner:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

the time range from the earliest writing time to the latest writing time is determined as the time index of the data area.

That is, the time index of the data area is a time range from the write time of the object block that was written into the data area at the earliest to the write time of the object block that was written into the data area at the latest.

For example, 256 object blocks are stored in the data area a, wherein the writing time of the object block 1 which is written into the data area a at the earliest is: in 2018, 10/1/8 am, and the write time of the object block 256 that was written into the data area a at the latest is: 10.2018, 10.1.9 am, 10 min. Then, the time index of the data area a is: 10 am 8 am on 1/10/2018 to 10 am 9 am on 1/10/2018.

In this step, the manner of obtaining the time index of the data area to be processed is not limited. For example, the electronic device may read the backup index data corresponding to each object block in the data area, obtain the writing time of each object block, and determine the earliest writing time and the latest writing time therein, thereby obtaining the time index of the data area.

S102, whether the time index of the data area is overlapped with a preset time range is determined.

The preset time range is set for deleting the main index data corresponding to the object block in the data area.

When the logical deletion of the object block is required, the predetermined time range may be set. The meaning of setting the predetermined time range is: and deleting the main index data corresponding to the object block with the writing time within the preset time range.

The predetermined time range may be in the form of: time 1 to time 2 may be: before time 3. Also, the predetermined time range may be set as needed. For example, the predetermined time range is 8 am on 1/10/2018 to 10 am on 1/2018. For another example, the predetermined time range is 10 months in 2018 before 10 am on 1 st day.

After obtaining the time index of the data area to be processed, it may be determined whether the time index of the data area overlaps with a predetermined time range. If the data area has the overlap, the data area has the object block which needs to be logically deleted. Otherwise, if there is no overlap, it indicates that there is no object block in the data area that needs to be logically deleted.

For example, the time index of the data area is: 10 am 8 am on 1/10/2018 to 10 am 9 am on 1/10/2018. The predetermined time range is 8 am on 1/10/2018 to 10 am on 1/2018. Then, there is an overlap of the time index of the data area and the predetermined time range.

S103, if the overlap exists, determining the target object block with the writing time within the target time range from the data area.

The target time range is an overlapping range of the time index of the data area and the predetermined time range.

If the time index of the data area overlaps the predetermined time range, the overlapping range of the time index of the data area and the predetermined time range may be used as the target time range. Then, among all the object blocks in the data area, the object block whose write time is in the target time range is the object block that needs to be logically deleted. Further, the main index data corresponding to the target object block is deleted.

The number of target object blocks may be one or more. Since streaming data has strong temporal continuity, when the number of target object blocks is plural, the writing times of the plural target object blocks are continuous, and then plural object block groups composed of the plural target object blocks and the respective corresponding auxiliary index blocks are continuously stored in the data area.

In this step, the method of specifying the target block in the slave data area, the write time of which is within the target time range, is not limited. In one implementation, the target object block may be determined by a pre-built database index. Wherein the pre-constructed database index is stored in another storage medium different from the HM-SMR hard disk, which may be, for example: SSD (Solid State Disk) or other type of storage medium. The pre-constructed database index records are: and database index data corresponding to each object block in the data area. The database index data may include: the Unit _ key of each object block in the data area, the object number of the object block, the length of valid data stored in the object block, the check value of the data stored in the object block, and the writing time of the object block.

Specifically, the following may be read from a pre-constructed database index: and writing the Unit _ key of each target object block with the time within the target time range, and reading the object number of the target object block corresponding to the Unit _ key. Wherein, the object number of the target object block refers to: identification of the target object block in the data area. And the object number of the target object block is determined, so that the main index data corresponding to the target object block can be further determined.

Based on this, when the main index data corresponding to the target object block needs to be deleted, the target object block can be determined through the pre-constructed database index, and then the main index data corresponding to the target object block can be further searched in the HM-SMR hard disk. The pre-constructed database index is stored in another storage medium different from the HM-SMR hard disk, that is, a part of search operation is realized in another storage medium without directly accessing the HM-SMR hard disk to search the main index data corresponding to the target object block, so that on one hand, the search performance can be improved, and on the other hand, the access amount to the HM-SMR hard disk can be reduced.

S104, searching a target area corresponding to the target object block in the main index area corresponding to the data area.

The main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored.

The main index area corresponding to the data area is as follows: and the main index data corresponding to each object block in the data area is continuously stored in the corresponding storage medium. Here, the respective storage media refer to: and the storage medium where the main index area corresponding to the data area is located.

In this embodiment, the corresponding storage medium may be an HM-SMR hard disk. Then the data area and the main index area corresponding to the data area are located in the same storage medium. Specifically, the main index area corresponding to the data area is located in the CMR area of the HM-SMR hard disk, and the main index area corresponding to the data area is a part of the main index data area in the CMR area.

Alternatively, in other embodiments, the data area and the main index area corresponding to the data area may be located in different storage media. Specifically, the main index area corresponding to the data area may be located in the SSD or other types of storage media. In this way, the deletion operation of the main index data is completely performed in a storage medium other than the HM-SMR hard disk, and the number of times of movement of the head in the HM-SMR hard disk can be reduced.

After the target object block is determined, a target area corresponding to the target object block can be searched in the main index area corresponding to the data area, and then main index data corresponding to the target object block is determined.

In one implementation, searching for a target area corresponding to a target object block in a main index area corresponding to a data area may include:

and searching a target area corresponding to the target object block in the main index area corresponding to the data area based on the storage position of the main index data corresponding to the target object block.

In this implementation, since the target area stores the main index data corresponding to the target object block, the target area corresponding to the target object block can be searched in the main index area corresponding to the data area based on the storage location of the main index data corresponding to the target object block. Specifically, when the number of the target object blocks is different, based on the storage location of the main index data corresponding to the target object block, the manner of searching for the target area corresponding to the target object block in the main index area corresponding to the data area is also different.

In this embodiment, the number of target object blocks may be one or more.

In the first manner, when the number of the target object blocks is one, based on the storage location of the primary index data corresponding to the target object block, finding the target area corresponding to the target object block in the primary index area corresponding to the data area may include the following steps a1-a 2:

step A1: determining a second starting position and a second ending position of main index data corresponding to the target object block in the main index area;

step A2: and determining the area between the second starting position and the second ending position in the main index area corresponding to the data area as a target area.

In this implementation manner, when the number of the target object blocks is one, the target area corresponding to the target object block is: and the storage area of the main index data corresponding to the target object block in the main index area.

Specifically, since the object number of any object block is recorded in the main index data corresponding to the object block, the main index data corresponding to the object block can be determined in the main index area according to the object number of the object block, so as to determine the second start position and the second end position of the main index data in the main index area. Then, the region from the second start position to the second end position is the target region.

In the second way, when the number of the target object blocks is multiple, based on the storage location of the main index data corresponding to the target object blocks, finding the target area corresponding to the target object block in the main index area corresponding to the data area may include the following steps B1-B2:

step B1: determining a first target object block with the earliest writing time and a second target object block with the latest writing time in a plurality of target object blocks;

step B2: determining a first starting position of main index data corresponding to the first target object block in the main index area and a first ending position of the main index data corresponding to the second target object block in the main index area;

step B3: and determining the area between the first starting position and the first ending position in the main index area corresponding to the data area as a target area.

In this implementation manner, when the number of the target object blocks is multiple, the target area corresponding to the target object block is: and a storage area in which the main index data corresponding to the plurality of target object blocks are continuously stored in the main index area. Based on this, when determining the target area, a first target block written earliest and a second target block written latest in the plurality of target blocks may be determined, and then an area between a first start position of the first target block and a second end position of the second target block may be used as the target area.

Specifically, since the object number of the object block is recorded in the main index data corresponding to any object block, the main index data corresponding to the first object block can be determined in the main index area according to the object number of the first object block, so as to determine the first starting position of the main index data in the main index area. And determining the main index data corresponding to the second target object block in the main index area according to the object number of the second target object block, so as to determine the first termination position of the main index data in the main index area. Then, the region from the first start position to the first end position is the target region.

S105, deleting the main index data in the target area.

After the target area is found, the main index data contained in the target area is: the main index data corresponding to the target object block which needs to be logically deleted can be deleted. And when the number of the target object blocks is one, deleting the main index data corresponding to the target object blocks in the target area. And when the number of the target object blocks is multiple, deleting the main index data corresponding to each target object block in the target area in batch.

In one implementation, deleting the main index data in the target area may include:

the main index data in the target area is deleted by performing an I/O operation once in the storage medium in which the main index area is located.

In this implementation, the I/O operation may be performed once in the CMR area, and the main index data in the target area may be deleted. Specifically, when the number of the target object blocks is multiple, the main index data corresponding to each target object block can be deleted by performing an I/O operation in the CMR area once. Compared with the prior art that for a plurality of object blocks, a plurality of I/O operations are required to be executed to delete the main index data corresponding to the object blocks. Thus, I/O operations can be greatly reduced, and the number of movements of the head in the HM-SMR hard disk can be greatly reduced.

According to the scheme provided by the embodiment of the invention, the time index of the data area to be processed is obtained firstly, and then whether the time index of the data area is overlapped with the preset time range or not is determined. If the data areas are overlapped, determining the target object blocks with the writing time within the target time range from the data areas, searching the target areas corresponding to the target object blocks in the main index areas corresponding to the data areas, and deleting the main index data in the target areas. In the scheme of the embodiment of the present invention, because the main index data corresponding to each object block in the data area to be processed is continuously stored in the main index area corresponding to the data area, when the main index data corresponding to the object block with the writing time within the predetermined time range in the data area needs to be deleted, the target area in which the main index data corresponding to the object block is stored can be searched in the main index area corresponding to the data area, so that the main index data in the target area can be deleted at one time. Since the magnetic head does not move frequently when the main index data in the target area is deleted at one time, the problem that the storage performance of the HM-SMR hard disk is reduced due to the frequent movement of the magnetic head in the prior art can be solved.

Corresponding to the data deleting method provided by the embodiment of the invention, the embodiment of the invention also provides a data deleting device. As shown in fig. 3, the data deleting apparatus may include the following modules:

an obtaining module 301, configured to obtain a time index of a data area to be processed; wherein the time index of the data area is: determining a time range according to the writing time of each object block in the data area;

a first determining module 302, configured to determine whether a time index of the data area overlaps with a predetermined time range; the preset time range is set for deleting the main index data corresponding to the object block in the data area; if there is overlap, trigger the second determination module 203;

a second determining module 303, configured to determine, from the data area, a target object block with a writing time within a target time range; wherein the target time range is an overlapping range of the time index of the data area and the predetermined time range;

a searching module 304, configured to search a target area corresponding to the target object block in a main index area corresponding to the data area; the main index area continuously stores main index data corresponding to each object block in the data area; the target area is an area in which main index data corresponding to the target object block is stored;

a deleting module 305, configured to delete the primary index data in the target area.

According to the scheme provided by the embodiment of the invention, the time index of the data area to be processed is obtained firstly, and then whether the time index of the data area is overlapped with the preset time range or not is determined. If the data areas are overlapped, determining a target object block with the writing time within the target time range from the data areas, searching a target area corresponding to the target object block in a main index area corresponding to the data areas, and deleting the main index data in the target area. In the scheme of the embodiment of the present invention, because the main index data corresponding to each object block in the data area to be processed is continuously stored in the main index area corresponding to the data area, when the main index data corresponding to the object block with the writing time within the predetermined time range in the data area needs to be deleted, the target area in which the main index data corresponding to the object block is stored can be searched in the main index area corresponding to the data area, so that the main index data in the target area can be deleted at one time. Since the magnetic head does not move frequently when the main index data in the target area is deleted at one time, the problem that the storage performance of the HM-SMR hard disk is reduced due to the frequent movement of the magnetic head in the prior art can be solved.

As an implementation manner of the embodiment of the present invention, the searching module 304 is specifically configured to search, based on a storage location of the main index data corresponding to the target object block, a target area corresponding to the target object block in the main index area corresponding to the data area.

As an implementation manner of the embodiment of the present invention, the search module 304 includes:

a first determination unit configured to determine, among a plurality of the target object blocks, a first target object block whose write time is earliest and a second target object block whose write time is latest when the number of the target object blocks is plural;

a second determining unit, configured to determine a first starting position of the main index data corresponding to the first target object block in the main index area, and a first ending position of the main index data corresponding to the second target object block in the main index area;

and a third determining unit, configured to determine, as a target area, an area between the first start position and the first end position in a main index area corresponding to the data area.

As an implementation manner of the embodiment of the present invention, the search module 304 includes:

a fourth determining unit, configured to determine, when the number of the target object blocks is one, a second start position and a second end position of the main index data corresponding to the target object block in the main index area;

and a fifth determining unit, configured to determine, as a target area, an area between the second start position and the second end position in the main index area corresponding to the data area.

As an implementation manner of the embodiment of the present invention, the time index of the data area is determined by:

determining the earliest writing time and the latest writing time in the writing time of each object block in the data area;

and determining the time range from the earliest writing time to the latest writing time as the time index of the data area.

As an implementation manner of the embodiment of the present invention, the data area and the main index area corresponding to the data area are located in the same or different storage media.

As an implementation manner of the embodiment of the present invention, the deleting module 305 is specifically configured to delete the main index data in the target area by performing an I/O operation once in the storage medium where the main index area is located.

An embodiment of the present invention further provides an electronic device, as shown in fig. 4, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404,

a memory 403 for storing a computer program;

the processor 401 is configured to implement the data deleting method provided in the foregoing embodiments of the present invention when executing the program stored in the memory 403, so as to obtain the same technical effect.

The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.

The communication interface is used for communication between the electronic equipment and other equipment.

The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.

The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.

In another embodiment of the present invention, a computer-readable storage medium is further provided, where instructions are stored, and when the instructions are executed on a computer, the computer is enabled to execute a data deleting method provided in the foregoing embodiment of the present invention, so as to obtain the same technical effect.

In another embodiment of the present invention, there is also provided a computer program product containing instructions, which when run on a computer, causes the computer to execute a data deleting method provided in the above-mentioned embodiment of the present invention, so as to obtain the same technical effect.

The computer instructions may be stored on or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g., from one website site, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DS L)) or wireless (e.g., infrared, wireless, microwave, etc.) means to another website site, computer, server, or data center, the computer-readable storage medium may be any available medium accessible by a computer or including one or more available media, such as a Solid State Disk, a magnetic storage medium (e.g., a floppy Disk, a Solid State Disk, a floppy Disk, a Solid State Disk, a magnetic storage medium (e.g., a Solid State Disk, a floppy Disk, a Solid State Disk, a magnetic storage medium, a hard Disk, a Solid State Disk, a magnetic storage medium, a magnetic Disk, a magnetic storage medium, a magnetic Disk, a magnetic storage medium, a magnetic Disk, or the like.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus/electronic device/storage medium/computer program product embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:数据处理方法、装置、SMR存储系统及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类