Disclosure of Invention
The invention mainly aims to solve the technical problem that the problem of finding the current disk after the software crashes is difficult.
The first aspect of the present invention provides a method for restoring a scan crash environment, where the method for restoring a scan crash environment includes:
when the source partition is scanned, reading the corresponding storage size of a scanned designated data block, recording the state information of the designated data block, and recording the offset of the designated data block;
when the scanning breakdown is monitored, collecting the state information of the appointed data block;
moving the offset in the source partition, and reading the storage data of the storage size on the moved address;
inquiring a partition with the storage capacity not smaller than that of the source partition in a preset storage disk to obtain a target partition, and writing the storage data into the target partition;
and loading the state information, and scanning the target partition to the address of the offset to obtain crash data.
Optionally, in a first implementation manner of the first aspect of the present invention, the writing the storage data to the target partition includes:
converting the storage data into binary data, and writing the binary data into the target partition.
Optionally, in a second implementation manner of the first aspect of the present invention, when the source partition is scanned, reading a corresponding storage size of a scanned specified data block, and recording state information of the specified data block, and recording an offset of the specified data block includes:
creating a shared memory when scanning the source partition;
reading the corresponding storage size of the scanned designated data block, recording the state information of the designated data block, recording the offset of the designated data block, and writing the offset, the storage size and the state information into the shared memory.
Optionally, in a third implementation manner of the first aspect of the present invention, the writing the offset, the storage size, and the state information into the shared memory includes:
based on a JOSN format, carrying out serialization processing on the state information to obtain serial state data;
and writing the sequence state data into the shared memory.
Optionally, in a fourth implementation manner of the first aspect of the present invention, when the monitoring detects that the scan crashes, collecting the state information of the specified data block includes:
and when the scanning breakdown is monitored, reading all the state information in the shared memory, and uploading all the state information to a preset server.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the loading the state information, scanning the target partition to the address of the offset, and obtaining crash data includes:
and analyzing the state information in a reverse ordering mode, and loading the state information into the address of the offset in the target partition to obtain crash data.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the monitoring when the scan crashes includes:
judging whether an abnormal exit code exists in the scanning process;
if the abnormal exit code exists, the scanning process is determined to be in a scanning collapse state.
The second aspect of the present invention provides a scan-down environment restoration device, which includes:
the reading and recording module is used for reading the corresponding storage size of the scanned appointed data block and recording the state information of the appointed data block when the source partition is scanned and recording the offset of the appointed data block;
the state collection module is used for collecting state information of the appointed data block when scanning breakdown is monitored;
the offset reading module is used for moving the offset in the source partition and reading the storage data of the storage size on the moved address;
the partition writing module is used for inquiring the partition with the storage capacity not smaller than that of the source partition in a preset storage disk to obtain a target partition, and writing the storage data into the target partition;
and the state loading module is used for loading the state information, scanning the target partition to the address of the offset and obtaining crash data.
A third aspect of the present invention provides an environment restoration device for scan collapse, comprising: a memory and at least one processor, the memory having instructions stored therein, the memory and the at least one processor being interconnected by a line; the at least one processor invokes the instructions in the memory to cause the scan-collapsed environment restoration device to perform the scan-collapsed environment restoration method described above.
A fourth aspect of the present invention provides a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the above-described method of context restoration of a scan crash.
In the embodiment of the invention, aiming at the partition of a lost file of a user, scanning is carried out according to the designated data block size, in the scanning process, the scanning state information and the offset and the size of the data block of the current scanning are analyzed and recorded, and when the occurrence of breakdown of software is detected, the information is collected and uploaded; after the collected crash information is received, finding out a partition with the capacity not smaller than that of the source partition as a target partition, restoring the partition to the target partition according to the offset and the size of the data block with the scanning crash, and reloading the scanning state information by software to scan so as to reproduce the crash.
Detailed Description
The embodiment of the invention provides a method, a device, equipment and a storage medium for restoring a scanning crash environment.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
For ease of understanding, the following describes a specific flow of an embodiment of the present invention, referring to fig. 1, and one embodiment of a method for restoring an environment of a scan crash in an embodiment of the present invention includes:
101. when the source partition is scanned, reading the corresponding storage size of a scanned designated data block, recording the state information of the designated data block, and recording the offset of the designated data block;
in the present embodiment, S1: in the process of scanning source partition, analyzing the specified data block size buffer_size each time, and recording scanning type state information class_data and the data block offset amount crash_offset read in the current scanning.
Further, at 101 the following steps may be performed:
1011. creating a shared memory when scanning the source partition;
1012. reading the corresponding storage size of the scanned designated data block, recording the state information of the designated data block, recording the offset of the designated data block, and writing the offset, the storage size and the state information into the shared memory.
In steps 1011-1012, it can be illustrated in the following manner:
x1: when the scanning process is started, a daemon process is started at the same time, and the daemon process creates a shared memory share_memory as a data interaction with the scanning process;
x2: meanwhile, the daemon process records the handle of the scanning process and monitors the exit state of the scanning process in real time;
x3: when scanning starts, a scanning process opens a shared memory share_memory of X1 and records a memory block pointer share_memory_ptr;
x4: in the process of scanning source partition, starting from partition initial offset 0, reading and analyzing the specified data block size buffer_size each time;
x5: after each analysis is completed for one data block, recording and scanning state information class_data (such as member variable values of the analysis class object), serializing in json format, and writing in the share_memory according to the share_memory_ptr position of X3;
x6: at the same time, the offset buffer_offset of the data block currently being scanned is also written onto the share_memory according to the share_memory_ptr position of X3.
Further, at 1012, the following steps may be performed:
10121. based on a JOSN format, carrying out serialization processing on the state information to obtain serial state data;
10122. and writing the sequence state data into the shared memory.
In the steps 10121-10122, the following steps can be used to describe:
x5: after each analysis is completed for one data block, recording and scanning state information class_data (such as member variable values of the analysis class object), serializing in json format, and writing in the share_memory according to the share_memory_ptr position of X3;
x6: at the same time, the offset buffer_offset of the data block currently being scanned is also written onto the share_memory according to the share_memory_ptr position of X3.
102. When the scanning breakdown is monitored, collecting the state information of the appointed data block;
103. moving the offset in the source partition, and reading the storage data of the storage size on the moved address;
in steps 102-103, the following procedure is used:
s2: the other process detects the exit state of the program in real time, when the program crashes, the class_data of the uploading S1 is collected, the data block content crash_buffer with the size of buffer_size is read at the crash_offset position of the source partition to the S1, and the uploading is collected.
Further, at 102 the following steps may be performed:
1021. and when the scanning breakdown is monitored, reading all the state information in the shared memory, and uploading all the state information to a preset server.
In this embodiment, X7: when the scanning process crashes, after the daemon detects the abnormal exit code of the scanning process, reading the class_data (all scanning state information before the scanning crashes) recorded by X5 in the shared memory share_memory in a binary mode, writing the class_data_file into the file, and uploading the file to a server.
X8: and simultaneously, reading the buffer_offset recorded by the X6 in the shared memory, opening the source partition of the user, starting at the buffer_offset position, reading the data block of the buffer_size, writing the buffer_offset and the buffer_buffer into the file buffer_buffer_file, and uploading the file buffer_file to the server.
Further, the following steps may be performed when a scan crash is monitored:
1022. judging whether an abnormal exit code exists in the scanning process;
1023. if the abnormal exit code exists, the scanning process is determined to be in a scanning collapse state.
In step 1022-1023, the basis for judging whether the scanning crash occurs is whether an abnormal exit code is received or not, continuously monitoring whether the abnormal exit code occurs, and if the abnormal exit code occurs, confirming that the scanning process is in a scanning crash state.
104. Inquiring a partition with the storage capacity not smaller than that of the source partition in a preset storage disk to obtain a target partition, and writing the storage data into the target partition;
in the present embodiment, S3: and (3) locally finding a partition with capacity not smaller than that of the source partition, taking the partition as a target partition, and restoring the crash_buffer collected by S2 into the target partition in a binary writing mode.
Further, the following steps may be performed in "write the storage data to the target partition":
1041. converting the storage data into binary data, and writing the binary data into the target partition.
In 1041 step, X9: and locally finding one or creating a partition with the capacity not smaller than the size of the source partition, taking the partition as a target partition crash_partition, downloading and analyzing a crash_buffer_file collected by X8 from a server, obtaining buffer_offset and crash_buffer recorded by X8, positioning the buffer_offset position of the target partition, and writing the buffer_offset position into a data block crash_buffer in a binary mode, thereby restoring the content of the current data block of a user with scanning breakdown.
105. And loading the state information, and scanning the target partition to the address of the offset to obtain crash data.
In the present embodiment, the following is performed: s4: starting a program, loading the class_data information collected by the S2, starting to scan the target partition constructed by the S3, scanning the class_offset position of the S1, and reproducing the crash, so that a developer can conveniently analyze the cause of the crash.
105 may also perform the following:
x10: downloading the class_data_file collected by X7 from a server, starting a scanning program, analyzing the class_data_file in a json deserializing mode, and loading the class_data_file into the state information of a scanning class object of the program (initializing the member variable value of the analysis class object), thereby restoring all scanning state information before the user has scanning breakdown;
x11: and (3) starting scanning, and selecting the partition crash_partition of the X9 to scan until the specified buffer_offset is scanned, so that the crash can be reproduced, and a developer can conveniently analyze and solve the crash reason.
In the embodiment of the invention, aiming at the partition of a lost file of a user, scanning is carried out according to the designated data block size, in the scanning process, the scanning state information and the offset and the size of the data block of the current scanning are analyzed and recorded, and when the occurrence of breakdown of software is detected, the information is collected and uploaded; after the collected crash information is received, finding out a partition with the capacity not smaller than that of the source partition as a target partition, restoring the partition to the target partition according to the offset and the size of the data block with the scanning crash, and reloading the scanning state information by software to scan so as to reproduce the crash.
The above description is given of the method for restoring the environment of the scan crash in the embodiment of the present invention, and the following description is given of the apparatus for restoring the environment of the scan crash in the embodiment of the present invention, referring to fig. 2, which is an embodiment of the apparatus for restoring the environment of the scan crash in the embodiment of the present invention, where the apparatus for restoring the environment of the scan crash includes:
the reading and recording module 201 is configured to read a corresponding storage size of a scanned specified data block and record status information of the specified data block when scanning the source partition, and record an offset of the specified data block;
a state collection module 202, configured to collect state information of the specified data block when a scanning crash is monitored;
an offset reading module 203, configured to move the offset in the source partition, and read the storage data of the storage size on the moved address;
a partition writing module 204, configured to query a preset storage disk for a partition with a storage capacity not less than that of the source partition, obtain a target partition, and write the storage data into the target partition;
the state loading module 205 is configured to load the state information, and scan the target partition to the address of the offset, to obtain crash data.
In the embodiment of the invention, aiming at the partition of a lost file of a user, scanning is carried out according to the designated data block size, in the scanning process, the scanning state information and the offset and the size of the data block of the current scanning are analyzed and recorded, and when the occurrence of breakdown of software is detected, the information is collected and uploaded; after the collected crash information is received, finding out a partition with the capacity not smaller than that of the source partition as a target partition, restoring the partition to the target partition according to the offset and the size of the data block with the scanning crash, and reloading the scanning state information by software to scan so as to reproduce the crash.
Referring to fig. 3, in another embodiment of the invention, a scan-collapsed environment restoration device includes:
the reading and recording module 201 is configured to read a corresponding storage size of a scanned specified data block and record status information of the specified data block when scanning the source partition, and record an offset of the specified data block;
a state collection module 202, configured to collect state information of the specified data block when a scanning crash is monitored;
an offset reading module 203, configured to move the offset in the source partition, and read the storage data of the storage size on the moved address;
a partition writing module 204, configured to query a preset storage disk for a partition with a storage capacity not less than that of the source partition, obtain a target partition, and write the storage data into the target partition;
the state loading module 205 is configured to load the state information, and scan the target partition to the address of the offset, to obtain crash data.
Wherein, the partition writing module 204 is specifically configured to:
converting the storage data into binary data, and writing the binary data into the target partition.
Wherein, the reading recording module 201 includes:
a creating unit 2011, configured to create a shared memory when scanning the source partition;
a record writing unit 2012, configured to read a storage size corresponding to a scanned specified data block, record status information of the specified data block, record an offset of the specified data block, and write the offset, the storage size, and the status information into the shared memory.
The record writing unit 2012 specifically includes:
based on a JOSN format, carrying out serialization processing on the state information to obtain serial state data;
and writing the sequence state data into the shared memory.
The state collection module 202 is specifically configured to:
and when the scanning breakdown is monitored, reading all the state information in the shared memory, and uploading all the state information to a preset server.
The state loading module 205 is specifically configured to:
and analyzing the state information in a reverse ordering mode, and loading the state information into the address of the offset in the target partition to obtain crash data.
Wherein, the state collection module 202 is further specifically configured to:
judging whether an abnormal exit code exists in the scanning process;
if the abnormal exit code exists, the scanning process is determined to be in a scanning collapse state.
In the embodiment of the invention, aiming at the partition of a lost file of a user, scanning is carried out according to the designated data block size, in the scanning process, the scanning state information and the offset and the size of the data block of the current scanning are analyzed and recorded, and when the occurrence of breakdown of software is detected, the information is collected and uploaded; after the collected crash information is received, finding out a partition with the capacity not smaller than that of the source partition as a target partition, restoring the partition to the target partition according to the offset and the size of the data block with the scanning crash, and reloading the scanning state information by software to scan so as to reproduce the crash.
The above fig. 2 and fig. 3 describe the scan-down environment restoration device in the embodiment of the present invention in detail from the point of view of the modularized functional entity, and the following describes the scan-down environment restoration device in the embodiment of the present invention in detail from the point of view of hardware processing.
Fig. 4 is a schematic structural diagram of a scan-down environment restoration device according to an embodiment of the present invention, where the scan-down environment restoration device 400 may have a relatively large difference due to different configurations or performances, and may include one or more processors (central processing units, CPU) 410 (e.g., one or more processors) and a memory 420, and one or more storage media 430 (e.g., one or more mass storage devices) storing application programs 433 or data 432. Wherein memory 420 and storage medium 430 may be transitory or persistent storage. The program stored on the storage medium 430 may include one or more modules (not shown), each of which may include a series of instruction operations in the environment restoration device 400 for a scan crash. Still further, the processor 410 may be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the scan-collapsed environment restoration device 400.
The scan-crash based environment restoration device 400 may also include one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input-output interfaces 560, and/or one or more operating systems 431, such as Windows Server, mac OS X, unix, linux, freeBSD, and the like. Those skilled in the art will appreciate that the scan-collapsed environment restoration device structure illustrated in fig. 4 does not constitute a definition of a scan-collapsed environment restoration device, and may include more or fewer components than illustrated, or may combine certain components, or may be a different arrangement of components.
The present invention also provides a computer readable storage medium, which may be a non-volatile computer readable storage medium, and may also be a volatile computer readable storage medium, where instructions are stored in the computer readable storage medium, which when executed on a computer, cause the computer to perform the steps of the method for restoring an environment of a scan crash.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the system or apparatus and unit described above may refer to the corresponding process in the foregoing method embodiment, which is not repeated herein.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a read-only memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.