CN107229414B - Storage space recovery method and device - Google Patents

Storage space recovery method and device Download PDF

Info

Publication number
CN107229414B
CN107229414B CN201610175965.3A CN201610175965A CN107229414B CN 107229414 B CN107229414 B CN 107229414B CN 201610175965 A CN201610175965 A CN 201610175965A CN 107229414 B CN107229414 B CN 107229414B
Authority
CN
China
Prior art keywords
segment
data
identifier
linked list
target
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
CN201610175965.3A
Other languages
Chinese (zh)
Other versions
CN107229414A (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.)
Hangzhou Hikvision Digital Technology Co Ltd
Original Assignee
Hangzhou Hikvision Digital Technology 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 Hangzhou Hikvision Digital Technology Co Ltd filed Critical Hangzhou Hikvision Digital Technology Co Ltd
Priority to CN201610175965.3A priority Critical patent/CN107229414B/en
Publication of CN107229414A publication Critical patent/CN107229414A/en
Application granted granted Critical
Publication of CN107229414B publication Critical patent/CN107229414B/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/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0647Migration mechanisms
    • 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/0608Saving storage space on 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

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)

Abstract

The embodiment of the invention provides a storage space recovery method and device. Wherein, the method comprises the following steps: when a preset space recovery condition is met, determining a target data block with an identifier to be recovered, wherein the identifier to be recovered is as follows: an identification set for data blocks having a full block identification and a space utilization below a predetermined utilization threshold; generating an occupied segment linked list and an idle segment linked list, wherein the idle segment linked list comprises: the segment identifier corresponding to the data segment with the deletion identifier occupies the segment linked list and comprises: segment identifiers corresponding to the data segments meeting the preset occupation conditions, wherein the preset occupation conditions are as follows: the data segment has no deletion identification, and the segment start offset is greater than the minimum value in the segment start offsets of the data segments covered by the idle segment linked list; performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list; and updating the target data block with the data in the block migrated to be the data block with the space recovery completed. By the scheme, the large movement amount of the data can be reduced, and the utilization rate of the storage resources can be improved.

Description

Storage space recovery method and device
Technical Field
The invention relates to the technical field of space recovery, in particular to a storage space recovery method and device.
Background
Data storage is one of the main forms of data processing, where certain types of data are stored in data blocks, such as: video surveillance data, and the like. In the case of storing data in a data block, after the data block is subjected to transaction processing, more or less holes may occur, and particularly, when the data block is stored in an additional writing manner (i.e., when data is written, data is written after an offset starts from the end of a used space), for a data block (full block) which is once fully written, even if a part of data content in the data block is deleted, the space occupied by the deleted data content cannot be used again, thereby causing resource waste. In order to make the storage space fully utilized, the storage space needs to be recycled.
In the existing storage space recovery method, a data block is taken as a unit when the storage space is recovered, and the storage space of another data block needs to be occupied to complete data migration. Although the prior art realizes the recycling of the storage space, the amount of data movement is large and the utilization rate of the storage resource is low due to the need of occupying additional storage space.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for recovering a storage space, so as to solve the problems of a large amount of data movement and a low utilization rate of storage resources in the prior art. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a storage space recycling method, including:
when a preset space recovery condition is met, determining a target data block with an identifier to be recovered, wherein the identifier to be recovered is as follows: an identifier set for a data block having a full block identifier and a space utilization below a predetermined utilization threshold, the full block identifier being: an identifier set for a data block whose available free capacity is smaller than the minimum data packet unit, where the available free capacity is: the capacity of space in which data can be written;
generating an occupied segment linked list and an idle segment linked list corresponding to the target data block, wherein the target data block comprises a plurality of data segments formed based on data storage operation and/or data deletion operation, and the idle segment linked list comprises: the segment identifier corresponding to the data segment having the deletion identifier in the target data block, where the occupied segment linked list includes: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment list has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment list, and the deletion identifier is as follows: an identifier set to the data segment of the deleted data;
performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
and updating the target data block with the data in the block migrated to a data block with the space recovery completed.
Optionally, the generating the occupied segment linked list and the idle segment linked list corresponding to the target data block includes:
according to the rule that the segment identification in the linked list conforms to the ascending sorting of the segment initial offset, constructing an occupied segment linked list and an idle segment linked list corresponding to the target data block;
the executing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list includes:
selecting a segment identifier belonging to the current linked list initial point from the idle segment linked list as a target segment identifier to be processed;
executing data migration aiming at the data segment corresponding to the target segment identification based on the space size of the data segment corresponding to the target segment identification and the space size of the data segment corresponding to the middle segment identification of the occupied segment linked list;
and after the execution is finished and the data of the data segment corresponding to the target segment identifier is migrated, judging whether the occupied segment linked list has the segment identifier currently, if so, returning to execute the step of selecting the segment identifier belonging to the initial point of the current linked list from the idle segment linked list as the target segment identifier to be processed.
Optionally, the executing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list includes:
initializing the idle segment linked list and the occupied segment linked list according to the rule that segment identifiers in the linked list accord with ascending order of segment initial offset;
selecting a segment identifier belonging to the current linked list initial point from the idle segment linked list as a target segment identifier to be processed;
executing data migration aiming at the data segment corresponding to the target segment identification based on the space size of the data segment corresponding to the target segment identification and the space size of the data segment corresponding to the middle segment identification of the occupied segment linked list;
and after the execution is finished and the data of the data segment corresponding to the target segment identifier is migrated, judging whether the occupied segment linked list has the segment identifier at present, if so, returning to execute the step of initializing the idle segment linked list and the occupied segment linked list according to the rule that the segment identifier in the linked list conforms to the ascending sorting of the segment initial offset.
Optionally, the executing the data migration for the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier in the occupied segment linked list includes:
judging whether at least one segment identifier meeting a preset migration condition exists in the segment identifiers of the occupied segment linked list, wherein the preset migration condition is as follows: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier;
when the judgment result is yes, copying the data content of the data segment corresponding to the at least one segment identifier meeting the preset migration condition to the offset position of the data segment corresponding to the target segment identifier, deleting the target segment identifier from the idle segment linked list after the copying is finished, and transferring the at least one segment identifier meeting the preset migration condition from the occupied segment linked list to the idle segment linked list;
when the judgment result is negative, judging whether the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is larger than the space size of the data segment corresponding to the target segment identifier, if so, dividing the data segment corresponding to the segment identifier to be utilized into sub-data segments, sequentially copying the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, after copying is completed, deleting the identifier to be utilized from the occupied segment linked list, deleting the target segment identifier from the idle segment linked list, modifying the segment initial offset of the data segment corresponding to the target segment identifier, and then adding the target segment identifier into the idle segment linked list again, wherein the segment identifier to be utilized is the segment identifier which belongs to the current linked list initial point in the occupied segment linked list;
otherwise, copying the data content of the data segment corresponding to the segment identifier to be utilized to the data segment corresponding to the target segment identifier, deleting the segment identifier to be utilized from the occupied segment linked list after copying is completed, deleting the target segment identifier from the idle segment linked list, modifying the segment initial offset of the data segment corresponding to the target segment identifier, and then adding the target segment identifier to the idle segment linked list again.
Optionally, the method for recovering a storage space provided in the embodiment of the present invention further includes:
in the process of executing data migration for the data segment corresponding to the target segment identifier, if the addresses of the data segments corresponding to at least two segment identifiers in the idle segment linked list are continuous, merging the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replacing the at least two segment identifiers in the idle segment linked list with the new segment identifier.
Optionally, the method for recovering a storage space provided in the embodiment of the present invention further includes:
in the process of executing data migration of the data segment corresponding to the target segment identification, obtaining a deletion instruction of the data segment in the target data block;
if the data segment to which the deleting instruction aims is being copied, the data segment to which the deleting instruction aims is not recycled in the current round;
if the segment start offset of the data segment for which the delete instruction is directed is greater than the segment start offset of the data segment corresponding to the target segment identifier, transferring the segment identifier of the data segment for which the delete instruction is directed from the occupied segment linked list into the spatial segment linked list;
and if the segment start offset of the data segment targeted by the deleting instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier, the data segment targeted by the deleting instruction is not recycled in the current round.
Optionally, the updating the target data block with the migrated data in the block into a data block with a completed space recycling includes:
and deleting the full block identifier and the identifier to be recovered of the target data block after the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Optionally, before the target data block in which data in the block is migrated is updated to a data block in which space recovery is completed, the method further includes:
modifying the mark to be recovered of the target data block into a recovering mark;
the updating the target data block with the migrated data in the block into a data block with the completed space recovery includes:
and deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is completely migrated, and updating the available space capacity and the space utilization rate of the target data block.
Optionally, when a predetermined space reclamation condition is satisfied, determining a target data block with an identifier to be reclaimed includes:
and when detecting that the current system service IO load is smaller than a preset service load value, determining the target data block with the identifier to be recovered.
Optionally, the method for recovering a storage space provided in the embodiment of the present invention further includes:
and when detecting that the current system service IO load is not less than the preset service load value, ending the recovery process.
Optionally, the determining method of the predetermined traffic load value includes:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
and taking the average value as a preset traffic load value.
Optionally, when a predetermined space reclamation condition is satisfied, determining a target data block with an identifier to be reclaimed includes:
and when the utilization rate of the system storage space reaches a preset utilization rate threshold value, determining the target data block with the mark to be recycled.
In a second aspect, an embodiment of the present invention provides a storage space recycling apparatus, including:
a target data block determination module, configured to determine a target data block with an identifier to be recovered when a predetermined space recovery condition is met, where the identifier to be recovered is: an identifier set for a data block having a full block identifier and a space utilization below a predetermined utilization threshold, the full block identifier being: an identifier set for a data block whose available free capacity is smaller than the minimum data packet unit, where the available free capacity is: the capacity of space in which data can be written;
a linked list generating module, configured to generate an occupied segment linked list and an idle segment linked list corresponding to the target data block, where the target data block includes multiple data segments formed based on a data storage operation and/or a data deletion operation, and the idle segment linked list includes: the segment identifier corresponding to the data segment having the deletion identifier in the target data block, where the occupied segment linked list includes: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment list has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment list, and the deletion identifier is as follows: an identifier set to the data segment of the deleted data;
the intra-block data migration module is used for executing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
and the target data block processing module is used for updating the target data block with the data in the block migrated completely into a data block with the space recovery completed.
Optionally, the linked list generating module includes:
the linked list generating unit is used for constructing an occupied segment linked list and an idle segment linked list corresponding to the target data block according to the rule that segment identification in the linked list accords with ascending order of segment initial offset;
the intra-block data migration module comprises:
a target segment identifier determining unit, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
the data migration unit is used for executing data migration aiming at the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier of the occupied segment linked list;
and the first section identification judging unit is used for judging whether the occupied section linked list has the section identification at present after the execution of the data migration aiming at the data section corresponding to the target section identification is finished, and if so, returning to execute the target section identification determining unit.
Optionally, the intra-block data migration module includes:
the initialization unit is used for initializing the generated idle segment linked list and the occupied segment linked list according to the rule that the segment identification in the linked list conforms to the ascending sorting of the segment initial offset before the intra-block data migration of the target data block is executed by the intra-block data migration module based on the idle segment linked list and the occupied segment linked list;
a target segment identifier determining unit, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
the data migration unit is used for executing data migration aiming at the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier of the occupied segment linked list;
and the second section identification judging unit is used for judging whether the occupied section linked list has the section identification at present after the execution of the data migration aiming at the data section corresponding to the target section identification is finished, and if so, returning to execute the initialization unit.
Optionally, the data migration unit includes:
a first occupied segment linked list judging subunit, configured to judge whether at least one segment identifier meeting a predetermined migration condition exists in segment identifiers of the occupied segment linked list, where the predetermined migration condition is: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier;
the first processing subunit is configured to, when the determination result is yes, copy the data content of the data segment corresponding to the at least one segment identifier that meets the predetermined migration condition to the offset position of the data segment corresponding to the target segment identifier, delete the target segment identifier from the idle segment linked list after the copy is completed, and transfer the at least one segment identifier that meets the predetermined migration condition from the occupied segment linked list to the idle segment linked list;
the second occupied section linked list judging subunit is used for judging whether the space size of the data section corresponding to the section identifier to be utilized in the occupied section linked list is larger than the space size of the data section corresponding to the target section identifier or not when the judgment result is negative, if so, the second processing subunit is triggered, and if not, the third processing subunit is triggered;
the second processing subunit is configured to divide the data segment corresponding to the segment identifier to be utilized into sub-data segments, sequentially copy the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, delete the identifier to be utilized from the occupied segment linked list after copying is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and add the target segment identifier to the idle segment linked list again, where the segment identifier to be utilized is a segment identifier belonging to a current linked list start point in the occupied segment linked list;
and the third processing subunit is configured to copy the data content of the data segment corresponding to the segment identifier to be utilized to the data segment corresponding to the target segment identifier, delete the segment identifier to be utilized from the occupied segment linked list after the copy is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and add the target segment identifier to the idle segment linked list again.
Optionally, the storage space recycling device provided in the embodiment of the present invention further includes:
and a segment identifier merging module, configured to, in a process of executing data migration for a data segment corresponding to the target segment identifier, if addresses of data segments corresponding to at least two segment identifiers in the idle segment linked list are consecutive, merge the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replace the at least two segment identifiers in the idle segment linked list with the new segment identifier.
Optionally, the storage space recycling device provided in the embodiment of the present invention further includes:
a deletion instruction obtaining module, configured to obtain a deletion instruction for a data segment in the target data block in a process of performing data migration for the data segment corresponding to the target segment identifier;
the first deleting instruction response module is used for not recycling the data segment corresponding to the deleting instruction in the current round if the data segment corresponding to the deleting instruction is being copied;
a second deletion instruction response module, configured to transfer the segment identifier of the data segment to which the deletion instruction is directed from the occupied segment linked list to the spatial segment linked list if the segment start offset of the data segment to which the deletion instruction is directed is greater than the segment start offset of the data segment to which the target segment identifier corresponds;
and the third deletion instruction response module is used for not recycling the data segment corresponding to the deletion instruction in the current round if the segment start offset of the data segment corresponding to the deletion instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier.
Optionally, the target data block processing module includes:
and the first target data block processing unit is used for deleting the full block identifier and the identifier to be recovered of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Optionally, the storage space recycling device provided in the embodiment of the present invention further includes:
the identification changing module is used for changing the identification to be recovered of the target data block into the identification being recovered before the target data block with the data in the block migrated is updated into the data block with the space recovery completed;
the target data block processing module comprises:
and the second target data block processing unit is used for deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Optionally, the target data block determining module includes:
the first target data block determination unit is used for determining a target data block with an identifier to be recovered when the current system service IO load is detected to be smaller than a preset service load value.
Optionally, the storage space recycling device provided in the embodiment of the present invention further includes:
and the end triggering module is used for ending the recovery process when detecting that the current system service IO load is not less than the preset service load value.
Optionally, the determining method of the predetermined traffic load value includes:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
and taking the average value as a preset traffic load value.
Optionally, the target data block determining module includes:
and the second target data block determining unit is used for determining the target data block with the mark to be recycled when the utilization rate of the system storage space reaches a preset utilization rate threshold value.
In the embodiment of the invention, when a preset space recovery condition is met, a target data block with an identifier to be recovered is determined; generating an occupied segment linked list and an idle segment linked list corresponding to the target data block; performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list; and updating the target data block with the data in the block migrated to a data block with the completed space recovery. Therefore, according to the scheme, the data block to be recovered is migrated in the block, and compared with the mode that the extra storage space is occupied in the prior art, the data migration method can reduce the data movement amount and improve the storage resource utilization rate.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a first flowchart of a storage space recycling method according to an embodiment of the present invention;
FIG. 2 is a second flowchart of a method for reclaiming storage space according to an embodiment of the present invention;
FIG. 3 is a third flowchart of a storage space reclamation method according to an embodiment of the present invention;
fig. 4 is a flowchart of data migration of a data segment corresponding to a target segment identifier in the storage space recovery method according to the embodiment of the present invention;
FIG. 5 is a block diagram illustrating intra-block data migration according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a first structure of a storage space recycling apparatus according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a second structure of a storage space recycling apparatus according to an embodiment of the present invention;
FIG. 8 is a schematic diagram illustrating a third structure of a storage space recycling apparatus according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a fourth structure of the storage space recycling device according to the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 order to solve the problems of large data movement amount and low storage resource utilization rate in the prior art, embodiments of the present invention provide a storage space recovery method and apparatus, so as to achieve reduction of data migration amount and improvement of storage resource utilization rate through an internal data migration manner.
First, a method for recovering a storage space according to an embodiment of the present invention is described below.
It should be emphasized that the execution subject of the storage space recycling method provided by the embodiment of the present invention may be a storage space recycling apparatus, where the storage space recycling apparatus may be a data storage system independent of the data storage system responsible for storing data, or may be a functional module inside the data storage system responsible for storing data, which is reasonable. In addition, the data stored in the data block according to the embodiment of the present invention may be video monitoring data, or may be other data, and the writing format of the data block may be additionally written, or another writing format in which a hole appears after the data block is subjected to business processing, where the additionally written format specifically refers to: when writing data, the offset writes the data back from the end of the used space.
As shown in fig. 1, the method for recovering a storage space according to an embodiment of the present invention may include the following steps:
s101, when a preset space recovery condition is met, determining a target data block with an identifier to be recovered;
the storage space recovery device can detect whether a preset space recovery condition is met or not in real time or at regular time, and when the preset space recovery condition is met, a target data block with an identifier to be recovered is determined, and then storage space recovery is carried out on the target data block subsequently; of course, it is also reasonable that the predetermined space reclamation condition may be detected by the data storage system in real time or at regular time, and when it is detected that the predetermined space reclamation condition is satisfied, a trigger notification is sent to the storage space reclamation apparatus, and then, the storage space reclamation apparatus performs determination of the target data block having the identifier to be reclaimed after receiving the trigger notification. Wherein, the mark to be recovered is: an identification set for a data block having a full block identification and a space utilization below a predetermined utilization threshold, the full block identification being: an identifier set for a data block whose available free capacity is smaller than the minimum packet unit, where the available free capacity is: the amount of space in which data can be written. It can be understood that the space utilization of the data block is: storing the ratio of the space size of the data to the total space size of the data segment; moreover, when a predetermined space reclamation condition is satisfied, there may be a plurality of data blocks having an identifier to be reclaimed, and each data block having an identifier to be reclaimed may be used as a target data block, that is, each data block having an identifier to be reclaimed realizes storage space reclamation according to the storage space reclamation method provided by the embodiment of the present invention.
It is emphasized that for the storage space reclamation apparatus to be independent of the data storage system: in one implementation manner, the data storage system may monitor and record the available free capacity and the space utilization rate of each data block, and set a full block identifier and a to-be-recovered identifier for a data block that meets the requirements, specifically, the monitoring and recording of the available free capacity, the monitoring and recording of the space utilization rate, the setting of the full block identifier, and the setting of the to-be-recovered identifier may be implemented by one or more functional modules in the data storage system; in another implementation, the storage space recovery apparatus may monitor and record the available free capacity and the space utilization rate of each data block by itself, and set the full block identifier and the identifier to be recovered for the data block that meets the requirement by itself, or the storage space recovery apparatus may set the full block identifier and the identifier to be recovered for the data block that meets the requirement by itself based on the available free capacity and the space utilization rate of each data block that is monitored and recorded by the data storage system, which is reasonable. And as for the storage space recovery device as a functional module inside the data storage system: in one implementation, one or more functional modules in the data storage system, other than the storage space recovery device, implement monitoring and recording of available free capacity, monitoring and recording of space utilization, setting of full block identifiers and setting of identifiers to be recovered; in another implementation, the storage space recycling device in the data storage system may monitor and record the available free capacity and space utilization rate of each data block, and set the full block identifier and the identifier to be recycled for the data block meeting the requirement by itself, which is reasonable.
Those skilled in the art can understand that, on the premise that the to-be-recovered flag is different from the full block flag, specific values of the to-be-recovered flag and the full block flag may be set according to an actual situation, and the embodiment of the present invention is not limited herein. Also, the predetermined space reclamation conditions may exist in a variety of forms and will be described later with reference to specific embodiments for clarity of the scheme.
S102, generating an occupied segment linked list and an idle segment linked list corresponding to the target data block;
after determining the target data block with the identifier to be recovered, in order to implement data migration within the block, an occupied segment linked list and an idle segment linked list corresponding to the target data block may be generated, and then the data migration within the block is completed subsequently by using the two linked lists. Wherein the target data block includes a plurality of data segments formed based on data storage operations and/or data deletion operations, and the free segment linked list includes: the segment identifier corresponding to the data segment with the deletion identifier in the target data block, wherein the occupied segment linked list comprises: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, and the deletion identifier is as follows: an identification set to the data segment of the deleted data.
Because some data segments without deletion marks do not have idle data segments in front of the data segments without deletion marks and do not have the need of migration, the preset occupation condition is set to include that the segment start offset is larger than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, so that unnecessary migration is avoided, and the migration amount of data is reduced. For example: data segment a with segment start offset 0 is the first data segment in the data block, and assuming that the data segment a does not have a deletion flag, then the data segment a does not need to be migrated during intra-block data migration.
It is understood that for a data block, it can be written many times, so that a plurality of data segments are generated, and similarly, data can be deleted, and the deleted portion can be located in various positions of the data block, such as: a header or a trailer, which also generates a plurality of data segments. Moreover, for the storage space recycling device to be independent of the data storage system, it is reasonable that the deletion identifier can be set by the data storage system or the storage space recycling device; it is reasonable that the deletion flag of the functional module of the data storage system, to which the storage space recovery apparatus belongs, may be set by a functional module other than the storage space recovery apparatus of the data storage system, or may be set by the storage space recovery apparatus. In addition, on the premise that the specific value of the deletion identifier is different from the full block identifier and the identifier to be recovered, the specific value of the deletion identifier is not limited herein.
S103, performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
after generating the free segment linked list and the occupied segment linked list, intra-block data migration may be performed on the target data block based on the free segment linked list and the occupied segment linked list.
For the sake of clear layout of the scheme, detailed description will be given later on executing intra-block data migration on the target data block based on the free segment linked list and the occupied segment linked list, with reference to specific embodiments.
And S104, updating the target data block with the data in the block migrated into the data block with the space recovery completed.
After the migration of the data in the block is completed, the target data block with the migrated data in the block may be updated to a data block with a space recovery completed, so that the data storage system may subsequently perform a data storage operation using the target data block.
In the embodiment of the invention, when a preset space recovery condition is met, a target data block with an identifier to be recovered is determined; generating an occupied segment linked list and an idle segment linked list corresponding to the target data block; performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list; and updating the target data block with the data in the block migrated to a data block with the completed space recovery. Therefore, according to the scheme, the data block to be recovered is migrated in the block, and compared with the mode that the extra storage space is occupied in the prior art, the data migration method can reduce the data movement amount and improve the storage resource utilization rate.
The following describes a storage space recycling method provided by an embodiment of the present invention with reference to a specific embodiment.
It should be emphasized that the execution subject of the storage space recycling method provided by the embodiment of the present invention may be a storage space recycling apparatus, where the storage space recycling apparatus may be a data storage system independent of the data storage system responsible for storing data, or may be a functional module inside the data storage system responsible for storing data, which is reasonable. In addition, the data stored in the data block according to the embodiment may be video monitoring data or other data, and the writing form of the data block may be additionally written, or another writing form in which a hole appears after the data block is subjected to business processing may be used.
As shown in fig. 2, a storage space reclamation method may include the following steps:
s201, when a preset space recovery condition is met, determining a target data block with an identifier to be recovered;
the storage space recovery device can detect whether a preset space recovery condition is met or not in real time or at regular time, and when the preset space recovery condition is met, a target data block with an identifier to be recovered is determined, and then storage space recovery is carried out on the target data block subsequently; of course, it is also reasonable that the predetermined space reclamation condition may be detected by the data storage system in real time or at regular time, and when it is detected that the predetermined space reclamation condition is satisfied, a trigger notification is sent to the storage space reclamation apparatus, and then, the storage space reclamation apparatus performs determination of the target data block having the identifier to be reclaimed after receiving the trigger notification. Wherein, the mark to be recovered is: an identification set for a data block having a full block identification and a space utilization below a predetermined utilization threshold, the full block identification being: an identifier set for a data block whose available free capacity is smaller than the minimum packet unit, where the available free capacity is: the amount of space in which data can be written. It can be understood that the space utilization of the data block is: storing the ratio of the space size of the data to the total space size of the data segment; moreover, when a predetermined space reclamation condition is satisfied, there may be a plurality of data blocks having an identifier to be reclaimed, and each data block having an identifier to be reclaimed may be used as a target data block, that is, each data block having an identifier to be reclaimed realizes storage space reclamation according to the storage space reclamation method provided by the embodiment of the present invention.
Specifically, in an implementation manner, the determining, when a predetermined space reclamation condition is satisfied, a target data block having an identifier to be reclaimed may include:
and when the utilization rate of the system storage space reaches a preset utilization rate threshold value, determining the target data block with the mark to be recycled.
Wherein, in such an implementation, the predetermined usage threshold may be an empirical value.
In another implementation manner, in order to avoid that storage space reclamation affects data services, the determining, when a predetermined space reclamation condition is satisfied, a target data block having an identifier to be reclaimed may include:
and when detecting that the current system service IO load is smaller than a preset service load value, determining the target data block with the identifier to be recovered. The system service IO load is the service data IO throughput in unit time.
In this implementation manner, further, when it is detected that the current system service IO load is not less than the predetermined service load value, the recycling process is ended.
Specifically, the predetermined traffic load value may be an empirical value, or a value determined by a certain calculation method, for example, the determining method of the predetermined traffic load value may include:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
the average value is taken as the predetermined traffic load value.
For example, the predetermined time period may be 24 hours, 48 hours, 72 hours, and the like, and the specific value may be set according to the actual situation, which is not limited herein. In addition, the system traffic IO load within a predetermined period of time may be collected using existing techniques.
It is emphasized that for the storage space reclamation apparatus to be independent of the data storage system: in one implementation manner, the data storage system may monitor and record the available free capacity and the space utilization rate of each data block, and set a full block identifier and a to-be-recovered identifier for a data block that meets the requirements, specifically, the monitoring and recording of the available free capacity, the monitoring and recording of the space utilization rate, the setting of the full block identifier, and the setting of the to-be-recovered identifier may be implemented by one or more functional modules in the data storage system; in another implementation, the storage space recovery apparatus may monitor and record the available free capacity and the space utilization rate of each data block by itself, and set the full block identifier and the identifier to be recovered for the data block that meets the requirement by itself, or the storage space recovery apparatus may set the full block identifier and the identifier to be recovered for the data block that meets the requirement by itself based on the available free capacity and the space utilization rate of each data block that is monitored and recorded by the data storage system, which is reasonable. And as for the storage space recovery device as a functional module inside the data storage system: in one implementation, one or more functional modules in the data storage system, other than the storage space recovery device, implement monitoring and recording of available free capacity, monitoring and recording of space utilization, setting of full block identifiers and setting of identifiers to be recovered; in another implementation, the storage space recycling device in the data storage system may monitor and record the available free capacity and space utilization rate of each data block, and set the full block identifier and the identifier to be recycled for the data block meeting the requirement by itself, which is reasonable.
As can be understood by those skilled in the art, the specific values of the to-be-recovered identifier and the full block identifier may be set according to actual conditions on the premise that the to-be-recovered identifier is different from the full block identifier.
S202, according to the rule that the segment identification in the linked list conforms to the ascending order of segment initial offset, constructing an occupied segment linked list and an idle segment linked list corresponding to the target data block;
after the target data block with the identifier to be recovered is determined, in order to realize data migration in the block and ensure that the data segment with the deletion identifier of the target data block is occupied from front to back, an occupied segment linked list and an idle segment linked list corresponding to the target data block can be constructed according to the rule that the segment identifier in the linked list conforms to the ascending ordering of segment initial offset, and then the data migration in the block is completed by utilizing the two linked lists subsequently. Wherein the target data block includes a plurality of data segments formed based on data storage operations and/or data deletion operations, and the free segment linked list includes: the segment identifier corresponding to the data segment with the deletion identifier in the target data block, wherein the occupied segment linked list comprises: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, and the deletion identifier is as follows: an identification set to the data segment of the deleted data.
Because some data segments without deletion marks do not have idle data segments in front of the data segments without deletion marks and do not have the need of migration, the preset occupation condition is set to include that the segment start offset is larger than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, so that unnecessary migration is avoided, and the migration amount of data is reduced. For example: data segment a with segment start offset 0 is the first data segment in the data block, and assuming that the data segment a does not have a deletion flag, then the data segment a does not need to be migrated during intra-block data migration.
It should be emphasized that, so-called, according to the rule that the segment identifier in the linked list conforms to the ascending order of the segment start offset, the occupied segment linked list and the idle segment linked list corresponding to the target data block are constructed, which means that: when segment identifiers are added into the occupied segment linked list and the idle segment linked list each time, the rule that the segment identifiers in the linked list accord with the ascending ordering of the segment initial offsets is required to be followed, so that the segment initial offsets of the data segments corresponding to the segment identifiers in the linked list formed by adding the segment identifiers each time are in the ascending ordering.
It is understood that for a data block, it can be written many times, so that a plurality of data segments are generated, and similarly, data can be deleted, and the deleted portion can be located in various positions of the data block, such as: a header or a trailer, which also generates a plurality of data segments. Moreover, for the storage space recycling device to be independent of the data storage system, it is reasonable that the deletion identifier can be set by the data storage system or the storage space recycling device; it is reasonable that the deletion flag of the functional module of the data storage system, to which the storage space recovery apparatus belongs, may be set by a functional module other than the storage space recovery apparatus of the data storage system, or may be set by the storage space recovery apparatus. In addition, on the premise that the specific value of the deletion identifier is different from the full block identifier and the identifier to be recovered, the specific value of the deletion identifier is not limited herein.
S203, selecting a segment identifier belonging to the initial point of the current linked list from the idle segment linked list as a target segment identifier to be processed;
in this embodiment, S203 to S205 are specific implementation steps of S103 in the embodiment shown in fig. 1.
When data in a target data block is migrated, the data segment with the deletion identifier of the target data block needs to be ensured to be occupied from front to back, so that the segment identifier belonging to the current linked list starting point can be selected as the target segment identifier to be processed from the idle segment linked list, and the target segment identifier is: and in the idle segment linked list, segment identification with minimum segment initial offset of the corresponding data segment.
S204, executing data migration aiming at the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier of the occupied segment linked list;
specifically, as shown in fig. 4, the executing the data migration for the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier in the occupied segment linked list may include:
s401, judging whether at least one segment identifier meeting a preset migration condition exists in the segment identifiers of the occupied segment linked list, if so, executing S402, otherwise, executing S403;
after the current target data segment is determined, whether at least one segment identifier meeting a preset migration condition exists in the segment identifiers of the occupied segment linked list or not can be judged, and different operations are executed according to different judgment results. Wherein the predetermined migration condition is: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier.
S402, copying the data content of the data segment corresponding to the at least one segment identifier meeting the preset migration condition to the offset position of the data segment corresponding to the target segment identifier, deleting the target segment identifier from the idle segment linked list after copying is finished, and transferring the at least one segment identifier meeting the preset migration condition from the occupied segment linked list to the idle segment linked list;
when judging whether at least one segment identifier meeting the preset migration condition exists in the segment identifiers of the occupied segment linked list, the data migration from the data content of the data segment corresponding to the at least one segment identifier meeting the preset migration condition to the data segment corresponding to the target segment identifier can be directly completed.
S403, judging whether the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is larger than that of the data segment corresponding to the target segment identifier, if so, executing S404, otherwise, executing S405;
when judging that at least one segment identifier meeting the preset migration condition does not exist in the segment identifiers of the occupied segment linked list, whether the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is larger than the space size of the data segment corresponding to the target segment identifier or not can be continuously judged, and different operations are executed according to different judgment results.
The segment identifier to be utilized is a segment identifier belonging to the current linked list starting point in the occupied segment linked list.
S404, dividing the data segment corresponding to the segment identifier to be used into sub-data segments, sequentially copying the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, deleting the identifier to be used from the occupied segment linked list after copying is finished, deleting the target segment identifier from the idle segment linked list, modifying the segment initial offset of the data segment corresponding to the target segment identifier, and adding the target segment identifier into the idle segment linked list again;
when the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is judged to be larger than the space size of the data segment corresponding to the target segment identifier, the data segment corresponding to the segment identifier to be utilized can be divided into sub-data segments according to the space size of the data segment corresponding to the target segment identifier, and then subsequent data migration is executed.
S405, copying the data content of the data segment corresponding to the segment identifier to be used to the data segment corresponding to the target segment identifier, deleting the segment identifier to be used from the occupied segment linked list after copying, deleting the target segment identifier from the idle segment linked list, modifying the segment start offset of the data segment corresponding to the target segment identifier, and then adding the target segment identifier to the idle segment linked list again.
When the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is judged to be not larger than the space size of the data segment corresponding to the target segment identifier, the data content of the data segment corresponding to the segment identifier to be utilized can be directly copied to the data segment corresponding to the target segment identifier. Moreover, modifying the segment start offset of the data segment corresponding to the target segment identifier specifically means: and shifting down the segment start offset of the data segment corresponding to the target segment identifier by the space size of the data segment corresponding to the segment identifier to be utilized.
S205, after the execution is finished and the data migration aiming at the data segment corresponding to the target segment identifier is finished, judging whether the occupied segment linked list has the segment identifier at present, if so, returning to the step S203; otherwise, executing S206;
after the execution of the data migration for the data segment corresponding to the target segment identifier is completed, whether the occupied segment linked list has the segment identifier currently can be judged, and corresponding operation is executed according to the judgment result. When it is determined that the segment identifier does not exist in the occupied segment linked list at present, it indicates that all the data segments capable of being subjected to data migration in the block have been processed, and therefore S206 may be performed; and when judging that the occupied segment linked list currently has the segment identifier, indicating that a data segment capable of being executed with intra-block data migration still exists, therefore, the step of executing S203 to S205 may be returned to. It should be emphasized that, when adding segment identifiers to the idle segment linked list or updating the segment identifiers, it is necessary to ensure that the idle segment linked list follows the rule that the segment identifiers in the linked list conform to the ascending order of the segment start offset.
And in the process of executing the data migration for the data segment corresponding to the target segment identifier, if the addresses of the data segments corresponding to at least two segment identifiers in the idle segment linked list are continuous, merging the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replacing the at least two segment identifiers in the idle segment linked list with the new segment identifier.
S206, the target data block with the data in the block migrated is updated to the data block with the space recovery completed.
After the intra-block data migration is performed on the target data block, the target data block may be updated to a data block whose space recovery is completed, so that the data storage system may subsequently perform a data storage operation using the target data block.
Specifically, in an implementation manner, the updating the target data block with the migrated data in the block to a data block with a completed space reclamation may include:
and deleting the full block identifier and the identifier to be recovered of the target data block after the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Furthermore, in order to better distinguish the target data block in which the intra-block data migration is being performed from other data blocks, before the target data block in which the intra-block data migration is completed is updated to the data block in which the space recovery is completed, the storage space recovery method provided in this embodiment may further include:
modifying the mark to be recovered of the target data block into a recovering mark;
correspondingly, the updating the target data block with the migrated data in the block into a data block with a completed space recycling includes:
and deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Furthermore, the method provided in this embodiment may further include:
in the process of executing data migration of the data segment corresponding to the target segment identification, obtaining a deletion instruction of the data segment in the target data block;
if the data segment to which the deleting instruction aims is being copied, the data segment to which the deleting instruction aims is not recycled in the current round;
if the segment start offset of the data segment corresponding to the deleting instruction is larger than the segment start offset of the data segment corresponding to the target segment identifier, transferring the segment identifier of the data segment corresponding to the deleting instruction from the occupied segment linked list to the spatial segment linked list;
if the segment start offset of the data segment targeted by the delete instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier, the data segment targeted by the delete instruction is not recycled in the current round.
It can be understood that the deletion instruction may be sent to the storage space recovery device by the data storage system when receiving a deletion instruction sent by a user, and for a case that the data segment targeted by the deletion instruction is not recovered in the current round, the data storage system may delete the data segment targeted by the deletion instruction by itself after the current round of recovery is finished.
Therefore, according to the scheme, the data block to be recovered is migrated in the block, and compared with the mode that the extra storage space is occupied in the prior art, the data migration method can reduce the data movement amount and improve the storage resource utilization rate.
A storage space recycling method provided in an embodiment of the present invention is described below with reference to another embodiment.
It should be emphasized that the execution subject of the storage space recycling method provided by the embodiment of the present invention may be a storage space recycling apparatus, where the storage space recycling apparatus may be a data storage system independent of the data storage system responsible for storing data, or may be a functional module inside the data storage system responsible for storing data, which is reasonable. In addition, the data stored in the data block according to the embodiment may be video monitoring data or other data, and the writing form of the data block may be additionally written, or another writing form in which a hole appears after the data block is subjected to business processing may be used.
As shown in fig. 3, a storage space reclamation method may include the following steps:
s301, when a preset space recovery condition is met, determining a target data block with an identifier to be recovered;
wherein, the mark to be recovered is: an identification set for a data block having a full block identification and a space utilization below a predetermined utilization threshold, the full block identification being: an identifier set for a data block whose available free capacity is smaller than the minimum packet unit, where the available free capacity is: the amount of space in which data can be written.
Specifically, in an implementation manner, the determining, when a predetermined space reclamation condition is satisfied, a target data block having an identifier to be reclaimed may include:
and when the utilization rate of the system storage space reaches a preset utilization rate threshold value, determining the target data block with the mark to be recycled.
Wherein, in such an implementation, the predetermined usage threshold may be an empirical value.
In another implementation manner, in order to avoid that storage space reclamation affects data services, the determining, when a predetermined space reclamation condition is satisfied, a target data block having an identifier to be reclaimed may include:
when detecting that the current system service IO load is smaller than a preset service load value, determining a target data block with an identifier to be recovered;
furthermore, when it is detected that the current system service IO load is not less than the predetermined service load value, the recycling process is ended.
Specifically, the predetermined traffic load value may be an empirical value, or a value determined by a certain calculation method, and the specific determination method of the predetermined traffic load value may include:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
the average value is taken as the predetermined traffic load value.
S301 in this embodiment is similar to S201 in the above embodiment, and is not described herein again.
S302, generating an occupied segment linked list and an idle segment linked list corresponding to the target data block;
after determining the target data block with the identifier to be recovered, in order to implement data migration within the block, an occupied segment linked list and an idle segment linked list corresponding to the target data block may be generated. Wherein the target data block includes a plurality of data segments formed based on data storage operations and/or data deletion operations, and the free segment linked list includes: the segment identifier corresponding to the data segment with the deletion identifier in the target data block, wherein the occupied segment linked list comprises: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, and the deletion identifier is as follows: an identification set to the data segment of the deleted data.
Because some data segments without deletion marks do not have idle data segments in front of the data segments without deletion marks and do not have the need of migration, the preset occupation condition is set to include that the segment start offset is larger than the minimum value of the segment start offsets of the data segments covered by the idle segment linked list, so that unnecessary migration is avoided, and the migration amount of data is reduced. For example: data segment a with segment start offset 0 is the first data segment in the data block, and assuming that the data segment a does not have a deletion flag, then the data segment a does not need to be migrated during intra-block data migration.
It is understood that for a data block, it can be written many times, so that a plurality of data segments are generated, and similarly, data can be deleted, and the deleted portion can be located in various positions of the data block, such as: a header or a trailer, which also generates a plurality of data segments. Moreover, for the storage space recycling device to be independent of the data storage system, it is reasonable that the deletion identifier can be set by the data storage system or the storage space recycling device; it is reasonable that the deletion flag of the functional module of the data storage system, to which the storage space recovery apparatus belongs, may be set by a functional module other than the storage space recovery apparatus of the data storage system, or may be set by the storage space recovery apparatus.
S303, initializing the idle segment linked list and the occupied segment linked list according to the rule that segment identifiers in the linked list accord with ascending order of segment initial offset;
in this embodiment, S303 to S306 are specific implementation steps of S103 in the embodiment shown in fig. 1.
After the idle segment linked list and the occupied segment linked list are generated, in the process of executing data migration in the target data block, in order to ensure that the data segment with the deletion identifier of the target data block is occupied from front to back, namely, the idle area and the data area respectively exist in a concentrated mode and the data area is positioned in front of the idle area, therefore, the idle segment linked list and the occupied segment linked list can be initialized according to the rule that the segment identifier in the linked list accords with the ascending ordering of segment initial offset, wherein after the initialization, the initial offset of the data segment corresponding to the segment identifier in the linked list is in the ascending order.
S304, selecting a segment identifier belonging to the initial point of the current linked list from the idle segment linked list as a target segment identifier to be processed;
when data in a block is migrated to a target data block, a segment identifier belonging to a current linked list start point may be selected from the idle segment linked list as a target segment identifier to be processed, where the target segment identifier is: in the idle segment linked list, the segment identifier with the minimum segment starting offset of the corresponding data segment ensures that the data segment with the deletion identifier of the target data block is occupied from front to back.
S305, executing data migration aiming at the data segment corresponding to the target segment identification based on the space size of the data segment corresponding to the target segment identification and the space size of the data segment corresponding to the middle segment identification of the occupied segment linked list;
in this embodiment, S305 is similar to S204 of the above embodiments, and is not described herein again.
S306, after the execution of the data migration of the data segment corresponding to the target segment identifier, judging whether the occupied segment linked list has the segment identifier at present, if so, returning to execute S303, otherwise, executing S307;
after the execution of the data migration for the data segment corresponding to the target segment identifier is completed, whether the occupied segment linked list has the segment identifier currently can be judged, and corresponding operation is executed according to the judgment result. When it is determined that the segment identifier does not exist in the occupied segment linked list currently, it indicates that all the data segments capable of being subjected to data migration in the block have been processed, so S307 may be executed; and when judging that the occupied segment linked list has the segment identifier currently, indicating that a data segment capable of being executed in the block data migration still exists, and because a new segment identifier is added into the idle segment linked list, returning to execute the step S303 and circularly executing the steps from the step S303 to the step S306.
It should be emphasized that, when adding segment identifiers to the idle segment linked list or updating the segment identifiers, it is necessary to ensure that the idle segment linked list follows the rule that the segment identifiers in the linked list conform to the ascending order of the segment start offset.
And in the process of executing the data migration for the data segment corresponding to the target segment identifier, if the addresses of the data segments corresponding to at least two segment identifiers in the idle segment linked list are continuous, merging the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replacing the at least two segment identifiers in the idle segment linked list with the new segment identifier.
S307, the target data block to which the intra-block data migration is completed is updated to a data block to which the space reclamation is completed.
Specifically, in an implementation manner, the updating the target data block with the migrated data in the block to a data block with a completed space reclamation may include:
and deleting the full block identifier and the identifier to be recovered of the target data block after the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Furthermore, in order to better distinguish the target data block in which the intra-block data migration is being performed from other data blocks, before the target data block in which the intra-block data migration is completed is updated to the data block in which the space recovery is completed, the storage space recovery method provided in this embodiment may further include:
modifying the mark to be recovered of the target data block into a recovering mark;
correspondingly, the updating the target data block with the migrated data in the block into a data block with a completed space recycling includes:
and deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Furthermore, in the process of executing data migration of the data segment corresponding to the target segment identification, a deletion instruction for the data segment in the target data block is obtained;
if the data segment to which the deleting instruction aims is being copied, the data segment to which the deleting instruction aims is not recycled in the current round;
if the segment start offset of the data segment corresponding to the deleting instruction is larger than the segment start offset of the data segment corresponding to the target segment identifier, transferring the segment identifier of the data segment corresponding to the deleting instruction from the occupied segment linked list to the spatial segment linked list;
if the segment start offset of the data segment targeted by the delete instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier, the data segment targeted by the delete instruction is not recycled in the current round.
S307 in this embodiment is similar to S206 in the above embodiments, and is not described herein again.
Therefore, according to the scheme, the data block to be recovered is migrated in the block, and compared with the mode that the extra storage space is occupied in the prior art, the data migration method can reduce the data movement amount and improve the storage resource utilization rate.
The following describes a storage space reclamation method provided by an embodiment of the present invention with reference to the schematic diagram of data migration in a block shown in fig. 5.
(1): when the predetermined space recovery condition is met, 7 data segments are determined in the target data block with the identifier to be recovered, specifically, as shown in fig. 5(step1), segment identifiers Seg1, Seg3 and Seg6 are marked with deletion identifiers, and therefore are added to the free segment linked list L1, while segment identifiers Seg2, Seg4, Seg5 and Seg7 are not marked with deletion identifiers, and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the free segment linked list L1, and therefore is added to the occupied segment linked list L2; when the segment identifiers are added into the idle segment linked list L1 and the occupied segment linked list L2, the rule that the segment identifiers in the linked list accord with the ascending ordering of segment initial offset is followed;
(2): for the first segment identifier Seg1 of the free segment linked list L1, the size of the space of the corresponding data segment is exactly equal to the sum of the data segments of the segment identifiers Seg2 and Seg7, the data content of the data segment corresponding to the segment identifiers Seg2 and Seg7 is copied to the offset position of the data segment corresponding to the segment identifier Seg1, at this time, the original space occupied by the data segment corresponding to the segment identifiers Seg2 and Seg7 becomes free, the data segment corresponding to the segment identifier Seg1 is occupied, therefore, the segment identifier Seg1 is deleted from the free segment linked list L1, the segment identifiers Seg2 and Seg7 are deleted from the occupied segment linked list L2, added to the free segment linked list L1, and the data segments corresponding to the segment identifiers Seg6 and Seg7 are merged into a free data segment, and the processing is completed as shown in fig. 5(step 2).
(3): for the current first segment identifier Seg2 in the idle segment linked list L1, if no segment identifier or sum of segment identifiers with the same space size is found in the occupied segment linked list L2, the data content of the data segment corresponding to the current first segment identifier Seg4 in the occupied segment linked list L2 is moved to the offset position of the data segment corresponding to the segment identifier Seg2, but because the space size of the data segment corresponding to the segment identifier Seg4 is larger than that of the data segment corresponding to the segment identifier Seg2, complete copying cannot be performed, the data segment corresponding to the segment identifier Seg4 is segmented according to the size of the data segment corresponding to the segment identifier Seg2, the data segment is copied segment by segment to the offset position of the data segment corresponding to the segment identifier Seg2, after copying is completed, the segment identifier Seg4 is deleted from the occupied segment L2, and the segment identifiers Seg2 and Seg3 are combined into a new segment identifier 895, as shown in fig. 3;
(4): for the first segment identifier Seg2+3 of the idle segment linked list L1, no suitable segment identifier is found in the occupied segment linked list L2, that is, no segment identifier or sum of segment identifiers with the space size equal to that found in the occupied segment linked list L2, the data content of the data segment corresponding to the first segment identifier Seg5 of the occupied segment linked list L2 is shifted to the offset position of the data segment corresponding to the segment identifier Seg2+3, and because the space size of the data segment corresponding to the segment identifier Seg5 is smaller than that of the data segment corresponding to the segment identifier Seg2+3, the data content corresponding to the segment identifier Seg5 is directly and completely copied to the offset position of the data segment corresponding to the segment identifier Seg2+3, the segment start offset of the data segment corresponding to the segment identifier Seg2+3 is shifted down to the space size of the data segment identifier Seg5, and the occupied segment identifiers Seg2, Seg 638, and Seg 638 are merged into one data segment identifier 2, Seg 638 and Seg 638, and forms the segment identity of the merged data segment as shown in fig. 5(step 4).
(5): and the occupied segment linked list L2 has no segment identifier, and the recycling is finished.
It should be noted that, in the target data block shown in fig. 5, different padding contents are used to distinguish between a data segment storing data content and a data segment not storing data content, and the difference is not limited in any way.
Corresponding to the foregoing method embodiment, an embodiment of the present invention further provides a storage space recycling device, and as shown in fig. 6, the device may include:
a target data block determining module 610, configured to determine a target data block having an identifier to be recovered when a predetermined space recovery condition is met, where the identifier to be recovered is: an identifier set for a data block having a full block identifier and a space utilization below a predetermined utilization threshold, the full block identifier being: an identifier set for a data block whose available free capacity is smaller than the minimum data packet unit, where the available free capacity is: the capacity of space in which data can be written;
a linked list generating module 620, configured to generate an occupied segment linked list and an idle segment linked list corresponding to the target data block, where the target data block includes multiple data segments formed based on a data storage operation and/or a data deletion operation, and the idle segment linked list includes: the segment identifier corresponding to the data segment having the deletion identifier in the target data block, where the occupied segment linked list includes: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment list has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment list, and the deletion identifier is as follows: an identifier set to the data segment of the deleted data;
an intra-block data migration module 630, configured to perform intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
and the target data block processing module 640 is configured to update the target data block with the migrated data in the block to a data block with a completed space recovery.
Therefore, according to the scheme, the data block to be recovered is migrated in the block, and compared with the mode that the extra storage space is occupied in the prior art, the data migration method can reduce the data movement amount and improve the storage resource utilization rate.
Specifically, in a specific embodiment, as shown in fig. 7, the linked list generating module 620 may include:
a linked list generating unit 621, configured to construct an occupied segment linked list and an idle segment linked list corresponding to the target data block according to a rule that segment identifiers in a linked list conform to ascending order of segment initial offset;
the intra-block data migration module 630 may include:
a target segment identifier determining unit 631, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
a data migration unit 632, configured to execute data migration for the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier in the occupied segment linked list;
the first segment identifier determining unit 633 is configured to determine whether a segment identifier exists in the occupied segment linked list currently after the execution of the data migration for the data segment corresponding to the target segment identifier is completed, and if so, return to the execution of the target segment identifier determining unit 631.
Specifically, in another specific embodiment, as shown in fig. 8, the intra-block data migration module 630 may include:
an initializing unit 634, configured to initialize the generated idle segment linked list and the occupied segment linked list according to a rule that an identifier of an internal segment in a linked list conforms to ascending order of initial offset of the segment before the intra-block data migration module performs intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
a target segment identifier determining unit 631, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
a data migration unit 632, configured to execute data migration for the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier in the occupied segment linked list;
the second segment identifier determining unit 635 is configured to determine whether a segment identifier exists in the occupied segment linked list currently after the execution of the data migration for the data segment corresponding to the target segment identifier is completed, and if so, return to execute the initializing unit 634.
Further, as shown in fig. 9, the data migration unit 632 may include:
a first occupied segment linked list determining subunit 6321, configured to determine whether at least one segment identifier meeting a predetermined migration condition exists in the segment identifiers of the occupied segment linked list, where the predetermined migration condition is: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier;
a first processing subunit 6322, configured to copy, when a determination result is yes, the data content of the data segment corresponding to the at least one segment identifier that meets the predetermined migration condition to an offset position of the data segment corresponding to the target segment identifier, delete the target segment identifier from the idle segment linked list after the copy is completed, and transfer the at least one segment identifier that meets the predetermined migration condition from the occupied segment linked list to the idle segment linked list;
the second occupied segment linked list judging subunit 6323 is configured to, when the judgment result is negative, judge whether the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is larger than the space size of the data segment corresponding to the target segment identifier, if so, trigger the second processing subunit 6324, and otherwise, trigger the third processing subunit 6325;
the second processing subunit 6324 is configured to divide the data segment corresponding to the segment identifier to be utilized into sub-data segments, sequentially copy the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, delete the identifier to be utilized from the occupied segment linked list after copying is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and then add the target segment identifier to the idle segment linked list again, where the segment identifier to be utilized is a segment identifier belonging to a current linked list start point in the occupied segment linked list;
the third processing subunit 6325 is configured to copy the data content of the data segment corresponding to the segment identifier to be used into the data segment corresponding to the target segment identifier, delete the segment identifier to be used from the occupied segment linked list after the copy is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and add the target segment identifier into the idle segment linked list again.
Furthermore, on the premise that the storage space recovery device includes a first occupied segment linked list determining subunit, a first processing subunit, a second occupied segment linked list determining subunit, a second processing subunit, and a third processing subunit, the storage space recovery device provided in the embodiment of the present invention may further include:
and a segment identifier merging module, configured to, in a process of executing data migration for a data segment corresponding to the target segment identifier, if addresses of data segments corresponding to at least two segment identifiers in the idle segment linked list are consecutive, merge the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replace the at least two segment identifiers in the idle segment linked list with the new segment identifier.
Furthermore, on the premise that the storage space recovery device includes a first occupied segment linked list determining subunit, a first processing subunit, a second occupied segment linked list determining subunit, a second processing subunit, and a third processing subunit, the storage space recovery device provided in the embodiment of the present invention may further include:
a deletion instruction obtaining module, configured to obtain a deletion instruction for a data segment in the target data block in a process of performing data migration for the data segment corresponding to the target segment identifier;
the first deleting instruction response module is used for not recycling the data segment corresponding to the deleting instruction in the current round if the data segment corresponding to the deleting instruction is being copied;
a second deletion instruction response module, configured to transfer the segment identifier of the data segment to which the deletion instruction is directed from the occupied segment linked list to the spatial segment linked list if the segment start offset of the data segment to which the deletion instruction is directed is greater than the segment start offset of the data segment to which the target segment identifier corresponds;
and the third deletion instruction response module is used for not recycling the data segment corresponding to the deletion instruction in the current round if the segment start offset of the data segment corresponding to the deletion instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier.
Specifically, for the embodiment shown in fig. 6, the target data block processing module 640 may include:
and the first target data block processing unit is used for deleting the full block identifier and the identifier to be recovered of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Specifically, on the basis of the embodiment shown in fig. 6, the storage space recycling device provided in the embodiment of the present invention may further include:
the identification changing module is used for changing the identification to be recovered of the target data block into the identification being recovered before the target data block with the data in the block migrated is updated into the data block with the space recovery completed;
the target data block processing module 640 may include:
and the second target data block processing unit is used for deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
Specifically, for the embodiment shown in fig. 6, the target data block determining module 610 may include:
the first target data block determination unit is used for determining a target data block with an identifier to be recovered when the current system service IO load is detected to be smaller than a preset service load value.
Furthermore, on the basis of the embodiment that includes the first target data block determining unit, the storage space recycling apparatus provided in the embodiment of the present invention may further include:
and the end triggering module is used for ending the recovery process when detecting that the current system service IO load is not less than the preset service load value.
Specifically, the determining method of the predetermined traffic load value includes:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
and taking the average value as a preset traffic load value.
Specifically, for the embodiment shown in fig. 6, the target data block determining module 610 may include:
and the second target data block determining unit is used for determining the target data block with the mark to be recycled when the utilization rate of the system storage space reaches a preset utilization rate threshold value.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (24)

1. A method for reclaiming storage space, comprising:
when a preset space recovery condition is met, determining a target data block with an identifier to be recovered, wherein the identifier to be recovered is as follows: an identifier set for a data block having a full block identifier and a space utilization below a predetermined utilization threshold, the full block identifier being: an identifier set for a data block whose available free capacity is smaller than the minimum data packet unit, where the available free capacity is: the capacity of space in which data can be written;
generating an occupied segment linked list and an idle segment linked list corresponding to the target data block, wherein the target data block comprises a plurality of data segments formed based on data storage operation and/or data deletion operation, and the idle segment linked list comprises: the segment identifier corresponding to the data segment having the deletion identifier in the target data block, where the occupied segment linked list includes: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment list has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment list, and the deletion identifier is as follows: an identifier set to the data segment of the deleted data;
performing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
and updating the target data block with the data in the block migrated to a data block with the space recovery completed.
2. The method of claim 1, wherein the generating the occupied segment linked list and the free segment linked list corresponding to the target data block comprises:
according to the rule that the segment identification in the linked list conforms to the ascending sorting of the segment initial offset, constructing an occupied segment linked list and an idle segment linked list corresponding to the target data block;
the executing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list includes:
selecting a segment identifier belonging to the current linked list initial point from the idle segment linked list as a target segment identifier to be processed;
executing data migration aiming at the data segment corresponding to the target segment identification based on the space size of the data segment corresponding to the target segment identification and the space size of the data segment corresponding to the middle segment identification of the occupied segment linked list;
and after the execution is finished and the data of the data segment corresponding to the target segment identifier is migrated, judging whether the occupied segment linked list has the segment identifier currently, if so, returning to execute the step of selecting the segment identifier belonging to the initial point of the current linked list from the idle segment linked list as the target segment identifier to be processed.
3. The method of claim 1, wherein performing intra-block data migration on the target data block based on the free segment linked list and the occupied segment linked list comprises:
initializing the idle segment linked list and the occupied segment linked list according to the rule that segment identifiers in the linked list accord with ascending order of segment initial offset;
selecting a segment identifier belonging to the current linked list initial point from the idle segment linked list as a target segment identifier to be processed;
executing data migration aiming at the data segment corresponding to the target segment identification based on the space size of the data segment corresponding to the target segment identification and the space size of the data segment corresponding to the middle segment identification of the occupied segment linked list;
and after the execution is finished and the data of the data segment corresponding to the target segment identifier is migrated, judging whether the occupied segment linked list has the segment identifier at present, if so, returning to execute the step of initializing the idle segment linked list and the occupied segment linked list according to the rule that the segment identifier in the linked list conforms to the ascending sorting of the segment initial offset.
4. The method according to claim 2 or 3, wherein the performing the data migration for the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the segment identifier in the occupied segment linked list comprises:
judging whether at least one segment identifier meeting a preset migration condition exists in the segment identifiers of the occupied segment linked list, wherein the preset migration condition is as follows: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier;
when the judgment result is yes, copying the data content of the data segment corresponding to the at least one segment identifier meeting the preset migration condition to the offset position of the data segment corresponding to the target segment identifier, deleting the target segment identifier from the idle segment linked list after the copying is finished, and transferring the at least one segment identifier meeting the preset migration condition from the occupied segment linked list to the idle segment linked list;
when the judgment result is negative, judging whether the space size of the data segment corresponding to the segment identifier to be utilized in the occupied segment linked list is larger than the space size of the data segment corresponding to the target segment identifier, if so, dividing the data segment corresponding to the segment identifier to be utilized into sub-data segments, sequentially copying the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, after copying is completed, deleting the segment identifier to be utilized from the occupied segment linked list, deleting the target segment identifier from the idle segment linked list, modifying the segment initial offset of the data segment corresponding to the target segment identifier, and then adding the target segment identifier into the idle segment linked list again, wherein the segment identifier to be utilized is the segment identifier which belongs to the current initial point in the occupied segment linked list;
otherwise, copying the data content of the data segment corresponding to the segment identifier to be utilized to the data segment corresponding to the target segment identifier, deleting the segment identifier to be utilized from the occupied segment linked list after copying is completed, deleting the target segment identifier from the idle segment linked list, modifying the segment initial offset of the data segment corresponding to the target segment identifier, and then adding the target segment identifier to the idle segment linked list again.
5. The method of claim 4, further comprising:
in the process of executing data migration for the data segment corresponding to the target segment identifier, if the addresses of the data segments corresponding to at least two segment identifiers in the idle segment linked list are continuous, merging the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replacing the at least two segment identifiers in the idle segment linked list with the new segment identifier.
6. The method of claim 4, further comprising:
in the process of executing data migration of the data segment corresponding to the target segment identification, obtaining a deletion instruction of the data segment in the target data block;
if the data segment to which the deleting instruction aims is being copied, the data segment to which the deleting instruction aims is not recycled in the current round;
if the segment start offset of the data segment for which the delete instruction is directed is greater than the segment start offset of the data segment corresponding to the target segment identifier, transferring the segment identifier of the data segment for which the delete instruction is directed from the occupied segment linked list to the idle segment linked list;
and if the segment start offset of the data segment targeted by the deleting instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier, the data segment targeted by the deleting instruction is not recycled in the current round.
7. The method of claim 1, wherein the updating the target data block with migrated data in the block into a data block with completed space reclamation comprises:
and deleting the full block identifier and the identifier to be recovered of the target data block after the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
8. The method of claim 1, wherein before the target data block with migrated data in block is updated to a data block with completed space reclamation, the method further comprises:
modifying the mark to be recovered of the target data block into a recovering mark;
the updating the target data block with the migrated data in the block into a data block with the completed space recovery includes:
and deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is completely migrated, and updating the available space capacity and the space utilization rate of the target data block.
9. The method of claim 1, wherein determining the target data block with the identifier to be reclaimed when a predetermined space reclamation condition is satisfied comprises:
and when detecting that the current system service IO load is smaller than a preset service load value, determining the target data block with the identifier to be recovered.
10. The method of claim 9, further comprising:
and when detecting that the current system service IO load is not less than the preset service load value, ending the recovery process.
11. The method according to claim 9 or 10, wherein the predetermined traffic load value is determined in a manner comprising:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
and taking the average value as a preset traffic load value.
12. The method of claim 1, wherein determining the target data block with the identifier to be reclaimed when a predetermined space reclamation condition is satisfied comprises:
and when the utilization rate of the system storage space reaches a preset utilization rate threshold value, determining the target data block with the mark to be recycled.
13. A storage space reclamation apparatus, comprising:
a target data block determination module, configured to determine a target data block with an identifier to be recovered when a predetermined space recovery condition is met, where the identifier to be recovered is: an identifier set for a data block having a full block identifier and a space utilization below a predetermined utilization threshold, the full block identifier being: an identifier set for a data block whose available free capacity is smaller than the minimum data packet unit, where the available free capacity is: the capacity of space in which data can be written;
a linked list generating module, configured to generate an occupied segment linked list and an idle segment linked list corresponding to the target data block, where the target data block includes multiple data segments formed based on a data storage operation and/or a data deletion operation, and the idle segment linked list includes: the segment identifier corresponding to the data segment having the deletion identifier in the target data block, where the occupied segment linked list includes: segment identifiers corresponding to data segments in the target data block that satisfy a predetermined occupation condition, where the predetermined occupation condition is: the data segment list has no deletion identifier and the segment start offset is greater than the minimum value of the segment start offsets of the data segments covered by the idle segment list, and the deletion identifier is as follows: an identifier set to the data segment of the deleted data;
the intra-block data migration module is used for executing intra-block data migration on the target data block based on the idle segment linked list and the occupied segment linked list;
and the target data block processing module is used for updating the target data block with the data in the block migrated completely into a data block with the space recovery completed.
14. The apparatus of claim 13, wherein the linked list generation module comprises:
the linked list generating unit is used for constructing an occupied segment linked list and an idle segment linked list corresponding to the target data block according to the rule that segment identification in the linked list accords with ascending order of segment initial offset;
the intra-block data migration module comprises:
a target segment identifier determining unit, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
the data migration unit is used for executing data migration aiming at the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier of the occupied segment linked list;
and the first section identification judging unit is used for judging whether the occupied section linked list has the section identification at present after the execution of the data migration aiming at the data section corresponding to the target section identification is finished, and if so, returning to execute the target section identification determining unit.
15. The apparatus of claim 13, wherein the intra-block data migration module comprises:
the initialization unit is used for initializing the generated idle segment linked list and the occupied segment linked list according to the rule that the segment identification in the linked list conforms to the ascending sorting of the segment initial offset before the intra-block data migration of the target data block is executed by the intra-block data migration module based on the idle segment linked list and the occupied segment linked list;
a target segment identifier determining unit, configured to select, from the idle segment linked list, a segment identifier that belongs to a starting point of the current linked list as a target segment identifier to be processed;
the data migration unit is used for executing data migration aiming at the data segment corresponding to the target segment identifier based on the space size of the data segment corresponding to the target segment identifier and the space size of the data segment corresponding to the middle segment identifier of the occupied segment linked list;
and the second section identification judging unit is used for judging whether the occupied section linked list has the section identification at present after the execution of the data migration aiming at the data section corresponding to the target section identification is finished, and if so, returning to execute the initialization unit.
16. The apparatus according to claim 14 or 15, wherein the data migration unit comprises:
a first occupied segment linked list judging subunit, configured to judge whether at least one segment identifier meeting a predetermined migration condition exists in segment identifiers of the occupied segment linked list, where the predetermined migration condition is: the space size of the corresponding data segment is equal to the space size of the data segment corresponding to the target segment identifier, or the space size of the combined segment of the corresponding data segments is equal to the space size of the data segment corresponding to the target segment identifier;
the first processing subunit is configured to, when the determination result is yes, copy the data content of the data segment corresponding to the at least one segment identifier that meets the predetermined migration condition to the offset position of the data segment corresponding to the target segment identifier, delete the target segment identifier from the idle segment linked list after the copy is completed, and transfer the at least one segment identifier that meets the predetermined migration condition from the occupied segment linked list to the idle segment linked list;
the second occupied section linked list judging subunit is used for judging whether the space size of the data section corresponding to the section identifier to be utilized in the occupied section linked list is larger than the space size of the data section corresponding to the target section identifier or not when the judgment result is negative, if so, the second processing subunit is triggered, and if not, the third processing subunit is triggered;
the second processing subunit is configured to divide the data segment corresponding to the segment identifier to be utilized into sub-data segments, sequentially copy the data content of the sub-data segments to the offset position of the data segment corresponding to the target segment identifier, delete the segment identifier to be utilized from the occupied segment linked list after copying is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and add the target segment identifier to the idle segment linked list again, where the segment identifier to be utilized is a segment identifier belonging to a current linked list start point in the occupied segment linked list;
and the third processing subunit is configured to copy the data content of the data segment corresponding to the segment identifier to be utilized to the data segment corresponding to the target segment identifier, delete the segment identifier to be utilized from the occupied segment linked list after the copy is completed, delete the target segment identifier from the idle segment linked list, modify the segment start offset of the data segment corresponding to the target segment identifier, and add the target segment identifier to the idle segment linked list again.
17. The apparatus of claim 16, further comprising:
and a segment identifier merging module, configured to, in a process of executing data migration for a data segment corresponding to the target segment identifier, if addresses of data segments corresponding to at least two segment identifiers in the idle segment linked list are consecutive, merge the data segments corresponding to the at least two segment identifiers to form a new segment identifier corresponding to the at least two segment identifiers, and replace the at least two segment identifiers in the idle segment linked list with the new segment identifier.
18. The apparatus of claim 16, further comprising:
a deletion instruction obtaining module, configured to obtain a deletion instruction for a data segment in the target data block in a process of performing data migration for the data segment corresponding to the target segment identifier;
the first deleting instruction response module is used for not recycling the data segment corresponding to the deleting instruction in the current round if the data segment corresponding to the deleting instruction is being copied;
a second deletion instruction response module, configured to transfer the segment identifier of the data segment to which the deletion instruction is directed from the occupied segment linked list to the idle segment linked list if the segment start offset of the data segment to which the deletion instruction is directed is greater than the segment start offset of the data segment to which the target segment identifier corresponds;
and the third deletion instruction response module is used for not recycling the data segment corresponding to the deletion instruction in the current round if the segment start offset of the data segment corresponding to the deletion instruction is smaller than the segment start offset of the data segment corresponding to the target segment identifier.
19. The apparatus of claim 13, wherein the target data block processing module comprises:
and the first target data block processing unit is used for deleting the full block identifier and the identifier to be recovered of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
20. The apparatus of claim 13, further comprising:
the identification changing module is used for changing the identification to be recovered of the target data block into the identification being recovered before the target data block with the data in the block migrated is updated into the data block with the space recovery completed;
the target data block processing module comprises:
and the second target data block processing unit is used for deleting the full block identifier and the recycling identifier of the target data block of which the data in the block is migrated, and updating the available space capacity and the space utilization rate of the target data block.
21. The apparatus of claim 13, wherein the target data block determination module comprises:
the first target data block determination unit is used for determining a target data block with an identifier to be recovered when the current system service IO load is detected to be smaller than a preset service load value.
22. The apparatus of claim 21, further comprising:
and the end triggering module is used for ending the recovery process when detecting that the current system service IO load is not less than the preset service load value.
23. The apparatus according to claim 21 or 22, wherein the predetermined traffic load value is determined by:
collecting system service IO load in a preset time period;
calculating the average value of the collected system service IO loads in the preset time period;
and taking the average value as a preset traffic load value.
24. The apparatus of claim 13, wherein the target data block determination module comprises:
and the second target data block determining unit is used for determining the target data block with the mark to be recycled when the utilization rate of the system storage space reaches a preset utilization rate threshold value.
CN201610175965.3A 2016-03-24 2016-03-24 Storage space recovery method and device Active CN107229414B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610175965.3A CN107229414B (en) 2016-03-24 2016-03-24 Storage space recovery method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610175965.3A CN107229414B (en) 2016-03-24 2016-03-24 Storage space recovery method and device

Publications (2)

Publication Number Publication Date
CN107229414A CN107229414A (en) 2017-10-03
CN107229414B true CN107229414B (en) 2020-01-17

Family

ID=59932014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610175965.3A Active CN107229414B (en) 2016-03-24 2016-03-24 Storage space recovery method and device

Country Status (1)

Country Link
CN (1) CN107229414B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508146B (en) * 2018-10-11 2021-07-23 广西师范大学 Method for recycling periodic storage space of block chain
US10534736B1 (en) 2018-12-31 2020-01-14 Texas Instruments Incorporated Shared buffer for multi-output display systems
CN111949200A (en) * 2019-05-17 2020-11-17 北京兆易创新科技股份有限公司 Memory and control method and control device thereof
CN110647294B (en) * 2019-09-09 2022-03-25 Oppo广东移动通信有限公司 Storage block recovery method and device, storage medium and electronic equipment
CN112667148A (en) * 2020-11-30 2021-04-16 上海七牛信息技术有限公司 Method and system for cluster storage data online migration
CN113641304B (en) * 2021-07-05 2023-10-20 深圳市宏旺微电子有限公司 Method, device, terminal equipment and storage medium for managing data blocks
CN113687774A (en) * 2021-07-19 2021-11-23 锐捷网络股份有限公司 Space recovery method, device and equipment
CN115442388B (en) * 2022-10-21 2023-01-06 四川省华存智谷科技有限责任公司 Capacity expansion method, device and system for 100% utilization rate of distributed storage cluster

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933169A (en) * 2015-06-29 2015-09-23 南开大学 File system defragmentation method based on hotspot file priority
EP2990952A1 (en) * 2014-08-29 2016-03-02 EMC Corporation Method and system for garbage collection in a storage system based on longevity of stored data

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2990952A1 (en) * 2014-08-29 2016-03-02 EMC Corporation Method and system for garbage collection in a storage system based on longevity of stored data
CN104933169A (en) * 2015-06-29 2015-09-23 南开大学 File system defragmentation method based on hotspot file priority

Also Published As

Publication number Publication date
CN107229414A (en) 2017-10-03

Similar Documents

Publication Publication Date Title
CN107229414B (en) Storage space recovery method and device
CN105868122A (en) Data processing method and device for quick flashing storage equipment
CN103077166B (en) The method for spacial multiplex of small documents storage and device
CN103678337A (en) Data eliminating method, device and system
CN106446044B (en) Storage space recovery method and device
CN109074227A (en) A kind of method and storage system of data check
CN105204783B (en) A kind of solid-state disk rubbish recovering method based on data lifetime
CN111417926A (en) Unmanned aerial vehicle and firmware upgrading method thereof
CN112306408A (en) Storage block processing method, device, equipment and storage medium
CN103677893B (en) Method for reducing size of image file of starting up and arithmetic device
CN104965835A (en) Method and apparatus for reading and writing files of a distributed file system
CN115098447A (en) File recovery method and device, electronic equipment and readable storage medium
CN104486448A (en) Data processing method and device
CN103729301B (en) Data processing method and device
CN111291085A (en) Hierarchical interest matching method and device, computer equipment and storage medium
CN111221468A (en) Storage block data deleting method and device, electronic equipment and cloud storage system
CN111581157B (en) Object storage platform, object operation method, device and server
CN115599295A (en) Node capacity expansion method and device of storage system
CN112035253B (en) Linux system page cache recovery method and related device
CN111736778B (en) Data updating method, device and system and electronic equipment
CN111984196B (en) File migration method, device, equipment and readable storage medium
CN106294002A (en) A kind of cloud backup method and device
CN114020707B (en) Storage space recovery method, storage medium, and program product
CN108345669B (en) Log updating method and device based on flash memory database
CN111343105A (en) Cutoff identification method and device based on deep learning

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