CN114237489A - Method and device for writing logical resources into SMR disk, electronic equipment and storage medium - Google Patents

Method and device for writing logical resources into SMR disk, electronic equipment and storage medium Download PDF

Info

Publication number
CN114237489A
CN114237489A CN202010941460.XA CN202010941460A CN114237489A CN 114237489 A CN114237489 A CN 114237489A CN 202010941460 A CN202010941460 A CN 202010941460A CN 114237489 A CN114237489 A CN 114237489A
Authority
CN
China
Prior art keywords
storage area
area
resource
logical
storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010941460.XA
Other languages
Chinese (zh)
Other versions
CN114237489B (en
Inventor
张鹏国
张琅
程冰冰
张飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Uniview Technologies Co Ltd
Original Assignee
Zhejiang Uniview Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Uniview Technologies Co Ltd filed Critical Zhejiang Uniview Technologies Co Ltd
Priority to CN202010941460.XA priority Critical patent/CN114237489B/en
Publication of CN114237489A publication Critical patent/CN114237489A/en
Application granted granted Critical
Publication of CN114237489B publication Critical patent/CN114237489B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The application discloses a method and a device for writing logic resources into a Shingled Magnetic Recording (SMR) disk, wherein the SMR disk comprises an SMR area, the SMR area comprises a first storage area, the first storage area is used for writing a plurality of logic resources, the plurality of logic resources comprise a first logic resource and a second logic resource, and the first logic resource is any one of at least one logic resource with the writing sequence being before the second logic resource, and the method comprises the following steps: determining that the first logical resource is writing to the first storage area; writing the second logic resource to be stored into a second storage area, wherein the second storage area is: an area of the SMR disk other than the first storage area. By using the scheme provided by the application, when different clients store the logic resources in the same storage area, the clients can write the logic resources into the SMR disk in time without waiting.

Description

Method and device for writing logical resources into SMR disk, electronic equipment and storage medium
Technical Field
The present invention relates to the field of storage technologies, and in particular, to a method and an apparatus for writing a logical resource to an SMR disk, an electronic device, and a storage medium.
Background
A Shingled Magnetic Recording (SMR) disk, in which tracks on a disk partially overlap like tiles on a roof, can accommodate more tracks on the disk than a conventional disk, and thus has a higher storage density and a larger storage capacity of a single disk, and thus is increasingly used for data storage.
The SMR disk comprises an SMR area, the SMR area comprises a plurality of storage areas which are physically separated and do not influence each other, each storage area is used for writing in the logic resources created by the client, the track distribution mode of each storage area is a shingled mode, and only sequential writing is supported in the same storage area of the SMR area. In the prior art, when different clients write logical resources into the same storage area, each client needs to sequentially write the logical resources into an SMR disk in sequence.
However, if each client sequentially writes the logical resources into the SMR disk in sequence, the clients often need to wait, that is, after the previous client completes writing, the subsequent client can start writing, and if the previous client does not complete writing, the subsequent client starts writing, which may result in a failure in writing of the second client, so that each client may not write the logical resources into the SMR disk in time.
Disclosure of Invention
The present application is directed to a method, an apparatus, an electronic device, and a storage medium for writing logical resources into an SMR disk, so that when different clients write logical resources into the same storage area of an SMR area, each client can write the logical resources into the SMR disk at the same time, and thus each client stores the logical resources on the SMR disk in a more timely manner. The application adopts the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for writing a logical resource to an SMR disk, where the SMR disk includes an SMR area, and the SMR area includes a first storage area, where the first storage area is used for being written by a plurality of logical resources, the plurality of logical resources include a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource whose writing order is before the second logical resource, and the method includes:
determining that the first logical resource is writing to the first storage area;
writing the second logic resource to be stored into a second storage area, wherein the second storage area is: an area of the SMR disk other than the first storage area.
By using the scheme provided by the application, when the second client writes the second logic resource into the first storage area, if the first client is writing the first logic resource into the first storage area, the second logic resource created by the second client can be written into the second storage area first, so that the second client can write the logic resource into the SMR disk in time without waiting, and when different clients store the logic resource into the same storage area, each client can write the logic resource into the SMR disk at the same time.
Optionally, the method further includes:
determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource;
storing the second logical resource to the first storage area.
Determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated to the first logical resource created by the first client, which indicates that it is the turn for the first logical resource to be written in the first storage area, and at this time, storing the first logical resource stored in the second storage area in the first storage area, so that the first logical resource can be finally written in the storage space allocated to the first storage area.
Optionally, the determining that the position to be written in the first storage area is the same as the starting position of the storage space allocated to the second logic resource includes:
determining that a last logical resource completes writing into the first storage area, wherein an ending position of a storage space allocated for the last logical resource is the same as a starting position of a storage space allocated for the second logical resource;
and determining that the position to be written in the first storage area is the same as the starting position of the storage space allocated for the second logic resource.
By determining that the last logic resource is written into the first storage area, the position to be written into the first storage area can be quickly and conveniently determined to be the same as the initial position of the storage space allocated for the second logic resource.
Optionally, before the storing the second logical resource to the first storage area, the method further includes:
determining that the second logical resource completes writing to the second storage area.
When the second logic resource is written into the second storage area and then stored into the first storage area, the phenomena of data loss, interruption and the like when the second logic resource is written into the first storage area can be reduced.
Optionally, the method further includes:
establishing a mapping relation, wherein the mapping relation is used for indicating the storage position of the second logic resource in the second storage area and the storage space allocated for the second logic resource;
the storing the second logical resource to the first storage area includes:
and storing the logic resources stored in the storage position to the storage space according to the mapping relation.
After the mapping relationship is established, the embodiment can accurately migrate the logic resource according to the established mapping relationship.
Optionally, the determining that the first logical resource is writing to the first storage area includes:
determining that the starting position of the storage space allocated for the second logic resource is different from the position to be written in the first storage area;
determining that the second logic resource to be stored fails to be written into the first storage area;
determining that the first logical resource is writing to the first storage area.
If the second logic resource fails to be written into the first storage area, it is indicated that other logic resources are being written into the first storage area, and the first logic resource can be quickly and conveniently determined to be written into the first storage area by determining that the second logic resource to be stored fails to be written into the first storage area.
Optionally, the SMR disk further comprises: a conventional magnetic recording CMR region, said second storage area comprising: an area in the CMR region for temporarily storing logical resources to be stored.
Because the CMR area supports random writing, the logic resources to be stored can be randomly written into the area for temporarily storing the logic resources to be stored in the CMR area, and the CMR space can be effectively utilized by writing each logic resource to be stored in the CMR area, so that the space waste is reduced.
Optionally, the SMR area further includes at least one temporary storage area, where the temporary storage area is: a storage area in the SMR area for temporarily storing a logical resource to be stored, the second storage area further comprising: each temporary storage area.
And a part of the storage area in the SMR area is also used as a second storage area to temporarily store the logic resources to be stored, so that the capacity of the second storage area can be increased, the number of the logic resources to be stored which can be temporarily stored in the second storage area can be increased, and the phenomenon that the logic resources to be stored are detained at the client is further reduced.
Optionally, the writing the second logic resource to be stored into a second storage area includes:
judging whether the size of a free area in an area for temporarily storing the logic resources to be stored in the CMR area is not smaller than the size of the second logic resource or not;
if not, writing the second logic resource into an area in the CMR area for temporarily storing the logic resource to be stored;
if the number of the temporary storage areas is smaller than the preset number, judging whether a free storage area exists in each temporary storage area;
and if the idle storage areas exist, writing the second logic resource into the idle storage areas in the temporary storage areas.
Because the CMR region supports random writing and has high space utilization rate, the second logic resource is preferentially written into the CMR region, and when the free area of the area for temporarily storing the logic resource to be stored in the CMR region is not enough to store the second logic resource, the second logic resource is written into the free storage area in the temporary storage area, so that the space of the CMR region can be effectively utilized, and the second logic resource can be written into the SMR disk in time.
In a second aspect, an embodiment of the present application provides an apparatus for writing a logical resource to an SMR disk, the SMR disk including an SMR area, the SMR area including a first storage area, where the first storage area is used for being written by a plurality of logical resources, the plurality of logical resources include a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource whose writing order is before the second logical resource, the apparatus including:
a write determination unit configured to determine that the first logical resource is being written to the first storage area;
a data writing unit, configured to write the second logic resource to be stored into a second storage area, where the second storage area is: an area of the SMR disk other than the first storage area.
Optionally, the apparatus further comprises:
a position determining unit, configured to determine that a position to be written in the first storage area is the same as a starting position of a storage space allocated for the second logic resource;
and the data migration unit is used for storing the second logic resource to the first storage area.
Optionally, an ending position of the storage space allocated to the first logic resource is the same as a starting position of the storage space allocated to the second logic resource;
the position determining unit is specifically configured to: and determining that the first logic resource is completely written into the first storage area, and determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource.
Optionally, the apparatus further comprises:
and a write completion determining unit, configured to determine that the second logic resource completes writing into the second storage area.
Optionally, the apparatus further comprises:
a mapping establishing unit, configured to establish a mapping relationship, where the mapping relationship is used to indicate a storage location of the second logic resource in the second storage area and a storage space allocated for the second logic resource;
the data migration unit is specifically configured to: and storing the logic resource stored in the storage position to the storage space according to the mapping relation.
Optionally, the write determining unit is specifically configured to: determining that the starting position of the storage space allocated for the second logic resource is different from the position to be written in the first storage area, determining that the second logic resource to be stored fails to be written in the first storage area, and determining that the first logic resource is being written in the first storage area.
Optionally, the SMR disk further comprises: a conventional magnetic recording CMR region, said second storage area comprising: an area in the CMR region for temporarily storing logical resources to be stored.
Optionally, the SMR area further includes at least one temporary storage area, where the temporary storage area is: a storage area in the SMR area for temporarily storing a logical resource to be stored, the second storage area further comprising: each temporary storage area.
Optionally, the data writing unit includes:
a first region judgment subunit, configured to judge whether a size of a free region in a region in the CMR region, where the logic resource to be stored is temporarily stored, is not smaller than a size of the second logic resource;
a first data writing subunit, configured to write the second logical resource into an area in the CMR area for temporarily storing the logical resource to be stored, when a determination result of the first area determining subunit is yes;
a second storage area judgment subunit, configured to judge whether there is a free storage area in each temporary storage area when the judgment result of the first area judgment subunit is negative;
and the second data writing subunit is configured to, when the judgment result of the second storage area judgment subunit is yes, write the second logic resource into an idle storage area in each temporary storage area.
In a third aspect, an embodiment of the present application further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method steps of any of the first aspect when executing the program stored in the memory.
In a fourth aspect, this application further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps of any one of the first aspects.
Drawings
FIG. 1 is a schematic diagram of a CMR disk magnetic recording mode;
FIG. 2 is a schematic diagram of a SMR disk magnetic recording mode;
FIG. 3 is a diagram illustrating the logical partitioning of an SMR disk according to an embodiment of the present invention;
FIG. 4 is a first flowchart of a method for writing logical resources to an SMR disk according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating writing of a second logical resource into a second storage area according to an embodiment of the present application;
FIG. 6 is a second flowchart illustrating a method for writing logical resources to an SMR disk according to an embodiment of the present application;
fig. 7 is a flowchart illustrating a method for determining that a position to be written in a first storage area is the same as a starting position of a storage space allocated for a second logic resource in an embodiment of the present application;
FIG. 8 is a schematic diagram of a fifth flowchart of a method for writing logical resources to an SMR disk according to an embodiment of the present application;
FIG. 9 is a diagram illustrating a storage state of logical resources to be stored in an SMR disk in an embodiment of the present application;
FIG. 10 is a diagram illustrating how logical resources to be stored are migrated back to an SMR disk in an embodiment of the present application;
FIG. 11 is another schematic diagram illustrating a migration manner of each logical resource to be stored in an SMR disk in an embodiment of the present application;
FIG. 12 is a schematic structural diagram of an apparatus for writing logical resources to an SMR disk according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The technical solution in the present application will be described below with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the following, the terms "first", "second", etc. are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first," "second," etc. may explicitly or implicitly include one or more of that feature.
SMR disks are a type of high capacity magnetic disks that employ new magnetic storage technologies. SMR disks use shingled magnetic recording techniques, with the tracks on the disks partially overlapping like tiles on a roof. The shingled magnetic recording technique allows very little variation in the manufacturing process of SMR disks, but can significantly increase the number of tracks contained in the same area, thereby increasing the disk storage density. In the current world with the rapid increase of data volume, SMR technology can effectively reduce the cost of disk storage per unit capacity, and is a development trend of future high-density disk storage technology.
Fig. 1 is a schematic diagram of a Conventional Magnetic Recording (CMR) disc, and fig. 2 is a schematic diagram of an SMR disc.
As shown in FIGS. 1 and 2, the tracks of the CMR disk are vertically spaced, and the width of the write head of the CMR disk is greater than the width of the read head. The SMR disk utilizes the characteristic that the width of a read head of the disk is smaller than that of a write head, so that the next track partially covers the previous track, the width of the part, which is not covered by the next track, of the track is not smaller than that of the read head, and the SMR disk can reserve sufficient reading space for the read head with smaller width, thereby being convenient for random reading. Because the back track of the SMR disk covers part of the front track, the write head can only write data in sequence according to the track sequence when writing data, therefore, the SMR disk only supports sequential writing and does not support random writing, if random writing is carried out, the written data of the next track can be covered by the data of the written track, and the loss of the stored data is caused.
An SMR disk typically includes a CMR area and an SMR area. The track distribution mode of the CMR area is a traditional non-overlapping track distribution mode, the CMR area is created to make the CMR area of the SMR disk have the capability of random writing so as to record information such as attribute information of the SMR disk and attribute information of data stored in the magnetic disk, and in order to reduce the influence on the storage density of the SMR disk as much as possible, the proportion of the CMR area in the total capacity of the SMR disk is small, for example, the proportion of the CMR area in the total capacity of the SMR disk is usually 1%. The SMR area is an area in the SMR disk for storing external data to be stored, the SMR area occupies a relatively large amount of total capacity of the SMR disk, for example, the SMR area occupies a relatively large amount of 99% of the total capacity of the SMR disk, so as to store more external data to be stored, the SMR area includes a plurality of storage areas, the storage areas are physically separated and do not affect each other, tracks of the storage areas are distributed in a shingled manner, the capacity of each storage area is generally 256 megabits, only sequential writing of data is supported in the same storage area, random writing is not supported, and each storage area generally has a write pointer for indicating a current position to be written in the storage area.
When a client writes a logical resource into an SMR area, if the logical resource created by the client is not an integral multiple of the capacity of a storage area, in order to effectively use the SMR area, different clients may write the logical resource into the same storage area, for example, the capacity of the storage area is 256 megabytes, the client is a camera, and the size of one video shot by the camera is 100 megabytes, and then 156 megabytes of video data shot by the camera are left in the storage area, and in this case, videos shot by other cameras may be stored in the same storage area. Because the same storage area of the SMR area only supports sequential writing, each client that stores the logical resources to the same storage area needs to sequentially write the logical resources to the SMR disk in the order of the allocated space, and thus, the client often needs to wait when writing the logical resources to the SMR disk, so that each client cannot timely store the created logical resources on the SMR disk.
Therefore, the embodiment of the application provides a method and a device for writing logical resources into an SMR disk, so that when different clients write logical resources into the same storage area of an SMR area, each client can write the logical resources into the SMR disk at the same time, and thus each client can store the logical resources on the SMR disk more timely.
Next, the SMR disk in the example of the present application will be described first.
In an embodiment of the present application, an SMR disk includes an SMR area, the SMR area includes a first storage area, the first storage area is used for being written by a plurality of logical resources, the plurality of logical resources includes a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource that is written sequentially before the second logical resource.
For example, the first logic resource may be a logic resource whose writing order is before the second logic resource and which is adjacent to the second logic resource, or may be a logic resource whose writing order is before the second logic resource and which is not adjacent to the second logic resource.
The first logical resource and the second logical resource may be resources created by the first client and the second client, respectively. In one embodiment, each storage area included in the SMR area may be entirely used for writing of a logical resource created by each client, and in this case, the first storage area may be any storage area in the SMR area. In another embodiment, each storage area included in the SMR area may also be partially used for writing the logical resource created by each client, and in this case, the first storage area may be any one of the storage areas in the SMR area that are used for writing the logical resource created by each client.
In this application, an SMR Disk may be logically divided into regions, and identification information may be added to each of the divided regions, for example, as shown in fig. 3, a region formed by a storage region that is not used for writing a logical resource created by each client in the SMR region may be denoted as a C region, a region formed by a storage region that is used for writing a logical resource created by each client in the SMR region may be denoted as a D region, and a CMR region may be logically partitioned to store different types of Data in different partitions, for example, as shown in fig. 3, the CMR region may be divided into a Disk Data type (DDF) region for recording Disk information, a B region for storing metadata of each logical resource, and an a region for storing other information. When the SMR area is divided into areas, the divided areas are in units of storage areas, that is, each of the areas into which the SMR area is logically divided includes at least one storage area.
Since the SMR disk is mainly used for being written by the logical resources created by each client, the capacity of the D area is the highest proportion of the total capacity of the SMR disk, for example, the capacity of the D area may be 96% to 98% of the total capacity of the SMR disk, specifically, the capacity of the D area may be 98% of the total capacity of the SMR disk, and the proportion of the D area to the total capacity of the SMR disk may be other relatively large proportions, which is not limited in this case. Those skilled in the art can also perform logical region division on the SMR disk in other manners according to actual needs, and the application does not limit a specific region division manner.
In the application, when the logical resources to be stored need to be stored in the SMR disk, the device for managing the SMR disk allocates a storage space to the logical resources to be stored according to the use condition and the space allocation condition of the SMR disk, and after the storage space is allocated, the logical resources to be stored may be stored in the allocated storage space.
The SMR disk in the embodiment of the application may be any one of a Host Managed (HM) SMR disk, a Host Aware (HA) SMR disk, and a Drive Managed (DM) SMR disk. Among them, the HM SMR disk allows upper layer software to fully manage the sequential write constraints of the SMR disk, and its write behavior is fully controlled by the software, so its performance is controllable, and the advantages of the SMR disk can be maximized, so in one embodiment, in order to make the storage of logical resources in the SMR disk more stable, the SMR disk in this application is the HM SMR disk.
The method for writing logical resources to shingled magnetic recording SMR disks provided by the embodiments of the present application is described below.
The execution subject of the method for writing the logical resource into the SMR disk provided in this embodiment may be an electronic device that manages a writing sequence of the SMR disk, where the electronic device may be a device with a computing function, such as a computer, a server, a laptop, a processor, or other electronic devices, and the present application is not limited in particular.
As shown in fig. 4, the method for writing a logical resource to an SMR disk provided in an embodiment of the present application includes the following steps S110 to S120.
S110: it is determined that a first logical resource is writing to a first storage area.
S120: and writing the second logic resource to be stored into a second storage area.
Wherein the second storage area is: an area other than the first storage area in the SMR disk.
When it is determined that the first logical resource is being written into the first storage area, since the SMR area only allows sequential writing, the second logical resource cannot be written into the first storage area, and in order to enable the client to write the created logical resource into the SMR disk in time and reduce the retention of the logical resource on the client, the embodiment writes the second logical resource into a second storage area other than the first storage area.
In one embodiment, step S110 may be implemented as follows: determining that the initial position of the storage space allocated for the second logic resource is different from the position to be written in the first storage area, determining that the second logic resource to be stored fails to be written in the first storage area, and determining that the first logic resource is being written in the first storage area. In this embodiment, the position of the write pointer in the first storage area may be determined as the position to be written in the first storage area.
Specifically, if the starting position of the storage space allocated to the second logical resource is different from the position to be written in the first storage area, the SMR disk may send information of the different writing positions to the electronic device, and after the electronic device receives the information of the different writing positions, it may be determined that the starting position of the storage space allocated to the second logical resource is different from the position to be written in the first storage area, and it is determined that the writing of the second logical resource in the first storage area fails, so that it is determined that the first logical resource is being written in the first storage area.
In another embodiment, step S110 can also be implemented as follows: determining that the logical resource being written to the first storage area is not the second logical resource, determining that the first logical resource is being written to the first storage area. In this embodiment, it may be determined by software implementation that the logical resource being written into the first storage area is not the second logical resource by checking which logical resource is being written into the first storage area.
Optionally, the method may further include the following steps: determining that the second logic resource to be stored fails to be written into the first storage area, determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource, judging that the disk is in error, and sending a disk error message to a second client side for creating the second logic resource. It can be understood that, in the case that the second logical resource fails to write into the first storage area, the starting location of the storage space allocated for the second logical resource and the location to be written into the first storage area should be different, and if the starting location and the location to be written into the first storage area are the same, it indicates that the disk hardware is faulty or damaged, and then it may be determined that the disk is faulty.
In another embodiment, step S110 may also be implemented as follows: and determining that the position to be written in the first storage area is different from the initial position of the storage space allocated for the second logic resource, and determining that the first logic resource is being written in the first storage area. Specifically, the electronic device may determine a write pointer position of the first storage area as a to-be-written position of the first storage area. In this application, the electronic device may receive a write pointer location of the first storage area sent by the SMR disk before the second logical resource is written to the first storage area.
The second logical resource may be a resource created by the second client, and the first logical resource may be a resource created by the first client. The first client and the second client may specifically be clients corresponding to two different video acquisition devices of the video monitoring system, and may also be two network disk clients of the network disk storage system. The method for writing the logic resources into the SMR disk has different application scenes, different types of clients and different types of logic resources.
In one embodiment, before step S110, the following steps may be further included: and acquiring the data size of the second logic resource, inquiring a first storage area of free storage spaces in each storage area for writing the logic resource in the SMR area, and selecting the storage space with the space size not smaller than the data size of the second logic resource from the free storage spaces of the first storage area for writing the second logic resource. Specifically, in order to make the utilization of the SMR disk higher, the electronic device may select, from the free memory space, a memory space that is the same as the second logical resource in size and is located most forward, for writing by the second logical resource. The free storage space is not used for writing in other logic resources to be stored.
In the embodiment of the application, the client can send the size of the created logic resource to the electronic device after creating the resource, and the electronic device can allocate a storage space for the logic resource according to the size of the resource after receiving the size of the logic resource. For example, after a video is captured by a camera, the size of the captured video may be sent to the electronic device, and the electronic device may allocate a storage space for the video according to the size of the video.
In this embodiment of the present application, the storage space allocated by the electronic device for each to-be-stored logical resource is a continuous storage space, for example, a starting position of the storage space allocated for the logical resource 2 is the same as an ending position of the storage space allocated for the logical resource 1, and a starting position of the storage space allocated for the logical resource 3 is the same as an ending position of the storage space allocated for the logical resource 2.
By using the scheme provided by the application, when the second client writes the second logic resource into the first storage area, if the first client is writing the first logic resource into the first storage area, the second logic resource created by the second client can be written into the second storage area first, so that the second client can write the logic resource into the SMR disk in time without waiting, and when different clients store the logic resource into the same storage area, each client can write the logic resource into the SMR disk at the same time.
In one embodiment, the SMR disk may further comprise: the CMR area, the second storage area may include: an area in the CMR zone for temporarily storing logical resources to be stored.
Specifically, the second storage area may include the above-described a area. A person skilled in the art may logically divide the CMR area according to actual situations, and store different types of data in different divided logical partitions according to actual needs, where an area in the CMR area for temporarily storing the logical resource to be stored may be any one or more of the divided logical partitions in the CMR area, and the present application is not limited in particular. In this embodiment, the second storage area includes an area in the CMR area for temporarily storing the logic resources to be stored, and since the CMR area supports random writing, the second logic resources can be randomly written into the area in the CMR area for temporarily storing the logic resources to be stored, and writing each logic resource to be stored into the CMR area can also effectively utilize the space of the CMR, thereby reducing space waste.
In another embodiment, the SMR area further comprises at least one temporary storage area, the temporary storage area being: a storage area in the SMR area for temporarily storing a logical resource to be stored, the second storage area further comprising: each temporary storage area.
Since the total capacity of the CMR area is usually a small proportion of the total capacity of the SMR disk, the total capacity of the CMR area is also small, and a partial area in the CMR area is also required to store information such as disk information and metadata of a logical resource to be stored, the capacity of an area in the CMR area for temporarily storing the logical resource to be stored is usually small, so that the second storage area can temporarily store less logical resources to be stored. Therefore, in the present embodiment, a part of the storage area in the SMR area is also used as the second storage area to temporarily store the logical resources to be stored, and the capacity of the second storage area can be increased, so that the number of the logical resources to be stored that can be temporarily stored in the second storage area can be increased, and the phenomenon that the logical resources to be stored are retained at the client is further reduced.
In one embodiment, as shown in fig. 5, step S120 may be implemented as steps S121 to S124 as follows:
s121: and judging whether the size of a free area in the area for temporarily storing the logic resources to be stored in the CMR area is not smaller than the size of the second logic resource.
S122: if the result of the determination in step S121 is yes, writing the second logic resource into the area of the CMR region for temporarily storing the logic resource to be stored.
S123: if the result of the interpretation in step S121 is negative, it is determined whether there is a free storage area in each temporary storage area.
S124: if the result of the determination in step S123 is yes, the second logic resource is written into the free storage area in each temporary storage area.
If the interpretation result in step S123 is negative, sending the information of write failure to the second client that sends the second logical resource.
Because the CMR region supports random writing and has high space utilization rate, the second logic resource is preferentially written into the CMR region, and when the free region of the region for temporarily storing the logic resource to be stored in the CMR region is not enough to store the second logic resource, the second logic resource is written into the free storage region in the temporary storage region, so that the space of the CMR region can be effectively utilized, and the second logic resource can be written into the SMR disk in time with higher probability.
In one embodiment, after writing the second logical resource into the area of the CMR area for temporarily storing the logical resource to be stored, the electronic device may count the size of the used space of the area of the CMR area for temporarily storing the logical resource to be stored and store information indicating the size of the used space in the DDF area of the CMR area, and after writing the second logical resource into the free storage area of the scratch area, may count the used storage area in each scratch area and store information indicating the used storage area in the DDF area of the CMR area. After the data are counted, the electronic device can inquire the areas for temporarily storing the logic resources to be stored in the CMR area and the use conditions of each temporary storage area, and after the data are stored in the DDF area, the data can be prevented from being lost due to power failure.
In one embodiment, as shown in fig. 6, the method may further include the following steps S130 to S140:
s130: and determining that the position to be written in the first storage area is the same as the starting position of the storage space allocated for the second logic resource.
S140: and storing the second logic resource to the first storage area.
After it is determined that the position to be written in the first storage area is the same as the starting position of the storage space allocated to the second logical resource, it is indicated that it is time to write the second logical resource into the first storage area at the present time, and at this time, the second logical resource stored in the second storage area is stored into the first storage area, so that the second logical resource can be written into the storage space allocated to the second storage area.
In an optional implementation manner, before the step S130, the following steps may be further included: and monitoring whether the initial position of the storage space allocated for the second logic resource is the same as the position of the write pointer of the first storage area, and if so, determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource.
In step S140, the second logic resource is stored in the first storage area, which may be storing the second logic resource in the first storage area, and deleting the second logic resource stored in the second storage area, that is, the second logic resource stored in the second storage area is migrated back to the first storage area, so that the space occupied by the second logic resource in the second storage area is emptied to temporarily store other logic resources.
In this embodiment, it is determined that the position to be written in the first storage area is the same as the initial position of the storage space allocated to the first logic resource created by the first client, which indicates that it is time to write the first logic resource into the first storage area, and at this time, the first logic resource stored in the second storage area is stored into the first storage area, so that the first logic resource can be finally written into the storage space allocated to the first storage area.
In one embodiment, as shown in fig. 7, step S130 may be implemented as following steps S131 to S132:
s131: determining that the last logic resource completes writing into the first storage area, wherein the ending position of the storage space allocated for the last logic resource is the same as the starting position of the storage space allocated for the second logic resource;
s132: and determining that the position to be written in the first storage area is the same as the starting position of the storage space allocated for the second logic resource.
In the embodiment of the application, since the storage space allocated to each to-be-stored logic resource is a continuous storage space, when it is determined that the last logic resource completes writing in the first storage area, it may be determined that the to-be-written position of the first storage area is the same as the starting position of the storage space allocated to the second logic resource.
In a specific embodiment, a complete write message may be generated after the second logic resource is stored in the first storage area, so that whether the second logic resource is stored in the first storage area may be known in time, and the logic resource to be stored whose allocated storage space is located behind the second logic resource may be written in the first storage area in time.
By determining the writing completion condition of the last logical resource in the first storage area, the embodiment can more simply determine whether the initial position of the storage space allocated for the second logical resource is the same as the position to be written in the first storage area.
In one embodiment, before step S110, the method may further include the following steps: determining the sequencing position of the second logic resource in each logic resource to be stored according to the starting position or the ending position of the storage space allocated to the second logic resource, wherein the storage space allocated to each logic resource to be stored is in the first storage area; and determining the logic resource to be stored, the sorting position of which is positioned before the sorting position of the second logic resource and the sorting position of which is adjacent to the sorting position of the second logic resource, as the last logic resource. The present embodiment facilitates determining the last logical resource by sorting the second logical resources.
In one embodiment, the method may further include the steps of: and recording a first state that whether the second logic resource completes writing in the second storage area and a second state that whether the second logic resource completes writing in the first storage area.
Step S130 may be implemented as the following steps: and determining that the first state of the second logic resource is write completion, the second state of the second logic resource is unfinished write, and the second state of the last logic resource is write completion, and storing the second logic resource to the first storage area.
Optionally, a start position and an end position of the storage space allocated for the second logical resource may also be recorded, so as to determine the last logical resource according to the recorded positions.
The first state and the second state of the second logic resource are recorded, and the storage time of the second logic resource in the first storage area is more convenient to determine.
In one embodiment, the method may further include the steps of: and monitoring the recorded state of each logic resource to be stored at preset time intervals. The preset time interval may be any one of 1 minute to 5 minutes, or may be another specific time interval. When the preset time interval is short, the second logic resource can be stored in the first storage area in time, so that the second storage area occupied by the second logic resource is released in time.
In an alternative embodiment, the recorded first state and second state of the second logical resource and the start and end locations of the storage space allocated for the second logical resource may be stored in an area of the SMR disk other than the first storage area to prevent the electronic device from losing such information when powered off. Specifically, the recorded information of the above-described first status, second status, start position, and end position may be stored in the CMR area, for example, in the DDF area, in the a area, or in the B area of the CMR area, and when the recorded information is recorded in the CMR area, the information may be randomly written, so that the information may be written to the SMR disk in a timely manner.
Optionally, after the second logic resource is stored in the first storage area, the stored first state and second state of the second logic resource and the start position and end position of the storage space allocated for the second logic resource may be deleted. To reduce the footprint of SMR disks.
In one embodiment, before step S140, the following steps may be further included: it is determined that the second logical resource completes writing to the second storage area.
In the embodiment, the second logic resource is determined to be stored in the first storage area after the second logic resource is written into the second storage area, so that the phenomena of data loss, interruption and the like when the second logic resource is stored in the first storage area can be reduced.
Optionally, the method may further include the following steps: and determining that the second logic resource completes writing in the second storage area, and generating a writing completion message that the second logic resource completes writing in the second storage area. Therefore, whether the second logic resource completes writing in the second storage area or not can be timely acquired.
In one embodiment, the method may further include the steps of: determining that the second logic resource is migrated back to the first storage area from an area for temporarily storing the logic resource to be stored in the CMR area, counting the size of used space of the area for temporarily storing the logic resource to be stored in the CMR area, determining that the second logic resource is migrated back to the first storage area from the temporary storage area, counting the used storage areas in each temporary storage area, and storing the counted information in the DDF area.
In one embodiment, before step S140, the method may further include the following steps: establishing a mapping relation, wherein the mapping relation is used for indicating the storage position of the second logic resource in the second storage area and a storage space allocated for the second logic resource; step S140 may be implemented as the following steps: and storing the logic resource stored in the storage position to the storage space according to the mapping relation.
Specifically, the electronic device may search the storage location and the storage space corresponding to the second logic resource from the mapping relationship, and store the logic resource stored in the searched storage location to the searched storage space.
After the mapping relationship is established, the second logic resource can be accurately and quickly migrated back according to the established mapping relationship.
In an embodiment, after the mapping relationship is established, the mapping relationship may be stored in the DDF area to prevent the established mapping relationship from being lost when the power is lost, and after the electronic device is rebooted, the mapping relationship in the DDF may be loaded into the memory to be quickly read.
In this embodiment of the application, after the second logic resource is migrated back to the first storage area, the mapping relationship corresponding to the second logic resource may be deleted from the DDF area, so as to reduce the occupancy rate of the DDF area.
The scheme provided by the application is described below by specific examples.
In this embodiment, the SMR disk includes a CMR area and an SMR area, the CMR area supports both sequential writing and random writing, and the SMR area supports only sequential writing. CMR region comprises DDF region, A region and B region; the CMR area has a head of a DDF area with the capacity of 1G and used for storing disk metadata, the DDF area comprises a shared space management area, a bad block mapping data area, a shared space data area and other sections, and each section is used for recording related information of different types of disks; the a-zone is an area for temporarily storing logical resources to be stored; the B area is an area for recording logical resource metadata, the size of the B area is 2G, and the CMR area capacity accounts for 1% of the entire SMR disk capacity; the SMR area comprises a C area and a D area, wherein the C area is also used for temporarily storing the logic resources to be stored, the capacity of the C area is 1% of the total capacity of the whole SMR hard disk, the D area is used for writing the logic resources to be stored in the SMR hard disk, the capacity of the D area is 98% of the total capacity of the whole SMR hard disk, the SMR area comprises a plurality of physically separated storage areas which are not affected with each other, and the capacity of each storage area is 256 Mm.
In this embodiment, as shown in fig. 8, the method for writing the shingled magnetic recording SMR disk by the logical resources includes the following steps S1 to S21:
s1: the second logical resource begins writing to the SMR disk.
S2: and judging whether the second logic resource is successfully written into the SMR disk.
S3: if the determination result at S2 is yes, it is determined that the logical resource is not required to be temporarily stored.
S4: if the determination result at S2 is negative, the start position of the storage space allocated for the second logical resource and the write pointer position of the first storage area are acquired.
S5: and judging whether the position of the write pointer is consistent with the initial position.
S6: if the determination result at S5 is yes, information of write failure is transmitted to the client.
And the second logic resource fails to write into the SMR disk, but the position of the write pointer is consistent with the initial position, which indicates that the hard disk of the SMR disk is wrong, and sends information of write failure to the client.
S7: if the determination result of S5 is negative, it is determined that there are different logic resources that need to be written into the first storage area at the same time.
S8: and judging whether the size of the idle area in the area A of the CMR area is not smaller than the size of the second logic resource.
Specifically, in this embodiment, if the total capacity of the SMR disk is x (M), the CMR area capacity of the SMR disk is 0.01x (M), the DDF area capacity of the CMR area is 1 × 1024(M), the CMR area B area capacity is 2 × 1024(M), and the CMR area a capacity is: the CMR area capacity-B area capacity-DDF area capacity is [ [0.01X- (2+1) × 1024] (M), and assuming that the CMR area a area used capacity is Y (M) and the size of the second logical resource (the size of the space required for temporary storage of the second logical resource) is Z (M), when Z [ <0.01X- (2+1) × 1024-Y, it is determined that the area a of the CMR area has sufficient capacity to temporarily store the second logical resource. The above (M) is a unit (mega) of capacity.
S9: if the determination result of S8 is no, it is determined whether a free storage area exists in the C area of the SMR area.
If the determination result in the step S9 is negative, the operation performed in the step S6 is performed.
S10: if the determination result in the step S9 is yes or the determination result in the step S8 is yes, the second logical resource is written into the area C or the area a, and the mapping relationship is established.
The mapping relationship is used for indicating the storage location of the second logic resource in the second storage area and the storage space allocated for the second logic resource.
The second storage area is an area A or an area C.
For example, as shown in fig. 9, if the logical resource 1 is being written into the first storage area at the present time, and at this time, if the logical resources 2 and 3 also want to be written into the first storage area, the logical resource 2 may be written into the free area in the area a first, and after the logical resource 2 is written into the area a, the area a has no free area, and the logical resource 3 may be written into the free storage area in the area C. Wherein, "1", "2" and "3" are respectively: identification information of logical resource 1, logical resource 2, and logical resource 3. And then, a mapping relation between the storage position of the logic resource 2 in the area A and the storage space allocated for the logic resource 2 is established, and a mapping relation between the storage position of the logic resource 3 in the area C and the storage space allocated for the logic resource 3 is established, wherein the identification information is '2'. The logic resource 1, the logic resource 2 and the logic resource 3 are 3 logic resources to be stored, which are respectively created by 3 clients.
S11: and storing the established mapping relation in the DDF area.
S12: information of the size of the used space of the a area and information of the used storage area of the C area are stored in the DDF area.
S13: and receiving a first write completion message sent by the SMR disk after the second logical resource completes writing in the area A or the area C.
S14: and judging whether a first write completion message is received or not.
S15: if the judgment result of S14 is yes, recording the first state that the second logic resource completes writing in the second storage area as completion of writing, and recording the start position and the end position of the storage space allocated for the second logic resource, storing the recorded information in the DDF area, and determining the sorting position of the second logic resource in each logic resource to be stored according to the start position or the end position.
If the result of the determination at S14 is negative, S13 is executed.
S16: and receiving a second write completion message sent by the SMR disk after the second logical resource completes writing in the first storage domain.
S17: and judging whether a second write completion message is received or not.
S18: if the determination result of S17 is yes, the second status that the second logical resource completes writing in the first storage area is recorded as write completion.
If the result of the determination at S17 is negative, S16 is executed.
S19: and determining whether the data back-migration condition is met according to the first state of the second logic resource, the second state of the second logic resource and the second state of the last logic resource.
Specifically, it may be determined that the data rollback condition is met when the first state of the second logic resource is write completion, the second state of the second logic resource is write incompletion, and the second state of the last logic resource is write completion.
S20: if the determination result of S19 is yes, the second logical resource in the second storage area is migrated back to the first storage area.
For example, as shown in fig. 10, after the logical resource 1 completes writing in the first storage area and the logical resource 2 completes writing in the a area, the logical resource 2 in the a area may be migrated back to the first storage area, and the logical resource 2 in the a area may be cleared. As shown in fig. 11, after the logical resource 2 completes writing in the first storage area and the logical resource 3 completes writing in the C area, the logical resource 3 in the C area is migrated back to the first storage area.
If the determination result of the step S19 is negative, the steps S13 and S16 are performed.
S21: the above-described mapping relationship in the DDF area is deleted, the information recorded in step S15 in the DDF area is deleted, and the information of the size of the used space of the a area and the information of the used storage area of the C area recorded in the DDF area are updated.
An embodiment of the present application further provides an apparatus for writing a logical resource to an SMR disk, as shown in fig. 12, where the SMR disk includes an SMR area, and the SMR area includes a first storage area, where the first storage area is used for being written by a plurality of logical resources, the plurality of logical resources include a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource whose writing order is before the second logical resource, and the apparatus includes:
a write determining unit 1310 configured to determine that the first logical resource is being written into the first storage area;
a data writing unit 1320, configured to write the second logic resource to be stored into a second storage area, where the second storage area is: an area of the SMR disk other than the first storage area.
In an alternative embodiment, the apparatus further comprises:
a position determining unit, configured to determine that a position to be written in the first storage area is the same as a starting position of a storage space allocated for the second logic resource;
and the data migration unit is used for storing the second logic resource to the first storage area.
In an alternative embodiment, the ending position of the memory allocated to the first logical resource is the same as the starting position of the memory allocated to the second logical resource;
the position determining unit is specifically configured to: and determining that the first logic resource is completely written into the first storage area, and determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource.
In an alternative embodiment, the apparatus further comprises:
and a write completion determining unit, configured to determine that the second logic resource completes writing into the second storage area.
In an alternative embodiment, the apparatus further comprises:
a mapping establishing unit, configured to establish a mapping relationship, where the mapping relationship is used to indicate a storage location of the second logic resource in the second storage area and a storage space allocated for the second logic resource;
the data migration unit is specifically configured to: and storing the logic resource stored in the storage position to the storage space according to the mapping relation.
In an optional implementation manner, the write determining unit is specifically configured to: determining that the starting position of a storage space allocated for a second logical resource is different from the position to be written in a first storage area, determining that the second logical resource to be stored fails to be written in the first storage area, and determining that the first logical resource is being written in the first storage area.
In an alternative embodiment, the SMR disk further comprises: a conventional magnetic recording CMR region, said second storage area comprising: an area in the CMR region for temporarily storing logical resources to be stored.
In an alternative embodiment, the SMR area further comprises at least one temporary storage area, where the temporary storage area is: a storage area in the SMR area for temporarily storing a logical resource to be stored, the second storage area further including: each temporary storage area.
In an optional implementation manner, the data writing unit includes:
a first region judgment subunit, configured to judge whether a size of a free region in a region in the CMR region, where the logic resource to be stored is temporarily stored, is not smaller than a size of the second logic resource;
a first data writing subunit, configured to write the second logical resource into an area in the CMR area for temporarily storing the logical resource to be stored, when a determination result of the first area determining subunit is yes;
a second storage area judgment subunit, configured to judge whether there is a free storage area in each temporary storage area when the judgment result of the first area judgment subunit is negative;
and the second data writing subunit is configured to, when the judgment result of the second storage area judgment subunit is yes, write the second logic resource into an idle storage area in each temporary storage area.
Corresponding to the above method for writing logical resources to the SMR disk, an embodiment of the present invention further provides an electronic device, as shown in fig. 13, including a processor 1401, a communication interface 1402, a memory 1403, and a communication bus 1404, where the processor 1401, the communication interface 1402, and the memory 1403 are communicated with each other via the communication bus 1104,
a memory 1403 for storing a computer program;
the processor 1401 is configured to implement the method for writing a logical resource to the SMR disk, as described in any one of the above embodiments, when executing the program stored in the memory 1403.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (pci) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory.
Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware components.
In response to the method for writing the logical resource to the SMR disk, an embodiment of the present invention further provides a computer readable storage medium, and when executed by a processor, the computer program implements the method for writing the logical resource to the SMR disk in any one of the embodiments.
In response to the method for writing logical resources to the SMR disk described above, an embodiment of the present invention further provides a computer program product including instructions that, when executed on a computer, cause the computer to perform the method for writing logical resources to the SMR disk described in any one of the above embodiments.
It should be understood that the above description is only for the purpose of helping those skilled in the art better understand the embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application. Various equivalent modifications or changes, or combinations of any two or more of the above, may be apparent to those skilled in the art in light of the above examples given. Such modifications, variations, or combinations are also within the scope of the embodiments of the present application.
It should also be understood that the foregoing descriptions of the embodiments of the present application focus on highlighting differences between the various embodiments, and that the same or similar elements that are not mentioned may be referred to one another, and thus, for brevity, will not be described again.
It should also be understood that the manner, the case, the category, and the division of the embodiments are merely for convenience of description and should not be construed as a particular limitation, and features in various manners, categories, cases, and embodiments may be combined without contradiction.
It is also to be understood that, in the various embodiments of the present application, unless otherwise specified or logically conflicting, terms and/or descriptions between different embodiments are consistent and may be mutually referenced, and technical features in different embodiments may be combined to form new embodiments according to their inherent logical relationships.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and all the changes or substitutions should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A method of writing a logical resource to an SMR disk, the SMR disk comprising an SMR area, the SMR area comprising a first storage area, wherein the first storage area is used for writing by a plurality of logical resources, the plurality of logical resources comprise a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource whose writing order is before the second logical resource, the method comprising:
determining that the first logical resource is writing to the first storage area;
writing the second logic resource to be stored into a second storage area, wherein the second storage area is: an area of the SMR disk other than the first storage area.
2. The method of claim 1, further comprising:
determining that the position to be written in the first storage area is the same as the initial position of the storage space allocated for the second logic resource;
storing the second logical resource to the first storage area.
3. The method according to claim 2, wherein the determining that the location to be written in the first storage area is the same as the starting location of the storage space allocated for the second logical resource comprises:
determining that the last logic resource completes writing into the first storage area, wherein the ending position of the storage space allocated for the last logic resource is the same as the starting position of the storage space allocated for the second logic resource;
and determining that the position to be written in the first storage area is the same as the starting position of the storage space allocated for the second logic resource.
4. The method of claim 2, wherein prior to said storing the second logical resource to the first storage area, the method further comprises:
determining that the second logical resource completes writing to the second storage area.
5. The method of claim 2, wherein prior to storing the second logical resource to the first storage area, the method further comprises:
establishing a mapping relation, wherein the mapping relation is used for indicating the storage position of the second logic resource in the second storage area and the storage space allocated for the second logic resource;
the storing the second logical resource to the first storage area includes:
and storing the logic resource stored in the storage position to the storage space according to the mapping relation.
6. The method of claim 1, wherein the determining that the first logical resource is writing to the first storage area comprises:
determining that the starting position of the storage space allocated for the second logic resource is different from the position to be written in the first storage area;
determining that the second logic resource to be stored fails to be written into the first storage area;
determining that the first logical resource is writing to the first storage area.
7. The method of claim 1, wherein the SMR disk further comprises: a conventional magnetic recording CMR region, said second storage area comprising: an area in the CMR region for temporarily storing logical resources to be stored.
8. The method of claim 7, wherein the SMR zone further comprises at least one scratch pad area, the scratch pad area being: a storage area in the SMR area for temporarily storing a logical resource to be stored, the second storage area further comprising: each temporary storage area.
9. The method of claim 8, wherein writing the second logical resource to be stored to a second storage area comprises:
judging whether the size of a free area in an area for temporarily storing the logic resources to be stored in the CMR area is not smaller than the size of the second logic resource or not;
if not, writing the second logic resource into an area in the CMR area for temporarily storing the logic resource to be stored;
if the number of the temporary storage areas is smaller than the preset number, judging whether a free storage area exists in each temporary storage area;
and if the idle storage areas exist, writing the second logic resource into the idle storage areas in the temporary storage areas.
10. An apparatus for writing a logical resource to an SMR disk, the SMR disk comprising an SMR area, the SMR area comprising a first storage area, wherein the first storage area is used for writing a plurality of logical resources, the plurality of logical resources comprise a first logical resource and a second logical resource, and the first logical resource is any one of at least one logical resource in which a writing order is prior to the second logical resource, the apparatus comprising:
a write determination unit configured to determine that the first logical resource is being written to the first storage area;
a data writing unit, configured to write the second logic resource to be stored into a second storage area, where the second storage area is: an area of the SMR disk other than the first storage area.
11. An electronic device, comprising: the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor, when executing the program stored in the memory, implementing the method steps of any of claims 1 to 9.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any of claims 1 to 9.
CN202010941460.XA 2020-09-09 2020-09-09 Method and device for writing logic resources into SMR disk, electronic equipment and storage medium Active CN114237489B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010941460.XA CN114237489B (en) 2020-09-09 2020-09-09 Method and device for writing logic resources into SMR disk, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010941460.XA CN114237489B (en) 2020-09-09 2020-09-09 Method and device for writing logic resources into SMR disk, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114237489A true CN114237489A (en) 2022-03-25
CN114237489B CN114237489B (en) 2024-04-05

Family

ID=80742679

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010941460.XA Active CN114237489B (en) 2020-09-09 2020-09-09 Method and device for writing logic resources into SMR disk, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114237489B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022262345A1 (en) * 2021-06-18 2022-12-22 华为技术有限公司 Data management method and apparatus, and storage space management method and apparatus

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102789367A (en) * 2011-02-14 2012-11-21 希捷科技有限公司 Dynamic storage regions
CN106201355A (en) * 2016-07-12 2016-12-07 腾讯科技(深圳)有限公司 Data processing method and device and storage system
US20170124104A1 (en) * 2015-10-31 2017-05-04 Netapp, Inc. Durable file system for sequentially written zoned storage
CN107003809A (en) * 2015-11-27 2017-08-01 华为技术有限公司 A kind of method and storage device of storage device data storage
US20190244638A1 (en) * 2018-02-06 2019-08-08 Western Digital Technologies, Inc. Dynamic hybrid shingled magnetic recording
CN110502455A (en) * 2018-05-18 2019-11-26 杭州海康威视数字技术股份有限公司 Date storage method and system
CN111399762A (en) * 2019-11-27 2020-07-10 杭州海康威视系统技术有限公司 Data storage method, device and storage system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102789367A (en) * 2011-02-14 2012-11-21 希捷科技有限公司 Dynamic storage regions
US20170124104A1 (en) * 2015-10-31 2017-05-04 Netapp, Inc. Durable file system for sequentially written zoned storage
CN107003809A (en) * 2015-11-27 2017-08-01 华为技术有限公司 A kind of method and storage device of storage device data storage
CN106201355A (en) * 2016-07-12 2016-12-07 腾讯科技(深圳)有限公司 Data processing method and device and storage system
US20190244638A1 (en) * 2018-02-06 2019-08-08 Western Digital Technologies, Inc. Dynamic hybrid shingled magnetic recording
CN110502455A (en) * 2018-05-18 2019-11-26 杭州海康威视数字技术股份有限公司 Date storage method and system
CN111399762A (en) * 2019-11-27 2020-07-10 杭州海康威视系统技术有限公司 Data storage method, device and storage system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022262345A1 (en) * 2021-06-18 2022-12-22 华为技术有限公司 Data management method and apparatus, and storage space management method and apparatus

Also Published As

Publication number Publication date
CN114237489B (en) 2024-04-05

Similar Documents

Publication Publication Date Title
US11853549B2 (en) Index storage in shingled magnetic recording (SMR) storage system with non-shingled region
US8074041B2 (en) Apparatus, system, and method for managing storage space allocation
CN103761190B (en) Data processing method and apparatus
CN107643880A (en) The method and device of file data migration based on distributed file system
JP2002123421A (en) Remapping control method for flash memory and structure for flash memory therefor
CN107291399B (en) Back-end storage method, device and system based on SPDK
CN106970765B (en) Data storage method and device
US11474919B2 (en) Method for managing multiple disks, electronic device and computer program product
CN113568582B (en) Data management method, device and storage equipment
CN109558457A (en) A kind of method for writing data, device, equipment and storage medium
CN110858162A (en) Memory management method and device and server
CN113495889B (en) Distributed object storage method and device, electronic equipment and storage medium
CN115576505B (en) Data storage method, device and equipment and readable storage medium
CN116466879B (en) CXL memory module, memory data replacement method and computer system
CN111651127A (en) Monitoring data storage method and device based on shingled magnetic recording disk
CN113377292A (en) Single machine storage engine
CN107092443B (en) Data migration method and device
CN114237489B (en) Method and device for writing logic resources into SMR disk, electronic equipment and storage medium
CN109196473B (en) Cache management method, cache manager, shared cache and terminal
US20050154848A1 (en) Duplication apparatus and method
CN109144403B (en) Method and equipment for switching cloud disk modes
CN109753224B (en) Storage structure and storage structure configuration method
CN111221468A (en) Storage block data deleting method and device, electronic equipment and cloud storage system
CN109508140B (en) Storage resource management method and device, electronic equipment and system
CN109739688A (en) Snapshot Resources space management, device, electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant