Distributed storage system and space allocation method and device, electronic equipment and nonvolatile storage medium
By dividing the storage space into storage areas of the same size and loading the bitmap information of the storage areas, the problems of excessive memory consumption and slow node restart in PB-level space management are solved, achieving low memory consumption and fast business recovery.
Patent Information
- Application Number
- CN202411998823.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-12-30
AI Technical Summary
When managing petabyte-scale space, existing technologies consume a lot of memory, and the loading time during node restarts is long, resulting in slow business recovery.
The storage space is pre-divided into multiple storage regions of the same size and with contiguous addresses, and the correspondence between the storage bitmap and the storage unit is persisted to the storage space. During the startup process of the storage node, only the bitmap information of the target storage region is loaded into memory, and space allocation is performed at the granularity of the storage region.
It effectively reduced memory usage, resisted the increase in memory usage caused by fragmentation, and improved the loading speed and business recovery speed when the node restarts.
Smart Images

Figure CN119718211B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a space allocation method and device, electronic equipment, non-volatile storage medium and distributed storage system. BACKGROUND
[0002] With the rapid development of artificial intelligence technology and big data technology, in order to meet the storage demand of the sharply increasing electronic data and the efficient processing of data, the space allocation performance requirement of the storage system is also higher and higher.
[0003] In the related art, when the disk space is in PB (trillion bytes), the memory occupied by the bitmap is too large, and about 35G of memory is needed to manage 1PB of space. In the node restart scenario, the bitmap needs to be loaded into the memory in full, and the business recovery speed is slow.
[0004] Therefore, when managing PB-level space, it is necessary to occupy less memory and reduce the loading time during node restart.
[0005] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present application, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0006] The present application provides a space allocation method and device, electronic equipment, non-volatile storage medium and distributed storage system, which can occupy less memory when managing PB-level space, reduce the loading time during node restart, and effectively improve the recovery speed of node operation business.
[0007] To solve the above technical problems, the present application provides the following technical solutions:
[0008] In one aspect, the present application provides a space allocation method, comprising:
[0009] The storage space is divided into a plurality of storage regions with the same storage capacity and continuous addresses in advance, and the correspondence between the storage bitmap and the storage address of the corresponding storage unit is persisted to the storage space; the storage region includes a plurality of storage units; during the startup process of the storage node, the target storage region in the idle state is determined in the storage space according to the correspondence, and the bitmap information corresponding to the target storage region is loaded into the memory; wherein each bit of the storage bitmap represents the state of the corresponding storage unit, and the state includes the idle state and the allocation state.
[0010] In the first exemplary embodiment, the loading of the bitmap information corresponding to the target storage region into the memory comprises: determining a starting address of the target storage region according to a starting storage address of a first target storage unit of the target storage region and a storage capacity of the target storage region; determining an offset address of the target storage region according to the starting storage address of the target storage unit and the starting address of the target storage region; and storing storage identification information corresponding to each target storage unit of the target storage region into the memory bitmap based on the starting address of the target storage region and the offset address.
[0011] In the second exemplary embodiment, the memory further comprises a cache space, and after the loading of the bitmap information corresponding to the target storage region into the memory, the method further comprises: receiving a space allocation request, determining a required storage space capacity by analyzing the space allocation request; if the free storage space capacity in the cache space is greater than or equal to the required storage space capacity, sending the storage address corresponding to the free storage of the cache space to the requester and updating the storage bitmap; if there is no free storage in the cache space, determining a matched first target storage space in the target storage region according to the memory bitmap, determining the storage address of the first target storage space according to the starting address and the offset address of the target storage region, and sending the storage address of the first target storage space to the requester and updating the storage bitmap; the space capacity of the first target storage space is the same as the required storage space capacity; if the free storage space capacity in the cache space is less than the required storage space capacity, determining a matched second target storage space in the target storage region according to the memory bitmap, determining the storage address of the second target storage space according to the starting address and the offset address of the target storage region, and sending the storage address of the second target storage space and the storage address corresponding to the free storage of the cache space to the requester together and updating the storage bitmap; the space capacity of the second target storage space is the difference between the required storage space capacity and the free storage space capacity in the cache space.
[0012] In a third exemplary embodiment, the determining the target storage area in the idle state in the storage space according to the correspondence comprises: determining a target storage unit in the idle state in the storage space according to the correspondence; obtaining a first target storage unit and placing the first target storage unit into the target storage area; obtaining a second target storage unit and a remaining storage space of the target storage area; if a storage unit capacity of the second target storage unit is greater than the remaining storage space, performing a truncation processing on the second target storage unit to obtain a first storage unit and a second storage unit; a space capacity of the first storage unit is the same as the remaining storage space; placing the first storage unit into the target storage area and placing the second storage space into a cache space of the memory.
[0013] In a fourth exemplary embodiment, after the loading the bitmap information corresponding to the target storage area into the memory, the method further comprises: generating a corresponding space release record each time a storage unit is released; merging all space release records at a current time into release record information when a record merging request is triggered; the release record information at least comprises identification information and a storage address of each released storage unit; calling a transaction start command to start a target transaction, generating a batch update statement according to the release record information and the correspondence, and executing the batch update statement in the target transaction to update the release record information to the correspondence.
[0014] In a fifth exemplary embodiment, after the loading the bitmap information corresponding to the target storage area into the memory, the method further comprises: during a running process of the storage node, each time a loaded storage space is determined to be used up according to a memory bitmap of the memory, obtaining each dynamic storage unit in the idle state according to the correspondence; aligning a starting storage address of a first dynamic storage unit based on a storage capacity of a storage area as a starting address of a dynamic storage area; taking a difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage area as an offset address of the dynamic storage area; placing the first dynamic storage unit into the dynamic storage area and updating the memory bitmap of the memory to obtain a second dynamic storage unit and a dynamic remaining storage space of the dynamic storage area; if a storage unit capacity of the second dynamic storage unit is greater than the dynamic remaining storage space, performing a truncation processing on the second dynamic storage unit to obtain a first dynamic storage unit and a second dynamic storage unit; a space capacity of the first dynamic storage unit is the same as the dynamic remaining storage space; placing the first dynamic storage unit into the dynamic storage area and placing the second dynamic storage space into a cache space of the memory.
[0015] Another aspect of the present application provides a space allocation device, comprising:
[0016] a storage partitioning module, configured to pre-divide a storage space into a plurality of storage regions with same storage capacity and continuous addresses, and persist the correspondence between a storage bitmap and the storage addresses of corresponding storage units in the storage space; the storage regions comprise a plurality of storage units;
[0017] a storage loading module, configured to determine a target storage region in an idle state in the storage space according to the correspondence during a storage node startup process, and load the bitmap information corresponding to the target storage region into a memory; wherein each bit of the storage bitmap represents the state of a corresponding storage unit, and the state comprises an idle state and an allocated state.
[0018] The present application also provides an electronic device comprising a processor configured to implement the steps of the space allocation method according to any one of the preceding aspects when executing a computer program stored in a memory.
[0019] The present application also provides a non-volatile storage medium having a computer program stored thereon, the computer program being configured to implement the steps of the space allocation method according to any one of the preceding aspects when executed by a processor.
[0020] The technical solution provided by the present application has the advantage that by dividing the underlying storage space into a plurality of storage regions with same size and head-to-tail connection, and loading only the bitmap information corresponding to one storage region into the memory at a time, the memory occupation is effectively reduced, even when the managed space reaches the PB level, the bitmap memory occupation will not be large, and the space occupation caused by fragmentation can also be resisted, while the loading time during node restart is reduced, effectively improving the recovery speed of node operation business.
[0021] In addition, the present application also provides corresponding implementation devices, electronic devices, non-volatile storage media and distributed storage systems for the space allocation method, further making the method more practical, and the devices, electronic devices, non-volatile storage media and distributed storage systems have corresponding advantages.
[0022] The technical features mentioned above, the technical features mentioned below, and the technical features shown in the drawings alone can be combined with each other arbitrarily, as long as the technical features to be combined are not contradictory to each other. All the feasible combinations of features are explicitly described herein. Any one of the multiple sub-features included in the same sentence can be applied independently, and does not have to be applied together with other sub-features. It should be understood that the above general description and the following detailed description are only exemplary, and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the present application or related art, the drawings needed to be used in the embodiments or related art description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0024] Figure 1 A flowchart of a space allocation method provided by the present application;
[0025] Figure 2 A storage space division schematic diagram provided by the present application;
[0026] Figure 3 A framework schematic diagram of an exemplary application scenario of the space allocation method provided by the present application;
[0027] Figure 4 A structure diagram of an exemplary embodiment of the space allocation apparatus provided by the present application;
[0028] Figure 5 A structure diagram of an exemplary embodiment of the electronic device provided by the present application;
[0029] Figure 6 A structure diagram of an exemplary embodiment of the distributed storage system provided by the present application. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the technical solutions of the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments. In the specification and the above drawings, the terms "first", "second", "third", "fourth" and the like are used to distinguish different objects, and are not used to describe a specific sequence. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. The term "exemplary" means "serving as an example, embodiment or illustration". Any embodiment described as "exemplary" herein does not necessarily mean that it is superior or better than other embodiments.
[0031] The storage system allocates memory for the applicant through a space allocator. For the space allocator that uses bitmap to save the free space information in the memory and the disk. In order to facilitate the search, such a space allocator uses a hierarchical index to save multiple states, which results in relatively small consumption of memory when the disk space is in the TB (Terabytes) level. In the case of 4K granularity, 1TB disk needs about 35M of memory space. When the managed space reaches the PB level, the bitmap occupies too much memory, and about 35G of memory is needed to manage 1PB of space. Moreover, in the node restart scenario, the bitmap needs to be loaded into the memory in full, and the business recovery speed is slow. In addition, for the space allocator that uses a tree structure to save the free space information in the memory and the disk, such as the space allocator of the log-type file system, the B+ tree is used to save the free space information in the memory and the disk. When the disk saves a small amount of data, the memory and disk space occupied by the B+ tree are relatively small, and the time and space efficiency is relatively high. As the use time increases, when the fragmentation degree is high, the memory and disk space occupied by the B+ tree will significantly increase, and manual defragmentation is needed to aggregate the discrete disk space. For the copy-on-write file system that uses a balanced binary tree to save the free space information in the memory, it uses a log to record the space allocation and release operations. When the disk space is close to full, the number of leaf nodes in the tree becomes smaller, and there is no problem of increasing the memory and disk space occupation. Although due to the use of the copy-on-write technology by the copy-on-write file system, data and metadata are only appended, and adjacent space records are merged, the copy-on-write file system reduces fragmentation by using 128k large blocks, and the merging of the ZIL (Zombie Inode List) and the write (delayed write) also helps to reduce fragmentation, but when the fragmentation degree is high, the memory and disk space occupied by the balanced binary tree will also significantly increase.
[0032] Therefore, in the related art, when managing PB-level space, more memory is occupied, and space fragmentation also causes the memory occupation to increase. In view of this, the present application divides the underlying storage space into a plurality of storage regions of the same size and head-to-tail connection, and loads only the bitmap information corresponding to one storage region into the memory at a time, so that when managing PB-level space, less memory is occupied, and the increase in memory occupation caused by space fragmentation is resisted. After introducing the technical solutions of the present application, various non-limiting embodiments of the present application will be described in detail below. In order to better illustrate the present application, numerous specific details are given in the specific embodiments below. Those skilled in the art should understand that the present application can also be implemented without these specific details. In some other examples, methods, means, elements and circuits familiar to those skilled in the art are not described in detail in order to highlight the main idea of the present application.
[0033] First, please refer toFigure 1 , Figure 1 A flowchart of a space allocation method provided by the embodiment is shown in the following. The embodiment can include the following contents.
[0034] S101: The storage space is divided into a plurality of storage regions with the same storage capacity and continuous addresses in advance, and the correspondence between the storage bitmap and the storage address of the corresponding storage unit is persisted to the storage space.
[0035] In the embodiment, the storage space is a bottom-layer management space composed of bottom-layer storage elements of a storage system, such as a storage space composed of persistent storage media such as mechanical hard disks, solid state disks, magnetic disks, etc. Figure 2 As shown in the figure, the storage space is divided into a plurality of storage regions with the same size and head-to-tail connection, and each storage region further includes a plurality of storage units, which are the minimum allocation units and can usually be an integer multiple of data blocks. The storage space has a bitmap for identifying whether the storage space is used. For ease of description, it is defined as a storage bitmap. After the storage space is divided into a plurality of storage regions, the corresponding bits (i.e. binary bits) of the storage bitmap represent the state of the corresponding storage unit, including the idle state and the allocation state. For example, in order to improve the retrieval efficiency, the correspondence between the storage bitmap and the storage address of the corresponding storage unit can be stored in the form of k-v (key-value), the key is the first address of the storage space, and the value is the bitmap of the storage space. One key can manage a plurality of minimum allocation units, and the value records the bitmap state of these minimum allocation units. Each persistent medium of the storage space can be identified using a byte sequence or using three byte sequences, which does not affect the implementation of the present application.
[0036] S102: In the storage node startup process, the target storage region in the idle state is determined in the storage space according to the correspondence, and the bitmap information corresponding to the target storage region is loaded into the memory.
[0037] For each storage node of the storage system, each time when normally starting up or restarting, the idle space information of only one storage region is loaded into the bitmap in the memory. For ease of description, the loaded storage region is defined as the target storage region.
[0038] In the technical scheme provided in the embodiment, the storage space of the bottom layer is divided into a plurality of storage areas of the same size and connected at the head and tail, and the bitmap information corresponding to one storage area is loaded into the memory each time as a granularity, so that the memory occupation is effectively reduced, even when the managed space reaches the PB level, the memory occupied by the bitmap will not be large, and the space occupation caused by fragmentation can also be resisted, and the loading time during node restart is reduced, so that the recovery speed of the node operation business is effectively improved.
[0039] It should be noted that there is no strict execution order between the steps in the present application, as long as the logical order is met, the steps can be executed simultaneously, or executed according to a certain preset order, Figure 1 It is only an illustrative manner, and does not mean that only such an execution order can be represented.
[0040] In the above embodiment, how to load the bitmap information corresponding to the target storage area into the memory is not limited, based on the above embodiment, the present application also gives an exemplary implementation process of loading the bitmap information corresponding to the target storage area into the memory, which can include the following contents:
[0041] According to the starting storage address of the first target storage unit of the target storage area and the storage capacity of the target storage area, the starting address of the target storage area is determined; according to the starting storage address of the target storage unit and the starting address of the target storage area, the offset address of the target storage area is determined; based on the starting address and the offset address of the target storage area, the storage identification information corresponding to each target storage unit of the target storage area is stored into the memory bitmap.
[0042] Since the storage area is continuous when it is divided, when the idle space is determined from the storage space corresponding to the storage location and the storage location corresponding relationship, the idle space is the storage unit in the idle state, in order to facilitate the description, the embodiment defines it as the target storage unit, and these idle spaces have a sequence according to the address continuity. From the direction of the first address to the terminal address of the storage area, the first idle space is the first target storage unit, and the storage capacity of the target storage area is the size of the divided storage area. For example, the starting address of the first target storage unit is 0x100000, the length is 4K, and the storage capacity of the target storage area is 1TB. In units of storage size, the corresponding target storage starting address is 0. The starting address of the first target storage unit is subtracted from the target storage starting address, and the offset address in the target storage can be obtained. When the target storage unit in the target storage area is determined, the target storage unit and its corresponding storage address information can be put into the bitmap of the memory. In order to facilitate the description, the memory bitmap can be defined as the memory bitmap. The storage identification information is used to indicate the identification information of the target storage unit, so as to facilitate the memory to locate the target storage unit when allocating space.
[0043] As can be seen from the above, the embodiment determines the address of the storage area loaded into the memory by the address of the storage unit and the size of the storage area, realizes loading into the memory according to the storage area granularity, reduces the memory occupation, and can effectively resist the space occupation rising problem caused by fragmentation.
[0044] The above embodiment does not make any limitation on how to determine the target storage area loaded into the memory from the storage space. Based on the above embodiment, the application also gives an exemplary implementation, which can include the following contents:
[0045] According to the corresponding relationship between the storage bitmap and the storage address of the corresponding storage unit, the target storage unit in the idle state in the storage space is determined; the first target storage unit is obtained and put into the target storage area; the second target storage unit and the remaining storage space of the target storage area are obtained; if the storage unit capacity of the second target storage unit is greater than the remaining storage space, the second target storage unit is truncated to obtain the first storage unit and the second storage unit; the space capacity of the first storage unit is the same as the remaining storage space; the first storage unit is put into the target storage area, and the second storage space is put into the cache space of the memory.
[0046] In this embodiment, the correspondence between the storage bitmap and the storage address of the corresponding storage unit is persisted in the storage space in the form of k-v. Based on the k-v, the storage units currently in the idle state are listed from the storage space. When the storage area is divided, the addresses are continuous. In the direction from the first address to the terminal address of the storage area, the order of the storage units in the idle state can be determined, which are defined as the first storage unit and the second storage unit, respectively. In order to facilitate the description and reflect the relationship between the storage unit and the storage area, this embodiment defines them as target storage units, and accordingly, they are defined as the first target storage unit and the second target storage unit. The size of the target storage area is fixed, so when the target storage units are put into the target storage area, it is inevitable that the size of the target storage unit currently to be put in will be larger than the remaining storage space of the target storage area. In view of this situation, whenever a target storage unit is put in, it can be judged whether the length of the target storage unit exceeds the end of the target storage area. If it exceeds, the target storage unit is truncated, and the first half is put into the memory bitmap, and the second half exceeding the end of the target storage area is put into the cache space of the memory. If it does not exceed, the next target storage unit is obtained, and the same direction is judged until all or part of the idle target storage area obtained cannot be put into the target storage area.
[0047] As can be seen from the above, in order to realize loading in the storage area granularity, the minimum allocation unit in the idle state is truncated in this embodiment, and the excess part is directly put into the cache space of the memory, which is beneficial to improve the space allocation efficiency.
[0048] Based on the above embodiment, when the applicant applies for space to the storage system, the applicant issues a space allocation request carrying storage requirements to the storage system. The storage system determines the space capacity to be stored by analyzing the space allocation request when receiving the space allocation request. The space to be stored is the storage space that the applicant wants to apply for, and the space capacity to be stored is the size of the storage space that the applicant wants to apply for. If the idle storage space capacity in the cache space is greater than or equal to the space capacity to be stored, the storage address corresponding to the idle storage of the cache space is sent to the requester, and the storage bitmap is updated at the same time. If there is no idle storage in the cache space, a first target storage space matching the target storage area is determined according to the memory bitmap, the storage address of the first target storage space is determined according to the start address and offset address of the target storage area, and the storage address of the first target storage space is sent to the requester, and the storage bitmap is updated at the same time. The space capacity of the first target storage space is the same as the space capacity to be stored. If the idle storage space capacity in the cache space is less than the space capacity to be stored, a second target storage space matching the target storage area is determined according to the memory bitmap, the storage address of the second target storage space is determined according to the start address and offset address of the target storage area, and the storage address of the second target storage space and the storage address corresponding to the idle storage of the cache space are sent to the requester at the same time, and the storage bitmap is updated at the same time. The space capacity value of the second target storage space is the difference between the space capacity to be stored and the space capacity of the idle storage in the cache space.
[0049] It can be understood that, as shown in Figure 3 When allocating idle storage space for the applicant, the memory bitmap stores the space storage space, and the cache space in the memory also saves part of the idle space that cannot be put into the target storage area. The idle space in the cache space can be used preferentially. When there is no available idle space in the cache space, the idle space is allocated for the applicant according to the memory bitmap. The address of the allocated idle space, that is, the offset address in the target storage area, is added to the start address of the target storage area to return to the applicant as the global address of the space. At the same time, the allocated space record is updated to the storage bitmap of the storage space, such as being persisted to the k-v of the storage space.
[0050] In order to further improve the storage space usage efficiency, reduce the memory occupation, and resist the problem of memory rising caused by fragmentation, based on the above embodiment, the application also provides an implementation manner for uniformly processing space release records in a transaction manner, which can include the following contents:
[0051] Whenever a storage unit is detected to be released, a corresponding space release record is generated; when a record merging request is triggered, all space release records at the current time are merged into release record information; the release record information at least includes the identification information and storage address of each released storage unit; a target transaction is started by calling a transaction start command, a batch update statement is generated according to the release record information and the corresponding relationship, and the batch update statement is executed in the target transaction to update the release record information to the corresponding relationship.
[0052] In the embodiment, a unique identifier such as a block ID or a storage unit ID can be allocated to each data block or storage unit in advance, and a release list can be created in advance. When a storage unit is released, the identifier can be put into the release list to generate a corresponding space release record. The record merging request can be implemented in a fixed frequency manner, such as issuing a record merging request every 24 hours, or can be manually initiated, or when the size of the release list exceeds a threshold or the space release record exceeds a preset threshold, the record merging request is issued. Whenever a record merging request is received, the generated space release records are batch-merged, which is defined as release record information to avoid description, and updated in batches through a transaction, such as updating to the persistent kv of the storage space. By way of example, the transaction batch update process can include: determining the objects that need to be updated, i.e., the storage bitmap of the storage space and its corresponding relationship with the storage address, and then updating according to the release record information, and then designing an SQL (database language) update statement according to the update requirements. Before batch updating, the relevant data can also be backed up to prevent data loss due to operation errors. Then a transaction can be started by using a SQL command, for example, using `START TRANSACTION` (database command) in MySQL (database name) to start a transaction. One or more SQL statements for batch updating are written, for example, an `UPDATE` statement can be used in combination with a `WHERE` clause to specify the update conditions, and these batch update statements are executed in the transaction. Further, to ensure successful updating, a query command can also be used to verify whether the updating is performed as expected by querying the storage bitmap of the storage space. If the updating result is correct, the transaction is committed to make all updates permanent. If the updating result is incorrect or an error is found, the transaction is rolled back using the `ROLLBACK;` command to undo all uncommitted update operations. If temporary tables or other resources are used, ensure that these resources are cleaned up after the transaction is completed. To facilitate problem tracing, operation logs of the batch updating can also be recorded at the same time, including operation time, operator, updated data volume, etc., to facilitate subsequent auditing and problem troubleshooting.
[0053] From the above, the embodiment can improve the storage space use efficiency, reduce the memory occupation and resist the memory rising problem caused by the fragmentation by uniformly processing the space release record in the transaction mode.
[0054] It can be understood that the storage space loaded in the memory is limited, when the memory bitmap shows that the loaded storage space is almost exhausted, the application also provides an implementation manner of loading the next region with free space into the memory by dynamically loading the next storage region under the condition that the storage node maintains the normal working state. The dynamic loading process can include the following contents:
[0055] In the running process of the storage node, when it is determined according to the memory bitmap of the memory that the loaded storage space is used up, each dynamic storage unit in the idle state is obtained according to the corresponding relationship; the starting storage address of the first dynamic storage unit is aligned based on the storage capacity of the storage region as a starting address of the dynamic storage region; the difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage region is taken as an offset address of the dynamic storage region; the first dynamic storage unit is put into the dynamic storage region, and the memory bitmap of the memory is updated to obtain the second dynamic storage unit and the dynamic remaining storage space of the dynamic storage region; if the storage unit capacity of the second dynamic storage unit is greater than the dynamic remaining storage space, the second dynamic storage unit is truncated to obtain the first dynamic storage unit and the second dynamic storage unit; the space capacity of the first dynamic storage unit is the same as the dynamic remaining storage space; the first dynamic storage unit is put into the dynamic storage region, and the second dynamic storage space is put into the cache space of the memory.
[0056] When the space represented by the memory bitmap is exhausted or about to be exhausted, the next storage area can be dynamically loaded into the memory without restarting the storage node, i.e. without user awareness. Since the cache space of the memory has storage space that is not put into the current storage area, when the next storage area is dynamically loaded, in order to avoid description, it is defined as a dynamic storage area. The first free space address can be obtained from the cache space of the memory. If the cache space has no free storage unit, the storage units in the space state can be listed based on the storage bitmap of the storage space. In order to facilitate the distinction, the storage units contained in the dynamic storage area are defined as dynamic storage units. Similarly, the first free space address of the dynamic storage unit is obtained, aligned in units of the size of the dynamic storage area, and used as the starting address of the dynamic storage area. The starting address of the first dynamic storage unit is subtracted from the starting address of the dynamic storage area to obtain the offset address in the dynamic storage area. The first dynamic storage unit is put into the dynamic storage area. If the length of the current dynamic storage unit exceeds the end address of the dynamic storage area, the free space of the current dynamic storage unit is truncated, the first half is put into the memory bitmap, and the second half exceeding the end address of the dynamic storage area is put into the cache space. The above steps are repeated until all or part of the dynamic storage unit obtained cannot be put into the dynamic storage area. Similarly, the cache space of the memory can also save part of the free space that cannot be put into the dynamic storage area. Next time the space is loaded or applied, the free space in the cache space is used first.
[0057] It can be understood that during the normal operation of the storage node, when the read-write task is large, dynamic loading is continuously performed. If the current dynamic storage area slides to the tail of the managed space, the next time dynamic loading is performed, it can jump to the head of the storage space, i.e. the dynamic storage area currently loaded can be physically discontinuous with the dynamic storage area loaded last time.
[0058] As can be seen from the above, the embodiment can dynamically load the free space in the region into the bitmap in the memory without user awareness during the operation of the storage node, according to the operation of the storage node, to realize global free space management and ensure the continuity and stability of the operation of the storage node.
[0059] It can be understood that in order to ensure that the storage system can stably perform the space allocation task, it is necessary to ensure that there is enough storage space. Based on the above embodiment, the application also provides an implementation manner for optimizing the storage space:
[0060] A space usage monitoring thread is constructed in advance, the space usage monitoring thread is called to monitor the space usage of the storage system, and storage space usage information is generated; and the storage configuration parameters are adjusted according to the storage space usage information.
[0061] The space usage monitoring thread can obtain the space usage and fragmentation by invoking the space management tool or pre-configured space management script, for example, the `ceph-bluestore-tool` can be used to check the space usage and fragmentation. The space usage can be obtained by the space usage check command, for example, the space usage check command can be: "ceph-bluestore-tool --path PATH_TO_OSD_DATA_DIRECTORY --allocator block free-score", according to the returned value of the command, the efficiency of space usage can be determined. The lower the score, the more fragmented the space usage. More detailed usage can also be obtained by the command "ceph-bluestore-tool --path PATH_TO_OSD_DATA_DIRECTORY --allocator block free-dump", such as capacity, allocation unit, allocation type and other detailed information. Further, the storage system such as ceph (distributed storage system) command line tool can also be used to query the cluster information, for example, the `ceph status` command can be used to check the status of the ceph storage cluster by logging into the Cephadm shell, and the cluster health status, OSD (Object Storage Device, object storage device) status, storage data volume and usage information can be obtained. The `ceph -w` command can also be used to monitor the continuous events of the storage cluster of the storage system, or the `status` subcommand or `-s` can be used to display the cluster status, so that the real-time state changes of the storage cluster and the changes of the space usage can be obtained, and the real-time state changes include the changes of the health status, service status and data status of the storage cluster. Correspondingly, the storage space usage information can include the space usage efficiency value, used capacity, remaining capacity, allocation unit, allocation type, cluster health status, OSD status, storage data volume and usage, and real-time state change information of the storage cluster.
[0062] When the storage space usage information is obtained, the block size of partitioned write data, the storage medium type, the storage location, the storage strategy, the object storage target, the cache size, and the write frequency can be adjusted. The default value of the block size of partitioned write data is 4k, and dynamically adjusting this parameter according to the storage space usage information can optimize the space usage efficiency. The storage medium type refers to matching the performance requirements of data read and write with the performance of the storage medium, for example, placing object data located on a mechanical hard disk on a solid state disk through a block database, and placing a pre-write log on an NVMe (Non-Volatile Memory express) device to improve performance. The storage location refers to defining the locations of separate data, block databases, and pre-write log devices through a service specification file to improve performance. The storage strategy includes space release and data compression, and the allocation and recycling of storage space can be coordinated through a FreelistManager (free list manager) to ensure that each data block is fully utilized while preventing fragmentation, thereby optimizing storage performance. In the case of allowing compressed data, the application workload has compressibility, and a matching compression mode can be used to compress the data. The adjustment of the object storage target is to keep the OSD stack memory usage below the target size specified by this configuration item. By reducing the size and frequency of write operations, the number of write operations on the storage medium can be reduced, thereby prolonging its life and improving efficiency.
[0063] The block size of partitioned write data specifies the minimum amount of space required for each object allocation. If the data written is smaller than this size, the storage system will fill the remaining space with zeros. Therefore, correctly configuring this parameter can avoid space waste, especially when small objects are written. In order to improve the storage performance of the storage space of the storage system, the block size of partitioned write data can be set to a parameter value that matches the minimum write operation, thereby avoiding the loss of write amplification. For example, if 4KB objects are frequently written, this parameter can be set to 4096 bytes.
[0064] As can be seen from the above, the embodiment can monitor the storage space of the storage system and optimize the storage configuration parameters according to the storage space usage information, thereby effectively optimizing the space usage efficiency, improving the storage performance and reliability, and ensuring the stable operation of user business.
[0065] The present application also provides a corresponding device for the space allocation method, further making the method more practical. The device can be described from the perspective of functional modules and the perspective of hardware. The space allocation device provided by the present application is described below, which is used to implement the space allocation method provided by the present application. In the present embodiment, the space allocation device can include or be divided into one or more program modules stored in a storage medium and executed by one or more processors to complete the space allocation method disclosed in embodiment one. The program module referred to in the present embodiment refers to a series of computer program instruction segments capable of completing a specific function, and is more suitable for describing the execution process of the space allocation device in the storage medium than the program itself. The functions of each program module in the present embodiment will be specifically described below. The space allocation device described below can be mutually referred to with the space allocation method described above.
[0066] Based on the perspective of functional modules, refer to Figure 4 , Figure 4 The structure diagram of the space allocation device provided by the present embodiment in a specific embodiment can include:
[0067] The storage partitioning module 401 is configured to pre-divide the storage space into a plurality of storage regions with the same storage capacity and continuous addresses, and persist the correspondence between the storage bitmap and the storage addresses of the corresponding storage units to the storage space. The storage region includes a plurality of storage units.
[0068] The storage loading module 402 is configured to determine a target storage region in an idle state in the storage space according to the correspondence during the startup process of the storage node, and load the bitmap information corresponding to the target storage region into the memory. Each bit of the storage bitmap represents the state of the corresponding storage unit, and the state includes an idle state and an allocated state.
[0069] For example, in some embodiments of the present embodiment, the storage loading module 402 described above can also be configured to: determine the starting address of the target storage region according to the starting storage address of the first target storage unit of the target storage region and the storage capacity of the target storage region; determine the offset address of the target storage region according to the starting storage address of the target storage unit and the starting address of the target storage region; and store the storage identification information corresponding to each target storage unit of the target storage region to the memory bitmap based on the starting address and the offset address of the target storage region.
[0070] For example, in some other embodiments of the present embodiment, the device can include an application request processing module, which can be configured to: when receiving a space allocation request, determine the space capacity to be stored by analyzing the space allocation request; if the free storage space in the cache space is greater than or equal to the space capacity to be stored, send the storage address corresponding to the free storage space of the cache space to the requester, and update the storage bitmap; if there is no free storage in the cache space, determine a first target storage space matching in the target storage area according to the memory bitmap, determine the storage address of the first target storage space according to the start address and offset address of the target storage area, and send the storage address of the first target storage space to the requester, and update the storage bitmap; the space capacity of the first target storage space is the same as the space capacity to be stored; if the free storage space in the cache space is less than the space capacity to be stored, determine a second target storage space matching in the target storage area according to the memory bitmap, determine the storage address of the second target storage space according to the start address and offset address of the target storage area, and send the storage address of the second target storage space and the storage address corresponding to the free storage space of the cache space to the requester, and update the storage bitmap; wherein the space capacity value of the second target storage space is the difference between the space capacity to be stored and the space capacity of the free storage in the cache space.
[0071] For example, in some other embodiments of the present embodiment, the storage splitting module 401 can also be configured to: determine the target storage unit in the idle state in the storage space according to the correspondence; obtain a first target storage unit and put the first target storage unit into the target storage area; obtain a second target storage unit and the remaining storage space of the target storage area; if the storage unit capacity of the second target storage unit is greater than the remaining storage space, truncate the second target storage unit to obtain a first storage unit and a second storage unit; the space capacity of the first storage unit is the same as the remaining storage space; put the first storage unit into the target storage area and put the second storage space into the cache space of the memory.
[0072] For example, in some other embodiments of the present embodiment, the device can also include a release module, which can be configured to: whenever a storage unit is detected to be released, generate a corresponding space release record; when a record merging request is triggered, merge all space release records at the current time into release record information; the release record information at least includes the identification information and storage address of each released storage unit; call a transaction start command to start a target transaction, generate a batch update statement according to the release record information and the correspondence, and execute the batch update statement in the target transaction to update the release record information to the correspondence.
[0073] For example, in some other embodiments of the present embodiment, the device can further include a dynamic recording module, which can be used to: during the running of the storage node, whenever it is determined according to the memory bitmap of the memory that the loaded storage space is used up, acquire each dynamic storage unit in an idle state according to the corresponding relationship; align the starting storage address of the first dynamic storage unit based on the storage capacity of the storage area as the starting address of the dynamic storage area; acquire the difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage area as the offset address of the dynamic storage area; put the first dynamic storage unit into the dynamic storage area, and update the memory bitmap of the memory; acquire the second dynamic storage unit and the dynamic remaining storage space of the dynamic storage area; if the storage unit capacity of the second dynamic storage unit is greater than the dynamic remaining storage space, truncate the second dynamic storage unit to obtain the first dynamic storage unit and the second dynamic storage unit; the space capacity of the first dynamic storage unit is the same as the dynamic remaining storage space; put the first dynamic storage unit into the dynamic storage area, and put the second dynamic storage space into the cache space of the memory.
[0074] The space allocation device mentioned above is described from the perspective of functional modules, and further, the present application also provides an electronic device, which is described from the perspective of hardware. Figure 5 The structure schematic diagram of the electronic device provided by the present embodiment in an embodiment is shown in FIG. 1. Figure 5 As shown in the figure, the electronic device includes a memory 50 for storing a computer program, and a processor 51 for executing the computer program to implement the steps of the space allocation method mentioned in any of the above embodiments.
[0075] The processor 51 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 51 can also be a controller, a microcontroller, a microprocessor, or other data processing chip, and the like. The processor 51 can be implemented in at least one of a hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), a PLA (Programmable Logic Array), and the like. The processor 51 can also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also referred to as a CPU (Central Processing Unit). The coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 51 can be integrated with a GPU (Graphics Processing Unit) for rendering and drawing content required to be displayed by a display screen. In some embodiments, the processor 51 can also include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
[0076] The memory 50 can include one or more computer non-transitory storage media. The memory 50 can also include high-speed random access memory and nonvolatile, computer-readable media such as one or more magnetic disk storage devices, optical disk storage devices, flash memory devices, and the like. In some embodiments, the memory 50 is a non-transitory storage medium. In other embodiments, the memory 50 is a transitory storage medium. The memory 50 in some embodiments is an internal storage unit of an electronic device, such as a hard disk of a server. The memory 50 in other embodiments is also an external storage device of an electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, and the like. Further, the memory 50 can include both an internal storage unit and an external storage device of an electronic device. The memory 50 can be used to store not only application software and various data installed in an electronic device, such as program codes for executing the space allocation method, but also data that has been output or will be output. In the present embodiment, the memory 50 is used to store at least the following computer program 501, which, when loaded and executed by the processor 51, can implement the relevant steps of the space allocation method disclosed in any of the preceding embodiments. In addition, the memory 50 can also store resources such as an operating system 502 and data 503, and the storage mode can be temporary storage or permanent storage. The operating system 502 can include Windows, Unix, Linux, and the like. The data 503 can include, but is not limited to, data corresponding to the space allocation result, and the like.
[0077] In some embodiments, the electronic device described above can further include a display screen 52, an input / output interface 53, a communication interface 54, or a network interface, a power supply 55, and a communication bus 56. Among them, the display screen 52 and the input / output interface 53 such as a keyboard belong to a user interface, and exemplary user interfaces can also include standard wired interfaces, wireless interfaces, etc. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visualized user interface. The communication interface 54 can include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, etc., which is usually used to establish a communication connection between the electronic device and other electronic devices. The communication bus 56 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 In the figure, only one thick line is used to represent it, but it does not mean that there is only one bus or only one type of bus.
[0078] Those skilled in the art can understand that Figure 5 The structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than the illustration, for example, it can also include sensors 57 for implementing various functions.
[0079] It can be understood that if the space allocation method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on such understanding, the technical solutions of the present application or the part that contributes to the related art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and performs all or part of the steps of the method of each embodiment of the present application. The foregoing storage medium includes but is not limited to: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable ROM, a register, a hard disk, a multimedia card, a card-type memory (such as an SD or DX memory), a magnetic storage, a removable magnetic disk, a CD-ROM, a magnetic disk or an optical disk, and various media that can store program codes. Based on this, the present application further provides a non-volatile storage medium having a computer program stored thereon, and the computer program is executed by a processor to perform the steps of the space allocation method as described in any one of the embodiments.
[0080] It can be understood that if the space allocation method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, the computer software product can also not need to be stored in an entity storage medium, for example, it can be directly transmitted to a computer or other information processing device to perform all or part of the steps of the method of each embodiment of the present application through a wired network or a wireless network. Based on such understanding, the technical solutions of the present application or the part that contributes to the related art or the whole or part of the technical solutions can be embodied in the form of a software product. Based on this, the present application further provides a computer program product having a computer program stored thereon, and the computer program is executed by a processor to perform the steps of the space allocation method as described in any one of the embodiments.
[0081] Finally, the present application also provides a distributed storage system, which can include a storage engine for taking charge of data read and write tasks on underlying disks, including managing the use of disk space. For example, the storage engine of the Ceph storage system is BlueStore (storage engine name). The storage engine can further include a space allocator, which is one of the components of the storage engine and has a decisive impact on the performance of the storage engine. The space allocator needs to consider both time and space efficiency, and can include a memory-based space allocator and a persistent medium-based free space manager. The memory-based space allocator is used to quickly find and mark free space in memory, and has a higher requirement for time efficiency. Bitmap or tree can be used. In the bitmap mode, each bit represents the state (allocated or free) of a minimum allocation unit. In the tree mode, each leaf node saves the address and length of the free block. The persistent medium-based free space manager is used to save free space information to the persistent medium, and has a higher requirement for space efficiency and does not need to be frequently searched. Bitmap, tree, and log can be used. Bitmap records whether each minimum allocation unit has been allocated, tree records the address and length of each free space block, and log records space allocation and release operations and merges logs under certain conditions. After the node starts, the space allocator loads the free space information on the persistent medium into the memory through the free space manager. In the present application, the space allocator implements the steps of the space allocation method described in any one of the above embodiments when executing the computer program stored in the memory. By dividing the space into regions and dynamically loading the bitmap in the memory with the region as the granularity during the startup or running of the storage node, the memory occupation is reduced, the memory occupation caused by space fragmentation can be resisted, and the loading time during node restart is also reduced.
[0082] The space allocation method, device, electronic equipment, non-volatile storage medium, and computer program product provided by the present application are described in detail above. The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts of each embodiment can be referred to. The units and algorithm steps of each example described in each disclosed embodiment are executed in the form of electronic hardware or computer software, which depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, and such implementation should not be considered beyond the scope of the present application. Without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the scope of the present application.
Claims
1. A space allocation method, characterized in that, include: The storage space is pre-divided into multiple storage regions with the same storage capacity and contiguous addresses, and the correspondence between the storage bitmap and the storage address of the corresponding storage unit is persisted to the storage space; the storage region includes multiple storage units; During the startup process of the storage node, the target storage area in the storage space that is in an idle state is determined according to the correspondence; Obtain the first target storage unit and place the first target storage unit into the target storage area; Obtain the second target storage unit and the remaining storage space of the target storage area; if the storage unit capacity of the second target storage unit is greater than the remaining storage space, truncate the second target storage unit to obtain the first storage unit and the second storage unit; the space capacity of the first storage unit is the same as the remaining storage space; place the first storage unit into the target storage area, place the second storage unit into the cache space of memory, and load the bitmap information corresponding to the target storage area into memory; In this storage bitmap, each bit represents the state of the corresponding storage unit, including an idle state and an allocated state.
2. The space allocation method according to claim 1, characterized in that, Loading the bitmap information corresponding to the target storage area into memory includes: The starting address of the target storage region is determined based on the starting storage address of the first target storage unit of the target storage region and the storage capacity of the target storage region; The offset address of the target storage region is determined based on the starting storage address of the first target storage unit and the starting address of the target storage region. Based on the starting address and the offset address of the target storage region, the storage identification information corresponding to each target storage unit of the target storage region is stored in the memory bitmap.
3. The space allocation method according to claim 2, characterized in that, The memory also includes a cache space. After loading the bitmap information corresponding to the target storage area into the memory, the method further includes: When a space allocation request is received, the required storage space capacity is determined by parsing the space allocation request. If the free storage capacity in the cache space is greater than or equal to the storage capacity to be requested, then the storage address corresponding to the free storage in the cache space is sent to the requester, and the storage bitmap is updated at the same time. If there is no free storage in the cache space, a matching first target storage space is determined in the target storage area according to the memory bitmap. The storage address of the first target storage space is determined according to the start address and offset address of the target storage area, and the storage address of the first target storage space is sent to the requester. At the same time, the storage bitmap is updated. The space capacity of the first target storage space is the same as the space capacity of the storage to be requested. If the free storage capacity in the cache space is less than the storage capacity to be requested, a matching second target storage space is determined in the target storage region according to the memory bitmap. The storage address of the second target storage space is determined according to the start address and offset address of the target storage region. The storage address of the second target storage space and the storage address corresponding to the free storage in the cache space are sent to the requester together, and the storage bitmap is updated at the same time. The space capacity of the second target storage space is the difference between the storage capacity to be requested and the free storage capacity in the cache space.
4. The space allocation method according to claim 1, characterized in that, After loading the bitmap information corresponding to the target storage area into memory, the method further includes: Whenever a storage unit is detected to be freed, a corresponding space release record is generated; When a record merging request is triggered, all space release records at the current moment are merged into release record information; the release record information includes at least the identification information and storage address of each released storage unit; The target transaction is started by calling the transaction start command. A batch update statement is generated based on the release record information and the corresponding relationship. The batch update statement is then executed in the target transaction to update the corresponding relationship with the release record information.
5. The space allocation method according to any one of claims 1 to 4, characterized in that, After loading the bitmap information corresponding to the target storage area into memory, the method further includes: During the operation of the storage node, whenever it is determined from the memory bitmap of the memory that the loaded storage space has been used up, the dynamic storage units in the idle state are obtained according to the correspondence. Based on the starting memory address of the first dynamic memory unit, alignment is performed in units of memory capacity to serve as the starting address of the dynamic memory region; The difference between the starting address of the first dynamic storage unit and the starting address of the dynamic storage region is used as the offset address of the dynamic storage region. The first dynamic storage unit is placed into the dynamic storage area, and the memory bitmap of the memory is updated simultaneously. Obtain the second dynamic storage unit and the dynamic remaining storage space of the dynamic storage region; If the storage capacity of the second dynamic storage unit is greater than the dynamic remaining storage space, the second dynamic storage unit is truncated to obtain a first dynamic storage unit and a second dynamic storage unit; the space capacity of the first dynamic storage unit is the same as the dynamic remaining storage space. The first dynamic storage unit is placed into the dynamic storage area, and the second dynamic storage unit is placed into the cache space of the memory.
6. A space allocation device, characterized in that, include: A storage partitioning module is used to pre-divide the storage space into multiple storage regions with the same storage capacity and contiguous addresses, and to persist the correspondence between the storage bitmap and the storage address of the corresponding storage unit to the storage space; the storage region includes multiple storage units; The storage loading module is used to determine the target storage area in the storage space that is in an idle state according to the correspondence during the startup process of the storage node; Obtain the first target storage unit and place the first target storage unit into the target storage area; Obtain the second target storage unit and the remaining storage space of the target storage area; if the storage unit capacity of the second target storage unit is greater than the remaining storage space, truncate the second target storage unit to obtain the first storage unit and the second storage unit; the space capacity of the first storage unit is the same as the remaining storage space; place the first storage unit into the target storage area, place the second storage unit into the cache space of memory, and load the bitmap information corresponding to the target storage area into memory; wherein, each bit of the storage bitmap represents the state of the corresponding storage unit, and the state includes an idle state and an allocated state.
7. An electronic device, characterized in that, It includes a processor and a memory, wherein the processor is configured to implement the steps of the space allocation method as described in any one of claims 1 to 5 when executing a computer program stored in the memory.
8. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the space allocation method as described in any one of claims 1 to 5.
9. A distributed storage system, comprising a storage engine, characterized in that, The storage engine includes a space allocator that, when executing a computer program stored in the memory, implements the steps of the space allocation method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Intelligent Redundant Array Of Independent Disks With High Performance Recompaction
US20190057024A1
Data processing method and apparatus
WO2023241528A1