Distributed storage system, 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 only the area bitmap information into memory, the problems of high memory footprint and long loading time in PB-level space management are solved, and more efficient memory usage and business recovery speed are achieved.
Patent Information
- Application Number
- CN202411998823.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-30
AI Technical Summary
When managing PeB-level space, the existing technology occupies a lot of memory and has a long loading time when node restarts, which affects the speed of business recovery.
Space allocation and management are achieved by dividing the underlying storage space into multiple storage areas of the same size and head-to-tail connection, and loading bitmap information of only one storage area into memory with the storage area as a granularity.
It effectively reduces memory footprint, resists the increase in memory footprint caused by space fragmentation, and significantly reduces loading time when node restarts, and improves business recovery speed.
Smart Images

Figure CN119718211A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a space allocation method, device, electronic equipment, non-volatile storage medium and distributed storage system. Background Art
[0002] With the rapid development of artificial intelligence technology and big data technology, in order to meet the storage needs of the greatly increased electronic data and the efficient processing of data, the space allocation performance requirements of the storage system are becoming increasingly higher.
[0003] In the process of space allocation, when the disk space is over PB (petabytes), the memory occupied by the bitmap is too large. Managing 1PB of space requires about 35G of memory. In addition, in the node restart scenario, the bitmap needs to be fully loaded into the memory, which slows down business recovery.
[0004] In view of this, when managing PB-level space, occupying less memory and reducing the loading time when the node is restarted are technical problems that need to be solved by technical personnel in this field.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The present invention provides a space allocation method, device, electronic device, non-volatile storage medium and distributed storage system, which can occupy less memory when managing PB-level space, while reducing the loading time when the node is restarted, and effectively improving the recovery speed of the node running business.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] In one aspect, the present invention provides a space allocation method, comprising:
[0009] The storage space is pre-divided into multiple storage areas with the same storage capacity and continuous addresses, and the correspondence between the storage bitmap and the storage address of the corresponding storage unit is persisted in the storage space; the storage area includes multiple storage units; during the startup of the storage node, the target storage area in an idle state is determined in the storage space according to the correspondence, and the bitmap information corresponding to the target storage area is loaded into the 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.
[0010] In a first exemplary embodiment, the loading of the bitmap information corresponding to the target storage area into the memory includes determining the starting address of the target storage area 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; determining the offset address of the target storage area according to the starting storage address of the target storage unit and the starting address of the target storage area; and storing the storage identification information corresponding to each target storage unit of the target storage area into the memory bitmap based on the starting address of the target storage area and the offset address.
[0011] In a second exemplary embodiment, the memory also includes a cache space, and after the bitmap information corresponding to the target storage area is loaded into the memory, it also includes: when a space allocation request is received, determining the space capacity of the storage to be required by parsing the space allocation request; if the space capacity of the free storage in the cache space is greater than or equal to the space capacity of the storage to be required, sending the storage address corresponding to the free storage of the cache space to the requester, and updating the storage bitmap at the same time; if there is no free storage in the cache space, determining a matching first target storage space in the target storage area according to the memory bitmap, determining the storage address of the first target storage space according to the starting address and offset address of the target storage area, and The storage address 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 of the storage to be required; if the space capacity of the free storage in the cache space is less than the space capacity of the storage to be required, a matching second target storage space is determined in the target storage area according to the memory bitmap, the storage address of the second target storage space is determined according to the starting 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 free storage of the cache space are sent to the requester together, and the storage bitmap is updated at the same time; wherein, the space capacity value of the second target storage space is the difference between the space capacity of the storage to be required and the space capacity of the free storage in the cache space.
[0012] In a third exemplary embodiment, determining a target storage area in an idle state in the storage space according to the corresponding relationship includes: determining a target storage unit in an idle state in the storage space according to the corresponding relationship; 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 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, truncating 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; placing the first storage unit into the target storage area, and placing the second storage space into the cache space of the memory.
[0013] In a fourth exemplary embodiment, after the bitmap information corresponding to the target storage area is loaded into the memory, it also includes: whenever a storage unit is detected to be released, a corresponding space release record is generated; when a record merge request is triggered, all space release records at the current moment are merged into release record information; the release record information at least includes the identification information and storage address of each released storage unit; calling a transaction start command to start the target transaction, generating a batch update statement according to the release record information and the corresponding relationship, and executing the batch update statement in the target transaction to update the corresponding relationship with the release record information.
[0014] In a fifth exemplary implementation, after the bitmap information corresponding to the target storage area is loaded into the memory, it also includes: during the operation of the storage node, whenever it is determined according to the memory bitmap of the memory that the loaded storage space is used up, each dynamic storage unit in an idle state is obtained according to the corresponding relationship; based on the starting storage address of the first dynamic storage unit, alignment is performed in units of the storage capacity of the storage area to serve as the starting address of the dynamic storage area; the difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage area is used as the offset address of the dynamic storage area; the first dynamic storage unit is placed into the dynamic storage area, 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 area; 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 placed into the dynamic storage area, and the second dynamic storage space is placed into the cache space of the memory.
[0015] Another aspect of the present invention provides a space allocation device, comprising:
[0016] A storage segmentation module, used to pre-divide the storage space into a plurality of storage areas with the same storage capacity and continuous addresses, and persist the corresponding relationship between the storage bitmap and the storage address of the corresponding storage unit to the storage space; the storage area includes a plurality of storage units;
[0017] A storage loading module is used to determine a target storage area in an idle state in the storage space according to the corresponding relationship during the startup of the storage node, and load the bitmap information corresponding to the target storage area into the 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.
[0018] The present invention also provides an electronic device, comprising a processor, wherein the processor is used to implement the steps of the space allocation method as described in any of the preceding items when executing a computer program stored in a memory.
[0019] Finally, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the space allocation method as described in any of the preceding items are implemented.
[0020] The advantage of the technical solution provided by the present invention is that by dividing the underlying storage space into multiple storage areas of the same size and connected head to tail, and loading the bitmap information corresponding to only one storage area into the memory at a time based on the storage area granularity, the memory usage 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 usage increase caused by fragmentation can be resisted. At the same time, the loading time when the node is restarted is reduced, and the recovery speed of the node running business is effectively improved.
[0021] In addition, the present invention 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 to be mentioned below, and the technical features shown separately in the drawings can be arbitrarily combined with each other, as long as the combined technical features are not contradictory. All feasible feature combinations are technical contents clearly recorded in this article. Any of the multiple sub-features contained 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 detailed description below are only exemplary and cannot limit the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 A schematic diagram of a flow chart of a space allocation method provided by the present invention;
[0025] Figure 2 A schematic diagram of the storage space division provided by the present invention;
[0026] Figure 3 A schematic diagram of a framework of the space allocation method provided by the present invention in an exemplary application scenario;
[0027] Figure 4 A structural diagram of an exemplary embodiment of a space allocation device provided by the present invention;
[0028] Figure 5 A structural diagram of an exemplary embodiment of an electronic device provided by the present invention;
[0029] Figure 6 This is a structural diagram of an exemplary implementation of the distributed storage system provided by the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Among them, the terms "first", "second", "third", "fourth", etc. in the specification and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations of the two are intended to cover non-exclusive inclusions. The term "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described here as "exemplary" is not necessarily interpreted as being superior or better than other embodiments.
[0031] The storage system allocates memory to applicants through a space allocator. For space allocators that use bitmaps to save free space information in memory and on disk, in order to facilitate searching, this type of space allocator uses hierarchical indexes to save multiple states. This results in relatively small memory consumption when the disk space is at the TB (Terabytes) level. With 4K as the granularity, a 1TB disk requires about 35M of memory space. When the managed space reaches the PB level, the bitmap occupies too much memory, and managing 1PB space requires about 35G of memory. Moreover, in the node restart scenario, the bitmap needs to be fully loaded into the memory, and the business recovery speed is slow. In addition, for space allocators that use tree structures to save free space information in memory and on disk, such as the space allocator of the log-type file system that uses B+ trees to save free space information in memory and on disk, when the disk saves a small amount of data, the B+ tree occupies less memory and disk space, and has higher time and space efficiency. As the usage time increases, when the degree of fragmentation is high, the memory and disk space occupied by the B+ tree will increase significantly, and manual defragmentation is required to aggregate the discrete disk space. For example, a copy-on-write file system that uses a balanced binary tree to store free space information in memory uses a log to record space allocation and release operations. When the disk space is close to full, the number of leaf nodes in the tree decreases, and there is no problem of increased memory and disk space usage. Although the copy-on-write file system uses copy-on-write technology, data and metadata are only written in appends, and adjacent space records are merged. The copy-on-write file system reduces fragmentation by using 128k blocks, and the merging of the intention log (ZIL) and write (delayed write) also helps reduce fragmentation. However, when the degree of fragmentation is high, the memory and disk space occupied by the balanced binary tree will still increase significantly.
[0032] It can be seen that when the related technology is performing space allocation, when managing PB-level space, it occupies more memory, and space fragmentation will also cause the memory usage to increase. In view of this, the present invention divides the underlying storage space into multiple storage areas of the same size and connected head to tail, and uses the storage area as the granularity to load only the bitmap information corresponding to one storage area into the memory at a time. When managing PB-level space, it occupies less memory and can resist the increase in memory usage caused by space fragmentation. After introducing the technical solution of the present invention, various non-limiting embodiments of the present invention are described in detail below. In order to better illustrate the present invention, numerous specific details are given in the specific embodiments below. Those skilled in the art should understand that the present invention can also be implemented without these specific details. In other examples, the methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present invention.
[0033] First see Figure 1 , Figure 1 A schematic diagram of a flow chart of a space allocation method provided in this embodiment, this embodiment may include the following contents:
[0034] S101: pre-dividing a storage space into a plurality of storage areas with the same storage capacity and continuous addresses, and persisting a correspondence between a storage bitmap and a storage address of a corresponding storage unit in the storage space.
[0035] In this embodiment, the storage space is the underlying management space composed of the underlying storage components of the storage system, such as a storage space composed of a mechanical hard disk, a solid-state hard disk, a magnetic disk, or other persistent storage media. Figure 2 As shown, the storage space is divided into multiple storage areas of the same size and connected head to tail, and each storage area also includes multiple storage units, which are the minimum allocation units and can usually be an integer multiple of a data block. The storage space has a bitmap for identifying whether the storage space is used. For the convenience of description, it is defined as a storage bitmap. After the storage space is divided into multiple storage areas, each bit (that is, a binary bit) of the storage bitmap represents the state of the corresponding storage unit, and the state includes an idle state and an allocated state. Exemplarily, 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 kv (key-value), where key is the first address of the storage space, and value is the bitmap of the storage space. A key can manage multiple minimum allocation units, and its value records the bitmap status of these minimum allocation units. Each persistent medium of the storage space can be identified by a byte sequence or a 3-byte sequence, which does not affect the implementation of the present invention.
[0036] S102: During the storage node startup process, a target storage area in an idle state is determined in the storage space according to the corresponding relationship, and bitmap information corresponding to the target storage area is loaded into the memory;
[0037] For each storage node of the storage system, each time when it is normally started or restarted, only the free space information of one storage area is loaded into the bitmap in the memory. For the convenience of description, the loaded storage area is defined as the target storage area.
[0038] In the technical solution provided in this embodiment, the underlying storage space is divided into multiple storage areas of the same size and connected head to tail, and the bitmap information corresponding to only one storage area is loaded into the memory at a time based on the storage area granularity, thereby effectively reducing the memory usage. Even when the managed space reaches the PB level, the memory occupied by the bitmap will not be large, and the space usage increase caused by fragmentation can be resisted. At the same time, the loading time when the node is restarted is reduced, and the recovery speed of the node running business is effectively improved.
[0039] It should be noted that there is no strict order of execution between the steps in the present invention. As long as they comply with the logical order, these steps can be executed simultaneously or in a certain preset order. Figure 1 This is just a schematic and does not mean that this is the only execution order.
[0040] In the above embodiment, there is no limitation on how to load the bitmap information corresponding to the target storage area into the memory. Based on the above embodiment, the present invention further provides an exemplary implementation process of loading the bitmap information corresponding to the target storage area into the memory, which may include the following contents:
[0041] The starting address of the target storage area is determined according to the starting storage address of the first target storage unit in the target storage area and the storage capacity of the target storage area; the offset 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; based on the starting address and the offset address of the target storage area, the storage identification information corresponding to each target storage unit in the target storage area is stored in a memory bitmap.
[0042] Since the storage area is continuous when it is divided, when the free space is listed from the storage position corresponding to the storage space and the corresponding relationship between the storage position, the free space is the storage unit in the idle state. For the convenience of description, this embodiment defines it as a target storage unit. These free spaces are in order according to the address continuity. From the first address to the end address of the storage area, the first free space is the first target storage unit. The storage capacity of the target storage area is the size of the divided storage area. For example, when the starting address of the first target storage unit is 0x100000 and the length is 4K, and the storage capacity of the target storage area is 1TB, it is aligned in units of storage size, and the corresponding target storage starting address is 0. Subtract the starting address of the target storage from the starting address of the first target storage unit to obtain the offset address in the target storage. 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. For the convenience of description, the memory bitmap can be defined as a memory bitmap. Among them, the storage identification information is the identification information used to represent the target storage unit, so that the target storage unit can be located when the memory allocates space.
[0043] From the above, it can be seen that this embodiment determines the address of the storage area loaded into the memory through the address of the storage unit and the size of the storage area, thereby realizing loading into the memory according to the granularity of the storage area, reducing memory occupancy and being able to effectively resist the problem of increased space occupancy caused by fragmentation.
[0044] The above embodiment does not limit how to determine the target storage area to be loaded into the memory from the storage space. Based on the above embodiment, the present invention further provides an exemplary implementation method, which may include the following contents:
[0045] Determine the target storage unit in the storage space that is in an idle state according to the correspondence between the storage bitmap and the storage address of the corresponding storage unit; obtain the first target storage unit and put 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; put the first storage unit into the target storage area, and put the second storage space into the cache space of the memory.
[0046] This embodiment takes the correspondence between the storage bitmap and the storage address of the corresponding storage unit as an example, and lists the storage units currently in the idle state from the storage space based on the kv. When the storage area is divided, the address is continuous. According to the direction from the first address to the end address of the storage area, the order of these idle storage units can be determined, and they are defined as the first storage unit and the second storage unit respectively. In order to facilitate description and reflect the relationship between the storage unit and the storage area, this embodiment defines them as target storage units, and correspondingly, they are the first target storage unit and the second target storage unit. The size of the target storage area is fixed, so when each target storage unit is placed in the target storage area, it is inevitable that the size of the target storage unit that needs to be placed is larger than the remaining storage space in the target storage area. In view of this situation, every time a target storage unit is placed, 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 placed in the memory bitmap, and the second half that exceeds the end of the target storage area is placed in the cache space of the memory. If it does not exceed, continue to obtain the next target storage unit and make judgments in the same direction until all or part of the obtained free target storage area cannot be placed in the target storage area.
[0047] As can be seen from the above, in order to load the data into the memory at the storage area granularity, this embodiment cuts off the minimum allocation unit in the idle state, and directly puts the excess into the cache space of the memory, which is beneficial to improving the space allocation efficiency.
[0048] Based on the above embodiment, when an applicant applies for space from a storage system, the applicant will send a space allocation request carrying storage requirements to the storage system. When the storage system receives the space allocation request, it determines the space capacity of the storage to be required by parsing the space allocation request. The storage to be required is the storage space that the applicant wants to apply for, and the space capacity of the storage to be required is the size of the storage space that the applicant wants to apply for. If the space capacity of the free storage in the cache space is greater than or equal to the space capacity of the storage to be required, the storage address corresponding to the free storage of 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 starting address and the 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 of the storage to be required; if the space capacity of the free storage in the cache space is less than the space capacity of the storage to be required, a matching second target storage space is determined in the target storage area according to the memory bitmap, the storage address of the second target storage space is determined according to the starting address and the offset address of the target storage area, and the storage address of the second target storage space and the storage address corresponding to the free storage of the cache space are sent to the requester together, and the storage bitmap is updated at the same time; wherein, the space capacity value of the second target storage space is the difference between the space capacity of the storage to be required and the space capacity of the free storage in the cache space.
[0049] It is understandable that if Figure 3 As shown, when allocating free storage space for the applicant, the memory bitmap stores the available storage space, and the cache space in the memory also stores some free space that cannot be placed in the target storage area, and the free space in the cache space can be used first. When there is no free space available in the cache space, the free storage space is allocated to the applicant according to the memory bitmap, and the allocated free space address, that is, the offset address in the target storage area, plus the starting address of the target storage area, is returned to the applicant as the global address of the space, and the allocated space record is updated to the storage bitmap of the storage space, such as persisted to the kv of the storage space.
[0050] In order to further improve the storage space utilization efficiency, reduce memory usage and resist the memory increase problem caused by fragmentation, based on the above embodiment, the present invention also provides an implementation method for uniformly processing space release records in a transactional manner, which may include the following contents:
[0051] Whenever it is detected that a storage unit is released, a corresponding space release record is generated; when a record merge 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 transaction start command is called to start the target transaction, 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 this embodiment, a unique identifier, such as a block ID or a storage unit ID, may be assigned to each data block or storage unit in advance, and a release list may be created in advance. When a storage unit is released, the identifier may be placed in the release list to generate a corresponding space release record. The record merge request may be implemented in a fixed frequency manner, such as issuing a record merge request every 24 hours, or it may be manually issued, or when the size of the release list exceeds a threshold or the space release record exceeds a preset threshold, a record merge request is issued. Whenever a record merge request is received, the generated space release records are batch merged. In order to avoid description, it is defined as release record information and updated in batches through transactions, such as updating to the persistent kv of the storage space. Exemplarily, the batch update process through transactions may include: when determining the object to be updated, that is, the storage bitmap of the storage space and its corresponding relationship with the storage address, the method is to update according to the release record information, and then the SQL (database language) update statement may be designed according to the update requirements. Before performing a batch update, the relevant data may also be backed up to prevent data loss due to operational errors. Then you can start a transaction through SQL commands, such as using `START TRANSACTION` (database command) in MySQL (database name) to start a transaction. Write one or more SQL statements for batch updates, such as using the `UPDATE` statement in combination with the `WHERE` clause to specify the update conditions, and execute these batch update statements in the transaction. Furthermore, to ensure that the update is successful, you can further use query commands to query the storage bitmap of the storage space to verify whether the update is executed as expected. If the update result is verified to be correct, commit the transaction to make all updates permanent. If the update result is found to be incorrect or an error occurs, use the `ROLLBACK;` command to roll back the transaction and 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. In order to facilitate tracing of problems, you can also record the operation log of batch updates at the same time, including the operation time, operator, amount of data updated, etc., to facilitate subsequent auditing and troubleshooting.
[0053] As can be seen from the above, this embodiment uniformly processes space release records in a transactional manner, which can not only improve the efficiency of storage space use, but also reduce memory usage and resist the problem of memory increase caused by fragmentation.
[0054] It is understandable that the storage space loaded in the memory is limited. When the memory bitmap shows that the loaded storage space is fully allocated, the present invention also provides a method for dynamically loading the next storage area to load the next area with free space into the memory while the storage node maintains a normal working state. The dynamic loading process may include the following contents:
[0055] During the operation of the storage node, whenever it is determined according to the memory bitmap of the memory that the loaded storage space is used up, each dynamic storage unit in an idle state is obtained according to the corresponding relationship; based on the starting storage address of the first dynamic storage unit, alignment is performed in units of the storage capacity of the storage area to serve as the starting address of the dynamic storage area; the difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage area is used as the offset address of the dynamic storage area; the first dynamic storage unit is placed in the dynamic storage area, 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 area; 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 placed in the dynamic storage area, and the second dynamic storage space is placed in 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, that is, without the user's perception. Since the cache space of the memory has storage space that is not placed in 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. You can first get the first free space address from the cache space of the memory. If there are no free storage units in the cache space, you can list the storage units in the space state based on the storage bitmap of the storage space. For easy distinction, the storage units determined to be included in the dynamic storage area are defined as dynamic storage units. Similarly, get the free space address of the first dynamic storage unit, align it with the size of the dynamic storage area, and use it as the starting address of the dynamic storage area. Subtract the starting address of the dynamic storage area from the starting address of the first dynamic storage unit as the offset address in the dynamic storage area, and put the first dynamic storage unit 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, and 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. Repeat the above steps until all or part of the obtained dynamic storage unit cannot be put into the dynamic storage area. Similarly, the cache space of the memory may also store some free space that cannot be put into the dynamic storage area. The next time you load or apply for space, use the free space in the cache space first.
[0057] It is understandable that during the normal operation of the storage node, when there are many read and write tasks, dynamic loading will be performed continuously. If the current dynamic storage area slides to the end of the managed space, the next dynamic loading can jump to the head of the storage space, that is, the currently loaded dynamic storage area may be physically discontinuous with the last loaded dynamic storage area.
[0058] From the above, it can be seen that during the operation of the storage node, without the user's awareness, this embodiment can dynamically load the free space in the area into the bitmap in the memory with the storage area as the granularity according to the operation status of the storage node, thereby realizing global free space management and ensuring the continuity and stability of the storage node's operation business.
[0059] It is understandable that in order to ensure that the storage system can stably perform the space allocation task, it is necessary to ensure that there is sufficient storage space. Based on the above embodiment, the present invention also provides an implementation method for optimizing the storage space:
[0060] A space usage monitoring thread is pre-built, and the space usage monitoring thread is called to monitor the space usage of the storage system and generate storage space usage information; storage configuration parameters are adjusted accordingly according to the storage space usage information.
[0061] Among them, the space usage monitoring thread can obtain space usage and fragmentation by calling the space management tool or the pre-configured space management script. For example, you can use `ceph-bluestore-tool` (tool name) to check space usage and fragmentation. You can use the space usage check command to obtain space usage. The space usage check command can be, for example: "ceph-bluestore-tool --path PATH_TO_OSD_DATA_DIRECTORY --allocator block free-score". The efficiency of space usage can be clarified based on the value returned by the command. The lower the score, the more fragmented the space usage. You can also use the command "ceph-bluestore-tool --path PATH_TO_OSD_DATA_DIRECTORY --allocator block free-dump" to obtain more detailed usage, such as capacity, allocation unit, allocation type and other detailed information. Furthermore, you can also use a storage system such as a ceph (distributed storage system) command line tool to query cluster information. For example, you can log in to the Cephadm shell and use the `ceph status` command to check the status of the ceph storage cluster to obtain information such as cluster health status, OSD (Object Storage Device) status, storage data volume and usage. For example, you can also use the `ceph -w` command to monitor the continuous events of the storage cluster of the storage system, or display the cluster status through the `status` subcommand or `-s` to obtain the real-time status changes of the storage cluster and changes in space usage. The real-time status changes include changes in the health status, service status and data status of the storage cluster. Accordingly, the storage space usage information may include 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 status change information of the storage cluster.
[0062] When the storage space usage information is obtained, the block size of partition write data, storage medium type, storage location, storage policy, object storage target, cache size, and write times can be adjusted. Among them, the default value of the block size of partition write data is 4k. 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 data with the performance requirements of the read and write performance with the performance of the storage medium, such as placing the object data located on the mechanical hard disk on the solid-state drive through the block database, and placing the pre-write log on the NVMe (Non-Volatile Memory express, non-volatile memory host controller) device to improve performance. The storage location refers to the location of the separated data, block database, and pre-write log devices that can be defined through the service specification file to improve performance. The storage policy includes space release and data compression. The FreelistManager can coordinate the allocation and recycling of storage space to ensure that each data block is fully utilized while preventing fragmentation, thereby optimizing storage performance. When compressed data usage is allowed, the application workload is compressible and the data can be compressed using a matching compression mode. The object storage target is tuned to keep OSD stack memory usage below the target size specified by this configuration option. By reducing the size and frequency of write operations, you can reduce the number of writes to the storage media, thereby extending its life and improving efficiency.
[0063] The block size for writing data to a partition specifies the minimum amount of space required for each object allocation. If the data written is smaller than this size, the storage system fills the remaining space with zeros. Therefore, correctly configuring this parameter can avoid wasting space, especially when writing small objects. In order to improve the storage performance of the storage space of the storage system, the block size for writing data to a partition 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 should be set to 4096 bytes.
[0064] As can be seen from the above, this 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 storage performance and reliability, and ensuring the stable operation of user services.
[0065] The present invention also provides a corresponding device for the space allocation method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and hardware. The space allocation device provided by the present invention is introduced below. The device is used to implement the space allocation method provided by the present invention. In this embodiment, the space allocation device may include or be divided into one or more program modules. The one or more program modules are stored in a storage medium and executed by one or more processors to complete the space allocation method disclosed in Example 1. The program module referred to in this embodiment refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the execution process of the space allocation device in the storage medium than the program itself. The following description will specifically introduce the functions of each program module of this embodiment. The space allocation device described below and the space allocation method described above can be referenced to each other.
[0066] From the perspective of functional modules, see Figure 4 , Figure 4 The structure diagram of the space allocation device provided in this embodiment under a specific implementation mode may include:
[0067] The storage segmentation module 401 is used to pre-divide the storage space into multiple storage areas with the same storage capacity and continuous addresses, and persist the corresponding relationship between the storage bitmap and the storage address of the corresponding storage unit to the storage space; the storage area includes multiple storage units.
[0068] The storage loading module 402 is used to determine the target storage area in an idle state in the storage space according to the corresponding relationship during the storage node startup process, and load the bitmap information corresponding to the target storage area into the 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.
[0069] Exemplarily, in some implementations of the present embodiment, the above-mentioned storage loading module 402 can also be used to: determine the starting address of the target storage area 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; determine the offset address of the target storage area according to the starting storage address of the target storage unit and the starting address of the target storage area; based on the starting address and the offset address of the target storage area, store the storage identification information corresponding to each target storage unit of the target storage area into the memory bitmap.
[0070] Exemplarily, in some other implementations of the present embodiment, the above-mentioned device may include an application request processing module, which can be used to: when receiving a space allocation request, determine the space capacity of the storage to be required by parsing the space allocation request; if the space capacity of the free storage in the cache space is greater than or equal to the space capacity of the storage to be required, send the storage address corresponding to the free storage of the cache space to the requester, and update the storage bitmap at the same time; if there is no free storage in the cache space, determine a matching first target storage space in the target storage area according to the memory bitmap, determine the storage address of the first target storage space according to the starting address and offset address of the target storage area, and store the storage address of the first target storage space Sent to the requester and updating the storage bitmap at the same time; the space capacity of the first target storage space is the same as the space capacity of the storage to be required; if the space capacity of the free storage in the cache space is less than the space capacity of the storage to be required, then determine a matching second target storage space in the target storage area according to the memory bitmap, determine the storage address of the second target storage space according to the starting 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 of the cache space to the requester together, and update the storage bitmap at the same time; wherein the space capacity value of the second target storage space is the difference between the space capacity of the storage to be required and the space capacity of the free storage in the cache space.
[0071] Illustratively, in some other implementations of the present embodiment, the above-mentioned storage segmentation module 401 can also be used to: determine the target storage unit that is in an idle state in the storage space according to the corresponding relationship; 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, and place the second storage space into the cache space of the memory.
[0072] Exemplarily, in some other implementations of the present embodiment, the above-mentioned device may also include a release module, which can be used to: generate a corresponding space release record whenever a storage unit is detected to be released; when a record merge request is triggered, merge all space release records at the current moment into release record information; the release record information includes at least the identification information and storage address of each released storage unit; call the transaction start command to start the target transaction, generate a batch update statement based on the release record information and the corresponding relationship, and execute the batch update statement in the target transaction to update the corresponding relationship of the release record information.
[0073] Exemplarily, in some other implementations of the present embodiment, the above-mentioned device may also include a dynamic recording module, which can be used for: during the operation of the storage node, whenever it is determined according to the memory bitmap of the memory that the loaded storage space is used up, each dynamic storage unit in an idle state is obtained according to the corresponding relationship; based on the starting storage address of the first dynamic storage unit, alignment is performed in units of the storage capacity of the storage area to serve as the starting address of the dynamic storage area; the difference between the starting storage address of the first dynamic storage unit and the starting address of the dynamic storage area is used as the offset address of the dynamic storage area; the first dynamic storage unit is placed in the dynamic storage area, and the memory bitmap of the memory is updated at the same time; the second dynamic storage unit and the dynamic remaining storage space of the dynamic storage area are obtained; 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 placed in the dynamic storage area, and the second dynamic storage space is placed in the cache space of the memory.
[0074] The space allocation device mentioned above is described from the perspective of functional modules. Furthermore, the present invention also provides an electronic device, which is described from the perspective of hardware. Figure 5 The following is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention in one implementation manner. Figure 5 As shown, the electronic device includes a memory 50 for storing a computer program; and a processor 51 for implementing the steps of the space allocation method mentioned in any of the above embodiments when executing the computer program.
[0075] Among them, the processor 51 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the processor 51 may also be a controller, a microcontroller, a microprocessor or other data processing chip. The processor 51 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 51 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 51 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 51 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0076] The memory 50 may include one or more computer non-volatile storage media, which may be non-transitory. The memory 50 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the memory 50 may be an internal storage unit of an electronic device, such as a hard disk of a server. In other embodiments, the memory 50 may also be an external storage device of an electronic device, such as a plug-in hard disk equipped on a server, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 50 may also include both an internal storage unit and an external storage device of an electronic device. The memory 50 may not only be used to store application software and various types of data installed in the electronic device, such as: the code of the program in the process of executing the space allocation method, etc., but also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 50 is at least used to store the following computer program 501, wherein, after the computer program is loaded and executed by the processor 51, the relevant steps of the space allocation method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 50 may also include an operating system 502 and data 503, etc., and the storage method may be temporary storage or permanent storage. The operating system 502 may include Windows, Unix, Linux, etc. The data 503 may include but is not limited to data corresponding to the space allocation result, etc.
[0077] In some embodiments, the electronic device may 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 the user interface, and exemplary user interfaces may also include standard wired interfaces, wireless interfaces, etc. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may 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 visual user interface. The communication interface 54 may exemplarily include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, etc., which are generally used to establish a communication connection between the electronic device and other electronic devices. The communication bus 56 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0078] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than those shown in the figure, for example, it may also include a sensor 57 for realizing various functions.
[0079] It is understandable that if the space allocation method in the above embodiment 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 an understanding, the technical solution of the present invention is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes but is not limited to: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, removable disk, CD-ROM, magnetic disk or optical disk, etc. Various media that can store program codes. Based on this, the present invention also provides a non-volatile storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the space allocation method recorded in any of the above embodiments are performed.
[0080] It is understandable that if the space allocation method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, the computer software product does not need to be stored in a physical storage medium. For example, it can be directly transmitted to a computer or other device with information processing capabilities through a wired network or a wireless network to execute all or part of the steps of the methods of each embodiment of the present invention. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product. Based on this, the present invention also provides a computer program product storing a computer program. When the computer program is executed by a processor, it performs the steps of the space allocation method described in any of the above embodiments.
[0081] Finally, the present invention also provides a distributed storage system, which may include a storage engine, which is responsible for the reading and writing tasks of data on the underlying disk, 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 may further include a space allocator, which is one of the components of the storage engine and has a decisive influence on the performance of the storage engine. The space allocator needs to take into account both time and space efficiency, which may include a memory-based space allocator and a free space manager based on a persistent medium. Among them, the memory-based space allocator is used to quickly find and mark free space in the memory, and has high requirements for time efficiency. Bitmap or tree can be used. In the bitmap mode, each bit represents the state of a minimum allocation unit (allocated or free), and in the tree mode, each leaf node saves the address and length of the free block. The free space manager based on the persistent medium is used to save the free space information on the persistent medium, which has high requirements for space efficiency and will not be frequently searched. Bitmap, tree, and log can be used. The bitmap records whether each minimum allocation unit has been allocated, the tree records the address and length of each free space, the log records the space allocation and release operations, and merges the logs under certain conditions. After the node is started, the space allocator loads the free space information on the persistent medium into the memory through the free space manager. In the present invention, the space allocator implements the steps of the space allocation method described in any of the above embodiments when executing the computer program stored in the memory, by dividing the space into regions and dynamically loading the regions into the bitmap located in the memory during the startup or operation of the storage node, thereby reducing memory usage, resisting the increase in memory usage caused by space fragmentation, and reducing the loading time when the node is restarted.
[0082] The above is a detailed introduction to a space allocation method, device, electronic device, non-volatile storage medium and computer program product provided by the present invention. The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can refer to each other. Whether the units and algorithm steps of each example described in each disclosed embodiment are executed in electronic hardware or computer software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods for each specific application to implement the described functions, and such implementation should not be considered to exceed the scope of the present invention. Without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A space allocation method, characterized in that: include: Pre-dividing the storage space into a plurality of storage areas with the same storage capacity and continuous addresses, and persisting the corresponding relationship between the storage bitmap and the storage address of the corresponding storage unit to the storage space; the storage area includes a plurality of storage units; During the startup of the storage node, a target storage area in an idle state is determined in the storage space according to the corresponding relationship, and bitmap information corresponding to the target storage area is loaded 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.
2. The space allocation method according to claim 1, characterized in that: The step of loading the bitmap information corresponding to the target storage area into the memory includes: Determine the starting address of the target storage area 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; Determining an offset address of the target storage area according to a starting storage address of the target storage unit and a starting address of the target storage area; Based on the start address of the target storage area and the offset address, storage identification information corresponding to each target storage unit of the target storage area is stored in a memory bitmap.
3. The space allocation method according to claim 2, characterized in that: The memory also includes a cache space, and after the bitmap information corresponding to the target storage area is loaded into the memory, the method further includes: When receiving a space allocation request, determining the space capacity to be stored by parsing the space allocation request; If the space capacity of the free storage in the cache space is greater than or equal to the space capacity of the storage to be requested, 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, a 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 of the storage to be required; If the space capacity of the free storage in the cache space is less than the space capacity of the storage to be required, a matching second target storage space is determined in the target storage area according to the memory bitmap, and the storage address of the second target storage space is determined according to the starting 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 free storage of the cache space are sent to the requester together, and the storage bitmap is updated at the same time; wherein, the space capacity value of the second target storage space is the difference between the space capacity of the storage to be required and the space capacity of the free storage in the cache space.
4. The space allocation method according to claim 1, characterized in that: The step of determining a target storage area in an idle state in the storage space according to the corresponding relationship includes: Determine a target storage unit in the storage space that is in an idle state according to the corresponding relationship; Acquire a first target storage unit, and place the first target storage unit into the target storage area; Acquire a second target storage unit and 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, the second target storage unit is truncated 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; The first storage unit is placed into the target storage area, and the second storage space is placed into the cache space of the memory.
5. The space allocation method according to claim 1, characterized in that: After the bitmap information corresponding to the target storage area is loaded into the memory, the method further includes: 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 moment are merged into release record information; the release record information at least includes identification information and storage addresses of each released storage unit; A transaction start command is called to start a target transaction, 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 corresponding relationship with the release record information.
6. The space allocation method according to any one of claims 1 to 5, characterized in that: After the bitmap information corresponding to the target storage area is loaded into the memory, the method further includes: During the operation of the storage node, whenever it is determined according to the memory bitmap of the memory that the loaded storage space is exhausted, each dynamic storage unit in an idle state is obtained according to the corresponding relationship; Based on the starting storage address of the first dynamic storage unit, the storage capacity of the storage area is used as a unit for alignment to serve as the starting address of the dynamic storage area; using a difference between a starting storage address of the first dynamic storage unit and a 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 a memory bitmap of the memory; Acquire a second dynamic storage unit and a 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, 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 space is placed into the cache space of the memory.
7. A space allocation device, characterized in that: include: A storage segmentation module, used to pre-divide the storage space into a plurality of storage areas with the same storage capacity and continuous addresses, and persist the corresponding relationship between the storage bitmap and the storage address of the corresponding storage unit to the storage space; the storage area includes a plurality of storage units; A storage loading module is used to determine a target storage area in an idle state in the storage space according to the corresponding relationship during the startup of the storage node, and load the bitmap information corresponding to the target storage area into the 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.
8. An electronic device, characterized in that: It comprises a processor and a memory, wherein the processor is used to implement the steps of the space allocation method as claimed in any one of claims 1 to 6 when executing the computer program stored in the memory.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the space allocation method according to any one of claims 1 to 6 are implemented.
10. A distributed storage system, comprising a storage engine, characterized in that: The storage engine comprises a space allocator, and the space allocator implements the steps of the space allocation method according to any one of claims 1 to 6 when executing a computer program stored in a memory.
Citation Information
Patent Citations
FLASH balanced erasing method and system
CN108255740A
Hard disk data management method and device, equipment and medium
CN113360095A
Control method and storage device
US20130262799A1
Intelligent Redundant Array Of Independent Disks With High Performance Recompaction
US20190057024A1
Selective volatile memory refresh via memory-side data valid indication
US20200098420A1
Cited By
Storage space management method and device, electronic equipment, storage medium and program product
CN120371720A
Dynamic memory allocation method and device, medium and product
CN120821439A
Dynamic APP management method and device, terminal equipment and storage medium
CN121187667A
A dynamic APP management method and device, terminal equipment and storage medium
CN121187667B