Bad block detection method, computer program product and electronic device
By tracking write operations and marking bad blocks according to historical storage locations in the video surveillance system, the problems of poor bad block detection accuracy and data corruption in the existing technology are solved, and more accurate and secure bad block detection is achieved.
Patent Information
- Application Number
- CN202211698627.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2042-12-28
AI Technical Summary
The prior art tends to destroy stored data when detecting bad blocks, and the detection accuracy is poor.
The target storage location of the current video data is determined based on the historical storage location of the previous video data, and the operation is tracked when writing the data. If the writing fails, the location is marked as a bad block and stored in the upper-level storage location.
It improves the accuracy of bad block detection without destroying stored data, ensuring that bad blocks can be avoided when writing or reading data next time, ensuring data accuracy and security.
Smart Images

Figure CN116264096B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a bad block detection method, a computer program product, and an electronic device. Background Art
[0002] In the video surveillance industry, how to store massive surveillance video data on a hard disk is a very important technology. In the existing technology, based on the characteristics of massive surveillance video data - sequentiality, the technology of massive video data sequential storage is generally used to store and access video data, for example: video data can be stored in products such as Network Video Recorder (NVR).
[0003] In traditional file systems, bad blocks are processed by using special tools to scan the entire hard disk. If the detection is performed by writing first, reading later, and then verifying, the data stored in it will be destroyed; if only the read method is used for detection, the detection accuracy is poor. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a bad block detection method, a computer program product and an electronic device to solve the technical problem in the prior art of how to improve the accuracy of bad block detection without destroying the stored data.
[0005] In a first aspect, an embodiment of the present application provides a bad block detection method, comprising: determining a target storage location of current video data in a storage device based on a historical storage location of previous video data in the storage device; wherein the storage device comprises multiple levels of storage locations, each level of storage location comprising at least one information storage area, each information storage area being used to store description information corresponding to the storage location at that level and bad block mark information corresponding to the storage location at a next level; tracking an operation of writing the current video data to the target storage location; if writing the current video data to the target storage location fails, storing bad block mark information characterizing the target storage location as a bad block in the information storage area of the previous level storage location corresponding to the target storage location.
[0006] In the above scheme, the target storage location of the current video data can be determined based on the historical storage location of the previous video data; by tracking the operation of writing the current video data to the target storage location, the storage device can be detected in time when writing data, thereby improving the accuracy of bad block detection without destroying the data stored in the storage device; in addition, if the video data fails to be written, the bad block can be marked in time, thereby ensuring that the bad block can be avoided the next time the data is written or read, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0007] In an optional implementation, the storage device includes multiple partitions, and one partition includes multiple slices; the determination of the target storage location of the current video data in the storage device includes: determining the target partition in the storage device according to the historical storage location; reading the partition description information stored in the target partition, and determining the target slice in the target partition according to the partition description information; judging whether the target slice is a bad block according to the bad block mark information stored in the target partition; if the target slice is not a bad block, determining the target slice as the target storage location. In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, and each partition can be divided into multiple slices; after determining the target partition according to the historical storage location, the target slice can be further determined according to the partition description information. By judging whether the target slice is a bad block and writing the video data into the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate, thereby ensuring the security of user data.
[0008] In an optional implementation, after determining whether the target slice is a bad block according to the mark information stored in the target partition, the method further includes: if the target slice is a bad block, determining the next slice of the target slice as a new target slice; determining whether the new target slice is a bad block according to the bad block mark information; and if the new target is not a bad block, determining the new target slice as the target storage location. In the above scheme, it is possible to determine whether the target slice is a bad block according to the partition description information, and write the video data into the target slice that is not a bad block, thereby ensuring that the video data written to the storage device is accurate and user data security is guaranteed.
[0009] In an optional implementation, a partition includes multiple large blocks, a large block includes multiple small blocks, and a small block includes multiple slices, and the partition description information includes: large block description information, small block description information, and slice description information; the determination of the target slice in the target partition according to the partition description information includes: reading the large block description information stored in the target partition, and determining the target large block in the target partition according to the large block description information; reading the small block description information stored in the target large block, and determining the target small block in the target large block according to the small block description information; reading the slice description information stored in the target small block, and determining the target slice in the target small block according to the slice description information. In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after the target partition is determined according to the historical storage position, the target large block, target small block, and target slice can be further determined according to the large block description information, the small block description information, and the slice description information. By determining whether the target slice is a bad block and writing the video data to the target slice that is not a bad block, the video data written to the storage device is guaranteed to be accurate, thus ensuring the security of user data.
[0010] In an optional implementation, the method further includes: obtaining a storage location to be read; reading partition description information corresponding to the storage location to be read, and judging whether the storage location to be read is a bad block according to bad block mark information in the partition description information; if the storage location to be read is a bad block,
[0011] If it is not a bad block, the corresponding video data is read from the storage location to be read. In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the partition to be read according to the storage location to be read, the large block to be read, the small block to be read, and the slice to be read can be further determined according to the large block description information, the small block description information, and the slice description information. By judging the
[0012] The read slice is checked to see if it is a bad block, and the video data is read from the slice to be read that is not a bad block, thereby ensuring that the video data obtained by reading 0 is accurate.
[0013] In an optional embodiment, after storing the bad block marking information characterizing the target storage location as a bad block in the information storage area of the upper-level storage location corresponding to the target storage location, the method further includes: determining a new target storage location according to the target storage location;
[0014] Track the operation of writing the current video data into the new target storage location until the current video data is successfully written into the new target storage location.
[0015] If writing to the target storage location fails, the bad block can be avoided and the video data can be written to a storage location that can be successfully written, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0016] In an optional implementation manner, the bad block 0 mark information indicating that the target storage location is a bad block is stored in the information storage area of the upper level storage location corresponding to the target storage location.
[0017] After that, the method further includes: calculating a checksum according to at least one bad block marking information, so as to verify the at least one bad block marking information according to the checksum. In the above scheme, after the bad block marking information is stored in the storage device, a checksum can be calculated according to at least one bad block marking information stored this time and previously stored, so that it can be determined whether the bad block marking information is damaged according to the checksum, so as to ensure the accuracy of the written and read data.
[0018] In a second aspect, an embodiment of the present application provides a bad block detection device, comprising: a first determination module, used to determine the target storage position of the current video data in the storage device based on the historical storage position of the previous video data in the storage device; wherein the storage device comprises multiple levels of storage positions, each level of storage position comprises at least one information storage area, each information storage area is used to store the description information corresponding to the storage position of that level and the bad block mark information corresponding to the storage position of the next level; a first tracking module, used to track the operation of writing the current video data to the target storage position; a storage module, used to store the bad block mark information characterizing the target storage position as a bad block in the information storage area of the previous level storage position corresponding to the target storage position if the writing of the current video data to the target storage position fails.
[0019] In the above scheme, the target storage location of the current video data can be determined based on the historical storage location of the previous video data; by tracking the operation of writing the current video data to the target storage location, the storage device can be detected in time when writing data, thereby improving the accuracy of bad block detection without destroying the data stored in the storage device; in addition, if the video data fails to be written, the bad block can be marked in time, thereby ensuring that the bad block can be avoided the next time the data is written or read, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0020] In an optional implementation, the storage device includes multiple partitions, and one partition includes multiple slices; the first determination module is specifically used to: determine the target partition in the storage device according to the historical storage location; read the partition description information stored in the target partition, and determine the target slice in the target partition according to the partition description information; determine whether the target slice is a bad block according to the bad block mark information stored in the target partition; if the target slice is not a bad block, determine the target slice as the target storage location. In the above scheme, based on the principle of sequential storage, it is possible to
[0021] The storage device is divided into multiple partitions, and each partition is divided into multiple slices; after determining the target partition according to the historical storage location 5, the target slice can be further determined according to the partition description information.
[0022] The slice is checked to see if it is a bad block, and the video data is written to the target slice which is not a bad block, thereby ensuring that the video data written to the storage device is accurate and user data security is guaranteed.
[0023] In an optional implementation manner, the bad block detection device further includes: a second determination module, configured to
[0024] If the target slice is a bad block, the next slice of the target slice is determined as a new target slice; the third determination module is used to determine whether the new target slice is a bad block according to the bad block mark information; the fourth determination module is used to determine the new target slice as the target storage location if the new target is not a bad block. In the above scheme, it is possible to determine whether the target slice is a bad block according to the partition description information, and write the video data into the target slice that is not a bad block, thereby ensuring that the video data written into the storage device is accurate and user data security is guaranteed.
[0025] In an optional implementation, a partition includes multiple large blocks, and a large block includes multiple small blocks.
[0026] A small block includes multiple slices, and the partition description information includes: large block description information, small block description information and slice description information; the first determination module is further used to: read the large block description information stored in the target partition, and determine the target large block in the target partition according to the large block description information;
[0027] Read the small block description information stored in the target large block, and determine the target small block in the target large block according to the small block description information; read the slice description information stored in the target small block, and determine the target slice in the target small block according to the slice description information. In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the target partition according to the historical storage position, the target large block, target small block and target slice can be further determined according to the large block description information, small block description information and slice description information. By judging whether the target slice is a bad block and writing the video data into the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate and the user data security is guaranteed.
[0028] In an optional embodiment, the bad block detection device further includes: an acquisition module for acquiring a storage location to be read; a first reading module for reading the partition description information corresponding to the storage location to be read, and judging whether the storage location to be read is a bad block according to the bad block mark information in the partition description information; and a second reading module for reading the corresponding video data from the storage location to be read if the storage location to be read is not a bad block. In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the partition to be read according to the storage location to be read, the large block to be read, the small block to be read, and the slice to be read can be further determined according to the large block description information, the small block description information, and the slice description information. By judging whether the slice to be read is a bad block, and reading the video data from the slice that is not a bad block, it is ensured that the read video data is accurate.
[0029] In an optional implementation, the bad block detection device further includes: a fifth determination module, used to determine a new target storage location according to the target storage location; and a second monitoring module, used to track the operation of writing the current video data into the new target storage location until the current video data is successfully written into the new target storage location. In the above solution, if the video data fails to be written into the target storage location, the bad block can be avoided and the video data can be written into a storage location that can be successfully written, so as to ensure that the written or read video data is accurate, thereby protecting the user data security.
[0030] In an optional embodiment, the bad block detection device further includes: a calculation module, which is used to calculate a checksum based on at least one bad block marking information, so as to verify the at least one bad block marking information based on the checksum. In the above scheme, after the bad block marking information is stored in the storage device, a checksum can be calculated based on at least one bad block marking information stored this time and previously stored, so that it can be determined whether the bad block marking information is damaged based on the checksum, so as to ensure the accuracy of the written and read data.
[0031] In a third aspect, an embodiment of the present application provides a computer program product, including computer program instructions, which, when read and executed by a processor, execute the bad block detection method as described in the first aspect.
[0032] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory and a bus; the processor and the memory communicate with each other through the bus; the memory stores computer program instructions that can be executed by the processor, and the processor calls the computer program instructions to execute the bad block detection method described in the first aspect.
[0033] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions. When the computer program instructions are executed by a computer, the computer executes the bad block detection method as described in the first aspect.
[0034] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the following specifically cites the embodiments of the present application and describes them in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0036] Figure 1 A flowchart of a bad block detection method provided in an embodiment of the present application;
[0037] Figure 2 A schematic diagram of a video data sequential storage solution provided in an embodiment of the present application;
[0038] Figure 3 A structural block diagram of a bad block detection device provided in an embodiment of the present application;
[0039] Figure 4 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0041] Please refer to Figure 1 , Figure 1 A flowchart of a bad block detection method provided in an embodiment of the present application, the bad block detection method may include the following steps:
[0042] Step S101: Determine a target storage location of current video data in a storage device according to a historical storage location of previous video data in the storage device.
[0043] Step S102: Tracking the operation of writing the current video data into the target storage location.
[0044] Step S103: If the current video data fails to be written into the target storage location, bad block marking information indicating that the target storage location is a bad block is stored in the information storage area of the upper-level storage location corresponding to the target storage location.
[0045] Specifically, the storage device refers to a hard disk device for storing videos, and the specific implementation method thereof is not specifically limited in the embodiments of the present application. For example, the storage device may be an NVR, etc.
[0046] Since video data is continuous data, the previous video data refers to a portion of video data that has been stored in the storage device last time, and the current video data refers to a portion of video data that needs to be stored this time. Accordingly, the historical storage location corresponding to the previous video data refers to the specific location where the previous video data is stored in the storage device, and the target storage location corresponding to the current video data refers to the specific location in the storage device where the current video data can be stored.
[0047] In the above step S101, the above target storage location can be determined based on the above historical storage location. Based on the principle of sequential storage, as an implementation, the next storage location of the historical storage location in the storage device can be determined as the target storage location; as another implementation, the next storage location of the historical storage location in the storage device that is not a bad block can also be determined as the target storage location. Those skilled in the art can make appropriate adjustments based on actual conditions.
[0048] It is understandable that when there is no previous video data, that is, when the current video data is the first video data stored in the storage device, based on the principle of sequential storage, the first storage position in the storage device can be directly determined as the target storage position.
[0049] In addition, the storage device may include multiple levels of storage locations, each level of storage location includes at least one information storage area, and each information storage area is used to store description information corresponding to the storage location of that level and bad block marking information corresponding to the storage location of the next level.
[0050] Based on the principle of sequential storage, a storage device can be divided into multiple storage locations, each of which can include multiple storage locations of the next level, thereby forming a multi-level storage location. For example, a multi-level storage location can include a primary storage location and a secondary storage location, and a primary storage location includes multiple secondary storage locations; the primary storage location includes an information storage area, and the information storage area is used to store description information corresponding to the primary storage location and bad block marking information corresponding to the secondary storage location.
[0051] The embodiment of the present application does not specifically limit the specific implementation of the description information corresponding to the above storage location, and those skilled in the art may make appropriate adjustments according to actual conditions, for example:
[0052] The description information may include the storage status in the storage location of this level, the historical storage location of the previous video data, the bad blocks of the next level storage location corresponding to the storage location of this level, etc.
[0053] In the above step S102, after the target storage location is determined, the current video data can be attempted to be written into the target storage location. At this time, two situations may occur: the first situation is that the current video data is successfully written into the target storage location, that is, the current video data is successfully stored in the target storage location.
[0054] In the second case, if the current video data fails to be written into the target storage location, the above step S103 can be executed.
[0055] In the above step S103, if the current video data fails to be written into the target storage location,
[0056] The target storage location is considered to be a bad block. Therefore, in order to bypass the bad block the next time data is written or data is read, the bad block mark information indicating that the target storage location is a bad block can be stored in the information storage area of the upper-level storage location corresponding to the target storage location.
[0057] In the above scheme, the target storage location of the current video data can be determined according to the historical storage location of the previous video data; by tracking the operation of writing the current video data into the target storage location,
[0058] The storage device can be detected in time when writing data, so that the accuracy of bad block detection can be improved without destroying the data stored in the storage device 5; in addition, if the video data fails to be written, the bad block can be marked in time, so that the bad block can be avoided the next time the data is written or read, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0059] Further, based on the above embodiment, as an implementation mode, the storage device may include multiple partitions, and one partition may include multiple slices. In this case, the above step S101 may specifically include:
[0060] The steps include:
[0061] Step 1), determining a target partition in the storage device according to the historical storage location.
[0062] Step 2), read the partition description information stored in the target partition, and determine the target slice in the target partition according to the partition description information.
[0063] Step 3), judging whether the target slice is a bad block according to the bad block mark information stored in the target partition.
[0064] Step 4), if the target slice is not a bad block, the target slice is determined as the target storage location.
[0065] Specifically, in an embodiment of the present application, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each of which has the same size; then each partition can be divided into multiple slices, each of which has the same size.
[0066] On this basis, in the above step 1), the target partition in the storage device can be determined according to the historical storage position.
[0067] For example, assume that the storage device includes three partitions, each partition includes three slices, and the historical storage location is the second slice in the first partition in the storage device; if the above-mentioned first partition is full, the second partition in the storage device can be determined as the target partition; if the above-mentioned first partition is not full, the first partition in the storage device can be determined as the target partition.
[0068] It is understandable that when the historical storage location is the last partition in the storage device and the partition is full, the first partition in the storage device can be determined as the target partition, that is, the current video data is stored by overwriting the historical video data.
[0069] Therefore, in the above step 2), the partition description information stored in the target partition may be read, and then the target slice in the target partition may be determined according to the partition description information.
[0070] For example, assume that the storage device includes three partitions, each partition includes three slices, and the historical storage location is the second slice in the first partition in the storage device, and the target partition is the first partition; according to the partition description information in the first partition, if the second slice in the above-mentioned first partition is already fully stored, then the third slice in the first partition can be determined as the target slice; according to the partition description information in the first partition, if the second slice in the above-mentioned first partition is not fully stored, then the second slice in the first partition can be determined as the target slice.
[0071] In addition, in the above step 3), after the target slice is determined, it can be further determined whether the target slice is a bad block according to the mark information stored in the target partition. At this time, two situations may occur: in the first situation, the target slice is not a bad block, and the above step 4) can be performed to determine the target slice as the target storage location; in the second situation, the target slice is a bad block, and the current video data can be stored in other locations.
[0072] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, and each partition can be divided into multiple slices; after determining the target partition according to the historical storage position, the target slice can be further determined according to the partition description information. By judging whether the target slice is a bad block and writing the video data to the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate, thereby ensuring the security of user data.
[0073] Further, after the above step 3), the bad block detection method provided in the embodiment of the present application may further include the following steps:
[0074] Step 1), if the target slice is a bad block, the next slice of the target slice is determined as a new target slice.
[0075] Step 2), determine whether the new target slice is a bad block according to the bad block mark information.
[0076] Step 3), if the new target is not a bad block, the new target slice is determined as the target storage location.
[0077] Specifically, if the target slice is judged to be a bad block based on the bad block mark information, the current video data needs to be stored in other storage locations, so the next slice of the target slice can be determined as a new target slice; the next steps are similar to the above embodiment, and whether the new target slice is a bad block can be determined based on the bad block mark information.
[0078] At this time, two situations may also occur: in the first situation, the new target slice is not a bad block, then the above step 3) can be executed to determine the new target slice as the target storage location; in the second situation, the new target slice is a bad block, then the above steps 1)-2) can be repeated until the new target slice is not a bad block, and then the above step 3) is executed.
[0079] In the above scheme, it is possible to determine whether the target slice is a bad block based on the partition description information, and write the video data into the target slice that is not a bad block, thereby ensuring that the video data written to the storage device is accurate and user data security is guaranteed.
[0080] Furthermore, based on the above-mentioned embodiment, a sequential storage scheme for video data is introduced, in which the storage device includes multiple partitions, one partition includes multiple large blocks, one large block includes multiple small blocks, one small block includes multiple slices, and the partition description information includes: large block description information, small block description information and slice description information.
[0081] For example, the storage device can be divided into multiple partitions, each partition is 4TB in size, and the size of the last partition is less than or equal to 4TB; each partition is divided into multiple large blocks, each large block is 16GB in size, and the size of the last large block is less than or equal to 16GB; each large block is divided into multiple small blocks, each small block is 64MB in size, and the size of the last small block is less than or equal to 64MB; each small block is divided into multiple slices, each slice is 1MB in size, and the size of the last slice is less than or equal to 1MB.
[0082] In addition, the partition description information may include large block description information, small block description information and slice description information; the large block description information corresponding to each large block in the partition may be stored in the partition, the small block description information corresponding to the large block may be stored in the large block, and the slice description information corresponding to the small block may be stored in the small block.
[0083] Please refer to Figure 2 , Figure 2 A schematic diagram of a video data sequential storage scheme provided in an embodiment of the present application. In the sequential storage scheme, large block description information is stored in a partition header area, small block description information is stored in a large block header area, and slice description information is stored in a small block header area. It is understandable that the above description information may also be stored in other areas, and the embodiment of the present application does not specifically limit this.
[0084] Further, based on the above embodiment, the step of determining the target slice in the target partition according to the partition description information may specifically include the following steps:
[0085] Step 1), read the chunk description information stored in the target partition, and determine the target chunk in the target partition according to the chunk description information.
[0086] Step 2), read the small block description information stored in the target large block, and determine the target small block in the target large block according to the small block description information.
[0087] Step 3), read the slice description information stored in the target small block, and determine the target slice in the target small block according to the slice description information.
[0088] Specifically, in the above step 1), the block description information stored in the partition header of the target partition can be read; the block description information can store information such as the block with problems in the target partition and the block where the previous video data is stored. Therefore, based on the block description information, the target block in the target partition can be determined.
[0089] Among them, after determining the target partition according to the historical storage position, the initial large block can be determined by reading the large block description information; then, it can be judged whether the initial large block is a bad block according to the marking information in the large block description information. If the initial large block is a bad block, the next large block is determined as a new initial large block, and the judgment is repeated until the new initial large block is not a bad block; if the initial large block is not a bad block, the initial large block is determined as the target large block.
[0090] In the above step 2), the small block description information stored in the large block header of the target large block can be read; the small block description information can store information such as the small block with problems in the target large block and the small block storing the previous video data. Therefore, based on the small block description information, the target small block in the target large block can be determined.
[0091] Among them, after determining the target large block according to the large block description information, the initial small block can be determined by reading the small block description information; then, it can be judged whether the initial small block is a bad block according to the marking information in the small block description information. If the initial small block is a bad block, the next small block is determined as a new initial small block, and the judgment is repeated until the new initial small block is not a bad block; if the initial small block is not a bad block, the initial small block is determined as the target small block.
[0092] In the above step 3), the slice description information stored in the slice header of the target small block can be read; the slice description information can store information such as the slice with problems in the target small block and the slice stored in the previous video data. Therefore, based on the slice description information, the target slice in the target small block can be determined.
[0093] Among them, after determining the target small block according to the small block description information, the initial block can be determined by reading the block description information; then, it can be judged whether the initial block is a bad block according to the mark information in the block description information. If the initial block is a bad block, the next block is determined as a new initial block, and the judgment is repeated until the new small block is not a bad block; if the initial block is not a bad block, the initial block is determined as the target block.
[0094] Therefore, when writing data, it will skip based on the mark information in the large block description information, small block description information, and slice description information. That is, as long as the write position is marked as a bad block, it will directly jump to the next normal large block, normal small block or normal slice to write data.
[0095] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the target partition according to the historical storage position, the target large block, target small block and target slice can be further determined according to the large block description information, small block description information and slice description information. By judging whether the target slice is a bad block and writing the video data into the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate and the user data security is guaranteed.
[0096] Furthermore, based on the above embodiment, in addition to writing video data to a storage device, video data can also be read from the storage device. The specific implementation method of reading video data from a storage device is introduced below. The bad block detection method provided in the embodiment of the present application can also include the following steps:
[0097] Step 1), obtain the storage location to be read.
[0098] Step 2), reading the partition description information corresponding to the storage location to be read, and judging whether the storage location to be read is a bad block according to the bad block mark information in the partition description information.
[0099] Step 3), if the storage location to be read is not a bad block, the corresponding video data is read from the storage location to be read.
[0100] Specifically, in the above step 1), the storage location to be read refers to a specific storage location of the video data to be read in the storage device.
[0101] It is understandable that the embodiments of the present application do not impose any specific limitations on the specific implementation methods for obtaining the storage location to be read, and those skilled in the art may make appropriate adjustments based on actual conditions, for example: being able to respond to the user's selection of video data to be read, being able to receive the storage location to be read sent by an external device, etc.
[0102] The above steps 2) to 3) are similar to those when writing data: the partition to be read in the storage device can be determined based on the partition description corresponding to the read storage location; the large block to be read can be determined by reading the large block description information in the partition to be read; the small block to be read can be determined by reading the small block description information in the large block to be read; the slice to be read can be determined by reading the slice description information in the small block to be read, and the corresponding video data can be read from the slice to be read.
[0103] It can be understood that after determining the partition to be read according to the partition description corresponding to the read storage location, the initial large block can be determined by reading the large block description information; then, it can be determined whether the initial large block is a bad block according to the mark information in the large block description information. If the initial large block is a bad block, the next large block is determined as a new initial large block, and the judgment is repeated until the new initial large block is not a bad block; if the initial large block is not a bad block, the initial large block is determined as the large block to be read.
[0104] After determining the large block to be read according to the large block description information, the initial small block can be determined by reading the small block description information; then, it can be determined whether the initial small block is a bad block according to the bad block mark information. If the initial small block is a bad block, the next small block is determined as a new initial small block, and the judgment is repeated until the new initial small block is not a bad block; if the initial small block is not a bad block, the initial small block is determined as the small block to be read.
[0105] After the small block to be read is determined according to the small block description information, the initial block can be determined by reading the block description information; then, whether the initial block is a bad block can be determined according to the mark information in the block description information. If the initial block is a bad block, the next block is determined as a new initial block, and the judgment is repeated until the new block is not a bad block; if the initial block is not a bad block, the initial block is determined as the block to be read.
[0106] Therefore, when reading data, it will also skip based on the marking information in the large block description information, small block description information, and slice description information. That is, as long as the write position is marked as a bad block, it will directly jump to the next normal large block, normal small block or normal slice to read data.
[0107] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the partition to be read according to the storage position to be read, the large block to be read, the small block to be read, and the slice to be read can be further determined according to the large block description information, the small block description information, and the slice description information. By judging whether the slice to be read is a bad block, and reading the video data from the slice to be read that is not a bad block, it is ensured that the read video data is accurate.
[0108] Further, based on the above embodiment, after the above step S103, the bad block detection method provided in the embodiment of the present application may further include the following steps:
[0109] Step 1), determining a new target storage location according to the target storage location.
[0110] Step 2), tracking the operation of writing the current video data into the new target storage location until the current video data is successfully written into the new target storage location.
[0111] Specifically, in the above step 1), if the current video data fails to be written into the target storage location, the current video data needs to be stored in another storage location. Therefore, a new target storage location can be determined according to the target storage location; as an implementation method, based on the principle of sequential storage, the next storage location of the target storage location can be determined as the new target storage location.
[0112] The above step 2) is similar to the above step S103, and can track the operation of writing the current video data into the new target storage location. At this time, two situations may occur: in the first situation, the current video data is successfully written into the new target storage location, and the next video data can be stored; in the second situation, the current video data fails to be written into the new target storage location, and the above steps 1) to 2) can be repeated until the current video data is successfully written into the new target storage location.
[0113] In the above scheme, if the video data fails to be written to the target storage location, the bad block can be avoided and the video data can be written to a storage location that can be successfully written, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0114] Further, based on the above embodiment, after the above step S103, the bad block detection method provided in the embodiment of the present application may further include the following steps:
[0115] A checksum is calculated according to the at least one bad block marking information, so as to verify the at least one bad block marking information according to the checksum.
[0116] Specifically, after the marking information is stored in the storage device, a checksum can be calculated based on the currently stored and previously stored at least one bad block marking information for fault tolerance. In this way, when some accidents occur, the checksum can be used to find that the bad block marking information is destroyed; at this time, the bad block marking information can be reset.
[0117] In the above scheme, after the marking information is stored in the storage device, a checksum can be calculated based on the currently stored and at least one previously stored bad block marking information, so that it can be determined whether the bad block marking information is damaged based on the checksum to ensure the accuracy of the written and read data.
[0118] Furthermore, based on the above embodiment, the data stored in the storage device may be formatted.
[0119] Specifically, although the sequential storage solution uses a unique way to store massive video data, it seems that there is no concept of files, let alone the concept of file systems, but in fact it can still be regarded as a special file system, except that there is only one file, which is very large, and stores some descriptive information in a specific location to manage the storage device itself. Therefore, the storage device can be formatted; when a new storage device is identified, the initialization data can be written in a specific location of the storage device. This process is formatting.
[0120] During this formatting process, the corresponding initialization data can be written into each partition description information. If a write failure occurs during this process, the location will also be marked as a bad block, and the corresponding description information will be stored in the parent unit.
[0121] For example, assuming that the location storing small block description information in a large block fails to write data, the location can be considered a bad block, and the bad block mark information of the location and the small block description information in the large block are stored in the information storage area corresponding to the large block.
[0122] Therefore, the timings for marking bad blocks include: initializing the storage device, writing description information, and writing video data. The timings for applying bad block marking data of bad blocks include: writing video data, and reading video data.
[0123] Further, based on the above embodiment, large block description information, small block description information and slice description information can all be exported to fully and in detail display the bad block status of the entire storage device, and the user can decide whether to replace the storage device accordingly.
[0124] Please refer to Figure 3 , Figure 3A structural block diagram of a bad block detection device provided in an embodiment of the present application, the bad block detection device 300 includes: a first determination module 301, used to determine the target storage location of the current video data in the storage device according to the historical storage location of the previous video data in the storage device; wherein the storage device includes multiple levels of storage locations, each level of storage location includes at least one information storage area, and each information storage area is used to store description information corresponding to the storage location of that level and bad block mark information corresponding to the storage location of the next level; a first tracking module 302, used to track the operation of writing the current video data to the target storage location; a storage module 303, used to store the bad block mark information characterizing the target storage location as a bad block in the information storage area of the previous level storage location corresponding to the target storage location if the writing of the current video data to the target storage location fails.
[0125] In the above scheme, the target storage location of the current video data can be determined based on the historical storage location of the previous video data; by tracking the operation of writing the current video data to the target storage location, the storage device can be detected in time when writing data, thereby improving the accuracy of bad block detection without destroying the data stored in the storage device; in addition, if the video data fails to be written, the bad block can be marked in time, thereby ensuring that the bad block can be avoided the next time the data is written or read, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0126] Further, based on the above embodiment, the storage device includes multiple partitions, and one partition includes multiple slices; the first determination module 301 is specifically used to: determine the target partition in the storage device according to the historical storage location; read the partition description information stored in the target partition, and determine the target slice in the target partition according to the partition description information; determine whether the target slice is a bad block according to the bad block mark information stored in the target partition; if the target slice is not a bad block, determine the target slice as the target storage location.
[0127] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, and each partition can be divided into multiple slices; after determining the target partition according to the historical storage position, the target slice can be further determined according to the partition description information. By judging whether the target slice is a bad block and writing the video data to the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate, thereby ensuring the security of user data.
[0128] Furthermore, based on the above embodiment, the bad block detection device 300 also includes: a second determination module, which is used to determine the next slice of the target slice as a new target slice if the target slice is a bad block; a third determination module, which is used to determine whether the new target slice is a bad block according to the bad block mark information; and a fourth determination module, which is used to determine the new target slice as the target storage location if the new target is not a bad block.
[0129] In the above scheme, it is possible to determine whether the target slice is a bad block based on the partition description information, and write the video data into the target slice that is not a bad block, thereby ensuring that the video data written to the storage device is accurate and user data security is guaranteed.
[0130] Further, based on the above embodiment, a partition includes multiple large blocks, a large block includes multiple small blocks, and a small block includes multiple slices, and the partition description information includes: large block description information, small block description information and slice description information; the first determination module 301 is also used to: read the large block description information stored in the target partition, and determine the target large block in the target partition according to the large block description information; read the small block description information stored in the target large block, and determine the target small block in the target large block according to the small block description information; read the slice description information stored in the target small block, and determine the target slice in the target small block according to the slice description information.
[0131] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the target partition according to the historical storage position, the target large block, target small block and target slice can be further determined according to the large block description information, small block description information and slice description information. By judging whether the target slice is a bad block and writing the video data into the target slice that is not a bad block, the video data written into the storage device is guaranteed to be accurate and the user data security is guaranteed.
[0132] Furthermore, based on the above embodiment, the bad block detection device 300 also includes: an acquisition module, used to acquire the storage position to be read; a first reading module, used to read the partition description information corresponding to the storage position to be read, and determine whether the storage position to be read is a bad block according to the bad block mark information in the partition description information; a second reading module, used to read the corresponding video data from the storage position to be read if the storage position to be read is not a bad block.
[0133] In the above scheme, based on the principle of sequential storage, the storage device can be divided into multiple partitions, each partition can be divided into multiple large blocks, each large block can be divided into multiple small blocks, and each small block can be divided into multiple slices; after determining the partition to be read according to the storage position to be read, the large block to be read, the small block to be read, and the slice to be read can be further determined according to the large block description information, the small block description information, and the slice description information. By judging whether the slice to be read is a bad block, and reading the video data from the slice that is not a bad block, it is ensured that the read video data is accurate.
[0134] Furthermore, based on the above embodiment, the bad block detection device 300 also includes: a fifth determination module, used to determine a new target storage location based on the target storage location; a second monitoring module, used to track the operation of writing the current video data to the new target storage location until the current video data is successfully written to the new target storage location.
[0135] In the above scheme, if the video data fails to be written to the target storage location, the bad block can be avoided and the video data can be written to a storage location that can be successfully written, ensuring that the written or read video data is accurate, thereby protecting user data security.
[0136] Furthermore, based on the above embodiment, the bad block detection device 300 further includes: a calculation module, configured to calculate a checksum according to at least one bad block marking information, so as to verify the at least one bad block marking information according to the checksum.
[0137] In the above scheme, after the bad block marking information is stored in the storage device, a checksum can be calculated based on the bad block marking information stored this time and at least one bad block marking information stored previously, so that it can be determined whether the bad block marking information is damaged based on the checksum to ensure the accuracy of the written and read data.
[0138] Please refer to Figure 4 , Figure 4 The structural block diagram of an electronic device provided in an embodiment of the present application, the electronic device 400 includes: at least one processor 401, at least one communication interface 402, at least one memory 403 and at least one communication bus 404. Among them, the communication bus 404 is used to realize the direct connection and communication of these components, the communication interface 402 is used to communicate signaling or data with other node devices, and the memory 403 stores machine-readable instructions executable by the processor 401. When the electronic device 400 is running, the processor 401 communicates with the memory 403 through the communication bus 404, and the above-mentioned bad block detection method is executed when the machine-readable instruction is called by the processor 401.
[0139] For example, the processor 401 of the embodiment of the present application reads a computer program from the memory 403 through the communication bus 404 and executes the computer program to implement the following method: Step S101: Determine the target storage location of the current video data in the storage device according to the historical storage location of the previous video data in the storage device. Step S102: Track the operation of writing the current video data to the target storage location. Step S103: If the current video data fails to be written to the target storage location, then store the bad block mark information indicating that the target storage location is a bad block in the information storage area of the upper-level storage location corresponding to the target storage location.
[0140] Among them, the processor 401 includes one or more, which can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 401 can be a general-purpose processor, including a central processing unit (CPU), a micro control unit (MCU), a network processor (NP) or other conventional processors; it can also be a dedicated processor, including a neural network processor (NPU), a graphics processor (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. In addition, when there are multiple processors 401, some of them can be general-purpose processors and the other part can be dedicated processors.
[0141] The memory 403 includes one or more, which may be, but not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0142] Understandably, Figure 4 The structure shown is for illustration only. The electronic device 400 may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in can be implemented by hardware, software or a combination thereof. In the embodiment of the present application, the electronic device 400 can be, but not limited to, a physical device such as a desktop computer, a laptop computer, a smart phone, a smart wearable device, a vehicle-mounted device, etc., and can also be a virtual device such as a virtual machine. In addition, the electronic device 400 is not necessarily a single device, but can also be a combination of multiple devices, such as a server cluster, etc.
[0143] An embodiment of the present application also provides a computer program product, including a computer program stored on a computer-readable storage medium, the computer program including computer program instructions, and when the computer program instructions are executed by a computer, the computer can execute the steps of the bad block detection method in the above-mentioned embodiment, for example including: determining the target storage position of the current video data in the storage device according to the historical storage position of the previous video data in the storage device; wherein the storage device includes multiple levels of storage positions, each level of storage position includes at least one information storage area, each information storage area is used to store description information corresponding to the storage position of this level and bad block mark information corresponding to the storage position of the next level; tracking the operation of writing the current video data to the target storage position; if the writing of the current video data to the target storage position fails, storing the bad block mark information characterizing that the target storage position is a bad block in the information storage area of the previous level storage position corresponding to the target storage position.
[0144] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions. When the computer program instructions are executed by a computer, the computer executes the bad block detection method described in the aforementioned method embodiment.
[0145] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0146] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0148] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM) random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0149] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0150] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A bad block detection method, characterized in that: include: Determine the target storage location of the current video data in the storage device according to the historical storage location of the previous video data in the storage device; wherein the storage device includes multiple levels of storage locations, each level of storage location includes at least one information storage area, and each information storage area is used to store description information corresponding to the storage location at that level and bad block mark information corresponding to the storage location at the next level; Tracking the operation of writing the current video data into the target storage location; If the current video data fails to be written into the target storage location, bad block marking information indicating that the target storage location is a bad block is stored in the information storage area of the upper-level storage location corresponding to the target storage location; The storage device includes a plurality of partitions, and a partition includes a plurality of slices; Determining the target storage location of the current video data in the storage device includes: Determine a target partition in the storage device according to the historical storage location; Reading partition description information stored in the target partition, and determining a target slice in the target partition according to the partition description information; Determining whether the target slice is a bad block according to the bad block marking information stored in the target partition; If the target slice is not a bad block, the target slice is determined as the target storage location.
2. The bad block detection method according to claim 1, characterized in that: After determining whether the target slice is a bad block according to the mark information stored in the target partition, the method further includes: If the target slice is a bad block, the next slice of the target slice is determined as a new target slice; Determine whether the new target slice is a bad block according to the bad block mark information; If the new target is not a bad block, the new target slice is determined as the target storage location.
3. The bad block detection method according to claim 2, characterized in that: A partition includes multiple large blocks, a large block includes multiple small blocks, and a small block includes multiple slices, and the partition description information includes: large block description information, small block description information and slice description information; The determining the target slice in the target partition according to the partition description information includes: Reading the chunk description information stored in the target partition, and determining the target chunk in the target partition according to the chunk description information; Reading the small block description information stored in the target large block, and determining the target small block in the target large block according to the small block description information; The slice description information stored in the target small block is read, and the target slice in the target small block is determined according to the slice description information.
4. The bad block detection method according to any one of claims 1 to 3, characterized in that: The method further comprises: Get the storage location to be read; Reading the partition description information corresponding to the storage location to be read, and judging whether the storage location to be read is a bad block according to the bad block mark information in the partition description information; If the storage location to be read is not a bad block, the corresponding video data is read from the storage location to be read.
5. The bad block detection method according to any one of claims 1 to 3, characterized in that: After storing the bad block marking information indicating that the target storage location is a bad block in the information storage area of the upper-level storage location corresponding to the target storage location, the method further includes: determining a new target storage location according to the target storage location; The operation of writing the current video data into the new target storage location is tracked until the current video data is successfully written into the new target storage location.
6. The bad block detection method according to any one of claims 1 to 3, characterized in that: After storing the bad block marking information indicating that the target storage location is a bad block in the information storage area of the upper-level storage location corresponding to the target storage location, the method further includes: A checksum is calculated according to at least one piece of bad block marking information, so as to verify the at least one piece of bad block marking information according to the checksum.
7. A computer program product, characterized in that The method comprises computer program instructions, and when the computer program instructions are read and executed by a processor, the bad block detection method according to any one of claims 1 to 6 is executed.
8. An electronic device, characterized in that: include: processor, memory, and bus; The processor and the memory communicate with each other via the bus; The memory stores computer program instructions that can be executed by the processor, and the processor calls the computer program instructions to execute the bad block detection method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a computer, the computer executes the bad block detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data writing method and device of solid state disk, computer equipment and storage medium
CN111722803A
Bit map control of erase block defect list in a memory
US20090161430A1