Data writing method and apparatus, device, and medium

By monitoring the disk loading event and performing exception detection, the target data partition is determined, and the corruption problem caused by accidental power failure of the FAT32 file system is solved, and the stable write of data is achieved.

WO2025179855A1PCT designated stage Publication Date: 2025-09-04CRSC RESEARCH & DESIGN INSTITUTE GROUP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/121143
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-02-26
Filing Date
2024-09-25
Publication Date
2025-09-04

AI Technical Summary

Technical Problem

The FAT32 file system accidentally lost power during data writing, resulting in damage and could not write data again.

Method used

Listen to disk loading events, determine the write data partition and perform exception detection, determine the target data partition from the write partition and backup partition according to the detection results and categories, and write the data to the target partition.

Benefits of technology

Ensure that data can be written normally in the case of a failure in the write partition, and improve the stability of data writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024121143_04092025_PF_FP_ABST
    Figure CN2024121143_04092025_PF_FP_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data storage. Disclosed are a data writing method and apparatus, a device, and a medium. The method comprises: when a disk mount event is detected, determining a write data partition of a disk; performing anomaly detection on the write data partition to obtain an anomaly detection result and an anomaly category of the write data partition; determining a target data partition from among the write data partition and at least one backup data partition on the basis of the anomaly detection result and the anomaly category of the write data partition; and writing data into the target data partition of the disk. According to the technical solutions in embodiments of the present invention, data can be normally written into the disk, improving the data writing stability.
Need to check novelty before this filing date? Find Prior Art

Description

Data writing method, device, equipment and medium Technical Field

[0001] The present invention relates to the field of data storage technology, and in particular to a data writing method, device, equipment and medium. Background Art

[0002] The FAT32 (File Allocation Table) file system is a file system that uses 32-bit binary numbers to record and manage disk files. It is widely used in various terminal devices or storage media.

[0003] If the storage medium loses power unexpectedly while writing data, the FAT32 file system will be damaged, making it impossible to write data to the storage medium again.

[0004] Summary of the Invention

[0005] The present invention provides a data writing method, device, equipment and medium to ensure that data can be written into a disk normally and guarantee the stability of data writing.

[0006] In a first aspect, the present invention provides a data writing method, comprising:

[0007] After monitoring the disk mounting event, determine the disk's write data partition;

[0008] Perform anomaly detection on the written data partition to obtain anomaly detection results and anomaly categories of the written data partition;

[0009] determining a target data partition from the write data partition and at least one backup data partition according to an anomaly detection result and an anomaly category of the write data partition;

[0010] Write the data to the target data partition of the disk.

[0011] In a second aspect, the present invention further provides a data writing device, comprising:

[0012] A first partition determination module is used to determine the write data partition of the disk after monitoring the disk loading event;

[0013] Anomaly detection module, used to detect anomalies in written data partitions;

[0014] a second partition determination module, configured to determine a target data partition from the write data partition and at least one backup data partition according to an abnormality detection result of the write data partition;

[0015] The data writing module is used to write data to the target data partition of the disk.

[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, including:

[0017] at least one processor; and

[0018] a memory communicatively coupled to at least one processor; wherein

[0019] The memory stores instructions that can be executed by at least one processor. The instructions are executed by the at least one processor so that the at least one processor can execute the data writing method provided by any embodiment of the present invention.

[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data writing method of any embodiment of the present invention when executed.

[0021] The embodiment of the present invention determines the write data partition of the disk after monitoring a disk loading event; performs anomaly detection on the write data partition to obtain anomaly detection results and anomaly categories of the write data partition; determines a target data partition from the write data partition and at least one backup data partition based on the anomaly detection results and anomaly categories of the write data partition; and writes data to the target data partition of the disk. The embodiment of the present invention can perform anomaly detection on the write data partition of the disk after monitoring a disk loading event, thereby determining a target data partition to which data can be normally written, and writes the data to the target data partition. In the event that a fault exists in the write data partition, data can be written to the target data partition, thereby ensuring that data can be normally written to the disk and improving the stability of data writing.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] FIG1 is a flow chart of a data writing method provided according to a first embodiment of the present invention;

[0025] FIG2 is a flow chart of a data writing method provided according to a second embodiment of the present invention;

[0026] FIG3 is a flow chart of a data writing method provided in Embodiment 3 of the present invention;

[0027] FIG4 is a schematic structural diagram of a data writing device provided according to a fourth embodiment of the present invention;

[0028] FIG5 is a schematic structural diagram of an electronic device for implementing the data writing method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first" and "second" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this way are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or apparatus.

[0031] In the technical solutions of the embodiments of the present invention, the acquisition, storage and application of data, disk loading events and abnormal detection results involved all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0032] Example 1

[0033] Figure 1 is a flowchart of a data writing method provided in Example 1 of the present invention. This embodiment is applicable to the situation of writing data into a data partition of a disk. The method can be executed by a data writing device, which can be implemented in the form of hardware and / or software and specifically configured in an electronic device, such as a server.

[0034] Referring to the data writing method shown in FIG1 , the method includes:

[0035] S101: After a disk mounting event is monitored, a data writing partition of the disk is determined.

[0036] S102: Perform anomaly detection on the written data partition to obtain an anomaly detection result and an anomaly category of the written data partition.

[0037] S103: Determine a target data partition from the write data partition and at least one backup data partition according to the abnormality detection result and abnormality category of the write data partition.

[0038] S104: Write the data into the target data partition of the disk.

[0039] In this embodiment, a disk mount event may refer to an event in which a mounted disk is identified. A write data partition may be a pre-defined data partition for writing data. Anomaly detection results may include, but are not limited to, normal and abnormal. Anomaly categories may correspond to the anomaly detection results for the data partition; if the anomaly detection result is normal, the anomaly category is empty. A backup data partition may be a data partition other than the write data partition and may serve as a backup for the write data partition. A target data partition may be the data partition ultimately used for writing data.

[0040] Specifically, after a disk mount event is detected, the disk's write partition parameter value is obtained; the data partition corresponding to the write partition parameter value is queried, and the queried data partition is used as the write data partition, and data partitions other than the write data partition are used as backup data partitions. The write partition parameter value can be used to identify the write data partition. For example, if the write partition parameter value is 0, and the data partition corresponding to 0 is data partition A, then data partition A is the write data partition.

[0041] In an optional embodiment, the disk includes, in addition to the write data partition and the backup data partition, a parameter partition for storing write partition parameter values. After a disk mount event is monitored, the write partition parameter values ​​of the disk can be obtained from the parameter partition of the disk.

[0042] In an optional embodiment, a data writer according to an embodiment of the present invention is deployed in an electronic device and can monitor a disk mount event after powering on. In a specific implementation, the disk can be pre-loaded in the electronic device, and the disk mount event can be monitored after the electronic device is powered on; or, the disk can be unloaded in the electronic device before the electronic device is powered on; after the electronic device is powered on, the disk is loaded in the electronic device so that the electronic device monitors the disk mount event.

[0043] A set anomaly detection algorithm is used to perform anomaly detection on the write data partition to obtain the anomaly detection result of the write data partition and the anomaly category of the write data partition; a set target data partition determination algorithm is used to determine the target data partition from the write data partition and at least one backup data partition based on the anomaly detection result and anomaly category of the write data partition, and the data is written to the target data partition of the disk.

[0044] The embodiment of the present invention determines the write data partition of the disk after monitoring a disk loading event; performs anomaly detection on the write data partition to obtain anomaly detection results and anomaly categories of the write data partition; determines a target data partition from the write data partition and at least one backup data partition based on the anomaly detection results and anomaly categories of the write data partition; and writes data to the target data partition of the disk. The embodiment of the present invention can perform anomaly detection on the write data partition of the disk after monitoring a disk loading event, thereby determining a target data partition to which data can be normally written, and writes the data to the target data partition. In the event that a fault exists in the write data partition, data can be written to the target data partition, thereby ensuring that data can be normally written to the disk and improving the stability of data writing.

[0045] Example 2

[0046] FIG2 is a flow chart of a data writing method provided by a second embodiment of the present invention. Based on the technical solutions of the above embodiments, the embodiment of the present invention optimizes and improves the operation of determining the target data partition.

[0047] Further, "determine the target data partition from the write data partition and at least one backup data partition based on the anomaly detection result and anomaly category of the write data partition" is refined into "if the anomaly detection result of the write data partition is normal, use the write data partition as the target data partition; if the anomaly detection result of the write data partition is abnormal, repair the write data partition based on the anomaly category of the write data partition; determine the repair result of the write data partition, and determine the target data partition from the write data partition and each backup data partition based on the repair result of the write data partition" to perform the target data partition determination operation.

[0048] It should be noted that for the parts not described in detail in the embodiments of the present invention, reference can be made to the description of the aforementioned embodiments.

[0049] Referring to the data writing method shown in FIG2 , the method includes:

[0050] S201: After a disk mounting event is detected, a data writing partition of the disk is determined.

[0051] S202: Perform anomaly detection on the written data partition to obtain an anomaly detection result and anomaly category of the written data partition.

[0052] S203: If the abnormality detection result of the written data partition is normal, the written data partition is used as the target data partition.

[0053] S204: If the abnormality detection result of the written data partition is abnormal, repair the written data partition according to the abnormality category of the written data partition.

[0054] Specifically, if the abnormality detection result of the written data partition is abnormal, the set algorithm is used to repair the written data partition according to the abnormality category of the written data partition.

[0055] S205: Determine the repair result of the written data partition, and determine the target data partition from the written data partition and each backup data partition according to the repair result of the written data partition.

[0056] The repair result may refer to whether the repair of the written data partition is successful, including but not limited to repair success and repair failure. Specifically, a predetermined algorithm is used to determine the repair result of the written data partition, and based on the repair result of the written data partition, a target data partition is determined from the written data partition and the backup data partition.

[0057] Optionally, based on the repair result of the written data partition, the target data partition is determined from the written data partition and each backup data partition, including: if the repair result of the written data partition is a successful repair, the written data partition is used as the target data partition; if the repair result of the written data partition is a failed repair, anomaly detection is performed on each backup data partition, and based on the anomaly detection result of each backup data partition, the target data partition is determined from each backup data partition.

[0058] The process of performing anomaly detection on backup data partitions is similar to that of performing anomaly detection on write data partitions. Specifically, if the repair result of the write data partition is repair failure, anomaly detection is performed on each backup data partition to obtain anomaly detection results for each backup data partition. A predetermined algorithm is then used to determine the target data partition from each backup data partition based on the anomaly detection results for each backup data partition.

[0059] It can be understood that, by adopting the above technical solution, if the write data partition is repaired successfully, the write data partition will be used as the target data partition; if the write data partition is repaired unsuccessfully, the target data partition will be determined from each backup data partition based on the abnormality detection results of each backup data partition, ensuring that the write data partition that can write data normally will be used as the target data partition, thereby improving the stability of data writing.

[0060] Optionally, based on the anomaly detection results of each backup data partition, a target data partition is determined from each backup data partition, including: if the anomaly detection result of a backup data partition is normal, the backup data partition with a normal anomaly detection result is determined as a normal backup partition, and the target data partition is determined from the normal backup partition; if the anomaly detection results of each backup data partition are all abnormal, each backup data partition is formatted, and the target data partition is determined from each formatted backup data partition.

[0061] Specifically, if the abnormality detection result of a backup data partition is normal, the backup data partition with the normal abnormality detection result is determined as the normal backup partition; if there is only one normal backup partition, the normal backup partition is used as the target data partition; if there are multiple normal backup partitions, one normal backup partition is selected from each normal backup partition as the target data partition; if the abnormality detection results of each backup data partition are abnormal, each backup data partition is formatted; and one backup data partition is selected from each formatted backup data partition as the target data partition.

[0062] It can be understood that by adopting the above technical solution, when a normal backup partition exists, the target data partition can be selected from the normal backup partition; when a normal backup partition does not exist, the abnormal backup data partitions are formatted to reset the abnormal backup data partition to a backup data partition that can write data normally, and the target data partition is selected from the formatted backup data partition to ensure that the write data partition that can write data normally is used as the target data partition, thereby improving the stability of data writing.

[0063] S206: Write the data into the target data partition of the disk.

[0064] The technical solution of the embodiment of the present invention is as follows: if the abnormality detection result of the write data partition is normal, the write data partition is used as the target data partition; if the abnormality detection result of the write data partition is abnormal, the write data partition is repaired according to the abnormality category of the write data partition; the repair result of the write data partition is determined, and according to the repair result of the write data partition, the target data partition is determined from the write data partition and each backup data partition, which can ensure that the write data partition that can write data normally is used as the target data partition, thereby improving the stability of data writing.

[0065] Example 3

[0066] FIG3 is a flow chart of a data writing method provided by a third embodiment of the present invention. Based on the technical solutions of the above embodiments, the embodiment of the present invention optimizes and improves the abnormality detection operation of writing data partitions.

[0067] Furthermore, "perform anomaly detection on the write data partition to obtain the anomaly detection result and anomaly category of the write data partition" is refined into "obtain the disk's end-write directory, and query the cluster chain corresponding to the end-write directory; determine whether the cluster chain corresponding to the end-write directory is continuous; if the cluster chain corresponding to the end-write directory is discontinuous, determine that the anomaly detection result of the write data partition is abnormal, and determine that the anomaly category of the write data partition is a directory cluster chain abnormality; if the cluster chain corresponding to the end-write directory is continuous, count the number of directory entries in the cluster chain corresponding to the end-write directory, and use the number of directory entries as the number of files in the end-write directory; obtain the number of end-directory files corresponding to the end-write directory; determine the anomaly detection result and anomaly category of the write data partition based on the comparison result of the number of files in the end-write directory and the number of files in the end-directory", so as to improve the anomaly detection operation on the write data partition.

[0068] It should be noted that for the parts not described in detail in the embodiments of the present invention, reference can be made to the description of the aforementioned embodiments.

[0069] Referring to the data writing method shown in FIG3 , the method includes:

[0070] S301: After a disk mounting event is monitored, determine the write data partition of the disk.

[0071] S302: Obtain the end-write directory of the disk, and query the cluster chain corresponding to the end-write directory.

[0072] In this embodiment, data may be stored in the form of files in the data partition of the disk. Specifically, the files are stored in the corresponding directories in the data partition. For any directory, the directory may occupy at least one cluster, and the clusters of the directory may be used to store directory entries corresponding to the files in the directory; wherein, a cluster may be a basic storage unit in the data partition. The directory entries corresponding to the files may be used to store file information of the files, and the file information may include but is not limited to the file name, file size, and the starting cluster number of the file; the directories also have corresponding directory entries, and the directory entries of the directories may be used to store directory information of the directories, such as the directory name, directory size, and the starting cluster number of the directory. The cluster chain corresponding to the terminated write directory may refer to a cluster number chain obtained by connecting the cluster numbers of the clusters occupied by the terminated write directory according to a set algorithm.

[0073] In this embodiment, the ending write directory may refer to the directory where the file to which the last data written to the disk belongs is located; the directory name of the ending write directory may be stored as a parameter in the disk's parameter partition. For a disk to which no data has been written, the directory name of the ending write directory is empty. Upon completion of any data write operation, the ending write directory name is updated to the directory name of the directory where the file to which the last data written in the operation belongs is located.

[0074] Specifically, the directory name of the disk's end-write directory is obtained, and the directory corresponding to the directory name is used as the end-write directory; the starting cluster number in the directory entry of the end-write directory is obtained; the cluster chain including only the starting cluster number is used as the target cluster chain; the value of the starting cluster number in the corresponding table entry in the file allocation table is used as the target cluster number; the table entry corresponding to the target cluster number is queried in the file allocation table, and it is determined whether the table entry corresponding to the target cluster number is queried; if the table entry corresponding to the target cluster number is not queried, the target cluster number is connected after the target cluster chain, and the target cluster chain connected after the target cluster number is used as the cluster chain corresponding to the end-write directory; if the table entry corresponding to the target cluster number is queried, the target cluster number is connected after the target cluster chain, and the target cluster chain is updated to the target cluster chain connected after the target cluster number, and the target cluster number is updated to the value in the table entry corresponding to the queried target cluster number; return to execute the step of querying the table entry corresponding to the target cluster number in the file allocation table, and determining whether the table entry corresponding to the target cluster number is queried, until the table entry corresponding to the target cluster number is not queried, and the cluster chain corresponding to the end-write directory is obtained.

[0075] For example, if the starting cluster number of the directory that ends writing is 3; the value of the corresponding entry of the starting cluster number 3 in the file allocation table is 7; the value of the corresponding entry of cluster number 7 in the file allocation table is 101; and there is no entry corresponding to cluster number 101 in the file allocation table, then the cluster chain of the directory that ends writing is 3-7-101.

[0076] S303: Determine whether the cluster chain corresponding to the terminated write directory is continuous.

[0077] Specifically, determine whether the last cluster number in the cluster chain of the terminated write directory is the end cluster identifier; if the last cluster number is not the end cluster identifier, determine that the cluster chain of the terminated write directory is discontinuous; if the last cluster number is the end cluster identifier, determine that the cluster chain of the terminated write directory is continuous; wherein, the end cluster identifier can be used to uniquely identify the end cluster; the end cluster can be a cluster used to represent the end of the cluster chain, which is a conceptual cluster and is not used to actually store data, but is only used to represent the end of the cluster chain.

[0078] In an optional embodiment, if the termination write directory is empty, the disk has not been written to data, that is, the disk is used for the first time, and the abnormality detection result of the write data partition is determined to be normal, and the abnormality category of the write data partition is empty.

[0079] S304: If the cluster chain corresponding to the terminated write directory is discontinuous, determine that the abnormality detection result of writing the data partition is abnormal, and determine that the abnormality category of writing the data partition is a directory cluster chain abnormality.

[0080] S305: If the cluster chain corresponding to the terminated writing directory is continuous, count the number of directory entries in the cluster chain corresponding to the terminated writing directory, and use the number of directory entries as the number of files in the terminated writing directory.

[0081] S306: Obtain the number of files in the termination directory corresponding to the termination writing directory.

[0082] In this embodiment, the number of terminated write directories may refer to the number of files in the terminated write directory. The number of terminated write files may be stored as a parameter in a parameter partition of the disk. For a disk to which no data has been written, the number of files in the terminated write directory is empty. For any data write operation, at the end of the data write operation, the number of files in the terminated write directory is counted, and the number of terminated write directories is updated to the counted number of files.

[0083] S307: Determine the abnormality detection result and abnormality category of the write data partition based on the comparison result of the number of files in the termination directory and the number of files in the termination directory.

[0084] Specifically, a set algorithm is used to determine the abnormality detection result and abnormality category of the write data partition according to the comparison result of the number of files in the termination writing directory and the number of files in the termination directory.

[0085] Optionally, based on the comparison result of the number of files in the termination write directory and the number of files in the termination directory, the abnormality detection result and abnormality category of the write data partition are determined, including: if the comparison result of the number of files in the termination write directory and the number of files in the termination directory are inconsistent, then the abnormality detection result of the write data partition is determined to be abnormal, and the abnormality category of the write data partition is determined to be file number abnormality; if the comparison result of the number of files in the termination write directory and the number of files in the termination directory are consistent, then the termination write file of the disk is obtained, and the cluster chain corresponding to the termination write file is queried; it is determined whether the cluster chain corresponding to the termination write directory is continuous; if the cluster chain corresponding to the termination write file is discontinuous, then the abnormality detection result of the write data partition is determined to be abnormal, and the abnormality category of the write data partition is determined to be file cluster chain abnormality; if the cluster chain corresponding to the termination write directory is continuous, then the abnormality detection result of the write data partition is determined to be normal, and the abnormality category of the write data partition is determined to be empty.

[0086] In this embodiment, the "terminated write file" may refer to the file to which the last data written to the disk belongs. Any file stored in the data partition may occupy at least one cluster, which is used to store the file's data. During the data writing process, at least one cluster may be allocated to any file. The process for storing cluster numbers for each file cluster is similar to that for directories and will not be further described here.

[0087] Specifically, if the comparison result of the number of files in the termination writing directory and the number of files in the termination directory is inconsistent, the abnormality detection result of writing the data partition is determined to be abnormal, and the abnormality category of writing the data partition is determined to be file quantity abnormality.

[0088] If the comparison result of the number of files in the termination write directory and the number of files in the termination directory are consistent, then obtain the termination write file on the disk and query the cluster chain corresponding to the termination write file; determine whether the cluster chain corresponding to the termination write directory is continuous; among them, the query process of the cluster chain corresponding to the termination write file is similar to the query process of the cluster chain corresponding to the termination write directory, and the determination process of whether the cluster chain corresponding to the termination write file is continuous is similar to the determination process of whether the cluster chain corresponding to the termination write directory is continuous, which will not be repeated here.

[0089] If the cluster chain corresponding to the terminated writing file is discontinuous, the abnormality detection result of writing the data partition is determined to be abnormal, and the abnormality category of writing the data partition is determined to be file cluster chain abnormality; if the cluster chain corresponding to the terminated writing directory is continuous, the abnormality detection result of writing the data partition is determined to be normal, and the abnormality category of writing the data partition is determined to be empty.

[0090] It can be understood that by adopting the above technical solution, based on whether the comparison results of the number of files in the termination write directory and the number of files in the termination directory are consistent, it can be determined whether there are faults such as file data loss in the write data partition, and then determine whether the write data partition is abnormal; and when the comparison results of the number of files in the termination write directory and the number of files in the termination directory are consistent, based on whether the cluster chain corresponding to the termination write directory is continuous, it is determined whether the file data can be correctly stored in the cluster in the write data partition, and then determine whether the write data partition is abnormal, which can improve the accuracy of abnormality detection for the write data partition.

[0091] S308: If the abnormality detection result of the written data partition is normal, the written data partition is used as the target data partition.

[0092] S309: If the abnormality detection result of the written data partition is abnormal, repair the written data partition according to the abnormality category of the written data partition.

[0093] Optionally, the write data partition is repaired according to the exception category of the write data partition, including: if the exception category of the write data partition is a directory cluster chain exception, determining the interrupt cluster of the terminated write directory, and determining the end cluster as the cluster pointed to by the interrupt cluster; if the exception category of the write data partition is a file quantity exception, determining the invalid directory entries in the cluster chain corresponding to the terminated write directory; removing the invalid directory entries, and updating the number of end directory files corresponding to the terminated write directory; if the exception category of the write data partition is a file cluster chain exception, determining the interrupt cluster of the terminated write file, and determining the end cluster as the cluster pointed to by the interrupt cluster.

[0094] In this embodiment, the interrupt cluster may be a cluster corresponding to the interrupt position in the cluster chain. The cluster pointed to by the interrupt cluster may be a cluster in the cluster chain that is adjacent to the interrupt cluster and connected after the interrupt cluster.

[0095] Specifically, if the exception category of writing to the data partition is a directory cluster chain exception, the cluster number in the cluster chain corresponding to the terminated write directory that is adjacent to the last cluster number and connected before the last cluster number is determined as the interrupted cluster number; the cluster corresponding to the interrupted cluster number is used as the interrupted cluster, and the end cluster identifier is stored in the table entry corresponding to the interrupted cluster number in the file allocation table, so that the end cluster is used as the cluster pointed to by the interrupted cluster, so that the cluster chain of the terminated write directory is continuous.

[0096] If the abnormality category of writing data partition is abnormal number of files, the directory entries of each cluster in the cluster chain corresponding to the terminated writing directory will be used as the directory entries of the cluster chain corresponding to the terminated writing directory; and the file name format of each directory entry will be checked to see if it is in the preset format; the directory entries whose file name format is not in the preset format will be determined as invalid directory entries; the invalid directory entries will be removed from each directory entry in the cluster chain corresponding to the terminated writing directory, and the number of files in the terminated directory will be updated to the difference between the number of the terminated file directory and the number of invalid directory entries.

[0097] Among them, when the exception category of writing the data partition is a file cluster chain exception, the process of determining the interrupted cluster in the cluster chain corresponding to the terminated file writing is similar to the process of determining the interrupted cluster in the cluster chain corresponding to the terminated directory writing, and the process of determining the end cluster as the cluster pointed to by the interrupted cluster in the cluster chain corresponding to the terminated file writing is similar to the process of determining the end cluster as the cluster pointed to by the interrupted cluster in the cluster chain corresponding to the terminated directory writing, which will not be repeated here.

[0098] It can be understood that by adopting the above technical solution, when there is an abnormality in the directory cluster chain or the file cluster chain, the end cluster can be connected after the interrupted cluster to make the cluster chain continuous, thereby avoiding the inability to perform correct cluster allocation when writing data due to the interruption of the cluster chain, and thus the inability to write data normally; in the case of an abnormal number of files, removing invalid directory entries can avoid errors caused by accessing or operating invalid directory entries, which may cause damage or loss of other data, thereby improving the stability of writing data partitions.

[0099] S310: Determine a repair result of the written data partition, and determine a target data partition from the written data partition and each backup data partition according to the repair result of the written data partition.

[0100] Optionally, determining the repair result of the written data partition includes: performing an anomaly detection on the repaired written data partition; if the anomaly detection result of the repaired written data partition is abnormal, determining the repair result of the written data partition as a repair failure; if the anomaly detection result of the repaired written data partition is normal, determining the repair result of the written data partition as a repair success. It should be noted that the process of performing anomaly detection on the repaired written data partition is similar to the process of performing anomaly detection on the written data partition, and will not be repeated here.

[0101] S311. Write the data into the target data partition of the disk.

[0102] The technical solution of the embodiment of the present invention can determine whether the data can be correctly stored in the cluster in the write data partition by determining whether the cluster chain corresponding to the termination write directory is continuous, and further determine whether the write data partition is abnormal; and when the cluster chain corresponding to the termination write directory is continuous, it can further determine whether the write data partition is abnormal based on the comparison result of the number of files in the termination write directory and the number of files in the termination directory, thereby avoiding obtaining erroneous anomaly detection results and improving the accuracy of anomaly detection for the write data partition.

[0103] Example 4

[0104] Figure 4 is a schematic diagram of the structure of a data writing device provided in accordance with a fourth embodiment of the present invention. This embodiment of the present invention is applicable to situations where data is written to a data partition of a disk. The device can execute a data writing method, can be implemented in hardware and / or software, and can be configured in an electronic device, such as a server.

[0105] Referring to the data writing device shown in FIG4 , it includes a first partition determination module 401 , an anomaly detection module 402 , a second partition determination module 403 and a data writing module 404 , wherein:

[0106] The first partition determination module 401 is configured to determine the write data partition of the disk after monitoring a disk mounting event;

[0107] Anomaly detection module 402, used to perform anomaly detection on the written data partition;

[0108] A second partition determination module 403 is configured to determine a target data partition from the written data partition and at least one backup data partition according to an abnormality detection result of the written data partition;

[0109] The data writing module 404 is used to write data into the target data partition of the disk.

[0110] In an embodiment of the present invention, a first partition determination module determines the disk's write data partition after monitoring a disk loading event; an anomaly detection module performs anomaly detection on the write data partition; a second partition determination module determines a target data partition from the write data partition and at least one backup data partition based on the anomaly detection result of the write data partition; and a data writing module writes data to the target data partition of the disk. In an embodiment of the present invention, after monitoring a disk loading event, an anomaly detection is performed on the disk's write data partition, thereby determining a target data partition to which data can be normally written, and writing the data to the target data partition. Furthermore, in the event of a failure in the write data partition, data can be written to the target data partition, thereby ensuring that data can be normally written to the disk and improving the stability of data writing.

[0111] Optionally, the second partition determination module 403 includes:

[0112] a first partition determination unit, configured to use the written data partition as a target data partition if the abnormality detection result of the written data partition is normal;

[0113] a partition repair unit, configured to repair the written data partition according to the abnormality category of the written data partition if the abnormality detection result of the written data partition is abnormal;

[0114] The second partition determining unit is configured to determine a repair result of the written data partition, and determine a target data partition from the written data partition and each backup data partition according to the repair result of the written data partition.

[0115] Optionally, the second partition determination unit includes:

[0116] a first partition determination subunit, configured to use the written data partition as a target data partition if the repair result of the written data partition is that the repair is successful;

[0117] The second partition determination subunit is configured to perform abnormality detection on each backup data partition if the repair result of the write data partition is repair failure, and determine a target data partition from each backup data partition according to the abnormality detection result of each backup data partition.

[0118] Optionally, the second partition determination subunit is specifically configured to:

[0119] If the abnormality detection result of the backup data partition is normal, the backup data partition with the normal abnormality detection result is determined as a normal backup partition, and the target data partition is determined from the normal backup partition;

[0120] If the abnormality detection results of each backup data partition are abnormal, each backup data partition is formatted, and a target data partition is determined from the formatted backup data partitions.

[0121] Optionally, the anomaly detection module 402 includes:

[0122] A cluster chain query unit is used to obtain the disk's end-write directory and query the cluster chain corresponding to the end-write directory;

[0123] A cluster chain detection unit, used to determine whether the cluster chain corresponding to the terminated write directory is continuous;

[0124] a first result determination unit, configured to determine that the abnormality detection result of writing the data partition is abnormal if the cluster chain corresponding to the terminated writing directory is discontinuous, and determine that the abnormality type of writing the data partition is a directory cluster chain abnormality;

[0125] a directory entry number query unit, configured to count the number of directory entries in the cluster chain corresponding to the terminated writing directory if the cluster chain corresponding to the terminated writing directory is continuous, and use the number of directory entries as the number of files in the terminated writing directory;

[0126] A file quantity acquisition unit is used to obtain the number of files in the termination directory corresponding to the termination writing directory;

[0127] The second result determination unit is configured to determine an abnormality detection result and an abnormality category of the write data partition according to a comparison result of the number of files in the write termination directory and the number of files in the termination directory.

[0128] Optionally, the second detection result determining unit includes:

[0129] a first result determination subunit, configured to determine that the abnormality detection result of the write data partition is abnormal, and determine that the abnormality category of the write data partition is abnormal in the number of files if the comparison result of the number of files in the ending write directory and the number of files in the ending directory is inconsistent;

[0130] The cluster chain query subunit is used to obtain the terminated write file on the disk and query the cluster chain corresponding to the terminated write file if the comparison result of the number of files in the terminated write directory and the number of files in the terminated directory are consistent;

[0131] A cluster chain detection subunit, used to determine whether the cluster chain corresponding to the terminated write directory is continuous;

[0132] A second result determination subunit is configured to determine that the abnormality detection result of writing the data partition is abnormal if the cluster chain corresponding to the terminated writing file is discontinuous, and determine that the abnormality category of writing the data partition is a file cluster chain abnormality;

[0133] The third result determination subunit is configured to determine that the abnormality detection result of the write data partition is normal if the cluster chain corresponding to the terminated write directory is continuous, and to determine that the abnormality category of the write data partition is empty.

[0134] Optional, partition repair unit, including:

[0135] A first repair subunit is configured to determine an interrupt cluster for terminating directory writing if the abnormality type of writing to the data partition is a directory cluster chain abnormality, and determine the end cluster as the cluster pointed to by the interrupt cluster;

[0136] an invalid directory entry determination subunit, configured to determine to terminate writing of invalid directory entries in a cluster chain corresponding to a directory if the abnormality category of writing a data partition is abnormal number of files;

[0137] The second repair subunit is used to remove invalid directory entries and update the number of termination directory files corresponding to the termination writing directory;

[0138] The third repair subunit is configured to determine an interrupt cluster for terminating the writing of the file if the abnormality type of the writing data partition is a file cluster chain abnormality, and determine the end cluster as the cluster pointed to by the interrupt cluster.

[0139] The data writing device provided by the embodiment of the present invention can execute the data writing method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the data writing method.

[0140] Example 5

[0141] FIG5 shows a block diagram of an electronic device 500 that can be used to implement an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0142] As shown in Figure 5, the electronic device 500 includes at least one processor 501 and a memory connected to the at least one processor 501, such as a read-only memory (ROM) 502, a random access memory (RAM) 503, etc., wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 501 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 502 or the computer program loaded from the storage unit 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The processor 501, ROM 502 and RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0143] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0144] The processor 501 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Examples of the processor 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors for running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 501 executes the various methods and processes described above, such as the data writing method.

[0145] In some embodiments, the data writing method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by processor 501, one or more steps of the data writing method described above can be performed. Alternatively, in other embodiments, processor 501 can be configured to perform the data writing method by any other appropriate means (e.g., by means of firmware).

[0146] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0147] Computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data writing device, so that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0148] In the context of the present invention, computer-readable storage medium can be a tangible medium that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage medium can include but is not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage medium can be a machine-readable signal medium. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device or any suitable combination of the foregoing.

[0149] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0150] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0151] A computing system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers and establishing a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within a cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosts and VPS (Virtual Private Server) services.

[0152] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0153] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A data writing method, characterized in that: The method comprises: After monitoring a disk mounting event, determining a write data partition of the disk; Performing anomaly detection on the write data partition to obtain an anomaly detection result and an anomaly category of the write data partition; determining a target data partition from the write data partition and at least one backup data partition according to an anomaly detection result and an anomaly category of the write data partition; The data is written to the target data partition of the disk.

2. The method according to claim 1, characterized in that The determining of a target data partition from the write data partition and at least one backup data partition according to the abnormality detection result and abnormality category of the write data partition comprises: If the abnormality detection result of the written data partition is normal, the written data partition is used as the target data partition; If the abnormality detection result of the written data partition is abnormal, repairing the written data partition according to the abnormality category of the written data partition; A repair result of the written data partition is determined, and a target data partition is determined from the written data partition and each of the backup data partitions according to the repair result of the written data partition.

3. The method according to claim 2, characterized in that The determining of a target data partition from the written data partition and each of the backup data partitions according to the repair result of the written data partition comprises: If the repair result of the written data partition is successful, the written data partition is used as the target data partition; If the repair result of the written data partition is repair failure, an abnormality detection is performed on each of the backup data partitions, and the target data partition is determined from each of the backup data partitions according to the abnormality detection results of each of the backup data partitions.

4. The method according to claim 3, characterized in that The step of determining the target data partition from each backup data partition according to the abnormality detection result of each backup data partition comprises: If the abnormality detection result of the backup data partition is normal, the backup data partition whose abnormality detection result is normal is determined as a normal backup partition, and the target data partition is determined from the normal backup partition; If the abnormality detection results of the backup data partitions are all abnormal, formatting is performed on the backup data partitions, and the target data partition is determined from the formatted backup data partitions.

5. The method according to claim 2, characterized in that The performing anomaly detection on the write data partition to obtain an anomaly detection result and an anomaly category of the write data partition includes: Obtaining the write termination directory of the disk, and querying the cluster chain corresponding to the write termination directory; Determine whether the cluster chain corresponding to the terminated write directory is continuous; If the cluster chain corresponding to the terminated write directory is discontinuous, determining that the abnormality detection result of the write data partition is abnormal, and determining that the abnormality category of the write data partition is a directory cluster chain abnormality; If the cluster chain corresponding to the write-stop directory is continuous, counting the number of directory entries in the cluster chain corresponding to the write-stop directory, and using the number of directory entries as the number of files in the write-stop directory; Obtain the number of files in the termination directory corresponding to the termination writing directory; The abnormality detection result and abnormality category of the write data partition are determined according to a comparison result of the number of files in the write termination directory and the number of files in the termination directory.

6. The method according to claim 5, characterized in that The determining of the abnormality detection result and abnormality category of the write data partition according to the comparison result of the number of files in the write termination directory and the number of files in the termination directory includes: If the comparison result of the number of files in the termination directory and the number of files in the termination directory is inconsistent, determining that the abnormality detection result of the write data partition is abnormal, and determining the abnormality category of the write data partition is abnormal number of files; If the comparison result of the number of files in the termination directory and the number of files in the termination directory is If they are consistent, the write termination file of the disk is obtained, and the cluster chain corresponding to the write termination file is queried; Determine whether the cluster chain corresponding to the terminated write directory is continuous; If the cluster chain corresponding to the terminated write file is discontinuous, determining that the abnormality detection result of the write data partition is abnormal, and determining that the abnormality category of the write data partition is a file cluster chain abnormality; If the cluster chain corresponding to the terminated write directory is continuous, it is determined that the abnormality detection result of the write data partition is normal, and the abnormality category of the write data partition is determined to be empty.

7. The method according to claim 6, characterized in that The repairing of the written data partition according to the abnormality category of the written data partition includes: If the abnormality type of the data writing partition is a directory cluster chain abnormality, determining the interrupt cluster for terminating the directory writing, and determining the end cluster as the cluster pointed to by the interrupt cluster; If the abnormal category of the data writing partition is abnormal number of files, determining an invalid directory entry in the cluster chain corresponding to the directory for terminating writing; Remove the invalid directory entry and update the number of termination directory files corresponding to the termination writing directory; If the abnormality type of the data writing partition is a file cluster chain abnormality, the interruption cluster for terminating the writing of the file is determined, and the end cluster is determined to be the cluster pointed to by the interruption cluster.

8. A data writing device, characterized in that: The device comprises: A first partition determination module is configured to determine a write data partition of the disk after monitoring a disk loading event; An anomaly detection module, used to perform anomaly detection on the written data partition; a second partition determination module, configured to determine a target data partition from the write data partition and at least one backup data partition according to an abnormality detection result of the write data partition; The data writing module is used to write data into the target data partition of the disk.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the data writing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data writing method according to any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • Terminal data recovery method and device, equipment and storage medium

    CN115373901A

  • Terminal starting method, electronic equipment and computer readable storage medium

    CN116257384A

  • Data writing method and device, equipment and medium

    CN118069056A

  • Unsupervised anomaly detection machine learning frameworks

    US20230229738A1