A data storage method, apparatus, device, and readable storage medium
By locking unoccupied and unlocked children in the bitmap allocator of BlueStore, querying and storing them to continuous available space, the problems of poor continuity and low efficiency of data storage are solved, and efficient data storage and disk management are achieved.
Patent Information
- Application Number
- CN202211060409.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-08-30
AI Technical Summary
The existing bitmap allocator causes poor continuity and inefficiency of data storage in BlueStore, making it impossible to effectively manage disk fragmentation.
By locking children in the bitmap layer that are not occupied and not locked, check whether there is continuous available space for the disk space. If there is, store data. If there is no, release the lock and lock other children until the last child, and store them first to reduce fragmentation.
Improves the efficiency and continuity of data storage, reduces disk fragmentation, and improves data read and write performance.
Smart Images

Figure CN115344217B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and more specifically, to a data storage method, device, equipment and readable storage medium. Background Art
[0002] BlueStore is a storage engine of the distributed storage system ceph. Currently, the default disk space allocator in BlueStore is the new version of the bitmap allocator. Among them, the bitmap allocator is implemented based on a bitmap, and is generally divided into three bit layers: L0, L1, and L2. Each bit layer contains a complete disk space mapping. Among them, one children in the L2 layer is a set of multiple children in the L1 layer, one children in the L1 layer is a set of multiple children in the L0 layer, and one children in the L0 layer is a set of multiple blocks in the disk. children is the allocation unit of the slot, and the slot is the basic unit of bit operation.
[0003] Currently, when the bitmap allocator stores data, it queries from the first children in the L2 layer to the children in the L1 layer, the children in the L0 layer, and the blocks in the disk according to the relationship between the children in the L2 layer, the children in the L1 layer, the children in the L0 layer, and the blocks in the disk to determine the unoccupied blocks in the disk. Then, the data is stored in the unoccupied blocks. Moreover, each piece of data starts from the first children in the L2 layer to determine the unoccupied blocks and stores the data. And it is after the previous piece of data is completely stored that the same operation is performed on the next piece of data for data storage to avoid data conflicts. However, since the bitmap allocator uses a bitmap management method, it is easy to cause disk fragmentation, and the continuity of data storage cannot be guaranteed. Moreover, the above method will result in relatively low data storage efficiency.
[0004] In summary, how to enhance the continuity of data storage and improve the data storage efficiency is a technical problem that those skilled in the art need to solve urgently at present. Summary of the Invention
[0005] In view of this, the purpose of the present application is to provide a data storage method, device, equipment and readable storage medium for enhancing the continuity of data storage and improving the data storage efficiency.
[0006] To achieve the above purpose, the present application provides the following technical solutions:
[0007] A data storage method applied to the bitmap allocator in BlueStore includes:
[0008] When the data to be stored is obtained, lock any unoccupied and unlocked child in the bitmap layer;
[0009] Query downward from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk;
[0010] If so, store the data to be stored in the continuous available space;
[0011] If not, release the lock of the locked child, lock any other unoccupied and unlocked child in the bitmap layer, and perform the step of querying downward from the locked child until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
[0012] Preferably, locking any unoccupied and unlocked child in the bitmap layer includes:
[0013] Determine the bitmap layer to be locked from the first bitmap layer and the second bitmap layer according to the disk space size corresponding to a child in the first bitmap layer included in the bitmap allocator, the disk space size corresponding to a child in the second bitmap layer, and the size of the data to be stored; one child in the first bitmap layer corresponds to multiple children in the second bitmap layer;
[0014] Lock any unoccupied and unlocked child in the bitmap layer to be locked.
[0015] Preferably, locking any unoccupied and unlocked child in the bitmap layer includes:
[0016] Lock any unoccupied and unlocked child in the first bitmap layer included in the bitmap allocator.
[0017] Preferably, it further includes:
[0018] Obtain the available space obtained by recycling useless data on the disk;
[0019] Determining whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk includes:
[0020] Determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children except for the available space obtained by recycling useless data in the disk;
[0021] When locking any other unoccupied and unlocked children in the bitmap layer, it further includes:
[0022] If the last unoccupied and unlocked child in the bitmap layer is locked, and it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child except for the available space obtained by recycling useless data in the disk, then start locking from the first unoccupied and unlocked child in the bitmap layer, and start querying from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the available space obtained by recycling useless data in the disk corresponding to the locked child.
[0023] Preferably, it further includes:
[0024] When new data to be stored is obtained, lock any other unoccupied and unlocked children in the bitmap layer included in the bitmap allocator, so as to determine corresponding continuous available space according to the locked children corresponding to the new data to be stored, and store the new data to be stored in the corresponding continuous available space.
[0025] Preferably, if it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last unoccupied and locked child in the bitmap layer, it further includes:
[0026] Divide the data to be stored according to the minimum allocation unit of the disk, and store the divided data blocks in the smallest idle allocation unit in the disk.
[0027] Preferably, after storing the data to be stored in the continuous available space, it further includes:
[0028] Output the storage information of the data to be stored.
[0029] A data storage device, applied to the bitmap allocator in BlueStore, includes:
[0030] A first locking module, configured to lock any unoccupied and unlocked child in the bitmap layer when data to be stored is obtained;
[0031] A query module, configured to query downward from the locked children to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk.
[0032] A storage module, configured to store the data to be stored in the continuous available space if there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk.
[0033] An execution module, configured to release the lock of the locked children if there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk, lock any other unoccupied and unlocked children in the bitmap layer, and execute the step of querying downward from the locked children until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
[0034] A data storage device, comprising:
[0035] A memory, configured to store a computer program;
[0036] A processor, configured to implement the steps of the data storage method as described in any one of the above when executing the computer program.
[0037] A readable storage medium, in which a computer program is stored, and the computer program implements the steps of the data storage method as described in any one of the above when executed by a processor.
[0038] The present application provides a data storage method, apparatus, device and readable storage medium. Among them, the method is applied to a bitmap allocator in BlueStore, and includes: when obtaining data to be stored, locking any unoccupied and unlocked child in the bitmap layer; querying downward from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk; if so, storing the data to be stored in the continuous available space; if not, releasing the lock of the locked child, locking any other unoccupied and unlocked child in the bitmap layer, and executing the step of querying downward from the locked child until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
[0039] In the above technical solution disclosed in this application, when the bitmap allocator in BlueStore performs data storage, it locks the children in the bitmap layer that are unoccupied and unlocked, so as to avoid querying the disk space from the first child in the bitmap layer every time, and enables that when processing the current data to be stored, there is no need to pay attention to whether there is other data to be stored being processed currently, but can directly perform the storage operation, and enables that when there is more data to be stored later, it can directly query and process from the unlocked children according to the locking situation of the children in the bitmap layer, without waiting for the current data to be stored to be completed before processing, so as to avoid data storage conflicts and achieve concurrent allocation of disk space and concurrent storage of data, thereby improving data storage efficiency. Moreover, when performing data storage, it queries downward from the locked children to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk. If it exists, the data to be stored is stored in the continuous available space; if it does not exist, the lock of the locked children is released, so that when other data to be stored comes, it can lock, query and utilize the corresponding disk space of the children, thereby improving data storage efficiency. After releasing the lock of the locked children, it locks the other unoccupied and unlocked children in the bitmap layer, and then executes the step of querying downward from the locked children until the last unoccupied and unlocked children in the bitmap layer are locked and corresponding processing is performed. By this method, when performing data storage, the data to be stored is preferentially stored in the continuous available space in the disk, so as to reduce disk fragmentation, enhance the continuity of data storage, and improve data reading and writing performance. Brief Description of the Drawings
[0040] In order to more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.
[0041] Figure 1 It is a flowchart of a data storage method provided by an embodiment of this application;
[0042] Figure 2 It is a schematic diagram of the bitmap allocator in BlueStore provided by an embodiment of this application;
[0043] Figure 3Schematic diagram of a data storage device provided by an embodiment of the present application;
[0044] Figure 4 Schematic diagram of a data storage device provided by an embodiment of the present application. Detailed implementation manners
[0045] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0046] See Figure 1 and Figure 2 wherein, Figure 1 shows a flowchart of a data storage method provided by an embodiment of the present application, Figure 2 shows a schematic diagram of a bitmap allocator in BlueStore provided by an embodiment of the present application. A data storage method provided by an embodiment of the present application, which is applied to the bitmap allocator in BlueStore, may include:
[0047] S11: When the data to be stored is obtained, lock any unoccupied and unlocked children in the bitmap layer.
[0048] In the present application, the bitmap allocator may specifically include a first bitmap layer (corresponding to the L2 layer in Figure 2 ), a second bitmap layer (corresponding to the L1 layer in Figure 2 ), and a third bitmap layer (corresponding to the L0 layer in Figure 2 ). One child in the first bitmap layer corresponds to multiple children in the second bitmap layer, one child in the second bitmap layer corresponds to multiple children in the third bitmap layer, and one child in the third bitmap layer corresponds to multiple minimum allocation units on the disk (i.e., blk in Figure 2 ). Each bitmap layer contains a complete mapping of the disk space. Among them, children: the allocation unit of the slot, which may occupy 1 bit or 2 bits, and slot: of uint64 type, 64 bits, the basic unit of bit operation.
[0049] When the bitmap allocator in BlueStore obtains the data to be stored, it can lock any unoccupied and unlocked child in one of the three-bit layers it contains in the first-level bit layer, so as to lock the unoccupied and unlocked child (that is, obtain the locked child), thereby indicating that the locked child corresponds to the data to be stored obtained by the bitmap allocator at this time. Among them, since the disk space corresponding to the first-level bit layer and the second-level bit layer is relatively large, therefore, in order to ensure the reliability of data storage and improve the data storage efficiency, when locking any unoccupied and unlocked child in the bit layer, it is preferred to lock any unoccupied and unlocked child in the first-level bit layer or the second-level bit layer, and in order to ensure the orderliness of child locking and disk space query and allocation, the unoccupied and unlocked child in the bit layer can be specifically locked according to the arrangement order of the children in the bit layer.
[0050] Among them, the fact that the child is unoccupied means that there is an unoccupied minimum allocation unit among the multiple minimum allocation units of the disk finally corresponding to the child, that is, there is a free minimum allocation unit. Assuming that the value of the child is 0 represents that all the corresponding multiple minimum allocation units are occupied, then the value of the unoccupied child is 1 (the value of 1 means that all the corresponding multiple minimum allocation units may be unoccupied, or some may be unoccupied, and specific queries need to be made to obtain it); the fact that the child is unlocked means that the bitmap allocator is not currently querying the child for other copies of the data to be stored, that is, it indicates that the child can be used by the bitmap allocator to query the corresponding disk space for the currently obtained data to be stored, so as to achieve concurrent data storage, and there will be no data storage conflicts, thereby improving the data storage efficiency.
[0051] As can be seen from the above process, by locking the children in the bitmap allocator that are not occupied and not locked in the bitmap layer, it is possible to avoid querying disk space from the first child in the bitmap layer every time, and when processing the current data to be stored, it is not necessary to pay attention to whether there are other data to be stored being processed. Instead, the data can be directly stored, and when there is more data to be stored later, it is possible to directly query and process the unlocked children according to the locking status of the children in the bitmap layer, without having to wait for the current data to be stored to be completed before processing. This can both avoid data storage conflicts and achieve concurrent allocation of disk space and concurrent storage of data, thereby improving data storage efficiency.
[0052] S12: Query downward from the locked child to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk; if so, execute step S13, if not, execute step S14;
[0053] After executing step S11, the bitmap allocator can start querying downward from the locked child obtained in step S11. Among them, querying downward from the locked child specifically means querying the children corresponding to the locked child and the disk space corresponding to the children below, that is, querying the disk space corresponding to the locked child according to the relationship between the bitmap layers included in the bitmap allocator and the relationship between the bitmap layer and the disk.
[0054] By querying downward from the locked child to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child managed by the bitmap allocator. The continuous available space corresponding to the size of the data to be stored mentioned here specifically refers to a continuous available space that is greater than or equal to the size of the data to be stored, that is, the continuous available space mentioned here refers to a continuous available disk space that can store the data to be stored.
[0055] S13: Store the data to be stored in the continuous available space;
[0056] When executing step S12, if it is determined that there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk, the obtained data to be stored can be stored in the continuous available space corresponding to the size of the data to be stored to achieve continuous storage of data on the disk, thereby improving data read and write performance and facilitating the improvement of disk space management performance.
[0057] It should be noted that after storing the data to be stored in the continuously available space, in order to make the children available for other data to be stored, the locks of the locked children can be released.
[0058] S14: Release the locks of the locked children, lock any other unoccupied and unlocked children in the bitmap layer, and perform the step of querying downward from the locked children until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
[0059] When executing step S12, if it is determined that there is no continuously available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk, the bitmap allocator can release the locks of the locked children, that is, make the locked children obtained in step S11 become unlocked children again, so that if there is other data to be stored coming, the bitmap allocator can relock and query the children to determine whether other data to be stored can be stored in the corresponding disk space, that is, make the children available for other data to be stored, thereby improving the data storage efficiency.
[0060] Moreover, the bitmap allocator can also lock any other unoccupied and unlocked children in the bitmap layer. Specifically, it is similar to step S11, except that the specific children are different. Among them, any other unoccupied and unlocked children mentioned here can be specifically located behind the previously locked children, that is, the children can be locked in the order of the arrangement of the children in the bitmap layer.
[0061] After locking any other unoccupied and unlocked children, it is possible to return to step S12, that is, it is possible to perform a downward query starting from the locked children to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk, and related steps, until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed. Among them, the corresponding processing mentioned here can specifically be that after locking the last unoccupied and unlocked child in the bitmap layer to obtain the last locked child, a downward query is performed starting from the last locked child to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child in the disk. If there is, the data to be stored is stored in the continuous available space. If not, the lock of the last locked child is released. In addition, if there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child, a prompt can be given so that relevant personnel can obtain the prompt and take corresponding measures according to the prompt, etc.
[0062] Through the above process, it is possible to preferentially store the data to be stored in the continuous available space in the disk, so as to reduce disk fragmentation, enhance the continuity of data storage, and improve data reading and writing performance.
[0063] In the above technical solution disclosed in this application, when the bitmap allocator in BlueStore performs data storage, it locks the unoccupied and unlocked children in the bitmap layer, so that it is not necessary to query the disk space from the first child in the bitmap layer every time, and when processing the current data to be stored, it is not necessary to pay attention to whether there is other data to be stored being processed currently, but can directly perform the storage operation, and when there is more data to be stored after that, it can directly query and process from the unlocked children according to the locking situation of the children in the bitmap layer, without waiting for the current data to be stored to be completed before processing, so as to avoid data storage conflicts and achieve concurrent allocation of disk space and concurrent storage of data, thereby improving data storage efficiency. Moreover, when performing data storage, it queries downward from the locked children to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk. If there is, the data to be stored is stored in the continuous available space; if not, the lock of the locked children is released, so that when other data to be stored comes, it can lock, query, and utilize the corresponding disk space of the children, thereby improving data storage efficiency. After releasing the lock of the locked children, it locks the other unoccupied and unlocked children in the bitmap layer, and then executes the step of querying downward from the locked children until the last unoccupied and unlocked children in the bitmap layer are locked and corresponding processing is performed. By this method, when performing data storage, the data to be stored is preferentially stored in the continuous available space in the disk, so as to reduce disk fragmentation, enhance the continuity of data storage, and improve data reading and writing performance.
[0064] A data storage method provided by an embodiment of this application for locking any unoccupied and unlocked child in the bitmap layer may include:
[0065] Determine the bitmap layer to be locked from the first bitmap layer and the second bitmap layer according to the disk space size corresponding to a child in the first bitmap layer included in the bitmap allocator, the disk space size corresponding to a child in the second bitmap layer, and the size of the data to be stored; one child in the first bitmap layer corresponds to multiple children in the second bitmap layer;
[0066] Lock any unoccupied and unlocked child in the bitmap layer to be locked.
[0067] In this application, when locking any unoccupied child in the alignment layer, the bitmap allocator can determine the disk space size corresponding to a child in the first layer contained in the bitmap allocator and the disk space size corresponding to a child in the second layer. Among them, one child in the first layer corresponds to multiple children in the second layer, one child in the second layer corresponds to multiple children in the third layer, and one child in the third layer corresponds to multiple minimum allocation units in the disk. It can be seen that the disk space size corresponding to one child in the first layer is greater than the disk space size corresponding to one child in the second layer.
[0068] After determining the disk space size corresponding to a child in the first layer contained in the bitmap allocator and the disk space size corresponding to a child in the second layer, the disk space size corresponding to a child in the first layer and the disk space size corresponding to a child in the second layer can be compared with the size of the data to be stored. If the size of the data to be stored is less than the disk space size corresponding to a child in the second layer, the second layer can be determined as the layer to be locked, so as to meet the disk space requirement of the data to be stored and enable the bitmap allocator to concurrently allocate disk space for more copies of the data to be stored; if the size of the data to be stored is between the disk space size corresponding to a child in the first layer and the disk space size corresponding to a child in the second layer, the first layer can be determined as the layer to be locked to meet the disk space requirement of the data to be stored.
[0069] After determining the layer to be locked, any unoccupied child in the layer to be locked can be locked. It should be noted that when the second layer is determined as the layer to be locked, it is necessary to first determine the unoccupied children in the second layer according to the status of the children in the first layer, and then lock any unoccupied and unlocked child in the second layer.
[0070] A data storage method provided by an embodiment of this application for locking any unoccupied and unlocked child in the alignment layer may include:
[0071] Lock any unoccupied and unlocked child in the first layer contained in the bitmap allocator.
[0072] In this application, when locking any unoccupied and unlocked child in the alignment layer, specifically, any unoccupied and unlocked child in the first alignment layer included in the bitmap allocator can be directly locked to facilitate query efficiency and data storage efficiency.
[0073] A data storage method provided by an embodiment of this application may further include:
[0074] Obtain the available space obtained by the disk reclaiming useless data;
[0075] Judge whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk, which may include:
[0076] Judge whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk except for the available space obtained by reclaiming useless data;
[0077] When locking any other unoccupied and unlocked child in the alignment layer, it may further include:
[0078] If the last unoccupied and unlocked child in the alignment layer is locked, and it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child in the disk except for the available space obtained by reclaiming useless data, then start locking from the first unoccupied and unlocked child in the bit layer, and start querying from the locked child to judge whether there is continuous available space corresponding to the size of the data to be stored in the available space obtained by the disk reclaiming useless data and corresponding to the locked child.
[0079] In this application, considering that the disk may successively reclaim the space occupied by useless data, therefore, the bitmap allocator can also obtain the available space obtained by the disk reclaiming useless data. And considering that the available space obtained by the disk reclaiming useless data is generally random and may be relatively small, therefore, when the bitmap determines whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk, specifically, it can judge whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child except for the available space obtained by reclaiming useless data, that is, the continuous available space mentioned here can specifically be the continuously unused available space in the disk, so as to facilitate improving the disk space allocation efficiency and data storage efficiency.
[0080] If there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in addition to the available space obtained by recycling useless data, store the data to be stored in the corresponding continuous available space.
[0081] If there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in addition to the available space obtained by recycling useless data, release the lock of the locked children, lock any other unoccupied and unlocked children in the bitmap layer, and query downward from the locked children to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children... If the last unoccupied and unlocked child in the bitmap layer is locked and the query is made downward from the last locked child, and it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child in addition to the available space obtained by recycling useless data, it indicates that the continuously available space that has not been used in the disk is relatively small and cannot store the data to be stored. Considering that as time goes by, the available space obtained by the disk recycling useless data may be continuous and relatively large, in this case, the first unoccupied and unlocked child in the bitmap layer can be locked and the query can start from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the available space obtained by the disk recycling useless data corresponding to the locked child, that is, the available space obtained by the disk recycling useless data is used as the alternative storage space for the data to be stored for determination. If there is continuous available space corresponding to the size of the data to be stored in the available space obtained by the disk recycling useless data corresponding to the locked child, store the data to be stored in the continuous available space. If there is no continuous available space corresponding to the size of the data to be stored in the available space obtained by the disk recycling useless data corresponding to the locked child, release the lock of the locked child and lock the next unoccupied and unlocked child in the bitmap layer... until the last unoccupied and unlocked child in the bitmap layer is locked and the corresponding processing is completed.
[0082] Through the above process, when there is no continuously available space on the disk that has not been used all the time to meet the storage requirements of the data to be stored (that is, when there is no continuously available space on the disk that has not been used all the time that can be allocated to the data to be stored), the available space obtained by recycling useless data on the disk is then used, that is, the available space obtained by recycling useless data on the disk participates in the storage of the data to be stored. Doing so helps to ensure the continuity of the disk space to the greatest extent, and thus helps to ensure the continuity of the data.
[0083] A data storage method provided by an embodiment of the present application may further include:
[0084] When new data to be stored is obtained, any other unoccupied and unlocked children in the bitmap layer included in the bitmap allocator are locked, so as to determine the corresponding continuously available space according to the locked children corresponding to the new data to be stored, and store the new data to be stored in the corresponding continuously available space.
[0085] In the present application, during the process of storing the data to be stored obtained in step S11, if the bitmap allocator obtains new data to be stored, any other unoccupied and unlocked children in the bitmap layer can be locked, so as to determine the corresponding continuously available space according to the locked children corresponding to the new data to be stored, and store the new data to be stored in the corresponding continuously available space. That is, the query and other processing of the continuously available space can be performed in a manner similar to that of the data to be stored obtained in step S11, so as to realize the concurrent storage of different portions of the data to be stored, without waiting for the previous portion of the data to be stored to be completed before the next portion of the data to be stored can be stored, thereby improving the data storage efficiency.
[0086] For a data storage method provided by an embodiment of the present application, if it is determined that there is no continuously available space corresponding to the size of the data to be stored in the disk space corresponding to the last unoccupied and locked child in the bitmap layer, it may further include:
[0087] The data to be stored is divided according to the minimum allocation unit of the disk, and the divided data blocks are stored in the smallest idle allocation unit on the disk.
[0088] In this application, if it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last unoccupied and locked child in the location layer, that is, if it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to any unoccupied child in the location layer, then at this time, the data to be stored can be divided according to the minimum allocation unit of the disk to obtain multiple data blocks, and the divided data blocks are stored in the smallest available allocation unit in the disk.
[0089] Through the above process, the data to be stored is stored in the disk to meet the data storage requirements and avoid data loss.
[0090] A data storage method provided by an embodiment of this application, after storing the data to be stored in the continuous available space, may further include:
[0091] Output the storage information of the data to be stored.
[0092] In this application, after storing the data to be stored in the continuous available space, the storage information of the data to be stored may further be output. Herein, the storage information mentioned specifically may include the storage disk location, the occupied disk space size, etc., so that relevant personnel can obtain relevant information about data storage based on the storage information, thereby improving the data reading and writing performance.
[0093] An embodiment of this application further provides a data storage device, which is applied to the bitmap allocator in BlueStore. Refer to Figure 3 , which shows a schematic structural diagram of a data storage device provided by an embodiment of this application, and may include:
[0094] The first locking module 31 is used to lock any unoccupied and unlocked child in the location layer when obtaining the data to be stored;
[0095] The query module 32 is used to query downward from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk;
[0096] The storage module 33 is used to store the data to be stored in the continuous available space if there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk;
[0097] An execution module 34, configured to, if there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk, release the locks of the locked children, lock any other unoccupied and unlocked children in the bitmap layer, and perform the step of querying downward from the locked children until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
[0098] A data storage device provided by an embodiment of the present application, the first locking module 31 may include:
[0099] A determination unit, configured to determine a bitmap layer to be locked from the first bitmap layer and the second bitmap layer according to the disk space size corresponding to a child in the first bitmap layer included in the bitmap allocator, the disk space size corresponding to a child in the second bitmap layer, and the size of the data to be stored; one child in the first bitmap layer corresponds to multiple children in the second bitmap layer;
[0100] A first locking unit, configured to lock any unoccupied and unlocked child in the bitmap layer to be locked.
[0101] A data storage device provided by an embodiment of the present application, the first locking module 31 may include:
[0102] A second locking unit, configured to lock any unoccupied and unlocked child in the first bitmap layer included in the bitmap allocator.
[0103] A data storage device provided by an embodiment of the present application may further include:
[0104] An acquisition module, configured to acquire the available space obtained by the disk recovering useless data;
[0105] The query module 32 may include:
[0106] A judgment unit, configured to judge whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children except for the available space obtained by the disk recovering useless data;
[0107] It may further include:
[0108] A determination module, when locking any other unoccupied and unlocked child in the bit map layer, if locking the last unoccupied and unlocked child in the bit map layer and determining that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child except for the available space obtained by recycling useless data in the disk, starts locking from the first unoccupied and unlocked child in the bit map layer, and starts querying from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the available space obtained by recycling useless data in the disk and corresponding to the locked child.
[0109] A data storage device provided by an embodiment of the present application may further include:
[0110] A second locking module, when obtaining new data to be stored, locks any other unoccupied and unlocked child in the bit map layer included in the bitmap allocator, determines corresponding continuous available space according to the locked child corresponding to the new data to be stored, and stores the new data to be stored in the corresponding continuous available space.
[0111] A data storage device provided by an embodiment of the present application may further include:
[0112] A partitioning module, if it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last unoccupied and locked child in the bit map layer, partitions the data to be stored according to the minimum allocation unit of the disk, and stores the partitioned data blocks in the smallest idle allocation unit in the disk.
[0113] A data storage device provided by an embodiment of the present application may further include:
[0114] An output module, after storing the data to be stored in the continuous available space, outputs the storage information of the data to be stored.
[0115] An embodiment of the present application further provides a data storage device. Refer to Figure 4 , which shows a schematic structural diagram of a data storage device provided by an embodiment of the present application. It may include:
[0116] A memory 41, for storing a computer program;
[0117] A processor 42, when executing the computer program stored in the memory 41, may implement the following steps:
[0118] When the data to be stored is obtained, lock any unoccupied and unlocked children in the bit layer; query downward from the locked children to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk; if so, store the data to be stored in the continuous available space; if not, release the lock of the locked children, lock any other unoccupied and unlocked children in the bit layer, and execute the step of querying downward from the locked children until the last unoccupied and unlocked child in the bit layer is locked and corresponding processing is performed.
[0119] The embodiment of the present application also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps can be implemented:
[0120] When the data to be stored is obtained, lock any unoccupied and unlocked children in the bit layer; query downward from the locked children to determine whether there is a continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked children in the disk; if so, store the data to be stored in the continuous available space; if not, release the lock of the locked children, lock any other unoccupied and unlocked children in the bit layer, and execute the step of querying downward from the locked children until the last unoccupied and unlocked child in the bit layer is locked and corresponding processing is performed.
[0121] The readable storage medium may include: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0122] For the description of the relevant parts in a data storage device, device, and readable storage medium provided by the present application, reference can be made to the detailed description of the corresponding parts in a data storage method provided by the embodiment of the present application, which will not be elaborated here.
[0123] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that the elements inherent in a process, method, article or device comprising a series of elements. Without further limitation, an element defined by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the said element. In addition, the parts of the above technical solutions provided by the embodiments of the present application that are consistent with the corresponding technical solutions in the prior art are not described in detail to avoid unnecessary repetition.
[0124] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data storage method, characterized in that, The bitmap allocator applied to BlueStore includes: When the data to be stored is obtained, lock any unoccupied and unlocked child in the bitmap layer; Query downward from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk; If so, store the data to be stored in the continuous available space; If not, release the lock of the locked child, lock any other unoccupied and unlocked child in the bitmap layer, and execute the step of querying downward from the locked child until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
2. The data storage method according to claim 1, characterized in that Locking any unoccupied and unlocked child in the bitmap layer includes: Determine the bitmap layer to be locked from the first bitmap layer and the second bitmap layer according to the disk space size corresponding to a child in the first bitmap layer included in the bitmap allocator, the disk space size corresponding to a child in the second bitmap layer, and the size of the data to be stored; one child in the first bitmap layer corresponds to multiple children in the second bitmap layer; Lock any unoccupied and unlocked child in the bitmap layer to be locked.
3. The data storage method according to claim 1, wherein Locking any unoccupied and unlocked child in the bitmap layer includes: Lock any unoccupied and unlocked child in the first bitmap layer included in the bitmap allocator.
4. The data storage method according to claim 1, wherein It also includes: Obtain the available space obtained by recycling useless data from the disk; Determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk, including: Determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child except for the available space obtained by recycling useless data in the disk; When locking any other unoccupied and unlocked child in the bitmap layer, it also includes: If the last unoccupied and unlocked child in the bitmap layer is locked and it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last locked child except for the available space obtained by recycling useless data in the disk, then start locking from the first unoccupied and unlocked child in the bitmap layer, and start querying from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the available space obtained by recycling useless data in the disk corresponding to the locked child.
5. The data storage method according to claim 1, wherein It also includes: When new data to be stored is obtained, lock any other unoccupied and unlocked child in the bitmap layer included in the bitmap allocator, so as to determine corresponding continuous available space according to the locked child corresponding to the new data to be stored, and store the new data to be stored in the corresponding continuous available space.
6. The data storage method according to claim 1, characterized in that, If it is determined that there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the last unoccupied and locked child in the bitmap layer, it further includes: Divide the data to be stored according to the minimum allocation unit of the disk, and store the divided data blocks in the smallest idle allocation unit in the disk.
7. The data storage method according to claim 1, wherein After storing the data to be stored in the continuous available space, it further includes: Output the storage information of the data to be stored.
8. A data storage device, characterized in that, Applied to the bitmap allocator in BlueStore, it includes: The first locking module is used to lock any unoccupied and unlocked child in the bitmap layer when data to be stored is obtained; The query module is used to query downward from the locked child to determine whether there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk; The storage module is used to store the data to be stored in the continuous available space if there is continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk; The execution module is used to release the lock of the locked child and lock any other unoccupied and unlocked child in the bitmap layer if there is no continuous available space corresponding to the size of the data to be stored in the disk space corresponding to the locked child in the disk, and execute the step of querying downward from the locked child until the last unoccupied and unlocked child in the bitmap layer is locked and corresponding processing is performed.
9. A data storage device, characterized in that, It includes: A memory for storing computer programs; A processor for implementing the steps of the data storage method according to any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that, A computer program is stored in the readable storage medium, and when the computer program is executed by the processor, the steps of the data storage method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Wireless terminal database establishing method based on shared memory design
CN103678553A
Space allocation method of file system, and apparatuses
CN106406756A