Data writing method and device and storage medium

By mapping data to mapped tracks in the SMR disk, data writing errors caused by inconsistencies between the write instruction start address and the write pointer address are resolved, and the random write function of the SMR disk is realized, ensuring that data writing does not affect data on other tracks.

CN120595993APending Publication Date: 2025-09-05GUANGDONG AIRPORT MANAGEMENT GRP CO LTD ENG CONSTR HEADQUARTERS +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410218742.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-28
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

SMR disks do not support write pointer rollback, resulting in the inability to perform random writes. Existing technologies cannot effectively resolve data write errors when the write instruction start address and the write pointer address are inconsistent.

Method used

Before writing data, determine the starting and ending addresses of the data to be stored, determine whether there is a mapped track, and map the data to the mapped track when necessary to ensure that the write does not overwrite the data of the next track. Manage track usage through the data migration module.

Benefits of technology

It realizes random writing of SMR disk, avoids the written data overwriting the data in other tracks, and ensures the accuracy and integrity of the writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120595993A_ABST
    Figure CN120595993A_ABST
Patent Text Reader

Abstract

The invention provides a data writing method and device and a storage medium, and relates to the technical field of magnetic disk, the method comprises the following steps: under the condition that a writing instruction of to-be-stored data is received, determining an initial address and a first termination address of the to-be-stored data in an SMR disk; under the condition that no mapped magnetic track exists between a first magnetic track to which the initial address belongs and a second magnetic track to which the first termination address belongs, determining whether the first termination address is a second termination address of the last magnetic track in a target area to which the second magnetic track belongs, when it is determined that the first termination address is not the second termination address and first data is stored between the first termination address in the second magnetic track and a termination address of a first target magnetic track in the target area, mapping the first data into a first mapping magnetic track; and writing the to-be-stored data based on the initial address and the first termination address. According to the invention, random write-in of data is realized, and data in other magnetic tracks are not influenced after random write-in.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Shingled Magnetic Recording (SMR) is a high-capacity disk that utilizes a novel magnetic storage technology. SMR disks partially overlap the data tracks on the disk, much like tiles on a roof. This technology, known as shingled magnetic recording, requires minimal changes to the manufacturing process, yet significantly increases disk storage density. In today's world of rapidly growing data volumes, SMR technology can effectively reduce the cost per unit of disk storage capacity, making it the future trend in high-density disk storage technology.

[0003] In related technologies, SMR disks do not support write pointer rollback. When a data write instruction is issued, if the write start address is inconsistent with the address where the write pointer is located, an error message will be returned, resulting in the inability to perform random writes. Summary of the Invention

[0004] In view of the problems existing in the prior art, embodiments of the present invention provide a data writing method, device and storage medium.

[0005] The present invention provides a data writing method, comprising:

[0006] Upon receiving a write instruction for data to be stored, determining a start address of the data to be stored and a first end address of the data to be stored in the SMR disk;

[0007] If it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determining whether the second track is a non-last track in a target area to which the second track belongs; the target area is an area in a resource area of ​​the SMR disk;

[0008] If it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, a first mapping track corresponding to the first data is determined in the mapping area of ​​the SMR disk; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0009] Reading the first data, and mapping the first data to the first mapping track;

[0010] The data to be stored is written based on the start address and the first end address.

[0011] According to a data writing method provided by the present invention, the method further includes:

[0012] When it is determined that there is a mapped track between the first track and the second track, the data to be stored is written based on the positional relationship, the start address and the first end address; the positional relationship is the positional relationship between the first track, the second track and the second target track; the second target track includes the mapped track and / or the mapping track corresponding to the mapped track.

[0013] According to a data writing method provided by the present invention, writing the data to be stored based on the position relationship, the start address and the first end address includes:

[0014] In a case where the positional relationship includes the first track being before the mapped track and the second track being a mapping track corresponding to the mapped track, the data to be stored is written based on the start address and the first end address.

[0015] According to a data writing method provided by the present invention, writing the data to be stored based on the position relationship, the start address and the first end address includes:

[0016] In a case where the positional relationship includes the first track and the second track being mapping tracks corresponding to the mapped track, the data to be stored is written into the mapping track starting from the start address.

[0017] According to a data writing method provided by the present invention, writing the data to be stored based on the position relationship, the start address and the first end address includes:

[0018] In the case where the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, the first mapping relationship between the mapped track and the mapping track is deleted, and the step returns to determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0019] According to a data writing method provided by the present invention, writing the data to be stored based on the position relationship, the start address and the first end address includes:

[0020] If the positional relationship includes the first track being the mapping track and the second track being after the mapped track, and it is determined that a new mapping relationship needs to be established when writing the data to be stored, reading data from a new mapped track included in the new mapping relationship, and writing the data from the new mapped track to a new mapping track included in the new mapping relationship;

[0021] Reading second data between the starting address of the mapped track and the starting address of the data to be stored, and writing the second data back to the mapped track;

[0022] The first mapping relationship between the mapped track and the mapping track is deleted, and the process returns to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0023] According to a data writing method provided by the present invention, the method further includes:

[0024] After the data in the mapped track included in the target mapping relationship is written to the mapping track included in the target mapping relationship, the target mapping relationship, the track usage of the resource area, and the track usage of the mapping area are all stored in the disk data format area of ​​the SMR disk, and the target mapping relationship is stored in the data migration module; the target mapping relationship includes the first mapping relationship, the new mapping relationship, or a second mapping relationship between the track to which the first data belongs and the first mapping track;

[0025] In the process of writing the data to be stored, if data is written in the mapped track, after writing the data in the data to be stored to the mapped track, updating the track usage of the mapping area into the disk data format area, and deleting the first mapping relationship in the disk data format area and the data migration module;

[0026] After the data to be stored is written, the track usage status of the resource area is updated to the disk data format area.

[0027] According to a data writing method provided by the present invention, the method further includes:

[0028] When it is determined by the data migration module based on the currently stored mapping relationships that there are multiple continuous mapped tracks in the same area and all addresses of the outermost mapped track among the multiple continuous mapped tracks are mapped, traversal begins from the innermost mapped track among the multiple continuous mapped tracks, and when it is determined that neither the currently traversed mapped track nor the mapped track corresponding to the currently traversed mapped track is currently performing a write operation, and when the next track of the currently traversed mapped track is a mapped track, data in the mapped track corresponding to the currently traversed mapped track is written back to the currently traversed mapped track, and a third mapping relationship between the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track is deleted;

[0029] The track usage status of the currently traversed mapped track and the track usage status of the mapped track corresponding to the currently traversed mapped track are stored in the disk data format area, and the third mapping relationship is deleted in the disk data format area and the data migration module until the traversal is completed.

[0030] According to a data writing method provided by the present invention, determining a first mapping track corresponding to the first data in a mapping area of ​​the SMR disk includes:

[0031] In a case where it is determined that there is a free track in the mapping area whose writing space is greater than or equal to the occupied space of the first data, the first mapping track is determined based on the free track.

[0032] According to a data writing method provided by the present invention, writing the data to be stored based on the start address and the first end address includes:

[0033] In the case that the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address.

[0034] The present invention also provides a data writing device, comprising:

[0035] a first determining unit, configured to determine, in the SMR disk, a start address of the data to be stored and a first end address of the data to be stored, upon receiving a write instruction for the data to be stored;

[0036] a second determining unit configured to, when it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determine whether the first end address is the second end address of the last track in a target area to which the second track belongs; the target area being an area in a resource area of ​​the SMR disk;

[0037] a third determining unit configured to, if it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, determine, in the mapping area of ​​the SMR disk, a first mapping track corresponding to the first data; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0038] a mapping unit, configured to read the first data and map the first data to the first mapping track;

[0039] A first writing unit is configured to write the data to be stored based on the start address and the first end address.

[0040] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-described data writing methods is implemented.

[0041] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements any of the above-mentioned data writing methods when executed by a processor.

[0042] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned data writing methods.

[0043] The data writing method, device, and storage medium provided by the present invention, upon receiving a write instruction for data to be stored, determine the starting address and first ending address of the data to be stored in the SMR disk, determine if there is no mapped track between the first track to which the starting address belongs and the second track to which the first ending address belongs, determine if the first ending address is the second ending address of the last track in the target area to which the second track belongs, and if it is determined that the first ending address is not the second ending address and first data is stored between the first ending address in the second track and the ending address of the first target track in the target area, map the first data to the first mapped track, and then write the data to be stored based on the starting address and the first ending address. Before writing the data to be stored, the present invention needs to first determine if the first ending address is the second ending address of the last track in the target area to which the second track belongs. When it is determined that the first ending address is not the second ending address, map the first data to the first mapped track before writing the data to be stored. Therefore, when writing the data to be stored, data in the next track of the currently written track will not be overwritten, thereby achieving random writing of data and ensuring that data in other tracks is not affected after random writing. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0045] Figure 1 It is a schematic diagram of a conventional magnetic recording method of a magnetic disk in the related art;

[0046] Figure 2 It is a schematic diagram of the magnetic recording method of the SMR disk in the related art;

[0047] Figure 3 It is a schematic diagram of the structure of the SMR disk in the related art;

[0048] Figure 4 This is one of the flow charts of the data writing method provided by an embodiment of the present invention;

[0049] Figure 5 This is a schematic diagram of the partitions of an SMR disk provided by an embodiment of the present invention;

[0050] Figure 6 is a schematic diagram of a magnetic track in zone C provided by an embodiment of the present invention;

[0051] Figure 7 It is a structural schematic diagram of a region provided by the present invention;

[0052] Figure 8 is a schematic diagram of a magnetic track provided by an embodiment of the present invention;

[0053] Figure 9 This is one of the schematic diagrams of data writing provided by an embodiment of the present invention;

[0054] Figure 10 This is a second flow chart of the data writing method provided by an embodiment of the present invention;

[0055] Figure 11 This is the third flow chart of the data writing method provided by an embodiment of the present invention;

[0056] Figure 12 This is the second schematic diagram of data writing provided by an embodiment of the present invention;

[0057] Figure 13 This is a fourth flow chart of the data writing method provided by an embodiment of the present invention;

[0058] Figure 14 This is the third schematic diagram of data writing provided by an embodiment of the present invention;

[0059] Figure 15 This is the fifth flow chart of the data writing method provided by an embodiment of the present invention;

[0060] Figure 16 This is the fourth schematic diagram of data writing provided by an embodiment of the present invention;

[0061] Figure 17 This is the sixth flow chart of the data writing method provided by an embodiment of the present invention;

[0062] Figure 18 This is the fifth schematic diagram of data writing provided by an embodiment of the present invention;

[0063] Figure 19 This is the sixth schematic diagram of data writing provided by an embodiment of the present invention;

[0064] Figure 20 This is the seventh schematic diagram of data writing provided by an embodiment of the present invention;

[0065] Figure 21 1 is a schematic structural diagram of a data writing device provided by an embodiment of the present invention;

[0066] Figure 22 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0067] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some 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 creative efforts shall fall within the scope of protection of the present invention.

[0068] SMR disks take advantage of the fact that the read head width can be smaller than the write head width. Data is written by partially overlapping the previous track, while leaving enough space for the narrower read head to read the data from the previous track. The result of shingled writing is a narrow track reserved for reading data and a wider write track for writing. The write will cover the width of several read tracks. Compared with traditional disks, SMR disks can accommodate more tracks in the same area through shingled writing, thereby increasing the storage area density and reducing the cost per unit storage capacity of the disk.

[0069] Figure 1 This is a schematic diagram of the traditional magnetic recording method of a disk in the related art, such as Figure 1 As shown, the tracks of a traditional disk are separate tracks. The white box represents the read head width, and the black box represents the write head width. The write head width is larger than the read head width. Figure 2 This is a schematic diagram of the SMR disk magnetic recording method in the related art, such as Figure 2 As shown, an SMR disk consists of a conventional magnetic recording (CMR) perpendicular magnetic recording area and an SMR shingled magnetic recording area. The CMR area accounts for 1% of the total capacity of the SMR disk, while the SMR area accounts for 99% of the total capacity. An SMR disk divides the tracks into several bands, each of which is a continuous write area consisting of continuous tracks. Each band is a basic unit that requires sequential writes. A band is a physical concept on an SMR disk, and its corresponding logical concept is a zone, which is the sequential write area of ​​the SMR disk visible to upper-layer software.

[0070] Figure 3 This is a schematic diagram of the structure of the SMR disk in the related art. Figure 3 As shown, the tracks of an SMR disk are divided into multiple track groups (Band 1, Band 2, ..., Band N). Isolation zones are set between track groups to prevent interference. The outermost ring of the SMR disk contains a buffer zone composed of non-shingled tracks to cache requested random write operations. Each zone has a capacity of 256 megabytes. Only sequential append writes are supported within a zone; random writes are not supported. The write pointer must be reset to the start of the zone and then restarted. Each zone has a write pointer.

[0071] Based on this, the present invention provides a data writing method. Before writing the data to be stored, it is necessary to first determine whether the first end address is the second end address of the last track in the target area to which the second track belongs. When it is determined that the first end address is not the second end address, it is necessary to first map the first data to the first mapping track and then write the data to be stored. Therefore, when writing the data to be stored, the data in the next track of the currently written track will not be overwritten, thereby realizing random writing of data and ensuring that the data in other tracks will not be affected after random writing.

[0072] The following combination Figure 4-Figure 20 The data writing method of the present invention is described. The execution subject of the data writing method can be an electronic device such as a computer, a server, or a server cluster, or a data writing device provided in the electronic device. The data writing device can be implemented by software, hardware, or a combination of both.

[0073] Figure 4 This is one of the flow charts of the data writing method provided by the embodiment of the present invention. Figure 4 As shown, the data writing method includes the following steps:

[0074] Step 401: Upon receiving a write instruction for data to be stored, determine a start address of the data to be stored and a first end address of the data to be stored in an SMR disk.

[0075] in, Figure 5 FIG. 1 is a schematic diagram of partitioning of an SMR disk provided by an embodiment of the present invention. Figure 5 As shown, the SMR disk consists of a traditional CMR perpendicular magnetic recording area and an SMR shingled magnetic recording area; the CMR area header has a 1G (gigabyte) disk data format (DDF) area, and the DDF area contains sections such as a shared space management area, a bad block mapping data area, and a shared space data area, which are used to record relevant information of the SMR disk; Area A of the CMR area is the logical resource metadata area; Area B of the SMR area is the logical area, which is an area provided to the outside world for creating logical resources, and its size is a% of the total capacity of the entire SMR disk; Area C of the SMR area is a reserved mapping area, which can provide a space mapping area, and its size is b% of the total capacity of the entire SMR disk. CMR area = area A + DDF area = 1% of the total capacity of the SMR disk, SMR area = area B + area C = total capacity of the SMR disk * (a + b) = 99% of the total capacity of the SMR disk; Area B is the area for creating logical resources, and all tracks are available. Area C is the area that provides space mapping. In order to enable random writing in Area C, not all tracks in each zone of Area C are available. Instead, every other track is available until the next track. Figure 6Schematic diagram of the magnetic track in the C zone provided by an embodiment of the present invention, Figure 6 As shown, an area in zone C includes track N, track N+1, track N+2 and track N+3, so track N is available, track N+1 is unavailable, and track N+2 is available, so that the tracks in zone C can be randomly written without affecting the data on other tracks.

[0076] For example, when a write instruction for data to be stored is received, the upper-layer software determines the starting address of the data to be stored in the SMR disk, determines the occupied space of the data to be stored, and determines the first ending address of the data to be stored based on the starting address and the occupied space of the data to be stored.

[0077] Specifically, taking the capacity of each zone in an SMR disk as 256MB as an example, since a zone is composed of continuous centripetal tracks on the same disk, the tracks within the zone are not of equal length and can be regarded as a regular arithmetic progression; Figure 7 It is a structural diagram of a region provided by the present invention, such as Figure 7 As shown, the starting address of the first track in a zone is LBA0, the starting address of the second track is LBA1, the first ending address of the first track is also the starting address of the second track, and so on; the number of tracks in a zone is X, assuming that the writable capacity is Y (M) for each additional bit of the LBA address, then the tolerance d can be expressed by the following formula (1), and the calculation of the total capacity in a zone can be expressed by the following formula (2):

[0078] d=[(LBA2-LBA1)-(LBA1-LBA0)]*Y=(LBA2-2LBA1+LBA0)*Y (1)

[0079]

[0080] The value of Y can be obtained from formula (1) and formula (2), and the value of Y can be expressed by the following formula (3):

[0081]

[0082] Assuming that the starting address of the data to be stored is represented by LBA N, and the space occupied by the data to be stored is B megabytes, the first ending address LBA(N+M) of the data to be stored can be represented by the following formula (4):

[0083]

[0084] When the first end address LBA(N+M) of the data to be stored is calculated, the second track to which the first end address of the data to be stored belongs can be determined based on the correspondence between the address and the track, and the first track to which the starting address of the data to be stored belongs can also be determined. Figure 8 Schematic diagram of a magnetic track provided by an embodiment of the present invention, such as Figure 8 As shown, the second track to which the first end address of the data to be stored belongs is track m, and the next track of the second track is track m+1.

[0085] Step 402: When it is determined that there is no mapped track between the first track to which the start address belongs and the second track to which the first end address belongs, determine whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area is an area in the resource area of ​​the SMR disk.

[0086] For example, when determining the first track to which the starting address of the data to be stored belongs and the second track to which the first ending address belongs, it is necessary to determine whether there is a mapped track between the first track and the second track. When there is no mapped track between the first track and the second track, it means that the writing of the data to be stored is the first writing or no mapping operation occurred between the first track and the second track during the previous writing. At this time, it is determined whether the first ending address is the second ending address of the last track in the target area to which the second track belongs.

[0087] Step 403: When it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, determine the first mapping track corresponding to the first data in the mapping area of ​​the SMR disk.

[0088] Wherein, when the second track is the last track, the first target track includes the last track; when the second track is not the last track, the first target track includes the next track of the second track.

[0089] Optionally, when it is determined that there is a free track in the mapping area whose writing space is greater than or equal to the occupied space of the first data, the first mapping track is determined based on the free track.

[0090] For example, when it is determined that the first end address is not the second end address of the last track in the target area to which the second track belongs, in order to avoid overwriting the data of the next track when writing the data to be stored, it is necessary to map the first data between the first end address in the second track and the end address of the first target track in the target area.

[0091] Specifically, when the second track is not the last track in the target area, it is necessary to query the DDF area of ​​the SMR disk, and query the usage of the addresses between the first end address in the second track and the end address of the next track m+1 in the DDF area. If the addresses between the first end address in the second track and the end address of the next track m+1 are not used, the data to be stored is written directly based on the start address and the first end address of the data to be stored; when the addresses between the first end address in the second track and the end address of the next track m+1 are used, the first data stored between the first end address in the second track and the end address of the next track m+1 needs to be mapped out. First, it is necessary to determine whether there is a qualified free track in the mapping area C to provide mapping, that is, calculate the occupied space of the first data. If the first end address is LBA(N+M) and the second end address is LBA(m+2), then the occupied space of the first data = [LBA(m+2)-LBA(N+M)]*Y.

[0092] If the second track is the last track in the target area, the usage of the addresses between the first end address and the second end address of the last track in the DDF area is queried. If the addresses between the first end address and the second end address of the last track in the last track are not used, the data to be stored is written directly based on the start address and the first end address of the data to be stored. If the addresses between the first end address and the second end address of the last track in the last track are used, the first data stored between the first end address and the second end address of the last track in the last track needs to be mapped out. That is, the occupied space of the first data is calculated. If the first end address is LBA(N+M) and the second end address is LBA(m), the occupied space of the first data = [LBA(m)-LBA(N+M)]*Y.

[0093] Then, a query is made in area C to see whether there are available free tracks, and the track capacity of the free tracks is greater than or equal to the space occupied by the first data. If a free track greater than or equal to the space occupied by the first data is found in area C, the free track is determined as the first mapping track; if a free track greater than or equal to the space occupied by the first data is not found in area C, it means that there are no free tracks in area C that can provide mapping. At this time, a write failure message is reported to the client, and the writing of the data to be stored is terminated.

[0094] It should be noted that when a free track with a space greater than or equal to the space occupied by the first data is found in area C, priority is given to searching for a free track with a space equal to the space occupied by the first data. If a free track with a space equal to the space occupied by the first data is not found, a free track with a space greater than the space occupied by the first data is searched to improve the utilization rate of the tracks in area C.

[0095] It should be noted that, when the second track is determined to be the last track in the target area, since different areas are isolated from each other, when writing the data to be stored, it will not affect the data in the next area of ​​the disk, so there is no need for a mapping operation. The data to be stored is written directly based on the starting address of the data to be stored and the first ending address. Specifically, when writing the data to be stored, it is necessary to first determine whether the starting address of the data to be stored and the address where the write pointer is located are consistent. When it is determined that the starting address of the data to be stored and the address where the write pointer is located are consistent, the data to be stored is written directly from the starting address of the data to be stored; when it is determined that the starting address of the data to be stored and the address where the write pointer is located are inconsistent, the address where the write pointer is located is moved to the starting address of the data to be stored, and then the data to be stored is written from the starting address of the data to be stored.

[0096] Step 404: Read the first data and map the first data to the first mapping track.

[0097] For example, when determining the first mapping track corresponding to the first data in the mapping area of ​​the SMR disk, a mapping relationship is established between the mapping track to which the first data belongs and the first mapping track, that is, when the second track is the last track, a mapping relationship is established between the last track and the first mapping track; when the second track is not the last track, a mapping relationship is established between the second track and the next track and the first mapping track, and the mapping relationship is first recorded in the memory, and then the first data is read and mapped to the first mapping track.

[0098] Step 405: Write the data to be stored based on the start address and the first end address.

[0099] Optionally, when the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address; when the starting address is the same as the address where the write pointer is located, the data to be stored is written directly starting from the starting address, that is, the present invention supports the rollback of the write pointer and can move the write pointer to any starting address that needs to be written.

[0100] For example, after writing the first data to the first mapping track, the track usage of logical area B and mapping area C is first updated to the memory. Then, after the data to be stored is written based on the start address and the first end address, the mapping relationship between the mapping track to which the first data belongs and the first mapping track, as well as the track usage of logical area B and mapping area C, are stored in the DDF area of ​​the SMR disk to prevent the mapping relationship and the track usage of logical area B and mapping area C from being lost after a power outage. After the device is powered on, the memory can read the mapping relationship and the track usage of logical area B and mapping area C from the DDF area. In addition, when the first data needs to be read later, it can be read from the first mapping track, thereby completing a write operation. Figure 9 This is one of the schematic diagrams of data writing provided by an embodiment of the present invention, such as Figure 9 As shown, taking the second track as not being the last track of the target area as an example, the second track to which the first end address of the data to be stored belongs is m, and the next track of the second track is m+1, the first data between the first end address of the second track m and the end address of the next track m+1 is mapped to the first mapping track 901 in area C. Figure 9 The arrows are used to indicate the mapping relationship between the mapping tracks m and m+1 to which the first data belongs and the first mapping track 901 .

[0101] The data writing method provided by the present invention determines the starting address and first ending address of the data to be stored in the SMR disk upon receiving a write instruction for data to be stored. When it is determined that there is no mapped track between the first track to which the starting address belongs and the second track to which the first ending address belongs, it is determined whether the first ending address is the second ending address of the last track in the target area to which the second track belongs. When it is determined that the first ending address is not the second ending address and first data is stored between the first ending address in the second track and the ending address of the first target track in the target area, the first data is mapped to the first mapped track, and then the data to be stored is written based on the starting address and the first ending address. Before writing the data to be stored, the present invention needs to first determine whether the first ending address is the second ending address of the last track in the target area to which the second track belongs. When it is determined that the first ending address is not the second ending address, the first data needs to be mapped to the first mapped track before writing the data to be stored. Therefore, when writing the data to be stored, the data in the next track of the currently written track will not be overwritten, thereby achieving random writing of data and ensuring that the random writing does not affect the data in other tracks.

[0102] In one embodiment, Figure 10 This is a second flow chart of the data writing method provided by an embodiment of the present invention. Figure 10 As shown, the data writing method further includes the following steps:

[0103] Step 406: When it is determined that a mapped track exists between the first track and the second track, write the data to be stored based on the positional relationship, the start address and the first end address; the positional relationship is the positional relationship between the first track, the second track and the second target track; the second target track includes the mapped track and / or the mapped track corresponding to the mapped track.

[0104] For example, when it is determined that there is a mapped track between the first track and the second track, it is necessary to first determine the positional relationship between the first track, the second track, the mapped track and the mapped track, and based on the positional relationship, determine whether the current writing of the data to be stored will affect the data already stored, determine which data updates are involved in the current writing of the data to be stored, and the updates include overwriting or deletion, and write the data to be stored based on the positional relationship, so that the capacity of area C can be released as much as possible, and the capacity of area B can be used first.

[0105] In this embodiment, when it is determined that there is a mapped track between the first track and the second track, the positional relationship between the first track, the second track, the mapped track and the mapping track is first determined, and the data to be stored is written based on the positional relationship, the starting address and the first ending address, avoiding updating other stored data when writing the data to be stored, thereby improving the accuracy of data writing.

[0106] In one embodiment, Figure 11 This is a third flow chart of the data writing method provided by an embodiment of the present invention, such as Figure 11 As shown, the above step 406 can be specifically implemented by the following steps:

[0107] Step 4061: When the positional relationship includes the first track being before the mapped track and the second track being a mapping track corresponding to the mapped track, write the data to be stored based on the start address and the first end address.

[0108] For example, in a case where the positional relationship includes the first track preceding the mapped track and the second track being the mapped track corresponding to the mapped track, since writing the data to be stored does not affect other stored data, the data to be stored can be written directly based on the starting address and the first ending address. Specifically, if the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address. If the starting address is the same as the address where the write pointer is located, the data to be stored is written directly starting from the starting address. After the data to be stored is written, the track usage status of the resource area and the track usage status of the mapping area are both stored in the disk data format area of ​​the SMR disk. Figure 12 This is the second schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 12 As shown, a mapping relationship is established between the mapped track 1201 and the mapping track 1202. The first track 1203 to which the starting address of the data to be stored belongs is before the mapped track 1201, and the second track to which the first ending address of the data to be stored belongs is the mapping track 1202. The data to be stored is written directly based on the starting address and the first ending address.

[0109] In this embodiment, when the positional relationship includes the first track being before the mapped track and the second track being the mapped track corresponding to the mapped track, since writing the data to be stored does not affect other stored data, the data to be stored can be written directly based on the starting address and the first ending address to ensure the accuracy of the written data.

[0110] In one embodiment, Figure 13 This is a fourth flow chart of the data writing method provided by an embodiment of the present invention, such as Figure 13 As shown, the above step 406 can be specifically implemented by the following steps:

[0111] Step 4062: When the positional relationship includes that the first track and the second track are both mapping tracks corresponding to the mapped track, write the data to be stored into the mapping track starting from the starting address.

[0112] For example, when the positional relationship includes the first track and the second track being mapped tracks corresponding to the mapped track, since writing the data to be stored does not affect other stored data, the data to be stored can be written directly based on the starting address and the first ending address. Specifically, when the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address. When the starting address and the address where the write pointer is located are the same, the data to be stored is written directly starting from the starting address. After the data to be stored is written, the track usage status of the resource area and the track usage status of the mapping area are both stored in the disk data format area of ​​the SMR disk. Figure 14 This is the third schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 14 As shown, a mapping relationship is established between the mapped track 1201 and the mapping track 1202. The first track to which the starting address of the data to be stored belongs and the second track to which the first ending address belongs are both mapped tracks 1202. The data to be stored is written directly based on the starting address and the first ending address.

[0113] In this embodiment, when the positional relationship includes the first track and the second track being mapped tracks corresponding to the mapped track, since writing the data to be stored does not affect other stored data, the data to be stored can be written directly based on the starting address and the first ending address to ensure the accuracy of the written data.

[0114] In one embodiment, Figure 15 This is a fifth flow chart of the data writing method provided by an embodiment of the present invention, such as Figure 15 As shown, the above step 406 can be specifically implemented by the following steps:

[0115] Step 4603: When the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, delete the first mapping relationship between the mapped track and the mapping track, and return to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0116] For example, in the case where the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, since the data in the mapped track is included in the range of this write, the data in the mapped track is regarded as data that can be deleted, so there is no need to map it again, so the first mapping relationship between the mapped track and the mapping track can be deleted, and the deletion information of the first mapping relationship is first recorded in the memory, and then return to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs in step 402 to complete the writing of the data to be stored; and in the process of writing the data to be stored, after the writing of the mapped tracks involved is completed, it is necessary to promptly delete the first mapping relationship in the disk data format area and the data migration module, and update the track usage of the mapping area in the disk data format area to prevent the first mapping relationship from being lost due to power failure, resulting in the newly written data being unable to be read on the mapped track; and after the writing of the data to be stored is completed, the track usage of the resource area in the disk data format area is promptly updated. Figure 16 This is a fourth schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 16 As shown, a mapping relationship is established between the mapped track 1201 and the mapping track 1202. The first track 1203 to which the starting address of the data to be stored belongs is before the mapped track 1201, and the second track 1204 to which the first ending address of the data to be stored belongs is after the mapped track 1201. Therefore, the mapping relationship is canceled first, and then the data to be stored is written according to steps 402 to 405.

[0117] In this embodiment, when the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, since the data in the mapped track is included in the range of this write, the data in the mapped track is regarded as data that can be deleted, so the first mapping relationship between the mapped track and the mapping track can be deleted first, and then the write operation of the data to be stored is performed to ensure the successful writing of the data to be stored.

[0118] In one embodiment, Figure 17 This is a sixth flow chart of the data writing method provided by an embodiment of the present invention, such as Figure 17 As shown, the above step 406 can be specifically implemented by the following steps:

[0119] Step 4064: When the positional relationship includes the first track as the mapping track, the second track is after the mapped track, and it is determined that a new mapping relationship needs to be established when writing the data to be stored, read the data in the new mapped track included in the new mapping relationship, and write the data in the new mapped track to the new mapping track included in the new mapping relationship, read the second data between the starting address of the mapping track and the starting address of the data to be stored, and write the second data back to the mapped track.

[0120] Step 4065: Delete the first mapping relationship between the mapped track and the mapping track, and return to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0121] For example, in the case where the position relationship includes the first track being a mapping track and the second track being after the mapped track, it is necessary to first determine based on the above steps 402 to 404 whether a new mapping relationship needs to be established when writing the data to be stored. When it is determined that a new mapping relationship needs to be established, the data in the new mapped track included in the new mapping relationship is read, and the data in the new mapped track is written to the new mapping track included in the new mapping relationship. After the writing is completed, the new mapping relationship, the track usage of the resource area, and the track usage of the mapping area are updated in the disk data format area. Since the next track of the mapped track also needs to be written this time, there is no need to map the next track of the mapped track. The mapped The reason is to prevent the writing of this track from affecting the next track, so the fixed second data between the starting address of the mapped track and the starting address of the data to be stored is read out and rewritten into the mapped track, and the deletion information of the first mapping relationship between the mapped track and the mapping track is stored in the memory. At this time, the starting address returns to the mapped track, and the data to be stored can be written based on the above steps 402 to 405. After the data to be stored is written to the mapped track, the first mapping relationship is deleted in the disk data format area and the data migration module, and the track usage of the mapping area is updated in the disk data format area; after the writing of the data to be stored is completed, the track usage of the resource area in the disk data format area is updated in time. Figure 18 This is a fifth schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 18 As shown, a mapping relationship is established between the mapped track 1201 and the mapping track 1202. The first track to which the starting address of the data to be stored belongs is the mapping track 1202, and the second track 1204 to which the first ending address of the data to be stored belongs is after the mapped track 1201. The fixed second data between the starting address of the mapping track and the starting address of the data to be stored is first read out and rewritten into the mapped track, and the mapping relationship is canceled. Then, the data to be stored is written according to steps 402 to 405.

[0122] In this embodiment, when the positional relationship includes the first track being a mapping track and the second track being after the mapped track, and it is determined that a new mapping relationship needs to be established, when reading the data in the new mapped track included in the new mapping relationship, the data in the new mapped track is first written to the new mapping track included in the new mapping relationship. After the writing is completed, the fixed second data between the starting address of the mapping track and the starting address of the data to be stored is read out and rewritten to the mapped track, thereby realizing the write back of the data in the mapping track, releasing the track capacity of zone C, ensuring that other data can be mapped and written normally, and maximizing the space utilization of zone C of the SMR disk.

[0123] In one embodiment, the data writing method further includes the following steps:

[0124] After the data in the mapped track included in the target mapping relationship is written to the mapping track included in the target mapping relationship, the target mapping relationship, the track usage of the resource area and the track usage of the mapping area are all stored in the disk data format area of ​​the SMR disk, and the target mapping relationship is stored in the data migration module (Data Migration, DM); the target mapping relationship includes the first mapping relationship, the new mapping relationship, or the second mapping relationship between the track to which the first data belongs and the first mapping track.

[0125] During the writing process of the data to be stored, if data is written in the mapped track, after the data in the data to be stored is written to the mapped track, the track usage status of the mapping area is updated to the disk data format area, and the first mapping relationship is deleted in the disk data format area and the data migration module.

[0126] After the data to be stored is written, the track usage status of the resource area is updated to the disk data format area.

[0127] It should be noted that the updating of the data stored in the disk data format area and the updating of the data stored in the data migration module have been described in the above embodiments, and the present invention will not elaborate on them here.

[0128] In this embodiment, the mapping relationship, the track usage of the resource area, and the track usage of the mapping area are all stored in the DDF area to prevent loss during power failure; and the cancellation or establishment of the mapping relationship is stored in the data migration module, so that the data migration module can determine whether there are multiple consecutive tracks with established mapping relationships based on the established mapping relationships.

[0129] In one embodiment, the data writing method further includes the following steps:

[0130] When the data migration module determines, based on the currently stored mapping relationships, that there are multiple consecutive mapped tracks in the same area and all addresses of the outermost mapped track among the multiple consecutive mapped tracks are mapped, traversal begins from the innermost mapped track among the multiple consecutive mapped tracks. When it is determined that neither the currently traversed mapped track nor the mapped track corresponding to the currently traversed mapped track currently performs a write operation, and the next track of the currently traversed mapped track is a mapped track, the data in the mapped track corresponding to the currently traversed mapped track is written back to the currently traversed mapped track, and the third mapping relationship between the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track is deleted.

[0131] The track usage status of the currently traversed mapped track and the track usage status of the mapped track corresponding to the currently traversed mapped track are stored in the disk data format area, and the third mapping relationship is deleted in the disk data format area and the data migration module until the traversal is completed.

[0132] For example, the data migration module performs background patrol, sorts each track based on the starting address and the first ending address of the track corresponding to each mapping relationship according to the stored mapping relationships, and determines whether there are multiple consecutive mapped tracks in the same area, that is, whether there are multiple consecutive tracks with established mapping relationships. When it is determined that there are multiple consecutive mapped tracks in the same area, and all addresses of the outermost mapped tracks among the multiple consecutive mapped tracks are mapped, it is necessary to start traversing from the innermost mapped track among the multiple consecutive mapped tracks, and write back the data in the mapping track corresponding to the currently traversed mapped track to the currently traversed mapped track. Before writing back, it is necessary to determine whether the currently traversed mapped track involved in the write-back and the mapping track corresponding to the currently traversed mapped track have not currently performed a write operation, and it is necessary to determine whether the currently traversed mapped track Whether the next track of the projected track is the mapped track. When it is determined that the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track involved in the write-back are not currently performing a write operation, and the next track of the currently traversed mapped track is the mapped track, it means that the write-back operation will not affect the data being written, so the data in the mapped track corresponding to the currently traversed mapped track can be directly written back to the currently traversed mapped track. After the write-back is completed, the third mapping relationship between the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track is deleted, and the track usage of the currently traversed mapped track and the track usage of the mapped track corresponding to the currently traversed mapped track are stored in the DDF area, and the deletion information of the third mapping relationship is sent to the DDF area and the data migration module for recording until the traversal is completed. In addition, when the currently traversed mapped track is the last track in the area, the data in the mapped track corresponding to the currently traversed mapped track is written back to the currently traversed mapped track; when the currently traversed mapped track is not the last track in the area, and the next track of the currently traversed mapped track is not the mapped track, that is, no mapping relationship is established for the next track, the write-back operation is not performed.

[0133] Figure 19 This is the sixth schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 19 As shown, for example, when data is written for the first time, the track where the ending LBA address is located is m1+1, and at this time, it is necessary to map the next track m+1 of the track m1+1; when data is written for the second time, the track where the ending LBA1 address is located is m2+1, and at this time, it is necessary to map the next track m1+1 of the track m2+1, so that a mapping relationship is established between the continuous tracks m+1 and m1+1. Figure 20 This is the seventh schematic diagram of data writing provided by an embodiment of the present invention, such as Figure 20As shown, the data in the mapping track corresponding to the innermost mapped track m1+1 is written back to the innermost mapped track m1+1.

[0134] In addition, when it is determined that the currently traversed mapped track involved in the write-back and / or the mapped track corresponding to the currently traversed mapped track is currently performing a write operation, the current write-back task is skipped and other eligible tracks that can be written back are continuously inspected.

[0135] In this embodiment, write-back is performed starting from the innermost mapped track among the multiple consecutive mapped tracks. This will not affect the mapping of other tracks in the multiple consecutive mapped tracks, thereby releasing the capacity of zone C to the maximum extent and improving the capacity utilization of zone C.

[0136] It should be noted that whenever a mapping relationship is created or canceled, or the track usage of the logical area and the track usage of the mapping area change, they need to be recorded and updated in the DDF area to prevent power loss. After the device is restarted, the data migration module reads the relevant information from the DDF area again.

[0137] It should be noted that the logical area B of the SMR area accounts for a% of the total capacity of the SMR disk, and the mapped area C of the SMR area accounts for b% of the total capacity of the SMR disk; this proportion can be adjusted according to the actual business scenario; when facing a business scenario with small-block and frequent data writes, for example, only one track is randomly written, and one track needs to be mapped. At this time, the capacity proportion of area C can be appropriately increased, because there may be more tracks mapped and the required capacity is relatively large; when facing a business scenario with large-block and infrequent data writes, for example, multiple tracks are randomly written, and only one track needs to be mapped. At this time, the capacity proportion of area C can be appropriately reduced, because there may be fewer tracks mapped and the required capacity is also relatively small.

[0138] The data writing device provided by the present invention is described below. The data writing device described below and the data writing method described above can be referenced to each other.

[0139] Figure 21 FIG. 1 is a schematic diagram of the structure of a data writing device provided by an embodiment of the present invention. Figure 21 As shown, the data writing device 2100 includes a first determining unit 2101, a second determining unit 2102, a third determining unit 2103, a mapping unit 2104 and a first writing unit 2105; wherein:

[0140] A first determining unit 2101 is configured to determine, in the SMR disk, a start address of the data to be stored and a first end address of the data to be stored when a write instruction for the data to be stored is received;

[0141] The second determining unit 2102 is configured to, when it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determine whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area being an area in the resource area of ​​the SMR disk;

[0142] The third determining unit 2103 is configured to, if it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, determine, in the mapping area of ​​the SMR disk, a first mapping track corresponding to the first data; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0143] A mapping unit 2104 is configured to read the first data and map the first data to the first mapping track;

[0144] The first writing unit 2105 is configured to write the data to be stored based on the start address and the first end address.

[0145] The data writing device provided by the present invention, upon receiving a write instruction for data to be stored, determines the starting address and first ending address of the data to be stored in the SMR disk, and upon determining that there is no mapped track between the first track to which the starting address belongs and the second track to which the first ending address belongs, determines whether the first ending address is the second ending address of the last track in the target area to which the second track belongs, and upon determining that the first ending address is not the second ending address and first data is stored between the first ending address in the second track and the ending address of the first target track in the target area, maps the first data to the first mapped track, and then writes the data to be stored based on the starting address and the first ending address. Before writing the data to be stored, the present invention needs to first determine whether the first ending address is the second ending address of the last track in the target area to which the second track belongs, and upon determining that the first ending address is not the second ending address, maps the first data to the first mapped track before writing the data to be stored. Thus, when writing the data to be stored, data in the next track of the currently written track will not be overwritten, thereby achieving random writing of data and ensuring that data in other tracks is not affected after random writing.

[0146] Based on any of the above embodiments, the data writing device 2100 further includes:

[0147] A second writing unit is configured to write the data to be stored based on a positional relationship, the start address, and the first end address when it is determined that a mapped track exists between the first track and the second track; the positional relationship is a positional relationship between the first track, the second track, and a second target track; and the second target track includes the mapped track and / or a mapping track corresponding to the mapped track.

[0148] Based on any of the above embodiments, the second writing unit is specifically configured to:

[0149] In a case where the positional relationship includes the first track being before the mapped track and the second track being a mapping track corresponding to the mapped track, the data to be stored is written based on the start address and the first end address.

[0150] Based on any of the above embodiments, the second writing unit is specifically configured to:

[0151] In a case where the positional relationship includes the first track and the second track being mapping tracks corresponding to the mapped track, the data to be stored is written into the mapping track starting from the start address.

[0152] Based on any of the above embodiments, the second writing unit is specifically configured to:

[0153] In the case where the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, the first mapping relationship between the mapped track and the mapping track is deleted, and the step returns to determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0154] Based on any of the above embodiments, the second writing unit is specifically configured to:

[0155] If the positional relationship includes the first track being the mapping track and the second track being after the mapped track, and it is determined that a new mapping relationship needs to be established when writing the data to be stored, reading data from a new mapped track included in the new mapping relationship, and writing the data from the new mapped track to a new mapping track included in the new mapping relationship;

[0156] Reading second data between the starting address of the mapped track and the starting address of the data to be stored, and writing the second data back to the mapped track;

[0157] The first mapping relationship between the mapped track and the mapping track is deleted, and the process returns to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

[0158] Based on any of the above embodiments, the data writing device 2100 further includes:

[0159] a first updating unit configured to, after writing data in a mapped track included in a target mapping relationship to a mapping track included in the target mapping relationship, store the target mapping relationship, track usage information of the resource area, and track usage information of the mapping area in a disk data format area of ​​the SMR disk, and store the target mapping relationship in a data migration module; the target mapping relationship includes a first mapping relationship, a new mapping relationship, or a second mapping relationship between the track to which the first data belongs and the first mapping track;

[0160] The first updating unit is further configured to, in the process of writing the data to be stored, if data is written in the mapped track, update the track usage of the mapping area into the disk data format area after writing the data in the data to be stored to the mapped track, and delete the first mapping relationship in the disk data format area and the data migration module;

[0161] The first updating unit is further configured to update the track usage status of the resource area to the disk data format area after the writing of the data to be stored is completed.

[0162] Based on any of the above embodiments, the data writing device 2100 further includes:

[0163] a write-back unit for, when it is determined by the data migration module based on the currently stored mapping relationships that there are multiple continuous mapped tracks in the same area and all addresses of the outermost mapped track among the multiple continuous mapped tracks are mapped, starting traversal from the innermost mapped track among the multiple continuous mapped tracks, and when it is determined that neither the currently traversed mapped track nor the mapped track corresponding to the currently traversed mapped track is currently performing a write operation, and when the next track of the currently traversed mapped track is a mapped track, writing back the data in the mapped track corresponding to the currently traversed mapped track to the currently traversed mapped track, and deleting the third mapping relationship between the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track;

[0164] The second update unit is used to store the track usage status of the currently traversed mapped track and the track usage status of the mapped track corresponding to the currently traversed mapped track in the disk data format area, and delete the third mapping relationship in the disk data format area and the data migration module until the traversal is completed.

[0165] Based on any of the foregoing embodiments, the third determining unit 2103 is specifically configured to:

[0166] In a case where it is determined that there is a free track in the mapping area whose writing space is greater than or equal to the occupied space of the first data, the first mapping track is determined based on the free track.

[0167] Based on any of the above embodiments, the first writing unit 2105 is specifically configured to:

[0168] In the case that the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address.

[0169] Figure 22 FIG is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 22 As shown, the electronic device may include: a processor (processor) 2210, a communication interface (Communications Interface) 2220, a memory (memory) 2230 and a communication bus 2240, wherein the processor 2210, the communication interface 2220, and the memory 2230 communicate with each other via the communication bus 2240. The processor 2210 may call the logic instructions in the memory 2230 to execute the data writing method, which includes:

[0170] Upon receiving a write instruction for data to be stored, determining a start address of the data to be stored and a first end address of the data to be stored in the SMR disk;

[0171] If it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determining whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area is an area in the resource area of ​​the SMR disk;

[0172] If it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, a first mapping track corresponding to the first data is determined in the mapping area of ​​the SMR disk; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0173] Reading the first data, and mapping the first data to the first mapping track;

[0174] The data to be stored is written based on the start address and the first end address.

[0175] In addition, the logic instructions in the above-mentioned memory 2230 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0176] On the other hand, the present invention further provides a computer program product, comprising a computer program. The computer program may be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the data writing method provided by each of the above methods, the method comprising:

[0177] Upon receiving a write instruction for data to be stored, determining a start address of the data to be stored and a first end address of the data to be stored in the SMR disk;

[0178] If it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determining whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area is an area in the resource area of ​​the SMR disk;

[0179] If it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, a first mapping track corresponding to the first data is determined in the mapping area of ​​the SMR disk; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0180] Reading the first data, and mapping the first data to the first mapping track;

[0181] The data to be stored is written based on the start address and the first end address.

[0182] In another aspect, the present invention further 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 data writing method provided by the above methods, the method comprising:

[0183] Upon receiving a write instruction for data to be stored, determining a start address of the data to be stored and a first end address of the data to be stored in the SMR disk;

[0184] If it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determining whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area is an area in the resource area of ​​the SMR disk;

[0185] If it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, a first mapping track corresponding to the first data is determined in the mapping area of ​​the SMR disk; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track;

[0186] Reading the first data, and mapping the first data to the first mapping track;

[0187] The data to be stored is written based on the start address and the first end address.

[0188] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0189] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A data writing method, characterized in that: include: Upon receiving a write instruction for data to be stored, determining a start address of the data to be stored and a first end address of the data to be stored in the SMR disk; If it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determining whether the first end address is the second end address of the last track in the target area to which the second track belongs; the target area is an area in the resource area of ​​the SMR disk; If it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, a first mapping track corresponding to the first data is determined in the mapping area of ​​the SMR disk; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track; Reading the first data, and mapping the first data to the first mapping track; The data to be stored is written based on the start address and the first end address.

2. The data writing method according to claim 1, wherein: The method further comprises: When it is determined that there is a mapped track between the first track and the second track, the data to be stored is written based on the positional relationship, the start address and the first end address; the positional relationship is the positional relationship between the first track, the second track and the second target track; the second target track includes the mapped track and / or the mapping track corresponding to the mapped track.

3. The data writing method according to claim 2, wherein: The step of writing the data to be stored based on the position relationship, the start address, and the first end address includes: In a case where the positional relationship includes the first track being before the mapped track and the second track being a mapping track corresponding to the mapped track, the data to be stored is written based on the start address and the first end address.

4. The data writing method according to claim 2, wherein: The step of writing the data to be stored based on the position relationship, the start address, and the first end address includes: In a case where the positional relationship includes the first track and the second track being mapping tracks corresponding to the mapped track, the data to be stored is written into the mapping track starting from the start address.

5. The data writing method according to claim 2, wherein: The step of writing the data to be stored based on the position relationship, the start address, and the first end address includes: In the case where the positional relationship includes the first track being before the mapped track and the second track being after the mapped track, the first mapping relationship between the mapped track and the mapping track is deleted, and the step returns to determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

6. The data writing method according to claim 2, wherein: The step of writing the data to be stored based on the position relationship, the start address, and the first end address includes: If the positional relationship includes the first track being the mapping track and the second track being after the mapped track, and it is determined that a new mapping relationship needs to be established when writing the data to be stored, reading data from a new mapped track included in the new mapping relationship, and writing the data from the new mapped track to a new mapping track included in the new mapping relationship; Reading second data between the starting address of the mapped track and the starting address of the data to be stored, and writing the second data back to the mapped track; The first mapping relationship between the mapped track and the mapping track is deleted, and the process returns to the step of determining whether the first end address is the second end address of the last track in the target area to which the second track belongs.

7. The data writing method according to claim 5 or 6, characterized in that: The method further comprises: After the data in the mapped track included in the target mapping relationship is written to the mapping track included in the target mapping relationship, the target mapping relationship, the track usage of the resource area, and the track usage of the mapping area are all stored in the disk data format area of ​​the SMR disk, and the target mapping relationship is stored in the data migration module; the target mapping relationship includes the first mapping relationship, the new mapping relationship, or a second mapping relationship between the track to which the first data belongs and the first mapping track; In the process of writing the data to be stored, if data is written in the mapped track, after writing the data in the data to be stored to the mapped track, updating the track usage of the mapping area into the disk data format area, and deleting the first mapping relationship in the disk data format area and the data migration module; After the data to be stored is written, the track usage status of the resource area is updated to the disk data format area.

8. The data writing method according to claim 7, wherein: The method further comprises: When it is determined by the data migration module based on the currently stored mapping relationships that there are multiple continuous mapped tracks in the same area and all addresses of the outermost mapped track among the multiple continuous mapped tracks are mapped, traversal begins from the innermost mapped track among the multiple continuous mapped tracks, and when it is determined that neither the currently traversed mapped track nor the mapped track corresponding to the currently traversed mapped track is currently performing a write operation, and when the next track of the currently traversed mapped track is a mapped track, data in the mapped track corresponding to the currently traversed mapped track is written back to the currently traversed mapped track, and a third mapping relationship between the currently traversed mapped track and the mapped track corresponding to the currently traversed mapped track is deleted; The track usage status of the currently traversed mapped track and the track usage status of the mapped track corresponding to the currently traversed mapped track are stored in the disk data format area, and the third mapping relationship is deleted in the disk data format area and the data migration module until the traversal is completed.

9. The data writing method according to any one of claims 1 to 6, characterized in that: The determining, in the mapping area of ​​the SMR disk, a first mapping track corresponding to the first data includes: In a case where it is determined that there is a free track in the mapping area whose writing space is greater than or equal to the occupied space of the first data, the first mapping track is determined based on the free track.

10. The data writing method according to any one of claims 1 to 6, characterized in that: Writing the data to be stored based on the start address and the first end address includes: In the case that the starting address is different from the address where the write pointer is located, the address where the write pointer is located is moved to the starting address, and the data to be stored is written starting from the starting address.

11. A data writing device, characterized in that: include: a first determining unit, configured to determine, in the SMR disk, a start address of the data to be stored and a first end address of the data to be stored, upon receiving a write instruction for the data to be stored; a second determining unit configured to, when it is determined that no mapped track exists between the first track to which the start address belongs and the second track to which the first end address belongs, determine whether the first end address is the second end address of the last track in a target area to which the second track belongs; the target area being an area in a resource area of ​​the SMR disk; a third determining unit configured to, if it is determined that the first end address is not the second end address and first data is stored between the first end address in the second track and the end address of the first target track in the target area, determine, in the mapping area of ​​the SMR disk, a first mapping track corresponding to the first data; if the second track is the last track, the first target track includes the last track; if the second track is not the last track, the first target track includes the next track of the second track; a mapping unit, configured to read the first data and map the first data to the first mapping track; A first writing unit is configured to write the data to be stored based on the start address and the first end address.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data writing method according to any one of claims 1 to 10 is implemented.