Storage space management method, system, electronic equipment and storage medium

文档序号:1627685 发布日期:2020-01-14 浏览:5次 中文

阅读说明:本技术 一种存储空间管理方法、系统、电子设备及存储介质 (Storage space management method, system, electronic equipment and storage medium ) 是由 刘志勇 于 2019-09-05 设计创作,主要内容包括:本申请公开了一种存储空间管理方法,所述方法包括查询存储状态由非可用状态转换为可用状态的目标存储子区间;判断是否存在相邻存储子区间;其中,所述相邻存储子区间为与所述目标存储子区间物理地址相邻且存储状态为可用状态的存储子区间;若是,则将所述目标存储子区间与所述相邻存储子区间合并为可用存储子区间,以便在所述可用存储子区间中写入数据。本申请能够提供连续的存储空间,提高写入数据的连续性。本申请还公开了一种存储空间管理系统、一种存储介质及一种电子设备,具有以上有益效果。(The application discloses a storage space management method, which comprises the steps of inquiring a target storage subinterval of which the storage state is converted from a non-available state to an available state; judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state; and if so, merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval so as to write data in the available storage subinterval. The method and the device can provide continuous storage space and improve the continuity of written data. The application also discloses a storage space management system, a storage medium and an electronic device, which have the beneficial effects.)

1. A method for memory space management, comprising:

inquiring a target storage subinterval of which the storage state is converted from a non-available state into an available state;

judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state;

and if so, merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval so as to write data in the available storage subinterval.

2. The method of claim 1, further comprising, after merging the target storage subinterval and the neighboring storage subinterval into an available storage subinterval:

and determining a target linked list corresponding to the available storage subinterval according to the space size of the available storage subinterval, and recording the address information of the available storage subinterval in the target linked list so as to store the data to be written into the available storage subinterval according to the address information in the target linked list.

3. The storage space management method according to claim 1, further comprising:

when a storage space dividing instruction is received, averagely dividing the total storage space into N storage intervals;

and dividing the storage interval into a plurality of storage sub-intervals according to the storage granularity corresponding to each storage space.

4. The storage space management method according to claim 3, further comprising:

constructing a linked list corresponding to each storage interval; the linked list stores the address information of the storage subinterval in an available state in the storage interval;

and when the storage subinterval with the changed storage state is detected, executing updating operation on the linked list corresponding to the storage subinterval with the changed storage state.

5. The storage space management method according to claim 3, wherein before dividing the storage interval into a plurality of storage sub-intervals according to the storage granularity corresponding to each of the storage spaces, the method further comprises:

sequentially setting a corresponding interval serial number i for each storage interval according to the sequence of the physical addresses from small to large; wherein i is 0, 1, 2, 3, … … N-1;

determining the storage granularity B of each storage interval according to the interval serial number i; wherein B is 2iX grain, grain is the minimum particle size.

6. The storage space management method of claim 3, wherein determining whether adjacent storage subintervals exist comprises:

and judging whether the adjacent storage subintervals exist in the storage interval in which the target storage subinterval is located.

7. The storage space management method according to claim 1, further comprising:

and when a data storage task is received, writing data into the storage subinterval with the largest storage space so as to complete the data storage task.

8. A storage space management system, comprising:

the query module is used for querying a target storage subinterval of which the storage state is converted from the unavailable state into the available state;

the judging module is used for judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state;

and the interval merging module is used for merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval when the adjacent storage subinterval exists so as to write data in the available storage subinterval.

9. An electronic device, comprising a memory in which a computer program is stored and a processor, wherein the processor implements the steps of the memory space management method according to any one of claims 1 to 7 when calling the computer program in the memory.

10. A storage medium having stored thereon computer-executable instructions which, when loaded and executed by a processor, carry out the steps of a storage space management method according to any one of claims 1 to 7.

Technical Field

The present disclosure relates to the field of data storage technologies, and in particular, to a method and a system for managing a storage space, an electronic device, and a storage medium.

Background

The full flash memory is an important direction of memory development, and with the gradual decrease of the price of the SSD, the full flash memory product must further seize the market share of the traditional memory in the future, and becomes the primary product in the memory field. Compared with the traditional storage, the full flash storage has absolute advantages in performance, and the main difference of the data organization mode is that the data storage mode of the traditional storage is an overwriting mode, namely, when data are written into the same logical address, the data are written into the same place and overwrite old data each time, while the full flash storage adopts an additional writing mode, namely, when data are written into the same logical address, the data are written into a new place each time, and the old data cannot be overwritten, but are processed through garbage collection.

For a full flash memory system, it has better read/write efficiency to read/write data by using a continuous data storage space, but in the related art, data is stored according to the sequence of physical addresses in the storage space, so the improvement of the related art described above is low in the continuity of write data.

Therefore, how to provide a continuous storage space and improve the continuity of the written data is a technical problem that needs to be solved by those skilled in the art at present.

Disclosure of Invention

The application aims to provide a storage space management method, a storage space management system, a storage medium and an electronic device, which can provide continuous storage space and improve the continuity of written data.

In order to solve the above technical problem, the present application provides a storage space management method, including:

inquiring a target storage subinterval of which the storage state is converted from a non-available state into an available state;

judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state;

and if so, merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval so as to write data in the available storage subinterval.

Optionally, after the target storage subinterval and the adjacent storage subinterval are merged into an available storage subinterval, the method further includes:

and determining a target linked list corresponding to the available storage subinterval according to the space size of the available storage subinterval, and recording the address information of the available storage subinterval in the target linked list so as to store the data to be written into the available storage subinterval according to the address information in the target linked list.

Optionally, the method further includes:

when a storage space dividing instruction is received, averagely dividing the total storage space into N storage intervals;

and dividing the storage interval into a plurality of storage sub-intervals according to the storage granularity corresponding to each storage space.

Optionally, the method further includes:

constructing a linked list corresponding to each storage interval; the linked list stores the address information of the storage subinterval in an available state in the storage interval;

and when the storage subinterval with the changed storage state is detected, executing updating operation on the linked list corresponding to the storage subinterval with the changed storage state.

Optionally, before dividing the storage interval into a plurality of storage sub-intervals according to the storage granularity corresponding to each storage space, the method further includes:

sequentially setting a corresponding interval serial number i for each storage interval according to the sequence of the physical addresses from small to large; wherein i is 0, 1, 2, 3, … … N-1;

determining the storage granularity B of each storage interval according to the interval serial number i; wherein B is 2iX grain, grain is the minimum particle size.

Optionally, the determining whether there is an adjacent storage subinterval includes:

and judging whether the adjacent storage subintervals exist in the storage interval in which the target storage subinterval is located.

Optionally, the method further includes:

and when a data storage task is received, writing data into the storage subinterval with the largest storage space so as to complete the data storage task.

The present application also provides a storage space management system, including:

the query module is used for querying a target storage subinterval of which the storage state is converted from the unavailable state into the available state;

the judging module is used for judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state;

and the interval merging module is used for merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval when the adjacent storage subinterval exists so as to write data in the available storage subinterval.

The present application also provides a storage medium having a computer program stored thereon, which when executed implements the steps performed by the above-described storage space management method.

The application also provides an electronic device, which comprises a memory and a processor, wherein the memory is stored with a computer program, and the processor realizes the steps executed by the storage space management method when calling the computer program in the memory.

The application provides a storage space management method, which comprises the steps of inquiring a target storage subinterval of which the storage state is converted from a non-available state into an available state; judging whether adjacent storage subintervals exist or not; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state; and if so, merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval.

According to the method and the device, after the target storage subinterval converted from the non-available state to the available state is inquired, whether an adjacent storage subinterval adjacent to a physical address of the target storage subinterval exists in the current available storage subinterval or not is judged, if yes, the target storage subinterval and the storage subinterval adjacent to the target storage subinterval are combined so as to obtain a continuous storage space, and after data are written by using the combined storage subinterval, the continuity of the written data can be improved. The application also provides a storage space management system, a storage medium and an electronic device, which have the beneficial effects and are not repeated herein.

Drawings

In order to more clearly illustrate the embodiments of the present application, the drawings needed for the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.

Fig. 1 is a flowchart of a storage space management method according to an embodiment of the present application;

fig. 2 is a flowchart of a method for dividing a storage interval according to an embodiment of the present disclosure;

FIG. 3 is a block model diagram of a storage space provided by an embodiment of the present application;

FIG. 4 is a diagram of a partition size block model provided in this embodiment of the present application;

fig. 5 is a schematic structural diagram of a storage space management system according to an embodiment of the present application.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

Referring to fig. 1, fig. 1 is a flowchart of a storage space management method according to an embodiment of the present disclosure.

The specific steps may include:

s101: inquiring a target storage subinterval of which the storage state is converted from a non-available state into an available state;

the embodiment can be applied to a full flash memory system, and when the full flash memory system mentioned in the embodiment performs space management, the memory space can be divided into a plurality of memory sub-intervals, and then the memory sub-intervals are used for storing data. As a possible implementation manner, the present embodiment may use a bitmap to record whether all storage sub-intervals are usable, that is, record the storage status of each storage sub-interval through the bitmap. The storage state may include an available state and a non-available state, and when the storage subinterval is in the available state, new data may be written, and when the storage subinterval is in the non-available state, it indicates that the written data in the storage subinterval cannot be written with new data.

The purpose of this step is to determine the storage subinterval whose storage status is changed from the unavailable status to the available status, and in the full flash storage system, because the data is written in the way of additional writing, when writing data to the same logical address, the data is written in a new storage subinterval each time, and the old data is not overwritten, but is processed by garbage collection. When the storage system performs a garbage collection operation, there may be a target storage subinterval that transitions from a non-available state to an available state.

S102: judging whether adjacent storage subintervals exist or not; if yes, entering S103; if not, entering S104;

the purpose of this step is to determine whether there is a storage sub-interval adjacent to the target storage sub-interval in all storage sub-intervals in the available state, where the aforementioned adjacent storage sub-interval is a storage sub-interval adjacent to the physical address of the target storage sub-interval and in which the storage state is the available state.

As a possible implementation manner, this embodiment may preset a bitmap recording the storage status of each storage sub-interval, and may determine the storage sub-interval in the available state according to the bitmap, and further determine the adjacent storage sub-interval according to the first address and the last address of the target storage sub-interval. That is, the first address or the last address of the adjacent storage subinterval determined in the present embodiment is adjacent to the first address or the last address of the target storage subinterval.

S103: merging the target storage subinterval and the adjacent storage subinterval into an available storage subinterval so as to write data in the available storage subinterval.

Based on the determination of the existence of the adjacent storage subintervals at S102, the step merges the adjacent storage subintervals with the target storage subintervals to obtain the available storage subintervals, and the above process can obtain continuous available storage subintervals with larger storage space. When data needs to be written into the available storage sub-interval, the available storage sub-interval which is possibly continuous can be found out, so that the written data can be ensured to be spliced into continuous data as much as possible when the disk is written subsequently.

It should be noted that, in this embodiment, the data writing operation may be performed according to a preset rule, where the preset rule is: and when a data writing task is received, selecting the available storage subinterval to perform data writing operation. When a plurality of available storage subintervals exist, the available storage subinterval with the largest storage space can be selected for data writing. As another possible implementation manner, when there are multiple available storage subintervals, the demand space of the data writing task may be determined, and a storage subinterval with the smallest storage space is selected from all the available storage subintervals with a space size larger than the demand space for performing the data writing operation.

S104: setting the target storage subinterval as an available storage subinterval for writing data in the available storage subinterval.

The embodiment is based on the determination that there is no adjacent storage subinterval in S102, and at this time, the target storage subinterval may be directly set as an available storage subinterval, so as to write data in the available storage subinterval.

In this embodiment, after a target storage subinterval converted from a non-available state to an available state is queried, it is determined whether an adjacent storage subinterval adjacent to a physical address of the target storage subinterval exists in the currently available storage subinterval, and if the adjacent storage subinterval exists, the target storage subinterval and the adjacent storage subinterval are merged to obtain a continuous storage space.

As a further supplement to the corresponding embodiment in fig. 1, after merging to obtain the usable storage subintervals at S103, the following steps may be further included:

step 1: determining a target linked list corresponding to the available storage subinterval according to the space size of the available storage subinterval;

step 2: and recording the address information of the available storage subinterval in the target linked list so as to store the data to be written into the available storage subinterval according to the address information in the target linked list.

This embodiment may be provided with a plurality of linked lists for recording the available storage sub-intervals. As a possible implementation, each linked list may correspond to a different size of available storage subinterval. For example, the address information of 0-256K of available storage subintervals may be recorded in the linked list a, the address information of 257-512K of available storage subintervals may be recorded in the linked list B, the address information of 513-1024K of available storage subintervals may be recorded in the linked list C, and so on. By the recording mode, the available storage subintervals of the specific storage size interval can be selected according to the linked list, and the number of the available storage subintervals in each storage space size range can be determined.

Referring to fig. 2, fig. 2 is a flowchart of a method for dividing a storage interval provided in an embodiment of the present application, where this embodiment is a method for dividing a storage sub-interval before S101 in an embodiment corresponding to fig. 1, and a more preferred embodiment can be obtained by combining this embodiment with the embodiment corresponding to fig. 1, where this embodiment may include the following steps:

s201: when a storage space dividing instruction is received, averagely dividing the total storage space into N storage intervals;

s202: sequentially setting a corresponding interval serial number i for each storage interval according to the sequence of the physical addresses from small to large;

wherein i is 0, 1, 2, 3, … … N-1;

s203: determining the storage granularity B of each storage interval according to the interval serial number i;

wherein B is 2iX grain, grain is the minimum particle size.

S204: and dividing the storage interval into a plurality of storage sub-intervals according to the storage granularity corresponding to each storage space.

The embodiment provides a method for dividing storage subintervals according to different granularities, and the method can provide storage spaces with various granularities and meet the requirements of different types of data write operations.

It is understood that when the present embodiment is combined with the embodiment corresponding to fig. 1, the specific operation of S102 may be: and judging whether the adjacent storage subintervals exist in the storage interval in which the target storage subinterval is located. In the embodiment corresponding to fig. 2, the storage granularity corresponding to each storage interval is different, so that the adjacent storage sub-interval can be determined from the storage interval in which the target storage sub-interval is located.

As a possible implementation manner, on the basis of the embodiment corresponding to fig. 2, the following operations may also be performed: constructing a linked list corresponding to each storage interval; the linked list stores the address information of the storage subinterval in an available state in the storage interval; and when the storage subinterval with the changed storage state is detected, executing updating operation on the linked list corresponding to the storage subinterval with the changed storage state.

The flow described in the above embodiment is explained below by an embodiment in practical use. The embodiment provides a method for stably and efficiently searching a continuous space, and the working process is as follows: the method comprises the steps of dividing a total storage space into blocks (namely storage intervals) according to a space unit with a larger granularity, setting numbers for each block, and subdividing the blocks into grains, wherein each block comprises a fixed number of grains. Then dividing blocks in block according to different granularities, setting a linked list for each granularity block, respectively storing idle blocks under corresponding granularity, and finally quickly finding out the continuous idle space as far as possible by inquiring each linked list, wherein the specific implementation mode is as follows:

in this embodiment, the basic granularity of the space is grain, the space is first divided into block blocks according to a larger granularity, each block includes a fixed number of grains, as shown in fig. 3, and fig. 3 is a storage provided in this embodiment of the present applicationAnd (5) a space block model diagram. In this embodiment, each block is partitioned according to different granularities, as shown in fig. 4, fig. 4 is a granularity partitioning model diagram provided in this embodiment of the present application. The first granularity in fig. 4 is in the form of a grain, i.e., each block contains a grain and is numbered as 0, 1, 2, 3, 4 … …, and so on; the second granularity is 2 grains, that is, each block contains two grains, which are numbered as 0, 1, 2, 3, and 4 … …, where 0 in the second granularity corresponds to 0 and 1 in the previous granularity; the third granularity is 4 grains, that is, each block contains 4 grains, which are numbered as 0, 1, 2, 3, and 4 … …, where 0 in the third granularity corresponds to 0 and 1 in the previous granularity; the fourth granularity is 8 grains, that is, each block contains 8 grains, which are 0, 1, 2, 3, and 4 … …, where 0 in the fourth granularity corresponds to 0 and 1 in the previous granularity. The division is carried out according to the rule until 2 blocks exist in each block in the last layer of granularitynAnd (4) individual grain.

In each granularity, all the adjacent blocks are pairing blocks, for example, in each granularity, the 0 th block and the 1 st block are pairing blocks, and the 2 nd block and the 3 rd block are pairing blocks. A linked list is set at each granularity for storing the block numbers available at that granularity during the run. In the initial stage, all the gains in the block are available, so the blocks at the maximum granularity are all stored in the corresponding linked list, and it should be noted that each block needs to be stored in the order of the block number when being hung on the linked list. When space allocation is carried out, if an available block is found on the linked list corresponding to the block with the maximum granularity, the block is indicated to have a large number of continuous grains, and therefore the available block can be taken out from the linked list. And after the subsequent used gains are recycled, hanging the idle gains into the chain, wherein the blocks with the minimum granularity correspond to one gain, so that the chain table hung by the recycled grian is the chain table corresponding to the blocks with the minimum granularity.

When a grain is hung on a linked list, whether a matching block of the block exists in the linked list or not can be checked, if so, the rest matching blocks are combined into a larger block (namely, a block with a larger primary granularity), and the combined block is transferred to the linked list corresponding to the block with the larger primary granularity; if the combined block still has a matching block on the linked list, continuing to combine and then transferring to the linked list corresponding to the block with the larger primary granularity; until there are no match blocks. After a period of operation, there may be different numbers of available free blocks on the linked list corresponding to each block with different granularity, and the free available blocks are found from the linked list corresponding to the block with the largest granularity preferentially when the free available blocks are found. If all the linked lists in one block have no free available blocks, the block is indicated to have no available space, and then continuous available space is found from other blocks.

The embodiment provides a method for stably and efficiently searching continuous space, which includes dividing the space into large-granularity block blocks including a fixed number of grains, dividing the blocks into different granularities, and setting a linked list for each granularity block for the existence of free available blocks of the granularity. According to the mode that when the space is released, the pairing block combination is transferred to the upper layer module, so that the available space of the large block as continuous as possible is quickly obtained.

Referring to fig. 5, fig. 5 is a schematic structural diagram of a storage space management system according to an embodiment of the present disclosure;

the system may include:

the query module 100 is configured to query a target storage subinterval whose storage state is converted from a non-available state to an available state;

a judging module 200, configured to judge whether there is an adjacent storage subinterval; the adjacent storage subinterval is a storage subinterval which is adjacent to the physical address of the target storage subinterval and has a storage state of an available state;

an interval merging module 300, configured to merge the target storage subinterval and the adjacent storage subinterval into an available storage subinterval when the adjacent storage subinterval exists, so as to write data in the available storage subinterval;

an interval setting module 400, configured to set the target storage subinterval as an available storage subinterval, so as to write data in the available storage subinterval.

In this embodiment, after a target storage subinterval converted from a non-available state to an available state is queried, it is determined whether an adjacent storage subinterval adjacent to a physical address of the target storage subinterval exists in the currently available storage subinterval, and if the adjacent storage subinterval exists, the target storage subinterval and the adjacent storage subinterval are merged to obtain a continuous storage space.

Further, the method also comprises the following steps:

and the linked list recording module is used for determining a target linked list corresponding to the available storage subinterval according to the space size of the available storage subinterval, and recording the address information of the available storage subinterval in the target linked list so as to store the data to be written into the available storage subinterval according to the address information in the target linked list.

Further, the method also comprises the following steps:

the first dividing module is used for averagely dividing the total storage space into N storage intervals when a storage space dividing instruction is received;

and the second dividing module is used for dividing the storage interval into a plurality of storage subintervals according to the storage granularity corresponding to each storage space.

Further, the method also comprises the following steps:

the linked list construction module is used for constructing a linked list corresponding to each storage interval; the linked list stores the address information of the storage subinterval in an available state in the storage interval;

and the linked list updating module is used for executing updating operation on the linked list corresponding to the storage subinterval with the changed storage state when the storage subinterval with the changed storage state is detected.

Further, the method also comprises the following steps:

the interval serial number setting module is used for sequentially setting a corresponding interval serial number i for each storage interval according to the sequence of the physical addresses from small to large; wherein i is 0, 1, 2, 3, … … N-1;

the granularity determining module is used for determining the storage granularity B of each storage interval according to the interval serial number i; wherein B is 2iX grain, grain is the minimum particle size.

Further, the determining module 200 is specifically a module for determining whether the storage section in which the target storage sub-section is located has the adjacent storage sub-section.

Further, the method also comprises the following steps:

and the data writing module is used for writing data into the storage subinterval with the largest storage space when the data storage task is received so as to complete the data storage task.

Since the embodiment of the system part corresponds to the embodiment of the method part, the embodiment of the system part is described with reference to the embodiment of the method part, and is not repeated here.

The present application also provides a storage medium having a computer program stored thereon, which when executed, may implement the steps provided by the above-described embodiments. The storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

The application further provides an electronic device, which may include a memory and a processor, where the memory stores a computer program, and the processor may implement the steps provided by the foregoing embodiments when calling the computer program in the memory. Of course, the electronic device may also include various network interfaces, power supplies, and the like.

The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.

It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种数据处理方法、系统、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类