CN117991969A - Disk space allocation method and related device - Google Patents

Disk space allocation method and related device Download PDF

Info

Publication number
CN117991969A
CN117991969A CN202211347952.1A CN202211347952A CN117991969A CN 117991969 A CN117991969 A CN 117991969A CN 202211347952 A CN202211347952 A CN 202211347952A CN 117991969 A CN117991969 A CN 117991969A
Authority
CN
China
Prior art keywords
allocation
space
allocation table
disk
storage units
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.)
Pending
Application number
CN202211347952.1A
Other languages
Chinese (zh)
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.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor 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 Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202211347952.1A priority Critical patent/CN117991969A/en
Publication of CN117991969A publication Critical patent/CN117991969A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a disk space allocation method, which comprises the following steps: receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk; responding to the space application request, and performing space allocation on the disk based on the allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different; and sending the target address to the equipment. So as to improve the efficiency of disk space allocation and reduce the resources consumed by the allocator. The application also discloses a disk space distribution device, a terminal device and a computer readable storage medium, which have the beneficial effects.

Description

Disk space allocation method and related device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a disk space allocation method, a disk space allocation apparatus, a terminal device, and a computer readable storage medium.
Background
With the continuous development of storage technology, a distributor is required to distribute disk space in management of a disk so as to improve the use efficiency of the disk space.
In the related art, disk space is generally allocated by data in an allocator. The data in the allocator may include a linked list, an interval tree, and a bitmap, among others. However, the data adopted in the distributor has the problems of large occupied resources, low distribution efficiency and the like.
Therefore, how to improve the efficiency of disk space allocation is a major concern for those skilled in the art.
Disclosure of Invention
The application aims to provide a disk space distribution method, a disk space distribution device, terminal equipment and a computer readable storage medium, so as to improve the efficiency of disk space distribution and reduce the resources consumed by a distributor.
In order to solve the above technical problems, the present application provides a disk space allocation method, including:
Receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
Responding to the space application request, and performing space allocation on the disk based on the allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
And sending the target address to the equipment.
Optionally, space allocation is performed on the disk based on the allocation table set of the disk to obtain a target address, including:
determining a corresponding allocation strategy based on the scene information corresponding to the space application request;
and carrying out space allocation processing on the space application request based on the allocation strategy and the plurality of allocation tables to obtain the target address.
Optionally, the allocation table group includes a first allocation table, a second allocation table and a third allocation table organized in a tree structure;
wherein the storage units in the first allocation table are a subset of the storage units in the second allocation table, and the storage units in the second allocation table are a subset of the storage units in the third allocation table;
the idle state values of the first storage units in the second allocation table are determined by the idle state values of the corresponding storage units in the first allocation table, and the storage units corresponding to the first storage units are all subsets of the first storage units;
The idle state values of the second storage units in the third allocation table are determined by the idle state values of the corresponding storage units in the second allocation table, and the storage units corresponding to the second storage units are all subsets of the second storage units.
Optionally, space allocation is performed on the disk based on the allocation table set of the disk to obtain a target address, including:
judging whether the data corresponding to the space application request is new data or not;
if yes, distributing the space application request based on the third distribution table to obtain the target address;
If not, the address closest to the address of the data corresponding to the space application request is allocated from the first allocation table or the second allocation table and is used as the target address.
Optionally, the third allocation table includes a complete allocation table and a complete unallocated table; correspondingly, the space application request is distributed based on the third distribution table to obtain the target address, which comprises the following steps:
Allocating an area including a plurality of unallocated memory units to the space application request based on a full unallocated table of the third allocation table;
And taking the addresses of preset offset positions in the areas of the plurality of unassigned memory units as the target addresses.
Optionally, the allocating an address closest to the address of the data corresponding to the space application request from the first allocation table or the second allocation table, and as the target address, includes:
Judging whether unallocated storage units exist in a plurality of storage units corresponding to a first storage unit corresponding to the data of the space application request;
If so, the address closest to the address of the data corresponding to the space application request is allocated based on the first allocation table and is used as the target address;
if not, the first storage unit closest to the address of the data corresponding to the space application request is allocated based on the second allocation table, and the offset address of the first storage unit is used as the target address.
Optionally, space allocation is performed on the disk based on the allocation table set of the disk to obtain a target address, including:
And performing space allocation processing on the space application request according to the sequence from the third allocation table to the second allocation table to the first allocation table to obtain the target address.
The application also provides a disk space distribution device, which comprises:
The system comprises a request receiving module, a request processing module and a storage module, wherein the request receiving module is used for receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
The space allocation module is used for responding to the space application request, and performing space allocation on the magnetic disk based on the allocation table group of the magnetic disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
and the address sending module is used for sending the target address to the equipment.
The application also provides a terminal device, comprising:
A memory for storing a computer program;
And a processor for implementing the steps of the disk space allocation method as described above when executing the computer program.
The present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the disk space allocation method as described above.
The application provides a disk space allocation method, which comprises the following steps: receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk; responding to the space application request, and performing space allocation on the disk based on the allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different; and sending the target address to the equipment.
The space allocation is carried out in the allocation table group based on the space application request to obtain the target address, the allocation table group comprises N allocation tables, idle state values of a plurality of storage units forming the space to be allocated of the magnetic disk are recorded in each allocation table, the sizes of the storage units of each allocation table are the same, the corresponding allocation tables of the storage units with different sizes are adopted in the space allocation process, the idle states of the storage units with different scales are determined, so that the space allocation can be carried out in different scales instead of the space allocation by adopting single structure data such as a linked list, the allocation efficiency is improved, and the resource consumption in the allocation process is reduced.
The application also provides a disk space distribution device, a terminal device and a computer readable storage medium, which have the advantages and are not described herein.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a disk space allocation method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a distributor of a disk space distribution method according to an embodiment of the present application;
FIG. 3 is a flowchart of a second method for allocating disk space according to an embodiment of the present application;
FIG. 4 is a flowchart of a third method for allocating disk space according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of a disk space allocation apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a terminal device according to the present application.
Detailed Description
The core of the application is to provide a disk space allocation method, a disk space allocation device, a terminal device and a computer readable storage medium, so as to improve the efficiency of disk space allocation and reduce the resources consumed by an allocator.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the related art, disk space is generally allocated by data in an allocator. The data in the allocator may include a linked list, an interval tree, and a bitmap, among others. However, the data adopted in the distributor has the problems of large occupied resources, low distribution efficiency and the like.
The application provides a disk space allocation method, which is characterized in that space allocation is carried out in an allocation table group based on a space application request to obtain a target address, the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of a disk, the sizes of the storage units of each allocation table are the same, and corresponding allocation tables of storage units with different sizes are adopted in the space allocation process, so that the idle states of the storage units with different scales are determined, space allocation can be carried out in different scales instead of single structural data such as a linked list, the allocation efficiency is improved, and the resource consumption in the allocation process is reduced.
The following describes a disk space allocation method provided by the present application through an embodiment.
Referring to fig. 1, fig. 1 is a flowchart of a disk space allocation method according to an embodiment of the present application.
In this embodiment, in order to improve the method, the method may include:
S101, receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
this step is intended to receive a space application request from the device for applying for free space in the space to be allocated of the disk.
The device may be a storage device in a server or a terminal device, or may be a separate independent storage device. When the device is a storage device in the server or the terminal device, the step is equivalent to that the upper device in the server or the terminal device sends a corresponding space application request to the storage device. If the device is a separate storage device, this step corresponds to the other terminal device sending a space application request to the storage device.
Further, the present embodiment may perform an allocation operation for allocation of devices. Wherein the allocator is a device that allocates disk space. Correspondingly, in this step, the distributor receives the space application request from other servers, or the distributor receives the space application request from other terminal devices.
The space application request is a request for performing space application on the disk. Generally, when a storage device or a allocator receives a corresponding space application request, space allocation is performed based on the space application request in a free space in a space to be allocated of a disk.
S102, responding to a space application request, and performing space allocation on the disk based on an allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, wherein each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of a magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
Based on S101, the step aims at responding to a space application request, and space allocation is carried out on the magnetic disk based on an allocation table group of the magnetic disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different.
Further, each allocation table records the free states of a plurality of storage units constituting the space to be allocated of all the disks.
Further, before responding to the space application request, it may also be determined whether the remaining space is greater than the preset space. If so, continuing to respond to the space application request. That is, when the remaining space in the disk is greater than the preset space, a subsequent process of space matching processing is performed.
The allocation table set of the disk may be structural data for spatial allocation by the allocator. The allocation table group of the magnetic disk comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different. Further, the storage units of each allocation table have a multiple relationship, that is, the storage units of the plurality of allocation tables are increased step by step. Further, allocation states of appropriate positions can be selected from the N allocation tables for allocation based on the data size in the space application request. It can be seen that the efficiency of allocation and the effect of allocation can be improved in the allocation process based on the N allocation tables.
Further, in order to improve the efficiency of space allocation for the structural data based on the allocator and improve the effect of allocation, the step may include:
s1021, determining a corresponding allocation strategy based on scene information corresponding to the space application request;
S1022, space allocation processing is carried out on the space application request based on the allocation strategy and the plurality of allocation tables, and the target address is obtained.
It can be seen that this alternative is mainly illustrative of how the matching to the target address is based on different allocation policies.
In the alternative scheme, a corresponding allocation strategy is determined based on scene information corresponding to a space application request; and performing space allocation processing on the space application request based on the allocation strategy and the plurality of allocation tables to obtain the target address. That is, in this alternative, the allocation policy corresponding to the allocation policy may be determined based on different scenario information, and further, allocation may be performed based on the allocation policy.
The scene information may be whether the space application request corresponds to old data, whether the data of the same type stored in the disk space exists, whether the data addresses to be stored are completely allocated, and the like. Accordingly, allocation policies of allocation tables of different memory cell sizes may be executed for a plurality of allocation tables in different cases. For example, the allocation is performed based on an allocation table with the smallest storage unit among the plurality of allocation tables, that is, the allocation table of the lowest layer. The allocation may be performed by using an allocation table located in the middle layer among the plurality of allocation tables, or may be performed by using an allocation table indicating the largest storage unit among the configuration data of the allocator.
When the space application request corresponds to old data, an address closest to the data address is allocated from an allocation table with the smallest storage unit.
When the stored data of the same type exists in the disk space, the storage unit closest to the data or the next storage unit is allocated from the allocation table with the smallest storage unit.
And when the data addresses to be stored are completely allocated, allocating the data addresses from the allocation table corresponding to the storage unit with the intermediate size.
And S103, sending the target address to the equipment.
On the basis of S102, this step aims at transmitting the target address to the device so that the device performs a corresponding operation based on the target address. Either data storage operations or space freeze operations.
In summary, the embodiment obtains the target address by performing space allocation in the allocation table group based on the space application request, where the allocation table group includes N allocation tables, each allocation table records idle state values of a plurality of storage units forming a space to be allocated of the disk, each storage unit of each allocation table has the same size, and corresponding allocation tables of storage units with different sizes are adopted in the space allocation process, so that idle states of storage units with different scales are determined, and space allocation can be performed at different scales instead of performing space allocation by adopting single structure data such as a linked list, thereby improving allocation efficiency and reducing resource consumption in the allocation process.
The following further describes a disk space allocation method according to another embodiment of the present application.
The allocation table group in this embodiment includes a first allocation table, a second allocation table, and a third allocation table organized in a tree structure;
wherein the storage units in the first allocation table are a subset of the storage units in the second allocation table, and the storage units in the second allocation table are a subset of the storage units in the third allocation table;
The idle state values of the first storage units in the second allocation table are determined by the idle state values of the corresponding storage units in the first allocation table, and the storage units corresponding to the first storage units are all subsets of the first storage units;
The idle state values of the second storage units in the third allocation table are determined by the idle state values of the corresponding storage units in the second allocation table, and the corresponding storage units of the second storage units are all subsets of the second storage units.
The storage unit of the first allocation table may be (AU, allocation unit) which is the smallest unit that can be allocated in the disk space, and indicates the minimum allocation disk space size, for example, 8KB when used for managing the disk.
That is, the allocation table group in the present embodiment includes a single allocation table. Wherein, each idle state value of the first allocation table corresponds to the smallest memory cell, the second level is inferior, and each idle state value of the third level represents the largest memory cell.
Further, each allocation table has recorded therein the free state values of a plurality of storage units constituting the space to be allocated of the disk. For example, each idle state value in the first allocation table corresponds to an idle state of a storage unit in the disk, and if an idle state value of 1 indicates unassigned, a 0 indicates allocated. The corresponding idle state value is denoted as 0 when a memory cell has been allocated and as 1 when a memory cell has not been allocated. So as to form a corresponding allocation table. It can be seen that the idle state of the corresponding memory cell can be determined by the content in the idle state value in the allocation table. Further, each bit of the idle state value in the second allocation table may represent an idle state of a plurality of idle state values in the first allocation table, for example, may represent an idle state of 512 units of data in the first allocation table. Further, each bit in the third allocation table is an idle state of a plurality of idle state values in the second allocation table.
Furthermore, to more accurately represent the idle state. The allocation tables in this embodiment can be classified into a complete allocation table and a complete unallocated table. Wherein each bit in the full allocation table indicates that the corresponding plurality of units of memory cells or idle state values are in a fully idle state or a fully idle state. Each bit in the fully unallocated table may represent a corresponding plurality of units of memory cells or idle state values as being in a fully unoccupied state or not being in a fully unoccupied state.
Therefore, in this embodiment, the allocation table may be used to allocate the memory cells in different sizes, so as to improve the efficiency of allocation based on the structure data.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a distributor of a disk space distribution method according to an embodiment of the present application.
Further, please refer to the allocation table set in fig. 2. The allocation table group comprises three allocation tables, namely an L0 layer allocation table, an L1 layer allocation table and an L2 layer allocation table.
Wherein the disk is diced according to AU, taking 8K as an example, a 1TB disk can be diced into 128MB 8K blocks, and the disk space is divided into 3 layers.
L0 layer: each BIT of the allocation table of the layer indicates whether 8K of space of the corresponding disk has been allocated, 0 indicates that it has been allocated, and 1 indicates that it has not been allocated.
Layer L1: the allocation table of this layer includes two tables, l1_v0 (full allocation table) and l1_v1 (full unallocated table), with each bit of the L1 layer representing the state of its corresponding 512L 0 layer bits.
A bit of l1_v0 of 0 indicates that all bits of its corresponding L0 layer are 0, and a1 indicates that not all bits of its corresponding L0 layer are 0.
A bit of l1_v1 of 1 indicates that all bits of its corresponding L0 layer are 1, and a bit of 0 indicates that not all bits of its corresponding L0 layer are 1.
L2 layer: the allocation table of this layer includes two tables, l2_v0 (full allocation table) and l2_v1 (full unallocated table), with each bit of the L2 layer representing the state of its corresponding 512L 1 layer bits.
A bit of l2_v0 of 0 indicates that all bits of its corresponding l1_v0 layer are 0, and a1 indicates that not all bits of its corresponding l1_v0 layer are 0.
A bit of l2_v1 of 0 indicates that all bits of its corresponding l1_v1 layer are 0, and a1 indicates that not all bits of its corresponding l1_v1 layer are 0.
It can be seen that the allocation table set described above includes three levels of allocation tables, each representing an idle state of a different disk space size. Further, in order to improve the efficiency and the distribution effect of the distribution, the L1 layer and the L2 layer respectively comprise distribution tables with different integrity so as to improve the accuracy of the distribution space.
Further, different allocation policies can be provided according to different scenes of the caller based on the allocation table group, that is, different allocation policies are adopted based on different scene information of the space application request. Wherein the plurality of allocation policies may include:
L0 policy: before allocation, a caller needs to query whether an allocated storage block exists in the SET to which the LBA (logical block address ) requested by the space application belongs, and the position of the L0 layer corresponding to the expected block address is calculated as a clue according to the allocated storage block address, and the corresponding block is allocated from the allocation table group according to the position of the L0 layer, so that the logical address continuous allocation blocks are continuous as much as possible, and the disk space allocation effect is improved.
In this embodiment, 128KB is taken as a SET, and 8KB is taken as an AU as an example, so that there are 16 AUs in a SET.
SET policy: when the SET to which the caller LBA belongs has no allocated block, an idle SET area is allocated from the L1 area to which the address belongs according to the last block address application of the address to which the caller LBA belongs as a clue, and the L0 position is calculated according to the offset of the LBA relative to the SET to finish allocation, and the adjacent space is quickly allocated from an allocation table with a higher storage unit size, so that the allocation effect is improved.
L1 strategy: when the caller writes new data, an area with the L1_v1 bit being 1 is preferentially allocated through the L2_v1 table, which is equivalent to an area with 512 AUs being free, and the area is used for the subsequent preferential allocation of the file, so that file allocation aggregation is realized, and meanwhile, the allocation efficiency is improved.
Default policy: the nearest L0 position of 1 is found through the traversal of the allocation table group, the searching mode is to lock the position of the L1_v0 table of 1 through the L2_v0 table, and then the nearest L0 position of 1 of the L0 table is found through the L1_v0 table, namely, the allocation mode from top to bottom, so that the allocation efficiency is improved.
Further, based on the allocation policy under the different scenarios, the allocation procedure in this embodiment may include:
Referring to fig. 3, fig. 3 is a flowchart of a second method for allocating disk space according to an embodiment of the present application.
Based on the above structural data, the method may include:
S201, receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
s202, judging whether data corresponding to a space application request is new data or not;
the step aims at determining the scene of the space application request, namely firstly judging whether the data corresponding to the space application request is new data, namely determining whether the data is written in the disk. If the data is old data, the subsequent data needs to be continuous with the old data as much as possible when the data is written, so that the data reading efficiency is improved, and the space allocation efficiency is improved.
Therefore, in this step, it is necessary to determine whether the data corresponding to the space application request is new data.
S203, if yes, distributing the space application request based on the third distribution table to obtain a target address;
on the basis of S202, this step aims to directly use the third allocation table to find a suitable space with a larger capacity as a target address when the data is new data, so that continuous space can be effectively allocated when other data is written and rewritten later, and the read-write performance of the data is improved.
Further, in order to improve the efficiency and effect of space allocation, the appropriate disk space is quickly determined from the structural data, and the third allocation table in the step comprises a complete allocation table and a complete unallocated table; further, the process may include:
S2031, allocating an area including a plurality of unallocated memory units to the space application request based on the full unallocated table of the third allocation table;
S2032, an address of a preset offset position in the areas of the plurality of unassigned memory cells is set as a target address.
It can be seen that this alternative is mainly illustrative of how the allocation is made. In this alternative, first, an area including a plurality of unallocated memory units is allocated to the space application request based on the completely unallocated table based on the third allocation table; and taking the addresses of preset offset positions in the areas of the plurality of unassigned memory units as target addresses. The completely unallocated table indicates completely unallocated space in the storage space, so as to accurately determine a large amount of unallocated space, and improve the efficiency of subsequent data reading and writing.
If not, the address closest to the address of the data corresponding to the space application request is allocated from the first allocation table or the second allocation table as the target address S204.
Further, in S202, when the data corresponding to the space application request is old, the present step is to allocate, as the target address, the address closest to the address of the data corresponding to the space application request from the first allocation table or the second allocation table. So that the space application request is allocated to space addresses which are as continuous as possible, thereby improving the allocation effect.
Further, in order to quickly determine the address that is as continuous as possible with the space application request in different situations for effective allocation, this step may include:
S2041, judging whether unallocated storage units exist in a plurality of storage units corresponding to a first storage unit corresponding to data of a space application request;
S2042, if yes, allocating an address closest to the address of the data corresponding to the space application request based on the first allocation table, and taking the address as a target address;
s2043, if not, allocating the first storage unit closest to the address of the data corresponding to the space application request based on the second allocation table, and taking the offset address of the first storage unit as the target address.
It can be seen that this alternative is mainly illustrative of how consecutive addresses are matched in different situations. In the alternative scheme, judging whether unallocated storage units exist in a plurality of storage units corresponding to a first storage unit corresponding to data of a space application request; the first storage unit SET is SET. That is, it is determined whether there are any more memory units (AUs) in the SET that can be allocated. If so, the address closest to the address of the data corresponding to the space application request is allocated from the first allocation table and is used as the affiliated target address; if not, the first storage unit closest to the address of the data corresponding to the space application request is allocated based on the second allocation table, and the offset address of the first storage unit is taken as the target address. That is, the nearest first storage unit is determined from the storage units of one stage larger than the AU, and the address is determined, keeping the closest storage address acquired. Therefore, the address which is continuous as far as possible can be allocated as the target address under any condition, and the data storage efficiency is finally improved.
Furthermore, on the basis of the above structural data, the method may include:
And performing space allocation processing on the space application request according to the sequence from the third allocation table to the second allocation table to the first allocation table to obtain a target address.
It can be seen that this alternative is mainly an allocation procedure that illustrates how the default policy is performed. Therefore, in the alternative scheme, the accurate space in the structural data can be rapidly determined through the sequence of the storage space from large to small, and space allocation is completed.
It can be seen that, in this embodiment, the space allocation is performed in the allocation table set based on the space application request to obtain the target address, where the allocation table set includes N allocation tables, each allocation table records idle state values of multiple storage units forming the space to be allocated of the disk, each storage unit of each allocation table has the same size, and corresponding allocation tables with storage units of different sizes are adopted in the space allocation process, so that idle states of storage units of different scales are determined, so that space allocation can be performed at different scales, instead of performing space allocation by adopting single structure data such as a linked list, thereby improving allocation efficiency and reducing resource consumption in the allocation process.
The following further describes a disk space allocation method provided by the present application through a further specific embodiment.
Referring to fig. 4, fig. 4 is a flowchart of a third method for allocating disk space according to an embodiment of the present application.
In this embodiment, the method may include:
S301, receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
The space application request may also include an allocation policy and an allocation hint, among other things. That is, the caller may pass allocation policies and allocation hints when it invokes the allocation table set to apply for allocation space. Wherein the allocation policy is an allocation policy determined based on the context information, the allocation hint may be an address that is desired to be allocated, e.g., if it is old data, then the allocation hint is an address of the old data.
S302, judging whether the residual space is larger than a preset space;
that is, it is determined whether the remaining space of the allocation table group is sufficient, if so, the allocation operation of the space is continued, otherwise, a failure message is returned.
S303, if so, performing space allocation processing on the space application request according to an allocation strategy and a plurality of allocation tables corresponding to the scene information to obtain a target address; the classification strategy comprises an L0 strategy, a SET strategy and an L1 strategy.
When using the L0 policy, the allocation hint is the position of L0 that it expects to allocate, if the position is 1, i.e. AU is not allocated, allocation is directly completed, and if the position is 0, i.e. AU has been allocated, allocation is downgraded to the SET policy.
When using the SET strategy, find the position of L1 corresponding to the old data according to the allocation clue, find the L0 area corresponding to the L1, find a completely free SET in the area, if there is a free SET, this allocates its offset position relative to SET according to the allocation clue, and completes the allocation process, otherwise downgrade to the L1 allocation strategy.
When the L1 strategy is used, the strategy directly inquires whether the allocation table group has a complete area with L0 corresponding to L1 being 1, namely, an area with all 512 AUs corresponding to L1 being unassigned, if yes, the offset position of the corresponding SET is directly found according to allocation clues, and allocation is completed. Otherwise downgrade to the default allocation policy.
The default policy, i.e. traversing to the most recently free block in the data structure of the allocation table set according to the allocation hint, completes the allocation.
It can be seen that, in this embodiment, the space allocation is performed in the allocation table set based on the space application request to obtain the target address, where the allocation table set includes N allocation tables, each allocation table records idle state values of multiple storage units forming the space to be allocated of the disk, each storage unit of each allocation table has the same size, and corresponding allocation tables with storage units of different sizes are adopted in the space allocation process, so that idle states of storage units of different scales are determined, so that space allocation can be performed at different scales, instead of performing space allocation by adopting single structure data such as a linked list, thereby improving allocation efficiency and reducing resource consumption in the allocation process.
The following describes a disk space allocation apparatus provided in an embodiment of the present application, and the disk space allocation apparatus described below and the disk space allocation method described above may be referred to correspondingly.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a disk space allocation apparatus according to an embodiment of the present application.
In this embodiment, the apparatus may include:
A request receiving module 100, configured to receive a space application request from a device, where the space application request is used to apply for a free space in a space to be allocated of a disk;
the space allocation module 200 is configured to respond to a space application request, and perform space allocation on the disk based on the allocation table set of the disk, so as to obtain a target address; the allocation table group comprises N allocation tables, wherein each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of a magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
The address sending module 300 is configured to send the target address to the device.
Optionally, the space allocation module 200 is specifically configured to determine a corresponding allocation policy based on the scenario information corresponding to the space application request; and performing space allocation processing on the space application request based on the allocation strategy and the plurality of allocation tables to obtain the target address.
Optionally, the allocation table group includes a first allocation table, a second allocation table and a third allocation table organized in a tree structure;
wherein the storage units in the first allocation table are a subset of the storage units in the second allocation table, and the storage units in the second allocation table are a subset of the storage units in the third allocation table;
The idle state values of the first storage units in the second allocation table are determined by the idle state values of the corresponding storage units in the first allocation table, and the storage units corresponding to the first storage units are all subsets of the first storage units;
The idle state values of the second storage units in the third allocation table are determined by the idle state values of the corresponding storage units in the second allocation table, and the corresponding storage units of the second storage units are all subsets of the second storage units.
Optionally, the space allocation module 200 may include:
The data judging unit is used for judging whether the data corresponding to the space application request is new data or not;
the new data storage unit is used for distributing the space application request based on the third distribution table to obtain a target address when the data corresponding to the space application request is new data;
and the old data storage unit is used for allocating an address closest to the address of the data corresponding to the space application request from the first allocation table or the second allocation table and taking the address as a target address when the data corresponding to the space application request is not new data.
Optionally, the new data storage unit is specifically configured to allocate an area including a plurality of unallocated storage units to the space application request based on the completely unallocated table of the third allocation table; taking the address of a preset offset position in the areas of a plurality of unassigned memory units as a target address
Optionally, the old data storage unit is specifically configured to determine whether an unallocated storage unit exists in a plurality of storage units corresponding to a first storage unit corresponding to data requested by the space application; if so, the address closest to the address of the data corresponding to the space application request is allocated based on the first allocation table and is used as a target address; if not, the first storage unit closest to the address of the data corresponding to the space application request is allocated based on the second allocation table, and the offset address of the first storage unit is taken as the target address.
Optionally, the space allocation module 200 is specifically configured to perform space allocation processing on the space application request according to the sequence from the third allocation table to the second allocation table to the first allocation table, so as to obtain the target address.
The present application also provides a terminal device, please refer to fig. 6, fig. 6 is a schematic structural diagram of the terminal device provided by the present application, and the terminal device may include:
A memory for storing a computer program;
and a processor for implementing the steps of any of the disk space allocation methods described above when executing the computer program.
As shown in fig. 6, which is a schematic structural diagram of a terminal device, the terminal device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all complete communication with each other through a communication bus 13.
In an embodiment of the present application, the processor 10 may be a central processing unit (Central Processing Unit, CPU), an asic, a dsp, a field programmable gate array, or other programmable logic device, etc.
Processor 10 may call a program stored in memory 11, and in particular, processor 10 may perform operations in an embodiment of an abnormal IP identification method.
The memory 11 is used for storing one or more programs, and the programs may include program codes including computer operation instructions, and in the embodiment of the present application, at least the programs for implementing the following functions are stored in the memory 11:
Receiving a space application request from equipment, wherein the space application request is used for applying for the free space in the space to be allocated of the disk;
Responding to a space application request, and performing space allocation on the disk based on the allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, wherein each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of a magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
the target address is sent to the device.
A program area and a storage data area, wherein the storage program area can store an operating system, at least one application program required by functions, and the like; the storage data area may store data created during use.
In addition, the memory 11 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid-state storage device.
The communication interface 12 may be an interface of a communication module for interfacing with other devices or systems.
Of course, it should be noted that the structure shown in fig. 6 does not limit the terminal device in the embodiment of the present application, and the terminal device may include more or fewer components than those shown in fig. 6 or may combine some components in practical applications.
The present application also provides a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of any of the disk space allocation methods described above.
The computer readable storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
For the description of the computer-readable storage medium provided by the present application, refer to the above method embodiments, and the disclosure is not repeated here.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above description is provided in detail for a disk space allocation method, a disk space allocation apparatus, a terminal device, and a computer readable storage medium. The principles and embodiments of the present application have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the method of the present application and its core ideas. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the application can be made without departing from the principles of the application and these modifications and adaptations are intended to be within the scope of the application as defined in the following claims.

Claims (10)

1. A disk space allocation method, comprising:
Receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
Responding to the space application request, and performing space allocation on the disk based on the allocation table group of the disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
And sending the target address to the equipment.
2. The disk space allocation method according to claim 1, wherein performing space allocation on the disk based on the allocation table group of the disk to obtain a target address, comprises:
determining a corresponding allocation strategy based on the scene information corresponding to the space application request;
and carrying out space allocation processing on the space application request based on the allocation strategy and the plurality of allocation tables to obtain the target address.
3. The disk space allocation method according to claim 1, wherein the allocation table group includes a first allocation table, a second allocation table, and a third allocation table organized in a tree structure;
wherein the storage units in the first allocation table are a subset of the storage units in the second allocation table, and the storage units in the second allocation table are a subset of the storage units in the third allocation table;
the idle state values of the first storage units in the second allocation table are determined by the idle state values of the corresponding storage units in the first allocation table, and the storage units corresponding to the first storage units are all subsets of the first storage units;
The idle state values of the second storage units in the third allocation table are determined by the idle state values of the corresponding storage units in the second allocation table, and the storage units corresponding to the second storage units are all subsets of the second storage units.
4. The disk space allocation method according to claim 3, wherein performing space allocation on the disk based on the allocation table group of the disk to obtain the target address comprises:
judging whether the data corresponding to the space application request is new data or not;
if yes, distributing the space application request based on the third distribution table to obtain the target address;
If not, the address closest to the address of the data corresponding to the space application request is allocated from the first allocation table or the second allocation table and is used as the target address.
5. The disk space allocation method according to claim 4, wherein the third allocation table includes a complete allocation table and a complete unallocated table; correspondingly, the space application request is distributed based on the third distribution table to obtain the target address, which comprises the following steps:
Allocating an area including a plurality of unallocated memory units to the space application request based on a full unallocated table of the third allocation table;
And taking the addresses of preset offset positions in the areas of the plurality of unassigned memory units as the target addresses.
6. The disk space allocation method according to claim 4, wherein allocating an address closest to an address of data corresponding to the space application request from the first allocation table or the second allocation table as the target address comprises:
Judging whether unallocated storage units exist in a plurality of storage units corresponding to a first storage unit corresponding to the data of the space application request;
If so, the address closest to the address of the data corresponding to the space application request is allocated based on the first allocation table and is used as the target address;
if not, the first storage unit closest to the address of the data corresponding to the space application request is allocated based on the second allocation table, and the offset address of the first storage unit is used as the target address.
7. The disk space allocation method according to claim 3, wherein performing space allocation on the disk based on the allocation table group of the disk to obtain the target address comprises:
And performing space allocation processing on the space application request according to the sequence from the third allocation table to the second allocation table to the first allocation table to obtain the target address.
8. A disk space allocation apparatus, comprising:
The system comprises a request receiving module, a request processing module and a storage module, wherein the request receiving module is used for receiving a space application request from equipment, wherein the space application request is used for applying for a free space in a space to be allocated of a disk;
The space allocation module is used for responding to the space application request, and performing space allocation on the magnetic disk based on the allocation table group of the magnetic disk to obtain a target address; the allocation table group comprises N allocation tables, each allocation table is recorded with idle state values of a plurality of storage units forming a space to be allocated of the magnetic disk, the sizes of the storage units of each allocation table are the same, and the sizes of the storage units in different allocation tables in the allocation table group are different;
and the address sending module is used for sending the target address to the equipment.
9. A terminal device, comprising:
A memory for storing a computer program;
A processor for implementing the steps of the disk space allocation method according to any one of claims 1 to 7 when executing said computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the disk space allocation method according to any of claims 1 to 7.
CN202211347952.1A 2022-10-31 2022-10-31 Disk space allocation method and related device Pending CN117991969A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211347952.1A CN117991969A (en) 2022-10-31 2022-10-31 Disk space allocation method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211347952.1A CN117991969A (en) 2022-10-31 2022-10-31 Disk space allocation method and related device

Publications (1)

Publication Number Publication Date
CN117991969A true CN117991969A (en) 2024-05-07

Family

ID=90897914

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211347952.1A Pending CN117991969A (en) 2022-10-31 2022-10-31 Disk space allocation method and related device

Country Status (1)

Country Link
CN (1) CN117991969A (en)

Similar Documents

Publication Publication Date Title
CN109154917B (en) Storage system and solid state disk
US10223010B2 (en) Dynamic storage device provisioning
CN104317742B (en) Automatic thin-provisioning method for optimizing space management
US9489409B2 (en) Rollover strategies in a N-bit dictionary compressed column store
CN102650931B (en) Method and system for writing data
RU2661280C2 (en) Massive controller, solid state disk and data recording solid state disk control method
TWI684098B (en) Memory system and control method for controlling non-volatile memory
US20130117527A1 (en) Method and apparatus for thin provisioning
CN105095094A (en) Memory management method and equipment
CN103116552A (en) Method and device for distributing storage space in distributed type storage system
US11093410B2 (en) Cache management method, storage system and computer program product
CN114185818B (en) GPU (graphics processing Unit) memory access self-adaptive optimization method and device based on extended page table
CN109960471B (en) Data storage method, device, equipment and storage medium
CN104536903A (en) Mixed storage method and system for conducting classified storage according to data attributes
CN101645837A (en) Method and device for realizing load balancing
CN110727517A (en) Memory allocation method and device based on partition design
CN110389712B (en) Data writing method and device, solid state disk and computer readable storage medium
CN111984425A (en) Memory management method, device and equipment for operating system
CN117311621A (en) Cache disk space allocation method and device, computer equipment and storage medium
US20170364442A1 (en) Method for accessing data visitor directory in multi-core system and device
CN116795735B (en) Solid state disk space allocation method, device, medium and system
CN117806989A (en) High-speed data processing method, device, equipment and medium based on persistent memory
CN115437579B (en) Metadata management method and device, computer equipment and readable storage medium
CN108897618B (en) Resource allocation method based on task perception under heterogeneous memory architecture
CN117991969A (en) Disk space allocation method and related device

Legal Events

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