Disk storage system, data reading and writing method, recovery method, device and medium

By using a combination of multi-level index storage method and backup inodes in the disk storage system, the problem of inability to recover files when disk problems occur is solved, and efficient file recovery is achieved when disk fragmentation or disk loose bad blocks are achieved.

CN115312084BActive Publication Date: 2025-04-25SHENZHEN STREAMING VIDEO TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210908683.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2025-04-25
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

In the prior art, when a disk has problems, files cannot be recovered by traversing the disk search method, especially when disk fragmentation is severely or disk loose and broken blocks are broken.

Method used

Multi-level index storage methods are adopted, including block index, file index and data index, combined with backup block index node and backup data index node, to ensure that files can still be restored by traversing disk search when there is a problem with the disk.

Benefits of technology

When disk fragmentation is severely fragmented or disks are loose and broken blocks, files can be recovered efficiently, improving file recovery efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115312084B_ABST
    Figure CN115312084B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a disk storage system, a data recovery method, a method for writing data, a method for reading data, an electronic device and a computer-readable storage medium. The data recovery method includes: if the block index data block is damaged, the block index data block is restored according to the backup block index node of each data block; if the file index block is damaged, the file index node is reconstructed according to each data index node and block index node in the data index table; if the data index block is damaged, the target data blocks belonging to the same file are determined according to the file ownership information in each block index node, and these target data blocks are traversed, and the data index table is reconstructed and written into the free block according to the backup data index node of each sub-file. The embodiment of the present application uses multi-level indexing of block index, file index and data index, combined with the backup index method, so that when the disk is damaged, the file can still be quickly restored by traversing the disk search method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of storage technology, and in particular relates to a disk storage system, a data recovery method, a data writing method, a data reading method, an electronic device, and a computer-readable storage medium. Background Art

[0002] At present, files are usually stored using standard file systems (such as FAT32, EXT4, etc.). When a file is damaged, it can be restored by using a file system repair tool.

[0003] However, if the file system is severely damaged, the video file cannot be recovered by repair tools. If the disk is severely fragmented, or the disk is loose or has bad blocks, the file cannot be recovered by traversing the disk search method. Summary of the invention

[0004] The embodiments of the present application provide a disk storage system, a data recovery method, a data writing method, a data reading method, an electronic device and a computer-readable storage medium, which can solve the problem in the prior art that when a disk problem occurs, files cannot be recovered by traversing the disk search method.

[0005] In a first aspect, an embodiment of the present application provides a disk storage system, comprising:

[0006] At least one data block, where the data block is obtained by dividing the total disk capacity into fixed block sizes;

[0007] The block index table stored in the block index data block includes the block index node corresponding to each data block. The block index node includes the data block type and file ownership information. The file ownership information is used to indicate the file to which the data stored in the data block corresponding to the block index node belongs. The data block type includes free block, file index block, data index block and target data block.

[0008] The file index table stored in the file index block includes the file index nodes corresponding to each data file stored in the disk, and the file index nodes include the information of the data file and the identifier of the data index block;

[0009] and a data index table stored in the data index block, including data index nodes corresponding to each sub-file of the data file, the data index nodes including information of the sub-file and an identifier of a target data block storing the sub-file;

[0010] Among them, at least one data block includes a block index data block, a file index block, a data index block, and a target data block; each data block except the block index data block stores a backup block index node, which is a backup of the block index node corresponding to the data block; the target data block stores a sub-file and a backup data index node corresponding to each sub-file, which is a backup of the data index node corresponding to the sub-file.

[0011] As can be seen from the above, the embodiment of the present application uses a multi-level index storage method consisting of block index, file index and data index, combined with the backup block index node and the backup data index node method. When the disk is severely fragmented or the disk has loose bad blocks, the file can still be recovered by traversing the disk search method. That is, through the multi-level index method and the backup index method, when the data index is not damaged, the file index can be quickly restored by traversing the data index block. When the file index and the data index are damaged, the file can be restored by traversing the target data block, and the efficiency of restoring the file is higher.

[0012] In a possible implementation of the first aspect, the block index node includes a sequential number of the video data block, and a start time and an end time of the video stored in the target data block; and the information of the sub-file includes a time point of the video data corresponding to the data index node.

[0013] In a possible implementation manner of the first aspect, the block index node further includes a first video channel number and a first check value;

[0014] The file index node also includes the first node status information and the second check value; the information of the data file includes the second video channel number corresponding to the video file, the file attribution stamp, and the start time and end time of the video file;

[0015] The data index node also includes second node status information and a third check value; the sub-file information includes a third video channel number, video data length and offset corresponding to the video file.

[0016] In a second aspect, an embodiment of the present application provides a data recovery method, which is applied to a disk storage system, and the method includes:

[0017] If the block index data block is damaged, the backup block index node stored in each data block is read, and each backup block data index node is written into the backup block index data block to restore the block index data block;

[0018] If the file index block is damaged, the file index node in the file index table is reconstructed according to each data index node in the data index table and the block index node corresponding to the data index block;

[0019] If the data index block is damaged, determine the target data blocks belonging to the same data file according to the file ownership information in each block index node in the block index table; traverse the target data blocks belonging to the same data file to obtain the backup data index node of each sub-file in the target data block; reconstruct the data index table according to the backup data index node and write it into the free block;

[0020] The disk storage system includes:

[0021] At least one data block, where the data block is obtained by dividing the total disk capacity into fixed block sizes;

[0022] The block index table stored in the block index data block includes the block index node corresponding to each data block. The block index node includes the data block type and file ownership information. The file ownership information is used to indicate the file to which the data stored in the data block corresponding to the block index node belongs. The data block type includes free block, file index block, data index block and target data block.

[0023] The file index table stored in the file index block includes the file index nodes corresponding to each data file stored in the disk, and the file index nodes include the information of the data file and the identifier of the data index block;

[0024] and a data index table stored in the data index block, including data index nodes corresponding to each sub-file of the data file, the data index nodes including information of the sub-file and an identifier of a target data block storing the sub-file;

[0025] Among them, at least one data block includes a block index data block, a file index block, a data index block, and a target data block; each data block except the block index data block stores a backup block index node, which is a backup of the block index node corresponding to the data block; the target data block stores a sub-file and a backup data index node corresponding to each sub-file, which is a backup of the data index node corresponding to the sub-file.

[0026] The embodiment of the present application uses a multi-level index storage method consisting of block index, file index and data index, combined with the method of backing up block index nodes and backing up data index nodes. When the disk is severely fragmented or the disk has loose bad blocks, the file can still be recovered by traversing the disk search method. In addition, through the multi-level index method, when the data index is not damaged, the file index can be quickly restored by traversing the data index block. When the file index and data index are damaged, only the target data block needs to be traversed to restore the file, and the efficiency of restoring the file is higher.

[0027] In a possible implementation of the second aspect, the block index node includes a sequential number of the video data block, and a start time and an end time of the video stored in the target data block; the information of the sub-file includes a time point of the video data corresponding to the data index node;

[0028] If the file index block is damaged, the method also includes:

[0029] Get the target time period;

[0030] Determine the target data blocks that belong to the target time period and the same data file according to the file ownership information in each block index node in the block index table and the start time and end time of the video stored in the target data block;

[0031] According to the size of the video data block sequence number, traverse the target data blocks that belong to the target time period and the same data file, and determine whether the time of each backup data index node in the target data block is within the target time period according to the video data time point corresponding to the data index node;

[0032] If so, the video data corresponding to the backup data index node is read, and all the video data are stored to obtain the video file data corresponding to the target time period.

[0033] In this implementation, based on the disk storage system provided in the embodiment of the present application, when the file index is damaged, the video file data of the target time period can be restored in a targeted manner.

[0034] In a possible implementation manner of the second aspect, the block index node further includes a first video channel number and a first check value;

[0035] The file index node also includes the first node status information and the second check value; the information of the data file includes the second video channel number corresponding to the video file, the file attribution stamp, and the start time and end time of the video file;

[0036] The data index node also includes second node status information and a third check value; the sub-file information includes a third video channel number, video data length and offset corresponding to the video file.

[0037] In a third aspect, an embodiment of the present application provides a method for writing data, which is applied to a disk storage system as described in any one of the first aspects above, and the method includes:

[0038] According to the data block type in the block index node, determine the free block as the data block to be written;

[0039] Construct a block index node of the data block to be written in the block index table, and back up the block index node of the data block to be written to the data block to be written;

[0040] Construct a file index node for the file to be written in the file index table, and construct a data index node for the sub-file of the file to be written in the data index table;

[0041] The sub-file of the file to be written is stored in the target data block, and the data index node is backed up to the target data block.

[0042] In a fourth aspect, an embodiment of the present application provides a method for reading data, which is applied to the disk storage system of any one of the first aspects above, and the method includes:

[0043] Traverse the block index table and find the file index block according to the data block type of the block index node;

[0044] Traverse the file index table in the file index block to obtain the file index node of the file to be read;

[0045] According to the file index node, find the data index block;

[0046] The data index table in the data index block is traversed to read the to-be-read file stored in the target data block.

[0047] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method of any one of the second aspect, the third aspect, or the fourth aspect is implemented.

[0048] In the fifth and sixth aspects, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of any one of the second, third or fourth aspects described above is implemented.

[0049] In a seventh aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes any one of the methods in the second, third or fourth aspects above.

[0050] It can be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0052] Figure 1 A schematic block diagram of the structure of a disk storage system provided in an embodiment of the present application;

[0053] Figure 2 A schematic block diagram of a disk storage structure provided in an embodiment of the present application;

[0054] Figure 3 A schematic block diagram of the process of a method for writing data provided in an embodiment of the present application;

[0055] Figure 4 A schematic block diagram of the process of a method for reading data provided in an embodiment of the present application;

[0056] Figure 5 A schematic block diagram of the process of the data recovery method provided in the embodiment of the present application;

[0057] Figure 6 Another schematic block diagram of the data recovery method provided in the embodiment of the present application;

[0058] Figure 7 A structural block diagram of a data recovery device provided in an embodiment of the present application;

[0059] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0061] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0062] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0063] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0064] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0065] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0066] See also Figure 1 , which is a structural schematic block diagram of a disk storage system provided in an embodiment of the present application. The disk storage system may include multiple data blocks (not shown in the figure), a block index table, a file index table stored in a file index block, a data index node stored in a data index block, and a target data block.

[0067] The data block is obtained by dividing the total disk capacity according to the fixed block size. The fixed block size can be set according to actual needs. For example, for an SD card with a total disk capacity of 128G, the fixed block size is 64MB; for a hard disk with a total disk capacity of 1TB, the fixed block size is 128MB; for a hard disk with a total disk capacity of 2TB, the fixed block size is 256MB.

[0068] That is to say, for a disk, it is divided into multiple data blocks according to the set fixed block size.

[0069] Each data block is assigned a unique identifier to facilitate subsequent search and differentiation of the data blocks. For example, the unique identifier is a number, that is, each data block is assigned a number, and the numbering starts from 0.

[0070] The types of data blocks may include free blocks, file index blocks, data index blocks, and target data blocks. A free block refers to a data block that is in an idle state. A file index block refers to a data block that stores a file index table. A data index block refers to a data block that stores a data index table. A target data block refers to a data block used to store file data.

[0071] The type of data block also includes a block index data block. A block index data block refers to a data block used to store a block index table. Usually, a data block numbered 0 is used as a block index data block, that is, the block index table is stored in the data block numbered 0. In some embodiments, in order to facilitate subsequent data recovery, a backup block index data block can be set. For example, after each data block is numbered from 0, the corresponding data block is set as a backup block index data block every fixed number of data blocks.

[0072] The block index table includes block index nodes corresponding to each data block, that is, each block index node corresponds to a data block, and the corresponding data block can be found through the block index node.

[0073] The block index node may include, but is not limited to, the data block type and file ownership information. The file ownership information is used to characterize the file to which the data stored in the data block corresponding to the block index node belongs. For example, the file ownership information is a file ownership stamp. The file ownership stamp of the same file is the same, and the file ownership stamp increases from 0.

[0074] Data block types include free blocks, file index blocks, data index blocks and target data blocks. Exemplarily, different data block types can be represented by different values, 0 represents free blocks, 1 represents file index blocks, 2 represents data index blocks, and 3 represents target data blocks.

[0075] The type of file data stored in the data block can be arbitrary, and it can store video files or non-video files. Taking the storage of video files as an example, the block index node includes the video data block sequence number, the start time and end time of the video stored in the target data block, and also includes the first video channel number and the first check value.

[0076] Exemplarily, the definition of a block index node may be as follows:

[0077]

[0078]

[0079] Wherein, block_type indicates the above data block type, 0 indicates a free block, 1 indicates a file index block, 2 indicates a file data index block, and 3 indicates a video data block, that is, a target data block for storing video file data.

[0080] Channel represents the first video channel number, which may start from 0 and represents the channel number corresponding to the video file stored in the data block.

[0081] start_time indicates the start time of the video in the data block, that is, the start time of the video file stored in the data block;

[0082] end_time indicates the end time of the video in the data block, that is, the end time of the video file stored in the data block.

[0083] owner_stamp represents the file ownership stamp, which increases from 0 and has the same value for the same file.

[0084] block_index indicates the sequential number of the video data block, starting from 0 and increasing.

[0085] check_sum represents the first checksum, which is the checksum of the current index node.

[0086] In specific applications, in order to facilitate subsequent data recovery, the block index node corresponding to each data block can be backed up to the corresponding data block. Figure 1 As shown in , the block index table includes block index node 0, block index node 1, block index node 2, ..., and block index node N. Block index node 1 is backed up to the file index block, that is, the file index block stores the backup block index node. Block index node 2 of the data index block is backed up to the data index block, that is, the data index block stores its own backup block index node.

[0087] The file index table is stored in the file index block. The file index table includes file index nodes corresponding to each data file stored in the disk, and each data file corresponds to a file index node. The file index node includes the information of the data file and the identifier of the data index block.

[0088] In a specific application, the block index node is traversed, and a free data block is found according to the data block type of the block index node, and the free data block is used as a file index block. For example, a data block with block_type of 0 is determined as a file index block, and the value of block_type is changed from 0 to 1, and the block index node of the data block is backed up.

[0089] Taking a video file as an example, the file index node also includes first node status information and a second check value; the information of the data file includes the second video channel number corresponding to the video file, the file attribution stamp, and the start time and end time of the video file.

[0090] Exemplarily, the definition of a file index node is as follows:

[0091]

[0092] Flag indicates the first node status information. For example, 0 indicates an idle node, and 1 indicates an occupied node.

[0093] Channel represents the second video channel number, that is, the channel number corresponding to the video file, which can start from 0.

[0094] owner_stamp indicates the file ownership stamp, which can be incremented from 0.

[0095] start_time indicates the start time of the video file.

[0096] end_time indicates the end time of the video file.

[0097] data_index_block_num indicates the number of the data index data block.

[0098] check_sum represents the second checksum, that is, the checksum of the current index node.

[0099] The data index table is stored in the data index block. In a specific application, a free node is found in the file index table, and after creating a file index node in the free node according to the definition of the file index node, a free data block is found according to the data block type, and the free data block is used as the data index block.

[0100] like Figure 1 As shown, the data block numbered 2 is used as a data index block, the block_type of the block index node of the data block numbered 2 is set to 2, and the block index node is backed up.

[0101] The data index table includes data index nodes corresponding to each sub-file of the data file, and the data index node includes information of the sub-file and an identifier of a target data block storing the sub-file. A sub-file refers to a partial data file obtained by dividing a data file. For example, when the data file is a video file, a sub-file refers to video data per second in the video file, that is, one second of video data corresponds to one data index node.

[0102] Taking the video file as an example, the data index node also includes the second node status information and the third check value; the sub-file information includes the third video channel number corresponding to the video file, the video data length, the offset, and the video data time point corresponding to the data index node.

[0103] Exemplarily, a data index node may be as follows:

[0104]

[0105] Flag represents the second node status information, for example, 0 represents an idle node, and 1 represents an occupied node.

[0106] Channel represents the third video channel number, that is, the video file channel number, which starts from 0.

[0107] data_time indicates the data time point corresponding to the data index node.

[0108] data_block_num indicates the data block number where the video data is located.

[0109] offset indicates the offset within the video data block.

[0110] length indicates the length of video data.

[0111] check_sum represents the third checksum, that is, the checksum of the current index node.

[0112] In the embodiment of the present application, each data block except the block index data block stores a backup block index node, which is a backup of the block index node corresponding to the data block. The target data block stores sub-files and backup data index nodes corresponding to each sub-file, which is a backup of the data index node corresponding to the sub-file. Figure 1 As shown, the target data block stores a backup block index node, a sub-file, and a backup data index node corresponding to each sub-file.

[0113] Take video file data as an example, see Figure 2 The schematic block diagram of the disk storage structure shown is different from Figure 1 ,A video data block refers to a data block used to store video data.

[0114] The embodiment of the present application uses a multi-level index storage method consisting of block index, file index and data index, combined with the backup block index node and the backup data index node method. When the disk is severely fragmented or the disk has loose bad blocks, the file can still be recovered by traversing the disk search method. That is, through the multi-level index method and the backup index method, when the data index is not damaged, the file index can be quickly restored by traversing the data index block. When the file index and the data index are damaged, the file can be restored by traversing the target data block, and the efficiency of restoring the file is higher.

[0115] Based on the disk storage system or disk storage structure mentioned above, the present application embodiment provides a method for writing data. Figure 3 A schematic flow chart of a method for writing data is shown, the method comprising:

[0116] Step S301: Determine, according to the data block type in the block index node, a free block as a data block to be written.

[0117] For example, when traversing the block index table, if the block_type of the block index node of a data block is 0, it indicates that the data block corresponding to the block index node is a free block, and the data block is determined as a data block to be written.

[0118] Step S302: construct a block index node of the data block to be written in the block index table, and back up the block index node of the data block to be written to the data block to be written.

[0119] In a specific application, according to the definition of the block index node, a block index node of the data block to be written is constructed, and the block index node is backed up.

[0120] Step S303: construct a file index node of the file to be written in the file index table, and construct a data index node of the sub-file of the file to be written in the data index table.

[0121] In a specific application, a file index node is constructed according to the definition of a file index node, and a data index node is constructed according to the definition of a data index node.

[0122] Step S304: store the sub-file of the file to be written into the target data block, and back up the data index node to the target data block.

[0123] Taking the file to be written as a video file as an example, according to the node status of the file index node, a free node is found in the file index table, and according to the definition of the file index node, the file index node of the video file is constructed in the free node.

[0124] Traverse the block index nodes, and find a free data block as the data index block of the video file according to the data block type, for storing the data index table. In addition, back up the block index node of the data index block to the starting offset position of the data index block, and update the data index block number of the file index node corresponding to the video file.

[0125] Traverse the block index nodes, find a free data block as the target data block of the video file according to the data block type, and back up the block index node of the target data block to the starting offset position of the data block.

[0126] The video file is divided into video data per second, and the video data per second is stored in the target data block. At this time, the data index node of the video data per second is constructed in the idle node of the data index table in the data index block, and the data index node corresponding to the video data per second is backed up to the target data block.

[0127] Determine whether the current target data block is full. If not, continue to store the video data per second into the target data block, build a data index node for the video data per second, and back up the data index node corresponding to the video data per second to the target data block; if so, update the video file end time in the block index node corresponding to the target data block, and continue to apply for a free block to write the unwritten video data per second.

[0128] When the video file is written, the video end time of the file index node corresponding to the video file is updated. In this way, the writing process of a video file is completed.

[0129] Based on the above-mentioned disk storage system or disk storage structure, the present application embodiment provides a method for reading data. Figure 4 The method for reading data is shown in a flowchart, the method comprising:

[0130] Step S401, traverse the block index table, and search for the file index block according to the data block type of the block index node.

[0131] For example, by traversing the block index nodes and finding the data block with block_type equal to 1, the file index block can be found.

[0132] Step S402: traverse the file index table in the file index block to obtain the file index node of the file to be read.

[0133] For example, when the file to be read is a video file, the file index node corresponding to the file to be read is found in the file index table according to the information such as the video channel and time period in the file index node.

[0134] Step S403: Search for a data index block according to the file index node.

[0135] For example, the data index block number can be obtained through the data_index_block_num field in the file index node, and then the data index block can be found.

[0136] Step S404: traverse the data index table in the data index block, and read the to-be-read file stored in the target data block.

[0137] For example, the file to be read is a video file. According to each data index node in the data index, the target data block and the offset position in the data block are obtained, and the video data per second is read accordingly.

[0138] Based on the above-mentioned disk storage system or disk storage structure, the present application embodiment provides a data recovery method. Figure 5 The data recovery method shown is a schematic flow chart, the method comprising:

[0139] Step S501: If the block index data block is damaged, read the backup block index node stored in each data block, write each backup block data index node into the backup block index data block, so as to restore the block index data block.

[0140] Understandably, in some cases, disk problems may occur. For example, in vehicle monitoring scenarios, due to the harsh environment of the vehicle equipment, vehicle vibration or unstable power supply, the disk may become loose or have bad blocks, resulting in severe disk fragmentation, which ultimately makes it impossible to search or play video files.

[0141] In a specific application, if a block index data block is damaged, it is necessary to restore the damaged block index data block. At this time, since the block index nodes corresponding to each data block are backed up to the offset position of each data block in the disk storage structure of the embodiment of the present application, when restoring the block index data block, the backup block index nodes in each data block are read, a block index table is constructed according to each backup block index node, and the reconstructed block index table is stored in the backup block index data block, and the damaged block index data block is replaced with the backup block index data block.

[0142] Step S502: If the file index block is damaged, reconstruct the file index node in the file index table according to each data index node in the data index table and the block index node corresponding to the data index block.

[0143] At this time, if the data index block is not damaged, the damaged file index block is restored according to the data index node.

[0144] For example, taking video files as an example, each data index node in the data index table is traversed, and the video data time point corresponding to the first data index node is used as the start time of the video file, and the video time point corresponding to the last data index node is used as the end time of the video file.

[0145] The owner_stamp, channel and video data block number in the block index node corresponding to the data index block are used as the owner_stamp, channel and data_index_block_num of the file index node respectively, and the file index node is reconstructed after the verification algorithm is passed according to the verification value.

[0146] Step S503: If the data index block is damaged, determine the target data blocks belonging to the same data file according to the file ownership information in each block index node in the block index table; traverse the target data blocks belonging to the same data file to obtain the backup data index node of each sub-file in the target data block; reconstruct the data index table according to the backup data index node and write it into the free block.

[0147] At this time, if the target data block is not damaged, the damaged data index block is restored according to the backup data index node in the target data block.

[0148] For example, taking a video file as an example, the block index table is traversed to find the target data blocks with the same file ownership stamp owner_stamp in the block index node. The video data stored in these target data blocks all belong to the same video file. Then, the target data blocks belonging to the same video file are sorted from small to large by block_index, and these target data blocks are traversed to find the backup data index node corresponding to each second of video data. Finally, the data index table is reconstructed according to the backup data index node, and the data index table is written into the new data index block. In this case, a new free block is applied as a new data index block.

[0149] It should be noted that if the file index block is damaged and the data index block is damaged, the data index block is restored first, and then the file index block is restored based on the restored data index block.

[0150] The embodiment of the present application adopts a multi-level index storage method consisting of block index, file index and data index, combined with the method of backing up block index node and backing up data index node. When the data index is not damaged, the file index can be quickly restored by traversing only the data index block; when both the file index and the data index are damaged, there is no need to traverse all the storage space, only the target data block needs to be traversed to restore the file, which shortens the file recovery time and improves the efficiency of file recovery.

[0151] In some embodiments, the block index node includes the sequential number of the video data block, and the start time and end time of the video stored in the target data block; the information of the sub-file includes the time point of the video data corresponding to the data index node.

[0152] At this time, if the file index block is damaged, you need to restore the damaged file index block. Figure 6 Another schematic flow chart of a data recovery method is shown, and the data recovery method may further include the following steps:

[0153] Step S601: Obtain a target time period.

[0154] The target time period can be set according to actual needs. For example, in a vehicle video surveillance scenario, if only video files of a specific accident or a specific time period need to be restored, the time of occurrence of the specific accident is determined as the target time period, and the specific time period is determined as the target time period.

[0155] Step S602: Determine the target data blocks that belong to the target time period and the same data file according to the file ownership information in each block index node in the block index table and the start time and end time of the video stored in the target data block.

[0156] The file ownership information can represent the file to which the data stored in the target data block belongs, based on which the target data blocks belonging to the same video file are screened out. In addition, according to the video start time and end time in the block index node, the target data blocks belonging to the same video file and falling within the target time period are screened out.

[0157] Step S603, traverse the target data blocks that belong to the target time period and the same data file according to the size of the sequential number of the video data blocks, and determine whether the time of each backup data index node in the target data block is within the target time period according to the video data time point corresponding to the data index node.

[0158] The size of the video data block sequence number indicates the order in which the video data is stored. Generally, the video data blocks with the earlier sequence numbers store the earlier video data. Based on the order in which the video data is stored, the selected target data blocks are traversed in sequence, and then it is determined whether the time points of the video data in these target data blocks fall into the target time period. If so, the video data corresponding to the backup data index node is read.

[0159] Step S604: If yes, then read the video data corresponding to the backup data index node, and store all the video data to obtain the video file data corresponding to the target time period.

[0160] If not, that is, the time point of the video data corresponding to the backup data index node does not fall into the target time period, the video data corresponding to the backup data index node will not be read.

[0161] In the embodiment of the present application, based on the disk storage system provided in the embodiment of the present application, when the file index is damaged, the video file data of the target time period can be quickly and directionally restored.

[0162] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0163] Corresponding to the data recovery method described in the above embodiment, Figure 7 A structural block diagram of a data recovery device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0164] Reference Figure 7, the device comprises:

[0165] The block index recovery module 71 is used to read the backup block index node stored in each data block if the block index data block is damaged, and write each backup block data index node into the backup block index data block to recover the block index data block;

[0166] A file index recovery module 72, for reconstructing the file index node in the file index table according to each data index node in the data index table and the block index node corresponding to the data index block if the file index block is damaged;

[0167] The data index recovery module 73 is used to determine the target data blocks belonging to the same data file according to the file ownership information in each block index node in the block index table if the data index block is damaged; traverse the target data blocks belonging to the same data file to obtain the backup data index node of each sub-file in the target data block; reconstruct the data index table according to the backup data index node and write it into the free block;

[0168] The disk storage system includes:

[0169] At least one data block, where the data block is obtained by dividing the total disk capacity into fixed block sizes;

[0170] The block index table stored in the block index data block includes the block index node corresponding to each data block. The block index node includes the data block type and file ownership information. The file ownership information is used to indicate the file to which the data stored in the data block corresponding to the block index node belongs. The data block type includes free block, file index block, data index block and target data block.

[0171] The file index table stored in the file index block includes the file index nodes corresponding to each data file stored in the disk, and the file index nodes include the information of the data file and the identifier of the data index block;

[0172] and a data index table stored in the data index block, including data index nodes corresponding to each sub-file of the data file, the data index nodes including information of the sub-file and an identifier of a target data block storing the sub-file;

[0173] Among them, at least one data block includes a block index data block, a file index block, a data index block, and a target data block; each data block except the block index data block stores a backup block index node, which is a backup of the block index node corresponding to the data block; the target data block stores a sub-file and a backup data index node corresponding to each sub-file, which is a backup of the data index node corresponding to the sub-file.

[0174] In a possible implementation, the block index node includes the video data block sequence number, and the start time and end time of the video stored in the target data block; the sub-file information includes the video data time point corresponding to the data index node;

[0175] If the file index block is damaged, the device further comprises:

[0176] The data recovery module for a specific time period is used to obtain a target time period; according to the file ownership information in each block index node in the block index table and the start time and end time of the video stored in the target data block, the target data blocks belonging to the target time period and belonging to the same data file are determined; according to the size of the sequential number of the video data blocks, the target data blocks belonging to the target time period and belonging to the same data file are traversed, and according to the video data time point corresponding to the data index node, it is determined whether the time of each backup data index node in the target data block is within the target time period; if so, the video data corresponding to the backup data index node is read, and all the video data are stored to obtain the video file data corresponding to the target time period.

[0177] In a possible implementation, the block index node also includes a first video channel number and a first check value; the file index node also includes first node status information and a second check value; the data file information includes a second video channel number corresponding to the video file, a file attribution stamp, and a start time and an end time of the video file; the data index node also includes second node status information and a third check value; the sub-file information includes a third video channel number corresponding to the video file, a video data length, and an offset.

[0178] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0179] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device 8 of this embodiment includes: at least one processor 80 ( Figure 8 Only one is shown), a memory 81, the memory 81 stores a computer program 82 that can be executed on at least one processor 80, and when the processor 80 executes the computer program 82, the steps in any of the above-mentioned method embodiments are implemented.

[0180] The electronic device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that Figure 8It is only an example of the electronic device 8 and does not constitute a limitation on the electronic device 8. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0181] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0182] In some embodiments, the memory 81 may be an internal storage unit of the electronic device 8, such as a hard disk or memory of the electronic device 8. In other embodiments, the memory 81 may also be an external storage device of the electronic device 8, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 8. In one embodiment, the memory 81 may also include both an internal storage unit of the electronic device 8 and an external storage device. The memory 81 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory 81 may also be used to temporarily store data that has been output or is to be output.

[0183] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0184] An embodiment of the present application also provides an electronic device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps of any of the above-mentioned method embodiments when executing the computer program.

[0185] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0186] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0187] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0188] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0189] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0190] In the embodiments provided in the present application, it should be understood that the disclosed devices, electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0191] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0192] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A disk storage system, characterized in that: include: at least one data block, the data block being obtained by dividing the total capacity of the disk according to a fixed block size; The block index table stored in the block index data block includes a block index node corresponding to each of the data blocks, the block index node includes a data block type and file ownership information, the file ownership information is used to characterize the file to which the data stored in the data block corresponding to the block index node belongs, and the data block type includes a free block, a file index block, a data index block and a target data block; The file index table stored in the file index block includes a file index node corresponding to each data file stored in the disk, and the file index node includes information of the data file and an identifier of the data index block; and a data index table stored in the data index block, including a data index node corresponding to each sub-file of the data file, wherein the data index node includes information of the sub-file and an identifier of a target data block storing the sub-file; Wherein, the at least one data block includes the block index data block, the file index block, the data index block, and the target data block; each of the data blocks except the block index data block stores a backup block index node, and the backup block index node is a backup of the block index node corresponding to the data block; the target data block stores the sub-files and the backup data index nodes corresponding to each of the sub-files, and the backup data index nodes are backups of the data index nodes corresponding to the sub-files.

2. The system according to claim 1, characterized in that The block index node includes a sequence number of the video data block, and a start time and an end time of the video stored in the target data block; The information of the sub-file includes the time point of the video data corresponding to the data index node.

3. The system according to claim 1 or 2, characterized in that: The block index node also includes a first video channel number and a first check value; The file index node also includes first node status information and a second check value; the information of the data file includes a second video channel number corresponding to the video file, a file attribution stamp, and the start time and end time of the video file; The data index node also includes second node status information and a third check value; the sub-file information includes a third video channel number, video data length and offset corresponding to the video file.

4. A data recovery method, characterized in that: Applied to a disk storage system, the method comprises: If the block index data block is damaged, read the backup block index node stored in each data block, and write each of the backup block data index nodes into the backup block index data block to restore the block index data block; If the file index block is damaged, the file index node in the file index table is reconstructed according to each data index node in the data index table and the block index node corresponding to the data index block; If the data index block is damaged, determine the target data blocks belonging to the same data file according to the file ownership information in each block index node in the block index table; traverse the target data blocks belonging to the same data file to obtain the backup data index nodes of each sub-file in the target data block; reconstruct the data index table according to the backup data index nodes and write them into the free blocks; Wherein, the disk storage system comprises: at least one data block, the data block being obtained by dividing the total capacity of the disk according to a fixed block size; The block index table stored in the block index data block includes the block index nodes corresponding to each of the data blocks, the block index nodes include data block types and the file ownership information, the file ownership information is used to characterize the file to which the data stored in the data block corresponding to the block index node belongs, and the data block types include free blocks, file index blocks, data index blocks and target data blocks; The file index table stored in the file index block includes the file index nodes corresponding to the respective data files stored in the disk, and the file index nodes include the information of the data files and the identifier of the data index block; and the data index table stored in the data index block includes the data index nodes corresponding to the respective sub-files of the data file, the data index nodes including the information of the sub-files and the identifier of the target data block storing the sub-files; Wherein, the at least one data block includes the block index data block, the file index block, the data index block, and the target data block; each of the data blocks except the block index data block stores a backup block index node, and the backup block index node is a backup of the block index node corresponding to the data block; the target data block stores the sub-files and the backup data index nodes corresponding to each of the sub-files, and the backup data index nodes are backups of the data index nodes corresponding to the sub-files.

5. The method according to claim 4, characterized in that The block index node includes the sequence number of the video data block, and the start time and end time of the video stored in the target data block; the information of the sub-file includes the time point of the video data corresponding to the data index node; If the file index block is damaged, the method further includes: Get the target time period; Determine the target data blocks that belong to the target time period and the same data file according to the file ownership information in each block index node in the block index table and the start time and end time of the video stored in the target data block; According to the size of the sequential number of the video data blocks, traverse the target data blocks that belong to the target time period and belong to the same data file, and determine whether the time of each backup data index node in the target data block is within the target time period according to the video data time point corresponding to the data index node; If so, the video data corresponding to the backup data index node is read, and all the video data are stored to obtain the video file data corresponding to the target time period.

6. The method according to claim 4, characterized in that The block index node also includes a first video channel number and a first check value; The file index node also includes first node status information and a second check value; the information of the data file includes a second video channel number corresponding to the video file, a file attribution stamp, and the start time and end time of the video file; The data index node also includes second node status information and a third check value; the sub-file information includes a third video channel number, video data length and offset corresponding to the video file.

7. A method for writing data, characterized in that: Applied to the disk storage system according to any one of claims 1 to 3, the method comprises: According to the data block type in the block index node, determine the free block as the data block to be written; Constructing a block index node of the data block to be written in the block index table, and backing up the block index node of the data block to be written to the data block to be written; Constructing a file index node of the file to be written in the file index table, and constructing a data index node of the sub-file of the file to be written in the data index table; The sub-file of the file to be written is stored in a target data block, and the data index node is backed up to the target data block.

8. A method for reading data, characterized in that: Applied to the disk storage system according to any one of claims 1 to 3, the method comprises: Traverse the block index table and find the file index block according to the data block type of the block index node; Traversing the file index table in the file index block to obtain the file index node of the file to be read; According to the file index node, searching for a data index block; The data index table in the data index block is traversed to read the to-be-read file stored in the target data block.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 4 to 6 or 7 or 8 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 4 to 6 or 7 or 8 is implemented.

Citation Information

Patent Citations

  • File management method and system, electronic equipment and storage medium

    CN110018998A

  • Data storage method, system and terminal device

    CN110149803A