CN106502587A - Data in magnetic disk management method and magnetic disk control unit - Google Patents

Data in magnetic disk management method and magnetic disk control unit Download PDF

Info

Publication number
CN106502587A
CN106502587A CN201610912077.5A CN201610912077A CN106502587A CN 106502587 A CN106502587 A CN 106502587A CN 201610912077 A CN201610912077 A CN 201610912077A CN 106502587 A CN106502587 A CN 106502587A
Authority
CN
China
Prior art keywords
data
log area
area
log
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.)
Granted
Application number
CN201610912077.5A
Other languages
Chinese (zh)
Other versions
CN106502587B (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201610912077.5A priority Critical patent/CN106502587B/en
Publication of CN106502587A publication Critical patent/CN106502587A/en
Application granted granted Critical
Publication of CN106502587B publication Critical patent/CN106502587B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

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 discloses data in magnetic disk management method and magnetic disk control unit is planted, for the fragment on high-efficiency management disk.The embodiment of the present invention is applied to the magnetic disk control unit for including disk, and the disk includes that data field and log area, method include:To caching device write data;Judge whether data are hot spot datas, wherein hot spot data be stored on disk after preset times modification and release after can make disk produce predetermined number fragment data;If data are not hot spot datas, data field space is write data in data separation with data field space for data;If data are hot spot datas, distribute log area space for data in log area, write data into log area space.It is managed by different types of data are stored in different regions on disk in a different manner, the debris management efficiency on disk can be improved, high-efficiency management of the log area to disk fragmentses can reduces the generation of disk fragmentses.

Description

Disk data management method and disk control device
Technical Field
The present invention relates to the field of data processing, and in particular, to a disk data management method and a disk control device.
Background
For ordinary mechanical hard disks, because the read-write position is positioned by depending on a mechanical rotating magnetic disk and a moving magnetic head, the sequential read-write of the hard disk is the most ideal read-write model. If the disk space is fragmented, continuous space cannot be allocated when writing data, which results in serious head jitter, and the main time of data transmission is consumed on the positioning tracks and sectors, thus leaving little time for data transmission. Because the data of the files are discrete, the efficiency is low when reading the files.
Therefore, most disk file systems try to avoid creating a large amount of fragmentation space, but fragmentation is still unavoidable.
For example, the advantage of disk sequential writing can be exploited using the COW mechanism. When one block of data is required to be modified and written, the old version of data is read instead of being directly overwritten, and after the data is modified, the data is written to a new position, the data written is aggregated and sequentially written to a disk, and the old version of data is released. Because the location of the data changes, the pointers in the index blocks of the previous layer that point to the data need to be modified, and so forth recursively to the topmost layer. This frees up a large amount of data, resulting in a large amount of fragmentation on the disk.
Disclosure of Invention
The embodiment of the invention provides a disk data management method and a disk control device, which are used for efficiently managing fragments on a disk.
The first aspect of the present invention provides a disk data management method, which is applied to a disk control device including a disk, where the disk includes a data area and a log area, and the method includes:
the disk control device writes data into a cache device, wherein the cache device can be a memory device, a flash card, a solid state disk and other memory devices different from the disk, and then the disk control device judges whether the data is hot data, wherein the hot data is data which can enable the disk to generate a preset number of fragments after being modified and released for a preset number of times after being stored on the disk. The type of the data is determined by judging the written data on the cache device, so as to execute different processing modes on different data.
When data is written into a disk, if the data is not hot spot data, allocating a data area space for the data in a data area, and writing the data into the data area space; if the data is the hot spot data, a log area space is allocated for the data in the log area, and the data is written into the log area space.
The disk data management method of the first aspect of the present invention divides data to be written into the disk into hot data and non-hot data, the hot data is likely to cause fragmentation of the disk, the number of hot points is stored in the log area, and the management is performed in a log manner, so that even if the data in the log area is frequently modified to generate disk fragmentation, the fragmentation is conveniently recovered and the like, the non-hot data is stored in the data area, the disk fragmentation is not likely to be caused by the release of the non-hot data, and the data area may not need to allocate too many resources for disk fragmentation management, so that by storing different types of data in different areas on the disk and performing management in different manners, the fragmentation management efficiency on the disk can be improved, the fragmentation on the disk can be effectively managed, and the generation of disk fragmentation can be avoided.
With reference to the first aspect, in a first possible implementation manner, where the cache device is a memory, and after allocating a log area space for the data in the log area, the first possible implementation manner further includes: and establishing a mapping relation between the data and the log area space. The disk control device allocates a log area space for the data in the log area, establishes a mapping relation on the cache device, records the storage condition of the data in the log area through the mapping relation for the corresponding relation between the data and the allocated log area space, and thus, the data elimination operation on the data in the log area and the cache device can be managed by using the mapping relation. In a first possible implementation manner, the cache device is a memory, but the cache device may be in other cases.
With reference to the first possible implementation manner of the first aspect, establishing a mapping relationship between data and a log area space in a second possible implementation manner includes: establishing a mapping relation between a plurality of target data and a log area space allocated to the plurality of target data, wherein the target data belongs to hot spot data;
writing data to a log area space, comprising: combining a plurality of write operations of a plurality of target data into one transaction; all target data for the transaction is written to the log area space. And when the write operation execution of one target data of the transaction fails, the write operation execution of other target data of the transaction fails. The plurality of target data refers to at least two target data, and the plurality of write operations refers to at least two write operations, respectively. In this way, the concept of database field transaction is introduced, and multiple hot spot data are used as a unit to perform operations, such as establishing a mapping relation between multiple hot spot data belonging to the same transaction, and performing write operations to the log area together with write operations of all the hot spot data of the transaction. This can improve the efficiency of data processing.
With reference to the second possible implementation manner of the first aspect, a third possible implementation manner further includes: and caching the data belonging to the hot spot data on the memory. The hot data is cached in the memory, for example, when the hot data is written into the log area, the data is also retained in the memory, or the hot data on the log area is read from the log area before the data is written into the memory and is cached in the memory, so that when the data is subsequently written into the content, the data can be directly modified on the memory, the data is migrated in the memory, the generation of fragments on the disk is reduced, and the data in the log area can be sorted according to the migration condition.
With reference to the third possible implementation manner of the first aspect, before writing all target data of the transaction into the log area space in the fourth possible implementation manner, the fourth possible implementation manner further includes:
establishing a data linked list according to the plurality of target data, wherein the data linked list is used for managing the target data, and the target data managed by the data linked list is the same as the target data of the transaction; then, managing the target data according to the data chain table, and managing the target data according to the data chain table includes: after the second data linked list is established, when second target data managed by the second data linked list is obtained by modifying first target data managed by a pre-established first data linked list, the first target data is not managed on the first data linked list; and deleting the information of the first target data on the first mapping relation corresponding to the first data linked list. Therefore, on the memory, the data migration between different transactions can be managed through the data linked list.
The method for managing the data in the memory according to the data linked list can be as follows: under the preset release condition, searching data which are not unmanaged by the data linked list according to the first-to-last establishment sequence of the data linked list; and releasing unmanaged data of the target data linked list on the memory, and reserving a target mapping relation corresponding to the target data linked list on the memory. The capacity of the memory management data can be enlarged by releasing the data on the target data link list. The system can read corresponding data from the log area through the query of the target mapping relation.
With reference to the fourth possible implementation manner of the first aspect, in a sixth possible implementation manner, under a preset release condition, searching for unmanaged data of the data chain table according to a first-to-last establishment sequence of the data chain table includes: when the memory reaches a first preset water level, searching data which are not unmanaged by the data linked list according to the first-to-last establishment sequence of the data linked list; in addition, the method also includes the memory data elimination of the second stage, namely after releasing the data which is not unmanaged by the target data linked list on the memory, the method also includes: when the memory reaches a second preset water level, reading data pointed by the target mapping relation from the log area; writing the data pointed by the target mapping relation into a data area; and deleting the target mapping relation on the memory. The management capacity of the memory for the data can be enlarged through the two-stage memory data elimination mechanism, and in the second-stage memory data elimination, the data pointed by the target mapping relation is inactive data, the possibility of modification is low, the data can be migrated from the log area to the data area for storage, and fragments of the data area cannot be excessively increased.
With reference to the fourth possible implementation manner of the first aspect, in a sixth possible implementation manner, the method further includes: and distributing the transaction numbers for the data linked list corresponding to the transactions according to the writing sequence of the transactions and the increasing rule. The data linked list can be managed according to the transaction number by distributing the transaction number to the data linked list, so that the management efficiency is improved. For example, starting from the data linked list with the smallest transaction number, the unmanaged data of the data linked list is searched according to the sequence of the transaction numbers from small to large, so that the unmanaged data of the data linked list can be searched according to the established sequence of the data linked list from first to last.
With reference to the fourth possible implementation manner of the first aspect, in a seventh possible implementation manner, the method further includes: and executing the log area data relocation under the preset recovery condition. For example, the step of executing the data relocation in the log area includes:
searching a mapping relation;
judging whether the data on the first log area corresponding to the mapping relation is migrated or not according to the information recorded by the mapping relation;
if the data on the first log area is not completely migrated, determining the space utilization rate on the first log area according to the information recorded by the mapping relation;
when the space utilization rate of the first log area is smaller than a preset utilization rate threshold value, transferring the data of the first log area to a second log area, and updating a mapping relation corresponding to the transferred data, wherein the second log area is a free log area or a log area used when the log area is recovered;
and stopping executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold value, otherwise, continuing executing the step of log area data relocation.
With reference to the seventh possible implementation manner of the first aspect, in an eighth possible implementation manner, the method further includes: and distributing the transaction numbers to the data linked lists corresponding to the transactions according to the writing sequence of the transactions and the increasing rule, and managing the data linked lists according to the transaction numbers, so that the management efficiency can be improved. For example, starting from the data linked list with the smallest transaction number, the mapping relationship corresponding to the data linked list is searched according to the sequence of the transaction numbers from small to large, so that the searching for the mapping relationship can be realized.
With reference to the seventh possible implementation manner of the first aspect, in a ninth possible implementation manner, the preset recovery condition includes at least one of expiration of a timer, completion of a recovery operation on the memory data, and reaching of a total water level of the log area to a preset water level threshold.
With reference to the first possible implementation manner of the first aspect, in a tenth possible implementation manner, data belonging to hot data is cached on a memory, and there are various manners, for example, after determining whether the data is the hot data, if the data is the hot data, the data is retained on the memory; alternatively, before writing data to the cache device, data is read from the journal area to the cache device.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in an eleventh possible implementation manner, the hotspot data includes data with a data size smaller than a preset data threshold, and/or the hotspot data includes metadata. The predetermined data threshold may be 128KB or other space size, and the specific value may be adjusted according to the service type, and if the data size of the data is smaller than the predetermined data threshold, the frequent release of the data may cause a large amount of fragmentation of the disk. And the metadata includes management data for the data, such as indirect blocks holding data addresses, and metadata blocks holding object management structures. Metadata can also cause a large amount of fragmentation of the disk. The hot data are screened out to be stored in the log area.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in a twelfth possible implementation manner, allocating a log area space for data in a log area, and writing the data in the log area space includes: and allocating log area spaces for the data in the log area according to the sequence, and additionally writing the data into the log area spaces in sequence. Therefore, the sequential reading and writing of the data in the log area can be realized, and the expenditure of the metadata is avoided when the data in the log area is moved. The arrangement cost is low, and the stability of the system performance is effectively ensured.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in a thirteenth possible implementation manner, the method further includes: when the space utilization rate of the data area is greater than a preset data area utilization threshold value, converting the current idle log area into the data area; and when the space utilization rate of the log area is greater than a preset log area utilization threshold value, converting the data area converted from the idle log area into the log area. Thus, the log area and the data area are converted to each other to adapt to a change in system capacity. The method can flexibly adapt to specific use scenes, and improves the use efficiency of the disk.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in a fourteenth possible implementation manner, the disk further includes a super block, each log area is allocated with identification information, and the super block is configured to record the identification information of the modified log area after the log area is modified. The log area is further managed through the super block, for example, if the system is powered off or crashes and recovers, the disk control device can timely search the modified log area according to the information recorded by the super block.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in a fifteenth possible implementation manner, the log area and the data area are alternately arranged on the disk. In this way, the data of the log area and the data area can be set closer.
With reference to the first aspect or any one of the second to tenth possible implementation manners of the first aspect, in a sixteenth possible implementation manner, the disk further includes a block group, the block group includes a preset number of log areas and data areas, the log areas and the data areas of the block group are continuously set, and the data areas and the log areas in the block group can be adjusted by the block group in a matching manner, for example, after a free target data area is determined according to management information of the block group, a data area space is allocated for data in the target data area; so that after writing data to the data area space, the method further comprises: generating target metadata according to the data and the data area space; writing target metadata into the cache device, and determining a target block group to which a target data area belongs after judging that the metadata is hot data by the magnetic disk control device; determining a log area available for the target block group; the target metadata is written to the available journal area. Therefore, the position of the metadata on the disk is close to the position of the data corresponding to the metadata stored on the disk, and the data is convenient to read and write.
With reference to any one of the second to tenth possible implementation manners of the first aspect, in a seventeenth possible implementation manner, the method further includes: and allocating a log area space on the log area for the mapping relation, and writing the mapping relation into the log area space allocated by the mapping relation. That is, the mapping relationship is also stored in the log area, so that the mapping relationship is reliably stored in the disk.
A second aspect of the present invention provides a disk control apparatus including a disk including a data area and a log area, the disk control apparatus having the function of the disk control apparatus in the above method. The functions may be implemented by hardware, or by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above.
In one possible implementation, the disk control apparatus includes:
a write unit for writing data to the cache device;
the cache manager is used for judging whether the data is hot spot data or not, wherein the hot spot data is data which can enable a disk to generate fragments with preset number after being stored on the disk and modified and released for preset times;
the data manager is used for distributing data area space for the data in the data area and writing the data into the data area space if the data is not the hot data;
and the log manager is used for allocating a log area space for the data in the log area and writing the data into the log area space if the data is the hot data.
In another possible implementation manner, the disk control apparatus includes:
a processor;
the processor performs the following acts: writing data into the cache device;
the processor performs the following acts: judging whether the data is hot data or not, wherein the hot data is data which can enable a disk to generate fragments with a preset number after being modified and released for a preset number of times after being stored on the disk;
the processor performs the following acts: if the data is not the hot spot data, distributing a data area space for the data in the data area, and writing the data into the data area space;
the processor performs the following acts: if the data is the hot data, distributing a log area space for the data in the log area, and writing the data into the log area space.
In a third aspect, an embodiment of the present application provides a computer storage medium storing program code for instructing to execute the method of the first aspect.
According to the technical scheme, the embodiment of the invention has the following advantages:
on a disk control device comprising a disk, wherein the disk comprises a data area and a log area, after data is written into a cache device, the disk control device judges whether the data is hot data, if the data is not the hot data, the disk control device allocates a data area space for the data in the data area, and writes the data into the data area space; if the data is the hot spot data, a log area space is allocated to the data in the log area, and the data is written into the log area space. Thus, the data to be written into the disk is divided into hot spot data and non-hot spot data, the hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk, the hot spot data is easy to cause the disk to generate fragments, the hot spot data is stored on a log area and is managed in a log mode, even if the data on the log area is frequently modified to generate disk fragments, the fragments are convenient to be recycled and the like, the non-hot data is stored in the data area, the disk is not easy to generate fragments due to the release of the non-hot data, the data area does not need to allocate excessive resources for disk fragment management, thus, by storing different types of data in different areas on the disk and managing them in different ways, the method can improve the management efficiency of the fragments on the disk, efficiently manage the disk fragments by the log area, and reduce the generation of the disk fragments.
Drawings
FIG. 1 is a logical view of an object on a log area provided by an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a disk data management method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating migration of data in memory according to the embodiment shown in FIG. 2;
FIG. 4 is a diagram illustrating caching of data in a memory according to the embodiment shown in FIG. 2;
FIG. 5 is a schematic structural diagram of a disk control device according to another embodiment of the present invention;
FIG. 6 is a schematic structural view of a recovery unit of the disk control apparatus shown in FIG. 5;
fig. 7 is a schematic diagram of a hardware structure of a disk control apparatus according to another embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a disk data management method and a disk control device, which are used for efficiently managing fragments on a disk.
First, an implementation environment related to a disk data management method of an embodiment of the present invention
The disk data management system comprises a disk and a memory, wherein the memory can be used as a cache device, the disk is divided into a data area Date zone and a Journal area Journal zone, and the Journal area manages data on the data area in a Journal mode.
Before the disk data management system writes data into the disk, the data is written into a memory serving as a cache device, if the disk data management system judges that the data is hot data, the hot data is data which can enable the disk to generate a preset number of fragments after being modified and released for a preset number of times after being stored on the disk, and the hot data can cause the disk to generate a large number of fragments after being modified on a data area of the disk. Therefore, after writing data into the memory, if the data is not hot spot data, a data area space is allocated to the data in the data area, and then the data is written into the data area space. If the data is the hot spot data, a log area space is allocated for the data in the log area, and the data is written into the log area space.
The data area space is a storage space on the data area, and may be a partial space on one data area or a total space on one data area. The log area space is a storage space on the data area, and may be a partial space on one log area or a total space on one log area.
Thus, the data to be written into the disk is divided into hot spot data and non-hot spot data, the hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk, the hot spot data is easy to cause the disk to generate fragments, the hot spot data is stored on a log area and is managed in a log mode, even if the data on the log area is frequently modified to generate disk fragments, the fragments are convenient to be recycled and the like, the non-hot data is stored in the data area, the disk is not easy to generate fragments due to the release of the non-hot data, the data area does not need to allocate excessive resources for disk fragment management, thus, by storing different types of data in different areas on the disk and managing them in different ways, the management efficiency of the fragments on the disk can be improved, the fragments on the disk can be effectively managed, and the effect of avoiding the generation of the disk fragments is also achieved through the management of the log area.
The log area and the data area of the disk may be provided in various ways, as described in detail below, as one implementation thereof.
The disk is divided into two types of areas, namely a data area and a log area, and the space size of the data area and the log area is not particularly limited in the embodiment of the present invention, and may be 256M, for example. The data area and the log area may be arranged alternately, as shown in table one, which is an example of a space layout of a disk, and the disk is divided into a super block, a data area and a log area. Alternatively, a proportion of 0.1% in the log area set is used as a fixed log area which is distributed on the disk at regular intervals, the log area of the type can only be used as the log area, and other log areas can be converted into the data area when the disk space is insufficient.
Watch 1
The data area and the log area have multiple setting modes on the disk, the above mentioned data area and the log area are set alternately only one mode, the invention is not limited to this, for example, the data area is set continuously in one area of the disk, the log area is set continuously in another area of the disk, or multiple data areas are set continuously as data group, multiple log areas are set continuously as log group, then data group and log group are set alternately, etc.
The data area may hold non-hotspot data, for example, more than 128KB of data is written directly to the data area. After the data is written into the data area in the data area, metadata of management data are generated, and the metadata can be written into the cache device and then allocated with space in the log area for storage.
The log area may store the hotspot data, for example, data and metadata smaller than 128KB are stored in the log area, in some embodiments, the hotspot data may be stored in the log area in an additional manner, and in some embodiments, an identification information ID may be further assigned to the log area in sequence. In the log area, data is managed in a log manner.
In some embodiments, io processing is performed in the log area according to a sequential additional writing manner, when a data block needs to be written into the log area, space is allocated from the last written tail of the log area, and when the log area cannot accommodate a data block, a log area with the largest free space is reselected for additional writing.
The layout of the Journal area is shown in table two, where Journal ctrl is identification information ID, Map is a mapping relation, and Record is data, such as data less than 128KB and metadata.
Watch two
As shown in table one, in some embodiments, a super block is further disposed on the disk of the disk control apparatus, and after data is written into the log area, the log area is modified, and the super block records the flag information ID of the modified log area. For example, when a batch of write operations to the log area are combined into a transaction, after the data of the transaction is saved to the hard disk, the identification information ID of the log area modified by the transaction can be recorded in the bitmap corresponding to the superblock.
The space size of the super block is not specifically limited in the embodiments of the present invention, and may be adjusted according to the specific device situation, for example, a 4T disk, where there are 8192 log areas at 4T/256M/2, and one 1024B is needed in the super block to record the overall usage of the log area.
The layout of the superblock may be as shown in table three. The Super Blkcctrk is used for recording overall management information, such as the used capacity of the disk, the total capacity, the total free capacity, the number of log areas and the number of data areas. The journal is used to record the transaction number that has been processed. The capacities of Super blkcctrk and journal may be 4K, respectively
Watch III
Super blkctrk Journalbitmap
In order to make the data allocated to the data area and the log area close, in some embodiments, a plurality of log areas and data areas may be combined into one chunk, and the log areas and the data areas on the chunk are arranged in series. Each block group has a space management object, and the use condition of the disk space in the block group is managed by adopting a bitmap mode of a bitmap file. For example, 16 log areas and data areas that are continuously set may be combined into one block group.
Tables four and five show the relationship of the chunk, data area, and log area. Table four is a schematic of the layout of the disk in units of chunks, and table five is a schematic of the layout of chunk 1 in table four.
Watch four
Watch five
As shown in table two, the log area further stores a mapping relationship Map, where the mapping relationship may be a corresponding relationship used for recording data on the log area and a log area space to which the data is allocated, as shown in fig. 1, which shows a logical view of the disk object, and the mapping relationship is exemplified according to the figure.
As shown in fig. 1, which shows one object on the log area. An object can be divided into a plurality of levels, the level of the lowest level is 0, and the level corresponds to a data block of the object. Above level0 is an indirect block with a level of 1. The uppermost layer is the block where the object management structure is located, and the level is 2. In the case of many data blocks, one indirect block cannot store the address pointers of such multiple data blocks, and at this time, multiple indirect blocks are required, and the number of layers of the target is increased. The blocks of the same layer are numbered from left to right, e.g., blkid of the data block of the lowest layer is numbered 0, 1, 2, and 3 in order.
When a data block is modified in a transaction, the relationship between the data and the log area space to which the data is allocated needs to be recorded in a mapping relationship. For example, if a transaction creates an object in fig. 1, it needs to record information in the mapping relationship as table six. In table six, the information type of the data recorded in each column in the mapping relationship is objseptid, objid, levelid, blkid, jounalid, offset, and size in sequence.
Wherein, objseptid refers to an object set ID, objid refers to an object ID, levelld refers to the number of layers of the data block, blkid refers to the number of layers of the data block from left to right, jounalid refers to the ID of a log area written in by the data block, offset refers to the relative offset of the data block written in the log area, and size refers to the size of the data block.
It can be understood that the information type of the mapping relationship record may include all the information types described above, may also include a part of the information types described above, and may also include more other information types, which is not specifically limited in this embodiment of the present invention.
Watch six
It is understood that in some embodiments, the cache device may be replaced by other devices, such as nvdim, Flash card, SSD (Solid State Drives), etc. It may be understood that, in some embodiments, the disk may not include the log area, and the hot spot data is stored in the cache device, which is not specifically limited in this embodiment of the present invention.
It can be understood that the disk control apparatus according to the embodiment of the present invention may be used in a computer, a server, and other devices, and this is not particularly limited in the embodiment of the present invention.
FIG. 2 is a flow diagram illustrating a method of disk data management in accordance with an exemplary embodiment. The method is applied to a disk control device, the disk control device comprises a disk, and the disk comprises a data area and a log area. With reference to the first part described above, that is, the implementation environment related to the disk data management method according to the embodiment of the present invention, taking the perspective that the disk control device executes the method according to the embodiment of the present invention as an example, referring to fig. 2, a method flow according to the embodiment of the present invention includes:
step 201: writing data into the memory;
before the device writes data to the disk, the disk control apparatus writes the data to the cache device to perform management before writing to the disk, for example, the data is managed by using a cache manager of the disk control apparatus.
The cache device may be a memory or a cache device such as a flash memory, which is not specifically limited in this embodiment of the present invention.
In the embodiment of the present invention, a cache device is used as a memory for description. The data written into the memory includes all external data of the disk control apparatus and metadata generated when data is written into the data area of the disk.
The writing of the data into the memory comprises two modes of modification and creation, wherein the modification means that the data written into the memory is the data on the memory, the new data covers the modified data, the creation means that the new data is written into the memory, and the memory does not have original data for caching the new data.
Step 202: judging whether the data is hot data, if not, executing step 203, and if so, executing step 204.
After writing data into the memory, the disk control device determines whether the data is hot data, for example, by using a cache manager module of the disk control device. And after judging whether the data to be written into the disk is the hot data or not, the disk control device executes different processing modes according to the judgment result.
The hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk. For example, in this embodiment, the hot spot data may refer to data with a data size smaller than a preset data threshold, and/or the hot spot data may also refer to metadata.
The data with the data size smaller than the preset data threshold is small data, disk fragments are easy to generate when the data is frequently modified and released, and a large number of disk fragments cannot be generated when the data with the data size larger than the certain preset data threshold is frequently modified on the disk. The preset data threshold is set in relation to the service model, and may be set to 64KB, 128KB, or the like, for example.
And the metadata is a record object management structure and a data block recording a data block address. When a data block on a data area of a disk is to be modified, a COW mechanism is generally used in the data area, that is, when a block of data is to be modified, the old version of data is read instead of being directly overwritten, and after the old version of data is modified, the old version of data is written to a new location to release the old version of data. Because the position of the data changes, a pointer in an index block of the previous layer pointing to the data needs to be modified, that is, the metadata needs to be modified, the modified new metadata is allocated to a new space, and the modified old metadata needs to be released, so that the process recurses to the topmost layer. Thus, when a large amount of data is released due to the modification of the metadata, the position of the released data on the disk is fragmented, thereby accelerating the disk fragmentation process.
Therefore, the data and/or the metadata with the data size smaller than the preset data threshold are classified as the hot data, and the data are easy to cause the fragmentation of the disk and need to be managed correspondingly.
Step 203: and allocating data area space for the data in the data area, and writing the data in the data area space.
Data determined to be not hot data can be stored in the data area on the disk because it is less likely to fragment the disk. The data area is an area on the disk for storing data, and the area can manage the data thereon by using a COW mechanism. The data area may be an area on the disk having a predetermined space size, which may be 256M, for example. The description of the data area may refer to the description of the data area in the above-described embodiment.
For example, when the size of a data is larger than 128KB, the cache manager determines that the data is not hot data, and the data area manager module of the disk control device may allocate a data area space on the data area for the data, and then write the data into the allocated data area space.
Wherein the metadata is generated after writing the data into the data area. The metadata is used to record the address of the data, thereby facilitating management of the data. For example, when organizing multiple pieces of data, a multi-level index is generally used, that is, an index block is allocated at a layer above the data block, and the content of the index block is the address of the recorded data block, and the index block can be used to splice multiple data blocks into a logically continuous object. This index chunk is one type of metadata. After the data is written into the data area to generate the metadata, the metadata can be written into the memory, and the above step 201 is executed. The cache manager may determine that the metadata is hot data and store the hot data in the log area and the memory.
It is to be understood that, in some embodiments, the disk of the disk control apparatus further includes a block group, the block group includes a preset number of log areas and data areas, the log areas and the data areas of the block group are arranged consecutively, and in the disk control apparatus including the block group, the specific implementation manner of allocating the data area space for the data in the data area is to select an appropriate block group, for example, a block group with less space usage or a block group with more free data areas, and then allocate the data area space of the data area for the data in the selected block group. After the space is allocated, the usage of the space needs to be recorded, i.e. after the free data block needs to be searched and allocated in the space management bitmap of the block group, the management structure of the block group needs to be modified. And subsequently, the metadata can be written into the log area belonging to the block group according to the space use condition recorded by the block group, and if the block group does not have a free log area, the metadata needs to be written into the adjacent log area. Such that the metadata is close to the location on disk of the data to which the metadata points.
The block group may refer to the corresponding description of the block group in the above implementation environment section.
It is understood that the data written in the data area may include data that is obsolete due to insufficient space, in addition to data that is determined to be non-hot data, for example, in the second stage of subsequent memory reclamation, the data pointed by the mapping relationship is migrated from the log area to the data area. The migrated data may be written to the data area space after the data area space is allocated by the data space manager.
Step 204: and allocating a log area space for the data in the log area.
And a log area is also arranged on the magnetic disk, and data on the log area is managed on the log area in a log mode.
When the data of step 201 is determined to be the hotspot data, and the log area space is allocated on the log area for the data, for example, the data is transferred to a log manager, which allocates the log area space on the log area for the hotspot data, so that the hotspot data is stored on the log area.
In the embodiment of the invention, in order to manage the data on the log area more conveniently, the space can be allocated on the log area for the data belonging to the hot data according to the sequence written into the log area. Of course, in other embodiments, log area space may not be allocated to the hotspot data sequentially, which is not specifically limited by the embodiments of the present invention,
and the data belonging to the hot data is stored in the log area, when the hot data on the memory is lost due to power failure, the data on the log area can be read to the memory for the equipment to execute operation, and the memory and the log area are matched for use, so that the hot data is stored in the log area, and the manageable data volume of the hot data in the memory can be enlarged.
The journal area may be an area on the disk with a certain space size, and may be 256M, for example. There may be a plurality of log areas and data areas on the disk, and the log areas may be assigned with identification information in the order of arrangement on the disk. The specific setting manner of the log area can refer to the corresponding description of the log area in the above-mentioned implementation environment section.
The setting manner of the journal area and the data area on the disk may have various manners, for example, the journal area and the data area are alternately arranged on the disk, as shown in the above table one. Of course, the data area and the log area may also be configured in other manners, which is not specifically limited in this embodiment of the present invention, and the corresponding description of the configuration of the data area and the log area may be specifically referred to in the above-mentioned implementation environment section.
Step 205: and establishing a mapping relation between the plurality of target data and the log area space allocated to the plurality of target data.
Wherein the target data belongs to the hot spot data.
After writing a plurality of data into the memory, after determining whether the data is hot data, a plurality of data belonging to the hot data may be obtained on the memory. The disk control device determines a plurality of target data belonging to the hot spot data on the memory so as to manage the plurality of target data together, thereby improving the processing efficiency. Target data are distributed with log area space in the log area, and the magnetic disk control device establishes mapping relation according to the target data and the log area space distributed by the target data. The target data belong to hotspot data, namely the target data comprise metadata and/or data with a data size smaller than a preset data threshold.
All data written into the log area need to record mapping relation between the data and the space of the log area, and record the data on the log area through the mapping relation so as to manage hot data on the memory or the data on the log area according to the mapping relation, for example, the device reads corresponding data stored in the log area according to an index of the mapping relation cached on the memory, or recovers the log area according to data information recorded by the mapping relation so as to perform fragment management on the log area.
The information type of the mapping relation record may include information such as objetid, objid, levelid, blkid, jounalid, offset, size, etc.,
for more on this mapping reference is made to the corresponding description of the above implementation environment section.
Step 206: and caching the mapping relation on the memory.
And after the mapping relation is established, storing the mapping relation on a memory to prepare for subsequent operation.
In some embodiments, the mapping relationship may also be saved in the log area, and when the mapping relationship needs to be saved in the memory, the mapping relationship is read from the log area to be cached in the memory. Of course, in some embodiments, the mapping relationship may be stored in both the memory and the log area.
Step 207: combining the multiple write operations of the multiple target data into one transaction.
After determining a plurality of target data, the disk control device combines the plurality of write operations of the plurality of target data into one transaction, and executes the disk write operation in units of the transaction. Where a transaction is the name for the combination of multiple write operations and not the execution of a write operation. And the plurality of target data refers to at least two target data, and correspondingly, the plurality of write operations refers to at least two write operations.
In order to improve writing efficiency and ensure writing reliability, when a device writes data to a log area, generally, a plurality of write operations of a plurality of data are performed in one operation of writing data to the log area, instead of performing only one write operation. The target data belonging to the same batch of write operations are either completely written successfully or completely written unsuccessfully during the process of writing to the disk. And combining a plurality of write operations of a plurality of target data of the same batch into one transaction.
It is understood that the execution order of step 207 and step 205 is not particularly limited by the embodiment of the present invention. That is, the write operations of a plurality of target data are combined into one transaction, and a mapping relationship can be established according to the target data, so that one transaction corresponds to one mapping relationship.
In some embodiments, the method of the embodiments of the present invention further includes establishing a data linked list according to the plurality of target data, that is, forming a data linked list according to a series of metadata in a transaction and data smaller than a preset threshold, where the data linked list is used for managing the target data. When the mapping relation is formed, the mapping relation can be established according to the data on the data linked list and the space distributed on the log area by the data.
Step 208: all target data for the transaction is written to the log area space.
The disk control device writes all target data of the transaction into a log area space, and after a plurality of target data are combined into one transaction, when the write operation execution of one target data of the transaction fails, the write operation executed by other target data of the transaction fails. Only if each write operation to the target data is performed successfully will the write operation for the transaction succeed.
After the mapping relation is established, a log area space is distributed for the mapping relation through a log area manager, and the log area space is also distributed for data belonging to the hot data, so that the mapping relation and the target data can be written into the log area space distributed by the mapping relation and the target data, and the mapping relation and the target data are stored in the log area.
After the mapping relationship is stored in the log area, the system may read the mapping relationship into the memory, so that the memory may obtain the mapping relationship again, which is particularly useful for the rework of the memory after the power failure.
In the embodiment of the present invention, the mapping relationship and the order of writing the target data of the transaction into the log area space are not specifically limited.
In some embodiments, the specific way to allocate a log area space for the data in the log area and write the data in the log area space is to allocate a log area space for the data in the log area in sequence and write the data additionally in the log area space in sequence. And sequentially allocating the space and sequentially appending the write data, namely allocating the space or writing the data on the storage space of the log area according to the sequence.
The data in the log area can be sequentially read and written in the mode of sequentially allocating log area spaces for the data in the log area and sequentially additionally writing the data in the log area spaces, the efficiency of data management is improved, the data in the log area can be determined according to the sequence, the mapping relation records the corresponding relation between the data stored in the log area and the log area spaces of the data, the mapping relation can be used for replacing the function of metadata, the data in the log area is determined without using the metadata, and therefore extra metadata management overhead is avoided. And when the log area writes data in a sequential addition mode, the information of the storage space of the data on the log area can be conveniently recorded by the mapping relation.
In an embodiment of the present invention, the method of an embodiment of the present invention further includes: if the data is hot data, caching the data on the memory, namely writing all target data of the transaction into a log area space, and caching the target data of the transaction on the memory, namely judging whether the data is the hot data, and if the data is the hot data, reserving the data on the memory, so that in the subsequent operation process, if the data is written into the memory, if the write operation is the modification write of the target data cached on the memory, the data can be directly modified on the memory, and the step of managing the target data according to the data linked list is executed. Therefore, the data is reserved on the memory, so that the data is migrated on the memory, the disk is easy to generate fragments due to hot data, the data is cached on the memory and is not stored in the data area, and the fragments generated on the data area due to the migration of the data can be avoided.
In some embodiments, the step of caching the data on the memory may not be performed if the data is the hot data, but the data is read from the log area to the memory for caching before step 201, that is, the data is read from the log area to the cache device for caching before the data is written into the cache device. Therefore, the data can be directly modified on the memory, and the step of managing the target data according to the data linked list is completed. Therefore, the data is reserved on the memory, so that the data is migrated on the memory, and fragments are prevented from being generated on the data area due to the migration of the data.
In some embodiments, the disk control apparatus further includes a super block, and when each log area is allocated with the identification information, the super block is configured to record the identification information of the modified log area after the log area is modified. Therefore, when the internal memory is powered off, the data on the corresponding log area can be read according to the identification information of the log area recorded by the super block, and then the read data on the log area is cached in the internal memory so as to continue to execute the subsequent data operation.
For example, after all the target data and the mapping relation of the transaction are written into the space of the log area, when all the write operations of one transaction are completed, the identification information of the modified log area is recorded into the bitmap of the superblock.
It is to be understood that, in some embodiments, the disk further includes a block group, where the block group includes a preset number of log areas and data areas, and the log areas and the data areas of the block are continuously arranged, in this case, as described above, the data area space is allocated in the data area for the data, and specifically, the data area space may be: determining an idle target data area according to the management information of the block group; and allocating data area space for the data in the target data area.
Therefore, after data is written into the data area space, target metadata is generated according to the data and the data area space, and the target metadata is used for recording the address of the data on the data area so as to conveniently manage and inquire the data.
After generating the metadata, writing the target metadata into the memory; determining a target block group to which a target data area belongs after judging that the metadata are hot data; determining the log area available for the target block group, i.e. finding the log area available for the target block group, and then writing the target metadata into the available log area. If not, the target data area or the nearest available log area near the target block group is searched.
When the writing of data to the log area is in transaction units, allocating the log area space for a plurality of target data of the transaction may use the above method to allocate the metadata of the target data close to the data pointed by the metadata.
Therefore, after the metadata and the data pointed by the metadata are stored on the disk according to the method, the storage position of the metadata is close to the storage position of the data pointed by the metadata, so that the moving distance of the magnetic head is reduced, and the read-write efficiency of the disk is improved.
In some embodiments of the present invention, multiple target data belonging to the same transaction on the memory are managed in a linked list manner. As described above, in the method according to the embodiment of the present invention, after a plurality of target data are determined, a data linked list may be established according to the plurality of target data, where the data linked list is used to manage the target data. That is, after the data and metadata of each transaction are submitted to the hard disk, the data of the corresponding log area is managed in a linked list method,
because the write operations for these target data are combined into one transaction, and thus one transaction corresponds to one data linked list, the target data managed by the data linked list is the same as the target data of the transaction. And a mapping relation is established according to the target data, so that one data linked list corresponds to the mapping relation, and the mapping relation records the storage condition of the data managed by the data linked list on the log area.
The target data can be managed according to the data linked list, and the specific management method is as follows:
according to the executing step, after a plurality of first target data belonging to the hot spot data are determined on the memory, a first data link table is established according to the first target data, the first target data belong to a first transaction, namely the first target data are written into the log area according to the same writing batch when being written into the log area, and as long as one first target data fails to be written, other data of the first transaction fails to be written. The first target data is also established with a first mapping relationship. The first mapping relationship is cached in the memory. For example, the first data linked list manages first target data a1, first target data B1, first target data C1, and first target data D1 on the memory. The corresponding first mapping relation records the relation between the first target data a1, the first target data B1, the first target data C1, the first target data D1, and the log area space allocated to these data in the log area. In the subsequent process, the disk control device establishes a second data link table according to a plurality of second target data, the plurality of second target data belong to the hotspot data and belong to the second transaction, and a second mapping relationship is established according to the plurality of second target data, and the data link table can manage, for example, the second target data a2, the second target data E1, the second target data F1, and the second target data D2.
When second target data managed by a second data link list is obtained by modifying first target data managed by a pre-established first data link list, the first target data is not managed on the first data link list; and deleting the information of the first target data on the first mapping relation corresponding to the first data linked list. Thus, migration of target data on the data link list and the mapping relation is realized. For example, when the second target data a2 managed by the second data link table is obtained by modifying the first target data a1 of the first data link table, the first target data a1 is no longer needed because the first target data a1 on the memory is modified to the second target data a2, so that the first data link table can be removed from managing the first target data a1, and accordingly, the information about the first target data a1 recorded on the first map gateway can be deleted. Because the information of the first target data a1 recorded by the first mapping relationship is deleted, when the log area is recovered, it can be determined that the log area corresponding to the first target data a1 has fragments according to the first mapping relationship, and when the data on the merged log area is migrated, the information of the first target data a1 cannot be read from the first mapping relationship, so that the first target data a1 on the log area is not moved to a new log area, that is, the first target data a1 on the log area can be released.
Fig. 3 is a schematic diagram of data migration in a memory, where each transaction includes a plurality of target data, and only a part of data blocks in fig. 3 are labeled with reference numerals. As shown in fig. 3, since transactions are continuously generated, the latter transactions modify the data managed in the first transaction because of the locality of io. For example, the second transaction modifies the first target data A1 to obtain the second target data A2, the fifth transaction modifies the first target data B1 to obtain the fifth target data B2, the fourth transaction modifies the first target data C1 to obtain the fourth target data C2, the second transaction modifies the first target data D1 to obtain the second target data D2, and the third transaction modifies the second target data D3 to obtain the third target data D3. Therefore, according to the first transaction and the first data linked list, all data of the first transaction are completely migrated to the following transaction, and correspondingly, the log area can completely release the target data of the first transaction. As shown in table 7, the target data of the first transaction is stored in the log area 1, and after all the data of the first transaction are migrated to the following transaction, all the data blocks on the log area 1 are migrated to the following transaction, and are written into other log areas, that is, other log areas store new version data corresponding to the data of the log area 1, and at this time, the log area 1 may be released as an empty log area when the log area is recovered. Similarly, when the migration of other target data is executed to the fifth transaction, the actual cache condition in the memory is as shown in fig. 4.
TABLE 7
In order to manage the target data more conveniently according to the data linked list, in some embodiments, the method of the embodiments of the present invention further includes allocating transaction numbers to the data linked list corresponding to the transactions according to an increasing rule according to a writing sequence of the transactions, where the writing sequence of the transactions refers to a sequence of writing the log area between different transactions, the transaction number allocated to the data linked list corresponding to the transaction written first is smaller, and a unit is added to the transaction number of the data linked list corresponding to the transaction written to the log area, so that each data linked list can have corresponding identifiers, and the identifiers also have an increasing rule. Therefore, the sequence of establishing the data linked list in the memory can be conveniently determined according to the transaction number.
For example, a data linked list of a first transaction is first established, the first transaction is first written into a log area, so that a transaction number 1 is allocated to the data linked list of the first transaction, then a data linked list of a second transaction is established according to a plurality of second target data, the data of the second transaction is written into the log area after the first transaction, so that a transaction number 2 is allocated to the second data linked list corresponding to the second transaction, similarly, a transaction number 3 is allocated to a third data linked list, and so on.
The above is part of the content for managing data according to the data link table. The data belonging to the hot data is written into the log area, and the read data is cached in the memory after the data belonging to the hot data is cached in the memory or the data is read from the log area, so that the data can be managed on the memory according to the data linked list, the hot data is migrated on the memory, the migration of the data on the disk is reduced, and the fragments generated by the disk by the data are reduced.
The data is cached in the memory, and the data can be directly read from the memory when being read, so that the data in the log area is prevented from being read.
And data is managed on the memory according to the data linked list so as to establish and change the mapping relation, and the data and fragments in the log area can be sorted according to the mapping relation so as to avoid or reduce fragments of the disk and improve the fragment processing efficiency. In order to fully utilize the space on the memory, the hot data cached on the memory can be released, and the space of the memory is recycled, so that the memory caches other more data. Therefore, the method of the embodiment of the invention can recycle the memory space under the preset release condition. For example, when the recovery level of the system memory is reached, cache eviction is triggered. An exemplary recovery method is shown below, which is divided into two stages.
First stage
When the memory reaches a first preset water level, starting from the data linked list with the minimum current transaction number, searching the unmanaged data of the data linked list according to the sequence of the transaction numbers from small to large. And then, for the searched target data linked list, releasing the data which is not unmanaged by the target data linked list on the memory, and reserving the target mapping relation corresponding to the target data linked list on the memory.
Because the data is managed in a data linked list mode, the data managed by the data linked list established first can be eliminated on the memory due to the modification of the data written later, and the eliminated data is eliminated from the data linked list. In this regard, reference may be made to the above description of the method of managing a data link list. And (4) recycling the memory, namely searching the data which are not eliminated in the data chain table, and releasing the data which are not eliminated in the memory. The data linked list to which these data released on memory reclamation belong may be referred to as the target data linked list. And the mapping relation corresponding to the target data linked list is still kept in the memory. The memory recovery in the first stage is not stopped until the memory space reaches a preset stop water level.
Through the steps, the data smaller than or equal to the preset data threshold value and the metadata generated by the writing data are written into the log area and are cached in the memory. For the hot data in the log area and the memory, as above, the order of transaction sequence is used for management, so that when the system runs for a period of time and the cache reaches a first preset water level, the background cache recovery thread is triggered to recover the memory space according to the order of the transaction numbers from small to large. For example, starting from the data linked list with the minimum transaction number at present, the unmanaged data of the data linked list is searched according to the sequence of the transaction numbers from small to large, and the data on the memory is released from the data linked list established at first.
The data which are left in the data link table established earlier and are not eliminated by the memory are the inactive data, the possibility of reading and modifying the data by the device is low, and therefore the data can be released from the memory, and the influence on the data reading efficiency of the device is low. And if the data to be queried is determined according to the target mapping relationship, the corresponding data can be read from the log area according to the target mapping relationship. Thus, the memory can manage more hot data.
It can be understood that the memory reaches the first preset water level, which is only one of the preset release conditions, and the data that is not unmanaged by the lookup data chain table may also be triggered under other preset release conditions, for example, when a set timer expires, which is not specifically limited in the embodiment of the present invention.
Second stage
After the memory is recycled in the first stage, reading data pointed by the target mapping relation from the log area when the memory reaches a second preset water level; writing the data pointed by the target mapping relation into a data area; and deleting the target mapping relation on the memory.
In order to further fully utilize the memory space, the memory space may be recycled for the second time at the second stage. And triggering the memory to execute the water level recovered in the second stage when the water level is preset in the second stage. The second preset water level may be the same as the first preset water level or different from the first preset water level, which is not specifically limited in the embodiments of the present invention, and specific values of the first preset water level and the second preset water level are also not specifically limited in the embodiments of the present invention, for example, may be flexibly set according to an actual memory capacity and a service type.
After the data pointed by the target mapping relation is read from the log area, the data pointed by the target mapping relation can be written into the data area. When the memory reaches the second preset water level, the memory runs for a certain time, the mapping relationships cached in the memory are more and more, and finally, when the memory also reaches the cache water level, the data pointed by the mapping relationships need to be read and written into the data area.
When the memory reaches the second preset water level, the earlier established data linked list has less possibility of being modified by undeleted data because the management method of the data linked list is executed, because if the managed data on the data linked list is modified by the data written later, the data is migrated from the data linked list to the corresponding data linked list of the later transaction. Therefore, the data left in the data link list established earlier can be judged as inactive data, the inactive data are less likely to be modified, so that the disk fragments generated by modification are less, and the data pointed by the target mapping relation can be written into the data area. For example, the data are read from the log area according to the target mapping relationship, then the data area manager allocates the data area space on the data area, and then the data are written into the allocated data area.
After the above steps are performed, when the device is to read data on the disk, for example, the device accesses data written in the log area, the disk control apparatus may first search for the data on the memory, and if the data is hit in the memory, the disk control apparatus may directly return the data. After the first stage of memory recovery, part of hot data is deleted from the memory, and the corresponding mapping relationship is reserved, so that if the data to be accessed is not found in the memory, but can be found in the mapping relationship of the memory cache, the data to be accessed can be directly read in the log area corresponding to the mapping relationship. And if the data to be searched cannot be searched in the mapping relation, searching and reading the data in the data area.
It can be understood that, in the embodiment of writing data in the log area in the sequential additional writing manner, after the elimination of the data linked list of a plurality of consecutive transactions is completed, for example, after the above-mentioned second-stage recovery of the memory is performed, the log area corresponding to the deleted mapping relationship is also completely released, and may be used as an empty log area again. Specific methods for releasing the log area and recovering the log area will be described below.
In some embodiments, after the foregoing method is executed, the embodiment of the present invention further includes an operation of reclaiming the log area. Therefore, the fragments on the log area are reduced, and the space of the log area is fully utilized.
The collection of the log area can be based on the above method, and the collection of the log area will be described below with an embodiment in which the log area is written with data written in addition in order. That is, step 208 is to sequentially write the target data of the transaction into the space of the log area, that is, the data in the log area is stored according to the sequence of the transaction,
the specific recovery method of the log area may include, for example, the following steps:
a1: executing the step of transferring the log area data under the preset recovery condition;
the preset recovery condition comprises at least one of overtime of a timer, completion of recovery operation on the memory data and reaching of a total water level of the log area to a preset water level threshold value. The completion of the recovery operation on the memory data refers to that when the memory is recovered, the execution of each stage is completed, and a log area data relocation step is triggered, that is, a log recovery thread is triggered to execute a log area recovery process.
A2: and stopping executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold value, otherwise, continuing executing the step of log area data relocation.
The step of executing the data relocation in the log area comprises the following steps:
b1: and starting from the data linked list with the minimum current transaction number, searching the mapping relation corresponding to the data linked list according to the sequence of the transaction numbers from small to large.
After the step of allocating the transaction number to the data linked list corresponding to the transaction according to the increasing rule according to the writing sequence of the transaction is executed in the method, the disk control device searches the mapping relation corresponding to the data linked list according to the sequence of the transaction number from small to large, and because the mapping relation records the relation between the data and the space allocated to the data on the log area, the distribution condition of the data blocks in the mapping relation on the log area can be analyzed, that is, how much data is not migrated on the corresponding log area, and the data which is not migrated is located on the corresponding log area.
And because the transaction is switched to the next log area after the transaction is advanced and used in one log area, the data of continuous transactions are written into the continuous log area. And analyzing the mapping relation according to the sequence of the transaction numbers from small to large, so as to obtain the data storage condition on the continuous log area.
B2: judging whether the data on the first log area corresponding to the mapping relation is migrated or not according to the information recorded by the mapping relation;
when data in the memory is managed according to the data linked list, the corresponding mapping relationship of the data migrated in the memory is also modified, if the information recorded by the data linked list reflects the data in a certain log area so as to be migrated in the memory, for example, the data corresponding to the log area has a new version in other log areas, or after the second stage of memory recovery, the data in the corresponding log area is already migrated to the data area, and at this time, it is determined that the data in the log area corresponding to the mapping relationship has been migrated.
B3: if the data migration of the first log area is finished, recovering the first log area;
and if the data in the first log area is completely moved, recovering the first log area. In embodiments where the usage of the log area is recorded by a superblock, the information in the superblock corresponding to the first log area may be cleared at this time.
B4: if the data on the first log area is not completely migrated, determining the space utilization rate on the first log area according to the information recorded by the mapping relation;
because the mapping relation records the relation between the data and the space allocated to the data on the log area, the space utilization rate on the first log area can be analyzed according to the information recorded by the mapping relation.
B5: and when the space utilization rate of the first log area is smaller than a preset utilization rate threshold value, transferring the data of the first log area to a second log area, and updating a mapping relation corresponding to the transferred data.
Wherein the second log area is a free log area or a log area used when the log area is reclaimed, for example, a log area used when the log area is reclaimed last time. The preset utilization threshold may be set according to specific use conditions, for example, when the log area is used more, but the utilization rate of each log area is lower, the preset utilization threshold may be decreased. For example, the preset utilization threshold may be set to 50%, and the embodiment of the present invention is not limited thereto. The updating of the mapping relationship corresponding to the moved data may be updating the mapping relationship between the data and the new log area space in time on the mapping relationship related to the data after the data is moved on the log area.
By the log area recovery method, the recovery of the log area can be realized, the fragments on the log area are reduced, and the space of the log area is fully utilized. The log area is read and written sequentially and corresponds to the transaction number of the data linked list from small to large, so that the corresponding mapping relation can be inquired according to the size of the transaction number of the data linked list, the data is moved, and the position of the data in the log area is not required to be recorded by metadata at the moment, so that the expenditure of the metadata is reduced.
In the method of the embodiment of the invention, on a disk control device comprising a disk, the disk comprises a data area and a log area, after data is written into a cache device, the disk control device judges whether the data is hot data, if the data is not the hot data, the disk control device allocates a data area space for the data in the data area, and writes the data into the data area space; if the data is the hot spot data, a log area space is allocated to the data in the log area, and the data is written into the log area space. Thus, the data to be written into the disk is divided into hot spot data and non-hot spot data, the hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk, the hot spot data is easy to cause the disk to generate fragments, the hot spot data is stored on a log area and is managed in a log mode, even if the data on the log area is frequently modified to generate disk fragments, the fragments are convenient to be recycled and the like, the non-hot data is stored in the data area, the disk is not easy to generate fragments due to the release of the non-hot data, the data area does not need to allocate excessive resources for disk fragment management, thus, by storing different types of data in different areas on the disk and managing them in different ways, the method can improve the management efficiency of the fragments on the disk, efficiently manage the disk fragments by the log area, and reduce the generation of the disk fragments.
Data in the log area are migrated due to the locality of the hot spot data, and when the log area is actually sorted, the read data are less, so that the data management efficiency of the log area is higher. And the hot data is stored in the log area, and because the hot data is easy to generate fragments, the fragments are concentrated in the log area, and the efficiency of defragmentation is further improved.
When data is written into the log area in a sequential additional writing mode, the data only needs to be sequentially read and written into the log area, the moved data does not generate the expenditure of metadata, and the defragmentation efficiency of the log area is high. By sorting the data in the log area, disk fragmentation can be effectively avoided or reduced.
In some embodiments, data may not be written into the log area in a sequential addition manner, and when the space allocation condition of the log area is known, the data may be managed by using a bitmap file bitmap corresponding to the journal zone.
For example, each bit corresponds to a fixed block size, e.g., 4K, then a 256M journal zone requires 8K to manage, and this bitmap needs to be modified each time the journal zone is written.
It is understood that in the embodiment of the present invention, the data area and the log area may be in a hierarchical storage, that is, the data area and the log area are in different levels, and when the log area is recycled, the hot spot data is migrated to a storage layer in a lower level.
It is understood that, in some embodiments, the mapping relationship may be searched in other manners, for example, the mapping relationship is randomly queried, then the space storage condition of the corresponding log area is analyzed according to the searched mapping relationship, and then the log area data is migrated, at this time, the target data of the transaction may not be written into the log area space in a manner of sequentially adding, and a specific writing manner is not limited. However, such a method may not reflect the storage condition of the whole space of the log area due to the mapping relationship, and thus the recycling effect of the log area is not ideal.
It can be understood that, in the embodiment of the present invention including multiple log areas and multiple data areas, in order to more fully use the data areas and the log areas, thereby fully utilizing the disk space, the method of the embodiment of the present invention further includes a step of converting the data areas and the log areas, for example, when the space utilization of the data areas is greater than a preset data area utilization threshold, the currently idle log areas are converted into the data areas; and when the space utilization rate of the log area is greater than a preset log area utilization threshold value, converting the data area converted from the idle log area into the log area.
For example, when initializing on a disk, it is preset that half of the disk space is a log area and the others are data areas. When the system runs for a period of time, the utilization rate of the data area is high, and the idle log areas are searched according to the increasing sequence of the identification information of the log areas and are converted into the data area. After being converted into a data area, in an embodiment including a chunk group, it is managed using a space management object of the chunk group. And setting the state of the log area as a data area, recording the log area into a management structure of the block group, and writing the log area into a disc for storage. When the data in the data area is deleted, the disk space is released, the space of the data area converted from the log area is completely released, and at this time, the state of the data area is switched to the log area, and is recorded in the management structure of the block group, and the disk is written and stored.
Fig. 5 is a schematic structural diagram of a disk control apparatus according to an exemplary embodiment, where the disk control apparatus includes a disk, and the disk includes a data area and a log area, and the disk control apparatus is configured to execute functions executed by the disk control apparatus in the embodiment corresponding to fig. 2. Referring to fig. 5, the disk control apparatus includes:
a write unit 501, configured to write data into the cache device;
the cache manager 502 is configured to determine whether data is hot data, where the hot data is data that is stored on a disk and enables the disk to generate a preset number of fragments after being modified and released for a preset number of times;
the data manager 503 is configured to allocate a data area space for the data in the data area if the data is not the hot spot data, and write the data in the data area space;
the log manager 504 is configured to allocate a log area space for the data in the log area if the data is the hotspot data, and write the data in the log area space.
Optionally, the cache device is a memory, and the disk control apparatus further includes:
a mapping relationship establishing unit 505, configured to establish a mapping relationship between data and a log area space in a memory;
optionally, the disk control apparatus further includes:
the cache unit 506 is configured to cache data belonging to the hot spot data in the memory.
Alternatively,
the mapping relationship establishing unit 505 is further configured to establish a mapping relationship between the plurality of target data and a log area space to which the plurality of target data are allocated, where the target data belong to the hot spot data;
the log manager 504 is further configured to combine multiple write operations of multiple target data into one transaction, and write all target data of the transaction into the log area space, where when a write operation of one target data of the transaction fails, a write operation performed on other target data of the transaction fails.
Alternatively,
the disk control apparatus further includes:
a linked list establishing unit 509, configured to establish a data linked list according to multiple target data, where the data linked list is used to manage the target data, and the target data managed by the data linked list is the same as the target data of the transaction;
a linked list management unit 510, configured to manage target data according to a data linked list;
the searching unit 511 is configured to search for unmanaged data of the data chain table according to an establishment sequence of the data chain table from first to last under a preset release condition;
the memory management unit 512 is configured to release data that is not unmanaged by the target data linked list on the memory, and retain a target mapping relationship corresponding to the target data linked list on the memory;
wherein, the linked list managing unit 510 is further configured to:
after the second data linked list is established, when second target data managed by the second data linked list is obtained by modifying first target data managed by a pre-established first data linked list, the first target data is not managed on the first data linked list; deleting information of the first target data on the first mapping relation corresponding to the first data linked list
Alternatively,
the searching unit 511 is further configured to search, when the memory reaches the first preset water level, unmanaged data of the data chain table according to the first-to-last establishment sequence of the data chain table;
the disk control apparatus further includes:
a reading unit 523, configured to read, when the memory reaches a second preset water level, data pointed by the target mapping relationship from the log area;
a mapping data writing unit 513, configured to write the data pointed by the target mapping relationship into the data area;
a deleting unit 514, configured to delete the target mapping relationship in the memory.
Alternatively,
the disk control apparatus further includes:
a transaction number allocation unit 515, configured to allocate a transaction number to the data linked list corresponding to the transaction according to the write-in sequence of the transaction and according to an increment rule;
the searching unit 511 is further configured to search, starting from the data linked list with the smallest current transaction number, data that is not unmanaged in the data linked list according to the sequence of the transaction numbers from small to large.
Alternatively,
the disk control apparatus further includes:
a recovery unit 516, configured to execute a step of migrating the log area data under a preset recovery condition;
as shown in fig. 6, in the step of executing the relocation of the log area data, the recovery unit 516 includes:
a recovery searching module 517, configured to search for a mapping relationship;
a recovery determining module 518, configured to determine whether the data in the first log area corresponding to the mapping relationship has been migrated according to the information recorded in the mapping relationship;
a recycling determination module 519, configured to determine, according to information recorded in the mapping relationship, a space utilization rate on the first log area if the data on the first log area is not migrated;
a recovery execution module 520, configured to migrate, when a space utilization of the first log area is smaller than a preset utilization threshold, data of the first log area to a second log area, and update a mapping relationship corresponding to the migrated data, where the second log area is a free log area or a log area that is used when the log area is recovered;
and the recovery module 521 is configured to stop executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold, and otherwise continue executing the step of log area data relocation.
Alternatively,
the disk control apparatus further includes:
a transaction number allocation unit 515, configured to allocate a transaction number to the data linked list corresponding to the transaction according to the write-in sequence of the transaction and according to an increment rule;
the recovery searching module 517 is further configured to search, starting from the data linked list with the smallest current transaction number, a mapping relationship corresponding to the data linked list according to a sequence of the transaction numbers from small to large;
optionally, the preset recovery condition includes at least one of that the timer is overtime, the recovery operation on the memory data is completed, and the total water level of the log area reaches a preset water level threshold.
Alternatively,
the cache unit 506 is further configured to cache the data on the memory if the data is hot data; or reading data from the log area to the cache device for caching.
Optionally, the hotspot data includes data with a data size smaller than a preset data threshold and/or the hotspot data includes metadata.
Alternatively,
the log manager 504 is further configured to allocate a log area space to the data in the log area in order, and write the data in the log area space in addition in order.
Alternatively,
the disk control apparatus further includes:
a data area converting unit 522, configured to convert a currently idle log area into a data area when a space utilization rate of the data area is greater than a preset data area utilization threshold;
the log area converting unit 524 is configured to convert the data area converted from the idle log area into the log area when the space utilization of the log area is greater than a preset log area utilization threshold.
Alternatively,
the disk further comprises super blocks, each log area is provided with identification information, and the super blocks are used for recording the identification information of the modified log area after the log area is modified.
Alternatively, the log area and the data area are alternately arranged on the disk.
Alternatively,
the disk also comprises a block group, the block group comprises a log area and a data area with preset quantity, the log area and the data area of the block are continuously arranged,
a data manager 503, comprising:
a free area determining module 525, configured to determine a free target data area according to the management information of the block group;
an allocating module 508, configured to allocate a data area space for the data in the target data area;
the disk control apparatus further includes:
a metadata generation module 507, configured to generate target metadata according to the data and the data area space;
a write unit 501, configured to write target metadata into the cache device;
after the cache manager judges that the metadata is hot data, the log manager 504 is further configured to determine a target block group to which the target data area belongs; determining a log area available for the target block group; the target metadata is written to the available journal area.
Alternatively,
the log manager 504 is further configured to allocate a log area space on the log area for the mapping relationship; and writing the mapping relation into the log area space allocated by the mapping relation.
In summary, in a disk control apparatus including a disk, the disk includes a data area and a log area, after the write unit 501 writes data into a cache device, the cache manager 502 determines whether the data is hot data, and if the data is not hot data, the data manager 503 allocates a data area space for the data in the data area, and writes the data in the data area space; if the data is hot data, the log manager 504 allocates a log area space for the data in the log area, and writes the data in the log area space. Thus, the data to be written into the disk is divided into hot spot data and non-hot spot data, the hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk, the hot spot data is easy to cause the disk to generate fragments, the hot spot data is stored on a log area and is managed in a log mode, even if the data on the log area is frequently modified to generate disk fragments, the fragments are convenient to be recycled and the like, the non-hot data is stored in the data area, the disk is not easy to generate fragments due to the release of the non-hot data, the data area does not need to allocate excessive resources for disk fragment management, thus, by storing different types of data in different areas on the disk and managing them in different ways, the method can improve the management efficiency of the fragments on the disk, efficiently manage the disk fragments by the log area, and reduce the generation of the disk fragments.
Fig. 7 is a schematic diagram of a hardware structure of a disk control apparatus according to another embodiment of the present invention, where the disk control apparatus includes a processor CPU701, a cache device 703, a disk 702, a disk controller 705, and a bus 704. The disk 702 includes a data area and a log area, and in some embodiments, the cache device may be, for example, a memory.
The steps executed by the disk control apparatus in the above-described embodiment may be based on the structure of the disk control apparatus shown in fig. 7.
The processor 701 executes a program to cause the disk control apparatus to execute the method of the disk data management method described above, and various optional designs are specifically described as follows.
The processor 701 executes a program to cause the disk control apparatus to function as: writing data into the cache device; judging whether the data is hot data or not, wherein the hot data is data which can enable a disk to generate fragments with a preset number after being modified and released for a preset number of times after being stored on the disk; if the data is not the hot spot data, distributing a data area space for the data in the data area, and writing the data into the data area space; if the data is the hot data, distributing a log area space for the data in the log area, and writing the data into the log area space.
In an alternative design, the cache device is a memory, and the processor 701 executes a program to enable the disk control apparatus to function as follows: and after the log area space is allocated to the data in the log area, establishing a mapping relation between the data and the log area space.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: establishing a mapping relation between a plurality of target data and a log area space allocated to the plurality of target data, wherein the target data belongs to hot spot data; combining a plurality of write operations of a plurality of target data into one transaction; all target data of the transaction are written into the log area space, and when the write operation execution of one target data of the transaction fails, the write operation execution of other target data of the transaction fails.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: and caching the data belonging to the hot spot data on the memory.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: before writing all target data of a transaction into a log area space, establishing a data linked list according to a plurality of target data, wherein the data linked list is used for managing the target data, and the target data managed by the data linked list is the same as the target data of the transaction; managing the target data according to the data linked list; under the preset release condition, searching data which are not unmanaged by the data linked list according to the first-to-last establishment sequence of the data linked list; releasing unmanaged data of the target data linked list on the memory, and reserving a target mapping relation corresponding to the target data linked list on the memory; wherein, managing the target data according to the data linked list comprises: after the second data linked list is established, when second target data managed by the second data linked list is obtained by modifying first target data managed by a pre-established first data linked list, the first target data is not managed on the first data linked list; deleting information of the first target data on the first mapping relation corresponding to the first data linked list
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: when the memory reaches a first preset water level, searching data which are not unmanaged by the data linked list according to the first-to-last establishment sequence of the data linked list;
after releasing unmanaged data of the target data linked list on the memory, reading data pointed by the target mapping relation from the log area when the memory reaches a second preset water level;
writing the data pointed by the target mapping relation into a data area;
and deleting the target mapping relation on the memory.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
distributing transaction numbers for the data linked list corresponding to the transactions according to the writing sequence of the transactions and the increasing rule;
and starting from the data linked list with the minimum current transaction number, searching unmanaged data of the data linked list according to the sequence of the transaction numbers from small to large.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: executing the step of transferring the log area data under the preset recovery condition;
the step of executing the data relocation in the log area comprises the following steps:
searching a mapping relation;
judging whether the data on the first log area corresponding to the mapping relation is migrated or not according to the information recorded by the mapping relation;
if the data on the first log area is not completely migrated, determining the space utilization rate on the first log area according to the information recorded by the mapping relation;
when the space utilization rate of the first log area is smaller than a preset utilization rate threshold value, transferring the data of the first log area to a second log area, and updating a mapping relation corresponding to the transferred data, wherein the second log area is a free log area or a log area used when the log area is recovered;
and stopping executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold value, otherwise, continuing executing the step of log area data relocation.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
distributing transaction numbers for the data linked list corresponding to the transactions according to the writing sequence of the transactions and the increasing rule; starting from the data linked list with the minimum current transaction number, searching a mapping relation corresponding to the data linked list according to the sequence of the transaction numbers from small to large;
in an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
the preset recovery condition comprises at least one of overtime of a timer, completion of recovery operation on the memory data and reaching of a total water level of the log area to a preset water level threshold value.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
after judging whether the data is the hot data, if the data is the hot data, caching the data on the memory; or,
and reading the data from the log area to the cache device before writing the data into the cache device.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
the hotspot data comprises data with the data size smaller than a preset data threshold value and/or the hotspot data comprises metadata.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
and allocating log area spaces for the data in the log area according to the sequence, and additionally writing the data into the log area spaces in sequence.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
when the space utilization rate of the data area is greater than a preset data area utilization threshold value, converting the current idle log area into the data area;
and when the space utilization rate of the log area is greater than a preset log area utilization threshold value, converting the data area converted from the idle log area into the log area.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
the disk further comprises super blocks, each log area is provided with identification information, and the super blocks are used for recording the identification information of the modified log area after the log area is modified.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as:
the log area and the data area are alternately arranged on the magnetic disk.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: the disk also comprises a block group, the block group comprises a preset number of log areas and data areas, the log areas and the data areas of the block group are continuously arranged, and an idle target data area is determined according to the management information of the block group; allocating data area space for the data in the target data area;
after the data is written into the data area space, target metadata is generated according to the data and the data area space; writing the target metadata to the cache device; determining a target block group to which a target data area belongs after judging that the metadata are hot data; determining a log area available for the target block group; the target metadata is written to the available journal area.
In an alternative design, the processor 701 executes a program to enable the disk control apparatus to function as: distributing a log area space on the log area for the mapping relation; and writing the mapping relation into the log area space allocated by the mapping relation.
In summary, in a disk control apparatus including a disk, the disk includes a data area and a log area, after the processor 701 writes data into a cache device, the processor 701 determines whether the data is hot data, and if the data is not the hot data, the processor 701 allocates a data area space for the data in the data area, and writes the data in the data area space; if the data is hot data, the processor 701 allocates a log area space for the data in the log area, and writes the data in the log area space. Thus, the data to be written into the disk is divided into hot spot data and non-hot spot data, the hot spot data is data which can enable the disk to generate fragments with preset number after being modified and released for preset times after being stored on the disk, the hot spot data is easy to cause the disk to generate fragments, the hot spot data is stored on a log area and is managed in a log mode, even if the data on the log area is frequently modified to generate disk fragments, the fragments are convenient to be recycled and the like, the non-hot data is stored in the data area, the disk is not easy to generate fragments due to the release of the non-hot data, the data area does not need to allocate excessive resources for disk fragment management, thus, by storing different types of data in different areas on the disk and managing them in different ways, the method can improve the management efficiency of the fragments on the disk, efficiently manage the disk fragments by the log area, and reduce the generation of the disk fragments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (26)

1. A disk data management method is applied to a disk control device comprising a disk, wherein the disk comprises a data area and a log area, and the method comprises the following steps:
writing data into the cache device;
judging whether the data is hot spot data or not, wherein the hot spot data is data which can enable the disk to generate fragments with a preset number after being modified and released for a preset number of times after being stored on the disk;
if the data is not the hot spot data, allocating a data area space for the data in the data area, and writing the data into the data area space;
if the data is the hot spot data, distributing a log area space for the data in the log area, and writing the data into the log area space.
2. The method of claim 1, wherein the cache device is a memory,
after allocating the log zone space for the data in the log zone, the method further comprises:
and establishing a mapping relation between the data and the log area space.
3. The method of claim 2,
the establishing of the mapping relationship between the data and the log area space comprises:
establishing a mapping relation between a plurality of target data and a log area space allocated to the target data, wherein the target data belongs to hotspot data;
the writing the data into the log area space comprises:
combining a plurality of write operations of the plurality of target data into one transaction;
writing all target data of the transaction into a log area space, and when the write operation execution of one target data of the transaction fails, the write operation execution of other target data of the transaction fails.
4. The method of claim 3, further comprising:
and caching the data belonging to the hot spot data on the memory.
5. The method of claim 4,
before writing all target data of the transaction into the log area space, the method further comprises:
establishing a data linked list according to the plurality of target data, wherein the data linked list is used for managing the target data, and the target data managed by the data linked list is the same as the target data of the transaction;
managing the target data according to the data linked list;
under the condition of preset release, searching unmanaged data of the data linked list according to the first-to-last establishment sequence of the data linked list;
releasing unmanaged data of a target data linked list on the memory, and reserving a target mapping relation corresponding to the target data linked list on the memory;
wherein the managing the target data according to the data link table includes:
after a second data linked list is established, when second target data managed by the second data linked list is obtained by modifying first target data managed by a pre-established first data linked list, the first target data is not managed on the first data linked list; and deleting the information of the first target data on the first mapping relation corresponding to the first data linked list.
6. The method of claim 5,
under the preset release condition, searching unmanaged data of the data linked list according to the first-to-last establishment sequence of the data linked list comprises the following steps:
when the memory reaches a first preset water level, searching unmanaged data of the data linked list according to the first-to-last establishment sequence of the data linked list;
after releasing the unmanaged data of the target data linked list on the memory, the method further comprises:
when the memory reaches a second preset water level, reading data pointed by the target mapping relation from the log area;
writing the data pointed by the target mapping relation into the data area;
and deleting the target mapping relation on the memory.
7. The method of claim 5,
the method further comprises the following steps:
executing the step of transferring the log area data under the preset recovery condition;
the step of executing the data relocation in the log area comprises the following steps:
searching the mapping relation;
judging whether the data on the first log area corresponding to the mapping relation is migrated or not according to the information recorded by the mapping relation;
if the data on the first log area is not completely migrated, determining the space utilization rate on the first log area according to the information recorded by the mapping relation;
when the space utilization rate of the first log area is smaller than a preset utilization rate threshold value, transferring the data of the first log area to a second log area, and updating a mapping relation corresponding to the transferred data, wherein the second log area is a free log area or a log area used in a log area recovery;
and stopping executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold value, otherwise, continuing executing the step of log area data relocation.
8. The method of claim 7,
the method further comprises the following steps:
distributing transaction numbers for the data linked list corresponding to the transactions according to the writing sequence of the transactions and the increasing rule;
in the step of executing data relocation in the log area, the searching for the mapping relationship includes:
and starting from the data linked list with the minimum current transaction number, searching the mapping relation corresponding to the data linked list according to the sequence of the transaction numbers from small to large.
9. The method of claim 4,
the caching the data belonging to the hot spot data on the memory comprises:
after judging whether the data is the hot data or not, if the data is the hot data, reserving the data on the memory; or,
and before the data is written into the cache device, reading the data from the log area to the cache device for caching.
10. The method according to any one of claims 1 to 9, wherein the hotspot data comprises data with a data size smaller than a preset data threshold and/or wherein the hotspot data comprises metadata.
11. The method according to any one of claims 1 to 9,
allocating a log area space for the data in the log area, and writing the data into the log area space, including:
and allocating log area spaces for the data in the log area according to the sequence, and writing the data into the log area spaces in sequence.
12. The method according to any one of claims 1 to 9,
the method further comprises the following steps:
when the space utilization rate of the data area is greater than a preset data area utilization threshold value, converting the current idle log area into the data area;
and when the space utilization rate of the log area is greater than a preset log area utilization threshold value, converting the data area converted from the idle log area into the log area.
13. The method according to any one of claims 2 to 9,
the method further comprises the following steps:
distributing a log area space on a log area for the mapping relation;
and writing the mapping relation into the log area space allocated by the mapping relation.
14. A magnetic disk control apparatus, characterized by comprising:
a write unit for writing data to the buffer;
the cache manager is used for judging whether the data is hot spot data or not, wherein the hot spot data is data which can enable the disk to generate fragments with a preset number after being stored on the disk and modified and released for a preset number of times;
the data manager is used for allocating a data area space for the data in the data area of the disk if the data is not the hot data, and writing the data into the data area space;
and the log manager is used for allocating a log area space for the data in the log area of the disk and writing the data into the log area space if the data is the hot data.
15. The apparatus according to claim 14, wherein the cache device is a memory, and the apparatus further comprises:
and the mapping relation establishing unit is used for establishing the mapping relation between the data and the log area space.
16. The magnetic disk control apparatus according to claim 15,
the mapping relation establishing unit is further configured to establish a mapping relation between a plurality of target data and a log area space to which the plurality of target data are allocated, where the target data belong to hot spot data;
the log manager is further configured to combine a plurality of write operations of the plurality of target data into one transaction; writing all target data of the transaction into a log area space, and when the write operation execution of one target data of the transaction fails, the write operation execution of other target data of the transaction fails.
17. The method of claim 16, wherein the disk control unit further comprises:
and the cache unit is used for caching the data belonging to the hot spot data on the memory.
18. The magnetic disk control apparatus according to claim 17,
the magnetic disk control apparatus further includes:
a linked list establishing unit, configured to establish a data linked list according to the multiple target data, where the data linked list is used to manage the target data, and the target data managed by the data linked list is the same as the target data of the transaction;
the linked list management unit is used for managing the target data according to the data linked list;
the searching unit is used for searching unmanaged data of the data linked list according to the first-to-last establishing sequence of the data linked list under the preset releasing condition;
the memory management unit is used for releasing data which is not unmanaged by the target data linked list on the memory and reserving a target mapping relation corresponding to the target data linked list on the memory;
wherein, the linked list management unit is further configured to:
after a second data linked list is established, when second target data managed by the second data linked list is obtained by modifying first target data managed by a pre-established first data linked list, the first target data is not managed on the first data linked list; and deleting the information of the first target data on the first mapping relation corresponding to the first data linked list.
19. The magnetic disk control apparatus according to claim 18,
the searching unit is further configured to search unmanaged data of the data chain table according to an establishment sequence of the data chain table from first to last when the memory reaches a first preset water level;
the magnetic disk control apparatus further includes:
the reading unit is used for reading data pointed by the target mapping relation from the log area when the memory reaches a second preset water level;
a mapping data writing unit, configured to write the data pointed by the target mapping relationship into the data area;
and the deleting unit is used for deleting the target mapping relation on the memory.
20. The magnetic disk control apparatus according to claim 18,
the magnetic disk control apparatus further includes:
the recovery unit is used for executing the step of transferring the log area data under the preset recovery condition;
in the step of executing the relocation of the log area data, the recovery unit includes:
the recovery searching module is used for searching the mapping relation;
the recovery judging module is used for judging whether the data on the first log area corresponding to the mapping relation is migrated or not according to the information recorded by the mapping relation;
a recovery determining module, configured to determine, according to the information recorded in the mapping relationship, a space utilization rate on the first log area if the data on the first log area is not migrated;
the recovery execution module is used for transferring the data of the first log area to a second log area when the space utilization rate of the first log area is smaller than a preset utilization rate threshold value, and updating a mapping relation corresponding to the transferred data, wherein the second log area is a free log area or a used log area when the log area is recovered;
and the recovery module is used for stopping executing the step of log area data relocation when the total space water level of the current log area reaches a preset space threshold value, and otherwise, continuing executing the step of log area data relocation.
21. The magnetic disk control apparatus according to claim 20,
the magnetic disk control apparatus further includes:
a transaction number allocation unit, configured to allocate a transaction number to the data linked list corresponding to the transaction according to an increasing rule according to the write-in sequence of the transaction;
in the step of executing data relocation in the log area, the searching for the mapping relationship includes:
and starting from the data linked list with the minimum current transaction number, searching the mapping relation corresponding to the data linked list according to the sequence of the transaction numbers from small to large.
22. The magnetic disk control apparatus according to claim 17,
the cache unit is further configured to, if the data is hot data, reserve the data on the memory; or reading data from the log area to the cache device for caching.
23. The disc control apparatus according to any of claims 14 to 22, wherein the hot spot data comprises data having a data size smaller than a preset data threshold and/or the hot spot data comprises metadata.
24. The magnetic disk control apparatus according to any of claims 14 to 22,
the log manager is further configured to allocate a log area space in the log area for the data in sequence, and write the data in the log area space in sequence.
25. The magnetic disk control apparatus according to any of claims 14 to 22,
the magnetic disk control apparatus further includes:
the data area conversion unit is used for converting the current idle log area into the data area when the space utilization rate of the data area is greater than a preset data area utilization threshold value;
and the log area conversion unit is used for converting the data area converted from the idle log area into the log area when the space utilization rate of the log area is greater than a preset log area utilization threshold value.
26. The magnetic disk control apparatus according to any of claims 15 to 22,
the log manager is also used for distributing a log area space on the log area for the mapping relation; and writing the mapping relation into the log area space allocated by the mapping relation.
CN201610912077.5A 2016-10-19 2016-10-19 Hard disk data management method and hard disk control device Active CN106502587B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610912077.5A CN106502587B (en) 2016-10-19 2016-10-19 Hard disk data management method and hard disk control device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610912077.5A CN106502587B (en) 2016-10-19 2016-10-19 Hard disk data management method and hard disk control device

Publications (2)

Publication Number Publication Date
CN106502587A true CN106502587A (en) 2017-03-15
CN106502587B CN106502587B (en) 2019-10-25

Family

ID=58294298

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610912077.5A Active CN106502587B (en) 2016-10-19 2016-10-19 Hard disk data management method and hard disk control device

Country Status (1)

Country Link
CN (1) CN106502587B (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107197191A (en) * 2017-05-27 2017-09-22 深圳市景阳科技股份有限公司 The wiring method and device of network hard disc video recording
CN107506156A (en) * 2017-09-28 2017-12-22 焦点科技股份有限公司 A kind of io optimization methods of block device
CN107688442A (en) * 2017-09-04 2018-02-13 郑州云海信息技术有限公司 A kind of virtual block management method for solid state hard disc
CN107885455A (en) * 2016-09-30 2018-04-06 郑州云海信息技术有限公司 A kind of Disk Logs area dynamic adjusting method
CN108920095A (en) * 2018-06-06 2018-11-30 深圳市脉山龙信息技术股份有限公司 A kind of data store optimization method and apparatus based on CRUSH
CN109558457A (en) * 2018-12-11 2019-04-02 浪潮(北京)电子信息产业有限公司 A kind of method for writing data, device, equipment and storage medium
WO2020000492A1 (en) * 2018-06-30 2020-01-02 华为技术有限公司 Storage fragment managing method and terminal
CN110955610A (en) * 2018-09-27 2020-04-03 三星电子株式会社 Method for operating storage device, storage device and storage system
CN111125033A (en) * 2018-10-31 2020-05-08 深信服科技股份有限公司 Space recovery method and system based on full flash memory array
CN111694703A (en) * 2019-03-13 2020-09-22 阿里巴巴集团控股有限公司 Cache region management method and device and computer equipment
CN113010616A (en) * 2021-04-26 2021-06-22 广州小鹏汽车科技有限公司 Data processing method and data processing system
CN116069261A (en) * 2023-03-03 2023-05-05 苏州浪潮智能科技有限公司 Data processing method, system, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060174156A1 (en) * 2005-02-01 2006-08-03 Sridhar Balasubramanian Cache redundancy for lsi raid controllers
CN103514260A (en) * 2013-08-13 2014-01-15 中国科学技术大学苏州研究院 Internal storage log file system and achieving method thereof
CN103544045A (en) * 2013-10-16 2014-01-29 南京大学镇江高新技术研究院 HDFS-based virtual machine image storage system and construction method thereof
CN105224237A (en) * 2014-05-26 2016-01-06 华为技术有限公司 A kind of date storage method and device
CN105956090A (en) * 2016-04-27 2016-09-21 中国科学技术大学 I/O self-adaption-based file system log mode

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060174156A1 (en) * 2005-02-01 2006-08-03 Sridhar Balasubramanian Cache redundancy for lsi raid controllers
CN103514260A (en) * 2013-08-13 2014-01-15 中国科学技术大学苏州研究院 Internal storage log file system and achieving method thereof
CN103544045A (en) * 2013-10-16 2014-01-29 南京大学镇江高新技术研究院 HDFS-based virtual machine image storage system and construction method thereof
CN105224237A (en) * 2014-05-26 2016-01-06 华为技术有限公司 A kind of date storage method and device
CN105956090A (en) * 2016-04-27 2016-09-21 中国科学技术大学 I/O self-adaption-based file system log mode

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885455A (en) * 2016-09-30 2018-04-06 郑州云海信息技术有限公司 A kind of Disk Logs area dynamic adjusting method
CN107197191B (en) * 2017-05-27 2021-05-11 深圳市景阳科技股份有限公司 Writing method and device for network hard disk video
CN107197191A (en) * 2017-05-27 2017-09-22 深圳市景阳科技股份有限公司 The wiring method and device of network hard disc video recording
CN107688442A (en) * 2017-09-04 2018-02-13 郑州云海信息技术有限公司 A kind of virtual block management method for solid state hard disc
CN107688442B (en) * 2017-09-04 2020-11-20 苏州浪潮智能科技有限公司 Virtual block management method for solid state disk
CN107506156A (en) * 2017-09-28 2017-12-22 焦点科技股份有限公司 A kind of io optimization methods of block device
CN108920095A (en) * 2018-06-06 2018-11-30 深圳市脉山龙信息技术股份有限公司 A kind of data store optimization method and apparatus based on CRUSH
CN108920095B (en) * 2018-06-06 2021-06-29 深圳市脉山龙信息技术股份有限公司 Data storage optimization method and device based on CRUSH
US11842046B2 (en) 2018-06-30 2023-12-12 Huawei Technologies Co., Ltd. Storage fragment management method and terminal
WO2020000492A1 (en) * 2018-06-30 2020-01-02 华为技术有限公司 Storage fragment managing method and terminal
CN110955610A (en) * 2018-09-27 2020-04-03 三星电子株式会社 Method for operating storage device, storage device and storage system
CN111125033A (en) * 2018-10-31 2020-05-08 深信服科技股份有限公司 Space recovery method and system based on full flash memory array
CN111125033B (en) * 2018-10-31 2024-04-09 深信服科技股份有限公司 Space recycling method and system based on full flash memory array
CN109558457B (en) * 2018-12-11 2022-04-22 浪潮(北京)电子信息产业有限公司 Data writing method, device, equipment and storage medium
CN109558457A (en) * 2018-12-11 2019-04-02 浪潮(北京)电子信息产业有限公司 A kind of method for writing data, device, equipment and storage medium
CN111694703A (en) * 2019-03-13 2020-09-22 阿里巴巴集团控股有限公司 Cache region management method and device and computer equipment
CN111694703B (en) * 2019-03-13 2023-05-02 阿里云计算有限公司 Cache region management method and device and computer equipment
CN113010616A (en) * 2021-04-26 2021-06-22 广州小鹏汽车科技有限公司 Data processing method and data processing system
CN116069261A (en) * 2023-03-03 2023-05-05 苏州浪潮智能科技有限公司 Data processing method, system, equipment and storage medium

Also Published As

Publication number Publication date
CN106502587B (en) 2019-10-25

Similar Documents

Publication Publication Date Title
CN106502587B (en) Hard disk data management method and hard disk control device
CN104346357B (en) The file access method and system of a kind of built-in terminal
US8719501B2 (en) Apparatus, system, and method for caching data on a solid-state storage device
US7350017B2 (en) Magnetic disk unit, file management system, and file management method
CN103186350B (en) The moving method of mixing storage system and hot spot data block
CN112395212B (en) Method and system for reducing garbage recovery and write amplification of key value separation storage system
CN107924291B (en) Storage system
CN111007991B (en) Method for separating read-write requests based on NVDIMM and computer thereof
CN111026329B (en) Key value storage system based on host management tile record disk and data processing method
WO2012106362A2 (en) Apparatus, system, and method for managing eviction of data
CN102646069A (en) Method for prolonging service life of solid-state disk
WO2017149592A1 (en) Storage device
WO2012116369A2 (en) Apparatus, system, and method for managing contents of a cache
CN107817945B (en) Data reading method and system of hybrid memory structure
KR101017067B1 (en) Locality-Aware Garbage Collection Technique for NAND Flash Memory-Based Storage Systems
CN110968269A (en) SCM and SSD-based key value storage system and read-write request processing method
CN107015763A (en) Mix SSD management methods and device in storage system
CN112860594B (en) Solid-state disk address remapping method and device and solid-state disk
CN111078143B (en) Hybrid storage method and system for data layout and scheduling based on segment mapping
KR100907477B1 (en) Apparatus and method for managing index of data stored in flash memory
WO2012021847A2 (en) Apparatus, system and method for caching data
CN112799590B (en) Differentiated caching method for online main storage deduplication
KR101077901B1 (en) Apparatus and method for managing flash memory using log block level mapping algorithm
CN111984604B (en) Method for reducing fragments of log-structured file system and flash memory storage system
CN107533506B (en) Garbage collection method and equipment in log structured file system

Legal Events

Date Code Title Description
C06 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