Bad block repairing method and device, computer equipment and storage medium

By concurrently scanning and repairing multiple hard disk partitions of SSDs and using log synchronization, the problem of low efficiency in identifying and repairing bad blocks in SSDs is solved, improving storage performance and stability.

CN118656247APending Publication Date: 2024-09-17ZHENGZHOU INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410841715.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

In the existing technology, solid-state drives (SSDs) may misjudge bad blocks when they experience abnormal power outages, resulting in an increase in the number of bad blocks and affecting storage performance. In addition, bad block scanning tools have low identification and repair efficiency, affecting storage performance.

Method used

By scanning a preset number of hard disk partitions for bad blocks at the same time, and updating the scanning information in real time during the scanning process, the bad block location information is obtained to locate the bad blocks to be repaired, and repairs are performed concurrently on multiple hard disk partitions, using logs as an intermediary. Synchronize scan and repair results.

Benefits of technology

It improves the efficiency of scanning and repairing bad blocks, reduces the number of garbage collections, ensures the stability of storage performance, identifies and repairs bad blocks in a timely manner, and avoids the problem of stuck scanning processes caused by too many bad blocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656247A
    Figure CN118656247A
Patent Text Reader

Abstract

The invention relates to the technical field of storage, and discloses a bad block repairing method and device, computer equipment and a storage medium, and the method comprises the steps: carrying out bad block scanning on a preset number of hard disk partitions at the same time, and updating the preset number of scanning process information in real time; in the bad block scanning process, the position information of the bad block is obtained in the scanning process information, and the position information is used for positioning the bad block; according to the position information, the bad blocks to be repaired in the bad blocks are repaired, a bad block repairing result is obtained, and the bad blocks to be repaired are determined according to the position information and the disk analysis tool. The problems that bad block recognition efficiency is low, bad blocks are difficult to repair in time, and storage performance is affected are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] If the SSD (Solid State Disk) does not have an abnormal power-off protection function, an abnormal power-off may cause the main controller to misjudge a bad block or actually generate a bad block. If there are enough bad blocks in the entire SSD, the available blocks will decrease, which will increase the number of garbage collections. At the same time, the OP (Over-Provisioning) capacity will decrease, which will seriously affect the garbage collection efficiency. Therefore, when the number of bad blocks increases to a certain level, it will affect the performance stability of the SSD and may cause data damage or loss. Therefore, it is necessary to repair the bad blocks to reduce the impact of bad blocks on the SSD.

[0003] Currently, bad block scanning tools are used to scan SSDs, identify bad blocks, and repair them. However, in actual scanning, bad block scanning tools are inefficient in identifying bad blocks, and the scanning time ranges from tens of minutes to hundreds of thousands of minutes. If there are too many bad blocks, the scanning time will be longer, making it difficult to repair the bad blocks in time, affecting storage performance.

[0004] Therefore, the related technology has the problem of low efficiency in identifying bad blocks, difficulty in timely repairing bad blocks, and affecting storage performance. Summary of the invention

[0005] In view of this, the present invention provides a bad block repair method, apparatus, computer equipment and storage medium to solve the problem of low efficiency in identifying bad blocks, difficulty in timely repairing bad blocks, and affecting storage performance.

[0006] In a first aspect, the present invention provides a bad block repair method, comprising:

[0007] Perform bad block scans on a preset number of hard disk partitions at the same time, and update the preset number of scanning process information in real time;

[0008] During the bad block scanning process, the position information of the bad block is obtained from the scanning process information, wherein the position information is used to locate the bad block;

[0009] According to the position information, the bad blocks to be repaired in the bad blocks are repaired to obtain the bad block repair result, wherein the bad blocks to be repaired are determined according to the position information and the disk analysis tool.

[0010] The bad block repair method provided in this embodiment simultaneously scans bad blocks for a preset number of hard disk partitions, and obtains the location information of the bad blocks from the scanning process information during the scanning process. After the location information is obtained, the bad blocks to be repaired in the bad blocks are repaired according to the location information, so that multiple hard disk partitions can be scanned concurrently for bad blocks, the scanning process information can be monitored in real time, the bad blocks to be repaired can be identified and repaired in time, and the bad block repair results can be obtained, so that the available blocks of the entire disk are increased and the number of garbage collection times is reduced. Bad block scanning, bad block repair, and result analysis are performed simultaneously, so that the analysis results are basically output synchronously with the completion of the scanning task. The problem of low efficiency in identifying bad blocks, difficulty in repairing bad blocks in time, and affecting storage performance is solved.

[0011] In some optional implementations, bad block scanning is performed on a preset number of hard disk partitions at the same time, and the preset number of scanning process information is updated in real time, including:

[0012] Obtaining first drive letters corresponding to a preset number of hard disk partitions, wherein the hard disk partitions do not include an operating system;

[0013] According to the bad block scanning command and the first drive letter, bad block scanning is performed on a preset number of hard disk partitions concurrently, and a preset number of scanning process logs are updated in real time, wherein the scanning process logs contain scanning process information.

[0014] In this embodiment, bad block scanning is performed concurrently on a preset number of hard disk partitions according to the bad block scanning command and the first drive letter, thereby improving the bad block scanning efficiency, and the scanning process information is written into the scanning process log, and the scanning results are logged. With the help of the log as an intermediate medium, the synchronous output of the task flow and result analysis is achieved, thereby optimizing the execution efficiency.

[0015] In some optional implementations, during the bad block scanning process, obtaining the bad block location information in the scanning process information includes:

[0016] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0017] If a bad block to be determined appears, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information; the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0018] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, the subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log, and then the process ends;

[0019] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0020] The subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log.

[0021] In some optional implementations, during the bad block scanning process, obtaining the bad block location information in the scanning process information includes:

[0022] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0023] If a bad block to be determined appears, the first time when the bad block to be determined appears is recorded, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information, and the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0024] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, subsequent steps are performed starting from reading the row information of the scanning process log;

[0025] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0026] Record the current second time;

[0027] Determine whether the time difference between the second time and the first time is less than a preset threshold;

[0028] If it is less than, the subsequent steps are executed starting from reading the row information of the scanning process log;

[0029] If it is not less than, determine whether the scan end mark can be read in the scan process log. If the scan end mark can be read, then end and output the bad block record result. If the scan end mark cannot be read, re-scan the bad blocks of the hard disk partition corresponding to the scan process log to obtain a new scan process log. Use the new scan process log as the scan process log, and execute subsequent steps starting from reading the row information of the scan process log until the bad block record result is output, then end.

[0030] In this embodiment, a preset number of hard disk partitions are scanned for bad blocks concurrently, and the location information of the bad blocks is obtained in the scanning process information, thereby improving the bad block scanning efficiency. In addition, by recording the first time and the second time, and judging whether the time difference between the second time and the first time is less than a preset threshold, it is determined whether the hard disk partition needs to be re-scanned for bad blocks, and a minute-level bad block scanning task is added to prevent the bad block scanning process from being stuck due to too many bad blocks.

[0031] In some optional implementations, repairing the bad blocks to be repaired in the bad blocks according to the position information to obtain the bad block repair result includes:

[0032] Obtain the first total amount of bad block information in the bad block record result;

[0033] Get the position parameter n, set n to the initial value, and determine whether n is less than the first total amount;

[0034] When n is less than the first total amount, obtaining the first field value in the nth bad block information;

[0035] When the first field value is the first preset value, n=n+1 is set, and subsequent steps are performed starting from determining whether n is less than the first total amount;

[0036] In the case where the first field value is the second preset value, the second drive letter and sector identifier in the nth bad block information are input into the repairability judgment script, and the judgment result is written into the second field value in the nth bad block information;

[0037] If the second field value is the third preset value, modify the first field value in the nth bad block information to the first preset value;

[0038] If the second field value is a fourth preset value, the bad block corresponding to the nth bad block information is used as the bad block to be repaired, the second drive letter and the sector identifier in the nth bad block information are input into the bad block repair tool, the bad block to be repaired is repaired, and the first field value in the nth bad block information is modified to the first preset value;

[0039] Set n=n+1, and start executing subsequent steps from determining whether n is less than the first total amount;

[0040] When n is not less than the first total amount, obtaining a second total amount of bad block information in the bad block record result;

[0041] Determine whether the second total amount is greater than the first total amount;

[0042] If the second total amount is not greater than the first total amount, determining whether the scan end flags exist in all the preset number of scan process logs; if they do exist, taking the bad block record result as the bad block repair result, and outputting the bad block repair result;

[0043] If the second total amount is greater than the first total amount, the second total amount is used as the first total amount, and subsequent steps are executed starting from obtaining the position parameter n until the bad block repair result is output, and then the process ends.

[0044] In this embodiment, the bad blocks to be processed are identified in real time and processed in time, so that the number of available blocks in the hard disk increases, thereby reducing the number of garbage collection times, and the log results are monitored in real time, basically achieving the end of log processing. Bad block scanning, bad block processing, and result analysis are performed simultaneously, with the log as an intermediate medium, so that the analysis results are basically output synchronously with the end of the scanning task.

[0045] In some optional implementations, after determining whether a preset number of scanning process logs all contain scanning end marks, the method further includes:

[0046] If at least one scanning process log does not have a scanning end mark, wait for a preset time;

[0047] After a preset time, the second total amount of bad block information in the bad block record result is re-obtained, and subsequent steps are executed starting from determining whether the second total amount is greater than the first total amount, until the bad block repair result is output, and then the process ends.

[0048] In some optional implementations, inputting the second drive letter and sector identifier in the nth bad block information into a repairability judgment script, and writing the judgment result into the second field value in the nth bad block information includes:

[0049] Input the second drive letter and sector identifier in the nth bad block information into the repairable judgment script to obtain the output result;

[0050] If the output result includes the first preset information, it is determined that the bad block corresponding to the n-th bad block information is unrepairable, and the judgment result is a third preset value;

[0051] If the output result includes the second preset information, it is determined that the bad block corresponding to the n-th bad block information is repairable, and the judgment result is a fourth preset value.

[0052] In this embodiment, the second drive letter and sector identifier are input into the repairable judgment script, and whether the bad block corresponding to the nth bad block information can be repaired is determined based on the output result, so as to facilitate the subsequent accurate processing of the bad block. The method is simple and easy to implement and has strong versatility.

[0053] In a second aspect, the present invention provides a bad block repair device, comprising:

[0054] A scanning module is used to scan bad blocks of a preset number of hard disk partitions at the same time, and update the preset number of scanning process information in real time;

[0055] An acquisition module, used for acquiring the position information of the bad block in the scanning process information during the bad block scanning process, wherein the position information is used for locating the bad block;

[0056] The repair module is used to repair the bad blocks to be repaired in the bad blocks according to the position information to obtain the bad block repair result, wherein the bad blocks to be repaired are determined according to the position information and the disk analysis tool.

[0057] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the bad block repair method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0058] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the bad block repair method of the first aspect or any corresponding embodiment thereof.

[0059] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the bad block repair method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0061] Figure 1 is a flowchart of a bad block repair method according to an embodiment of the present invention;

[0062] Figure 2 is a flow chart of scanning bad blocks and outputting bad block scanning results according to an embodiment of the present invention;

[0063] Figure 3 is a flowchart of repairing bad blocks according to an embodiment of the present invention;

[0064] Figure 4 is a structural block diagram of a bad block repair device according to an embodiment of the present invention;

[0065] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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 described embodiments are 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0067] For distributed block storage systems, the main component is the block. In actual production, various factors may cause block damage, i.e. bad blocks. Physical factors such as hardware failure, scratches or damage to the disk surface may cause bad blocks. As time goes by and the number of times it is used increases, storage devices may age, resulting in some areas being unable to read or write data correctly. Power instability or sudden voltage fluctuations may damage data in storage devices. Long-term use of storage devices in environments with extreme temperature, humidity or vibration may increase the risk of bad blocks. When bad blocks appear in storage devices, data may be damaged or lost. Therefore, various manufacturers will manage bad blocks in advance to reduce the impact of bad blocks in production.

[0068] In bad block management, the following three types of bad blocks are defined: factory bad blocks, which are blocks that do not meet the manufacturer's standards or cannot meet the manufacturer's published standards after random testing by the manufacturer, and have been marked as bad blocks by the manufacturer at the factory; some factory bad blocks can be erased, and some cannot be erased; new bad blocks or used bad blocks caused by wear during use; false bad blocks that are misjudged by the main control due to abnormal power failure and other reasons. Not all new bad blocks are caused by wear. If the SSD does not have an abnormal power failure protection function, abnormal power failure may cause the main control to misjudge bad blocks or real new bad blocks to be generated. Upper Page is a Page with a longer operation time, also called a "slow page"; Lower Page is a Page with a shorter operation time, also called a "fast page". In the absence of abnormal power-off protection, if the Lower page has been programmed successfully, and there is a sudden power failure during the Upper page programming process, it will inevitably cause data transmission errors in the Lower page. If the number of data errors exceeds the SSDECC error correction capability, an error will occur during reading, and the block will be judged as a "Bad Block" by the master control and marked in the badblock table. Some of the newly added bad blocks can be erased, and after the newly added bad blocks are erased, re-reading, writing and erasing data may not cause errors again, because the error or not is also related to the pattern of writing data. If an error occurs when using a certain pattern, it may not occur when changing to another pattern. Factory bad blocks will be separated on the bitline, so they will not affect the erase speed of other blocks. However, if the number of new bad blocks in the entire SSD is large enough, the number of available blocks in the entire disk will decrease, which will increase the number of garbage collections. At the same time, the OP capacity will decrease, which will seriously affect the garbage collection efficiency. Therefore, when the bad blocks increase to a certain level, the performance stability of the SSD will be affected, especially when the SSD is continuously written, because the system performs garbage collection, it will cause performance degradation and the SSD performance curve will fluctuate greatly. When applied to actual products such as hyper-convergence, once a large number of non-factory bad blocks are generated, data loss will occur at the least, and the disk cannot be unloaded and used, or even the system will crash.

[0069] As mentioned above, not all bad blocks are irreparable. In order to ensure the normal use of the system and to recover customer data as much as possible, a bad block scanning tool such as badblocks will be used to scan and identify and process the repairable bad blocks. However, in actual scanning, as the number of bad blocks increases, the scanning time of badblocks varies from tens of minutes to hundreds of thousands of minutes. The more bad blocks there are, the longer the scanning time, resulting in the scanning work being too lengthy. Secondly, the badblocks scanning report only shows the bad block sector, and it is not known whether the bad block sector has data, so the accuracy of the repairable sector cannot be guaranteed.

[0070] Based on the above content, the embodiment of the present invention provides a bad block repair method, which realizes multi-disk concurrency for bad block scanning tasks, logs the scanning results and polls the results in seconds, and adds a minute-level stuck re-scanning mechanism to avoid the problem of too many bad blocks being stuck; it identifies resettable bad blocks in real time and resets them in time, so that the available blocks of the entire disk are increased, thereby reducing the number of garbage collection times, and monitors the log results in real time, basically achieving the end of log processing. Bad block scanning, bad block reset, and result analysis are carried out simultaneously, with the log as an intermediate medium, so that the analysis results are basically output synchronously with the end of the scanning task. In order to achieve the effect of improving the bad block identification efficiency, optimizing the bad block scanning process, and improving the bad block repair efficiency. This method can be applied not only to hyper-converged platforms, but also to other products using hard disks; the script used in this method has extremely strong versatility. Except for the reverse deduction of whether the bad block is available, which is different for each product, the rest can be reused in other products. The processing process of this method is automated, so that the purpose of outputting the analysis results can be achieved by simply providing an environment to execute the corresponding shell script, thereby achieving the purpose of releasing manpower.

[0071] According to an embodiment of the present invention, a bad block repair embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer device with data processing capabilities, such as a computer, a server, etc., and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0072] In this embodiment, a bad block repair method is provided, which can be used in the above-mentioned computer device. Figure 1 is a flow chart of a bad block repair method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0073] Step S101, scanning bad blocks of a preset number of hard disk partitions simultaneously, and updating the preset number of scanning process information in real time.

[0074] Specifically, the preset number represents multiple, and no specific number limit is imposed here. Multiple hard disk partitions are scanned for bad blocks simultaneously, for example: a bad block scanning tool such as badblocks is used to scan the hard disk partitions for bad blocks respectively, and badblocks will generate scanning process information for each hard disk partition, and the scanning process information consists of a preset number of pieces, and badblocks will update the scanning process information in real time as the scanning process progresses.

[0075] Step S102, during the bad block scanning process, obtaining the position information of the bad block in the scanning process information, wherein the position information is used to locate the bad block.

[0076] Specifically, during the bad block scanning process, the location information of the bad block is obtained from the scanning process information, such as the drive letter of the hard disk partition where the bad block is located and the sector identifier corresponding to the bad block. The bad block can be located through the location information such as the drive letter and the sector identifier.

[0077] Step S103, repairing the bad blocks to be repaired among the bad blocks according to the position information, and obtaining the bad block repair result, wherein the bad blocks to be repaired are determined according to the position information and the disk analysis tool.

[0078] Specifically, based on the location information, the bad blocks scanned are located, and the bad blocks to be repaired are repaired. The bad blocks to be repaired are bad blocks that can be repaired. For example, the repair method is to reset the bad blocks using the hdparm disk tool. During the repair process, the bad block repair result result will be obtained, and the bad block repair result will be continuously updated as the repair progresses. The bad block repair result may include: bad block location information, bad block information to be repaired, whether to repair the bad blocks to be repaired, and other information.

[0079] In addition, after obtaining the location information of at least one bad block in step S102, the bad block repair process in step S103 can be executed without waiting for the scan to be completed. The result can be saved to generate a scan report, and the bad block scanning of the hard disk partition in step S101 and the bad block repair process in step S103 can be performed simultaneously. The two tasks are decoupled, and with the help of the scanning process information as a medium, the analysis results are basically output synchronously with the completion of the scanning task.

[0080] It should be noted that this application has been applied to the hyper-converged platform, and its bad block scanning mechanism provides best practices for bad block scanning optimization for various products using hard disks. Secondly, the logic of achieving synchronization of processes and results through media can be applied to various fields.

[0081] The bad block repair method provided in this embodiment simultaneously scans bad blocks for a preset number of hard disk partitions, and obtains the location information of the bad blocks from the scanning process information during the scanning process. After the location information is obtained, the bad blocks to be repaired in the bad blocks are repaired according to the location information, so that multiple hard disk partitions can be scanned concurrently for bad blocks, the scanning process information can be monitored in real time, the bad blocks to be repaired can be identified and repaired in time, and the bad block repair results can be obtained, so that the available blocks of the entire disk are increased and the number of garbage collection times is reduced. Bad block scanning, bad block repair, and result analysis are performed simultaneously, so that the analysis results are basically output synchronously with the completion of the scanning task. The problem of low efficiency in identifying bad blocks, difficulty in repairing bad blocks in time, and affecting storage performance is solved.

[0082] In some optional implementations, the process of scanning bad blocks may include steps A1 to A3.

[0083] Step A1, simultaneously scanning erase blocks with the same number in each DIE unit on the same row in a flash memory array (FLASH array) of a solid state drive.

[0084] Specifically, the FLASH array structure of the solid state drive can be regarded as a two-dimensional table, which includes multiple columns and multiple rows. The intersection of each row and each column is a DIE unit, and each DIE unit includes multiple erase blocks.

[0085] Step A2, writing all the scanned erase blocks page by page at the same time, and then reading back all the erase blocks page by page at the same time after all the erase blocks scanned this time are full.

[0086] Step A3, comparing whether the written and read-back data of each page are consistent. If there is any inconsistency, the corresponding erased block is considered to be a bad block.

[0087] In this embodiment, the erase blocks with the same number in each DIE unit on the same row of the FLASH array of the solid-state hard disk are scanned simultaneously; each scanned erase block is filled page by page at the same time, and after all the erase blocks scanned this time are filled, each erase block is read back page by page at the same time; the written and read-back data of each page are compared to see whether they are consistent, and if there is any inconsistency, the corresponding erase block is considered to be a bad block. The erase blocks in multiple DIE units are detected simultaneously to see whether they are bad blocks, so as to solve the problem of low detection efficiency in the prior art when identifying bad blocks of solid-state hard disks because only one erase block can be read and written at a time.

[0088] In some optional implementations, bad block scanning is performed on a preset number of hard disk partitions at the same time, and the preset number of scanning process information is updated in real time, including:

[0089] Obtaining first drive letters corresponding to a preset number of hard disk partitions, wherein the hard disk partitions do not include an operating system;

[0090] According to the bad block scanning command and the first drive letter, bad block scanning is performed on a preset number of hard disk partitions concurrently, and a preset number of scanning process logs are updated in real time, wherein the scanning process logs contain scanning process information.

[0091] Specifically, obtain the drive letter list device_list of all non-system hard disk partitions, whose content format is: [sda, sdb, sdc...], where sda, sdb, sdc are the first drive letters of different hard disk partitions, and when obtaining the drive letter list device_list, execute the command lsblk to exclude the hard disk partition where the operating system ( / boot) is located.

[0092] The bad block scanning command is, for example, nohupbadblocks–s–v–b 512 / dev / sdx>sdx.log2>&1&, which indicates that the bad block scanning is performed on the hard disk partition with the drive letter sdx. According to the bad block scanning command and the first drive letter, all the first drive letters in the drive letter list device_list are traversed, and the bad block scanning is performed on all the hard disk partitions corresponding to the first drive letters. Badblocks will write the scanning process information to the corresponding scanning process log. For example, the scanning process log corresponding to the first drive letter sda is sda.log, and the scanning process log corresponding to the first drive letter sdx is sdx.log. Subsequently, by polling sda.log…sdx.log in sequence, you can check whether there are bad blocks and obtain the location information of the bad blocks.

[0093] The above process is as follows Figure 2 As shown, the badblocks scanning task flow implements multi-disk concurrency, logs the results and polls the results in seconds, and rescans the task if it gets stuck in minutes; obtains the drive letter list device_list of all non-system drives; determines whether device_list has not been traversed completely, if not, performs bad block scanning on the traversed drive letters and continues traversal; if traversal has been completed, obtains the scanning results sda.log…sdx.log.

[0094] In this embodiment, bad block scanning is performed concurrently on a preset number of hard disk partitions according to the bad block scanning command and the first drive letter, thereby improving the bad block scanning efficiency, and the scanning process information is written into the scanning process log, and the scanning results are logged. With the help of the log as an intermediate medium, the synchronous output of the task flow and result analysis is achieved, thereby optimizing the execution efficiency.

[0095] In some optional implementations, during the bad block scanning process, obtaining the bad block location information in the scanning process information includes:

[0096] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0097] If a bad block to be determined appears, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information; the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0098] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, the subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log, and then the process ends;

[0099] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0100] The subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log.

[0101] Specifically, read the row information of the scanning process log to determine whether there are bad blocks to be determined. For example, if a bad block is found during the bad block scanning of the hard disk partition, the information of the bad block will be written into the scanning process log. Read the row information of each row of the scanning process log in turn. If a bad block appears, take the bad block as a bad block to be determined, and obtain the sector identifier and the second drive letter of the bad block to be determined. For example, the sector identifier is snum, and the second drive letter is sdx. The sector identifier and the second drive letter belong to the location information, which can locate the bad block. Determine whether the sector identifier snum and the second drive letter sdx have been recorded in the bad block record result. If no bad block appears, directly read the row information of the next row of the scanning process log.

[0102] If the above-mentioned sector identifier and the second drive letter have been recorded in the bad block record result, there is no need to record them again. Start reading the row information from the next row containing the bad block row information to be determined in the scanning process log until the scanning process log reads the scanning end flag "completed". "Completed" is written into the scanning process log after the bad block scan of the hard disk partition is completed.

[0103] If the above-mentioned sector identifier and the second drive letter are not recorded in the bad block record result, the sector identifier and the second drive letter need to be recorded in the bad block record result. The preset data format is, for example: defining a one-dimensional array result to store the bad block information, the format is: [drive letter, sector identifier, whether the bad block can be reset, whether it has been processed]. Based on the above-mentioned second drive letter, sector identifier and preset data format, generate the bad block information of the bad block to be determined, and write the bad block information into the bad block record result result.

[0104] After the bad block information is written into the bad block record result, it is necessary to start reading the row information from the next row containing the bad block row information to be determined in the scanning process log until the scanning end flag "completed" is read in the scanning process log.

[0105] In some optional implementations, during the bad block scanning process, obtaining the bad block location information in the scanning process information includes:

[0106] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0107] If a bad block to be determined appears, the first time when the bad block to be determined appears is recorded, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information, and the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0108] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, subsequent steps are performed starting from reading the row information of the scanning process log;

[0109] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0110] Record the current second time;

[0111] Determine whether the time difference between the second time and the first time is less than a preset threshold;

[0112] If it is less than, the subsequent steps are executed starting from reading the row information of the scanning process log;

[0113] If it is not less than, determine whether the scan end mark can be read in the scan process log. If the scan end mark can be read, then end and output the bad block record result. If the scan end mark cannot be read, re-scan the bad blocks of the hard disk partition corresponding to the scan process log to obtain a new scan process log. Use the new scan process log as the scan process log, and execute subsequent steps starting from reading the row information of the scan process log until the bad block record result is output, then end.

[0114] Specifically, read the row information of the scanning process log to determine whether there are bad blocks to be determined. For example, if a bad block is found during the bad block scanning of the hard disk partition, the information of the bad block will be written into the scanning process log. Read the row information of each row of the scanning process log in turn. If a bad block appears, record the first time tx1 when the bad block to be determined appears, take the bad block as the bad block to be determined, and obtain the sector identifier and the second drive letter of the bad block to be determined, for example, the sector identifier is snum, and the second drive letter is sdx. The sector identifier and the second drive letter belong to the location information, which can locate the bad block. Determine whether the sector identifier snum and the second drive letter sdx have been recorded in the bad block record result. If no bad block appears, directly read the row information of the next row of the scanning process log.

[0115] If the above-mentioned sector identifier and the second drive letter have been recorded in the bad block record result, there is no need to record them again. Start reading the row information from the next row containing the bad block row information to be determined in the scanning process log until the scanning process log reads the scanning end flag "completed". "Completed" is written into the scanning process log after the bad block scan of the hard disk partition is completed.

[0116] If the above-mentioned sector identifier and the second drive letter are not recorded in the bad block record result, the sector identifier and the second drive letter need to be recorded in the bad block record result. The preset data format is, for example: defining a one-dimensional array result to store the bad block information, the format is: [drive letter, sector identifier, whether the bad block can be reset, whether it has been processed]. Based on the above-mentioned second drive letter, sector identifier and preset data format, generate the bad block information of the bad block to be determined, and write the bad block information into the bad block record result result.

[0117] After the bad block information is written into the bad block record result, the current second time tx2 is recorded. The preset threshold is, for example, 300 seconds, and it is determined whether the time difference between the second time tx2 and the first time tx1 is less than the preset threshold.

[0118] If the time difference is less than the preset threshold, it means that the current bad block scanning process is running normally, and the row information is read from the next row containing the bad block row information to be determined in the scanning process log. In the process of continuing to read the row information, if no new bad blocks are read, the second time tx2 will continue to increase until the time difference is not less than the preset threshold.

[0119] If the time difference is not less than the preset threshold, determine whether the scan end flag "completed" can be read in the scan process log. If the scan end flag can be read, it ends. It is determined that the bad block has not been read because the bad block scanning process has ended. The current bad block record result "result" has recorded all the bad block information. Output result, for example: [

[0121] ["sda",10000,false,false],

[0122] ["sdb",10008,false,false],

[0123] ["sdc",11111,false,false],

[0124] ["sda",20000,false,false],

[0125] ["sda",20038,false,false],

[0126] ["sdx",21111,false,false]],

[0127] …

[0128] ], where each line is a piece of bad block information in the format of [drive letter, sector ID, whether the bad block can be reset, whether it has been processed]. For example, ["sda", 10000, false, false] means there is a bad block, the corresponding second drive letter is sda, the sector ID is 10000, it cannot be reset, and it has not been processed. For other bad block information, see result, which will not be repeated here.

[0129] If the scan completion flag "completed" cannot be read, it is determined that the bad block scanning process is stuck, resulting in the failure to read the bad blocks. It is necessary to re-scan the bad blocks of the hard disk partition corresponding to the scan process log to obtain a new scan process log. Use the new scan process log as the scan process log and re-execute the above steps "read the row information of the scan process log to determine whether there are bad blocks to be determined" and subsequent steps.

[0130] The above process is as follows Figure 3As shown, check whether there are bad blocks in sdx.log. If not, re-execute "Check whether there are bad blocks in sdx.log". If yes, record the current time tx1; determine whether there are records of the corresponding drive letter sdx and sector in result. If yes, re-execute "Check whether there are bad blocks in sdx.log". If not, add a sector record in result; determine whether the current time tx2-tx1 is less than 300s. If yes, re-execute "Check whether there are bad blocks in sdx.log". If not, determine whether there is completed in the log. If yes, output result and end. If no, re-scan the drive letter sdx and re-execute "Check whether there are bad blocks in sdx.log". It should be noted that the above process is applicable to the hard disk partition with the first drive letter sda and each other hard disk partition. For details, see Figure 2 , I will not go into details here.

[0131] In this embodiment, a preset number of hard disk partitions are scanned for bad blocks concurrently, and the location information of the bad blocks is obtained in the scanning process information, thereby improving the bad block scanning efficiency. In addition, by recording the first time and the second time, and judging whether the time difference between the second time and the first time is less than a preset threshold, it is determined whether the hard disk partition needs to be re-scanned for bad blocks, and a minute-level bad block scanning task is added to prevent the bad block scanning process from being stuck due to too many bad blocks.

[0132] In some optional implementations, repairing the bad blocks to be repaired in the bad blocks according to the position information to obtain the bad block repair result includes:

[0133] Obtain the first total amount of bad block information in the bad block record result;

[0134] Get the position parameter n, set n to the initial value, and determine whether n is less than the first total amount;

[0135] When n is less than the first total amount, obtaining the first field value in the nth bad block information;

[0136] When the first field value is the first preset value, n=n+1 is set, and subsequent steps are performed starting from determining whether n is less than the first total amount;

[0137] In the case where the first field value is the second preset value, the second drive letter and sector identifier in the nth bad block information are input into the repairability judgment script, and the judgment result is written into the second field value in the nth bad block information;

[0138] If the second field value is the third preset value, modify the first field value in the nth bad block information to the first preset value;

[0139] If the second field value is a fourth preset value, the bad block corresponding to the nth bad block information is used as the bad block to be repaired, the second drive letter and the sector identifier in the nth bad block information are input into the bad block repair tool, the bad block to be repaired is repaired, and the first field value in the nth bad block information is modified to the first preset value;

[0140] Set n=n+1, and start executing subsequent steps from determining whether n is less than the first total amount;

[0141] When n is not less than the first total amount, obtaining a second total amount of bad block information in the bad block record result;

[0142] Determine whether the second total amount is greater than the first total amount;

[0143] If the second total amount is not greater than the first total amount, determining whether the scan end flags exist in all the preset number of scan process logs; if they do exist, taking the bad block record result as the bad block repair result, and outputting the bad block repair result;

[0144] If the second total amount is greater than the first total amount, the second total amount is used as the first total amount, and subsequent steps are executed starting from obtaining the position parameter n until the bad block repair result is output, and then the process ends.

[0145] Specifically, the bad block record result result is read in real time to obtain the number of elements len1, where len1 is the first total amount of bad block information in the bad block record result.

[0146] Define a position parameter n, which is used to indicate the nth bad block information currently read in the result, and set n to an initial value, such as 0. Determine whether n is less than the first total amount len1.

[0147] If n is less than len1, the first field value in the nth bad block information is obtained, and the first field value is, for example, the value of the [Has it been processed] field.

[0148] The first preset value is, for example, true; the second preset value is, for example, false. When the first field value is the first preset value, it indicates that the bad block information has been processed, and there is no need to repair the bad block corresponding to the bad block information. The next bad block information, that is, the n+1th bad block information, needs to be processed, and the step "determining whether n is less than the first total amount" and subsequent steps are re-executed. When the first field value is the second preset value, it indicates that the bad block information has not been processed, and the bad block information needs to be processed. The repairable judgment script is, for example, python disk_analysis.py. The second drive letter and sector identifier in the nth bad block information are input into the repairable judgment script. The command to determine whether the bad block is repairable is executed: python disk_analysis.py-d / dev / the second drive letter –s sector identifier. The judgment result is obtained. The judgment result indicates whether the bad block corresponding to the bad block information can be repaired by resetting. The judgment result is written into the second field value in the nth bad block information. The second field value is, for example, [whether the bad block can be reset].

[0149] The third preset value is, for example, false; the fourth preset value is, for example, true. If the second field value is the third preset value, it means that the bad block corresponding to the nth bad block information cannot be repaired by resetting, so no further operation is required. Although it is not repaired by resetting, it is considered that the nth bad block information has been processed, and the first field value in the nth bad block information is directly modified to the first preset value.

[0150] If the second field value is the fourth preset value, it means that the bad block corresponding to the nth bad block information can be repaired by resetting. The bad block corresponding to the nth bad block information is used as the bad block to be repaired, and the second drive letter and sector identifier in the nth bad block information are input into the bad block repair tool, such as the hdparm disk tool, and the bad block repair command is executed: hdparm –write-sector sector identifier –yes-i-know-what-i-am-doing / dev / second drive letter, the bad block to be repaired is repaired, and the first field value in the nth bad block information is modified to the first preset value.

[0151] After processing the nth bad block information, it is necessary to process the n+1th bad block information, set n=n+1 to continue reading the next value in result, and re-execute the above step of "determining whether n is less than the first total amount" and subsequent steps.

[0152] When n is not less than the first total amount len1, it means that the bad block information previously obtained from the bad block record result has been completely processed. According to the above embodiment, the bad block record result will be updated with the bad block scanning process of the hard disk partition. At this time, new bad block information may appear in the bad block record result. Therefore, the second total amount len2 of the bad block information in the current bad block record result is obtained.

[0153] Determine whether the second total amount len2 is greater than the first total amount len1.

[0154] If the second total amount len2 is not greater than the first total amount len1, and no new bad block information appears in the bad block record result, the specific reason needs to be confirmed, and the preset number of scanning process logs, such as sda.log...sdx.log, etc., are judged to see whether the scan end mark "completed" exists. If "completed" exists, it means that the bad block scan of all hard disk partitions has been completed, and no new bad blocks need to be processed. The bad block record result is used as the bad block repair result, and the bad block repair result is output. For example, the bad block repair result is: [

[0156] [“sda”,10000,false,true],

[0157] [“sdb”,10008,false,true],

[0158] [“sdc”,11111,true,true],

[0159] [“sda”,20000,true,true],

[0160] [“sda”,20038,false,true],

[0161] ["sdx",21111,false,true]],

[0162] …

[0163] ], where each line represents a bad block information and its processing result, in the format of [drive letter, sector ID, whether the bad block can be reset, whether it has been processed]. For example, ["sda", 10000, false, false] means there is a bad block, the corresponding second drive letter is sda, the sector ID is 10000, it cannot be reset, and it has been processed. For other bad block information, please refer to the bad block repair results, which will not be repeated here.

[0164] If the second total quantity len2 is greater than the first total quantity len1, it indicates that new bad blocks have been obtained and need to be processed. Set the second total quantity len2 as the first total quantity len1, and re-execute the step "obtain the position parameter n" and subsequent steps until the bad block repair result is output, and then end.

[0165] The above process is as Figure 3 shown. Real-time identify and reset the resettable bad blocks in a timely manner, and monitor the log results in real time; obtain the number of elements len1 of the result; define the element position as n, n = 0; determine whether n < len1. If n < len1, determine whether the nth element has been processed. If so, then n = n++, and re-execute "determine whether n < len1". If it has not been processed, execute disk_analysis.py to obtain the bad block sector return value result_info; determine whether the bad block can be reset based on the result_info value; determine whether the bad block can be reset. If it cannot be reset, update the value of

whether it has been processed

whether it has been processed

[0166] In this embodiment, the bad blocks to be processed are identified and processed in real time, so that the number of available blocks in the hard disk increases, thereby reducing the number of garbage collections, and the log results are monitored in real time, and basically the log end processing ends. Bad block scanning, bad block processing, and result analysis are carried out synchronously, with the log as the intermediate medium, so that the analysis results are basically output synchronously with the end of the scanning task.

[0167] In some alternative embodiments, after determining whether the scan end flag exists in each of the preset number of scan process logs, the method further includes:

[0168] If the scan end flag does not exist in at least one scan process log, wait for a preset duration;

[0169] After the preset duration, re-obtain the second total quantity of the bad block information in the bad block record result, and start executing the subsequent steps from determining whether the second total quantity is greater than the first total quantity until the bad block repair result is output, and then end.

[0170] Specifically, the scanning process log is, for example, sda.log…sdx.log. It is determined whether all scanning process logs have the scanning end mark "completed". If so, it indicates that the scanning of all hard disk partitions is completed and no new bad blocks will appear. The repair process can be ended and the bad block repair result can be output.

[0171] If at least one scanning process log does not have a scanning end mark, it indicates that at least one hard disk partition has not completed the bad block scan, and new bad blocks may appear and need to be repaired. In this case, the preset time is waited for so that the bad block scan is performed again for the preset time. The preset time is, for example, 300s, 500s, etc.

[0172] After a preset time, the second total amount of bad block information in the bad block record result is obtained again, and the step of "determining whether the second total amount is greater than the first total amount" and subsequent steps are re-executed until the bad block repair result is output, and then the process ends.

[0173] In some optional implementations, inputting the second drive letter and sector identifier in the nth bad block information into a repairability judgment script, and writing the judgment result into the second field value in the nth bad block information includes:

[0174] Input the second drive letter and sector identifier in the nth bad block information into the repairable judgment script to obtain the output result;

[0175] If the output result includes the first preset information, it is determined that the bad block corresponding to the n-th bad block information is unrepairable, and the judgment result is a third preset value;

[0176] If the output result includes the second preset information, it is determined that the bad block corresponding to the n-th bad block information is repairable, and the judgment result is a fourth preset value.

[0177] Specifically, the repairable judgment script is, for example: python disk_analysis.py, the second drive letter and sector identifier in the nth bad block information are input into the repairable judgment script, and the command for judging whether the bad block is repairable is executed: python disk_analysis.py -d / dev / second drive letter – s sector identifier, and the output result result_info is obtained.

[0178] The first preset information is, for example, Hit zookpeeper partition, Hit metad partition, Hit journal partition, pid:***, etc. If the output result result_info includes one or more of the first preset information, it is determined that the bad block corresponding to the nth bad block information is unrepairable, and the judgment result is a third preset value, for example, the third preset value is: false.

[0179] The second preset information is, for example, Can not get pidinfos, Not hit replica data, etc. If the output result result_info includes one or more of the second preset information, it is determined that the bad block corresponding to the nth bad block information is repairable, and the judgment result is a fourth preset value, for example, true.

[0180] In this embodiment, the second drive letter and sector identifier are input into the repairable judgment script, and whether the bad block corresponding to the nth bad block information can be repaired is determined based on the output result, so as to facilitate the subsequent accurate processing of the bad block. The method is simple and easy to implement and has strong versatility.

[0181] In this embodiment, a bad block repair device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0182] This embodiment provides a bad block repair device, such as Figure 4 As shown, including:

[0183] The scanning module 401 is used to simultaneously scan bad blocks of a preset number of hard disk partitions and update the preset number of scanning process information in real time;

[0184] An acquisition module 402 is used to acquire the position information of the bad block in the scanning process information during the bad block scanning process, wherein the position information is used to locate the bad block;

[0185] The repair module 403 is used to repair the bad blocks to be repaired among the bad blocks according to the position information to obtain the bad block repair result, wherein the bad blocks to be repaired are determined according to the position information and the disk analysis tool.

[0186] In some optional implementations, the scanning module 401 simultaneously scans bad blocks on a preset number of hard disk partitions, and updates the preset number of scanning process information in real time, including:

[0187] Obtaining first drive letters corresponding to a preset number of hard disk partitions, wherein the hard disk partitions do not include an operating system;

[0188] According to the bad block scanning command and the first drive letter, bad block scanning is performed on a preset number of hard disk partitions concurrently, and a preset number of scanning process logs are updated in real time, wherein the scanning process logs contain scanning process information.

[0189] In some optional implementations, the acquisition module 402 acquires the location information of the bad block from the scanning process information during the bad block scanning process, including:

[0190] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0191] If a bad block to be determined appears, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information; the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0192] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, the subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log, and then the process ends;

[0193] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0194] The subsequent steps are executed starting from reading the row information of the scanning process log until the scanning end mark is read in the scanning process log.

[0195] In some optional implementations, the scanning module 401 obtains the location information of the bad block from the scanning process information during the bad block scanning process, including:

[0196] Read the row information of the scanning process log to determine whether there are any pending bad blocks;

[0197] If a bad block to be determined appears, the first time when the bad block to be determined appears is recorded, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information, and the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector;

[0198] In the case where the sector identifier and the second drive letter are recorded in the bad block record result, subsequent steps are performed starting from reading the row information of the scanning process log;

[0199] In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, bad block information of the bad block to be determined is generated according to the second drive letter, the sector identifier and the preset data format, and the bad block information is written into the bad block record result;

[0200] Record the current second time;

[0201] Determine whether the time difference between the second time and the first time is less than a preset threshold;

[0202] If it is less than, the subsequent steps are executed starting from reading the row information of the scanning process log;

[0203] If it is not less than, determine whether the scan end mark can be read in the scan process log. If the scan end mark can be read, then end and output the bad block record result. If the scan end mark cannot be read, re-scan the bad blocks of the hard disk partition corresponding to the scan process log to obtain a new scan process log. Use the new scan process log as the scan process log, and execute subsequent steps starting from reading the row information of the scan process log until the bad block record result is output, then end.

[0204] In some optional implementations, the repair module 403 repairs the bad blocks to be repaired in the bad blocks according to the position information to obtain the bad block repair result, including:

[0205] Obtain the first total amount of bad block information in the bad block record result;

[0206] Get the position parameter n, set n to the initial value, and determine whether n is less than the first total amount;

[0207] When n is less than the first total amount, obtaining the first field value in the nth bad block information;

[0208] When the first field value is the first preset value, n=n+1 is set, and subsequent steps are performed starting from determining whether n is less than the first total amount;

[0209] In the case where the first field value is the second preset value, the second drive letter and sector identifier in the nth bad block information are input into the repairability judgment script, and the judgment result is written into the second field value in the nth bad block information;

[0210] If the second field value is the third preset value, modify the first field value in the nth bad block information to the first preset value;

[0211] If the second field value is a fourth preset value, the bad block corresponding to the nth bad block information is used as the bad block to be repaired, the second drive letter and the sector identifier in the nth bad block information are input into the bad block repair tool, the bad block to be repaired is repaired, and the first field value in the nth bad block information is modified to the first preset value;

[0212] Set n=n+1, and start executing subsequent steps from determining whether n is less than the first total amount;

[0213] When n is not less than the first total amount, obtaining a second total amount of bad block information in the bad block record result;

[0214] Determine whether the second total amount is greater than the first total amount;

[0215] If the second total amount is not greater than the first total amount, determining whether the scan end flags exist in all the preset number of scan process logs; if they do exist, taking the bad block record result as the bad block repair result, and outputting the bad block repair result;

[0216] If the second total amount is greater than the first total amount, the second total amount is used as the first total amount, and subsequent steps are executed starting from obtaining the position parameter n until the bad block repair result is output, and then the process ends.

[0217] In some optional implementations, after the repair module 403 determines whether there are scan end marks in a preset number of scan process logs, the method further includes:

[0218] If at least one scanning process log does not have a scanning end mark, wait for a preset time;

[0219] After a preset time, the second total amount of bad block information in the bad block record result is re-obtained, and subsequent steps are executed starting from determining whether the second total amount is greater than the first total amount, until the bad block repair result is output, and then the process ends.

[0220] In some optional implementations, the repair module 403 inputs the second drive letter and sector identifier in the nth bad block information into the repairability judgment script, and writes the judgment result into the second field value in the nth bad block information, including:

[0221] Input the second drive letter and sector identifier in the nth bad block information into the repairable judgment script to obtain the output result;

[0222] If the output result includes the first preset information, it is determined that the bad block corresponding to the n-th bad block information is unrepairable, and the judgment result is a third preset value;

[0223] If the output result includes the second preset information, it is determined that the bad block corresponding to the n-th bad block information is repairable, and the judgment result is a fourth preset value.

[0224] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0225] The bad block repair device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0226] The embodiment of the present invention also provides a computer device having the above Figure 4 The bad block repair device shown.

[0227] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.

[0228] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0229] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0230] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0231] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0232] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0233] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0234] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0235] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A bad block repair method, characterized in that: The method comprises: Perform bad block scans on a preset number of hard disk partitions at the same time, and update the preset number of scanning process information in real time; During the bad block scanning process, obtaining the position information of the bad block from the scanning process information, wherein the position information is used to locate the bad block; According to the position information, the bad blocks to be repaired among the bad blocks are repaired to obtain a bad block repair result, wherein the bad blocks to be repaired are determined according to the position information and a disk analysis tool.

2. The method according to claim 1, characterized in that The bad block scanning is performed on a preset number of hard disk partitions at the same time, and the preset number of scanning process information is updated in real time, including: Obtaining first drive letters corresponding to a preset number of hard disk partitions, wherein the hard disk partitions do not include an operating system; According to the bad block scanning command and the first drive letter, bad block scanning is performed on a preset number of hard disk partitions concurrently, and a preset number of scanning process logs are updated in real time, wherein the scanning process logs include the scanning process information.

3. The method according to claim 2, characterized in that In the bad block scanning process, obtaining the location information of the bad blocks in the scanning process information includes: Read the row information of the scanning process log to determine whether there is a bad block to be determined; If the bad block to be determined appears, the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located are obtained, and it is determined whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information; the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector; In the case where the sector identifier and the second drive letter are recorded in the bad block record result, the subsequent steps are performed starting from the line information of the scanning process log being read, and the scanning process log is terminated after a scanning end mark is read; In the case that the sector identifier and the second drive letter are not recorded in the bad block record result, generating bad block information of the bad block to be determined according to the second drive letter, the sector identifier and a preset data format, and writing the bad block information into the bad block record result; The subsequent steps are executed starting from the reading of the row information of the scanning process log until a scanning end mark is read in the scanning process log, and then the process ends.

4. The method according to claim 2, characterized in that: In the bad block scanning process, obtaining the location information of the bad blocks in the scanning process information includes: Read the row information of the scanning process log to determine whether there is a bad block to be determined; If the bad block to be determined appears, record the first time when the bad block to be determined appears, obtain the sector identifier corresponding to the bad block to be determined and the second drive letter of the hard disk partition where the bad block to be determined is located, and determine whether the sector identifier and the second drive letter are recorded in the bad block record result, wherein the sector identifier and the second drive letter are included in the position information, and the bad block record result is used to record the drive letter of the hard disk partition where the bad block is located and the identifier of the corresponding sector; In the case where the sector identifier and the second drive letter are recorded in the bad block record result, executing subsequent steps starting from reading the row information of the scanning process log; In a case where the sector identifier and the second drive letter are not recorded in the bad block record result, generating bad block information of the bad block to be determined according to the second drive letter, the sector identifier and a preset data format, and writing the bad block information into the bad block record result; Record the current second time; Determine whether the time difference between the second time and the first time is less than a preset threshold; If it is less than, executing subsequent steps starting from reading the row information of the scanning process log; If it is not less than, determine whether the scan end mark can be read in the scan process log. If the scan end mark can be read, terminate and output the bad block record result. If the scan end mark cannot be read, re-scan the bad blocks of the hard disk partition corresponding to the scan process log to obtain a new scan process log. Use the new scan process log as the scan process log, and execute subsequent steps starting from the row information of reading the scan process log until the bad block record result is output, then terminate.

5. The method according to claim 3 or 4, characterized in that: The step of repairing the bad blocks to be repaired among the bad blocks according to the position information to obtain the bad block repair result includes: Obtaining a first total amount of the bad block information in the bad block record result; Obtaining a position parameter n, setting n to an initial value, and determining whether n is less than the first total amount; When n is less than the first total amount, obtaining a first field value in the nth bad block information; In the case where the first field value is the first preset value, n=n+1 is set, and subsequent steps are performed starting from the step of determining whether n is less than the first total amount; In the case where the first field value is a second preset value, the second drive letter and the sector identifier in the nth bad block information are input into a repairable judgment script, and the judgment result is written into the second field value in the nth bad block information; If the second field value is a third preset value, modifying the first field value in the nth bad block information to the first preset value; If the second field value is a fourth preset value, taking the bad block corresponding to the nth bad block information as the bad block to be repaired, inputting the second drive letter and the sector identifier in the nth bad block information into a bad block repair tool, repairing the bad block to be repaired, and modifying the first field value in the nth bad block information to the first preset value; Set n=n+1, and start executing subsequent steps from the step of determining whether n is less than the first total amount; When n is not less than the first total amount, obtaining a second total amount of the bad block information in the bad block record result; determining whether the second total amount is greater than the first total amount; If the second total amount is not greater than the first total amount, determining whether the scan end flag exists in all preset number of the scan process logs, and if so, taking the bad block record result as the bad block repair result, and outputting the bad block repair result; If the second total amount is greater than the first total amount, the second total amount is used as the first total amount, and subsequent steps are executed starting from the acquisition of the position parameter n until the bad block repair result is output, and then the process ends.

6. The method according to claim 5, characterized in that After determining whether the scan end mark exists in a preset number of the scan process logs, the method further includes: If at least one of the scanning process logs does not contain the scanning end mark, wait for a preset time period; After a preset time, the second total amount of the bad block information in the bad block record result is reacquired, and subsequent steps are executed starting from determining whether the second total amount is greater than the first total amount until the bad block repair result is output, and then the process ends.

7. The method according to claim 5, characterized in that The step of inputting the second drive letter and the sector identifier in the nth bad block information into a repairable judgment script, and writing the judgment result into a second field value in the nth bad block information comprises: Input the second drive letter and the sector identifier in the nth bad block information into a repairability judgment script to obtain an output result; If the output result includes the first preset information, it is determined that the bad block corresponding to the n-th bad block information is unrepairable, and the judgment result is a third preset value; If the output result includes the second preset information, it is determined that the bad block corresponding to the n-th bad block information is repairable, and the judgment result is a fourth preset value.

8. A bad block repair device, characterized in that: The device comprises: A scanning module is used to scan bad blocks of a preset number of hard disk partitions at the same time, and update the preset number of scanning process information in real time; An acquisition module, used for acquiring the position information of the bad block in the scanning process information during the bad block scanning process, wherein the position information is used for locating the bad block; A repair module is used to repair the bad blocks to be repaired in the bad blocks according to the position information to obtain bad block repair results, wherein the bad blocks to be repaired are determined according to the position information and a disk analysis tool.

9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the bad block repair method according to any one of claims 1 to 7 by executing the computer instructions.

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 computer to execute the bad block repair method according to any one of claims 1 to 7.