Monitoring data writing and deleting method, device and equipment and storage medium

By storing the same video file or image data from the same time period within the SMR zone and using an information table to record the storage status, the problem of deleting monitoring data affecting other data is solved, thus improving the stability of data storage and space utilization.

CN122111309APending Publication Date: 2026-05-29ZHEJIANG UNIVIEW TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG UNIVIEW TECH CO LTD
Filing Date
2024-11-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies may affect other monitoring data when deleting monitoring data from the oldest video or image services, leading to unstable data storage.

Method used

By storing the same video file or image data from the same time period within the same partition of the SMR area, and using an information table to record the storage status of each partition, it is ensured that deleting data from a certain file or time period does not affect data from other files or time periods.

Benefits of technology

This feature ensures that deleting monitoring data does not affect monitoring data in other files or time periods, thus improving data storage stability and space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111309A_ABST
    Figure CN122111309A_ABST
Patent Text Reader

Abstract

The application provides a kind of monitoring data writing and deleting method, device, equipment and storage medium, the method comprises: obtaining the business side transmission and the storage monitoring data of candidate partition in idle SMR area are written into;According to the attribute information of the storage monitoring data, update the information corresponding to candidate partition in first information table;First information table includes the storage time and / or file information of the monitoring data stored in each partition in SMR area, and the monitoring data stored in each partition corresponds to a same file and / or the storage time of the monitoring data stored in each partition corresponds to a same time period;If full coverage deletion condition is reached, then determine the target partition to be deleted in SMR area according to the information of each partition in first information table, and delete all monitoring data stored in target partition.The technical scheme of the embodiment of the present application can not affect other video files or pictures when deleting a video file or picture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of surveillance technology, and in particular to a method, apparatus, device, and storage medium for writing and deleting surveillance data. Background Technology

[0002] In terms of surveillance data storage, SMR (Shingled Magnetic Recording) disks are currently commonly used. SMR disks overlap the data tracks on the platter, much like roof tiles. The manufacturing process involves very little variation, yet it significantly increases disk storage density, making it widely used in data storage. SMR disks divide the tracks into zones, which are sequentially writable areas composed of consecutive tracks. Each zone constitutes a basic unit that needs to be written sequentially, and the size of a zone is typically in the range of 256MB.

[0003] In related technologies, surveillance data storage typically includes two types: video data storage and image data storage. Video data is generally stored in multiple files, and full-overwrite deletion usually involves deleting one or more files from the oldest time period. Image data files are relatively smaller, and full-overwrite deletion is typically done by hourly directory.

[0004] However, when the aforementioned technology deletes monitoring data from the oldest video or image services, it may affect other monitoring data. Summary of the Invention

[0005] This invention provides a method, apparatus, device, and storage medium for writing and deleting monitoring data, which addresses the shortcomings of existing technologies where deleting monitoring data from video or image services from the furthest point in time may affect other monitoring data. By storing the same video file or images from the same time period within the same partition of the SMR area, the deletion of a certain video file or image from a certain time period will not affect other video files or images from other time periods.

[0006] This invention provides a method for writing and deleting monitoring data, including: The system acquires the monitoring data to be stored transmitted from the service side and writes it into an empty candidate partition in the SMR (Shingled Magnetic Recording) area. The monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. Based on the attribute information of the monitoring data to be stored, update the information corresponding to the candidate partitions in the first information table; the first information table includes the information of each partition in the SMR area, and the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period. If the full coverage deletion condition is met, the target partition to be deleted is determined in the SMR area based on the information of each partition in the first information table, and all monitoring data stored in the target partition is deleted.

[0007] According to a method for writing and deleting monitoring data provided by the present invention, the monitoring data to be stored is video data to be stored, the first information table includes a first information table corresponding to the video service, and the method further includes: Detect whether the SMR area has a first partition; the first partition is the partition in the storage area that is not full after the file corresponding to the video data to be stored has been written. If a first partition exists, the video data stored in the first partition is written back to the vertical magnetic recording area (CMR), and the second information table corresponding to the video service is updated. The second information table corresponding to the video service includes at least one of the following: the storage address, file name, file start storage time, and usage status of the video data stored in each logical block within the CMR. Set the usage status of the first partition to unused and update the first information table corresponding to the video service.

[0008] According to a monitoring data writing and deletion method provided by the present invention, the monitoring data to be stored is image data to be stored, the attribute information of the image data to be stored includes a first storage time period corresponding to the image data to be stored, and a first information table includes a first information table corresponding to the image service. The method of writing the monitoring data to be stored into a free candidate partition in the Shingled Magnetic Recording (SMR) area includes: Determine the first number of free secondary partitions in the SMR region; Select a second number of second partitions from a first number of multiple second partitions as candidate partitions; the second number is less than the first number. The image data to be stored is written to the candidate partitions respectively, and the first information table corresponding to the image business is updated; the storage time of the image data stored in all candidate partitions corresponds to the first storage time period.

[0009] According to a monitoring data writing and deletion method provided by the present invention, the candidate partition includes multiple candidate partitions, and before writing the image data to be stored to the candidate partitions respectively, the method further includes: Determine whether the write pointers corresponding to each of the multiple candidate partitions are in an occupied state; If the write pointers corresponding to multiple candidate partitions are all in an occupied state, the image data to be stored is written to CMR, and the second information table corresponding to the image service is updated. The second information table corresponding to the image service includes at least one of the following: the storage address, storage time period, and usage status of the image data stored in each logical block within CMR.

[0010] According to a monitoring data writing and deletion method provided by the present invention, the method further includes: If writing image data to a candidate partition stops, obtain the first image data stored in CMR and the target storage time period corresponding to the first image data; If there is a third partition in the SMR area that corresponds to the target storage time period and whose image data is not full, then the first image data will be written back to the third partition. If all partitions in the SMR area corresponding to the target storage time period are full, then based on the second capacity corresponding to the first image data, determine whether to request a new partition in the SMR area to store the first image data.

[0011] According to a monitoring data writing and deletion method provided by the present invention, the method further includes: After writing image data to the second number of candidate partitions multiple times in succession, if it is determined that the total remaining capacity of the second number of candidate partitions is greater than or equal to the preset capacity threshold, then the second number is decremented by one to obtain a new second number. Alternatively, after writing image data to the second number of candidate partitions at least once, if it is determined that the total capacity of the second number of candidate partitions is less than the capacity of the image data to be written, then the second number is incremented by one to obtain a new second number.

[0012] According to a monitoring data writing and deletion method provided by the present invention, the attribute information of the monitoring data to be stored includes a first capacity corresponding to the monitoring data to be stored. Before writing the monitoring data to be stored into a free candidate partition in the SMR region, the method further includes: Determine if there are any free partitions within the SMR region; If a free partition exists, return to the above steps of writing the monitoring data to be stored to a free candidate partition in the shingled magnetic recording (SMR) area. If no free partition exists, the remaining storage capacity of CMR and the first capacity will determine whether to write the monitoring data to be stored to CMR.

[0013] The present invention also provides a monitoring data writing and deletion device, comprising the following modules: The data writing module is used to acquire the monitoring data to be stored transmitted from the service side and write the monitoring data to be stored into the idle candidate partition in the SMR area of ​​the shingled magnetic recording area; the aforementioned monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. The information table update module is used to update the information corresponding to the candidate partitions in the first information table according to the attribute information of the monitoring data to be stored. The first information table includes the information of each partition in the SMR area. The information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period. The deletion module is used to determine the target partition to be deleted in the SMR area based on the information of each partition in the first information table if the full coverage deletion condition is met, and delete all monitoring data stored in the target partition.

[0014] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the monitoring data writing and deletion method as described above.

[0015] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the monitoring data writing and deletion method as described above.

[0016] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the monitoring data writing and deletion method as described above.

[0017] The monitoring data writing and deletion method, apparatus, device, and storage medium provided by this invention acquire monitoring data to be stored transmitted from the service side, write the monitoring data to be stored into an idle candidate partition in the SMR area, and then update the information corresponding to the candidate partition in the first information table according to the attribute information of the monitoring data to be stored. If the full coverage deletion condition is met, the target partition to be deleted is determined in the SMR area according to the information of each partition in the first information table, and all monitoring data in the target partition is deleted. The monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. The first information table includes information of each partition in the SMR area. The information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period. In this method, since data is stored in the partitions of the SMR area according to the principle that each partition stores only one file or only the monitoring data of the same time period, and the storage status of each partition can be recorded through the first information table, when a file or monitoring data of a certain time period needs to be deleted due to full coverage, the complete partition can be found directly through the first information table and all data in that partition can be deleted directly to achieve deletion without affecting the monitoring data of other files or other time periods. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0019] Figure 1 This is a diagram illustrating the traditional disk and SMR disk recording methods.

[0020] Figure 2 This is one of the flowcharts illustrating the monitoring data writing and deletion method provided by the present invention.

[0021] Figure 3 This is a schematic diagram of the area division of the SMR hard disk provided by the present invention.

[0022] Figure 4 This is a schematic diagram of the video data write-back process provided by the present invention.

[0023] Figure 5 This is a schematic diagram of the process of writing image data into the candidate partition of the SMR area provided by the present invention.

[0024] Figure 6This is a schematic diagram of the image data write-back process provided by the present invention.

[0025] Figure 7 This is a schematic diagram of the monitoring data writing and deletion device provided by the present invention.

[0026] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0028] To better illustrate the technical solutions of the embodiments of the present invention, the relevant technical background of the present invention will be described below.

[0029] SMR (Synthetic Magnetic Retention) disks are high-capacity hard drives that utilize a novel magnetic storage technology. This technology involves very minor changes to the manufacturing process but can significantly increase disk storage density. In today's world of rapidly growing data volumes, SMR technology effectively reduces the cost per unit capacity of disk storage and represents the future trend of high-density disk storage technology. SMR disks primarily utilize the fact that the width of the read head can be smaller than the width of the write head. Data is written by partially overlapping the previous track, while leaving sufficient space for the narrower read head to access the data from the previous track. See also... Figure 1 The diagram illustrates the magnetic recording methods of traditional hard drives and SMR disks. In traditional hard drive magnetic recording, tracks are numbered from top to bottom as TrackN, TrackN+1, ..., while in SMR disk magnetic recording, tracks are numbered from top to bottom as TrackN, TrackN+1, TrackN+2, TrackN+3, ..., where N is greater than or equal to 1. It can be seen that the result of shingled magnetic recording is a narrow track reserved for reading and a wider write track used for writing, with the writing process covering the width of several read tracks. Compared to traditional hard drive magnetic recording, SMR disks, through shingled magnetic recording, can accommodate more tracks in the same area, thereby increasing storage areal density and reducing the cost per unit storage capacity.

[0030] Currently, commonly used SMR disks consist of both traditional perpendicular magnetic recording (CMR) and shingled magnetic recording (SMR) disks. In a typical SMR hard drive, the CMR area occupies 1% of the total SMR disk capacity, while the SMR area occupies 99%. Of course, SMR disks with other percentages are also possible; this is just an example. An SMR disk typically includes multiple zones, each consisting of consecutive concentric tracks on the same platter. Currently, each zone has a capacity of 256MB. Zones are physically separated and do not interfere with each other. Generally, only sequential writes are supported within each zone, not random writes. Each zone also has a write pointer to facilitate data writing within that zone.

[0031] In surveillance operations, data is typically written continuously and sequentially, including both video and image data. Video files are usually divided into multiple files based on size (e.g., 1.5GB, equivalent to 6 zones) or time interval (e.g., 2 hours). Full-overwrite deletion usually removes one or more files from the earliest / farthest time period. Image files are relatively small, such as a few KB, and full-overwrite deletion is typically done by hourly directory (e.g., deleting images stored within a specific hour). However, for video files, network outages or power failures can cause a video file to be less than a multiple of 256MB. This can result in multiple video files being written to a single zone. When attempting to delete the earliest file (i.e., deleting data from the first track of a zone), it may fail, affecting other video files. Similarly, for images, a 256MB zone may store images from different hours. Full-overwrite deletion by hourly directory (requiring deletion of data from the first track of a zone) may also fail, potentially affecting images stored in other hourly directories. Based on this, embodiments of the present invention provide a method, apparatus, device, and storage medium for writing and deleting monitoring data to solve the above-mentioned technical problems.

[0032] The following is combined with Figures 2-6 This invention describes a method for writing and deleting monitoring data according to an embodiment of the present invention.

[0033] It should be noted that the execution subject in the embodiments of the present invention can be a monitoring data writing and deleting device, an electronic device, or other devices or apparatuses, without specific limitations. The following embodiments will use an electronic device as an example for illustration.

[0034] The aforementioned electronic devices can be terminals or servers. The specific form of the terminal or server is not specifically limited here. For example, a terminal can be a surveillance camera, a desktop computer, a laptop computer, etc., and a server can be a standalone server or a server cluster, etc.

[0035] Figure 2 This is one of the flowcharts illustrating the monitoring data writing and deletion method provided by the present invention, such as... Figure 2 As shown, the method includes the following steps: Step 202: Obtain the monitoring data to be stored transmitted from the service side, and write the monitoring data to be stored into an idle candidate partition in the SMR area of ​​the shingled magnetic recording area; the aforementioned monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services.

[0036] In this context, the service side, also known as the client, can be the business entity that needs to store images, such as image acquisition devices (e.g., cameras, camcorders) in a monitoring scenario. The images here generally include video or pictures. In this embodiment, the electronic device executing the image storage process can be connected to the service-side device, and then the service side can continuously transmit the monitoring data to be stored to the electronic device after generating it. This monitoring data to be stored can be video data generated by the service side's video service or image data generated by the service side's image service.

[0037] After receiving the monitoring data to be stored transmitted from the service side, the electronic device can also obtain the attribute information of the monitoring data to be stored. This attribute information may include the initial capacity (i.e., the size of the monitoring data to be stored), the storage time, the category of the monitoring data, and the identifier ID of the image acquisition device corresponding to the monitoring data. The storage time may include the start time of data storage and the corresponding time period; the category may include video data or image data; and the identifier ID of the image acquisition device indicates which acquisition device collected the monitoring data.

[0038] When storing monitoring data, since an SMR disk typically includes an SMR area and a CMR area, and the capacity of the SMR area is generally much larger than that of the CMR area, data is usually stored preferentially in the SMR area. Additionally, it should be noted that the SMR hard drive in this embodiment is a Host Managed SMR, i.e., a host-managed shingled magnetic recording hard drive.

[0039] When storing data in the SMR zone, specifically, you can search for unused partitions in the SMR zone based on the usage status of each zone, that is, find partitions that do not store monitoring data. These partitions are free partitions. Then, you can use all of these free partitions as candidate partitions, or select a portion of these free partitions as candidate partitions. After that, you can store the monitoring data to be stored in the candidate partitions.

[0040] In practice, when storing data in the SMR area, there may be situations where the SMR area cannot store data. Therefore, to ensure accurate data storage, as an optional embodiment, before writing the monitoring data to be stored into a free candidate partition in the SMR area, it can first determine whether there is a free partition in the SMR area. If a free partition exists, the process returns to the step of writing the monitoring data to be stored into a free candidate partition in the SMR area. In other words, when the electronic device obtains monitoring data to be stored and needs to write it, it can first check whether there is a free or unused candidate partition in the SMR area. If so, the monitoring data to be stored can be written into the candidate partition of the SMR.

[0041] If there are no free partitions in the SMR area, the decision to write the monitoring data to be stored is made based on the remaining storage capacity and the initial capacity of the CMR. In other words, if there are no free partitions available for writing in the SMR area, writing can be considered in the CMR area. Before writing the monitoring data to be stored in the CMR area, it can be determined whether the CMR area has sufficient capacity for writing. The specific determination method is as follows: Assuming the total capacity of the SMR hard drive is X (MB), the proportion of the CMR area in the total SMR hard drive capacity is W, the capacity of the CMR area is W*X (MB), the used capacity of the CMR area is D (MB), and the size of the file to be written to the CMR area is Z (MB), i.e., the initial capacity is Z (MB), then the remaining storage capacity of the CMR area can be expressed as: W*XD. Then, W*XD can be compared with Z. If Z ≤ W*XD, it is determined that the CMR area has sufficient remaining storage capacity for writing, and the monitoring data to be stored can be written to the CMR area; if Z > W*XD, it is determined that the remaining storage capacity of the CMR area is insufficient, and an error can be reported to the client, notifying that the data write has failed.

[0042] In addition, when writing data, data can be stored / written in both the SMR area and the CMR area, which supports simultaneous writing of data from different clients, thereby improving data writing efficiency.

[0043] Step 204: Update the information corresponding to the candidate partitions in the first information table according to the attribute information of the monitoring data to be stored; the first information table includes the information of each partition in the SMR area, and the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period.

[0044] This step first explains the storage methods of the SMR and CMR sectors in an SMR hard drive. CMR sectors generally support both sequential and random data writes, while SMR sectors only support sequential data writes. See [link / reference] Figure 3 The diagram shown illustrates the area division of an SMR hard drive. The CMR area header contains a 1GB Disk Metadata (DDF) area, which includes segments such as the shared space management area, bad block mapping data area, and shared space data area. This area can be used to record relevant storage information of the SMR hard drive. The SMR area is the area provided by the SMR hard drive that can be written to clients normally.

[0045] As mentioned above, the DDF area can record relevant storage information of the SMR disk. In this embodiment, for video services and image services, a first information table can be stored / maintained in the DDF area respectively. That is, video services and image services will each correspond to a first information table. The first information table mainly records the data storage status of video services and image services in the SMR area.

[0046] For video services, the corresponding first information table can include information about each partition in the SMR area. The first information table for video services is shown in Table 1 below. The information for each partition can include the partition ID, the file name corresponding to the monitoring data stored in each partition, the storage time of the monitoring data stored in each partition, and the usage status of each partition. The monitoring data stored in each partition is video data or video files. Specifically, the storage time of the video files stored in each partition can be the start time or the start storage time of the video files stored in each partition.

[0047] Table 1

[0048] Here, zone ID represents the ID of each partition, and the stored file is the file name stored in the partition. camera1.1 and 1.2 represent two video files from camera1, respectively. The start time of file storage refers to the start storage time of the file stored in each partition. Zone usage status includes used and unused, with unused indicating that the partition is idle. It should be noted that in the first information table corresponding to the video service, the files stored in each partition must be files containing the same video data; that is, each partition can only store one video file corresponding to one file name, and storing multiple different video files is not allowed.

[0049] Based on Table 1 above, for the case where the monitoring data to be stored is video data, if there are free candidate partitions in the SMR area, the video data to be stored can be stored in the candidate partitions. Specifically, when storing the video data to be stored in the candidate partitions, video services usually divide the video data to be stored into multiple files based on size (e.g., 1.5G) or time interval (e.g., 2 hours). This can result in multiple partitions storing the same video file (the video file corresponding to the video data to be stored). Here, we set each partition to store only one video file. Then, when other video files of video data to be stored are sequentially written to the partitions of the SMR area, even if the current partition is not full and has remaining capacity, it will not continue to write in the unfilled partition. Instead, a new free partition will be selected for writing, thus ensuring that each partition stores the same video file of the same video data. This ensures that the video file can be deleted from the entire partition later without affecting other video files. For example, zone2 stores camera1.2, which is the second video file of the first camera. However, zone2 is not full and has remaining capacity. The next video file to be stored is camera2.1, which is the first video file of the second camera. At this time, camera2.1 will not be written to zone2 sequentially. Instead, it will be written to the free zone3, thus ensuring that only one video file is written to each zone.

[0050] Furthermore, for cases where the monitoring data to be stored is video data to be stored, after writing the video data to be stored to the free partition of the SMR area, the first information table corresponding to the video service can be updated, that is, the first information records the stored file, the start time of the file, and the usage status of each partition.

[0051] For image services, the corresponding first information table can include information about each partition in the SMR zone. The first information table for image services is shown in Table 2 below. The information for each partition can include the partition ID, the storage time of the monitoring data stored in each partition, and the usage status of each partition. Specifically, the storage time of the monitoring data stored in each partition can be the time period in which the files stored in each partition are located, specifically, an hourly time period.

[0052] Table 2

[0053] Specifically, when the monitoring data to be stored is image data, the storage method differs from that for video data. Since image files are typically smaller, less than 256MB, meaning a single partition can store multiple image files, to ensure that deleting image files from a specific time period doesn't affect files from other time periods, the first information table for the image service can be configured to store only one image file for each time period in each partition. This ensures that deleting an image file from one time period doesn't affect images from other time periods.

[0054] Furthermore, for cases where the monitoring data to be stored is image data to be stored, after writing the image data to be stored to the corresponding free partition in the SMR area according to the storage time period, the first information table corresponding to the image service can be updated. That is, the first information records the time period of the file stored in each partition and the usage status of each partition.

[0055] In summary, after obtaining the monitoring data to be stored, the category of the monitoring data to be stored, i.e., whether it is video data or image data, can be determined based on information such as the source or attributes of the monitoring data to be stored. After storing the monitoring data to be stored in the candidate partition of the SMR area, the first information table of the corresponding category is updated.

[0056] Step 206: If the full coverage deletion condition is met, determine the target partition to be deleted in the SMR area based on the information of each partition in the first information table, and delete all monitoring data stored in the target partition.

[0057] In this step, the full-coverage deletion condition can be a pre-set condition. For example, the maximum storage capacity of each camera in the SMR hard drive can be set in advance. If the current storage capacity exceeds the maximum storage capacity, it can be considered that the storage capacity of that camera has reached the full-coverage deletion condition, and the video data or image data stored in the SMR hard drive of that camera needs to be fully covered and deleted.

[0058] When performing a full-overlay deletion of the stored data for a specific camera, the earliest / farthest stored video or image files for that camera are typically deleted. Specifically, the Full Overlay Delete (FOD) module in the electronic device can locate all video or image files related to that camera in the SMR area based on the first information table corresponding to the video service or the first information table corresponding to the image service.

[0059] If video files are being deleted, the system can sort the stored video files by their start times, find all partitions corresponding to the earliest start time video files, and designate them as the target partitions. Then, all video files in the target partitions are deleted to free up space. After freeing up space, the corresponding first information table for the video service can be updated. In this table, the stored files and start times of the target partition can be set to empty, and the partition status can be set to unused, making it available for other video files to write to.

[0060] If the files being deleted are image files, then all files from the earliest one or more hours need to be deleted. This can be done by referring to the first information table corresponding to the image service, finding all target partitions within the desired deletion time period, and then deleting all image files within those target partitions to free up space. After freeing up space, the first information table corresponding to the image service can be updated accordingly. In the first information table, the storage time period for the files stored in the target partition can be set to empty, and the partition status can be set to unused, making it available for other image files to write.

[0061] It is understandable that the target partitions mentioned above can be one or more. Since the target partitions store the same video file or image files from the same time period, deleting videos by file will not affect other video files, or deleting images by hour will not affect images from other time periods.

[0062] Of course, as mentioned above, when there are no free partitions in the SMR area, the monitoring data to be stored can also be stored in the CMR area. In this case, when deleting a data file that is fully covered, the entire partition or all logical blocks storing the monitoring data of a certain camera can be searched in both the SMR and CMR areas. Then, the target partition can be found and the monitoring data in the target partition can be deleted. This way, the capacity of the entire partition can be released at once without affecting other video files or image files.

[0063] In this embodiment, the monitoring data to be stored transmitted from the service side is acquired and written into an idle candidate partition in the SMR area. Then, the information corresponding to the candidate partition in the first information table is updated according to the attribute information of the monitoring data to be stored. If the full coverage deletion condition is met, the target partition to be deleted is determined in the SMR area according to the information of each partition in the first information table, and all monitoring data in the target partition is deleted. The monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. The first information table includes the information of each partition in the SMR area. The information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition. The monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period. In this method, since data is stored in the partitions of the SMR area according to the principle that each partition stores only one file or only the monitoring data of the same time period, and the storage status of each partition can be recorded through the first information table, when a file or monitoring data of a certain time period needs to be deleted due to full coverage, the complete partition can be found directly through the first information table and all data in that partition can be deleted directly to achieve deletion without affecting the monitoring data of other files or other time periods.

[0064] In some real-world scenarios, when the monitoring data to be stored is video data, there may be cases where the video file stored by a certain camera is not an integer multiple of 256MB. This can lead to a situation where a certain partition of the SMR area of ​​that camera is not full when storing the video file. In order to improve space utilization, this embodiment proposes a technical solution for video data write-back. The following embodiment describes the process of writing back video data.

[0065] Figure 4 This is a schematic diagram of the video data write-back process provided by the present invention, such as... Figure 4 As shown, the above method may also include the following steps: Step 302: Detect whether the SMR area has a first partition; the first partition is the partition in the storage area that is not full after the file corresponding to the video data to be stored has been written.

[0066] In this step, an electronic device can be equipped with a write-back module (WB). This write-back module can poll in the background to check if there is a situation where the video file of a certain camera has been written completely, but the video file of that camera was not filled when writing the last partition. That is, the video file stored by a certain camera is not an integer multiple of 256MB. If this situation exists, the last unfilled partition written by that camera is taken as the first partition.

[0067] Step 304: If a first partition exists, the video data stored in the first partition is written back to the vertical magnetic recording area (CMR), and the second information table corresponding to the video service is updated. The second information table corresponding to the video service includes at least one of the following: the storage address, file name, file start storage time, and usage status of the video data stored in each logical block within the CMR.

[0068] In this step, after finding the first partition of a certain camera, it can be determined that the video file written in the first partition has not reached 256MB. Then, the video file written in the first partition can be written back to the CMR area.

[0069] As mentioned above, the DDF area of ​​CMR can maintain / store a first information table corresponding to video services. This first information table records the data storage status of video services in the SMR area. Simultaneously, to facilitate the rapid deletion of video data stored in the CMR area, a second information table corresponding to video services can also be maintained / stored in the DDF area. This second information table records the storage address, file name, file start storage time, and usage status of the video data / video files stored in each logical block within CMR.

[0070] For the second information table of video services, please refer to Table 3 below: Table 3

[0071] LBA refers to Logical Block Address. The second information table mentioned above can record the start and end addresses of the logical blocks occupied by the video files stored in the CMR area, as well as the start time and usage status of the video files stored in each logical block.

[0072] After successfully writing the video file from the first partition in the SMR area back to the logical block in the CMR area, the start and end addresses of the logical block storing the video file corresponding to the first partition in the CMR area, the start time of the video file, etc. are obtained. Then, this information is synchronously updated to the second information table corresponding to the video service, and the usage status of the logical block in the second information table is set to "used".

[0073] In addition, when deleting video data with full coverage, if the deleted video data is stored in the CMR area, the second information table of the video service can be updated after deletion. That is, the start and end addresses of the LBA of the file corresponding to the deleted video data, the name of the stored file, and the start time are all set to empty, and the usage status of the LBA of the file corresponding to the deleted video data is set to unused.

[0074] Step 306: Set the usage status of the first partition to unused and update the first information table corresponding to the video service.

[0075] In this step, the first information table includes the first information table corresponding to the video service. After writing the video files in the first partition back to the CMR area, the capacity of the first partition in the SMR area can be released, and the first information table corresponding to the video service can be updated. That is, the video files and start times stored in the first partition in the first information table are set to empty, and the status of the first partition is set to unused, so that other video files can use the first partition in the future and perform full partition writing on the first partition.

[0076] In this embodiment, for the case where the video file has been written but the last partition is not full, the video file in the unfilled partition is written back to the CMR area, and the capacity of the partition is released so that other video files can be written to the partition in full, thereby improving the space utilization of the SMR area.

[0077] In the case where the monitoring data to be stored is image data, assuming that the attribute information of the image data to be stored includes the first storage time period corresponding to the image data to be stored, the following embodiment will explain how to store the image data to be stored in the candidate partition of the SMR area.

[0078] Figure 5 This is a schematic diagram illustrating the process of writing image data to the candidate partition of the SMR region provided by the present invention, as shown below. Figure 5 As shown, step 202 above, "writing the monitoring data to be stored to an empty candidate partition in the SMR (Shingled Magnetic Recording) area," may include the following steps: Step 402: Determine a first number of free secondary partitions in the SMR region.

[0079] In this step, if the monitoring data to be stored is image data, since the space occupied by each image file is small, such as the smallest image file being only a few KB, multiple image files can be stored in one partition of the SMR area. In order to avoid the image files of the same time period being stored too scattered, in this embodiment, image files of the same time period can be stored centrally.

[0080] Specifically, when storing image data, you can first find all free / unused partitions in the SMR area. These partitions are all recorded as the second partitions, and their total number is recorded as the first number.

[0081] Step 404: Select a second number of second partitions as candidate partitions from a first number of multiple second partitions; the second number is less than the first number.

[0082] In this step, after obtaining all free second partitions in the SMR area, a second number of partitions can be selected from all the second partitions according to a preset second number. These selected partitions can be used as candidate partitions. Here, when selecting candidate partitions from all the second partitions, multiple second partitions can be selected sequentially from all the second partitions according to their IDs as candidate partitions.

[0083] It should be noted that the second number is less than the first number. In other words, when storing image data for the same time period, a smaller number of partitions can be selected from the available partitions to store the image data for this time period. That is, the maximum number of partitions that can be used within the same hour is always the smaller number of the second number, while other partitions are unusable. This can prevent the waste of resource space and facilitate the deletion of the entire partition when full-coverage deletion occurs later.

[0084] Step 406: Write the image data to be stored to the candidate partitions respectively, and update the first information table corresponding to the image service; the storage time of the image data stored in all candidate partitions corresponds to the first storage time period.

[0085] In this step, the first information table includes the first information table corresponding to the image service. After selecting candidate partitions, the image data to be stored can be stored in the candidate partitions, and then the first information table corresponding to the image service can be updated. Specifically, the update may include: setting the time period of the storage files corresponding to these candidate partitions in the first information table to the same time period / the same hour period, i.e., setting them all to the first storage time period, and simultaneously setting the usage status of these candidate partitions to "used".

[0086] Furthermore, when the aforementioned candidate partitions include multiple candidate partitions, in order to facilitate the successful writing of the image data to be stored to the candidate partitions of the SMR area, as an optional embodiment, before writing the image data to be stored to the candidate partitions of the SMR area, it can be determined whether the write pointers corresponding to each of the multiple candidate partitions are in an occupied state; if the write pointers corresponding to the multiple candidate partitions are all in an occupied state, then the image data to be stored is written to the CMR, and the second information table corresponding to the image service is updated; the second information table corresponding to the image service includes at least one of the following: the storage address, storage time period, and usage status of the image data stored in each logical block within the CMR.

[0087] Each partition in the SMR region corresponds to a write pointer. When an image file needs to be written to a candidate partition in the SMR region, it can be checked whether at least one of the write pointers of these multiple (second number) candidate partitions is in an idle state. If a write pointer is writing data to a candidate partition, its state is occupied; if it is not writing data, its state is idle.

[0088] In one possible implementation, if one or more write pointers among all candidate partitions are idle, and at least one of the idle candidate partitions has sufficient capacity, then the image data to be stored can be sequentially written to the idle candidate partition with sufficient capacity. If one or more write pointers among all candidate partitions are idle, but the capacity of all idle candidate partitions is insufficient, resulting in the inability to successfully write data, then a new partition can be requested for data writing, and the first information table corresponding to the image service needs to be updated synchronously.

[0089] The process for determining whether the capacity of a candidate partition with a free write pointer is sufficient is as follows: Each candidate partition has a capacity of 256MB. The LBA address description can be simply understood as a linear sequence of numbers, where each number corresponds to a physical sector on the SMR hard drive. Assuming the LBA address of the first sector of the first track within the candidate partition is LBA0, and the LBA address of the last sector of the last track is LBAn, then the total number of sectors in a candidate partition is: LBAn - LBA0 + 1. Assuming the size of each sector is Y (MB), then Y can be expressed using the following formula: .

[0090] Then, based on the termination address LBAx of the last business (i.e., image file) written to each candidate partition and the termination address LABn of the candidate partition, the free unused space Z (MB) of the candidate partition can be calculated, expressed by the following formula: .

[0091] Assuming the image file to be written is Q (MB), if Z ≥ Q, it means the candidate partition has enough space to write the image file, and the image file can be written sequentially in that candidate partition. If Z < Q, it means the candidate partition lacks sufficient space to write the image file, and other candidate partitions need to be considered for writing. If none of the second number of candidate partitions within this time period have enough space to write, an additional free partition needs to be requested for writing. After successful writing, the first information table corresponding to the image service needs to be updated synchronously. If requesting a free partition fails, a message indicating the image write failure needs to be reported for review.

[0092] In another possible implementation, if all candidate partitions' write pointers are occupied, meaning there are no free write pointers, data can be written to the CMR area. In this case, it is necessary to first determine whether the CMR area has enough remaining storage capacity for writing. The determination process can refer to the determination process for video data storage described above. Assuming the image file size to be stored is Q (MB), if Q ≤ W * XD, it means that the remaining storage capacity of the CMR area is sufficient, and writing can be performed in the CMR area. If Q > W * XD, it means that the remaining storage capacity of the CMR area is insufficient, so it continues to return and wait for the SMR area, the second number of candidate partitions, to become free, i.e., writing to the SMR area continues.

[0093] Additionally, as mentioned above, the DDF area of ​​CMR can maintain / store a first information table corresponding to image services. This first information table records the data storage status of image services in the SMR area. Simultaneously, to facilitate the rapid deletion of image data stored / written in the CMR area, a second information table corresponding to image services can also be maintained / stored in the DDF area. This second information table records the storage address, storage time period, and usage status of the image data / image files stored in each logical block within CMR.

[0094] For the second information table for image services, please refer to Table 4 below: Table 4

[0095] After writing the image data to be stored to the CMR area, the content of the second information table corresponding to the image service can be updated, namely the content in Table 4 above. Specifically, the time period corresponding to the logical block storing the image data to be stored (a logical block within a certain starting LBA address and ending LBA address) can be set to the time period in which the image data to be stored is located, and the status of the logical block storing the image data to be stored can be set to used.

[0096] In addition, when deleting image data with full coverage, if the deleted image data is stored in the CMR area, the second information table of the image service can be updated after deletion. That is, the LBA start and end addresses of the file corresponding to the deleted image data, the hour and time period, etc. are all set to empty. At the same time, the usage status of the LBA of the file corresponding to the deleted image data is set to unused, and the space is released for other image files to be rewritten.

[0097] In this embodiment, by setting time period attributes for the SMR (Segmented Memory Access) area and CMR (Concurrent Memory Access) area for storing image data, and storing image data in a small number of concentrated partitions within the SMR area, the space utilization of the SMR and CMR areas can be improved, and it is also convenient to delete image data from the entire SMR area later. Furthermore, when multiple candidate partitions in the SMR area are writing data, the image data to be stored can be stored in the CMR area, which can improve the efficiency of image data storage.

[0098] In real-world scenarios, image data may be stored in the CMR area. To improve space utilization, the image data stored in the CMR area can be written back to the SMR area. The following example illustrates the image data write-back process.

[0099] Figure 6 This is a schematic diagram of the image data write-back process provided by the present invention, as follows: Figure 6 As shown, the method includes the following steps: Step 502: If writing image data to the candidate partition stops, obtain the first image data stored in CMR and the target storage time period corresponding to the first image data.

[0100] In this step, the write-back module in the electronic device can continuously poll in the background. After it learns that the image data for a certain time period has been stored, it can search for the image data stored in that time period in the CMR area and record it as the first image data. This time period is recorded as the target storage time period.

[0101] Step 504: If there is a third partition in the SMR area that corresponds to the target storage time period and whose image data is not full, then the first image data is written back to the third partition.

[0102] In this step, the write-back module in the electronic device can also retrieve partitions in the SMR region that are within the same time period as the target storage time period, and then check whether these partitions are all full of data. If at least one partition within the target storage time period is not full of data, these partitions can be designated as third partitions, and then write-back can be initiated to sequentially write the first image data of the same period in the CMR region to these third partitions. If there are multiple third partitions, the data can be written to the corresponding third partitions in order of their IDs.

[0103] When writing the first image data corresponding to the target storage period in the CMR area to the third partition, for each image file in the first image data, one image file is written back at a time. After each image file is written back, it is necessary to check whether the remaining capacity / space of the third partition is sufficient. If it is sufficient, the next image file is written back.

[0104] Step 506: If all partitions in the SMR area corresponding to the target storage time period are full, determine whether to apply for a new partition in the SMR area to store the first image data based on the second capacity corresponding to the first image data.

[0105] In this step, if all partitions in the SMR area corresponding to the target storage time period are full of data or all partitions in the third partition are full of data, and there is not enough space to support the write-back of any image file in the first image data, while the CMR area still has the first image data of the target storage time period that has not been completely written back, then it can be determined whether the total size of the remaining unwritten first image data files in the CMR area within the target storage time period is greater than or equal to the capacity of one partition (i.e., 256MB).

[0106] If the total size of the remaining unwritten first image data is greater than or equal to the capacity of a partition, a new partition can be allocated in the SMR area to write the remaining unwritten first image data. If allocating a new partition cannot write all the first image data, it can be checked whether the total size of the remaining unwritten first image data is greater than or equal to the capacity of a partition. If it is, a new partition can be allocated in the SMR area to continue writing until the total size of the remaining unwritten first image data in the CMR is less than the capacity of a partition in the SMR area. Simultaneously, after the first image data is successfully written, the first and second information tables corresponding to the image service are updated. If allocating a new partition fails, the remaining unwritten first image data will not be written back and will continue to be stored in the CMR area. If the total size of the remaining unwritten first image data is less than the capacity of a partition, the remaining unwritten first image data will not be written back and will continue to be stored in the CMR area, preventing waste of SMR area space and improving space utilization.

[0107] In this embodiment, when there are partitions in the SMR area that are not full for the same time period, the images in the CMR area for the same time period are written back to the partitions in the SMR area that are not full for the same time period. At the same time, when all partitions in the SMR area for the same time period are full, the data in the CMR area for the same time period is not written back. This can improve the space utilization of the SMR.

[0108] In some embodiments, during the storage of image files, if the current storage enters the next time period, the business writing (i.e., image writing) of the second number of candidate partitions is stopped, and the business writing permissions of another second number of candidate partitions are enabled, so as to ensure that the image files in the same time period are stored in at least a number of partitions, which facilitates the subsequent deletion of images from the entire partition.

[0109] The size of the second quantity can be dynamically adjusted according to the busyness of the image storage business. Its initial value can be set according to the actual business scenario. For example, if the number of cameras is 1000, the initial value of the second quantity can be set at a ratio of 100:1. In this case, the initial value of the second quantity can be set to 10, that is, 10 partitions are selected for image file storage in each time period.

[0110] As an optional embodiment, the dynamic adjustment of the second quantity can include: after writing image data to the candidate partitions of the second quantity multiple times, if it is determined that the total remaining capacity of the candidate partitions of the second quantity is greater than or equal to a preset capacity threshold, then the second quantity is decremented by one to obtain a new second quantity; or, after writing image data to the candidate partitions of the second quantity at least once, if it is determined that the total capacity of the candidate partitions of the second quantity is less than the capacity of the image data to be written, then the second quantity is incremented by one to obtain a new second quantity.

[0111] Specifically, the capacity calculation method described above can be used to calculate the remaining capacity of each candidate partition corresponding to a certain time period after all image data has been written. Then, the remaining capacities of all candidate partitions within that time period are summed to obtain the total remaining capacity of all candidate partitions within that time period. Simultaneously, image data stored in the CMR area for the same time period can be written back to the candidate partitions of the SMR area for the same time period. During the write-back process, one image file is written back at a time, and the total remaining capacity of all candidate partitions in the SMR area is calculated each time. This total remaining capacity is then compared with a preset capacity threshold (e.g., the size of a partition, 256MB). If, after multiple consecutive write-backs of image files, the total remaining capacity of all candidate partitions in the SMR area is greater than the preset capacity threshold, it indicates that the second quantity set for the current time period is too large and needs to be reduced in the next time period to accommodate scenarios with fewer image writes / storages and avoid space waste. If the total remaining capacity of all candidate partitions in the SMR area is less than the required capacity of the image file after one or more write-backs of the image file, it indicates that the second quantity set in the current time period is too small to store all the image data. It needs to be increased in the next time period to adapt to the busy image writing / storage scenario.

[0112] The specific reduction process is as follows: A first flag, such as a -1 flag, can be preset. The initial value of the -1 flag is 0. When writing back image files for a certain period of time, if the total remaining capacity of all candidate partitions in the SMR area is greater than the preset capacity threshold after each write-back, the value of the -1 flag is incremented by 1. When the value of the -1 flag reaches the M value, the value of the second number can be decremented by one to obtain a new second number. At this time, the -1 flag is restored to its initial value of 0. If the total remaining capacity of these second number of candidate partitions is less than the preset capacity threshold or an additional free partition needs to be requested during the write-back, the -1 flag is also restored to its initial value of 0.

[0113] The specific process of increasing the capacity is as follows: A second flag, such as a +1 flag, can be pre-set, with an initial value of 0. After each consecutive write-back or during image service write, if the total remaining capacity of the second number of candidate partitions is insufficient and at least one additional free partition needs to be requested, the value of the +1 flag is incremented by 1. When the value of the +1 flag reaches the M value, the value of the second number can be incremented by one to obtain a new second number, at which point the +1 flag returns to its initial value of 0. If, in the middle, the total remaining capacity of the second number of candidate partitions is sufficient and no additional free partition needs to be requested, the +1 flag also returns to its initial value of 0.

[0114] Regarding the M value mentioned above, since the difference in image writes within a day is large, but the average difference between days is not significant, the M value can be set to be greater than 24. The specific size can be set according to the actual situation to better achieve efficient storage of image services.

[0115] In this embodiment, by reducing the number of SMR partitions storing images from the same time period during periods of low workload, SMR resources can be saved. Conversely, by increasing the number of SMR partitions storing images from the same time period during periods of high workload, image storage efficiency can be improved, thus enhancing the user storage experience. In summary, this embodiment dynamically adjusts the number of SMR partitions storing images from the same time period based on workload, ensuring that the number of partitions matches the workload level. This better facilitates image storage for users and improves their storage experience.

[0116] The monitoring data writing and deletion device provided by the present invention is described below. The monitoring data writing and deletion device described below can be referred to in correspondence with the monitoring data writing and deletion method described above.

[0117] Figure 7 This is a schematic diagram of the monitoring data writing and deletion device provided by the present invention. See below. Figure 7 As shown, the device may include: The data writing module 610 is used to acquire the monitoring data to be stored transmitted from the service side and write the monitoring data to be stored into the idle candidate partition in the SMR area; the aforementioned monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. The information table update module 620 is used to update the information corresponding to the candidate partitions in the first information table according to the attribute information of the monitoring data to be stored. The first information table includes the information of each partition in the SMR area. The information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition. The monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period. The deletion module 630 is used to determine the target partition to be deleted in the SMR area based on the information of each partition in the first information table if the full coverage deletion condition is met, and delete all monitoring data stored in the target partition.

[0118] In some embodiments, the monitoring data to be stored is video data to be stored, the first information table includes a first information table corresponding to the video service, and the device further includes: The detection module is used to detect whether the SMR area has a first partition; the first partition is the partition in the storage area that is not full after the file corresponding to the video data to be stored has been written. The first write-back module is used to write back the video data stored in the first partition to the vertical magnetic recording area (CMR) if a first partition exists, and update the second information table corresponding to the video service. The second information table corresponding to the video service includes at least one of the following: the storage address, file name, file start storage time, and usage status of the video data stored in each logical block within the CMR. The first update module is used to set the usage status of the first partition to unused and update the first information table corresponding to the video service.

[0119] In some embodiments, the monitoring data to be stored is image data to be stored. The attribute information of the image data to be stored includes a first storage time period corresponding to the image data to be stored. The first information table includes a first information table corresponding to the image service. The data writing module 610 is specifically used to determine a first number of multiple second partitions that are free in the SMR area; select a second number of second partitions as candidate partitions from the first number of multiple second partitions; the second number is less than the first number; write the image data to be stored to the candidate partitions respectively, and update the first information table corresponding to the image service; the storage time of the image data stored in all candidate partitions corresponds to the first storage time period.

[0120] Optionally, the candidate partitions include multiple candidate partitions. Before the data writing module 610 writes the image data to be stored to the candidate partitions respectively, the device further includes: The status judgment module is used to determine whether the write pointers corresponding to multiple candidate partitions are in an occupied state; The second update module is used to write the image data to be stored to CMR and update the second information table corresponding to the image service if the write pointers corresponding to multiple candidate partitions are all in an occupied state. The second information table corresponding to the image service includes at least one of the following: the storage address, storage time period, and usage status of the image data stored in each logical block in CMR.

[0121] In some embodiments, the above-described apparatus further includes: The second write-back module is used to obtain the first image data stored in the CMR and the target storage time period corresponding to the first image data when writing image data to the candidate partition stops; if there is a third partition in the SMR area that corresponds to the target storage time period and the image data is not full, then the first image data is written back to the third partition; if all partitions in the SMR area that correspond to the target storage time period are full, then based on the second capacity corresponding to the first image data, it is determined whether to apply for a new partition in the SMR area to store the first image data.

[0122] In some embodiments, the above apparatus further includes: an adjustment module, configured to, after writing image data to a second number of candidate partitions multiple times consecutively, if it is determined that the sum of the remaining capacities of the second number of candidate partitions is greater than or equal to a preset capacity threshold, decrement the second number by one to obtain a new second number; or, after writing image data to a second number of candidate partitions at least once, if it is determined that the sum of the capacities of the second number of candidate partitions is less than the capacity of the image data to be written, increment the second number by one to obtain a new second number.

[0123] In some embodiments, the attribute information of the monitoring data to be stored includes a first capacity corresponding to the monitoring data to be stored. Before the data writing module 610 writes the monitoring data to be stored into a free candidate partition in the SMR area, the device further includes: a capacity determination module, used to determine whether there is a free partition in the SMR area; if there is a free partition, then return to the step of writing the monitoring data to be stored into a free candidate partition in the SMR area; if there is no free partition, then determine whether to write the monitoring data to be stored into the CMR based on the remaining storage capacity of the CMR and the first capacity.

[0124] It should be noted that the apparatus provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.

[0125] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8As shown, the electronic device may include: a processor 710, a communications interface 720, a memory 730, and a communications bus 740, wherein the processor 710, the communications interface 720, and the memory 730 communicate with each other through the communications bus 740. The processor 710 can call logical instructions in the memory 730 to execute a monitoring data writing and deletion method. The method includes: acquiring monitoring data to be stored transmitted from the service side and writing the monitoring data to be stored into an idle candidate partition in the SMR area; the monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services; updating the information corresponding to the candidate partition in the first information table according to the attribute information of the monitoring data to be stored; the first information table includes information of each partition in the SMR area, and the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period; if the full coverage deletion condition is met, the target partition to be deleted is determined in the SMR area according to the information of each partition in the first information table, and all monitoring data stored in the target partition is deleted.

[0126] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0127] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the monitoring data writing and deletion methods provided by the above methods. The method includes: acquiring monitoring data to be stored transmitted from the service side and writing the monitoring data to be stored into a free candidate partition in the SMR area; the monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services; updating the information corresponding to the candidate partition in the first information table according to the attribute information of the monitoring data to be stored; the first information table includes information of each partition in the SMR area, the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period; if the full coverage deletion condition is met, determining the target partition to be deleted in the SMR area according to the information of each partition in the first information table, and deleting all monitoring data stored in the target partition.

[0128] In another aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the monitoring data writing and deletion methods provided by the above methods. The method includes: acquiring monitoring data to be stored transmitted from the service side and writing the monitoring data to be stored into a free candidate partition in the SMR area; the monitoring data to be stored includes video data to be stored corresponding to a video service or image data to be stored corresponding to an image service; updating the information corresponding to the candidate partition in the first information table according to the attribute information of the monitoring data to be stored; the first information table includes information of each partition in the SMR area, the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period; if the full coverage deletion condition is met, determining the target partition to be deleted in the SMR area according to the information of each partition in the first information table, and deleting all monitoring data stored in the target partition.

[0129] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for writing and deleting monitoring data, characterized in that, include: Acquire the monitoring data to be stored transmitted from the service side, and write the monitoring data to be stored into an empty candidate partition in the SMR area of ​​the shingled magnetic recording area; The monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. Based on the attribute information of the monitoring data to be stored, update the information corresponding to the candidate partition in the first information table; the first information table includes the information of each partition in the SMR area, and the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period; If the full coverage deletion condition is met, the target partition to be deleted is determined in the SMR area according to the information of each partition in the first information table, and all monitoring data stored in the target partition is deleted.

2. The monitoring data writing and deletion method according to claim 1, characterized in that, The monitoring data to be stored is video data to be stored, and the method further includes: Detect whether the SMR area has a first partition; the first partition is the partition that is not full in the partition storing the video data to be stored after the file corresponding to the video data to be stored has been written; If the first partition exists, the video data stored in the first partition is written back to the vertical magnetic recording area (CMR), and the second information table corresponding to the video service is updated. The second information table corresponding to the video service includes at least one of the following: the storage address, file name, file start storage time, and usage status of the video data stored in each logical block within the CMR. Set the usage status of the first partition to unused and update the first information table corresponding to the video service.

3. The monitoring data writing and deletion method according to claim 1, characterized in that, The monitoring data to be stored is image data to be stored. The attribute information of the image data to be stored includes a first storage time period corresponding to the image data to be stored. The step of writing the monitoring data to be stored into a free candidate partition in the SMR area includes: Determine a first number of free second partitions in the SMR region; A second number of second partitions are selected from a plurality of second partitions of the first number as candidate partitions; the second number is less than the first number. The image data to be stored is written to the candidate partitions respectively, and the first information table corresponding to the image service is updated; the storage time of the image data stored in all the candidate partitions corresponds to the first storage time period.

4. The monitoring data writing and deletion method according to claim 3, characterized in that, The candidate partitions include multiple candidate partitions, and before writing the image data to be stored into the candidate partitions respectively, the method further includes: Determine whether the write pointers corresponding to each of the multiple candidate partitions are in an occupied state; If the write pointers corresponding to the multiple candidate partitions are all in an occupied state, the image data to be stored is written to CMR, and the second information table corresponding to the image service is updated; the second information table corresponding to the image service includes at least one of the following: the storage address, storage time period, and usage status of the image data stored in each logical block within CMR.

5. The monitoring data writing and deletion method according to claim 4, characterized in that, The method further includes: When writing image data to the candidate partition stops, obtain the first image data stored in the CMR and the target storage time period corresponding to the first image data; If there is a third partition in the SMR area that corresponds to the target storage time period and whose image data is not full, then the first image data is written back to the third partition. If all partitions in the SMR area corresponding to the target storage time period are full, then based on the second capacity corresponding to the first image data, it is determined whether to apply for a new partition in the SMR area to store the first image data.

6. The monitoring data writing and deletion method according to claim 3, characterized in that, The method further includes: After writing image data to the second number of candidate partitions multiple times in succession, if it is determined that the total remaining capacity of the second number of candidate partitions is greater than or equal to the preset capacity threshold, then the second number is decremented by one to obtain a new second number. Alternatively, after writing image data to the second number of candidate partitions at least once, if it is determined that the total capacity of the second number of candidate partitions is less than the capacity of the image data to be written, then the second number is incremented by one to obtain a new second number.

7. The monitoring data writing and deletion method according to any one of claims 1 to 6, characterized in that, The attribute information of the monitoring data to be stored includes a first capacity corresponding to the monitoring data to be stored. Before writing the monitoring data to be stored into a free candidate partition in the SMR region, the method further includes: Determine whether there are any free partitions within the SMR region; If a free partition exists, return to the step of writing the monitoring data to be stored to a free candidate partition in the shingled magnetic recording (SMR) area. If no free partition exists, then based on the remaining storage capacity of the CMR and the first capacity, it is determined whether to write the monitoring data to be stored into the CMR.

8. A monitoring data writing and deletion device, characterized in that, include: The data writing module is used to acquire the monitoring data to be stored transmitted from the service side and write the monitoring data to be stored into the idle candidate partition in the shingled magnetic recording area (SMR area). The monitoring data to be stored includes video data to be stored corresponding to video services or image data to be stored corresponding to image services. The information table update module is used to update the information corresponding to the candidate partition in the first information table according to the attribute information of the monitoring data to be stored; the first information table includes the information of each partition in the SMR area, and the information of each partition includes the storage time and / or file information of the monitoring data stored in the corresponding partition, and the monitoring data stored in each partition corresponds to the same file and / or the storage time of the monitoring data stored in each partition corresponds to the same time period; The deletion module is used to determine the target partition to be deleted in the SMR area according to the information of each partition in the first information table if the full coverage deletion condition is met, and delete all monitoring data stored in the target partition.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the monitoring data writing and deletion method as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the monitoring data writing and deletion method as described in any one of claims 1 to 7.