[go: up one dir, main page]

WO2020077534A1 - Disk management method, disk management apparatus, and electronic device - Google Patents

Disk management method, disk management apparatus, and electronic device Download PDF

Info

Publication number
WO2020077534A1
WO2020077534A1 PCT/CN2018/110489 CN2018110489W WO2020077534A1 WO 2020077534 A1 WO2020077534 A1 WO 2020077534A1 CN 2018110489 W CN2018110489 W CN 2018110489W WO 2020077534 A1 WO2020077534 A1 WO 2020077534A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
disk
data
video file
usage information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2018/110489
Other languages
French (fr)
Chinese (zh)
Inventor
王斌
刘文涛
归建章
苏晓天
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Streamax Technology Co Ltd
Original Assignee
Streamax Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Streamax Technology Co Ltd filed Critical Streamax Technology Co Ltd
Priority to PCT/CN2018/110489 priority Critical patent/WO2020077534A1/en
Priority to CN201880001664.6A priority patent/CN109496292B/en
Publication of WO2020077534A1 publication Critical patent/WO2020077534A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools

Definitions

  • the present application belongs to the technical field of vehicle-mounted equipment, and particularly relates to a disk management method, a disk management apparatus, electronic equipment, and a computer-readable storage medium.
  • Vehicle-mounted devices usually operate under harsh conditions such as unstable voltage, abnormal power failure, high temperature, and vibration. At present, ordinary disks often suffer from partial data damage under such harsh conditions.
  • Standard storage management systems used for ordinary disks such as FAT32, NTFS, EXT2, etc., usually set the minimum storage unit to be relatively small. After repeated deletion and writing of data, a large amount of disk fragmentation will occur, resulting in disk Read and write performance drops.
  • the present application provides a disk management method, a disk management device, an electronic device, and a computer-readable storage medium, which can improve disk read and write performance to a certain extent.
  • the first aspect of the present application provides a disk management method, including:
  • the disk is read through the first data block.
  • the second aspect of the present application provides a disk management device, including:
  • the dividing unit is used to divide the disk into more than one data block, wherein the capacity of the above data block is calculated by a preset formula
  • the scanning unit is used to scan the usage information of each data block of the disk
  • a storage unit configured to store usage information of each data block obtained by scanning in a preset first data block
  • the reading unit is configured to read the disk through the first data block when the disk system is started.
  • a third aspect of the present application provides an electronic device.
  • the electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the computer program as described above. The steps of the method of the first aspect.
  • a fourth aspect of the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect described above are implemented.
  • a fifth aspect of the present application provides a computer program product.
  • the computer program product includes a computer program.
  • the steps of the method according to the first aspect described above are implemented.
  • the disk is first divided into more than one data block, wherein the capacity of the above data block is calculated by a preset formula, and then the usage information of each data block of the above disk is scanned and the The usage information of each data block obtained by scanning is stored in a preset first data block, and when the disk system is started, the disk is read through the first data block.
  • the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write the disk, the specific data block can be used to quickly locate and improve the disk read and write to a certain extent performance.
  • FIG. 1 is an implementation flowchart of a disk management method provided by an embodiment of the present application
  • FIG. 3 is a structural block diagram of a disk management device provided by an embodiment of the present application.
  • FIG. 4 is a structural block diagram of an electronic device provided by an embodiment of the present application.
  • the disk management method in the embodiment of the present application includes:
  • step 101 the disk is divided into more than one data block
  • the capacity of the data block cannot be too small. If it is too small, the data block will be allocated more frequently during recording, and the data dispersion will be large, which will affect the read and write efficiency of the disk; the data block The capacity cannot be too large, because the smallest allocation unit is the size of the data block, so too much data block capacity is easy to cause waste of space; at the same time, in order not to let the disk usage information be recorded in multiple data blocks scattered, avoid adding program logic Complexity, the total number of data blocks on the disk cannot exceed the size that one data block can record.
  • the size of the data block is set to not less than 4 megabytes, and the size of the data block is increased by 4 megabytes, that is, the data block size is an integer multiple of 4 megabytes.
  • the capacity of the above-mentioned data block is calculated by a preset formula, where it is set that recording the usage information of one data block requires 32 bytes, then the above-mentioned preset formula is:
  • the total capacity of the disk is a trillion
  • the capacity of the one data block is b times 4 trillion, that is, the capacity of the data block is 4b trillion
  • the above preset formula find the minimum b value that satisfies the above formula, Obtain the specific value of the above data block capacity of 4b trillion.
  • b is a positive integer.
  • step 102 scan the usage information of each data block of the disk
  • the above usage information includes but is not limited to: data block attribution stamp, data block location, start time of video file in the data block, end time of video file in the data block, data Block type and data block parity, wherein the data block attribution stamp indicates the complete video file to which the data block belongs.
  • data block attribution stamp indicates the complete video file to which the data block belongs.
  • a video file File1 has a video time span of 18: 00-18: 05.
  • the above-mentioned video file File1 needs to be stored together through two data blocks, data block 1 and data block 2, then the above data
  • the data block attribution stamps of block 1 and data block 2 indicate that the two belong to the above-mentioned video file File1;
  • the above-mentioned data block 1 stores the video content in the video file File1 with a time span of 18: 00-18: 03.
  • Data block 2 stores the video content in the video file File1 with a time span of 18: 03-18: 05.
  • the start time of the video file in the data block is 18:00 and the data block
  • the end time of the internal video file is 18:03; for the above data block 2, the start time of the video file in the data block is 18:03, and the end time of the video file in the data block is 18:05; the above video block type indication
  • the status of data blocks, including idle data blocks, recording (backup) data blocks, and video data blocks; the location of the above data blocks is specifically expressed by the internal number of the video file, that is, the visual number can be determined by the internal number of the video file.
  • the above-mentioned usage information together constitute a usage structure of a data block, occupying 32 bytes. For idle data blocks and video data blocks, the first 32 bytes of the data block store the usage information of the data block.
  • step 103 the usage information of each data block obtained by scanning is stored in a preset first data block
  • the data block at a specific location of the disk is used as the first data block, and the first data block is dedicated to storing usage information of each data block, that is, the The data block type of a data block is a recording data block, where the above-mentioned specified location may be the first data block in the disk, or may be another location specified by the user, and the above-mentioned specific location is not limited here.
  • the usage information of each data block obtained by the scan is stored in the first data block.
  • step 104 when the disk system is started, the disk is read through the first data block.
  • the above-mentioned disks are globally scanned to obtain the disk usage status, which lays the foundation for subsequent read and write operations; however, since each time it needs to be rescanned, it A certain amount of time will be wasted; in order to realize the quick start of the disk and understand the usage of the disk in time, the usage information of each data block of the disk has been stored in the first data block in step 103, so when the disk is read, You only need to read the first data block to quickly know the disk usage.
  • the usage information of each data block recorded in the first data block corresponds to the address of the data block, for example, the usage information of the first data block in the first data block corresponds to the disk
  • the usage information of the first data block, the usage information of the second data block in the first data block corresponds to the usage information of the second data block in the disk, so that there is no need to establish an additional index relationship
  • the usage information of each data block stored in the first data block is mapped into an actual storage unit (ie, data block).
  • the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be quickly positioned, and to a certain extent Improve disk read and write performance.
  • Embodiment 2 of this application provides another disk management method.
  • the following describes another disk management method provided in Embodiment 2 of the present application.
  • the disk management method in Embodiment 2 of the present application includes:
  • step 201 the disk is divided into more than one data block
  • step 202 scan the usage information of each data block of the disk
  • step 203 the usage information of each data block obtained by scanning is stored in a preset first data block
  • the above steps 201, 202, and 203 are the same as or similar to the above steps 101, 102, and 103, respectively.
  • step 204 the first data block is backed up to a preset second data block, so that the first data block and the second data block are mutually backed up;
  • the data stored in the first data block can be backed up to the preset second data block, so that even if the first data block is damaged, the data can be quickly restore.
  • the positions of the second data block and the first data block are separated by at least a preset distance, so as to avoid that the first data block and the second data block are simultaneously damaged.
  • the first data block and the second data block can be allocated to a fixed location on the disk, such as One data block block is set as the first data block, and the 401st data block of the disk is set as the second data block.
  • the distance between the first data block and the second data block is 400 data blocks, and the distance is an empirical value. , It is physically separated by several tracks, which can effectively prevent the two from being damaged at the same time.
  • the data block type of the second data block is a backup data block.
  • step 205 when the disk system is started, it is detected whether the first data block is damaged, if yes, step 207 is performed, if not, step 106 is performed;
  • step 206 read the disk through the first data block
  • step 207 the disk is read through the second data block.
  • the first data block and the second data block both record the usage information of the data blocks of the entire disk, when the disk starts, as long as the two data blocks are not damaged, no matter which one is read One data block can accurately obtain the above disk usage status.
  • the foregoing disk management method further includes:
  • a video file list is obtained based on the first data block mapping
  • the complete video file that satisfies the time condition is used as the search result.
  • a retrieval instruction when retrieval is required, a retrieval instruction is input, wherein the retrieval instruction includes a time condition, that is, a start time and an end time of the video file to be retrieved. Since the first data block stores usage information of each data block, and the above usage information can indicate the complete video file to which each data block belongs, therefore, according to the data block attribution stamp of each data block, the video stored in the disk can be mapped to The list of files, at the same time, the corresponding data blocks of each complete video file are obtained, for example, the above-mentioned video file File1 corresponds to data block 1 and data block 2; then, according to the start time of the video file in the data block of each data block and The end time of the video file in the data block determines the start time and end time of each complete video file.
  • the start time of the video file in the data block of the above data block 1 is 18:00, and the end time of the video file in the data block is 18:03; the start time of the video file in the data block of the above data block 2 is 18:03, and the end time of the video file in the data block is 18:05, because the data block 1 and the data block 2 constitute a complete video file, After splicing it, it can be seen that the start time of the complete video file File1 is 18:00 and the end time is 18:05.
  • the complete video file that meets the time condition is used as the search result, and the search result is output to the screen; if there are multiple search results, the search results are sorted in chronological order , Displayed in a list, after the user enters the selection instruction, the video file selected by the selection instruction is played for the user to view.
  • the 8 megabytes of data can be read in less than 0.067 seconds; that is, the first data block can be read in 0.067 seconds, and the usage status of the entire disk can be obtained to complete the retrieval of the video file. It should be noted that if the above-mentioned first data block is damaged, the above-mentioned retrieval process can be applied to the second data block, and retrieval is performed through the second data block.
  • the foregoing disk management method further includes:
  • the first data block After writing the data to be written into the data block to be written, the first data block is updated.
  • the free data blocks in the disk can be searched by the data block type in the usage information of each data block recorded in the first data block. If there are more than two free data blocks in the disk, the two or more free data blocks can be freed.
  • the free data block at the front is the data block to be written; alternatively, any data block can be randomly designated as the data block to be written, and the determination method of the written data block is not limited here. After the data to be written is written into the data block to be written, the data block to be written has already been written with data, that is, the usage information of the data block has been changed.
  • the first data block is updated, and at the same time, after the first data block is updated, the updated data is backed up to the second data block, that is, the first data block and the second data block are kept as backups for each other at any time. It should be noted that if the above-mentioned first data block is damaged, the above-mentioned writing process may be applied to the second data block, and writing is performed through the second data block.
  • the foregoing disk management method further includes:
  • the usage information is restored through the second data block.
  • the first data block and the second data block are mutually backup, and the two are far apart, generally no damage will occur at the same time, so the use of the data block stored in the first data block or the second data block
  • the above-mentioned second data block or the first data block can be used to restore the usage information stored by itself.
  • the usage information of the same data block stored in the first data block and the second data block is damaged, only the first 32 bytes of the corresponding data block need to be read to obtain the data block again And restore the usage information read again to the corresponding positions of the first data block and the second data block.
  • the above-mentioned recovery process can also be referred to to recover the damaged usage information through the first data block, which is not limited here.
  • the foregoing disk management method further includes:
  • the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be quickly positioned, and to a certain extent Improve disk read and write performance.
  • the specific data block can be quickly positioned, and to a certain extent Improve disk read and write performance.
  • Embodiment 3 of the present application provides a disk management apparatus.
  • the above disk management apparatus may be integrated into an electronic device.
  • the disk management apparatus 300 in the embodiment of the present application includes:
  • the dividing unit 301 is used to divide the disk into more than one data block, wherein the capacity of the above data block is calculated by a preset formula
  • the scanning unit 302 is configured to scan the usage information of each data block of the disk
  • the storage unit 303 is configured to store usage information of each data block obtained by scanning in a preset first data block;
  • the reading unit 304 is configured to read the disk through the first data block when the disk system is started.
  • the above-mentioned disk management device 300 further includes:
  • a backup unit configured to backup the first data block to a preset second data block, so that the first data block and the second data block are mutually backed up, wherein the second data block and the first data The positions of the blocks are separated by at least a preset distance;
  • the reading unit 304 includes:
  • a first data block detection subunit configured to detect whether the first data block is damaged
  • a first data block reading subunit configured to read the disk through the first data block if the first data block is not damaged
  • the second data block reading subunit is used to read the disk through the second data block if the first data block is damaged.
  • the above-mentioned usage information includes: data block attribution stamp, data block position, start time of video file in the data block, end time of video file in the data block, data block type and data block check bit, wherein the above data
  • the block attribution stamp indicates the complete video file to which the above data block belongs.
  • the above-mentioned disk management device 300 further includes:
  • a file list obtaining unit configured to obtain a video file list based on the first data block mapping when receiving a search instruction, wherein the search instruction includes a time condition;
  • a data block obtaining unit configured to obtain a data block corresponding to each complete video file in the above-mentioned video file list
  • the time determination unit is used to determine the start time and end time of each complete video file based on the start time of the video file in the data block of each data block and the end time of the video file in the data block;
  • the retrieval result determination unit is used to take a complete video file that satisfies the above time condition as a retrieval result.
  • the reading unit 304 is further configured to read the first data block when receiving data to be written;
  • the disk management device 300 also includes:
  • a data block to be written determination unit configured to determine an idle data block in the disk as the data block to be written based on the first data block
  • a writing unit configured to write the data to be written into the data block to be written
  • the updating unit is configured to update the first data block after writing the data to be written into the data block to be written.
  • the reading unit 304 is further configured to read the first data block, and determine whether the corresponding usage information is damaged through the data block check bit;
  • the disk management device 300 also includes:
  • the recovery unit is configured to recover the use information through the second data block if there is damaged use information.
  • the disk management device stores the usage information of each data block in the disk in a specific data block, so that when the disk needs to be read and written, the specific data block can be used to quickly locate And to a certain extent, improve disk read and write performance.
  • the specific data block can be used to quickly locate And to a certain extent, improve disk read and write performance.
  • Embodiment 4 of the present application provides an electronic device, please refer to FIG. 4, the electronic device in the embodiment of the present application includes: a memory 401, one or more processors 402 (only one shown in FIG. 4) and stored in the memory A computer program on 401 that can run on a processor.
  • the memory 401 is used to store software programs and modules.
  • the processor 402 executes various functional applications and data processing by running the software programs and units stored in the memory 401 to obtain resources corresponding to the preset events. Specifically, the processor 402 implements the following steps by running the above computer program stored in the memory 401:
  • the disk is read through the first data block.
  • the processor 402 also implements the following steps by running the above computer program stored in the memory 401:
  • reading the disk through the first data block includes:
  • the disk is read through the second data block.
  • the usage information includes: data block attribution stamp, data block location, start time of video file in the data block, video in the data block The end time of the file, the type of the data block and the parity of the data block, wherein the data block attribution stamp indicates the complete video file to which the data block belongs.
  • the processor 402 further implements the following steps when running the above-mentioned computer program stored in the memory 401:
  • a video file list is obtained based on the first data block mapping, wherein the retrieval instruction includes a time condition
  • the complete video file that satisfies the above time conditions is used as the search result.
  • the processor 402 further implements the following steps by running the above computer program stored in the memory 401:
  • the first data block After writing the data to be written into the data block to be written, the first data block is updated.
  • the processor 402 further implements the following steps by running the above computer program stored in the memory 401:
  • the above electronic device may further include: one or more input devices 403 (only one shown in FIG. 4) and one or more output devices 404 (only one shown in FIG. 4).
  • the memory 401, the processor 402, the input device 403, and the output device 404 are connected through a bus 405.
  • the so-called processor 402 may be a central processing unit (Central Processing Unit (CPU), the processor can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (Application Specific Integrated Circuit (ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the input device 403 may include a keyboard, a touchpad, a fingerprint sensor (for collecting user's fingerprint information and fingerprint direction information), a microphone, etc.
  • the output device 404 may include a display, a speaker, and the like.
  • the memory 401 may include a read-only memory and a random access memory, and provide instructions and data to the processor 402. Part or all of the memory 401 may also include non-volatile random access memory. For example, the memory 401 may also store device type information.
  • the electronic device stores the usage information of each data block in the disk in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be used to quickly locate, and To a certain extent, improve disk read and write performance.
  • the specific data block can be used to quickly locate, and To a certain extent, improve disk read and write performance.
  • each functional unit and module is used as an example for illustration.
  • the above-mentioned functions can be allocated by different functional units
  • Module completion means that the internal structure of the above device is 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 may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above integrated unit may use hardware It can also be implemented in the form of software functional units.
  • the specific names of each functional unit and module are only for the purpose of distinguishing each other, and are not used to limit the protection scope of the present application.
  • the disclosed device and method may be implemented in other ways.
  • the system embodiments described above are only schematic.
  • the above-mentioned division of modules or units is only a division of logical functions.
  • there may be other divisions for example, multiple units or components may be combined Or it can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be 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.
  • the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.
  • the present application can implement all or part of the processes in the methods of the above embodiments, and can also be completed by instructing relevant hardware through a computer program.
  • the above computer program can be stored in a computer-readable storage medium When executed by the processor, the steps of the foregoing method embodiments may be implemented.
  • the above-mentioned computer program includes computer program code, and the above-mentioned computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the above-mentioned computer-readable storage medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, removable disk, magnetic disk, optical disk, computer-readable memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signals, telecommunication signals, and software distribution media.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • electrical carrier signals telecommunication signals
  • software distribution media software distribution media.
  • the content contained in the above computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in jurisdictions.
  • computer-readable storage The medium does not include electrical carrier signals and telecommunications signals.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Quality & Reliability (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

Disclosed are a disk management method, a disk management apparatus, an electronic device, and a computer readable storage medium. The disk management method comprises: equally dividing a disk into more than one data block, wherein a capacity of the data blocks is obtained by calculation according to a preset formula; scanning usage information of the data blocks of the disk; storing the usage information of the data blocks obtained by scanning into a preset first data block; and when a disk system is started, reading the disk by means of the first data block. By means of the solution of the present application, the reading and writing performance of the disk can be improved to a certain extent.

Description

一种磁盘管理方法、磁盘管理装置及电子设备Disk management method, disk management device and electronic equipment 技术领域Technical field

本申请属于车载设备技术领域,尤其涉及一种磁盘管理方法、磁盘管理装置、电子设备及计算机可读存储介质。The present application belongs to the technical field of vehicle-mounted equipment, and particularly relates to a disk management method, a disk management apparatus, electronic equipment, and a computer-readable storage medium.

背景技术Background technique

车载设备通常运行在电压不稳、异常断电、高温、震动等恶劣条件下,目前普通磁盘在这类恶劣条件下经常会出现部分数据损坏。Vehicle-mounted devices usually operate under harsh conditions such as unstable voltage, abnormal power failure, high temperature, and vibration. At present, ordinary disks often suffer from partial data damage under such harsh conditions.

技术问题technical problem

普通磁盘所采用的标准存储管理系统,如FAT32、NTFS、EXT2等,通常会将最小存储单元设置得比较小,在重复的删除及写入数据后,就会出现大量的磁盘碎片,从而导致磁盘的读写性能下降。Standard storage management systems used for ordinary disks, such as FAT32, NTFS, EXT2, etc., usually set the minimum storage unit to be relatively small. After repeated deletion and writing of data, a large amount of disk fragmentation will occur, resulting in disk Read and write performance drops.

技术解决方案Technical solution

有鉴于此,本申请提供了一种磁盘管理方法、磁盘管理装置、电子设备及计算机可读存储介质,可一定程度上提高磁盘读写性能。In view of this, the present application provides a disk management method, a disk management device, an electronic device, and a computer-readable storage medium, which can improve disk read and write performance to a certain extent.

本申请的第一方面提供了一种磁盘管理方法,包括:The first aspect of the present application provides a disk management method, including:

将磁盘等分为一个以上的数据块,其中,上述数据块的容量由预设公式计算得出;Divide the disk into more than one data block, where the capacity of the above data block is calculated by a preset formula;

扫描上述磁盘的各个数据块的使用信息;Scan the usage information of each data block of the above disk;

将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;Store the usage information of each data block obtained by scanning in a preset first data block;

在磁盘系统启动时,通过上述第一数据块读取上述磁盘。When the disk system is started, the disk is read through the first data block.

本申请的第二方面提供了一种磁盘管理装置,包括:The second aspect of the present application provides a disk management device, including:

划分单元,用于将磁盘等分为一个以上的数据块,其中,上述数据块的容量由预设公式计算得出;The dividing unit is used to divide the disk into more than one data block, wherein the capacity of the above data block is calculated by a preset formula;

扫描单元,用于扫描上述磁盘的各个数据块的使用信息;The scanning unit is used to scan the usage information of each data block of the disk;

存储单元,用于将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;A storage unit, configured to store usage information of each data block obtained by scanning in a preset first data block;

读取单元,用于在磁盘系统启动时,通过上述第一数据块读取上述磁盘。The reading unit is configured to read the disk through the first data block when the disk system is started.

本申请的第三方面提供了一种电子设备,上述电子设备包括存储器、处理器以及存储在上述存储器中并可在上述处理器上运行的计算机程序,上述处理器执行上述计算机程序时实现如上述第一方面的方法的步骤。A third aspect of the present application provides an electronic device. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program as described above. The steps of the method of the first aspect.

本申请的第四方面提供了一种计算机可读存储介质,上述计算机可读存储介质存储有计算机程序,上述计算机程序被处理器执行时实现如上述第一方面的方法的步骤。A fourth aspect of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect described above are implemented.

本申请的第五方面提供了一种计算机程序产品,上述计算机程序产品包括计算机程序,上述计算机程序被一个或多个处理器执行时实现如上述第一方面的方法的步骤。A fifth aspect of the present application provides a computer program product. The computer program product includes a computer program. When the computer program is executed by one or more processors, the steps of the method according to the first aspect described above are implemented.

有益效果Beneficial effect

由上可见,通过本申请方案,首先将磁盘等分为一个以上的数据块,其中,上述数据块的容量由预设公式计算得出,然后扫描上述磁盘的各个数据块的使用信息,并将扫描得到的各个数据块的使用信息存放于预设的第一数据块中,在磁盘系统启动时,通过上述第一数据块读取上述磁盘。在本申请方案中,将磁盘中各个数据块的使用信息存放于一个特定的数据块,使得在需要读写磁盘时,可通过该特定的数据块实现快速定位,并且一定程度上提高磁盘读写性能。It can be seen from the above that through this application scheme, the disk is first divided into more than one data block, wherein the capacity of the above data block is calculated by a preset formula, and then the usage information of each data block of the above disk is scanned and the The usage information of each data block obtained by scanning is stored in a preset first data block, and when the disk system is started, the disk is read through the first data block. In the solution of the present application, the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write the disk, the specific data block can be used to quickly locate and improve the disk read and write to a certain extent performance.

附图说明BRIEF DESCRIPTION

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only for the application In some embodiments, for those of ordinary skill in the art, without paying creative labor, other drawings may be obtained based on these drawings.

图1是本申请实施例提供的磁盘管理方法的一种实现流程图;FIG. 1 is an implementation flowchart of a disk management method provided by an embodiment of the present application;

图2是本申请实施例提供的磁盘管理方法的另一种实现流程图;2 is another implementation flowchart of a disk management method provided by an embodiment of the present application;

图3是本申请实施例提供的磁盘管理装置的结构框图;3 is a structural block diagram of a disk management device provided by an embodiment of the present application;

图4是本申请实施例提供的电子设备的结构框图。4 is a structural block diagram of an electronic device provided by an embodiment of the present application.

本发明的实施方式Embodiments of the invention

以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structure and technology are proposed to thoroughly understand the embodiments of the present application. However, those skilled in the art should understand that the present application can 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 so as not to obscure the description of the present application with unnecessary details.

为了说明本申请上述的技术方案,下面通过具体实施例来进行说明。In order to explain the above technical solutions of the present application, the following will be described with specific embodiments.

实施例1Example 1

下面对本申请实施例提供的一种磁盘管理方法进行描述,请参阅图1,本申请实施例中的磁盘管理方法包括:The following describes a disk management method provided by an embodiment of the present application. Referring to FIG. 1, the disk management method in the embodiment of the present application includes:

在步骤101中,将磁盘等分为一个以上的数据块;In step 101, the disk is divided into more than one data block;

在本申请实施例中,数据块的容量不能够太小,如果太小会则会导致录像时,分配数据块比较频繁,同时导致数据的离散性大,会影响磁盘的读写效率;数据块的容量也不能太大,由于最小分配单位为数据块大小,所以数据块容量太大则容易导致空间浪费;同时,为了不让磁盘的使用信息分散记录在多个数据块中,避免增加程序逻辑的复杂度,磁盘的数据块的总数不能超过一个数据块能够记录的大小。基于此,设定数据块的大小不低于4兆,且数据块的大小以4兆递增,即数据块大小为4兆的整数倍。具体地,上述数据块的容量上述数据块的容量由预设公式计算得出,其中,设定记录一个数据块的使用信息需要占用32个字节,则上述预设公式为:In the embodiment of the present application, the capacity of the data block cannot be too small. If it is too small, the data block will be allocated more frequently during recording, and the data dispersion will be large, which will affect the read and write efficiency of the disk; the data block The capacity cannot be too large, because the smallest allocation unit is the size of the data block, so too much data block capacity is easy to cause waste of space; at the same time, in order not to let the disk usage information be recorded in multiple data blocks scattered, avoid adding program logic Complexity, the total number of data blocks on the disk cannot exceed the size that one data block can record. Based on this, the size of the data block is set to not less than 4 megabytes, and the size of the data block is increased by 4 megabytes, that is, the data block size is an integer multiple of 4 megabytes. Specifically, the capacity of the above-mentioned data block is calculated by a preset formula, where it is set that recording the usage information of one data block requires 32 bytes, then the above-mentioned preset formula is:

(4b×1024×1024)÷32×(4b×1024×1024)≥(a×1024×1024)(4b × 1024 × 1024) ÷ 32 × (4b × 1024 × 1024) ≥ (a × 1024 × 1024)

其中,上述磁盘的总容量为a兆,上述一个数据块的容量为4兆的b倍,即数据块容量为4b兆,根据上述预设公式,求出满足上述公式的最小b值,即可得到上述数据块容量4b兆的具体数值。需要注意的是,上述b为正整数。Among them, the total capacity of the disk is a trillion, the capacity of the one data block is b times 4 trillion, that is, the capacity of the data block is 4b trillion, according to the above preset formula, find the minimum b value that satisfies the above formula, Obtain the specific value of the above data block capacity of 4b trillion. It should be noted that b is a positive integer.

在步骤102中,扫描上述磁盘的各个数据块的使用信息;In step 102, scan the usage information of each data block of the disk;

在本申请实施例中,在本申请实施例中,上述使用信息包括但不限于:数据块归属戳、数据块位置、数据块内视频文件的开始时间、数据块内视频文件的结束时间、数据块类型及数据块校验位,其中,所述数据块归属戳指示了所述数据块所属的完整视频文件。例如,某一视频文件File1的视频时间跨度为18:00-18:05,由于数据过大,需要通过数据块1及数据块2这两个数据块共同存储上述视频文件File1,那么,上述数据块1及数据块2的数据块归属戳则指示了二者属于上述视频文件File1;上述数据块1所存储的是视频文件File1中,时间跨度为18:00-18:03的视频内容,上述数据块2所存储的是视频文件File1中,时间跨度为18:03-18:05的视频内容,则对于上述数据块1,其数据块内视频文件的开始时间为18:00,其数据块内视频文件的结束时间为18:03;对于上述数据块2,其数据块内视频文件的开始时间为18:03,其数据块内视频文件的结束时间为18:05;上述视频块类型指示了数据块的状态,包括空闲数据块、记录(备份)数据块及视频数据块;上述数据块位置具体通过视频文件内部编号表达,即通过上述视频文件内部编号能够确定该视频文件的数据块位置;上述数据块校验位用于通过该值判断该数据块所存储的数据是否合法。上述使用信息共同构成了一个数据块的使用信息结构体,占用32字节,对空闲数据块及视频数据块,其数据块的前32字节存储了本数据块的使用信息。In the embodiment of the present application, in the embodiment of the present application, the above usage information includes but is not limited to: data block attribution stamp, data block location, start time of video file in the data block, end time of video file in the data block, data Block type and data block parity, wherein the data block attribution stamp indicates the complete video file to which the data block belongs. For example, a video file File1 has a video time span of 18: 00-18: 05. Because the data is too large, the above-mentioned video file File1 needs to be stored together through two data blocks, data block 1 and data block 2, then the above data The data block attribution stamps of block 1 and data block 2 indicate that the two belong to the above-mentioned video file File1; the above-mentioned data block 1 stores the video content in the video file File1 with a time span of 18: 00-18: 03. Data block 2 stores the video content in the video file File1 with a time span of 18: 03-18: 05. For the above data block 1, the start time of the video file in the data block is 18:00 and the data block The end time of the internal video file is 18:03; for the above data block 2, the start time of the video file in the data block is 18:03, and the end time of the video file in the data block is 18:05; the above video block type indication The status of data blocks, including idle data blocks, recording (backup) data blocks, and video data blocks; the location of the above data blocks is specifically expressed by the internal number of the video file, that is, the visual number can be determined by the internal number of the video file. Location of the file data blocks; said data block check bits for the value to determine whether the data stored in the data block legitimate. The above-mentioned usage information together constitute a usage structure of a data block, occupying 32 bytes. For idle data blocks and video data blocks, the first 32 bytes of the data block store the usage information of the data block.

在步骤103中,将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;In step 103, the usage information of each data block obtained by scanning is stored in a preset first data block;

在本申请实施例中,在本申请实施例中,将磁盘特定位置的数据块作为上述第一数据块,上述第一数据块专用于存储各个数据块的使用信息,也即是说,上述第一数据块的数据块类型为记录数据块,其中,上述指定位置可以是磁盘中的第一个数据块,也可以是用户指定的其它位置,此处不对上述特定位置作出限定。在对磁盘进行了全盘扫描后,将扫描得到的各个数据块的使用信息存放于上述第一数据块中。In the embodiment of the present application, in the embodiment of the present application, the data block at a specific location of the disk is used as the first data block, and the first data block is dedicated to storing usage information of each data block, that is, the The data block type of a data block is a recording data block, where the above-mentioned specified location may be the first data block in the disk, or may be another location specified by the user, and the above-mentioned specific location is not limited here. After a full disk scan is performed on the disk, the usage information of each data block obtained by the scan is stored in the first data block.

在步骤104中,在磁盘系统启动时,通过上述第一数据块读取上述磁盘。In step 104, when the disk system is started, the disk is read through the first data block.

在本申请实施例中,正常情况下,在磁盘系统时,会对上述磁盘进行全局扫描,得到磁盘的使用状况,为后续读写操作打下基础;然而,由于每次启动时需要重新扫描,因而会浪费一定时间;为了能够实现磁盘的快速启动,及时了解磁盘的使用情况,在步骤103中已经将磁盘的各个数据块的使用信息存放于上述第一数据块中,因而在磁盘读取时,只需读取上述第一数据块,即可快速获知磁盘的使用状况。In the embodiment of the present application, under normal circumstances, during the disk system, the above-mentioned disks are globally scanned to obtain the disk usage status, which lays the foundation for subsequent read and write operations; however, since each time it needs to be rescanned, it A certain amount of time will be wasted; in order to realize the quick start of the disk and understand the usage of the disk in time, the usage information of each data block of the disk has been stored in the first data block in step 103, so when the disk is read, You only need to read the first data block to quickly know the disk usage.

具体地,上述第一数据块中所记录的各个数据块的使用信息和数据块的地址是一一对应的,比如,上述第一数据块中的第一条数据块的使用信息即对应磁盘中第一个数据块的使用信息,上述第一数据块中的第二条数据块的使用信息即对应磁盘中第二个数据块的使用信息,这样一来,不用额外的建立索引关系,即可从第一数据块中所存储的各个数据块的使用信息映射到实际的存储单元(即数据块)中。Specifically, the usage information of each data block recorded in the first data block corresponds to the address of the data block, for example, the usage information of the first data block in the first data block corresponds to the disk The usage information of the first data block, the usage information of the second data block in the first data block corresponds to the usage information of the second data block in the disk, so that there is no need to establish an additional index relationship, The usage information of each data block stored in the first data block is mapped into an actual storage unit (ie, data block).

由上可见,在本申请实施例中,将磁盘中各个数据块的使用信息存放于一个特定的数据块,使得在需要读写磁盘时,可通过该特定的数据块实现快速定位,并且一定程度上提高磁盘读写性能。As can be seen from the above, in the embodiment of the present application, the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be quickly positioned, and to a certain extent Improve disk read and write performance.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the order of execution, and 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.

实施例2Example 2

在实施例1的基础上,本申请实施例2提供了另一种磁盘管理方法。下面对本申请实施例2提供的另一种磁盘管理方法进行描述,请参阅图2,本申请实施例2中的磁盘管理方法包括:Based on Embodiment 1, Embodiment 2 of this application provides another disk management method. The following describes another disk management method provided in Embodiment 2 of the present application. Referring to FIG. 2, the disk management method in Embodiment 2 of the present application includes:

在步骤201中,将磁盘等分为一个以上的数据块;In step 201, the disk is divided into more than one data block;

在步骤202中,扫描上述磁盘的各个数据块的使用信息;In step 202, scan the usage information of each data block of the disk;

在步骤203中,将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;In step 203, the usage information of each data block obtained by scanning is stored in a preset first data block;

在本申请实施例中,在本申请实施例中,上述步骤201、202及203分别与上述步骤101、102及103相同或相似,具体可参见上述步骤101、102及103的相关描述,在此不再赘述。In the embodiments of the present application, in the embodiments of the present application, the above steps 201, 202, and 203 are the same as or similar to the above steps 101, 102, and 103, respectively. For details, please refer to the related descriptions of the above steps 101, 102, and 103. No longer.

在步骤204中,将上述第一数据块备份至预设的第二数据块中,使得上述第一数据块与上述第二数据块互为备份;In step 204, the first data block is backed up to a preset second data block, so that the first data block and the second data block are mutually backed up;

在本申请实施例中,由于车载环境恶劣,常出现突然断电或震动导致磁头写入数据异常,致使磁盘相应位置发生故障,甚至可能对相邻位置也产生影响,因而,为了在第一数据块损坏时也能够达到快速恢复的目的,可以将上述第一数据块所存储的数据备份至预设的第二数据块中,使得即便第一数据块出现信息损坏情况,也能实现数据的快速恢复。所述第二数据块与所述第一数据块的位置至少相隔预设距离,避免上述第一数据块及第二数据块被同时损坏。为了简单、快速的找到上述第一数据块及第二数据块,从而快速得到整个磁盘的使用状况,可以将上述第一数据块及第二数据块分配到磁盘的固定位置,如将磁盘的第1个数据块块设定为第一数据块,将磁盘的第401个数据块设定为第二数据块,上述第一数据块及第二数据块距离400个数据块,该距离为经验值,物理上已经相隔几个磁道,能有效避免二者被同时损坏,当然,也可以将用户指定的其它位置的数据块设定为第一数据块及第二数据块,此处不作限定;需要说明的是,一个磁盘中,仅需设定一个第一数据块及一个第二数据块。具体地,上述第二数据块的数据块类型为备份数据块。In the embodiment of the present application, due to the bad environment of the vehicle, sudden power failure or vibration often causes the data written by the magnetic head to be abnormal, resulting in a failure of the corresponding position of the disk, and may even affect the adjacent position. Therefore, in order to When the block is damaged, the purpose of fast recovery can also be achieved. The data stored in the first data block can be backed up to the preset second data block, so that even if the first data block is damaged, the data can be quickly restore. The positions of the second data block and the first data block are separated by at least a preset distance, so as to avoid that the first data block and the second data block are simultaneously damaged. In order to find the first data block and the second data block simply and quickly, so as to quickly obtain the usage status of the entire disk, the first data block and the second data block can be allocated to a fixed location on the disk, such as One data block block is set as the first data block, and the 401st data block of the disk is set as the second data block. The distance between the first data block and the second data block is 400 data blocks, and the distance is an empirical value. , It is physically separated by several tracks, which can effectively prevent the two from being damaged at the same time. Of course, you can also set the data block at other locations specified by the user as the first data block and the second data block, which is not limited here; It is explained that, in one disk, only one first data block and one second data block need to be set. Specifically, the data block type of the second data block is a backup data block.

在步骤205中,在磁盘系统启动时,检测上述第一数据块是否损坏,若是,则执行步骤207,若否,则执行步骤106;In step 205, when the disk system is started, it is detected whether the first data block is damaged, if yes, step 207 is performed, if not, step 106 is performed;

在步骤206中,通过上述第一数据块读取上述磁盘;In step 206, read the disk through the first data block;

在步骤207中,通过上述第二数据块读取上述磁盘。In step 207, the disk is read through the second data block.

在本申请实施例中,由于上述第一数据块及第二数据块均记录了整个磁盘的数据块的使用信息,因而在磁盘启动时,只要这两个数据块没有发生损坏,无论读取哪一个数据块都能准确获得上述磁盘的使用状况。In the embodiment of the present application, since the first data block and the second data block both record the usage information of the data blocks of the entire disk, when the disk starts, as long as the two data blocks are not damaged, no matter which one is read One data block can accurately obtain the above disk usage status.

可选地,在上述实施例1及实施例2中,上述磁盘管理方法还包括:Optionally, in the foregoing Embodiment 1 and Embodiment 2, the foregoing disk management method further includes:

当接收到检索指令时,基于所述第一数据块映射得到视频文件列表;When receiving the retrieval instruction, a video file list is obtained based on the first data block mapping;

获取所述视频文件列表中每个完整视频文件所对应的数据块;Obtaining a data block corresponding to each complete video file in the video file list;

基于各个数据块的数据块内视频文件的开始时间及数据块内视频文件的结束时间,确定各个完整视频文件的开始时间及结束时间;Based on the start time of the video file in the data block of each data block and the end time of the video file in the data block, determine the start time and end time of each complete video file;

将满足所述时间条件的完整视频文件作为检索结果。The complete video file that satisfies the time condition is used as the search result.

其中,在需要检索时,输入检索指令,其中,所述检索指令包括时间条件,也即需要检索得到的视频文件的开始时间及结束时间。由于第一数据块存储了各个数据块的使用信息,而上述使用信息可以指示各个数据块所属的完整视频文件,因而,根据各个数据块的数据块归属戳,可以映射得到磁盘中所存储的视频文件的列表,同时获取到每一完整视频文件所对应的数据块,例如,上述视频文件File1对应有数据块1及数据块2;随后,根据各个数据块的数据块内视频文件的开始时间及数据块内视频文件的结束时间,确定各个完整视频文件的开始时间及结束时间,例如,上述数据块1的数据块内视频文件的开始时间为18:00,数据块内视频文件的结束时间为18:03;上述数据块2的数据块内视频文件的开始时间为18:03,其数据块内视频文件的结束时间为18:05,由于申述数据块1及数据块2组成完整视频文件,将其拼接后,可知完整视频文件File1的开始时间为18:00,结束时间为18:05。在拼接完成各个完整视频文件后,将满足所述时间条件的完整视频文件作为检索结果,并将检索结果输出至屏幕;若存在多个检索结果,则将各个检索结果以时间先后等顺序进行排序,显示在一列表中,在用户输入选择指令后,播放选择指令所选择的视频文件供用户查看。通过上述检索流程,对于目前主流使用的1T至4T的磁盘,可根据上述实施例1中的公式计算出数据块的容量为8兆,目前的磁盘顺序读取速度一般都在120MB/s以上,即,8兆的数据不到0.067秒就能读取完成;也就是说,0.067秒就能将第一数据块读取完毕,能够获取到整个磁盘的使用状况,完成对视频文件的检索。需要注意的是,若上述第一数据块损坏,则可以将上述检索流程应用于第二数据块中,通过第二数据块进行检索。Wherein, when retrieval is required, a retrieval instruction is input, wherein the retrieval instruction includes a time condition, that is, a start time and an end time of the video file to be retrieved. Since the first data block stores usage information of each data block, and the above usage information can indicate the complete video file to which each data block belongs, therefore, according to the data block attribution stamp of each data block, the video stored in the disk can be mapped to The list of files, at the same time, the corresponding data blocks of each complete video file are obtained, for example, the above-mentioned video file File1 corresponds to data block 1 and data block 2; then, according to the start time of the video file in the data block of each data block and The end time of the video file in the data block determines the start time and end time of each complete video file. For example, the start time of the video file in the data block of the above data block 1 is 18:00, and the end time of the video file in the data block is 18:03; the start time of the video file in the data block of the above data block 2 is 18:03, and the end time of the video file in the data block is 18:05, because the data block 1 and the data block 2 constitute a complete video file, After splicing it, it can be seen that the start time of the complete video file File1 is 18:00 and the end time is 18:05. After splicing each complete video file, the complete video file that meets the time condition is used as the search result, and the search result is output to the screen; if there are multiple search results, the search results are sorted in chronological order , Displayed in a list, after the user enters the selection instruction, the video file selected by the selection instruction is played for the user to view. Through the above search process, for the currently used mainstream 1T to 4T disks, the capacity of the data block can be calculated according to the formula in the above embodiment 1 to 8 trillion, and the current disk sequential reading speed is generally above 120MB / s. That is, the 8 megabytes of data can be read in less than 0.067 seconds; that is, the first data block can be read in 0.067 seconds, and the usage status of the entire disk can be obtained to complete the retrieval of the video file. It should be noted that if the above-mentioned first data block is damaged, the above-mentioned retrieval process can be applied to the second data block, and retrieval is performed through the second data block.

可选地,在上述实施例1及实施例2中,上述磁盘管理方法还包括:Optionally, in the foregoing Embodiment 1 and Embodiment 2, the foregoing disk management method further includes:

当接收到待写入数据时,读取所述第一数据块;When receiving the data to be written, read the first data block;

基于所述第一数据块,确定所述磁盘中的一空闲数据块作为待写入数据块;Based on the first data block, determining a free data block in the disk as a data block to be written;

将所述待写入数据写入所述待写入数据块中;Writing the data to be written into the data block to be written;

在将所述待写入数据写入所述待写入数据块中后,更新所述第一数据块。After writing the data to be written into the data block to be written, the first data block is updated.

其中,可以通过上述第一数据块所记录的各个数据块的使用信息中的数据块类型查找磁盘中的空闲数据块,若磁盘中有两个以上空闲数据块,则可以将上述两个以上空闲数据块中,位置最前的空闲数据块作为待写入数据块;或者,也可以随机指定任一数据块作为待写入数据块,此处不对待写入数据块的确定方法做出限定。在将所述待写入数据写入所述待写入数据块中后,上述待写入数据块已经被写入了数据,也即该数据块的使用信息发生了更改,此时需要对上述第一数据块进行更新,同时在第一数据块更新完毕后,将更新的数据备份至第二数据块,也即随时保持上述第一数据块及第二数据块互为备份。需要注意的是,若上述第一数据块损坏,则可以将上述写入流程应用于第二数据块中,通过第二数据块进行写入。Wherein, the free data blocks in the disk can be searched by the data block type in the usage information of each data block recorded in the first data block. If there are more than two free data blocks in the disk, the two or more free data blocks can be freed. Among the data blocks, the free data block at the front is the data block to be written; alternatively, any data block can be randomly designated as the data block to be written, and the determination method of the written data block is not limited here. After the data to be written is written into the data block to be written, the data block to be written has already been written with data, that is, the usage information of the data block has been changed. The first data block is updated, and at the same time, after the first data block is updated, the updated data is backed up to the second data block, that is, the first data block and the second data block are kept as backups for each other at any time. It should be noted that if the above-mentioned first data block is damaged, the above-mentioned writing process may be applied to the second data block, and writing is performed through the second data block.

可选地,在上述实施例1及实施例2中,上述磁盘管理方法还包括:Optionally, in the foregoing Embodiment 1 and Embodiment 2, the foregoing disk management method further includes:

读取所述第一数据块,通过所述数据块校验位判断对应的使用信息是否被损坏;Reading the first data block, and judging whether the corresponding usage information is damaged by the data block check bit;

若存在被损坏的使用信息,则通过所述第二数据块恢复所述使用信息。If there is damaged usage information, the usage information is restored through the second data block.

其中,由于上述第一数据块及第二数据块互为备份,且二者相距较远,一般不会同时发生损坏,因而在上述第一数据块或者第二数据块所存储的数据块的使用信息发生损坏时,可以通过上述第二数据块或者第一数据块对自身所存储的使用信息进行恢复。可选地,即便发生上述第一数据块及第二数据块所存储的同一数据块的使用信息均被损坏的情形,也只需读取对应数据块的前32个字节再次获取该数据块的使用信息,并将再次读取到的使用信息恢复至第一数据块及第二数据块的相应位置。通过上述恢复流程,即使整个第一数据块及第二数据块被损坏,也只需读取每个数据块的起始32个字节,例如,针对4T字节的磁盘,每个数据块为8兆,那么总共有524288个数据块,只需读取524288个数据块的前32个字节,即只需读取524288*32字节=16兆的数据即可恢复整个4T磁盘的数据。当然,在第二数据块需要数据恢复时,也可以参照上述恢复流程,通过上述第一数据块恢复损坏的使用信息,此处不作限定。Among them, because the first data block and the second data block are mutually backup, and the two are far apart, generally no damage will occur at the same time, so the use of the data block stored in the first data block or the second data block When the information is damaged, the above-mentioned second data block or the first data block can be used to restore the usage information stored by itself. Optionally, even if the usage information of the same data block stored in the first data block and the second data block is damaged, only the first 32 bytes of the corresponding data block need to be read to obtain the data block again And restore the usage information read again to the corresponding positions of the first data block and the second data block. Through the above recovery process, even if the entire first data block and the second data block are damaged, only the first 32 bytes of each data block need to be read. For example, for a 4T-byte disk, each data block is 8 trillion, then there are a total of 524288 data blocks, only need to read the first 32 bytes of the 524288 data blocks, that is, only need to read the data of 524288 * 32 bytes = 16 trillion to restore the data of the entire 4T disk. Of course, when the second data block needs data recovery, the above-mentioned recovery process can also be referred to to recover the damaged usage information through the first data block, which is not limited here.

可选地,在上述实施例1及实施例2中,上述磁盘管理方法还包括:Optionally, in the foregoing Embodiment 1 and Embodiment 2, the foregoing disk management method further includes:

读取所述第一数据块;Reading the first data block;

基于所述第一数据块,确定所述磁盘中的存储的视频文件最早的数据块作为待覆盖数据块;Based on the first data block, determining the earliest data block of the video file stored in the disk as the data block to be overwritten;

将所述待覆盖数据块所存储的数据清除为空白数据块。Clear the data stored in the data block to be overwritten as a blank data block.

其中,对于用于监控的视频文件而言,为了在有限的磁盘空间下保证持续录像,需要采取覆盖时间较早的数据块的方式,才能保证视频文件的及时性及流畅性。需要注意的是,若上述第一数据块损坏,则可以将上述覆盖流程应用于第二数据块中,通过第二数据块进行覆盖。Among them, for the video files used for monitoring, in order to ensure continuous recording under the limited disk space, it is necessary to adopt the method of covering the data blocks with an earlier time to ensure the timeliness and fluency of the video files. It should be noted that if the above-mentioned first data block is damaged, the above-mentioned overwriting process can be applied to the second data block, and the second data block is used for overwriting.

由上可见,在本申请实施例中,将磁盘中各个数据块的使用信息存放于一个特定的数据块,使得在需要读写磁盘时,可通过该特定的数据块实现快速定位,并且一定程度上提高磁盘读写性能。在需要使用到磁盘时,不管是数据的检索、写入、恢复或覆盖,都能快速执行。As can be seen from the above, in the embodiment of the present application, the usage information of each data block in the disk is stored in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be quickly positioned, and to a certain extent Improve disk read and write performance. When you need to use the disk, whether it is data retrieval, writing, recovery or overwriting, it can be quickly executed.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the order of execution, and 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.

实施例3Example 3

本申请实施例3提供了一种磁盘管理装置,上述磁盘管理装置可集成于电子设备中,如图3所示,本申请实施例中的磁盘管理装置300包括:Embodiment 3 of the present application provides a disk management apparatus. The above disk management apparatus may be integrated into an electronic device. As shown in FIG. 3, the disk management apparatus 300 in the embodiment of the present application includes:

划分单元301,用于将磁盘等分为一个以上的数据块,其中,上述数据块的容量由预设公式计算得出;The dividing unit 301 is used to divide the disk into more than one data block, wherein the capacity of the above data block is calculated by a preset formula;

扫描单元302,用于扫描上述磁盘的各个数据块的使用信息;The scanning unit 302 is configured to scan the usage information of each data block of the disk;

存储单元303,用于将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;The storage unit 303 is configured to store usage information of each data block obtained by scanning in a preset first data block;

读取单元304,用于在磁盘系统启动时,通过上述第一数据块读取上述磁盘。The reading unit 304 is configured to read the disk through the first data block when the disk system is started.

可选地,上述磁盘管理装置300还包括:Optionally, the above-mentioned disk management device 300 further includes:

备份单元,用于将上述第一数据块备份至预设的第二数据块中,使得上述第一数据块与上述第二数据块互为备份,其中,上述第二数据块与上述第一数据块的位置至少相隔预设距离;A backup unit, configured to backup the first data block to a preset second data block, so that the first data block and the second data block are mutually backed up, wherein the second data block and the first data The positions of the blocks are separated by at least a preset distance;

上述读取单元304包括:The reading unit 304 includes:

第一数据块检测子单元,用于检测上述第一数据块是否损坏;A first data block detection subunit, configured to detect whether the first data block is damaged;

第一数据块读取子单元,用于若上述第一数据块未损坏,则通过上述第一数据块读取上述磁盘;A first data block reading subunit, configured to read the disk through the first data block if the first data block is not damaged;

第二数据块读取子单元,用于若上述第一数据块已损坏,则通过上述第二数据块读取上述磁盘。The second data block reading subunit is used to read the disk through the second data block if the first data block is damaged.

可选地,上述使用信息包括:数据块归属戳、数据块位置、数据块内视频文件的开始时间、数据块内视频文件的结束时间、数据块类型及数据块校验位,其中,上述数据块归属戳指示了上述数据块所属的完整视频文件。Optionally, the above-mentioned usage information includes: data block attribution stamp, data block position, start time of video file in the data block, end time of video file in the data block, data block type and data block check bit, wherein the above data The block attribution stamp indicates the complete video file to which the above data block belongs.

可选地,上述磁盘管理装置300还包括:Optionally, the above-mentioned disk management device 300 further includes:

文件列表获取单元,用于当接收到检索指令时,基于上述第一数据块映射得到视频文件列表,其中,上述检索指令包括时间条件;A file list obtaining unit, configured to obtain a video file list based on the first data block mapping when receiving a search instruction, wherein the search instruction includes a time condition;

数据块获取单元,用于获取上述视频文件列表中每个完整视频文件所对应的数据块;A data block obtaining unit, configured to obtain a data block corresponding to each complete video file in the above-mentioned video file list;

时间确定单元,用于基于各个数据块的数据块内视频文件的开始时间及数据块内视频文件的结束时间,确定各个完整视频文件的开始时间及结束时间;The time determination unit is used to determine the start time and end time of each complete video file based on the start time of the video file in the data block of each data block and the end time of the video file in the data block;

检索结果确定单元,用于将满足上述时间条件的完整视频文件作为检索结果。The retrieval result determination unit is used to take a complete video file that satisfies the above time condition as a retrieval result.

可选地,上述读取单元304,还用于当接收到待写入数据时,读取上述第一数据块;Optionally, the reading unit 304 is further configured to read the first data block when receiving data to be written;

上述磁盘管理装置300还包括:The disk management device 300 also includes:

待写入数据块确定单元,用于基于上述第一数据块,确定上述磁盘中的一空闲数据块作为待写入数据块;A data block to be written determination unit, configured to determine an idle data block in the disk as the data block to be written based on the first data block;

写入单元,用于将上述待写入数据写入上述待写入数据块中;A writing unit, configured to write the data to be written into the data block to be written;

更新单元,用于在将上述待写入数据写入上述待写入数据块中后,更新上述第一数据块。The updating unit is configured to update the first data block after writing the data to be written into the data block to be written.

可选地,上述读取单元304,还用于读取上述第一数据块,通过上述数据块校验位判断对应的使用信息是否被损坏;Optionally, the reading unit 304 is further configured to read the first data block, and determine whether the corresponding usage information is damaged through the data block check bit;

上述磁盘管理装置300还包括:The disk management device 300 also includes:

恢复单元,用于若存在被损坏的使用信息,则通过上述第二数据块恢复上述使用信息。The recovery unit is configured to recover the use information through the second data block if there is damaged use information.

由上可见,在本申请实施例中,磁盘管理装置将磁盘中各个数据块的使用信息存放于一个特定的数据块,使得在需要读写磁盘时,可通过该特定的数据块实现快速定位,并且一定程度上提高磁盘读写性能。在需要使用到磁盘时,不管是数据的检索、写入、恢复或覆盖,都能快速执行。As can be seen from the above, in the embodiment of the present application, the disk management device stores the usage information of each data block in the disk in a specific data block, so that when the disk needs to be read and written, the specific data block can be used to quickly locate And to a certain extent, improve disk read and write performance. When you need to use the disk, whether it is data retrieval, writing, recovery or overwriting, it can be quickly executed.

实施例4Example 4

本申请实施例4提供了一种电子设备,请参阅图4,本申请实施例中的电子设备包括:存储器401,一个或多个处理器402(图4中仅示出一个)及存储在存储器401上并可在处理器上运行的计算机程序。其中:存储器401用于存储软件程序以及模块,处理器402通过运行存储在存储器401的软件程序以及单元,从而执行各种功能应用以及数据处理,以获取上述预设事件对应的资源。具体地,处理器402通过运行存储在存储器401的上述计算机程序时实现以下步骤:Embodiment 4 of the present application provides an electronic device, please refer to FIG. 4, the electronic device in the embodiment of the present application includes: a memory 401, one or more processors 402 (only one shown in FIG. 4) and stored in the memory A computer program on 401 that can run on a processor. The memory 401 is used to store software programs and modules. The processor 402 executes various functional applications and data processing by running the software programs and units stored in the memory 401 to obtain resources corresponding to the preset events. Specifically, the processor 402 implements the following steps by running the above computer program stored in the memory 401:

将磁盘等分为一个以上的数据块,其中,上述数据块的容量由预设公式计算得出;Divide the disk into more than one data block, where the capacity of the above data block is calculated by a preset formula;

扫描上述磁盘的各个数据块的使用信息;Scan the usage information of each data block of the above disk;

将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;Store the usage information of each data block obtained by scanning in a preset first data block;

在磁盘系统启动时,通过上述第一数据块读取上述磁盘。When the disk system is started, the disk is read through the first data block.

假设上述为第一种可能的实施方式,则在第一种可能的实施方式作为基础而提供的第二种可能的实施方式中,在上述将扫描得到的各个数据块的使用信息存放于预设的第一数据块中之后,处理器402通过运行存储在存储器401的上述计算机程序时还实现以下步骤:Assuming that the above is the first possible implementation manner, in the second possible implementation manner provided as the basis of the first possible implementation manner, in the above, the usage information of each scanned data block is stored in a preset After the first data block, the processor 402 also implements the following steps by running the above computer program stored in the memory 401:

将上述第一数据块备份至预设的第二数据块中,使得上述第一数据块与上述第二数据块互为备份,其中,上述第二数据块与上述第一数据块的位置至少相隔预设距离;Backing up the first data block to a preset second data block, so that the first data block and the second data block are mutually backup, wherein the second data block and the first data block are at least separated from each other Preset distance

上述在磁盘系统启动时,通过上述第一数据块读取上述磁盘,包括:When the disk system is started, reading the disk through the first data block includes:

检测上述第一数据块是否损坏;Check whether the above first data block is damaged;

若上述第一数据块未损坏,则通过上述第一数据块读取上述磁盘;If the first data block is not damaged, read the disk through the first data block;

若上述第一数据块已损坏,则通过上述第二数据块读取上述磁盘。If the first data block is damaged, the disk is read through the second data block.

在上述第二种可能的实施方式作为基础而提供的第三种可能的实施方式中,上述使用信息包括:数据块归属戳、数据块位置、数据块内视频文件的开始时间、数据块内视频文件的结束时间、数据块类型及数据块校验位,其中,上述数据块归属戳指示了上述数据块所属的完整视频文件。In a third possible embodiment provided as the basis of the second possible embodiment above, the usage information includes: data block attribution stamp, data block location, start time of video file in the data block, video in the data block The end time of the file, the type of the data block and the parity of the data block, wherein the data block attribution stamp indicates the complete video file to which the data block belongs.

在上述第三种可能的实施方式作为基础而提供的第四种可能的实施方式中,处理器402通过运行存储在存储器401的上述计算机程序时还实现以下步骤:In the fourth possible embodiment provided as the basis of the third possible embodiment above, the processor 402 further implements the following steps when running the above-mentioned computer program stored in the memory 401:

当接收到检索指令时,基于上述第一数据块映射得到视频文件列表,其中,上述检索指令包括时间条件;When a retrieval instruction is received, a video file list is obtained based on the first data block mapping, wherein the retrieval instruction includes a time condition;

获取上述视频文件列表中每个完整视频文件所对应的数据块;Obtain the data block corresponding to each complete video file in the above video file list;

基于各个数据块的数据块内视频文件的开始时间及数据块内视频文件的结束时间,确定各个完整视频文件的开始时间及结束时间;Based on the start time of the video file in the data block of each data block and the end time of the video file in the data block, determine the start time and end time of each complete video file;

将满足上述时间条件的完整视频文件作为检索结果。The complete video file that satisfies the above time conditions is used as the search result.

在上述第三种可能的实施方式作为基础而提供的第五种可能的实施方式中,处理器402通过运行存储在存储器401的上述计算机程序时还实现以下步骤:In the fifth possible implementation manner provided as the basis of the above third possible implementation manner, the processor 402 further implements the following steps by running the above computer program stored in the memory 401:

当接收到待写入数据时,读取上述第一数据块;When receiving the data to be written, read the first data block;

基于上述第一数据块,确定上述磁盘中的一空闲数据块作为待写入数据块;Based on the first data block, determining an idle data block in the disk as a data block to be written;

将上述待写入数据写入上述待写入数据块中;Writing the data to be written into the data block to be written;

在将上述待写入数据写入上述待写入数据块中后,更新上述第一数据块。After writing the data to be written into the data block to be written, the first data block is updated.

在上述第三种可能的实施方式作为基础而提供的第六种可能的实施方式中,处理器402通过运行存储在存储器401的上述计算机程序时还实现以下步骤:In the sixth possible implementation manner provided as the basis of the third possible implementation manner described above, the processor 402 further implements the following steps by running the above computer program stored in the memory 401:

读取上述第一数据块,通过上述数据块校验位判断对应的使用信息是否被损坏;Reading the first data block, and judging whether the corresponding usage information is damaged by the data block check bit;

若存在被损坏的使用信息,则通过上述第二数据块恢复上述使用信息。If there is damaged usage information, the above usage information is restored through the above second data block.

进一步,如图4所示,上述电子设备还可包括:一个或多个输入设备403(图4中仅示出一个)和一个或多个输出设备404(图4中仅示出一个)。存储器401、处理器402、输入设备403和输出设备404通过总线405连接。Further, as shown in FIG. 4, the above electronic device may further include: one or more input devices 403 (only one shown in FIG. 4) and one or more output devices 404 (only one shown in FIG. 4). The memory 401, the processor 402, the input device 403, and the output device 404 are connected through a bus 405.

应当理解,在本申请实施例中,所称处理器402可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现成可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in the embodiment of the present application, the so-called processor 402 may be a central processing unit (Central Processing Unit (CPU), the processor can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (Application Specific Integrated Circuit (ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

输入设备403可以包括键盘、触控板、指纹采传感器(用于采集用户的指纹信息和指纹的方向信息)、麦克风等,输出设备404可以包括显示器、扬声器等。The input device 403 may include a keyboard, a touchpad, a fingerprint sensor (for collecting user's fingerprint information and fingerprint direction information), a microphone, etc., and the output device 404 may include a display, a speaker, and the like.

存储器401可以包括只读存储器和随机存取存储器,并向处理器402 提供指令和数据。存储器401的一部分或全部还可以包括非易失性随机存取存储器。例如,存储器401还可以存储设备类型的信息。The memory 401 may include a read-only memory and a random access memory, and provide instructions and data to the processor 402. Part or all of the memory 401 may also include non-volatile random access memory. For example, the memory 401 may also store device type information.

由上可见,在本申请实施例中,电子设备将磁盘中各个数据块的使用信息存放于一个特定的数据块,使得在需要读写磁盘时,可通过该特定的数据块实现快速定位,并且一定程度上提高磁盘读写性能。在需要使用到磁盘时,不管是数据的检索、写入、恢复或覆盖,都能快速执行。As can be seen from the above, in the embodiment of the present application, the electronic device stores the usage information of each data block in the disk in a specific data block, so that when it is necessary to read and write to the disk, the specific data block can be used to quickly locate, and To a certain extent, improve disk read and write performance. When you need to use the disk, whether it is data retrieval, writing, recovery or overwriting, it can be quickly executed.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将上述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for convenience and conciseness of description, only the above-mentioned division of each functional unit and module is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated by different functional units, Module completion means that the internal structure of the above device is 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 may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above integrated unit may use hardware It can also be implemented in the form of software functional units. In addition, the specific names of each functional unit and module are only for the purpose of distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working processes of the units and modules in the above system, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For a part that is not detailed or recorded in an embodiment, you can refer to the related descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者外部设备软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art may realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of external device software and electronic hardware. Whether these functions are executed in hardware or software depends on the specific application of the technical solution and design constraints. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

在本申请所提供的实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的系统实施例仅仅是示意性的,例如,上述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed device and method may be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the above-mentioned division of modules or units is only a division of logical functions. In actual implementation, there may be other divisions, for example, multiple units or components may be combined Or it can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.

上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be 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.

上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,上述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,上述计算机程序包括计算机程序代码,上述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。上述计算机可读存储介质可以包括:能够携带上述计算机程序代码的任何实体或装置、记录介质、U盘、移动磁盘、磁碟、光盘、计算机可读存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,上述计算机可读存储介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读存储介质不包括是电载波信号和电信信号。If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the processes in the methods of the above embodiments, and can also be completed by instructing relevant hardware through a computer program. The above computer program can be stored in a computer-readable storage medium When executed by the processor, the steps of the foregoing method embodiments may be implemented. Wherein, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code may be in the form of source code, object code, executable file or some intermediate form. The above-mentioned computer-readable storage medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, removable disk, magnetic disk, optical disk, computer-readable memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signals, telecommunication signals, and software distribution media. It should be noted that the content contained in the above computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in jurisdictions. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage The medium does not include electrical carrier signals and telecommunications signals.

以上上述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they can still perform the foregoing embodiments The recorded technical solutions are modified, or some of the technical features are equivalently replaced; and these 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 this application, and should be included in this Within the scope of protection applied for.

Claims (10)

一种磁盘管理方法,其特征在于,包括:A disk management method, characterized in that it includes: 将磁盘等分为一个以上的数据块,其中,所述数据块的容量由预设公式计算得出;Divide the disk into more than one data block, wherein the capacity of the data block is calculated by a preset formula; 扫描所述磁盘的各个数据块的使用信息;Scan the usage information of each data block of the disk; 将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;Store the usage information of each data block obtained by scanning in a preset first data block; 在磁盘系统启动时,通过所述第一数据块读取所述磁盘。When the disk system is started, the disk is read through the first data block. 如权利要求1所述的磁盘管理方法,其特征在于,在所述将扫描得到的各个数据块的使用信息存放于预设的第一数据块中之后,所述磁盘管理方法还包括:The disk management method according to claim 1, wherein after storing the usage information of each scanned data block in a preset first data block, the disk management method further comprises: 将所述第一数据块备份至预设的第二数据块中,使得所述第一数据块与所述第二数据块互为备份,其中,所述第二数据块与所述第一数据块的位置至少相隔预设距离;Backing up the first data block to a preset second data block, so that the first data block and the second data block are mutually backed up, wherein the second data block and the first data The positions of the blocks are separated by at least a preset distance; 所述在磁盘系统启动时,通过所述第一数据块读取所述磁盘,包括:When the disk system is started, reading the disk through the first data block includes: 检测所述第一数据块是否损坏;Detect whether the first data block is damaged; 若所述第一数据块未损坏,则通过所述第一数据块读取所述磁盘;If the first data block is not damaged, read the disk through the first data block; 若所述第一数据块已损坏,则通过所述第二数据块读取所述磁盘。If the first data block is damaged, the disk is read through the second data block. 如权利要求1或2所述的磁盘管理方法,其特征在于,所述使用信息包括:数据块归属戳、数据块位置、数据块内视频文件的开始时间、数据块内视频文件的结束时间、数据块类型及数据块校验位,其中,所述数据块归属戳指示了所述数据块所属的完整视频文件。The disk management method according to claim 1 or 2, wherein the usage information includes: data block attribution stamp, data block position, start time of video file in the data block, end time of video file in the data block, Data block type and data block check bit, wherein the data block attribution stamp indicates the complete video file to which the data block belongs. 如权利要求3所述的磁盘管理方法,其特征在于,所述磁盘管理方法还包括:The disk management method according to claim 3, wherein the disk management method further comprises: 当接收到检索指令时,基于所述第一数据块映射得到视频文件列表,其中,所述检索指令包括时间条件;When a retrieval instruction is received, a video file list is obtained based on the first data block mapping, where the retrieval instruction includes a time condition; 获取所述视频文件列表中每个完整视频文件所对应的数据块;Obtaining a data block corresponding to each complete video file in the video file list; 基于各个数据块的数据块内视频文件的开始时间及数据块内视频文件的结束时间,确定各个完整视频文件的开始时间及结束时间;Based on the start time of the video file in the data block of each data block and the end time of the video file in the data block, determine the start time and end time of each complete video file; 将满足所述时间条件的完整视频文件作为检索结果。The complete video file that satisfies the time condition is used as the search result. 如权利要求3所述的磁盘管理方法,其特征在于,所述磁盘管理方法还包括:The disk management method according to claim 3, wherein the disk management method further comprises: 当接收到待写入数据时,读取所述第一数据块;When receiving the data to be written, read the first data block; 基于所述第一数据块,确定所述磁盘中的一空闲数据块作为待写入数据块;Based on the first data block, determining a free data block in the disk as a data block to be written; 将所述待写入数据写入所述待写入数据块中;Writing the data to be written into the data block to be written; 在将所述待写入数据写入所述待写入数据块中后,更新所述第一数据块。After writing the data to be written into the data block to be written, the first data block is updated. 如权利要求3所述的磁盘管理方法,其特征在于,所述磁盘管理方法还包括:The disk management method according to claim 3, wherein the disk management method further comprises: 读取所述第一数据块,通过所述数据块校验位判断对应的使用信息是否被损坏;Reading the first data block, and judging whether the corresponding usage information is damaged by the data block check bit; 若存在被损坏的使用信息,则通过所述第二数据块恢复所述使用信息。If there is damaged usage information, the usage information is restored through the second data block. 一种磁盘管理装置,其特征在于,包括:A disk management device is characterized by comprising: 划分单元,用于将磁盘等分为一个以上的数据块,其中,所述数据块的容量由预设公式计算得出;A dividing unit is used to divide the disk into more than one data block, wherein the capacity of the data block is calculated by a preset formula; 扫描单元,用于扫描所述磁盘的各个数据块的使用信息;A scanning unit for scanning the usage information of each data block of the disk; 存储单元,用于将扫描得到的各个数据块的使用信息存放于预设的第一数据块中;A storage unit, configured to store usage information of each data block obtained by scanning in a preset first data block; 读取单元,用于在磁盘系统启动时,通过所述第一数据块读取所述磁盘。The reading unit is configured to read the disk through the first data block when the disk system is started. 如权利要求7所述的磁盘管理装置,其特征在于,所述磁盘管理装置还包括:The disk management device according to claim 7, wherein the disk management device further comprises: 备份单元,用于将所述第一数据块备份至预设的第二数据块中,使得所述第一数据块与所述第二数据块互为备份,其中,所述第二数据块与所述第一数据块的位置至少相隔预设距离;A backup unit, configured to backup the first data block to a preset second data block, so that the first data block and the second data block are mutually backed up, wherein the second data block is The positions of the first data blocks are at least separated by a preset distance; 所述读取单元包括:The reading unit includes: 第一数据块检测子单元,用于检测所述第一数据块是否损坏;A first data block detection subunit, configured to detect whether the first data block is damaged; 第一数据块读取子单元,用于若所述第一数据块未损坏,则通过所述第一数据块读取所述磁盘;A first data block reading subunit, configured to read the disk through the first data block if the first data block is not damaged; 第二数据块读取子单元,用于若所述第一数据块已损坏,则通过所述第二数据块读取所述磁盘。The second data block reading subunit is used to read the magnetic disk through the second data block if the first data block is damaged. 一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至6任一项所述方法的步骤。An electronic device, including a memory, a processor, and a computer program stored in the memory and runable on the processor, characterized in that, when the processor executes the computer program, it is implemented as claimed in claims 1 to 6. The steps of any one of the methods. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至6任一项所述方法的步骤。A computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
PCT/CN2018/110489 2018-10-16 2018-10-16 Disk management method, disk management apparatus, and electronic device Ceased WO2020077534A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/110489 WO2020077534A1 (en) 2018-10-16 2018-10-16 Disk management method, disk management apparatus, and electronic device
CN201880001664.6A CN109496292B (en) 2018-10-16 2018-10-16 Disk management method, disk management device and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/110489 WO2020077534A1 (en) 2018-10-16 2018-10-16 Disk management method, disk management apparatus, and electronic device

Publications (1)

Publication Number Publication Date
WO2020077534A1 true WO2020077534A1 (en) 2020-04-23

Family

ID=65713834

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/110489 Ceased WO2020077534A1 (en) 2018-10-16 2018-10-16 Disk management method, disk management apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN109496292B (en)
WO (1) WO2020077534A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112732494A (en) * 2020-12-29 2021-04-30 北京浪潮数据技术有限公司 Bad disk replacement method, device, equipment and medium for storage system
CN113687777A (en) * 2021-07-23 2021-11-23 苏州浪潮智能科技有限公司 Method, device, equipment and medium for predicting usable time of disk
CN114489479A (en) * 2021-12-23 2022-05-13 北京云宽志业网络技术有限公司 Method and device for powering on and powering off data storage disk
CN119356617A (en) * 2024-12-23 2025-01-24 苏州元脑智能科技有限公司 A data verification method, product, device and storage medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112416454B (en) * 2020-11-17 2024-12-27 浙江大华技术股份有限公司 Method and device for controlling disk startup
CN113608683B (en) * 2021-06-30 2024-05-07 山东海量信息技术研究院 Dual-live-disk cleaning method, system and related device
CN113741807B (en) * 2021-07-29 2023-08-11 苏州浪潮智能科技有限公司 Method, system, equipment and storage medium for improving system storage performance
CN115421650A (en) * 2022-08-18 2022-12-02 Oppo广东移动通信有限公司 Data storage method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008919A (en) * 2007-01-31 2007-08-01 浙江大学 Audio/video data access method and device based on raw device
CN101446976A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 File storage method in distributed file system
CN104065906A (en) * 2014-07-09 2014-09-24 珠海全志科技股份有限公司 Video recording method and device of digital video recording equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
MY128496A (en) * 1998-10-22 2007-02-28 Matsushita Electric Industrial Co Ltd Information recording medium, and method and apparatus for managing defect thereof
US7263629B2 (en) * 2003-11-24 2007-08-28 Network Appliance, Inc. Uniform and symmetric double failure correcting technique for protecting against two disk failures in a disk array
CN103049400B (en) * 2012-12-27 2015-12-23 华为技术有限公司 A kind of disk reconstructing method and device thereof
CN104268040B (en) * 2014-09-16 2016-04-06 深圳市腾讯计算机系统有限公司 A kind of disk performance detection method and device
CN105893188B (en) * 2014-09-30 2018-12-14 伊姆西公司 Method and apparatus for accelerating the data reconstruction of disk array

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008919A (en) * 2007-01-31 2007-08-01 浙江大学 Audio/video data access method and device based on raw device
CN101446976A (en) * 2008-12-26 2009-06-03 中兴通讯股份有限公司 File storage method in distributed file system
CN104065906A (en) * 2014-07-09 2014-09-24 珠海全志科技股份有限公司 Video recording method and device of digital video recording equipment

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112732494A (en) * 2020-12-29 2021-04-30 北京浪潮数据技术有限公司 Bad disk replacement method, device, equipment and medium for storage system
CN112732494B (en) * 2020-12-29 2024-02-13 北京浪潮数据技术有限公司 Bad disk replacement method, device, equipment and medium of storage system
CN113687777A (en) * 2021-07-23 2021-11-23 苏州浪潮智能科技有限公司 Method, device, equipment and medium for predicting usable time of disk
CN113687777B (en) * 2021-07-23 2023-08-08 苏州浪潮智能科技有限公司 Method, device, equipment and medium for predicting usable time length of magnetic disk
CN114489479A (en) * 2021-12-23 2022-05-13 北京云宽志业网络技术有限公司 Method and device for powering on and powering off data storage disk
CN114489479B (en) * 2021-12-23 2023-06-09 北京云宽志业网络技术有限公司 Method and device for powering on and off a data storage disk
CN119356617A (en) * 2024-12-23 2025-01-24 苏州元脑智能科技有限公司 A data verification method, product, device and storage medium
CN119356617B (en) * 2024-12-23 2025-03-07 苏州元脑智能科技有限公司 A data verification method, product, device and storage medium

Also Published As

Publication number Publication date
CN109496292A (en) 2019-03-19
CN109496292B (en) 2022-02-22

Similar Documents

Publication Publication Date Title
WO2020077534A1 (en) Disk management method, disk management apparatus, and electronic device
US11853549B2 (en) Index storage in shingled magnetic recording (SMR) storage system with non-shingled region
US7444460B2 (en) Data storage device, method for updating management information in data storage device, and computer program
US8682867B2 (en) Deleted data recovery in data storage systems
CN115576505B (en) A data storage method, device, equipment and readable storage medium
CN112783420B (en) Data deletion and garbage collection method, device, system and storage medium
CN110147203B (en) File management method and device, electronic equipment and storage medium
JP2017079053A (en) Method and system for improving storage journaling
WO2021109590A1 (en) Data storage method and apparatus, electronic device, and storage medium
CN107315659B (en) Method and device for redundant backup of metadata
CN109918352B (en) Memory system and method of storing data
CN103034592A (en) Data processing method and device
WO2021129151A1 (en) File backup method and apparatus, and terminal device
CN103559139A (en) Data storage method and device
CN110019063B (en) Method for computing node data disaster recovery playback, terminal device and storage medium
JP2018106545A (en) Information processing device, information processing system, information processing method and program
CN104572762A (en) Method and device for deleting and recovering video files
CN103049391B (en) Data processing method and equipment
CN110692058B (en) Auxiliary storage device for providing independent backup and recovery functions and equipment suitable for auxiliary storage device
US7567994B2 (en) Method and apparatus to proactively capture and transmit dense diagnostic data of a file system
CN109783321B (en) Monitoring data management method and device and terminal equipment
CN113467698A (en) Writing method and device based on file system, computer equipment and storage medium
CN108052644A (en) The method for writing data and system of data pattern log file system
WO2021027271A1 (en) Bad block information protection method and apparatus, computer device and storage medium
JP4390618B2 (en) Database reorganization program, database reorganization method, and database reorganization apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18937419

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18937419

Country of ref document: EP

Kind code of ref document: A1