Method and device for handling abnormal hard disk write operation of HM-SMR
By establishing a mapping relationship between abnormal storage blocks and CMR areas in SMR hard drives, the data to be written is stored in the CMR area, which solves the space waste and performance impact caused by abnormal storage blocks and achieves efficient data writing and performance improvement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIVIEW TECH CO LTD
- Filing Date
- 2024-11-27
- Publication Date
- 2026-05-29
AI Technical Summary
In SMR hard drives, when an abnormal sector appears within a storage block, current technology can only discard the entire storage block, resulting in wasted storage space and performance impact.
In shingled magnetic recording hard disks, by establishing a mapping relationship between abnormal storage blocks and traditional magnetic recording areas, the data to be written is stored in the CMR area, avoiding the direct discarding of abnormal storage blocks and utilizing the unoccupied space of the CMR area for data writing.
It saves storage space, reduces data write redundancy, improves the write performance of SMR hard drives, and enhances the user's writing experience.
Smart Images

Figure CN122111308A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of storage technology, and in particular to a method and apparatus for handling write operation anomalies on an HM-SMR hard disk. Background Technology
[0002] Shingled Magnetic Recording (SMR) hard drives are high-capacity disks that utilize a novel magnetic storage technology. SMR hard drives overlap the data tracks on the platters, a technique known as shingled magnetic recording. This technology requires very little change in the manufacturing process but can significantly increase disk storage density and effectively reduce the cost per unit capacity, representing the future trend in high-density disk storage technology.
[0003] When writing data to an SMR hard drive, the data is typically written to the SMR zone within the drive. An SMR zone consists of multiple storage blocks (Zones), each composed of multiple contiguous radial tracks on the same platter. Currently, each storage block has a capacity of 256MB, and the blocks are physically separated and do not interfere with each other.
[0004] Because each storage block has a corresponding write pointer, only sequential writes are supported, and random writes are not allowed. Therefore, when a sector within a storage block is faulty, the write operation cannot skip the faulty sector and continue writing. Instead, the entire storage block must be discarded, the data to be written must be reassembled, and other normal storage blocks must be selected for rewriting. This not only wastes the storage block's space capacity but also affects the performance of the SMR hard drive. Summary of the Invention
[0005] This invention provides a method and apparatus for handling write operation anomalies in HM-SMR hard disks, in order to overcome the deficiencies existing in related technologies.
[0006] This invention provides a method for handling write operation anomalies on an HM-SMR hard disk, comprising: Receive data to be written; During the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area within the shingled magnetic recording hard disk, if there is an abnormal sector, the abnormal capacity in the abnormal storage block where the abnormal sector is located is determined. If the unoccupied capacity of the traditional magnetic recording area within the shingled magnetic recording hard disk is greater than or equal to the abnormal capacity, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, the unoccupied space of the target capacity is requested from the traditional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data.
[0007] According to the present invention, a method for handling write operation anomalies in an HM-SMR hard disk includes, based on the remaining occupied capacity of currently unwritten data in the data to be written and the anomaly capacity, requesting unoccupied space of a target capacity from the conventional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data, comprising: Based on the relationship between the remaining occupied capacity and the abnormal capacity, the target capacity is determined, and the unoccupied space is requested from the traditional magnetic recording area to establish a mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space. Based on the mapping relationship, the target capacity of data from the currently unwritten data is written into the unoccupied space.
[0008] According to the present invention, a method for handling write operation anomalies in an HM-SMR hard disk includes determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity, comprising: If the remaining occupied capacity is greater than the abnormal capacity, then the target capacity is determined to be the abnormal capacity; Based on the mapping relationship, the step of writing the target capacity of currently unwritten data into the unoccupied space further includes: Write the remaining data from the currently unwritten data into a new storage block.
[0009] According to the HM-SMR hard disk write operation anomaly handling method provided by the present invention, the step of determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity further includes: If the remaining occupied capacity is less than or equal to the abnormal capacity, then the target capacity is determined to be the remaining occupied capacity.
[0010] According to the HM-SMR hard disk write operation anomaly handling method provided by the present invention, the method further includes, after establishing the mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space: Set the abnormal region to an invalid state; The mapping relationship, the change information of the termination address of the abnormal storage block, the capacity of the abnormal storage block after the mapping relationship is established, and the invalid state of the abnormal region are recorded in the disk metadata area of the shingled magnetic recording hard disk.
[0011] According to the present invention, a method for handling write operation anomalies in an HM-SMR hard disk includes, based on the remaining occupied capacity of currently unwritten data in the data to be written and the anomaly capacity, applying for unoccupied space of a target capacity in the conventional magnetic recording area of the shingled magnetic recording hard disk to write the currently unwritten data, and then including: Receive the deletion command for the data to be written; The data to be written to the abnormal storage block and the data to be written to the conventional magnetic recording area are deleted, the mapping relationship is released, and the records in the disk metadata area are updated.
[0012] According to the present invention, a method for handling write operation anomalies in an HM-SMR hard disk includes, based on the remaining occupied capacity of currently unwritten data in the data to be written and the anomaly capacity, applying for unoccupied space of a target capacity in the conventional magnetic recording area of the shingled magnetic recording hard disk to write the currently unwritten data, and further comprising: Receive the read instruction for the data to be written; Read the data written to the abnormal storage block by the data to be written, and based on the mapping relationship, read the data written to the conventional magnetic recording area by the data to be written.
[0013] According to the present invention, a method for handling write operation anomalies in an HM-SMR hard disk includes, after determining the abnormal capacity in the abnormal storage block where the abnormal sector is located, the method further includes: If the unoccupied capacity is less than the abnormal capacity, the data to be written will be rewritten to a new storage block.
[0014] An HM-SMR hard disk write operation anomaly handling device provided by the present invention includes: The data receiving module is used to receive data to be written. An exception handling module is used to, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area within a shingled magnetic recording hard disk, if an exception sector exists, determine the exception capacity in the exception storage block where the exception sector is located, and, if the unoccupied capacity of the traditional magnetic recording area within the shingled magnetic recording hard disk is greater than or equal to the exception capacity, apply for a target capacity of unoccupied space in the traditional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the exception capacity.
[0015] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the HM-SMR hard disk write operation exception handling method as described above.
[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the HM-SMR hard disk write operation exception handling method as described above.
[0017] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the HM-SMR hard disk write operation exception handling method as described above.
[0018] The HM-SMR hard disk write operation anomaly handling method and apparatus provided by this invention first receives the data to be written; then, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area (CMR) of the shingled magnetic recording hard disk, if an abnormal sector exists, the abnormal capacity of the abnormal storage block where the abnormal sector is located is determined. If the unoccupied capacity of the conventional magnetic recording area (CMR) in the shingled magnetic recording hard disk is greater than or equal to the abnormal capacity, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, the unoccupied space of the target capacity in the CMR in the shingled magnetic recording hard disk is requested to write the currently unwritten data. This method, when an abnormal sector exists in a storage block, does not directly discard the abnormal storage block containing the abnormal sector and select a new storage block. Instead, it prioritizes storing the currently unwritten data in the CMR area. This not only saves storage blocks and reduces storage space waste, but also avoids rewriting data from normal sectors already written to abnormal storage blocks to other storage blocks, reducing data writing redundancy and improving the write performance of the SMR hard disk. Furthermore, storing currently unwritten data from the data to be written into the CMR area will not be noticed by the client, which can improve the user's writing experience. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this invention or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the traditional magnetic recording method of a hard disk.
[0021] Figure 2 This is a schematic diagram of the magnetic recording method of an SMR hard drive.
[0022] Figure 3 This is one of the flowcharts of the HM-SMR hard disk write operation exception handling method provided by the present invention.
[0023] Figure 4 This is a schematic diagram of the SMR hard disk partitioning in the HM-SMR hard disk write operation exception handling method provided by the present invention.
[0024] Figure 5This is a schematic diagram of the abnormal storage block in the HM-SMR hard disk write operation abnormality handling method provided by the present invention.
[0025] Figure 6 This is a schematic diagram of the mapping relationship in the HM-SMR hard disk write operation exception handling method provided by the present invention.
[0026] Figure 7 This is the second flowchart of the HM-SMR hard disk write operation exception handling method provided by the present invention.
[0027] Figure 8 This is a schematic diagram of the structure of the HM-SMR hard disk write operation anomaly handling device provided by the present invention.
[0028] Figure 9 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0030] In SMR hard drives, the width of the read head can be smaller than the width of the write head. Data writing is achieved by partially overlapping the previous track, while leaving enough space for the narrower read head to read data from the previous track. The result of shingled writing is a narrower read track used for reading and a wider write track used for writing, covering the width of several read tracks. Compared to traditional hard drives, SMR hard drives, through shingled writing, accommodate more tracks within the same disk area, thereby increasing storage areal density and reducing the cost per unit storage capacity.
[0031] Figure 1 This is the traditional magnetic recording method used on hard disks. Figure 1 The width of the read head is smaller than the width of the write head, and two adjacent write tracks are independent of each other and there is no overlapping area.
[0032] Figure 2 This is the magnetic recording method used in SMR hard drives. Figure 2 The width of the read head is smaller than the width of the write head, but the areas occupied by two adjacent write tracks overlap except for the area occupied by the read track.
[0033] Because each storage block in the SMR area of an SMR hard drive can only be written sequentially and does not support random writing, when a sector within a storage block malfunctions, the entire storage block must be discarded, the data to be written must be reassembled, and other normal storage blocks must be selected for rewriting. This not only wastes the storage block's capacity but also affects the performance of the SMR hard drive. Based on this, this embodiment of the invention provides a method for handling write operation anomalies in an HM-SMR hard drive.
[0034] Figure 3 This is a flowchart illustrating an HM-SMR hard disk write operation exception handling method provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the method includes: S1, receives data to be written; S2, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area in the shingled magnetic recording hard disk, if there is an abnormal sector, the abnormal capacity in the abnormal storage block where the abnormal sector is located is determined, and if the unoccupied capacity of the traditional magnetic recording area in the shingled magnetic recording hard disk is greater than or equal to the abnormal capacity, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, the unoccupied space of the target capacity in the traditional magnetic recording area in the shingled magnetic recording hard disk is requested to write the currently unwritten data.
[0035] Specifically, the HM-SMR hard disk write operation exception handling method provided in this embodiment of the invention is executed by a host used to manage the SMR hard disk. It can be understood that the HM-SMR hard disk is a host-managed shingled magnetic recording (HM-SMR) hard disk, through which data writing, reading, deletion, and modification operations on the SMR hard disk can be performed.
[0036] like Figure 4 As shown, SMR hard drives include not only SMR areas but also conventional magnetic recording (CMR) areas. For ordinary SMR hard drives, the CMR area accounts for 1% of the total SMR disk capacity, while the SMR area accounts for 99%; however, for hybrid SMR hard drives, the CMR area accounts for an even larger proportion.
[0037] The CMR area has a 1GB disk data format (DDF) header, which includes sections such as the shared space management area, bad block mapping data area, and shared space data area, to record relevant information about the SMR hard drive.
[0038] First, execute step S1 to receive the data to be written. This data is the data that needs to be written to the SMR hard disk and can be sent by the client.
[0039] Then, step S2 is executed. Since the SMR area storage block includes multiple sectors, the data to be written can be written sector by sector in the SMR area storage block within the SMR hard disk. Here, this storage block can be obtained by the client from the SMR hard disk.
[0040] During the writing process of data to be written, if there is an abnormal sector, that is, a sector where data cannot be successfully written, the storage block where the abnormal sector is located is an abnormal storage block. The conventional approach is to directly discard the abnormal storage block and rewrite the data to be written into a new storage block. However, in this embodiment of the invention, when there is an abnormal sector, the host performs subsequent steps through the Bad Block Reallocated (BBR) unit, that is, first determines the abnormal capacity in the abnormal storage block where the abnormal sector is located. The abnormal capacity refers to the capacity of the abnormal region in the abnormal storage block, and the abnormal region refers to the area from the abnormal sector to the last sector of the last track in the abnormal storage block.
[0041] like Figure 5 As shown, the total capacity of the abnormal storage block is 256 (MB). If the Logical Block Address (LBA) of the first sector of the first track within the abnormal storage block is LBA0, and the LBA of the last sector of the last track is LBAn, then the total number of sectors within the abnormal storage block can be (LBAn-LBA0+1). The size of each sector is Y (MB). Therefore: .
[0042] like Figure 5 As shown, assuming the LBA of the unwritable sector is LBAm, the abnormal region within the abnormal storage block is the LBAm-LBAn segment, and the remaining unwritable capacity within the abnormal storage block is Z (MB), and we have: .
[0043] Next, determine the unused capacity of the CMR area within the SMR hard drive. This unused capacity refers to the capacity of the unused area within the CMR area, which is the area where data can be written.
[0044] The unused capacity H (MB) can be expressed as: H = W * XD; Where X (MB) is the total capacity of the SMR hard drive, W*X (MB) is the total capacity of the CMR area within the SMR hard drive, W is the percentage of the CMR area's capacity within the SMR hard drive, and D (MB) is the used capacity of the CMR area within the SMR hard drive.
[0045] After that, the unused capacity H of the CMR area can be compared with the abnormal capacity Z. If the unused capacity H of the CMR area is greater than or equal to the abnormal capacity Z, that is, H≥Z, it means that there is enough unused capacity in the CMR area to store the data that originally needed to be written to the abnormal area in the abnormal storage block. At this time, the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity are used to apply for the target capacity of unused space in the CMR area of the SMR hard disk to write the currently unwritten data.
[0046] Here, "currently unwritten data" refers to the data in the pending data, excluding the data in the normal sectors before the abnormal sectors were written. "Remaining occupied capacity" refers to the capacity required for the currently unwritten data to be successfully written, which is the size of the currently unwritten data.
[0047] Assuming the total capacity of the data to be written is M (MB), and the initial address of the storage block to be written to the SMR area is LBAx, then the remaining occupied capacity of the data to be written that has not yet been written is L (MB), and we have: .
[0048] For example, we can first compare the remaining occupied capacity L with the abnormal capacity Z, and take the smaller of the remaining occupied capacity and abnormal capacity min(L,Z) as the target capacity. Then, we can request the unoccupied space of the target capacity from the CMR area to write the currently unwritten data.
[0049] Once the currently unwritten data is successfully written to the CMR area, a success message is sent to the client. Therefore, the currently unwritten data is written to the unoccupied space of the target capacity of the CMR area without the client's awareness, which improves the user's writing experience.
[0050] The HM-SMR hard disk write operation anomaly handling method provided in this embodiment of the invention first receives the data to be written; then, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area within the shingled magnetic recording hard disk, if an abnormal sector exists, the abnormal capacity of the abnormal storage block where the abnormal sector is located is determined. If the unoccupied capacity of the conventional magnetic recording area within the shingled magnetic recording hard disk is greater than or equal to the abnormal capacity, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, the method requests the target capacity of unoccupied space in the conventional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data. When an abnormal sector exists in a storage block, this method does not directly discard the abnormal storage block containing the abnormal sector and select a new storage block. Instead, it prioritizes storing the currently unwritten data in the shingled data into the CMR area. This not only saves storage blocks and reduces storage space waste, but also avoids rewriting data from normal sectors already written to abnormal storage blocks to other storage blocks, reducing data writing redundancy and improving the write performance of the SMR hard disk. Furthermore, storing currently unwritten data from the data to be written into the CMR area will not be noticed by the client, which can improve the user's writing experience.
[0051] Based on the above embodiments, the step of requesting unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity includes: Based on the relationship between the remaining occupied capacity and the abnormal capacity, the target capacity is determined, and the unoccupied space is requested from the traditional magnetic recording area to establish a mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space. Based on the mapping relationship, the target capacity of data from the currently unwritten data is written into the unoccupied space.
[0052] Specifically, during the process of requesting unused space in the CMR area of an SMR hard drive to write currently unwritten data, the target capacity can be determined by the relationship between the remaining unwritten space and the abnormal capacity. For example, if the remaining unwritten space is greater than the abnormal capacity of the abnormal storage block, it means that even if the abnormal storage block is normal, its total capacity is insufficient to store the data to be written, and the remaining data needs to be written to a new storage block. Therefore, to avoid confusion in the mapping between storage blocks and CMR areas, the abnormal capacity can be used as the target capacity. If the remaining unwritten space is less than or equal to the abnormal capacity of the abnormal storage block, it means that if the abnormal storage block is normal, its total capacity is just enough to store the data to be written, or there is still space remaining after storing the data to be written. Therefore, the remaining unwritten space can be directly used as the target capacity.
[0053] Afterwards, unused space of the target capacity can be requested from the CMR area, and a mapping relationship can be established between the abnormal region in the abnormal storage block and the unused space of the target capacity. This mapping relationship can be the correspondence between each sector in the abnormal region and each location in the unused space of the CMR area. For example... Figure 6 As shown, if the unoccupied space in the CMR area is represented as the LBAa-LBAb segment, then the mapping relationship can be a mapping from the LBAm-LBAn segment to the LBAa-LBAb segment.
[0054] Therefore, this mapping relationship can be used to write currently unwritten data from the data to be written into the unused space of the target capacity. It is understandable that if the remaining occupied capacity of the currently unwritten data is greater than the abnormal capacity of the faulty storage block, the unused space of the target capacity requested from the CMR area cannot completely write all the currently unwritten data. Therefore, only the data of the target capacity from the currently unwritten data can be written into the unused space of the target capacity, and the remaining data needs to be written into the new storage block after the client requests it. If the remaining occupied capacity of the currently unwritten data is less than or equal to the abnormal capacity of the faulty storage block, the unused space of the target capacity requested from the CMR area is sufficient to completely write all the currently unwritten data. Therefore, after writing the currently unwritten data into the unused space of the target capacity, there is no remaining data, and the client does not need to request a new storage block.
[0055] In this embodiment of the invention, by applying for unoccupied space of the target capacity from the CMR zone and establishing a mapping relationship between abnormal areas and unoccupied space, not only can the space utilization of the SMR hard drive be maximized, but it can also provide convenience for fast data reading, modification, deletion and other operations.
[0056] Based on the above embodiments, determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity includes: If the remaining occupied capacity is greater than the abnormal capacity, then the target capacity is determined to be the abnormal capacity; Based on the mapping relationship, the step of writing the target capacity of currently unwritten data into the unoccupied space further includes: Write the remaining data from the currently unwritten data into a new storage block.
[0057] Specifically, when determining the target capacity, if the remaining occupied capacity L of the currently unwritten data is greater than the abnormal capacity Z in the abnormal storage block (i.e., L > Z), then the target capacity can be determined as the abnormal capacity Z in the abnormal storage block. Furthermore, after writing the target capacity of the currently unwritten data into the unoccupied space, since there is still remaining data in the currently unwritten data that has nowhere to be written, it is necessary to write the remaining data in the currently unwritten data into a new storage block. This new storage block can be obtained by the client from the SMR hard drive. Here, the capacity of the remaining data in the currently unwritten data is LZ.
[0058] In this embodiment of the invention, when the remaining occupied capacity is greater than the abnormal capacity, after writing the target capacity of the currently unwritten data into the unoccupied space, it is also necessary to write the remaining data in the currently unwritten data into a new storage block to ensure that all data to be written is written to the SMR hard disk.
[0059] Based on the above embodiments, determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity further includes: If the remaining occupied capacity is less than or equal to the abnormal capacity, then the target capacity is determined to be the remaining occupied capacity.
[0060] Specifically, if the remaining occupied capacity L is less than or equal to the abnormal capacity Z (L≤Z), and the unoccupied capacity H of the CMR area is greater than or equal to the abnormal capacity Z (H≥Z), and the remaining occupied capacity L is less than or equal to the unoccupied capacity H of the CMR area (L≤Z≤H), then the target capacity can be determined as the remaining occupied capacity L. This means the CMR area has sufficient unoccupied space for writing unwritten data. After the mapping write is completed, the client has finished writing all the data to be written, and there is no need to trigger the client to request new storage blocks in the SMR area for writing.
[0061] If the remaining occupied capacity L is greater than the unoccupied capacity H of the CMR area (i.e., H < L), it means that there is not enough unoccupied capacity in the CMR area to store the data that originally needed to be written to the abnormal area in the abnormal storage block. Therefore, the host reports an error to the client, which needs to reassemble the data to be written and re-apply for a new storage block to rewrite the data to be written into the new storage block.
[0062] Based on the above embodiments, the step of establishing the mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space further includes: Set the abnormal region to an invalid state; The mapping relationship, the change information of the termination address of the abnormal storage block, and the invalid status of the abnormal region are recorded in the disk metadata area of the shingled magnetic recording hard disk.
[0063] Specifically, after establishing the mapping relationship, since it is only necessary to write the unwritten data to the unoccupied space in the CMR area, the abnormal area in the abnormal storage block is no longer useful for writing data, so the abnormal area can be set to an invalid state.
[0064] Afterwards, the mapping relationship, the change information of the termination address of the abnormal storage block, and the invalid state of the abnormal region can be stored in the DDF of the SMR hard disk in the form of records. In this way, the records can be read from the SMR hard disk and put into memory when the client boots up.
[0065] Before establishing the mapping relationship, the termination address of the abnormal storage block is the termination LBA of the abnormal storage block, which refers to the LBA of the last sector on the last track of the abnormal storage block. After establishing the mapping relationship, since the normal area in the abnormal storage block can store data normally, the termination address of the abnormal storage block is the starting LBA of the abnormal area in the abnormal storage block, which refers to the termination address of the normal area in the abnormal storage block.
[0066] The capacity of the abnormal storage block before and after establishing the mapping relationship can also be recorded in the DDF. Before establishing the mapping relationship, the capacity of the abnormal storage block is equal to the normal capacity in the abnormal storage block. After establishing the mapping relationship, the capacity of the abnormal storage block is equal to the sum of the normal capacity in the abnormal storage block and the capacity occupied by the data mapped to the CMR area.
[0067] In addition, the occupied locations and occupied capacity of the CMR area can be recorded in the DDF to prevent data loss during power outages.
[0068] The records corresponding to each abnormal storage block can be summarized in a record table, and some contents of the record table are shown in Table 1.
[0069] Table 1 Record Table Partial Content
[0070] The starting LBA of the abnormal region refers to the LBA of the abnormal sector, and the ending LBA of the abnormal region refers to the LBA of the last sector on the last track of the abnormal memory block.
[0071] In this embodiment of the invention, the relevant information of the abnormal storage block is recorded in the DDF of the SMR hard disk, which facilitates the determination of the writing location of the data to be written and the relevant information of the abnormal storage block, providing convenience for subsequent operations such as reading, modifying, and deleting the data to be written, and facilitating the maintenance of the SMR hard disk.
[0072] Based on the above embodiments, the step of applying for unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, and then including: Receive the deletion command for the data to be written; The data to be written to the abnormal storage block and the data to be written to the conventional magnetic recording area are deleted, the mapping relationship is released, and the records in the disk metadata area are updated.
[0073] Specifically, after the data to be written is written to the SMR and CMR areas of the SMR hard drive, a deletion command for the data to be written can be received. This deletion command is used to instruct the host to delete the data to be written to the SMR hard drive.
[0074] Afterwards, the data to be written to the abnormal storage block and the data written to the CMR area are deleted. To achieve information synchronization, it is also necessary to remove the mapping relationship established when writing data and update the records in the DDF area, i.e., update Table 1. For example, the start / end LBA of the unoccupied space in the CMR area is set to null, and the capacity of the abnormal storage block is updated to the normal capacity available for writing before the abnormal sector. This makes it easier for the host to identify the actual normal capacity of the abnormal storage block.
[0075] Based on the above embodiments, the step of applying for unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, and then including: Receive the read instruction for the data to be written; Read the data written to the abnormal storage block by the data to be written, and based on the mapping relationship, read the data written to the conventional magnetic recording area by the data to be written.
[0076] Specifically, after the data to be written is written to the SMR and CMR areas of the SMR hard drive, a read command for the data to be written can be received. This read command instructs the host to read the data to be written to the SMR hard drive.
[0077] Subsequently, the host reads the data written in the abnormal storage block and, based on the mapping relationship, reads the data written in the conventional magnetic recording area.
[0078] Based on the above embodiments, after determining the abnormal capacity in the abnormal storage block where the abnormal sector is located, the method further includes: If the unoccupied capacity is less than the abnormal capacity, the data to be written will be rewritten to a new storage block.
[0079] Specifically, if the unused capacity H is less than the abnormal capacity Z (i.e., H < Z), it means that there is not enough unused capacity in the CMR area to store the data that should have been written to the abnormal area in the abnormal storage block. Therefore, the host reports an error to the client, which needs to reassemble the data to be written and re-apply for a new storage block to rewrite the data to be written into the new storage block.
[0080] like Figure 7 The diagram shown is a complete flowchart of an HM-SMR hard disk write operation exception handling method provided in an embodiment of the present invention. The method includes: The host begins writing the data to be written sector by sector in the storage block of the SMR area; Determine if there are any abnormal sectors. If there are abnormal sectors, use BBR to calculate the remaining occupied capacity L of the data to be written that has not yet been written, and calculate the abnormal capacity Z in the abnormal storage block where the abnormal sector is located. If there are no abnormal sectors, the storage block is successfully written. Determine the relationship between L and Z. If L > Z, then use Z as the target capacity that BBR requests from the CMR area, request the unused space of the target capacity from the CMR area, and write the remaining data (with a capacity of LZ) in the currently unwritten data to the new storage block. If L ≤ Z, then use L as the target capacity that BBR requests from the CMR area, and request the unused space of the target capacity from the CMR area. Determine the relationship between the unoccupied capacity H and the abnormal capacity Z of the CMR area. If H ≥ Z, establish a mapping relationship and write the currently unwritten data to the unoccupied space of the CMR area based on the mapping relationship. If H < Z, select a new storage block, reorganize the data to be written, and rewrite the data to be written in the new storage block.
[0081] In summary, the HM-SMR hard disk write operation anomaly handling method provided in this embodiment of the invention, when there are abnormal sectors within the SMR area's storage block, establishes a mapping relationship between the abnormal region and the CMR area, allowing the writing of currently unwritten data to continue without reselecting a new storage block or reorganizing the data to be written, thus effectively improving write performance. Furthermore, already written data remains unchanged; the entire abnormal storage block is not discarded, but rather each storage block within the SMR area is transformed into usable storage blocks of varying sizes, thereby maximizing the space utilization of the SMR hard disk. In addition, information such as the mapping relationship, the usage status of abnormal storage blocks within the SMR area, and the usage status of the CMR area are all recorded in the DDF area to prevent data loss upon power failure, and can be read from the DDF area into memory during boot.
[0082] like Figure 8 As shown, based on the above embodiments, this embodiment of the invention provides an HM-SMR hard disk write operation anomaly handling device, including: Data receiving module 81 is used to receive data to be written; The exception handling module 82 is used to, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area in the shingled magnetic recording hard disk, if there is an exception sector, determine the exception capacity in the exception storage block where the exception sector is located, and if the unoccupied capacity of the traditional magnetic recording area in the shingled magnetic recording hard disk is greater than or equal to the exception capacity, apply for the target capacity of unoccupied space in the traditional magnetic recording area in the shingled magnetic recording hard disk to write the currently unwritten data based on the remaining occupied capacity of the currently unwritten data in the data to be written and the exception capacity.
[0083] Based on the above embodiments, the exception handling module is specifically used for: Based on the relationship between the remaining occupied capacity and the abnormal capacity, the target capacity is determined, and the unoccupied space is requested from the traditional magnetic recording area to establish a mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space. Based on the mapping relationship, the target capacity of data from the currently unwritten data is written into the unoccupied space.
[0084] Based on the above embodiments, the exception handling module is further specifically used for: If the remaining occupied capacity is greater than the abnormal capacity, then the target capacity is determined to be the abnormal capacity; Based on the mapping relationship, the step of writing the target capacity of currently unwritten data into the unoccupied space further includes: Write the remaining data from the currently unwritten data into a new storage block.
[0085] Based on the above embodiments, the exception handling module is further specifically used for: If the remaining occupied capacity is less than or equal to the abnormal capacity, then the target capacity is determined to be the remaining occupied capacity.
[0086] Based on the above embodiments, the exception handling module is further specifically used for: Set the abnormal region to an invalid state; The mapping relationship, the change information of the termination address of the abnormal storage block, the normal capacity of the abnormal storage block after the mapping relationship is established, and the invalid state of the abnormal area are recorded in the disk metadata area of the shingled magnetic recording hard disk.
[0087] Based on the above embodiments, the exception handling module is further specifically used for: Receive the deletion command for the data to be written; The data to be written to the abnormal storage block and the data to be written to the conventional magnetic recording area are deleted, the mapping relationship is released, and the records in the disk metadata area are updated.
[0088] Based on the above embodiments, the exception handling module is further specifically used for: Receive the read instruction for the data to be written; Read the data written to the abnormal storage block by the data to be written, and based on the mapping relationship, read the data written to the conventional magnetic recording area by the data to be written.
[0089] Based on the above embodiments, the exception handling module is further specifically used for: If the unoccupied capacity is less than the abnormal capacity, the data to be written will be rewritten to a new storage block.
[0090] Specifically, the functions of each module in the HM-SMR hard disk write operation exception handling device provided in this embodiment of the invention correspond one-to-one with the operation flow of each step in the above method-like embodiments, and the achieved effects are also the same. For details, please refer to the above embodiments, and this will not be repeated in this embodiment of the invention.
[0091] Figure 9 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 9As shown, the electronic device may include a processor 910, a communications interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communications interface 920, and the memory 930 communicate with each other via the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute the HM-SMR hard disk write operation exception handling method provided in the above embodiments.
[0092] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to related technologies, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0093] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the HM-SMR hard disk write operation exception handling method provided in the above embodiments.
[0094] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the HM-SMR hard disk write operation exception handling method provided in the above embodiments.
[0095] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0096] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of software products. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for handling write operation anomalies on an HM-SMR hard disk, characterized in that, include: Receive data to be written; During the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area within the shingled magnetic recording hard disk, if there is an abnormal sector, the abnormal capacity in the abnormal storage block where the abnormal sector is located is determined. If the unoccupied capacity of the conventional magnetic recording area within the shingled magnetic recording hard disk is greater than or equal to the abnormal capacity, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, the unoccupied space of the target capacity is requested from the conventional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data.
2. The HM-SMR hard disk write operation anomaly handling method according to claim 1, characterized in that, The step of applying for unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity includes: Based on the relationship between the remaining occupied capacity and the abnormal capacity, the target capacity is determined, and the unoccupied space is requested from the traditional magnetic recording area to establish a mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space. Based on the mapping relationship, the target capacity of data from the currently unwritten data is written into the unoccupied space.
3. The HM-SMR hard disk write operation anomaly handling method according to claim 2, characterized in that, Determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity includes: If the remaining occupied capacity is greater than the abnormal capacity, then the target capacity is determined to be the abnormal capacity; Based on the mapping relationship, the step of writing the target capacity of currently unwritten data into the unoccupied space further includes: Write the remaining data from the currently unwritten data into a new storage block.
4. The HM-SMR hard disk write operation anomaly handling method according to claim 2, characterized in that, The step of determining the target capacity based on the relationship between the remaining occupied capacity and the abnormal capacity further includes: If the remaining occupied capacity is less than or equal to the abnormal capacity, then the target capacity is determined to be the remaining occupied capacity.
5. The HM-SMR hard disk write operation anomaly handling method according to claim 2, characterized in that, The process of establishing the mapping relationship between the abnormal region in the abnormal storage block and the unoccupied space further includes: Set the abnormal region to an invalid state; The mapping relationship, the change information of the termination address of the abnormal storage block, the capacity of the abnormal storage block after the mapping relationship is established, and the invalid state of the abnormal region are recorded in the disk metadata area of the shingled magnetic recording hard disk.
6. The HM-SMR hard disk write operation anomaly handling method according to claim 5, characterized in that, The process involves applying for unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, followed by: Receive the deletion command for the data to be written; The data to be written to the abnormal storage block and the data to be written to the conventional magnetic recording area are deleted, the mapping relationship is released, and the records in the disk metadata area are updated.
7. The HM-SMR hard disk write operation anomaly handling method according to claim 2, characterized in that, The process involves applying for unoccupied space of the target capacity from the traditional magnetic recording area within the shingled magnetic recording hard disk based on the remaining occupied capacity of the currently unwritten data in the data to be written and the abnormal capacity, followed by: Receive the read instruction for the data to be written; Read the data written to the abnormal storage block by the data to be written, and based on the mapping relationship, read the data written to the conventional magnetic recording area by the data to be written.
8. A device for handling write operation anomalies in HM-SMR hard disks, characterized in that, include: The data receiving module is used to receive data to be written. An exception handling module is used to, during the process of writing the data to be written sector by sector in the storage block of the shingled magnetic recording area within a shingled magnetic recording hard disk, if an exception sector exists, determine the exception capacity in the exception storage block where the exception sector is located, and, if the unoccupied capacity of the traditional magnetic recording area within the shingled magnetic recording hard disk is greater than or equal to the exception capacity, apply for a target capacity of unoccupied space in the traditional magnetic recording area within the shingled magnetic recording hard disk to write the currently unwritten data, based on the remaining occupied capacity of the currently unwritten data in the data to be written and the exception capacity.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the HM-SMR hard disk write operation exception handling method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the HM-SMR hard disk write operation exception handling method as described in any one of claims 1-7.