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

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

Info

Publication number
CN114237489B
CN114237489B CN202010941460.XA CN202010941460A CN114237489B CN 114237489 B CN114237489 B CN 114237489B CN 202010941460 A CN202010941460 A CN 202010941460A CN 114237489 B CN114237489 B CN 114237489B
Authority
CN
China
Prior art keywords
storage area
area
resource
logic
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.)
Active
Application number
CN202010941460.XA
Other languages
Chinese (zh)
Other versions
CN114237489A (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

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

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, the first logic resource is any one of at least one logic resource, and the writing sequence of the at least one logic resource is positioned before the second logic resource, and the method comprises the following steps: determining that the first logical resource is being written 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, each client can write the logic resources into the SMR disk in time without waiting.

Description

Method and device for writing logic 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, an apparatus, an electronic device, and a storage medium for writing a logic resource to an SMR disk.
Background
The tracks on the platter of a shingled magnetic recording (Shingled Magnetic Recording, SMR) platter overlap partially like a shingled roof tile, and the SMR platter can hold more tracks on the platter than a conventional platter, so that the storage density of the SMR platter is higher and the storage capacity of a single platter is larger, and thus, the SMR platter is increasingly used for data storage.
The SMR disk comprises an SMR area, wherein the SMR area comprises a plurality of storage areas which are physically separated and are not affected by each other, each storage area is used for writing in logic resources created by a 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 the logic resource into the same storage area, each client needs to sequentially write the logic resource into the SMR disk.
However, if each client sequentially writes the logic resources to the SMR disk, the client often needs to wait, that is, after the previous client completes writing, the next client can start writing, and if the previous client has not completed writing, the next client starts writing, which may cause the writing failure of the second client, so that each client may not be able to write the logic resources to the SMR disk in time.
Disclosure of Invention
The invention aims to provide a method, a device, electronic equipment and a storage medium for writing logic resources into an SMR disk, so that when different clients write the logic resources into the same storage area of an SMR area, each client can write the logic resources into the SMR disk at the same time, and therefore each client stores the logic resources on the SMR disk more timely. The application is realized by adopting the following technical scheme:
in a first aspect, an embodiment of the present application provides a method for writing a logic resource to an SMR disk, where the SMR disk includes an SMR area, where the SMR area includes a first storage area, where the first storage area is used for writing a plurality of logic resources, where the plurality of logic resources includes a first logic resource and a second logic resource, and where the first logic resource is any one of at least one logic resource that is written in sequence before the second logic resource, and the method includes:
determining that the first logical resource is being written 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 simultaneously.
Optionally, the method further comprises:
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;
and storing the second logic resource to the first storage area.
The position to be written in the first storage area is determined to be the same as the initial position of the storage space allocated to the first logic resource created by the first client, and the fact that the first logic resource is written in the first storage area is taken turns at the moment is indicated, and at the moment, the first logic resource stored in the second storage area is stored in the first storage area, so that the first logic resource can be finally written in the storage space allocated for the first logic resource.
Optionally, 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 includes:
determining that the last logic resource is completely written 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 initial position of the storage space allocated for the second logic resource.
By determining that the last logical resource is written into the first storage area, it can be quickly and conveniently determined 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 logical resource.
Optionally, before the storing the second logic resource in the first storage area, the method further includes:
and determining that the second logic resource finishes writing into 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 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 resources stored in the storage position into the storage space according to the mapping relation.
After the mapping relation is established, the embodiment can accurately restore the logic resource according to the established mapping relation.
Optionally, the determining that the first logical resource is writing to the first storage area includes:
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 into the first storage area;
determining that the first logical resource is being written 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 by determining the manner that the second logic resource to be stored fails to be written into the first storage area, the first logic resource can be quickly and conveniently determined to be written into the first storage area.
Optionally, the SMR disk further comprises: a conventional magnetic recording CMR zone, the second storage region comprising: and the CMR area is used for temporarily storing the area of the logic resource 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 space of the CMR can be effectively utilized by writing each logic resource to be stored into 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 logical resources to be stored, the second storage area further including: each temporary storage area.
The partial storage area in the SMR area is also used as the 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 stay in a client side is further reduced.
Optionally, the writing the second logic resource to be stored in the second storage area includes:
Judging whether the size of a hollow area in the CMR area for temporarily storing the logic resource to be stored is not smaller than the size of the second logic resource;
if not, writing the second logic resource into an area for temporarily storing the logic resource to be stored in the CMR area;
if the data is smaller than the data, judging whether an idle storage area exists in each temporary storage area;
and if the free storage area exists, writing the second logic resource into the free storage area in each temporary storage area.
Because the CMR area supports random writing and has high space utilization rate, the second logic resource is preferentially written into the CMR area, and when the free area of the area for temporarily storing the logic resource to be stored in the CMR area is insufficient for storing 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 area can be effectively utilized, and the second logic resource can be timely written into the SMR disk.
In a second aspect, an embodiment of the present application provides an apparatus for writing a logic resource to an SMR disk, where the SMR disk includes an SMR area, where the SMR area includes a first storage area, where the first storage area is used for writing a plurality of logic resources, where the plurality of logic resources includes a first logic resource and a second logic resource, and where the first logic resource is any one of at least one logic resource that is written in sequence before the second logic resource, and the apparatus includes:
A write determining unit configured to determine that the first logical resource is being written to the first storage area;
the data writing unit is 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 includes:
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 logical resource;
and the data returning unit is used for storing the second logic resource to the first storage area.
Optionally, the end position of the storage space allocated for the first logic resource is the same as the start position of the storage space allocated for the second logic resource;
the position determining unit is specifically configured to: and determining that the first logic resource finishes writing into the first storage area, and determining that the position to be written into 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 includes:
and the writing completion determining unit is used for determining that the second logic resource completes writing into the second storage area.
Optionally, the apparatus further includes:
the mapping establishing unit is used for 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 data returning unit is specifically configured to: and storing the logic resources stored in the storage position into the storage space according to the mapping relation.
Optionally, the writing determining unit is specifically configured to: 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.
Optionally, the SMR disk further comprises: a conventional magnetic recording CMR zone, the second storage region comprising: and the CMR area is used for temporarily storing the area of the logic resource 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 logical resources to be stored, the second storage area further including: each temporary storage area.
Optionally, the data writing unit includes:
a first area judging subunit for judging whether the size of an empty area in the area for temporarily storing the logic resource to be stored in the CMR area is not smaller than the size of the second logic resource;
a first data writing subunit, configured to write, when the determination result of the first area determination subunit is yes, the second logical resource into an area for temporarily storing a logical resource to be stored in the CMR area;
a second storage area judging subunit, configured to judge whether an idle storage area exists in each temporary storage area when the judging result of the first area judging subunit is no;
and the second data writing subunit is used for writing the second logic resource into the idle storage area in each temporary storage area when the judging result of the second storage area judging subunit is yes.
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 communication with each other through the communication bus;
The memory is used for storing a computer program;
the processor is configured to implement any of the method steps described in the first aspect when executing the program stored in the memory.
In a fourth aspect, embodiments of the present application further provide a computer-readable storage medium having stored therein a computer program which, when executed by a processor, implements the method steps of any 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 schematic diagram of an SMR disk logically divided into regions according to an embodiment of the present application;
FIG. 4 is a first flowchart of a method for writing a logical resource to an SMR disk according to embodiments of the present application;
FIG. 5 is a flowchart of writing a second logic resource into a second storage area according to an embodiment of the present application;
FIG. 6 is a second flowchart of a method for writing logical resources to an SMR disk provided in an embodiment of the present application;
FIG. 7 is a flowchart of a method for determining that a location to be written in a first storage area is the same as a starting location of a storage space allocated for a second logical resource according to an embodiment of the present application;
FIG. 8 is a fifth flowchart of a method for writing logical resources to an SMR disk according to embodiments of the present application;
FIG. 9 is a schematic diagram of a storage state of an SMR disk for each logical resource to be stored in an embodiment of the present application;
FIG. 10 is a schematic diagram of a migration manner of each logical resource to be stored in an SMR disk according to an embodiment of the present application;
FIG. 11 is another schematic diagram of a migration manner of each logical resource to be stored in an SMR disk according to an embodiment of the present application;
FIG. 12 is a schematic 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 according to an embodiment of the present application.
Detailed Description
The technical solutions in the present application will be described below with reference to the accompanying drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Hereinafter, the terms "first," "second," and the like 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 defining "a first", "a second", etc. may explicitly or implicitly include one or more such feature.
An SMR disk is a high capacity magnetic disk that employs a new magnetic storage technology. SMR disks use shingled magnetic recording technology where tracks on the disk overlap as do tiles on the roof. The shingled magnetic recording technique allows for very small variations in the manufacturing process of the SMR disk, but can greatly increase the number of tracks accommodated within the same area, thereby increasing the storage density of the disk. In the current world where the data volume is rapidly increased, SMR technology can effectively reduce the storage cost of a magnetic disk with unit capacity, and is a development trend of future high-density magnetic disk storage technology.
FIG. 1 is a schematic diagram of a conventional magnetic recording (conventional magnetic recording, CMR) disk magnetic recording mode, and FIG. 2 is a schematic diagram of an SMR disk magnetic recording mode.
As shown in FIGS. 1 and 2, the tracks of the CMR disk are vertically spaced with spaces between the tracks, and the width of the CMR disk write head is greater than the width of the read head. The SMR disk utilizes the characteristic that the width of a magnetic disk read head is smaller than that of a write head, so that a next magnetic track partially covers a previous magnetic track, the width of a part, which is not covered by the next magnetic track, of the magnetic track is not smaller than that of the read head, and the SMR disk can leave enough reading space for the read head with smaller width, thereby being convenient for random reading. Because the latter magnetic track of SMR disk covers part of former magnetic track, the write head can only write in sequence according to magnetic track sequence when writing data, therefore SMR disk only supports sequential writing, but not random writing, if random writing is carried out, the written data of the next magnetic track will be covered by the written data of the next magnetic track, resulting in the loss of stored data.
An SMR disk typically includes a CMR region and an SMR region. The track distribution of the CMR area is a conventional non-overlapping track distribution, and the CMR area is created to have random writing capability in the CMR area of the SMR disc, so as to record information such as attribute information of the SMR disc, attribute information of data stored in the disc, and the like, so that the CMR area occupies a relatively small proportion of the total capacity of the SMR disc, for example, the CMR area occupies a proportion of typically 1% of the total capacity of the SMR disc, in order to reduce the influence on the storage density of the SMR disc as much as possible. The SMR area is an area of the SMR disk for storing external data to be stored, and the SMR area occupies a relatively large amount of the total capacity of the SMR disk, for example, the SMR area occupies a proportion of typically 99% of the total capacity of the SMR disk to store more external data to be stored, and includes a plurality of storage areas, each of which is physically separated and does not affect each other, the tracks of each of the storage areas are distributed in a shingled manner, the capacity of each storage area is typically 256 megabits, sequential writing of data is only supported in the same storage area, random writing is not supported, and each storage area typically has a write pointer for indicating a position to be currently written in the storage area.
When the client writes the logical resource into the SMR area, if the logical resource created by the client is not an integer multiple of the capacity of the storage area, in order to make the SMR area be effectively utilized, different clients may write the logical resource into the same storage area, for example, the capacity of the storage area is 256 megabits, the client is a camera, and the size of a video shot by the camera is 100 megabits, then 156 megabits remain after 100 megabits of video data shot by the camera are stored in the storage area, and in this case, the video shot by other cameras may be stored in the same storage area. Because only sequential writing is supported in the same storage area of the SMR area, each client storing logical resources in the same storage area needs to sequentially write logical resources to the SMR disk in the order of the allocated space, and thus, when writing logical resources into the SMR disk, the client often needs to wait, so that each client cannot store the created logical resources on the SMR disk in time.
Therefore, the embodiment of the application provides a method and a device for writing logic resources into an SMR disk, so that when different clients write the logic resources into the same storage area of an SMR area, each client can write the logic resources into the SMR disk at the same time, thereby enabling each client to store the logic resources on the SMR disk more timely.
Next, an SMR disk in the embodiment of the present application will be described first.
In this embodiment of the present application, the SMR disc includes an SMR area, where the SMR area includes a first storage area, where the first storage area is used for writing a plurality of logic resources, the plurality of logic resources includes a first logic resource and a second logic resource, and the first logic resource is any one of at least one logic resource that is located before the second logic resource in a writing order.
For example, the first logical resource may be a logical resource whose write order is located before and adjacent to the second logical resource, or may be a logical resource whose write order is located before and not adjacent to the second logical 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 used for writing to 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 in a logic resource created by each client, where the first storage area may be any storage area in the SMR area for writing in a logic resource created by each client.
In this application, the SMR disc may be logically divided into areas, and identification information may be added to each divided area, for example, as shown in fig. 3, an area formed by a storage area that is not used for writing in a logical resource created by each client in the SMR area may be marked as a C area, an area formed by a storage area that is used for writing in a logical resource created by each client in the SMR area may be marked as a D area, and the CMR area may be logically divided to store different types of Data in different partitions, for example, as shown in fig. 3, the CMR area may be divided into a Disk Data Format (DDF) area for recording Disk information, a B area for storing metadata of each logical resource, and an a area for storing other information. In the region division of the SMR region, the divided regions are in units of storage regions, i.e., each region of the SMR region logically divided contains at least one storage region.
Because the SMR disk is mainly used for writing in the logical resources created by each client, the capacity of the D area accounts for the highest proportion of the total capacity of the entire SMR disk, for example, the capacity of the D area may account for 96% -98% of the total capacity of the entire SMR disk, specifically, the capacity of the D area may account for 98% of the total capacity of the entire SMR disk, and the ratio of the D area to the total capacity of the entire SMR disk may also be other relatively large proportion, which is not specifically limited herein. Those skilled in the art may also logically divide the SMR disk into regions in other ways according to actual needs, and the present application is not limited to a specific manner of dividing the regions.
In the application, when the logic resource to be stored needs to be stored in the SMR disc, the device for managing the SMR disc allocates a storage space to the logic resource to be stored according to the usage condition and the space allocation condition of the SMR disc, and after the storage space is allocated, the logic resource to be stored can be stored in the allocated storage space.
The SMR disk in the embodiment of the present application may be any one of a Host Management (HM) SMR disk, a Host Aware (HA) SMR disk, and a Drive Management (DM) SMR disk. The HM SMR disk allows upper software to fully manage sequential write constraints of the SMR disk, and the write behavior is fully controlled by the software, so that the performance is controllable, and the advantages of the SMR disk can be maximally exerted, so, in one embodiment, in order to make the storage of logic resources in the SMR disk more stable, the SMR disk in this application is the HM SMR disk.
The method of writing logical resources to a shingled magnetic recording SMR disk provided by embodiments of the present application is described below.
The execution body of the method for writing the logic resource into the SMR disk provided in the embodiment of the present application may be an electronic device for managing the writing sequence of the SMR disk, where the electronic device may be a device having a computing function, such as a computer, a server, a notebook computer, a processor, or other electronic devices, and the application is not specifically limited.
As shown in fig. 4, the method for writing a logical resource to an SMR disk according to an embodiment of the present application includes the following steps S110 to S120.
S110: it is determined that the first logical resource is writing to the first storage area.
S120: and writing the second logic resource to be stored into a second storage area.
Wherein, the second storage area is: areas of the SMR disk other than the first storage area.
When it is determined that the first logic resource is being written into the first storage area, since the SMR area only allows sequential writing, the second logic resource cannot be written into the first storage area, so that in order to enable the client to write the created logic resource into the SMR disk in time, the retention condition of the logic resource on the client is reduced.
In one embodiment, step S110 may be implemented as follows: and 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 write pointer position of the first storage area may be determined as the position to be written of the first storage area.
Specifically, if the starting position of the storage space allocated for the second logic resource is different from the to-be-written position of the first storage area, the SMR disc may send information of the different writing position to the electronic device, and after receiving the information of the different writing position, the electronic device may determine that the starting position of the storage space allocated for the second logic resource is different from the to-be-written position of the first storage area, and determine that the writing of the second logic resource into the first storage area fails, thereby determining that the first logic resource is being written into the first storage area.
In another embodiment, step S110 may also be implemented as follows: the method includes determining that a logical resource being written to a first storage area is not a second logical resource, and determining that the first logical resource is being written to the first storage area. In this embodiment, it is possible to determine that the logical resource being written to the first storage area is not the second logical resource by checking which logical resource is being written to the first storage area through software implementation.
Optionally, the method may further include the steps of: 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 a disk error, and sending a disk error message to a second client creating the second logic resource. It will be appreciated that, in the case that writing of the second logical resource into the first storage area fails, the starting position of the storage space allocated for the second logical resource and the position to be written into the first storage area should be different, and if the starting position and the position to be written into the first storage area are the same, it is indicated that the disk hardware is in error or damaged, and then the disk error can be determined.
In another embodiment, step S110 may also be implemented as follows: the method comprises the steps of determining that a position to be written in a first storage area is different from a starting position of a storage space allocated for a second logic resource, and determining that the first logic resource is being written in the first storage area. Specifically, the electronic device may determine the write pointer position of the first storage area as the position to be written in the first storage area. In this application, before the second logic resource is written into the first storage area, the electronic device may receive the write pointer position of the first storage area sent by the SMR disc.
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 can be specifically the clients corresponding to two different video acquisition devices of the video monitoring system, and can also be two network disk clients of the network disk storage system. The application scene of the method for writing the logic resource into the SMR disk is different, the types of the clients are different, and the types of the logic resource are also different.
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 with a free storage space in each storage area for writing the logic resource in the SMR area, and selecting a storage space with the space size not smaller than the data size of the second logic resource from the free storage space in the first storage area for writing the second logic resource. Specifically, in order to make the usage rate of the SMR disc higher, the electronic device may select, from the free storage spaces, a storage space having the same size as the second logical resource and located at the forefront for writing in the second logical resource. The free memory space is not used for writing in other logic resources to be stored.
In this embodiment of the present application, after creating a resource, the client may send the size of the created logical resource to the electronic device, and after receiving the size of the logical resource, the electronic device may allocate a storage space for the logical resource according to the size of the resource. For example, after a video is captured by a camera, the size of the captured video may be sent to an electronic device, and the electronic device may allocate 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 logical resource to be stored is a continuous storage space, for example, the starting position of the storage space allocated for the logical resource 2 is the same as the ending position of the storage space allocated for the logical resource 1, and the starting position of the storage space allocated for the logical resource 3 is the same as the 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 simultaneously.
In one embodiment, the SMR disk may further include: the CMR area, the second storage area may include: an area for temporarily storing logical resources to be stored in the CMR area.
Specifically, the second storage area may include the above-mentioned area a. The CMR area may be logically divided according to actual situations by a person skilled in the art, and different types of data may be stored in different divided logical partitions according to actual needs, and the area in the CMR area for temporarily storing the logical resource to be stored may be any one of the logical partitions divided in the CMR area, or any multiple of the partitions. In this embodiment, the second storage area includes an area for temporarily storing the logic resource to be stored in the CMR area, and since the CMR area supports random writing, the second logic resource can be randomly written into the area for temporarily storing the logic resource to be stored in the CMR area, 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 region further includes at least one staging area, where the staging area is: a storage area in the SMR area for temporarily storing logical resources to be stored, the second storage area further comprising: each temporary storage area.
Since the total capacity of the CMR zone is generally smaller than the total capacity of the SMR disk, the total capacity of the CMR zone is also smaller, and a partial area in the CMR zone is also required to store information such as disk information, metadata of logical resources to be stored, and the like, the capacity of an area in the CMR zone for temporarily storing logical resources to be stored is generally smaller, so that the second storage area is also capable of temporarily storing fewer logical resources to be stored. Therefore, in this embodiment, the partial storage area in the SMR area is also used as the second storage area to temporarily store the logic resources to be stored, so that the capacity of the second storage area can be increased, so that the number of 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 stay in the client side is further reduced.
In one embodiment, as shown in fig. 5, step S120 may be implemented as the following steps S121 to S124:
s121: and judging whether the size of the hollow area in the area for temporarily storing the logic resource to be stored in the CMR area is not smaller than the size of the second logic resource.
S122: if the result of the interpretation in step S121 is yes, the second logic resource is written into the area for temporarily storing the logic resource to be stored in the CMR area.
S123: if the result of the step S121 is no, it is determined whether there is a free storage area in each temporary storage area.
S124: if the result of the interpretation in step S123 is yes, the second logic resource is written into the free storage area in each temporary storage area.
If the result of the interpretation in step S123 is no, sending information of the write failure to the second client sending the second logic resource.
Because the CMR area supports random writing and has high space utilization rate, the second logic resource is preferentially written into the CMR area, and when the free area of the area for temporarily storing the logic resource to be stored in the CMR area is insufficient for storing 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 area can be effectively utilized, and the second logic resource can be written into the SMR disk in time with higher probability.
In one embodiment, the electronic device may count a used space size of an area for temporarily storing the logical resource to be stored in the CMR area after writing the second logical resource into the area for temporarily storing the logical resource to be stored in the CMR area, and store information indicating the used space size in the DDF area of the CMR area, and may count used storage areas in the temporary storage areas after writing the second logical resource into the free storage areas in the temporary storage areas, and store information indicating the used storage areas 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 service conditions of the temporary storage areas, and after the data are stored in the DDF area, the data can be prevented from losing due to power failure.
In one embodiment, as shown in fig. 6, the above method may further include the following steps S130 to S140:
s130: the position to be written in the first storage area is determined to be the same as the initial position of the storage space allocated for the second logic resource.
S140: the second logical resource is stored to the first storage area.
After the fact 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 is determined, the fact that the second logic resource is written in the first storage area is indicated to be the same at the current moment, and the second logic resource stored in the second storage area is stored in the first storage area at the moment, so that the second logic resource can be written in the storage space allocated for the second logic resource.
In an alternative embodiment, before step S130, the following steps may be further included: 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 that the second logic resource is stored in the first storage area, and the second logic resource stored in the second storage area is deleted, i.e. 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 can be 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 starting position of the storage space allocated to the first logic resource created by the first client, which indicates that it is time for the first logic resource to write in the first storage area, and at this time, the first logic resource stored in the second storage area is stored in the first storage area, so that the first logic resource can be finally written in the storage space allocated for the first logic resource.
In one embodiment, as shown in fig. 7, step S130 may be implemented as the following steps S131 to S132:
s131: determining that the last logic resource is completely written 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: the position to be written in the first storage area is determined to be the same as the initial position of the storage space allocated for the second logic resource.
In the embodiment of the present application, since the storage space allocated for each logical resource to be stored is a continuous storage space, when it is determined that the last logical resource completes writing in the first storage area, 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 for the second logical resource.
In a specific embodiment, after the second logic resource is stored in the first storage area, a write-completed message may be generated, so that whether the second logic resource is stored in the first storage area or not may be timely known, and thus the logic resource to be stored, in which the allocated storage space is located behind the second logic resource, may be timely written into the first storage area.
In this embodiment, by determining the writing completion condition of the last logical resource in the first storage area, it can be more simply determined whether the starting 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 steps of: determining the ordering 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 for the second logic resource, wherein the storage space allocated for each logic resource to be stored is in the first storage area; and determining the logic resource to be stored, the ordering position of which is positioned before the ordering position of the second logic resource and the ordering position of which is adjacent to the ordering position of the second logic resource, as the last logic resource. The present embodiment facilitates determining the last logical resource by ordering the second logical resource.
In one embodiment, the method may further include the steps of: and recording a first state of whether the second logic resource completes writing in the second storage area and a second state of whether the second logic resource completes writing in the first storage area.
Step S130 may be implemented as follows: determining that the first state of the second logic resource is the completed writing, the second state of the second logic resource is the unfinished writing, and the second state of the last logic resource is the completed writing, and storing the second logic resource into the first storage area.
Alternatively, the starting position and the ending position of the storage space allocated for the second logical resource may be recorded, so as to determine the last logical resource according to the recorded position.
The embodiment records the first state and the second state of the second logic resource, and is more convenient for determining the time for storing the second logic resource in the first storage area.
In one embodiment, the method may further include the steps of: the recorded state of each logic resource to be stored is monitored at preset time intervals. The preset time interval may be any time interval of 1 to 5 minutes, or may be other specific time intervals. When the preset time interval is shorter, 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, second state, and start and end locations of the memory allocated for the second logical resource may be stored in an area of the SMR disk other than the first memory area to prevent the electronic device from losing such information when powered down. Specifically, the recorded information of the above-described first state, second state, start position, end position, and the like may be stored in the CMR area, for example, in the DDF area, a area, or 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 disc in time.
Optionally, after the second logical resource is stored in the first storage area, the first state, the second state, and the starting position and the ending position of the storage space allocated for the second logical resource may be deleted. To reduce the footprint of the SMR disk.
In one embodiment, before step S140, the following steps may be further included: determining that the second logical resource completes writing to the second storage area.
According to the embodiment, the second logic resource is stored in the first storage area after the second logic resource is determined to be 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 steps of: and determining that the second logic resource completes writing in the second storage area, and generating a writing completion message for the second logic resource to complete writing in the second storage area. Thus, whether the second logic resource completes writing in the second storage area can be timely known.
In one embodiment, the method may further comprise the steps of: determining that the second logic resource is migrated back to the first storage area from the area for temporarily storing the logic resource to be stored in the CMR area, counting the size of the 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 the temporary storage areas, and storing the counted information in the DDF area.
In one embodiment, before step S140, the method may further include the steps of: 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; step S140 may be implemented as follows: and storing the logic resources stored in the storage position into 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 logical resource from the mapping relationship, and store the logical resource stored in the searched storage location into the searched storage space.
After the mapping relation is established, the second logic resource can be accurately and quickly relocated according to the established mapping relation.
In one 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 power is lost, and after the electronic device is restarted, the mapping relationship in the DDF may be loaded into the memory to be quickly read.
In this embodiment of the present application, after the second logical resource is migrated back to the first storage area, the mapping relationship corresponding to the second logical resource may be deleted from the DDF area, so as to reduce the occupancy rate of the DDF area.
The following describes the solution provided in the present application by means of specific examples.
In this embodiment, the SMR disc includes a CMR area and an SMR area, the CMR area supporting both sequential writing and random writing, and the SMR area supporting only sequential writing. The CMR region comprises a DDF region, a A region and a B region; the CMR area has a 1G-capacity DDF area for storing disc metadata, and the DDF area includes shared space management area, bad block mapping data area, shared space data area and other sections for recording different disc relevant information; the area A 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 capacity of the CMR area accounts for 1% of the capacity of the whole SMR disk; the SMR area comprises a C area and a D area, wherein the C area is also an area 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 an area for writing in each logic resource 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 by each other, and the capacity of each storage area is 256 megabytes.
In this embodiment, as shown in FIG. 8, the method of writing logical resources to a shingled magnetic recording SMR disk 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 to the SMR disk.
S3: if the judgment result of S2 is yes, it is judged that the temporary storage of the logic resource is not required.
S4: if the judgment result of the step S2 is negative, the starting position of the storage space allocated for the second logic resource and the write pointer position of the first storage area are obtained.
S5: and judging whether the write pointer position is consistent with the initial position.
S6: if the judgment result of S5 is yes, information of writing failure is sent to the client.
The second logic resource does not write successfully to the SMR disk, but the write pointer position is consistent with the initial position, which indicates that the hard disk of the SMR disk is wrong, and sends information of writing failure to the client.
S7: if the judgment result of S5 is negative, it is judged that different logic resources need to be written into the first storage area at the same time.
S8: and judging whether the size of the hollow area in the A area 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 disc is X (M), the CMR zone capacity of the SMR disc is 0.01X (M), the DDF zone capacity of the CMR zone is 1X 1024 (M), the CMR zone B zone capacity is 2X 1024 (M), and the CMR zone a zone capacity is: CMR area capacity-B area capacity-DDF area capacity= [0.01X- (2+1) X1024 ] (M), assuming that the CMR area a area has used capacity Y (M) and the size of the second logical resource (the size of space required for temporary storage of the second logical resource) is Z (M), when z= <0.01X- (2+1) X1024-Y, it is determined that the CMR area a area has sufficient capacity to temporarily store the second logical resource. The above (M) is a unit (mega) of capacity.
S9: if the judgment result of S8 is no, it is judged whether there is a free memory area in the C area of the SMR area.
If the result of the determination in step S9 is no, the operation performed in step S6 is performed.
S10: if the judgment result of the step S9 is yes or the judgment result of the step S8 is yes, writing the second logic resource into the area C or the area a, and establishing a mapping relation.
The mapping relationship 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 second storage area is an area A or an area C.
For example, as shown in fig. 9, if the logic resource 1 is being written into the first storage area at the present time, at this time, if the logic resource 2 and the logic resource 3 also want to be written into the first storage area, then the logic resource 2 may be written into the free area of the a area first, and after the logic resource 2 is written into the a area, the a area has no free area, and the logic resource 3 may be written into the free storage area of the C area. Wherein, "1", "2", and "3" are respectively: identification information of logical resource 1, logical resource 2, and logical resource 3. And then establishing the mapping relation between the storage position of the identification information of 2 and the logic resource 2 in the area A and the storage space allocated for the logic resource 2, and establishing the mapping relation between the storage position of the identification information of 3 and the logic resource 3 in the area C and the storage space allocated for the logic resource 3. Logical resource 1, logical resource 2, and logical resource 3 are 3 logical resources to be stored created by 3 clients, respectively.
S11: and storing the established mapping relation in the DDF area.
S12: information of the size of the space used by the a area and information of the storage area used by the C area are stored in the DDF area.
S13: and receiving a first writing completion message sent by the SMR disk after the second logic resource completes writing in the A area or the C area.
S14: it is determined whether a first complete write message is received.
S15: if the judgment result of the step S14 is yes, the first state of the second logic resource which is written in the second storage area is recorded as the writing completion, the starting position and the ending position of the storage space allocated for the second logic resource are recorded, the recorded information is stored in the DDF area, and the ordering position of the second logic resource in each logic resource to be stored is determined according to the starting position or the ending position.
If the judgment result of S14 is no, S13 is executed.
S16: and receiving a second writing completion message sent by the SMR disk after the second logic resource completes writing in the first storage domain.
S17: it is determined whether a second complete write message is received.
S18: if the judgment result of S17 is yes, the second state of the second logic resource which completes writing in the first storage area is recorded as the completion writing.
If the determination at S17 is negative, S16 is executed.
S19: and determining whether the data returning 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, when the first state of the second logical resource is the completion of writing, the second state of the second logical resource is the incompletion of writing, and the second state of the last logical resource is the completion of writing, it may be determined that the data migration condition is satisfied.
S20: if the judgment result of S19 is yes, the second logic resource in the second storage area is migrated back to the first storage area.
For example, as shown in fig. 10, after the writing of the logic resource 1 is completed in the first storage area and the writing of the logic resource 2 is completed in the area a, the logic resource 2 in the area a may be migrated back to the first storage area, and the logic resource 2 in the area a is cleared. As shown in fig. 11, after the writing of the logical resource 2 is completed in the first storage area and the writing of the logical resource 3 is completed in the C area, the logical resource 3 in the C area is migrated back to the first storage area.
If the determination at S19 is negative, steps S13 and S16 are executed.
S21: the above-described mapping relation in the DDF area is deleted, the information recorded in step S15 in the DDF area is deleted, and the information of the used space size of the a area and the information of the used storage area of the C area recorded in the DDF area are updated.
The embodiment of the present application further provides an apparatus for writing a logic 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 writing a plurality of logic resources, the plurality of logic resources includes a first logic resource and a second logic resource, and the first logic resource is any one of at least one logic resource that is written in a sequence before the second logic resource, and the apparatus includes:
a write determining unit 1310, configured to determine that the first logical resource is being written to the first storage area;
a data writing unit 1320, configured to write the second logical resource to be stored in 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 logical resource;
and the data returning unit is used for storing the second logic resource to the first storage area.
In an alternative embodiment, the ending position of the storage space allocated for the first logic resource is the same as the starting position of the storage space allocated for the second logic resource;
the position determining unit is specifically configured to: and determining that the first logic resource finishes writing into the first storage area, and determining that the position to be written into 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 the writing completion determining unit is used for determining that the second logic resource completes writing into the second storage area.
In an alternative embodiment, the apparatus further comprises:
the mapping establishing unit is used for 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 data returning unit is specifically configured to: and storing the logic resources stored in the storage position into the storage space according to the mapping relation.
In an alternative embodiment, the writing determining unit is specifically configured to: 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 an alternative embodiment, the SMR disk further comprises: a conventional magnetic recording CMR zone, the second storage region comprising: and the CMR area is used for temporarily storing the area of the logic resource to be stored.
In an alternative embodiment, the SMR region further comprises at least one staging area, the staging area being: a storage area in the SMR area for temporarily storing logical resources to be stored, the second storage area further including: each temporary storage area.
In an alternative embodiment, the data writing unit includes:
a first area judging subunit for judging whether the size of an empty area in the area for temporarily storing the logic resource to be stored in the CMR area is not smaller than the size of the second logic resource;
a first data writing subunit, configured to write, when the determination result of the first area determination subunit is yes, the second logical resource into an area for temporarily storing a logical resource to be stored in the CMR area;
a second storage area judging subunit, configured to judge whether an idle storage area exists in each temporary storage area when the judging result of the first area judging subunit is no;
And the second data writing subunit is used for writing the second logic resource into the idle storage area in each temporary storage area when the judging result of the second storage area judging subunit is yes.
In response to the above method for writing logical resources to an SMR disk, an embodiment of the present application further provides an electronic device, as shown in fig. 13, where the electronic device includes 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 perform communication with each other through the communication bus 1104,
a memory 1403 for storing a computer program;
a processor 1401, when executing a program stored in a memory 1403, implements the method for writing a logical resource to an SMR disk according to any of the above embodiments.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, pi) bus or an extended industry standard architecture (Extended Industry Sandard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include 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 aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
Corresponding to the above method for writing a logical resource to an SMR disk, an embodiment of the present invention further provides a computer readable storage medium, where the computer program, when executed by a processor, implements the method for writing a logical resource to an SMR disk according to any of the above embodiments.
Corresponding to the above method for writing a logical resource to an SMR disk, an embodiment of the present invention further provides a computer program product containing instructions, which when run on a computer, cause the computer to perform the method for writing a logical resource to an SMR disk according to any of the above embodiments.
It should be understood that the foregoing is only intended to assist those skilled in the art in better understanding the embodiments of the present application and is not intended to limit the scope of the embodiments of the present application. Various equivalent modifications and changes will be apparent to those skilled in the art from the foregoing examples, or the combination of any two or more of the foregoing embodiments may be made. Such modifications, variations, or combinations are also within the scope of embodiments of the present application.
It should also be understood that the foregoing description of embodiments of the present application focuses on highlighting differences between the various embodiments and that the same or similar elements not mentioned may be referred to each other and are not described in detail herein for brevity.
It should also be understood that the manner, condition, class and division of the embodiments in the embodiments of the present application are for convenience of description only and should not be construed as being particularly limited, and the various manners, classes, conditions and features of the embodiments may be combined without contradiction.
It is also to be understood that in the various embodiments of the application, terms and/or descriptions of the various embodiments are consistent and may be referenced to one another in the absence of a particular explanation or logic conflict, and that the features of the various embodiments may be combined to form new embodiments in accordance with their inherent logic relationships.
The foregoing is merely a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes and substitutions are intended to be covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (11)

1. A method of writing logical resources to an SMR disk, wherein the SMR disk includes an SMR zone, the SMR zone including a first storage area, wherein the first storage area is configured to be written to by a plurality of logical resources, the plurality of logical resources including 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 to in sequence before the second logical resource, the method comprising:
determining that the first logical resource is being written 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;
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;
And storing the second logic resource to the first storage area.
2. The method of claim 1, wherein the determining that the location of the first storage area to be written is the same as a starting location of the storage space allocated for the second logical resource comprises:
determining that the last logic resource is completely written 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 initial position of the storage space allocated for the second logic resource.
3. The method of claim 1, wherein prior to said storing the second logical resource to the first storage region, the method further comprises:
and determining that the second logic resource finishes writing into the second storage area.
4. The method of claim 1, wherein prior to storing the second logical resource to the first storage region, 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 resources stored in the storage position into the storage space according to the mapping relation.
5. The method of claim 1, wherein the determining that the first logical resource is writing to the first storage area comprises:
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 into the first storage area;
determining that the first logical resource is being written to the first storage area.
6. The method of claim 1, wherein the SMR disk further comprises: a conventional magnetic recording CMR zone, the second storage region comprising: and the CMR area is used for temporarily storing the area of the logic resource to be stored.
7. The method of claim 6, wherein the SMR region further comprises at least one staging area, the staging area being: a storage area in the SMR area for temporarily storing logical resources to be stored, the second storage area further including: each temporary storage area.
8. The method of claim 7, wherein the writing the second logical resource to be stored to a second storage area comprises:
judging whether the size of a hollow area in the CMR area for temporarily storing the logic resource to be stored is not smaller than the size of the second logic resource;
if not, writing the second logic resource into an area for temporarily storing the logic resource to be stored in the CMR area;
if the data is smaller than the data, judging whether an idle storage area exists in each temporary storage area;
and if the free storage area exists, writing the second logic resource into the free storage area in each temporary storage area.
9. An apparatus for writing logical resources to an SMR disk, wherein the SMR disk includes an SMR region, the SMR region including a first storage region, wherein the first storage region is configured to be written to by a plurality of logical resources, the plurality of logical resources including 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 comprising:
a write determining unit configured to determine that the first logical resource is being written to the first storage area;
The data writing unit is 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;
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 logical resource;
and the data returning unit is used for storing the second logic resource to the first storage area.
10. An electronic device, comprising: the device 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 being adapted to carry out the method steps of any one of claims 1 to 8 when executing a program stored on the memory.
11. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1 to 8.
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 CN114237489A (en) 2022-03-25
CN114237489B true 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)

Families Citing this family (1)

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

Citations (5)

* 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
CN107003809A (en) * 2015-11-27 2017-08-01 华为技术有限公司 A kind of method and storage device of storage device data storage
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

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170124104A1 (en) * 2015-10-31 2017-05-04 Netapp, Inc. Durable file system for sequentially written zoned storage
US10381040B1 (en) * 2018-02-06 2019-08-13 Western Digital Technologies, Inc. Dynamic hybrid shingled magnetic recording device

Patent Citations (5)

* 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
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
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

Also Published As

Publication number Publication date
CN114237489A (en) 2022-03-25

Similar Documents

Publication Publication Date Title
US11853549B2 (en) Index storage in shingled magnetic recording (SMR) storage system with non-shingled region
CN111506251B (en) Data processing method and device, SMR storage system and storage medium
US8074041B2 (en) Apparatus, system, and method for managing storage space allocation
US7136977B2 (en) Backup acquisition method and disk array apparatus
CN107291399B (en) Back-end storage method, device and system based on SPDK
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
CN113568582B (en) Data management method, device and storage equipment
CN109240607B (en) File reading method and device
US20200133810A1 (en) Method for managing multiple disks, electronic device and computer program product
CN113495889B (en) Distributed object storage method and device, electronic equipment and 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
CN114237489B (en) Method and device for writing logic resources into SMR disk, electronic equipment and storage medium
CN111309245A (en) Layered storage writing method and device, reading method and device and system
CN109144403B (en) Method and equipment for switching cloud disk modes
CN113434470B (en) Data distribution method and device and electronic equipment
CN109753224B (en) Storage structure and storage structure configuration method
CN109542800A (en) Method, solid state hard disk and the storage device of garbage disposal based on flash memory
CN108646987A (en) A kind of management method of file volume, device, storage medium and terminal
US7752405B2 (en) Data recording apparatus, program product, and data recording method
CN111221468A (en) Storage block data deleting method and device, electronic equipment and cloud storage system
CN112181277B (en) Data storage space management method and device, storage medium and electronic equipment
CN109508140B (en) Storage resource management method and device, electronic equipment and system
CN112433669A (en) Method, system, equipment and medium for online migration of distributed storage volume

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