Hard disk management method, electronic device, storage medium, and program product

By dynamically selecting free sectors on the hard disk as backup sectors, the problems of high replacement delay and low efficiency of fixed backup sector locations are solved, achieving more efficient hard disk management and improving hard disk reliability and performance.

CN120491908BActive Publication Date: 2025-10-10INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510979736.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-10-10
Estimated Expiration
2045-07-16

AI Technical Summary

Technical Problem

In existing hard disk management methods, the location of backup sectors is fixed, resulting in high replacement delay and low replacement efficiency, which affects the overall performance of the hard disk.

Method used

By identifying the operating status of the working sectors on the hard disk, calculating the physical distance between the abnormal sectors and the idle sectors, and dynamically selecting the optimal backup sector to update the address mapping table, frequent head movement and long-distance seeks are avoided.

Benefits of technology

It reduces sector replacement delay, improves replacement efficiency, and enhances hard drive reliability and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491908B_ABST
    Figure CN120491908B_ABST
Patent Text Reader

Abstract

The application discloses a hard disk management method, electronic equipment, storage medium and program product, relates to the technical field of hard disk management, and does not set a backup sector of a fixed position, can take any idle sector as the backup sector, calculates the physical distance between the abnormal sector and other idle sectors after recognizing the abnormal sector on the hard disk, determines the backup sector of the abnormal sector from the idle sectors based on the physical distance, selects the closer idle sector as the backup sector of the abnormal sector through the physical distance, to a certain extent, reduces the head seeking time length, and further reduces the replacement delay of the sector, simultaneously, to a certain extent, can avoid frequent head movement, improves the replacement efficiency of the sector, and further improves the reliability and performance of the hard disk, and solves the technical problems that, in the related art, due to the fixed position of the backup sector, the replacement delay is high, the replacement efficiency is low, and the overall performance of the hard disk is affected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of hard disk management, and in particular to a hard disk management method, electronic equipment, storage medium and program product. Background Art

[0002] In data storage systems, hard drives can develop bad sectors over time due to physical wear, head impacts, and media aging. Existing hard drives typically reserve a certain number of backup sectors in fixed locations (such as the outer, middle, or inner rings) to replace bad sectors. When the hard drive detects that a sector is not reading or writing properly, the hard drive firmware migrates the sector's data to the backup sector and updates the logical block address mapping table to ensure that subsequent access is not affected.

[0003] However, since the position of the backup sector is fixed, when the bad sector is far away from the backup sector, the head needs to seek a long distance, resulting in increased replacement delay. Moreover, when multiple bad sectors are distributed in different areas of the hard disk, the fixed backup sector may cause frequent head movement, resulting in low replacement efficiency and affecting the overall performance of the hard disk. Summary of the Invention

[0004] The present invention provides a hard disk management method, electronic device, storage medium and program product to at least solve the problem in the related art that the position of the backup sector is fixed, resulting in high replacement delay, low replacement efficiency and affecting the overall performance of the hard disk.

[0005] The present invention provides a hard disk management method, comprising: identifying the operating status of a working sector on a hard disk; determining whether the corresponding working sector is an abnormal sector according to the operating status, wherein the abnormal sector is a sector that does not respond to a data read request and / or a data write request; if the working sector is an abnormal sector, calculating the physical distance between the abnormal sector and at least one idle sector, and determining a backup sector of the abnormal sector from the at least one idle sector based on the physical distance; and updating the address mapping table of the abnormal sector to the address mapping table of the backup sector.

[0006] The present invention also provides a hard disk management device, including: an identification module for identifying the operating status of a working sector on a hard disk; a first determination module for determining whether the corresponding working sector is an abnormal sector based on the operating status, wherein the abnormal sector is a sector that does not respond to a data read request and / or a data write request; a second determination module for calculating the physical distance between the abnormal sector and at least one free sector if the working sector is an abnormal sector, and determining a backup sector of the abnormal sector from at least one free sector based on the physical distance; and an update module for updating the address mapping table of the abnormal sector to the address mapping table of the backup sector.

[0007] The present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the above hard disk management methods when executing the computer program.

[0008] The present invention also provides a non-volatile computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned hard disk management methods are implemented.

[0009] The present invention also provides a computer program product, comprising a computer program, which implements the steps of any of the above hard disk management methods when executed by a processor.

[0010] Through the present invention, since a backup sector with a fixed position is not set, any idle sector can be used as a backup sector. After an abnormal sector is identified on the hard disk, the physical distance between the abnormal sector and other idle sectors is calculated, and the backup sector of the abnormal sector is determined from the idle sectors based on the physical distance. The closer idle sector can be selected as the backup sector of the abnormal sector according to the physical distance, which reduces the head seek time to a certain extent, thereby reducing the sector replacement delay. At the same time, it can avoid frequent head movement to a certain extent, improve the sector replacement efficiency, and thus improve the reliability and performance of the hard disk. Therefore, it can solve the technical problems in the related technology that the position of the backup sector is fixed, resulting in high replacement delay, low replacement efficiency, and affecting the overall performance of the hard disk, and achieve the technical effect of reducing replacement delay, improving replacement efficiency, and improving the reliability and performance of the hard disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0012] Figure 1 A flowchart of a hard disk management method according to an embodiment of the present invention;

[0013] Figure 2 A flowchart of a hard disk management method according to a specific embodiment of the present invention;

[0014] Figure 3 A flowchart of dynamically selecting a backup sector according to an embodiment of the present invention;

[0015] Figure 4 A block diagram of a hard disk management device according to an embodiment of the present invention;

[0016] Figure 5 A schematic structural diagram of an electronic device provided according to an embodiment of the present invention. DETAILED DESCRIPTION

[0017] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0018] It should be noted that, in the description of the present invention, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. The terms "first," "second," etc., in the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence.

[0019] Before describing the solution of the present invention, the management of backup sectors in related technologies is first introduced.

[0020] 1. Fixed backup sector.

[0021] A certain number of backup sectors are reserved in fixed locations (such as the outer, middle, or inner rings). Western Digital (WD) and Seagate hard drives typically reserve backup sectors on the outer rings of the platter. Data is migrated to these areas when bad blocks are replaced. The disadvantage of this method is that seek times are long, impacting performance.

[0022] 2. Distributed backup sectors.

[0023] Some hard drive manufacturers have tried to disperse a small number of backup sectors across multiple tracks, but they are still unable to dynamically adjust the location of the backup sectors, resulting in limited replacement efficiency.

[0024] In summary, the above backup sector management method has the following problems:

[0025] 1. High latency in bad block replacement: Since the backup sector location is fixed, the head needs to seek over a long distance when replacing a bad block, which increases the command response time and may cause a timeout error.

[0026] 2. Low utilization of backup sectors: In traditional methods, backup sectors are only used to replace bad sectors and cannot participate in data storage during normal operation, resulting in a waste of storage resources.

[0027] 3. Performance degradation in multiple bad sector scenarios: When a hard drive has multiple bad sectors, fixed backup sectors may cause frequent head movement, low replacement efficiency, and affect overall throughput.

[0028] To this end, the present invention proposes a hard disk management method to solve at least one of the above technical problems.

[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0030] An embodiment of the present invention provides a hard disk management method, which is described in detail in conjunction with the execution flow of the hard disk management method.

[0031] like Figure 1 As shown, the hard disk management method includes the following steps:

[0032] In step S101, the operating status of the working sector on the hard disk is identified.

[0033] Among them, the operating status includes normal operating status and abnormal operating status; the sector is the smallest physical storage unit of storage devices such as hard disks, and is the basic unit for data reading and writing. The sector is a sector-shaped small block divided from the annular area on the hard disk platter, and each sector has a unique physical address.

[0034] In step S102, it is determined whether the corresponding working sector is an abnormal sector according to the operating status, wherein the abnormal sector is a sector that does not respond to a data read request and / or a data write request.

[0035] Among them, abnormal sectors can also be understood as bad sectors, which refer to physically damaged sectors. The causes of bad sectors may be due to physical wear of the hard disk during long-term use, head collision, media aging, etc.

[0036] It is understandable that the embodiment of the present invention can determine whether the corresponding working sector is an abnormal sector according to the operating status, so as to subsequently perform a replacement operation on the abnormal sector.

[0037] In some embodiments of the present invention, whether a corresponding working sector is an abnormal sector is determined based on the operating status, including: if the working sector does not respond to a data read request and / or a data write request, re-executing the data read request and / or the data write request on the working sector; if the working sector still does not respond to the data read request and / or the data write request, determining that the corresponding working sector is an abnormal sector.

[0038] Since there are many reasons for sector read and write failures in a hard disk, not all of them are due to physical damage to the sector itself, but may be temporary interference, such as head positioning deviation, electromagnetic interference, signal attenuation, etc. Therefore, when the embodiment of the present invention first identifies that a sector does not respond to a data read request and / or a data write request, it does not determine it as an abnormal sector, and retries the data read request and / or data write request for the working sector. After the retry, it is found that the working sector still does not respond to the data read request and / or data write request, and it is determined to be an abnormal sector. Therefore, the retry can avoid the misjudgment of abnormal sectors caused by temporary interference, and can reduce unnecessary consumption of backup sectors, ensuring that backup sectors are only used for truly irreparable failures, optimizing resource utilization, and also extending the service life of the hard disk.

[0039] In step S103, if the working sector is an abnormal sector, a physical distance between the abnormal sector and at least one idle sector is calculated, and a backup sector of the abnormal sector is determined from the at least one idle sector based on the physical distance.

[0040] The idle sectors are sectors other than sectors used by users and working sectors currently being detected.

[0041] Compared with the existing fixed sector position, when the bad sector is far away from the backup sector, the head needs to seek a long distance, resulting in increased replacement delay. The embodiment of the present invention does not set a backup sector in a fixed position, and any idle sector can be used as a backup sector. After the abnormal sector is identified on the hard disk, the physical distance between the abnormal sector and other idle sectors is calculated, and the backup sector of the abnormal sector is determined from the idle sectors based on the physical distance. The closer idle sector can be selected as the backup sector of the abnormal sector according to the distance, which reduces the head seek time to a certain extent, thereby reducing the sector replacement delay. At the same time, it can avoid frequent head movement to a certain extent, improve the sector replacement efficiency, and thus improve the reliability and performance of the hard disk.

[0042] In some embodiments of the present invention, calculating the physical distance between an abnormal sector and at least one backup sector includes: obtaining the three-dimensional physical position of the abnormal sector and the three-dimensional physical position of the idle sector; and calculating the physical distance based on the three-dimensional physical position of the abnormal sector and the three-dimensional physical position of the idle sector.

[0043] The three-dimensional physical position can also be called a physical address, specifically CHS (cylinder-head-sector) addressing. CHS addressing is unique and is used to mark the physical address of a sector. For example, a sector address of "cylinder 100, head 2, sector 5" indicates that the sector is located on the track corresponding to the 100th cylinder and the second head, and is the fifth sector on the track.

[0044] It is understandable that the embodiment of the present invention can obtain the three-dimensional physical position of the abnormal sector and the physical position of the idle sector, and calculate the physical distance based on the three-dimensional physical position of the abnormal sector and the three-dimensional physical position of the idle sector.

[0045] In an embodiment of the present invention, the physical distance between sectors is calculated using the CHS address. Specifically, the CHS address determines the sector position using three parameters: cylinder, head, and sector. When calculating the distance between two sectors, the cylinder difference, head difference, and sector difference must be calculated separately. The cylinder difference reflects the distance the head moves between tracks of different radii, the head difference reflects the situation when the head switches between different disk surfaces, and the sector difference is the difference in sector position within the same track. Taking these three differences into consideration, the physical distance between sectors can be obtained. For example, if the CHS address of sector 1 is (100, 2, 5) and the CHS address of sector 2 is (105, 3, 8), then the cylinder difference is 5, the head difference is 1, and the sector difference is 3.

[0046] In some embodiments of the present invention, a backup sector of an abnormal sector is determined from at least one free sector based on physical distance, including: determining a distance weight of the corresponding free sector according to the physical distance; identifying a head type of at least one free sector, and determining a head switching weight of the corresponding free sector according to the head type; calculating a comprehensive distance of the corresponding free sector according to the physical distance, the distance weight and the head switching weight, and determining a backup sector of the abnormal sector from at least one free sector according to the comprehensive distance.

[0047] Among them, the head is the read-write component on the hard disk. Each sector belongs to the track corresponding to a specific head. Therefore, different sectors may correspond to different heads. For example, on a double-sided disk, head 0 is responsible for the tracks on the top surface of the disk, and head 1 is responsible for the tracks on the bottom surface.

[0048] Since the heads corresponding to sectors are different when reading and writing, and head switching is required when the heads are different, and head switching takes time, the embodiment of the present invention can take into account the time generated by head switching when determining the nearest idle sector of the abnormal sector as the backup sector based on the physical distance. Specifically, the comprehensive distance of the corresponding idle sector is calculated by the physical distance, the distance weight and the head switching weight, and the backup sector of the abnormal sector is determined from the idle sectors according to the comprehensive distance, so as to determine the most suitable backup sector for the abnormal sector, avoid the additional delay caused by head switching, thereby improving the backup replacement delay of the sector and improving the backup replacement efficiency of the sector.

[0049] In some embodiments of the present application, determining the backup sector of the abnormal sector from the at least one free sector according to the comprehensive distance comprises: sorting the at least one free sector according to the comprehensive distance; and selecting the free sector with the minimum comprehensive distance from the sorting result as the backup sector of the abnormal sector.

[0050] It can be understood that, in the embodiments of the present application, the free sectors can be sorted according to the comprehensive distance, and the free sector with the minimum comprehensive distance can be selected from the sorting result as the backup sector of the abnormal sector, so as to reduce the backup replacement delay of the sector and improve the backup replacement efficiency of the sector.

[0051] For example, assuming that the CHS address of the abnormal sector A is (cylinder 100, head 0, sector 5), there are three candidate backup sectors, and specifically:

[0052] The CHS address of the sector B is (cylinder 100, head 0, sector 7), and the physical distance from the abnormal sector A is 2, and the head type is the same as that of the abnormal sector A;

[0053] The CHS address of the sector C is (cylinder 101, head 0, sector 5), and the physical distance from the abnormal sector A is 3, and the head type is the same as that of the abnormal sector A;

[0054] The CHS address of the sector D is (cylinder 00, head 1, sector 5), and the physical distance from the abnormal sector A is 1, and the head type is different from that of the abnormal sector A.

[0055] Assuming that the weight of one head switching is equivalent to an increase of 5 in the physical distance, the comprehensive distance of the sector B is 2, the comprehensive distance of the sector C is 3, and the comprehensive distance of the sector D is 6, and finally the sector B is selected as the backup sector of the abnormal sector A.

[0056] In addition, it should be noted that, in the embodiments of the present application, the process of selecting the backup sector of the abnormal sector through the physical distance, that is, the process of calculating the comprehensive distance, can be realized through the DSSA algorithm.

[0057] In step S104, the address mapping table of the abnormal sector is updated to the address mapping table of the backup sector.

[0058] The address mapping table is a core data structure for realizing the conversion between the logical address and the physical address, and its function is similar to the navigation map inside the hard disk, so as to ensure that the upper software (such as the operating system) can access the data actually stored in the physical sector through the unified logical address.

[0059] There are two address systems for hard drives: LBA (Logical Block Addressing): The address visible to the operating system and users is a linear number of sectors (such as sector 0, sector 1000), which does not depend on the physical structure of the hard drive; physical address (CHS): The real address used to locate sectors inside the hard drive, composed of three-dimensional coordinates of cylinder (Cylinder), head (Head), and sector (Sector), which directly corresponds to the physical location on the disk. The function of the address mapping table is to establish the correspondence between LBA and CHS. For example: When the operating system requests to access LBA 100, the mapping table will tell the hard drive: "LBA 100 corresponds to physical address (cylinder 50, head 2, sector 8)", and the head will move to the target location accordingly to read and write data.

[0060] It can be understood that, after determining the backup sector of the abnormal sector, the embodiment of the present invention can update the address mapping table of the abnormal sector to the address mapping table of the backup sector to establish a mapping of the logical block address to the new sector, ensuring that the user's read and write requests for the abnormal sector can be correctly routed to the replaced backup sector.

[0061] In some embodiments of the present invention, before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, it also includes: identifying the actual number of backup sectors on the hard disk; if the actual number is less than the number threshold, updating the address mapping table of the abnormal sector to the address mapping table of the backup sector; if the actual number is greater than or equal to the number threshold, generating an abnormal alarm.

[0062] Among them, the quantity threshold can be set according to the specific situation, and there is no specific limit on this. For example, if the total number of sectors on the hard disk is 300 and the user-available sectors are set to 200, then the backup sectors are 100. Or it can be directly set according to the preset ratio, such as 1%~5% of the total sectors.

[0063] It can be understood that, in an embodiment of the present invention, when the actual number of backup sectors on the hard disk is less than the quantity threshold, the address mapping table of the abnormal sector is normally updated to the address mapping table of the backup sector. If the actual number is greater than or equal to the quantity threshold, an abnormal alarm is generated to ensure the user's available storage space and avoid excessive occupation of backup sectors. At the same time, when the actual number of used backup sectors exceeds the quantity table threshold, it indicates that many sectors in the hard disk have been damaged. Therefore, an abnormal alarm can be generated to remind the user to repair the hard disk in time.

[0064] The abnormal alarm in the embodiment of the present invention may be a sound alarm, or a code fault may be popped up on the operating system currently being used by the user.

[0065] For example, the preset threshold of the number of backup sectors is 20, the number of currently used backup sectors is 20, and an abnormal sector currently occurs, a hard disk abnormality alarm is generated, indicating that the hard disk has a relatively serious fault at this time, otherwise, if the number of currently used backup sectors is 18 and an abnormal sector currently occurs, the address mapping table of the abnormal sector is updated to the address mapping table of the backup sector determined by the abnormal sector.

[0066] In other words, the embodiment of the application can set the number of user available sectors and backup sectors on the hard disk, the user available sector is the storage space developed by the hard disk to the user, and setting the number of user available sectors and backup sectors can ensure the usability of the hard disk, avoid compressing the user available capacity due to unlimited occupation of backup sectors, and by setting the number of user available sectors and backup sectors, the backup sectors can be reserved to cope with the risk of sector damage, without excessive occupation of user space, further, the resource boundary of the two can also be delimited to avoid resource competition during operation and ensure stable operation of the hard disk.

[0067] In some embodiments of the application, the hard disk is divided into a plurality of running areas.

[0068] The running area can be divided according to specific conditions, such as being divided into inner circle, outer circle and middle circle according to the tracks of the hard disk.

[0069] In some embodiments of the application, before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, the method further comprises: identifying the running area of the abnormal sector; and determining the threshold according to the running area of the abnormal sector.

[0070] It can be understood that the embodiment of the application can determine the threshold according to the running area of the abnormal sector, so as to adjust the position of the backup sector, and by determining the threshold according to the running area of the abnormal sector, the threshold is adapted to the area characteristics, thereby improving the service life of the hard disk.

[0071] In some embodiments of the application, before determining the preset threshold according to the running area of the abnormal sector, the method further comprises: obtaining historical running data of the hard disk; determining distribution data of the abnormal sector on the hard disk according to the historical running data; and updating the threshold of the running area according to the distribution data.

[0072] The historical running data can be the data of the hard disk obtained periodically, such as data obtained once every 24 hours, including the distribution data of the abnormal sector.

[0073] It can be understood that the embodiment of the present invention can update the quantity threshold of each operating area based on the distribution data of abnormal sectors on the hard disk, so as to tilt the backup sectors toward high-risk areas, avoid premature failure due to exhaustion of backup sectors, reduce the movement of heads for cross-region replacement, reduce the overall seek time, maintain stable hard disk performance, and optimize resource utilization.

[0074] Specifically, the embodiment of the present invention can regularly (e.g., every 24 hours) count the distribution of bad sectors; if a certain area (e.g., the outer circle) has a high bad sector rate, the number of backup sectors in the area is dynamically increased; if a certain area has no bad sectors for a long time, the number of backup sectors is reduced and converted into available storage space.

[0075] In other words, since the hard disk is not specified by the user during the data writing process, but is randomly specified by the system, when the bad sectors in a certain area are high, then when writing data, priority is given to writing to the area with fewer bad sectors, that is, priority is given to using sectors in the area with fewer bad sectors, which is equivalent to reserving more free sectors in the area with more bad sectors in disguise, so that they can be used as backup sectors for the bad sectors in the area later, thereby optimizing resource allocation and relatively reducing the replacement time of bad sectors.

[0076] In some embodiments of the present invention, after updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, it also includes: obtaining a distributed linked list of the backup sector, wherein the distributed linked list stores the three-dimensional physical location and usage status of the backup sector; and updating the usage status of the backup sector in the distributed linked list.

[0077] The distributed linked list is a special data structure used to organize and manage the physical distribution of backup sectors. Unlike traditional linked lists, its nodes (backup sectors) are stored in separate physical areas of the hard drive rather than arranged continuously, enabling fast search and dynamic adjustment of backup sectors.

[0078] It is understandable that, after updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, the embodiment of the present invention updates the usage status of the backup sector to avoid subsequent duplicate allocation or resource conflict.

[0079] For example, the backup sector determined by the current abnormal sector is backup sector 1, and when the address mapping table of the abnormal sector is updated to the address mapping table of backup sector 1, the usage status of backup sector 1 is updated to used in the backup sector distributed linked list.

[0080] In the embodiment of the present invention, the distributed linked list may also be replaced by a bitmap structure.

[0081] In addition, it should be noted that the embodiment of the present invention only limits the number of backup sectors but does not limit the location of the backup sectors. The idle sector closest to the abnormal sector is selected as its backup sector from the idle sectors based on the specific situation. Therefore, the backup sector of the embodiment of the present invention can also participate in data storage when the hard disk is operating normally, or when the user's available sectors have been used up but there are still remaining backup sectors, they can be used as the user's available sectors, that is, the user's available storage space, to improve the utilization rate of the hard disk space.

[0082] Specifically, the core of the present invention's solution is to not fix the location of backup sectors, but to reserve a certain proportion of backup sectors outside of all available storage space on the hard drive. An intelligent algorithm is then used to dynamically select the optimal backup sector for bad sector replacement. This allows backup sectors to be flexibly allocated based on the location of bad sectors, thereby optimizing the bad sector replacement process and improving the reliability and performance of the hard drive. The core mechanisms of the present invention include:

[0083] 1. Initialization of the backup sector pool.

[0084] When the hard disk is shipped from the factory or low-level formatted, the backup sectors are not divided into fixed areas (such as outer / middle / inner circles). Instead, a certain proportion (such as 1% to 5%) of the backup sectors are dynamically reserved outside of all available sectors.

[0085] These backup sectors are managed in a distributed linked list manner, recording the physical location (CHS address) and status (free / occupied (also called used)) of each backup sector.

[0086] 2. Bad sector detection and replacement.

[0087] When the hard disk controller (HDD) detects a sector read / write failure (ECC (Error Checking and Correction) error or retry timeout), it is determined to be a bad sector.

[0088] The dynamic replacement algorithm starts:

[0089] Calculate the physical distance between the bad sector and all free backup sectors (based on Cylinder-Head-Sector (CHS) addressing).

[0090] Select the nearest available backup sector for replacement and update the BBT (Bad Block Table) to establish a mapping from logical block addresses to new physical sectors.

[0091] If the nearest backup sector is not available (it is already occupied), the next nearest backup sector is selected until an available sector is found.

[0092] 3. Dynamic balance.

[0093] Periodically (for example, every 24 hours) collect statistics on the distribution of bad sectors:

[0094] If the bad sector rate in a certain area (such as the outer ring) is high, the number of backup sectors in that area will be dynamically increased.

[0095] If a certain area has no bad sectors for a long time, reduce the number of backup sectors and convert them into available storage space.

[0096] The following describes the hard disk management method according to an embodiment of the present invention through a specific embodiment. The specific process is as follows: Figure 2 Shown, including:

[0097] 1. When reading and writing data on the hard disk, the target sector will be accessed and bad sectors will be detected through ECC verification or retry mechanism. If the access is successful, data reading and writing will be performed directly. If the access fails, the reading and writing will be retried.

[0098] 2. If the read and write retries are unsuccessful, the target sector will be marked as a bad sector.

[0099] 3. Call the DSSA algorithm to calculate the physical distance between the bad sector and all free backup sectors (based on the CHS address), select the backup sector with the shortest seek time for replacement, and reduce the head movement delay. If the backup sector cannot be found, a hard disk failure warning will be issued.

[0100] 4. If a suitable backup sector is found, the address mapping table of the original sector is updated. If the bad sector data can be recovered (through ECC error correction), the data is migrated to the new backup sector and the bad block mapping table (BBT) is updated to ensure that subsequent accesses are automatically redirected to the new sector.

[0101] 5. After the sector replacement is completed, update the backup sector monitoring data.

[0102] The specific process of dynamic allocation of backup sectors is as follows: Figure 3 Shown, including:

[0103] 1. Identify the bad sectors of the hard disk through the bad sector detection algorithm and receive the bad sector CHS search information, including Cylinder-Head-Sector.

[0104] 2. Get the hard disk free sector list and initialize the minimum distance.

[0105] 3. Call the dynamic sector allocation algorithm (DSSA) to traverse the three-dimensional distance of the sector and find the available sector with the minimum distance from the bad sector.

[0106] 4. After the traversal is completed, the best candidate backup sector is returned and the bad sector of the hard disk is replaced.

[0107] In summary, the hard disk management method according to the embodiment of the present invention can achieve the following beneficial effects:

[0108] 1. Reduce the delay of bad sector replacement.

[0109] By dynamically selecting the nearest backup sector, the head seek time is reduced and command timeouts are avoided.

[0110] 2. Improve storage space utilization.

[0111] The backup sectors can be used to store low-priority data when not in use, reducing resource waste.

[0112] 3. Enhance hard disk reliability.

[0113] Dynamically adjust the backup sector distribution to avoid partial backup sector exhaustion and extend the hard drive life.

[0114] 4. Compatible with existing hardware architecture.

[0115] There is no need to change the physical structure of the hard disk, only the firmware algorithm needs to be optimized, which is easy to implement.

[0116] Based on the above solution, the hard disk management method of the present invention will be described below through a specific application embodiment.

[0117] Assume that a hard drive is divided into three operating zones: outer zone (zone 1), middle zone (zone 2), and inner zone (zone 3). Each zone has a different preset threshold for the number of backup sectors. The current status is as follows:

[0118] Area 1 (outer circle): 20 backup sectors (15 currently idle), historical bad sector rate 8%;

[0119] Area 2 (middle circle): 30 backup sectors (25 currently free), historical bad sector rate 5%;

[0120] Area 3 (inner circle): 15 backup sectors (10 currently idle), historical bad sector rate 3%;

[0121] Step 1: When performing read and write operations, the hard disk firmware finds that the physical address CHS (100, 2, 10), located in area 1, does not respond to read requests for three consecutive times and marks it as an abnormal sector.

[0122] Step 2: Select the 15 free backup sectors in area 1 and calculate the physical distance between each backup sector and the abnormal sector:

[0123] Get the 3D physical location: abnormal sector CHS: (100, 2, 10);

[0124] Candidate backup sector A: (101, 2, 5) (short distance, same head);

[0125] Candidate backup sector B: (110, 3, 8) (far away, head switching required);

[0126] Calculate the comprehensive distance: distance weight: sector A (0.2), sector B (0.8), head switching weight: sector A (0), sector B (0.5).

[0127] Comprehensive distance: Sector A: 0.2 × 1 + 0 × 0.5 = 0.2 Sector B: 0.8 × 10 + 0.5 × 1 = 8.5.

[0128] Select the optimal backup sector: Sector A has the smallest comprehensive distance and is selected as the backup sector.

[0129] Step 3: The system updates the address mapping from the original CHS (100, 2, 10) to the backup sector CHS (110, 3, 8) and marks CHS (100, 2, 10) as unavailable.

[0130] Step 4: Based on the historical high bad sector rate of area 1 of 8%, increase the number of free sectors in area 1, that is, the number of backup sectors.

[0131] By selecting backup sectors with close physical distance, the head seek time is shortened and the read and write latency is reduced; dynamic adjustment ensures that there are sufficient backup sectors in high-risk areas (outer circle).

[0132] According to the hard disk management method proposed in an embodiment of the present invention, a backup sector with a fixed position is not set, and any idle sector can be used as a backup sector. After an abnormal sector is identified on the hard disk, the physical distance between the abnormal sector and other idle sectors is calculated, and the backup sector of the abnormal sector is determined from the idle sectors based on the physical distance. The closer idle sector can be selected as the backup sector of the abnormal sector through the physical distance, which reduces the head seek time to a certain extent, thereby reducing the sector replacement delay. At the same time, it can avoid frequent head movement to a certain extent, improve the sector replacement efficiency, and thus improve the reliability and performance of the hard disk.

[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0134] An embodiment of the present invention further provides a hard disk management device.

[0135] Figure 4 The figure is a block diagram of a hard disk management device according to an embodiment of the present invention.

[0136] like Figure 4 As shown, the hard disk management device 10 includes: an identification module 100 , a first determination module 200 , a second determination module 300 and an update module 400 .

[0137] Among them, the identification module 100 is used to identify the operating status of the working sector on the hard disk; the first determination module 200 is used to determine whether the corresponding working sector is an abnormal sector based on the operating status, wherein the abnormal sector is a sector that does not respond to data read requests and / or data write requests; the second determination module 300 is used to calculate the physical distance between the abnormal sector and at least one free sector if the working sector is an abnormal sector, and determine the backup sector of the abnormal sector from at least one free sector based on the physical distance; the update module 400 is used to update the address mapping table of the abnormal sector to the address mapping table of the backup sector.

[0138] In some embodiments of the present invention, the second determination module 300 is further configured to: obtain the 3D physical position of the abnormal sector and the 3D physical position of the idle sector; and calculate the physical distance based on the 3D physical position of the abnormal sector and the 3D physical position of the idle sector.

[0139] In some embodiments of the present invention, the second determination module 300 is further used to: determine the distance weight of the corresponding free sector based on the physical distance; identify the head type of at least one free sector, and determine the head switching weight of the corresponding free sector based on the head type; calculate the comprehensive distance of the corresponding free sector based on the physical distance, the distance weight and the head switching weight, and determine the backup sector of the abnormal sector from at least one free sector based on the comprehensive distance.

[0140] In some embodiments of the present invention, the second determining module 300 is further configured to: sort at least one idle sector according to the comprehensive distance; and select an idle sector with the smallest comprehensive distance from the sorting result as a backup sector for the abnormal sector.

[0141] In some embodiments of the present invention, the hard disk management device 10 of the embodiment of the present invention further includes: a judgment module.

[0142] Among them, the judgment module is used to identify the actual number of backup sectors on the hard disk before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector; if the actual number is less than the quantity threshold, the address mapping table of the abnormal sector is updated to the address mapping table of the backup sector; if the actual number is greater than or equal to the quantity threshold, an abnormal alarm is generated.

[0143] In some embodiments of the present invention, the hard disk is divided into multiple operating areas.

[0144] In some embodiments of the present invention, the hard disk management device 10 of the embodiment of the present invention further includes: a third determination module.

[0145] The third determining module is configured to identify the operation area of ​​the abnormal sector before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector; and determine the quantity threshold according to the operation area of ​​the abnormal sector.

[0146] In some embodiments of the present invention, the hard disk management device 10 of the embodiment of the present invention further includes: a fourth determining module.

[0147] Among them, the fourth determination module is used to obtain historical operation data of the hard disk before determining a preset number threshold according to the operation area of ​​the abnormal sector; determine the distribution data of the abnormal sectors on the hard disk according to the historical operation data; and update the number threshold of the operation area according to the distribution data.

[0148] It should be noted that the description of the features in the embodiment corresponding to the hard disk management device can refer to the relevant description of the embodiment corresponding to the hard disk management method, and will not be repeated here.

[0149] According to the hard disk management device proposed in an embodiment of the present invention, a backup sector with a fixed position is not set, and any idle sector can be used as a backup sector. After an abnormal sector is identified on the hard disk, the physical distance between the abnormal sector and other idle sectors is calculated, and the backup sector of the abnormal sector is determined from the idle sectors based on the physical distance. The closer idle sector can be selected as the backup sector of the abnormal sector through the physical distance, which reduces the head seek time to a certain extent, thereby reducing the sector replacement delay. At the same time, it can avoid frequent head movement to a certain extent, improve the sector replacement efficiency, and thus improve the reliability and performance of the hard disk.

[0150] An embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a memory 501 and a processor 502. The memory 501 stores a computer program, and the processor 502 is configured to run the computer program to execute the steps in any of the above hard disk management method embodiments.

[0151] An embodiment of the present invention further provides a non-volatile computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned hard disk management method embodiments when running.

[0152] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0153] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above hard disk management method embodiments are implemented.

[0154] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.

[0155] The above is a detailed introduction to the hard disk management method, electronic device, storage medium and program product provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core concept. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A hard disk management method, characterized in that: The following steps are involved: Identify the operating status of working sectors on the hard disk; determining whether a corresponding working sector is an abnormal sector according to the operating status, wherein the abnormal sector is a sector that does not respond to a data read request and / or a data write request; determining whether the corresponding working sector is an abnormal sector according to the operating status includes: if the working sector does not respond to the data read request and / or the data write request, re-executing the data read request and / or the data write request on the working sector; if the working sector still does not respond to the data read request and / or the data write request, determining that the corresponding working sector is an abnormal sector; If the working sector is an abnormal sector, calculating the physical distance between the abnormal sector and at least one free sector, and determining a backup sector of the abnormal sector from the at least one free sector based on the physical distance; calculating the physical distance between the abnormal sector and the at least one free sector, comprising: obtaining a three-dimensional physical position of the abnormal sector and a three-dimensional physical position of the free sector; calculating the physical distance based on the three-dimensional physical position of the abnormal sector and the three-dimensional physical position of the free sector, wherein the three-dimensional physical position includes a cylinder, a head, and a sector; determining the backup sector of the abnormal sector from the at least one free sector based on the physical distance, comprising: determining a distance weight corresponding to the free sector according to the physical distance; identifying a head type of the at least one free sector, and determining a head switching weight corresponding to the free sector according to the head type; calculating a comprehensive distance corresponding to the free sector according to the physical distance, the distance weight, and the head switching weight, and determining the backup sector of the abnormal sector from the at least one free sector according to the comprehensive distance; The address mapping table of the abnormal sector is updated to the address mapping table of the backup sector.

2. The hard disk management method according to claim 1, wherein: The determining, according to the comprehensive distance, a backup sector of the abnormal sector from at least one of the idle sectors comprises: sorting at least one of the idle sectors according to the comprehensive distance; The backup sector with the smallest comprehensive distance is selected from the sorting results as the backup sector of the abnormal sector.

3. The hard disk management method according to claim 1, wherein: Before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, the method further includes: Identify the actual number of said backup sectors on the hard disk; If the actual number is less than the number threshold, updating the address mapping table of the abnormal sector to the address mapping table of the backup sector; If the actual quantity is greater than or equal to the quantity threshold, an abnormality alarm is generated.

4. The hard disk management method according to claim 3, wherein: The hard disk is divided into a plurality of operating areas, and before updating the address mapping table of the abnormal sector to the address mapping table of the backup sector, the method further includes: Identify the operating area of ​​abnormal sectors; The quantity threshold is determined according to the operating area of ​​the abnormal sector.

5. The hard disk management method according to claim 4, characterized in that: Before determining the preset quantity threshold according to the operating area of ​​the abnormal sector, the method further includes: Obtaining historical operating data of the hard disk; Determining distribution data of abnormal sectors on the hard disk according to the historical operation data; The threshold value of the number of the operating areas is updated according to the distribution data.

6. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the hard disk management method according to any one of claims 1 to 5 when executing the computer program.

7. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the hard disk management method according to any one of claims 1 to 5 when executed by a processor.

8. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the hard disk management method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Disk management method and device and network equipment

    CN102306128A

  • Method and device for access control of disk data

    CN103064804A