Block storage method and related equipment

By comparing the storage configuration files of the blockchain system and updating metadata, building block data indexes solves the problem of low storage efficiency in the blockchain system, achieving horizontal expansion of storage space and efficient block data manage.

CN119106035APending Publication Date: 2024-12-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310673388.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-07
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

When existing blockchain systems store block data, the storage efficiency is low due to file system or disk storage space limitations, and when the storage space is full, the node cannot store new blocks, resulting in system stagnation.

Method used

By obtaining the comparison of the current and historical storage configuration files, update the metadata collection to identify new storage space, build block data index, determine the target file and storage space, and write block data in the target space to achieve storage space Scale outward.

Benefits of technology

Improve the efficiency of block storage, avoid the system stagnation after the storage space is full, and realize efficient management and storage expansion of block data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106035A_ABST
    Figure CN119106035A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a block storage method and device, electronic equipment and a computer readable storage medium. According to the embodiment of the invention, after the current storage configuration file is acquired and compared with the corresponding historical storage configuration file, when the comparison result indicates that the current node has the newly-added storage space, the metadata set is updated based on the space identifier of the newly-added storage space; identifying a block mapping relationship in the updated metadata set to obtain a block data index, when block data of a to-be-stored block is obtained, determining a target file and a target storage space corresponding to the target file based on the block data index and a current block identifier of the to-be-stored block, and storing the to-be-stored block in the target storage space. Writing the block data into the target file; according to the scheme, the block storage efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain, and in particular to a block storage method and related equipment. Background Art

[0002] In recent years, with the development of blockchain technology, the application of blockchain systems in the transaction field has become more and more extensive. In the blockchain system, each node can store the block data on the chain. The existing block data storage method often writes the block data directly to a file system (folder) corresponding to the current node.

[0003] In the process of research and practice of the prior art, the inventors of the present application found that when storing block data in a file system, the storage limit of the blockchain is subject to the size of the storage space of the file system (folder) or the disk corresponding to the file system. When the storage space is full, the chain stops working, making the current node unable to store new blocks, thus resulting in low efficiency of block storage. Summary of the invention

[0004] Embodiments of the present invention provide a block storage method, device, electronic device, and computer-readable storage medium, which can improve the efficiency of block storage.

[0005] A block storage method, comprising:

[0006] Obtaining a current stored configuration file, and comparing the current stored configuration file with a corresponding historical stored configuration file;

[0007] When the comparison result indicates that there is a newly added storage space in the current node, based on the space identifier of the newly added storage space, the metadata set is updated, and the metadata set indicates a file mapping relationship between the space identifier, the file identifier, and the block identifier information of the file;

[0008] Identifying a block mapping relationship in the updated metadata set to obtain a block data index, wherein the block mapping relationship includes mapping relationships between the block identifier in the block identifier information and the file identifier and the space identifier respectively;

[0009] When the block data of the block to be stored is obtained, based on the block data index and the current block identifier of the block to be stored, a target file and a target storage space corresponding to the target file are determined;

[0010] In the target storage space, the block data is written into the target file.

[0011] Accordingly, an embodiment of the present invention provides a block storage device, including:

[0012] An acquisition unit, used to acquire a current storage configuration file, and compare the current storage configuration file with a corresponding historical storage configuration file;

[0013] an updating unit, configured to update a metadata set based on a space identifier of the newly added storage space when the comparison result indicates that the current node has newly added storage space, wherein the metadata set indicates a file mapping relationship between the space identifier, the file identifier, and the block identifier information of the file;

[0014] an identification unit, configured to identify a block mapping relationship in the updated metadata set to obtain a block data index, wherein the block mapping relationship includes a mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively;

[0015] a determination unit, configured to determine a target file and a target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored when the block data of the block to be stored is obtained;

[0016] A writing unit is used to write the block data into the target file in the target storage space.

[0017] In some embodiments, the identification unit can be specifically used to identify the block identification interval of each file corresponding to the file identification in the block identification information; convert the file mapping relationship into the block mapping relationship corresponding to the block identification within the block identification interval; and construct the block data index corresponding to the current node based on the block mapping relationship.

[0018] In some embodiments, the identification unit can be specifically used to identify the initial file mapping relationship between the block identifier and the file identifier in the file block mapping relationship; identify the initial space mapping relationship between the block identifier and the space identifier in the space block mapping relationship; and merge the initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship to obtain the block mapping relationship.

[0019] In some embodiments, the identification unit can be specifically used to use the block identifier as a key value, and use the file identifier, space identifier and block identifier interval corresponding to the block identifier as leaf nodes; based on the block mapping relationship, the key value and the leaf node, a search tree is constructed, and the search tree is used as the block data index.

[0020] In some embodiments, the block storage device may further include a creation unit, which may be specifically used to obtain the remaining storage capacity of the target file and compare the remaining storage capacity with the storage capacity occupied by the block data; when the storage capacity exceeds the remaining storage capacity, create a candidate file and determine the file metadata corresponding to the candidate file; based on the file metadata, update the block data index and use the updated block data index as the block data index.

[0021] In some embodiments, the creation unit can be specifically used to query the historical file corresponding to the preset block identifier in the block data index; when the historical file exists, adjust the preset block identifier in the historical file to the current block identifier, and create the candidate file based on the current block identifier; when the historical file does not exist, create the candidate file based on the current block identifier.

[0022] In some embodiments, the creation unit can be specifically used to obtain storage space information of the current node, and based on the storage space information, determine the candidate space identifier corresponding to the candidate file; according to the current block identifier, set the starting block identifier and the ending block identifier corresponding to the candidate file; and use the candidate file identifier, the starting block identifier, the ending block identifier and the candidate space identifier as the file metadata.

[0023] In some embodiments, the creation unit can be specifically used to extract dictionary sorting information of the storage space set corresponding to the block data index from the storage space information; based on the dictionary sorting information, filter out the candidate storage space corresponding to the candidate file in the storage space set to obtain the candidate space identifier of the candidate storage space.

[0024] In some embodiments, the creation unit can be specifically used to extract the current remaining storage capacity of each storage space in the storage space set corresponding to the block data index from the storage space information; sort the storage space based on the current remaining storage capacity; and according to the sorting result, filter out the candidate storage space corresponding to the candidate file in the storage space set to obtain the candidate space identifier of the candidate storage space.

[0025] In some embodiments, the acquisition unit can be specifically used to query the historical space identifier in the corresponding historical storage configuration file in the current space identifier set of the current storage configuration file; when the historical space identifier is included in the current space identifier set, it is determined that the current storage configuration file is correctly configured, and the space identifier in the current space identifier set is compared with the historical space identifier; when there are space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is new storage space for the current node; when there are no space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is no new storage space for the current node.

[0026] In some embodiments, the acquisition unit can be specifically used to store the block to be stored based on the current block data index when the current node has a current block data index; when the current node does not have the block data index, build the block data index based on the metadata set, and store the block to be stored based on the block data index.

[0027] In addition, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the block storage method provided by the embodiment of the present invention.

[0028] In addition, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor to execute the steps in any one of the block storage methods provided in the embodiments of the present invention.

[0029] In addition, an embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in the data method provided in the embodiment of the present application.

[0030] In the embodiment of the present invention, after obtaining the current storage configuration file and comparing the current storage configuration file with the corresponding historical storage configuration file, when the comparison result indicates that there is a newly added storage space in the current node, the metadata set is updated based on the space identifier of the newly added storage space, and the block mapping relationship is identified in the updated metadata set to obtain the block data index. When the block data of the block to be stored is obtained, the target file and the target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored, and the block data is written into the target file in the target storage space. Since the scheme can manage the relationship between blocks, files and the storage space of files through the current storage configuration file, the metadata set and the block data index, the new storage space is supported in the storage configuration file, and then the file writing of different storage spaces is allocated through the metadata set and the block data index, so as to realize the horizontal expansion of the storage space, and therefore, the efficiency of block storage can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 is a schematic diagram of a scenario of a block storage method provided by an embodiment of the present invention;

[0033] Figure 2 is a flowchart of a block storage method provided by an embodiment of the present invention;

[0034] Figure 3 is a schematic diagram of different versions of storage configuration files provided by an embodiment of the present invention;

[0035] Figure 4 is a schematic diagram of the data structure of a metadata set provided by an embodiment of the present invention;

[0036] Figure 5 is a schematic diagram of blocks stored in a file provided by an embodiment of the present invention;

[0037] Figure 6 is a schematic diagram of files stored in a storage space provided by an embodiment of the present invention;

[0038] Figure 7 is a schematic diagram of a data structure of a block data index provided by an embodiment of the present invention;

[0039] Figure 8is a schematic diagram of sorting storage space according to a dictionary provided by an embodiment of the present invention;

[0040] Fig. 9 is a schematic diagram of screening candidate storage spaces after dictionary sorting provided by an embodiment of the present invention;

[0041] Fig.10 is a schematic diagram of screening candidate storage spaces based on the capacity of the storage space provided by an embodiment of the present invention;

[0042] Fig.11 is a schematic diagram of a process for creating a new candidate file provided by an embodiment of the present invention;

[0043] Fig.12 is a schematic diagram of the structure of a metadata system provided by an embodiment of the present invention;

[0044] Fig.13 It is a schematic diagram of a process of starting or restarting a metadata system provided by an embodiment of the present invention;

[0045] Fig.14 is another flowchart of the block storage method provided by an embodiment of the present invention;

[0046] Fig.15 is a schematic diagram of the structure of a block storage device provided by an embodiment of the present invention;

[0047] Fig.16 is another structural schematic diagram of a block device provided by an embodiment of the present invention;

[0048] Fig.17 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0050] The embodiment of the present invention provides a block storage method, device, electronic device and computer-readable storage medium. The block storage device can be integrated in an electronic device, which can be a server or a terminal.

[0051] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0052] For example, see Figure 1 Taking the block storage device integrated in an electronic device as an example, the electronic device can obtain a current storage configuration file and compare the current storage configuration file with the corresponding historical storage configuration file. When the comparison result indicates that there is a new storage space in the current node, the metadata set is updated based on the space identifier of the new storage space, and the block mapping relationship is identified in the updated metadata set to obtain a block data index. When the block data of the block to be stored is obtained, the target file and the target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored, and the block data is written into the target file in the target storage space, thereby improving the efficiency of block storage.

[0053] Among them, the block storage method of the present application is mainly used in the blockchain system, and can be applied to one or more nodes in the blockchain system. The so-called blockchain is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.

[0054] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operation management. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the correspondence between the user's real identity and the blockchain address (authority management), etc., and, under authorization, supervises and audits the transactions of certain real identities and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records valid requests to storage after consensus is reached. For a new business request, the basic service first adapts the interface for parsing and authentication (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management). The smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution and complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation management module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status check, node device health status check, etc.

[0055] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can superimpose business features based on these basic capabilities to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.

[0056] It can be understood that in the specific implementation of this application, related data such as blocks or block data are involved. When the following embodiments of this application are applied to specific products or technologies, permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0057] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.

[0058] This embodiment will be described from the perspective of a block storage device, which can be specifically integrated in an electronic device, which can be a server or a terminal. The terminal can include a tablet computer, a laptop computer, a personal computer (PC), a wearable device, a virtual reality device, or other smart devices that can store blocks.

[0059] A block storage method, comprising:

[0060] A current storage configuration file is obtained, and the current storage configuration file is compared with the corresponding historical storage configuration file. When the comparison result indicates that there is a newly added storage space in the current node, a metadata set is updated based on the space identifier of the newly added storage space. The metadata set indicates a file mapping relationship between the space identifier, the file identifier and the block identifier information of the file. The block mapping relationship is identified in the updated metadata set to obtain a block data index. The block mapping relationship includes a mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively. When the block data of the block to be stored is obtained, a target file and a target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored. The block data is written into the target file in the target storage space.

[0061] like Figure 2 As shown, the specific process of the block storage method is as follows:

[0062] 101. Obtain a current storage configuration file, and compare the current storage configuration file with a corresponding historical storage configuration file.

[0063] Among them, the current storage configuration file can be the latest storage configuration file in the current node. The so-called storage configuration file can be understood as a configuration file for configuring the storage space in the current node. The so-called storage space can be understood as a space or area in a file system, folder or disk for storing block data or other data, or it can also be understood as a space for storing data in a file system, folder or disk. The so-called file system can be a mechanism for providing users with underlying data access. It divides the space in the device into blocks of a specific size (or clusters), generally 512 bytes per block. The data is stored in these blocks, and the size is corrected to occupy an integer number of blocks. The file system software is responsible for organizing these blocks into files and directories, and recording which blocks are allocated to which file, and which blocks are not used. The storage configuration file may include a set of space identifiers and file version numbers of the configured storage space. The space identifier set may include the space identifiers of all configured storage spaces, for example, it may include the following content:

[0064]

[0065] There are many ways to obtain the current storage configuration file, which can be as follows:

[0066] For example, when a storage configuration file uploaded by a terminal is received, the uploaded storage configuration file can be directly used as the current storage configuration file, or the storage configuration file with the most recent modification time can be queried in the preset storage area, and the queried storage configuration file can be used as the current storage configuration file, or, when the storage capacity of the storage space of the current node is less than the preset storage capacity threshold, a space warning information can be sent to the terminal corresponding to the current node, and the storage configuration file returned by the receiving terminal based on the space warning information can be used as the current storage configuration file, and so on.

[0067] After obtaining the current storage configuration file, the current storage configuration file can be compared with the corresponding historical storage configuration file. There are many ways to compare. For example, the historical space identifier in the historical storage configuration file can be queried in the current space identifier set of the current storage configuration file. When the current space identifier set contains the historical space identifier, it is determined that the current storage configuration file is configured correctly, and the space identifier in the current identifier set is compared with the historical space identifier. When there are space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is new storage space in the current node. When there are no space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is no new storage space in the current node.

[0068] Among them, there are many ways to query the historical space identifier in the historical storage configuration file in the current space identifier set of the current storage configuration file. For example, the current storage space identifier set and the current version number can be extracted from the current storage configuration file, and the historical storage configuration file set of the current node can be obtained. Based on the current version number, the historical storage configuration file corresponding to the current storage configuration file is filtered out in the historical storage configuration file set, the space identifier in the space identifier set in the historical storage configuration file is obtained, the historical space identifier is obtained, and the historical space identifier is queried in the current space identifier set.

[0069] When the current space identifier set includes the historical space identifier, it is determined that the current storage configuration file is correctly configured. The so-called correct configuration means that the current storage configuration file does not delete or modify the storage space in the current node in the configuration, thereby ensuring the data security of the historical block data stored in the current node. Conversely, when the current space identifier set does not include the historical space identifier, it means that the current storage configuration file has deleted or modified the storage space of the current node in the configuration. In this case, the process will be stopped, thereby preventing the storage space of the current node from being configured according to the current storage configuration file.

[0070] When it is determined that the current storage configuration file is correctly configured, the space identifiers in the current identifier set can be compared with the historical space identifiers. When there are space identifiers other than the historical space identifiers in the current space identifier set, it is determined that there is a new storage space in the current node. For example, taking the current space identifier set including disk1, disk2, disk3, and disk4, and the historical space identifiers including disk1, disk2, and disk3 as an example, at this time, there is disk4 in the current space identifier set that does not exist in the historical space identifiers. Therefore, it can be determined that there is a new storage space disk4 in the current node. When there is no space identifier other than the historical space identifier in the current space identifier set, it can be indicated that the space identifier in the current space identifier set is the same as the historical space identifier. At this time, it is determined that there is no new storage space on the current node. For example, taking the current space identifier set including disk1, disk2 and disk3, and the historical space identifiers including disk1, disk2 and disk3 as an example, at this time, it can be found that the space identifier in the current space identifier set is the same as the historical space identifier, and it can be determined that there is no new storage space on the current node.

[0071] Among them, it should be noted that after the current node increases the storage space, the storage space information of the current node can be updated. In addition, in order to detect whether new storage space is added in the storage configuration file each time it is configured, it is necessary to retain the historical version information. Therefore, each version of the storage configuration file obtained can also be stored, that is, each time the storage configuration file is modified (for example, the number of new storage space or file systems, etc.), the new storage configuration file (current storage configuration file) needs to be persistently stored or saved. For example, taking the example of the current storage configuration file adding storage space of disk4 relative to the historical storage configuration file, these two versions of the storage configuration files need to be stored, which can be done as follows. Figure 3 It should also be noted that if no additional storage space is added to the current storage configuration file relative to the historical storage configuration file, the current storage configuration file may be stored or not.

[0072] In some embodiments, when it is determined that there is newly added storage space in the current node, the metadata set can be updated based on the space identifier of the newly added storage space, as described below for details.

[0073] 102. When the comparison result indicates that there is a newly added storage space, the metadata set is updated based on the space identifier of the newly added storage space.

[0074] Among them, the metadata set may include various types of metadata such as stored blocks, files or storage spaces. The metadata set indicates the file mapping relationship between the space identifier, the file identifier and the block identifier information of the file. The so-called metadata may include the block identifier of the block, the file identifier of the file, the block identifier information or the space identifier of the storage space, etc. The block identifier may include the block height (block height) of the block. The block identifier information of the file may include the start block height (startHeight) and the end block height (endHeight) of the block stored in the file. The start block height may be the block height of the first block contained or stored in the file, and the end block height may be the block height of the last block contained or stored in the file. When the file is being written, if it is the last block written to the file, the end block height of the file may be the preset maxUint64 or other preset block identifier. Therefore, if the end block height of a file is maxUint64 or other preset block identifier, it can be indicated that the file has not been completely filled.

[0075] When the comparison result indicates that there is a new storage space in the current node, there are multiple ways to update the metadata set based on the space identifier of the new storage space, which can be as follows:

[0076] For example, when the comparison result indicates that there is a new storage space in the current node, the space identifier of the new storage space can be obtained, and the space identifier can be added to the metadata set as metadata to obtain an updated metadata set.

[0077] Among them, the metadata in the metadata collection needs to be persisted. After the server or process is restarted, the metadata information can be read from the persistent data and the block data index (memory index) can be regenerated in the memory. Therefore, leveldb can be used to save the data for the persistent storage of the metadata collection. The metadata collection can be regarded as a Db (DoggaByte) data. The so-called Db data can be a key / value structured data, with the file identifier (file name filename) as the key and the value as the serialized data of the file's metadata information (FileMeta). FileMeta can include the file name (filename), the start block height (startHeight) in the file, the end block height (endHeight) in the file, and the space identifier of the storage space corresponding to the file (the identifier of the file system / folder / disk / hard disk), which can be as follows Figure 4As shown. When there is a new storage space, the space identifier of the new storage space can be added to the metadata collection. At this time, the new storage space is not assigned a corresponding file. Therefore, in the updated metadata collection, the key corresponding to the space identifier is empty, and the value does not contain a file identifier, a start block height, and an end block height. For this type of key / value data, it means that the storage space corresponding to the space identifier has not yet been assigned a file and written block data. When it is necessary to store block storage data in the new storage space, it can trigger the creation of a file in the new storage space. After the file is created, you can choose to write the block data of the block to be stored in the created file. The specific creation of files and writing of block data can be described in detail below.

[0078] 103. Identify the block mapping relationship in the updated metadata set to obtain the block data index.

[0079] Among them, the block mapping relationship includes the mapping relationship between the block identifier in the block identification information and the file identifier and space identifier respectively. For example, it can include the mapping relationship between block A and file A storing block A, and it can also include the mapping relationship between block A and storage space A corresponding to file A, and file A is in storage space A. Therefore, it can be found that for the storage of blocks, the blocks can be serialized into byte streams first, and then the byte streams are written into the file to complete the storage of the blocks, so that many blocks are stored in one file. This file is saved in (belongs to) a storage space (file system / folder / disk / hard disk). For example, you can refer to Figure 5 , 4 blocks (block1, block2, block3 and block4) can be stored in the file (wal.bfdb.001). For another example, a storage space A can store multiple files such as (wal.bfdb.001), (wal.bfdb.002), (wal.bfdb.003) and (wal.bfdb.004). Figure 6 As shown in the figure. Wal (Write Ahead Log) is a pre-write log, which is a common method in database systems to ensure the atomicity and persistence of data operations.

[0080] The block data index may be an index containing block mapping relationships. The block data index may be used to retrieve metadata information such as file identifiers and space identifiers corresponding to each block identifier, and is used for high-performance search of file metadata information.

[0081] There are multiple ways to identify the block mapping relationship in the updated metadata set to obtain the block data index, which can be specifically as follows:

[0082] For example, the block identification interval of each file corresponding to the file identification can be identified in the block identification information, the file mapping relationship is converted into a block mapping relationship corresponding to the block identification, and the block data index corresponding to the current node is constructed according to the block mapping relationship.

[0083] Among them, the block identifier interval can be the interval between the block identifier of the start block and the block identifier of the end block in each file. There are many ways to identify the block identifier interval, for example, obtain the block identifier information of the file corresponding to each file identifier, extract the start block height and the end block height from the block identifier information, when the end block height is not the preset block identifier (maxUint64 or other preset end block height identifier), it indicates that the file is full of block data, that is, no new block data can be written, and the block identifier interval at this time can be the interval between the start block height and the end block height. For example, taking the start block height as 3 and the end block height as 5, the block identifier at this time is The identification interval is block 3-block 5; when the end block height is the preset block identifier (maxUint64 or other preset end block height identifier), it means that the file is not full of block data, and new block data can continue to be written. The block height of the last written historical block is obtained, and the start block height and the block height of the historical block are used as the block identification interval. For example, the start block height is 3, the end block height is maxUint64, and the block height of the last written block is 6. At this time, the block identification interval can be block 3-block 6, and so on.

[0084] After the block identification interval is identified, the file mapping relationship can be converted into a block mapping relationship corresponding to the block identification in the block identification interval. The file mapping relationship may include a file space mapping relationship, a file block mapping relationship, and a space block mapping relationship. The so-called file space mapping relationship may include a mapping relationship between a file identifier and a space identifier, a file block mapping relationship may include a mapping relationship between a file identifier and the block identification information of a file, and a space block mapping relationship may include a mapping relationship between a space identifier and the block identification information of a file. There may be multiple ways to convert the file mapping relationship into a block mapping relationship corresponding to the block identifier in the block identification interval, for example, an initial file mapping relationship between a block identifier and a file identifier may be identified in the file block mapping relationship, an initial space mapping relationship between a block identifier and a space identifier may be identified in the space block mapping relationship, and the initial file mapping relationship, the initial space mapping relationship, and the file space mapping relationship may be merged to obtain a block mapping relationship.

[0085] There are many ways to identify the initial file mapping relationship between the block identifier and the file identifier in the file-block mapping relationship. For example, based on the file-block mapping relationship, determine the candidate file identifier corresponding to the block identifier interval, use the candidate file identifier as the file identifier corresponding to the block identifier in the block identifier interval, thereby obtaining the target file identifier corresponding to each block identifier, and determine the initial file mapping relationship based on the block identifier and the target file identifier corresponding to the block identifier. For example, taking the block identifier interval as block 3-block 5, and the corresponding candidate file identifier as file A, the file corresponding to block 3 is file A, the file corresponding to block 4 is file A, and the file corresponding to block 5 is file A, thereby obtaining the initial file mapping relationship between the block identifier and the file identifier of each block.

[0086] Among them, the method of identifying the initial spatial mapping relationship between the block identifier and the spatial identifier in the spatial block mapping relationship is similar to the method of identifying the initial file mapping relationship, as described above, and will not be repeated here.

[0087] After the initial file mapping relationship and the initial space mapping relationship are identified, the initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship can be merged into the block mapping relationship. There are many ways to merge the initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship. For example, the initial file mapping relationship and the initial space mapping relationship can be associated to obtain the space identifier corresponding to each block identifier and the file identifier corresponding to the block identifier. Based on the file space mapping relationship, the space identifier is associated with the file identifier to obtain the file metadata corresponding to each block identifier (file identifier and corresponding space identifier), and the block mapping relationship is constructed based on the block identifier and the corresponding file metadata.

[0088] After the initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship are merged, the obtained block mapping relationship can be merged to construct the block data index corresponding to the current node. There are many ways to construct the block data index. For example, the block identifier can be used as the key value, and the file identifier, space identifier and block identifier interval corresponding to the block identifier can be used as leaf nodes. Based on the block mapping relationship, key value and leaf node, a search tree is constructed, and the search tree is used as the block data index.

[0089] The search tree can be understood as a tree data that contains key and leaf nodes and satisfies the block mapping relationship. There can be many types of search trees, for example, B-tree (self-balancing tree), binary sorted tree, balanced tree, red-black tree or other types of tree data, etc. For example, taking the search tree as B-tree as an example, assuming that a file stores 1000MB of data, then 1PB of total data requires 1000000 (one million files), and from one million file objects, the file metadata information is searched according to the block height. The corresponding block data index data structure can be as follows: Figure 7 As shown, it supports 1PB of data, and the time complexity of reading is O(m), where m is generally less than 10.

[0090] 104. When the block data of the block to be stored is obtained, a target file and a target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored.

[0091] For example, when obtaining block data of a block to be stored, the current block identifier of the block to be stored can be obtained, and the current file identifier and the current space identifier corresponding to the current block identifier can be queried in the block data index. Based on the query result and the block data index, the target file corresponding to the block to be stored and the target storage space corresponding to the target file can be determined.

[0092] There are many ways to obtain the block data of the block to be stored. For example, you can directly receive the block to be stored distributed by the blockchain system, serialize the block to be stored, obtain the byte stream of the block to be stored, and use the byte stream as the block data of the block to be stored, or directly receive the block data of the area to be stored uploaded or sent by the terminal, and so on.

[0093] Serialization may refer to the process of converting a data structure or object state into an accessible format (such as saving it into a file, storing it in a buffer, or sending it over a network) so that the original state can be restored later in the same or another computer environment.

[0094] Among them, there can be multiple ways to determine the target file corresponding to the block to be stored and the target storage space corresponding to the target file based on the query results and the block data index. For example, when there is a current file identifier and a current space identifier, the file corresponding to the current file identifier is used as the target file, and the storage space corresponding to the current space identifier is used as the target storage space corresponding to the target file. Or, when there is no current file identifier and a current space identifier, it is also possible to obtain the current block identifier of the block to be stored, determine the last written target historical block based on the current block identifier, retrieve the candidate file written by the target historical block in the block data index, and determine the end block identifier of the candidate file. When the end block identifier is a preset block identifier, the candidate file is used as the target file, and the current space identifier corresponding to the file identifier of the target file is screened out in the block data index, and the storage space corresponding to the current space identifier is used as the target storage space corresponding to the target file.

[0095] Among them, when the current file identifier and the current space identifier do not exist, after determining the target file and the target storage space, the block data index can be updated based on the current block identifier, the file identifier of the target file and the space identifier of the target storage space to obtain an updated block data index, and the updated block data index can be used as the block data index.

[0096] Optionally, in some embodiments, after determining the target file and the target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored, the remaining storage space of the target file can also be detected, and the creation of a new file can be triggered. There are many ways to create a new file. For example, the remaining storage capacity of the target file can be obtained, and the remaining capacity can be compared with the storage capacity occupied by the block data. When the storage capacity exceeds the remaining storage capacity, a candidate file is created, and the file metadata corresponding to the candidate file is determined. Based on the file metadata, the block data index is updated, and the updated block data index is used as the block data index.

[0097] Among them, when the storage capacity exceeds the remaining storage capacity, it means that the target node is full after writing the block data and cannot write new block data. At this time, in order to store the block data of the next block, it is necessary to add or create a candidate file (new file). There are many ways to create a candidate file. For example, you can query the historical file corresponding to the preset block identifier in the block data index. When the historical file exists, adjust the preset block identifier in the historical file to the current block identifier, and create a candidate file based on the current block identifier. When the historical file does not exist, create a candidate file based on the current block identifier.

[0098] Among them, the historical file can be understood as the file in which the block data is written in the last block before the candidate file. The preset block identifier can be a preset end block height used to characterize that the file has not been completely filled, for example, it can be maxUint64 or other preset block identifiers. Since a new candidate file needs to be created, it means that the historical file is already full. For the file that is already full, the end block height should be the block height of the last written block, rather than the preset block identifier. Therefore, when there is a historical file, the preset block identifier in the historical file can be adjusted to the current block identifier, and then, based on the current block identifier, a candidate file is created. It should be noted that when there is a historical file, it means that there is an error or anomaly in the end block height in the historical file. There can be many reasons for this error or anomaly, for example, it can include a server or process crash or a fault (bug).

[0099] In some embodiments, when there is no historical file, it means that there is no error or abnormality in the end block height of the previous file of the candidate file. At this time, the candidate file can be created based on the current block identifier.

[0100] Among them, there are many ways to create candidate files based on the current block identifier. For example, you can create a new file, and based on the current block identifier, determine the candidate file identifier corresponding to the new file to obtain the candidate file, or you can also determine the candidate file identifier of the candidate file based on the current block identifier, create a new file, and obtain the candidate file.

[0101] There are many ways to determine the candidate file identifier based on the current block identifier. For example, the next block identifier of the current block identifier can be used as the candidate block identifier, and the candidate file identifier can be generated based on the candidate block identifier and the file identifier template. For example, if the current block identifier is block 3, the next block identifier can be block 4.

[0102] After creating the candidate file, the file metadata corresponding to the candidate file can be determined. The file metadata may include a file identifier, a start block identifier (start block height) within the candidate file, an end block identifier (end block height), a space identifier of the storage space corresponding to the candidate file, and so on. There are many ways to determine the file metadata of a candidate file, such as obtaining the storage space information of the current node, and based on the storage space information, determining the candidate space identifier corresponding to the candidate file, setting the start block identifier and end block identifier corresponding to the candidate file according to the current block identifier, and using the candidate file identifier, start block identifier, end block identifier, and candidate space identifier as file metadata, which may be as follows:

[0103] (1) Obtain storage space information of the current node, and determine a candidate space identifier corresponding to the candidate file based on the storage space information.

[0104] The storage space information may be information related to the storage space of the current node, for example, it may include a set of space identifiers of all storage spaces of the current node, the storage capacity of each storage space, the remaining capacity, or sorting information of each storage space, and so on.

[0105] There are many ways to obtain the storage space information of the current node, which can be as follows:

[0106] For example, the node attribute information of the current node may be obtained, and the storage space information may be extracted from the node attribute information, or the attribute information corresponding to the storage space of the current node may be obtained, and the storage space information may be extracted from the attribute information, and so on.

[0107] After obtaining the storage space information of the current node, the candidate space identifier corresponding to the candidate file can be determined based on the storage space information. There are many ways to determine the candidate space identifier corresponding to the candidate file based on the storage space information. For example, the dictionary sorting information of the storage space set corresponding to the block data index can be extracted from the storage space information, and the candidate storage space corresponding to the candidate file can be screened out from the storage space set based on the dictionary sorting information to obtain the candidate space identifier of the candidate storage space; or, the current remaining storage capacity of each storage space in the storage space set corresponding to the block data index can be extracted from the storage space information, and the storage space can be sorted based on the current remaining storage capacity. According to the sorting result, the candidate storage space corresponding to the candidate file can be screened out from the storage space to obtain the candidate storage space identifier of the candidate storage space.

[0108] The dictionary sorting information can be understood as information for sorting the space identifiers of the storage spaces in the storage space set based on the dictionary order. For example, if the space identifiers of the storage space set configured in the storage configuration file are disk3 / disk1 / disk2, the sorting can be performed in the dictionary order to obtain the sorting result of disk1 / disk2 / disk3. Then, the storage space identifier in the storage configuration file is modified to OnlineFs: / disk1, / disk2, / disk3 to obtain the dictionary sorting information. The specific information can be as follows: Figure 8 shown.

[0109] After extracting the dictionary sorting information, the candidate storage space corresponding to the candidate file can be screened out in the storage space set based on the dictionary sorting information. There are many ways to screen the candidate storage space, for example, extracting the remaining storage capacity of the historical storage space where the previous file of the candidate file was stored from the storage space information, when the remaining storage capacity of the historical storage space is less than the preset capacity threshold, the next storage space of the historical storage space can be used as the candidate storage space based on the dictionary sorting information, thereby obtaining the candidate space identification of the candidate storage space; when the remaining storage capacity of the historical storage space is greater than the preset capacity threshold, the historical storage space can be used as the candidate storage space, thereby obtaining the candidate space identification of the candidate storage space. For example, if the storage space of the current node includes / disk1, / disk2 and / disk3, and the historical storage space is / disk1, when the remaining storage capacity in / disk1 is less than the preset capacity threshold, it can be switched to the next storage space of / disk1 (i.e. / disk2) based on the dictionary sorting information, and / disk2 is used as the candidate storage space corresponding to the candidate file. When / disk2 is full, it can also be switched to the next storage space of / disk2 (i.e. / disk3), and so on. Specifically, it can be as follows Fig. 9 As shown; when the remaining storage capacity in / disk1 is greater than the preset capacity threshold, it means that files can still be stored in / disk1 at this time. At this time, / disk1 can continue to be used as the candidate space identifier of the candidate storage space corresponding to the candidate file.

[0110] Among them, it should be noted that, since this solution supports the addition of new storage space, the storage space of the current node has the function of horizontal expansion, thereby increasing the overall capacity limit of the storage space, which can greatly increase the storage flexibility of the block data of the current node, and will not cause the blockchain to stop working due to the storage space being full. Therefore, the storage efficiency of block storage can be greatly improved.

[0111] Among them, the current remaining storage capacity can be the remaining capacity of the storage space corresponding to when the candidate file is created. The storage space is sorted based on the current remaining storage capacity to obtain the sorting results of each storage space. Then, based on the sorting results, the candidate storage space corresponding to the candidate file is screened out in the storage space set to obtain the candidate space identifier of the candidate storage space. There are many ways to screen out the candidate storage space. For example, based on the sorting results, the storage space with the largest current remaining storage capacity can be screened out in the storage space set to obtain the candidate storage space, and the candidate space identifier of the candidate storage space can be determined. Alternatively, the storage space with the smallest current remaining storage capacity can be screened out in the storage space set to obtain the candidate storage space, and the candidate space identifier of the candidate storage space can be determined, and so on.

[0112] For example, if the storage space set includes / disk1, / disk2 and / disk3, and the current remaining storage capacity of / disk2 is the largest and the current remaining capacity of / disk1 is the smallest, when the candidate storage space is the storage space with the largest current remaining storage capacity, the storage space with the largest current remaining storage capacity can be selected from the storage space set (Next_FileSystem=Max(freeDisk1, freeDisk2, freeDisk3)), so that / disk2 is used as the candidate space identifier of the candidate storage space. Specifically, Fig.10 As shown; when the candidate storage space is the storage space with the smallest current remaining capacity, the storage space with the smallest current remaining storage capacity can be screened out from the storage space set, so that / disk1 is used as the candidate space identifier of the candidate storage space.

[0113] (2) According to the current block identifier, set the starting block identifier and the ending block identifier corresponding to the candidate file.

[0114] The starting block identifier can be the block identifier of the first block to be stored, or can be understood as the block identifier of the first block to be stored in the candidate file. The block identifier here can be the block height (block height). The ending block identifier can be the block identifier of the last block to be stored. When the candidate file is not full of block data, the ending block can be a preset block identifier, for example, maxUint64 or other preset block identifiers, etc.

[0115] There are multiple ways to set the start block identifier and the end block identifier corresponding to the candidate file according to the current block identifier, which can be as follows:

[0116] For example, the next block identifier of the current block identifier may be used as the starting block identifier of the candidate file, and the preset block identifier may be used as the ending block identifier of the candidate file.

[0117] Among them, taking the current block identifier as block 3 and the preset block identifier as maxUint64 as an example, the starting block identifier corresponding to the candidate file may be block 4, and the ending block identifier corresponding to the candidate file may be maxUint64.

[0118] (3) The candidate file identifier, the start block identifier, the end block identifier and the candidate space identifier are used as file metadata.

[0119] For example, the start block identifier and the end block identifier may be used as block identifier information of the candidate file, and the block identifier information, the file identifier and the candidate space identifier may be used as file metadata corresponding to the candidate file.

[0120] After determining the file metadata corresponding to the candidate file, the block data index can be updated based on the file metadata. There are many ways to update. For example, the file identifier of the candidate file can be used as the key, and the candidate space identifier and block identifier information can be used as the value, so that the file identifier, candidate space identifier and block identifier information are persistently written into the metadata set to obtain the target metadata set. The current block mapping relationship is identified in the target metadata set, and based on the current block mapping relationship, the block data index is updated, and the updated block data index is used as the block data index.

[0121] After the block data index is updated and the updated block data index is used as the block data index, when the block data of the block to be stored is obtained, the process can return to the step of determining the target file and the target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored, thereby achieving that the block data of all the blocks to be stored can be written into the file in the storage space based on the block data index, thereby improving the efficiency of block storage.

[0122] The newly created candidate file is mainly used to meet the writing of the block data of the next block of the block to be stored when the target file corresponding to the block data of the block to be stored is full. As for the time of creating a new candidate file, a new candidate file can be created not only after the target file corresponding to the block to be stored is determined, but also after the block data of the block to be stored is written to the target file. The overall process of creating a new candidate file can be as follows: Fig.11 As shown, after creation, you can first detect whether there is a previous file (i.e., the target file) whose end block identifier is the preset block identifier (maxUint64). When a previous file exists, you can find the target file and modify the end block height (endHeight) of the target file to the block height of the current latest block (i.e., the current block identifier). Then, create a new file and specify the file name (file identifier). When a previous file does not exist, you can directly create a new file and specify the file name. After creating a new file, get the space identifier of the storage space corresponding to the new file, then set the starting block height (startHeight) and end block height (endHeight) of the new file, then persist and write it to the metadata collection, and finally update the block data index (memory index).

[0123] 105. In the target storage space, write the block data into the target file.

[0124] For example, the target file can be stored in the target storage space, and then, in the target storage space, the block data can be written to the target file, thereby completing the block storage of the block to be stored; or, the block data can be written to the target file, and the target file with the written block data can be stored in the target storage space, thereby completing the block storage of the block to be stored, and so on.

[0125] Optionally, in some embodiments, after there is no newly added storage space at the current node, the current block data index can also be queried at the current node. When the current block data index exists at the current node, the block to be stored is stored based on the current block data index. When the current block data index does not exist at the current node, a block data index is constructed based on the metadata set, and the block to be stored is stored based on the current block data index.

[0126] Among them, the current block data index can be stored in the cache. When the process is started or restarted, the current block data index may not exist in the current node. When the current block data index does not exist, it is necessary to build the current block data index based on the metadata set. The method of building the current block data index is similar to the method of building the block data index. See the above description for details, and will not be repeated here.

[0127] When the current block data index exists or the current block data index is constructed based on the metadata set, after obtaining the block data of the block to be stored, the target file and the target storage space corresponding to the target file can be determined based on the current block data index and the current block of the block to be stored, and the block data can be written into the target file in the target storage space. For details, please refer to the above description, which will not be repeated here.

[0128] Among them, for block storage, this solution can realize block storage and horizontal expansion of storage space during block storage through the metadata system. The metadata system can include storage configuration files, block data indexes and metadata collections (Db), which can be specifically as follows: Fig.12As shown. The storage configuration file may include the space identifier and version number of the configured storage space. The block data index may be an index of a B-tree structure, with the block height as the key and fileMeta as the value. According to the block height, the file identifier and the space identifier of the storage space corresponding to the block height can be queried. The metadata set is also a key / value structure data, with the file identifier as the key and the serialized data of fileMeta as the value. The metadata set can be used for persistent metadata. When the metadata system / process is started or restarted, the metadata information can be directly read from the metadata set, and the block data index can be constructed based on the read metadata information. When the block data of the block to be stored is obtained, the block data can be stored based on the block data index.

[0129] When the metadata system is started or restarted, it can also read the current storage configuration file, check for errors and update it, then read the metadata information in the metadata collection, and build a block data index based on the read metadata information. Specifically, Fig.13 In addition, the metadata system can be deployed in one or more nodes in the blockchain system to implement block storage for one or more nodes.

[0130] Among them, in this solution, by adding a storage configuration file of the storage space, the metadata set can be updated, and the block data index can be built or updated. In addition, a new file can be created in the storage space, and the new file can be switched to the corresponding storage space, and the block identification information of the new file can be set, and this information can be persisted to the metadata set, and based on the metadata set, the block data index can be built or updated, so that the storage space has the ability to expand horizontally. When a single storage space (file system / folder / disk / hard disk) is not enough, a new storage space can be added, and the storage space can be switched intelligently, thereby increasing the upper limit of the overall capacity of the storage space. Especially in the case of cloud deployment, it is more convenient and simpler to use, and the performance is the same as using a single storage space, so the efficiency of block storage can be improved.

[0131] As can be seen from the above, after obtaining the current storage configuration file and comparing the current storage configuration file with the corresponding historical storage configuration file, when the comparison result indicates that there is a newly added storage space in the current node, the metadata set is updated based on the space identifier of the newly added storage space, and the block mapping relationship is identified in the updated metadata set to obtain the block data index. When the block data of the block to be stored is obtained, the target file and the target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored, and the block data is written to the target file in the target storage space; because the scheme can manage the relationship between blocks, files and storage spaces of files through the current storage configuration file, the metadata set and the block data index, the new storage space is supported in the storage configuration file, and then the file writing of different storage spaces is allocated through the metadata set and the block data index, thereby realizing the horizontal expansion of the storage space, and therefore, the efficiency of block storage can be improved.

[0132] According to the method described in the above embodiment, the following is further described in detail with examples.

[0133] In this embodiment, the block storage device is specifically integrated in an electronic device, the electronic device is a server, the block identifier is a block height (block height), the preset block identifier is maxUint64, and the storage space is a file system.

[0134] like Fig.14 As shown in FIG. 1 , a block storage method is shown, and the specific process is as follows:

[0135] 201. The server obtains a current storage configuration file.

[0136] For example, when the server receives a storage configuration file uploaded by a terminal, it can directly use the uploaded storage configuration file as the current storage configuration file, or it can query the storage configuration file with the most recent modification time in the preset storage area, and use the queried storage configuration file as the current storage configuration file, or it can send storage warning information to the terminal corresponding to the current node when the storage capacity of the file system of the current node is less than the preset storage capacity threshold, receive the storage configuration file returned by the terminal based on the space warning information, and use the returned storage configuration file as the current storage configuration file, and so on.

[0137] 202. The server compares the current storage configuration file with the corresponding historical storage configuration file.

[0138] For example, the server extracts the current file system identifier set and the current version number from the current storage configuration file, obtains the historical storage configuration file set of the current node, and based on the current version number, filters out the historical storage configuration file corresponding to the current storage configuration file from the historical storage configuration file set, obtains the space identifier in the space identifier set in the historical storage configuration file, obtains the historical space identifier, and queries the historical space identifier in the current space identifier set.

[0139] When the current space identifier set includes the historical space identifier, the server determines that the current storage configuration file is configured correctly, and compares the space identifier in the current identifier set with the historical space identifier. When there are space identifiers other than the historical space identifier in the current space identifier set, it determines that there is a new file system on the current node. When there are no space identifiers other than the historical space identifier in the current space identifier set, it determines that there is no new file system on the current node.

[0140] 203. When the comparison result indicates that a new file system exists in the current node, the server updates the metadata set based on the space identifier of the new file system.

[0141] For example, when the comparison result indicates that a new file system exists in the current node, the server may obtain the space identifier of the new file system, add the space identifier as metadata to the metadata set, and obtain an updated metadata set.

[0142] 204. The server identifies the block mapping relationship in the updated metadata set to obtain a block data index.

[0143] For example, the server obtains the block height information of the file corresponding to each file identifier, extracts the start block height and the end block height from the block height information, and when the end block height is not maxUint64, the block height interval at this time can be the interval between the start block height and the end block height. When the end block height is maxUint64, the block height of the last written historical block is obtained, and the start block height and the block height of the historical block are used as the block height interval.

[0144] The server identifies the initial file mapping relationship between block height and file identifier in the file block mapping relationship, identifies the initial space mapping relationship between block height and space identifier in the space block mapping relationship, merges the initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship to obtain the block mapping relationship.

[0145] The server associates the initial file mapping relationship with the initial space mapping relationship to obtain the space identifier corresponding to each block height and the file identifier corresponding to the block height. Based on the file space mapping relationship, the server associates the space identifier with the file identifier to obtain the file metadata corresponding to each block height (file identifier and corresponding space identifier). Based on the block height and the corresponding file metadata, the block mapping relationship is constructed.

[0146] The server can use the block height as the key value, and the file identifier, space identifier and block height interval corresponding to the block height as leaf nodes. Based on the block mapping relationship, key value and leaf nodes, a search tree (B-tree) is constructed, and the search tree is used as the block data index.

[0147] 205. When the comparison result indicates that there is no newly added file system on the current node, the server constructs a block data index based on the metadata set.

[0148] For example, when the comparison result indicates that there is no new file system at present, the server queries the current block data index at the current node. When the current block data index exists at the current node, the current block data index is used as the block data index. When the current block data index does not exist at the current node, the block data index is constructed based on the metadata set.

[0149] 206. When the server obtains the block data of the block to be stored, it determines the target file and the target file system corresponding to the target file based on the block data index and the current block height of the block to be stored.

[0150] For example, the server can receive the blocks to be stored distributed by the blockchain system, serialize the blocks to be stored, obtain the byte stream of the blocks to be stored, and use the byte stream as the block data of the blocks to be stored, or directly receive the block data of the area to be stored uploaded or sent by the terminal, and so on.

[0151] The server can query the current file identifier and the current space identifier corresponding to the current block height in the block data index. When the current file identifier and the current space identifier exist, the file corresponding to the current file identifier is used as the target file, and the file system corresponding to the current space identifier is used as the target file system corresponding to the target file. Alternatively, when the current file identifier and the current space identifier do not exist, the server can also obtain the current block height of the block to be stored, determine the last target historical block written based on the current block height, retrieve the candidate file written to the target historical block in the block data index, and determine the end block height of the candidate file. When the end block height is maxUint64, the candidate file is used as the target file, and the current space identifier corresponding to the file identifier of the target file is filtered out in the block data index, and the file system corresponding to the current space identifier is used as the target file system corresponding to the target file.

[0152] When the server does not have a current file identifier and a current space identifier, it can also update the block data index based on the current block height, the file identifier of the target file and the space identifier of the target file system after determining the target file and the target file system, obtain an updated block data index, and use the updated block data index as the block data index.

[0153] In some embodiments, after determining the target file and the target file system corresponding to the target file based on the block data index and the current block height of the block to be stored, the server can also obtain the remaining storage capacity of the target file, and compare the remaining capacity with the storage capacity occupied by the block data. When the storage capacity exceeds the remaining storage capacity, query the historical file corresponding to maxUint64 in the block data index. When the historical file exists, adjust the maxUint64 in the historical file to the current block height, and create a new file based on the current block height. Based on the current block height, determine the candidate file identifier corresponding to the new file to obtain the candidate file, or determine the candidate file identifier of the candidate file based on the current block height, create a new file, and obtain the candidate file.

[0154] In some embodiments, when there is no historical file, the server can directly create a candidate file. The process of creating the candidate file can be referred to as described above and will not be described in detail here.

[0155] After creating the candidate file, the server may use the next block height of the current block height as the candidate block height, and generate a candidate file identifier based on the candidate block height and the file identifier template.

[0156] The server may obtain node attribute information of the current node and extract the file system information from the node attribute information, or may also obtain attribute information corresponding to the file system of the current node and extract the file system information from the attribute information, and so on.

[0157] The server extracts the dictionary sorting information of the file system set corresponding to the block data index from the file system information, and extracts the remaining storage capacity of the historical file system where the previous file of the candidate file is stored from the file system information. When the remaining storage capacity of the historical file system is less than the preset capacity threshold, the next file system of the historical file system can be used as a candidate file system based on the dictionary sorting information, thereby obtaining the candidate space identifier of the candidate file system; when the remaining storage capacity of the historical file system is greater than the preset capacity threshold, the historical file system can be used as a candidate file system, thereby obtaining the candidate space identifier of the candidate file system; or, the current remaining storage capacity of each file system in the file system set corresponding to the block data index can be extracted from the file system information, and the file systems are sorted based on the current remaining storage capacity. Based on the sorting result, the file system with the largest current remaining storage capacity is screened out from the file system set to obtain the candidate file system, and the candidate space identifier of the candidate file system is determined; or, the file system with the smallest current remaining storage capacity can be screened out from the file system set to obtain the candidate file system, and the candidate space identifier of the candidate file system is determined, and so on.

[0158] The server can use the next block height of the current block height as the starting block height of the candidate file, and use maxUint64 as the ending block height of the candidate file. Then, the starting block height and the ending block height are used as the block height information of the candidate file, and the block height information, file identifier, and candidate space identifier are used as the file metadata corresponding to the candidate file.

[0159] The server can use the file identifier of the candidate file as the key and the candidate space identifier and block height information as the value, thereby persistently writing the file identifier, candidate space identifier and block height information into the metadata set to obtain a target metadata set, identify the current block mapping relationship in the target metadata set, and based on the current block mapping relationship, update the block data index, and use the updated block data index as the block data index.

[0160] After the server updates the block data index and uses the updated block data index as the block data index, when the block data of the block to be stored is obtained, it can return to execute the step of determining the target file and the target file system corresponding to the target file based on the block data index and the current block height of the block to be stored.

[0161] 207. The server writes the block data into the target file in the target file system.

[0162] For example, the server may store the target file in the target file system, and then, in the target file system, write the block data to the target file, thereby completing the block storage of the block to be stored; or, the block data may be written into the target file, and the target file with the written block data may be stored in the target file system, thereby completing the block storage of the block to be stored, etc. As can be seen from the above, after the server of this embodiment obtains the current storage configuration file and compares the current storage configuration file with the corresponding historical storage configuration file, when the comparison result indicates that a new file system exists in the current node, the metadata set is updated based on the space identifier of the new file system, and in the updated metadata set The block mapping relationship is identified to obtain the block data index. When the block data of the block to be stored is obtained, the target file and the target file system corresponding to the target file are determined based on the block data index and the current block height of the block to be stored. The block data is written into the target file in the target file system. Since the scheme can manage the relationship between blocks, files and file systems through the current storage configuration file, metadata set and block data index, it supports adding a new file system in the storage configuration file, and then allocates file writing of different file systems through metadata set and block data index, thereby realizing horizontal expansion of the file system, and therefore, the efficiency of block storage can be improved.

[0163] In order to better implement the above method, an embodiment of the present invention further provides a block storage device, which can be integrated in an electronic device, such as a server or a terminal. The terminal can include a tablet computer, a laptop computer and / or a personal computer.

[0164] For example, Fig.15 As shown, the block storage device may include an acquisition unit 301, an update unit 302, an identification unit 303, a determination unit 304 and a write unit 305, as follows:

[0165] (1) Acquisition unit 301;

[0166] The acquisition unit 301 is used to acquire a current storage configuration file and compare the current storage configuration file with a corresponding historical storage configuration file.

[0167] For example, the acquisition unit 301 can be specifically used to obtain the current storage configuration file, query the historical space identifier in the historical storage configuration file in the current space identifier set of the current storage configuration file, and when the current space identifier set includes the historical space identifier, determine that the current storage configuration file is correctly configured, and compare the space identifier in the current identifier set with the historical space identifier. When there are space identifiers other than the historical space identifier in the current space identifier set, determine that there is new storage space in the current node; when there are no space identifiers other than the historical space identifier in the current space identifier set, determine that there is no new storage space in the current node.

[0168] (2) Update unit 302;

[0169] The updating unit 302 is used to update the metadata set indicating the file mapping relationship between the space identifier, the file identifier and the block identifier information of the file based on the space identifier of the new storage space when the comparison result indicates that the current node has a new storage space.

[0170] For example, the updating unit 302 may be specifically used to obtain a space identifier of the newly added storage space when the comparison result indicates that the current node has newly added storage space, and add the space identifier as metadata to the metadata set to obtain an updated metadata set.

[0171] (3) identification unit 303;

[0172] The identification unit 303 is used to identify the block mapping relationship in the updated metadata set to obtain the block data index. The block mapping relationship includes the mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively.

[0173] For example, the identification unit 303 can be specifically used to identify the block identification interval of each file corresponding to the file identification in the block identification information, convert the file mapping relationship into a block mapping relationship corresponding to the block identification, and construct a block data index corresponding to the current node according to the block mapping relationship.

[0174] (4) determining unit 304;

[0175] The determination unit 304 is configured to determine the target file and the target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored when the block data of the block to be stored is obtained.

[0176] For example, the determination unit 304 can be specifically used to obtain the current block identifier of the block to be stored when the block data of the block to be stored is obtained, query the current file identifier and the current space identifier corresponding to the current block identifier in the block data index, and determine the target file corresponding to the block to be stored and the target storage space corresponding to the target file based on the query result and the block data index.

[0177] (5) Write unit 305;

[0178] The writing unit 305 is used to write the block data into the target file in the target storage space.

[0179] For example, the write unit 305 can be specifically used to store the target file in the target storage space, and then, in the target storage space, write the block data to the target file, thereby completing the block storage of the block to be stored; or, the block data can also be written to the target file, and the target file with the written block data can be stored in the target storage space, thereby completing the block storage of the block to be stored, and so on.

[0180] Optionally, in some embodiments, the block storage device may further include a creation unit 306, such as Fig.16 As shown, the specific details can be as follows:

[0181] The creation unit 306 is used to create a candidate file and update the block data index based on the file data corresponding to the candidate file.

[0182] For example, creation unit 306 can be specifically used to obtain the remaining storage capacity of the target file, and compare the remaining capacity with the storage capacity occupied by the block data. When the storage capacity exceeds the remaining storage capacity, a candidate file is created, and the file metadata corresponding to the candidate file is determined. Based on the file metadata, the block data index is updated, and the updated block data index is used as the block data index.

[0183] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0184] As can be seen from the above, in this embodiment, after the acquisition unit 301 acquires the current storage configuration file and compares the current storage configuration file with the corresponding historical storage configuration file, the updating unit 302 updates the metadata set based on the space identifier of the newly added storage space when the comparison result indicates that the current node has a newly added storage space, the identification unit 303 identifies the block mapping relationship in the updated metadata set to obtain the block data index, and the determination unit 304 determines the target file and the target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored when the block data of the block to be stored is acquired, and the writing unit 305 writes the block data to the target file in the target storage space; because the scheme can manage the relationship between blocks, files and storage spaces of files through the current storage configuration file, the metadata set and the block data index, supports the addition of storage space in the storage configuration file, and then allocates file writing of different storage spaces through the metadata set and the block data index, thereby realizing horizontal expansion of the storage space, and therefore, can improve the efficiency of block storage.

[0185] The embodiment of the present invention further provides an electronic device, such as Fig.17 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:

[0186] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Fig.17 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0187] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0188] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0189] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0190] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0191] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0192] A current storage configuration file is obtained, and the current storage configuration file is compared with the corresponding historical storage configuration file. When the comparison result indicates that there is a newly added storage space in the current node, a metadata set is updated based on the space identifier of the newly added storage space. The metadata set indicates a file mapping relationship between the space identifier, the file identifier and the block identifier information of the file. The block mapping relationship is identified in the updated metadata set to obtain a block data index. The block mapping relationship includes a mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively. When the block data of the block to be stored is obtained, a target file and a target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored. The block data is written into the target file in the target storage space.

[0193] For example, the electronic device can take the current storage configuration file, query the historical space identifier in the historical storage configuration file in the current space identifier set of the current storage configuration file, and when the current space identifier set contains the historical space identifier, it is determined that the current storage configuration file is correctly configured, and the space identifier in the current identifier set is compared with the historical space identifier. When there are space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is new storage space in the current node, and when there are no space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is no new storage space in the current node. When the comparison result indicates that there is new storage space in the current node, the space identifier of the new storage space can be obtained, and the space identifier can be added to the metadata set as metadata to obtain an updated metadata set. The block identifier interval of each file corresponding to the file identifier is identified in the block identifier information, and the file mapping relationship is converted into a block mapping relationship corresponding to the block identifier. According to the block mapping relationship, a block data index corresponding to the current node is constructed. When the block data of the block to be stored is obtained, the current block identifier of the block to be stored is obtained, and the current file identifier and the current space identifier corresponding to the current block identifier are queried in the block data index. Based on the query result and the block data index, the target file corresponding to the block to be stored and the target storage space corresponding to the target file are determined. The target file is stored in the target storage space, and then, in the target storage space, the block data is written to the target file, thereby completing the block storage of the block to be stored; or, the block data can also be written to the target file, and the target file with the written block data is stored in the target storage space, thereby completing the block storage of the block to be stored. After determining the target file and the target storage space corresponding to the target file, the remaining storage capacity of the target file can also be obtained, and the remaining capacity is compared with the storage capacity occupied by the block data. When the storage capacity exceeds the remaining storage capacity, a candidate file is created, and the file metadata corresponding to the candidate file is determined. Based on the file metadata, the block data index is updated, and the updated block data index is used as the block data index.

[0194] The specific implementation of the above operations can be found in the previous embodiments and will not be described in detail here.

[0195] As can be seen from the above, after obtaining the current storage configuration file and comparing the current storage configuration file with the corresponding historical storage configuration file, when the comparison result indicates that there is a newly added storage space in the current node, the metadata set is updated based on the space identifier of the newly added storage space, and the block mapping relationship is identified in the updated metadata set to obtain the block data index. When the block data of the block to be stored is obtained, the target file and the target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored, and the block data is written to the target file in the target storage space; because the scheme can manage the relationship between blocks, files and storage spaces of files through the current storage configuration file, the metadata set and the block data index, and supports the addition of new storage space in the storage configuration file, and then allocates file writing of different storage spaces through the metadata set and the block data index, thereby realizing horizontal expansion of the storage space, and therefore, the efficiency of block storage can be improved.

[0196] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0197] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any block storage method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:

[0198] A current storage configuration file is obtained, and the current storage configuration file is compared with the corresponding historical storage configuration file. When the comparison result indicates that there is a newly added storage space in the current node, a metadata set is updated based on the space identifier of the newly added storage space. The metadata set indicates a file mapping relationship between the space identifier, the file identifier and the block identifier information of the file. The block mapping relationship is identified in the updated metadata set to obtain a block data index. The block mapping relationship includes a mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively. When the block data of the block to be stored is obtained, a target file and a target storage space corresponding to the target file are determined based on the block data index and the current block identifier of the block to be stored. The block data is written into the target file in the target storage space.

[0199] For example, the electronic device can take the current storage configuration file, query the historical space identifier in the historical storage configuration file in the current space identifier set of the current storage configuration file, and when the current space identifier set contains the historical space identifier, it is determined that the current storage configuration file is correctly configured, and the space identifier in the current identifier set is compared with the historical space identifier. When there are space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is new storage space in the current node, and when there are no space identifiers other than the historical space identifier in the current space identifier set, it is determined that there is no new storage space in the current node. When the comparison result indicates that there is new storage space in the current node, the space identifier of the new storage space can be obtained, and the space identifier can be added to the metadata set as metadata to obtain an updated metadata set. The block identifier interval of each file corresponding to the file identifier is identified in the block identifier information, and the file mapping relationship is converted into a block mapping relationship corresponding to the block identifier. According to the block mapping relationship, a block data index corresponding to the current node is constructed. When the block data of the block to be stored is obtained, the current block identifier of the block to be stored is obtained, and the current file identifier and the current space identifier corresponding to the current block identifier are queried in the block data index. Based on the query result and the block data index, the target file corresponding to the block to be stored and the target storage space corresponding to the target file are determined. The target file is stored in the target storage space, and then, in the target storage space, the block data is written to the target file, thereby completing the block storage of the block to be stored; or, the block data can also be written to the target file, and the target file with the written block data is stored in the target storage space, thereby completing the block storage of the block to be stored. After determining the target file and the target storage space corresponding to the target file, the remaining storage capacity of the target file can also be obtained, and the remaining capacity is compared with the storage capacity occupied by the block data. When the storage capacity exceeds the remaining storage capacity, a candidate file is created, and the file metadata corresponding to the candidate file is determined. Based on the file metadata, the block data index is updated, and the updated block data index is used as the block data index.

[0200] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0201] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0202] Since the instructions stored in the computer-readable storage medium can execute the steps in any block storage method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any block storage method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details, which will not be repeated here.

[0203] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional implementations of the above-mentioned block storage aspect or block data storage aspect.

[0204] The above is a detailed introduction to a block storage method, device, electronic device and computer-readable storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A block storage method, characterized in that: include: Obtaining a current stored configuration file, and comparing the current stored configuration file with a corresponding historical stored configuration file; When the comparison result indicates that there is a newly added storage space in the current node, based on the space identifier of the newly added storage space, the metadata set is updated, and the metadata set indicates a file mapping relationship between the space identifier, the file identifier, and the block identifier information of the file; Identifying a block mapping relationship in the updated metadata set to obtain a block data index, wherein the block mapping relationship includes mapping relationships between the block identifier in the block identifier information and the file identifier and the space identifier respectively; When the block data of the block to be stored is obtained, based on the block data index and the current block identifier of the block to be stored, a target file and a target storage space corresponding to the target file are determined; In the target storage space, the block data is written into the target file.

2. The block storage method according to claim 1, characterized in that: The step of identifying the block mapping relationship in the updated metadata set to obtain the block data index includes: Identifying the block identification interval of each file corresponding to the file identification in the block identification information; Converting the file mapping relationship into the block mapping relationship corresponding to the block identifier within the block identifier interval; According to the block mapping relationship, the block data index corresponding to the current node is constructed.

3. The block storage method according to claim 2, characterized in that: The file mapping relationship includes a file space mapping relationship, a file block mapping relationship and a space block mapping relationship, and the converting of the file mapping relationship into the block mapping relationship corresponding to the block identifier within the block identifier interval includes: Identifying an initial file mapping relationship between the block identifier and the file identifier in the file-block mapping relationship; Identifying an initial spatial mapping relationship between the block identifier and the spatial identifier in the spatial block mapping relationship; The initial file mapping relationship, the initial space mapping relationship and the file space mapping relationship are merged to obtain the block mapping relationship.

4. The block storage method according to claim 2, characterized in that: The step of constructing the block data index corresponding to the current node according to the block mapping relationship includes: The block identifier is used as a key value, and the file identifier, space identifier and block identifier interval respectively corresponding to the block identifier are used as leaf nodes; A search tree is constructed based on the block mapping relationship, the key value and the leaf node, and the search tree is used as the block data index.

5. The block storage method according to claim 1, characterized in that: After determining the target file and the target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored, the method further includes: Acquire the remaining storage capacity of the target file, and compare the remaining storage capacity with the storage capacity occupied by the block data; When the storage capacity exceeds the remaining storage capacity, creating a candidate file, and determining file metadata corresponding to the candidate file; Based on the file metadata, the block data index is updated, and the updated block data index is used as the block data index.

6. The block storage method according to claim 5, characterized in that: The step of creating a candidate file comprises: Searching the block data index for a history file corresponding to a preset block identifier; When the historical file exists, adjusting the preset block identifier in the historical file to the current block identifier, and creating the candidate file based on the current block identifier; When the historical file does not exist, the candidate file is created based on the current block identifier.

7. The block storage method according to claim 5, characterized in that: The determining the file metadata corresponding to the candidate file includes: Acquire storage space information of the current node, and determine a candidate space identifier corresponding to the candidate file based on the storage space information; According to the current block identifier, setting the start block identifier and the end block identifier corresponding to the candidate file; The candidate file identifier, the start block identifier, the end block identifier and the candidate space identifier are used as the file metadata.

8. The block storage method according to claim 7, characterized in that: The determining, based on the storage space information, a candidate space identifier corresponding to the candidate file includes: Extracting dictionary sorting information of the storage space set corresponding to the block data index from the storage space information; Based on the dictionary sorting information, the candidate storage space corresponding to the candidate file is screened out from the storage space set to obtain a candidate space identifier of the candidate storage space.

9. The block storage method according to claim 7, characterized in that: The determining, based on the storage space information, a candidate space identifier corresponding to the candidate file includes: Extracting the current remaining storage capacity of each storage space in the storage space set corresponding to the block data index from the storage space information; sorting the storage space based on the current remaining storage capacity; According to the sorting result, the candidate storage space corresponding to the candidate file is screened out from the storage space set to obtain a candidate space identifier of the candidate storage space.

10. The block storage method according to claim 1, characterized in that: The comparing the current stored configuration file with the corresponding historical stored configuration file includes: Querying the current space identifier set of the current storage configuration file for the corresponding historical space identifier in the historical storage configuration file; When the current space identifier set includes the historical space identifier, determining that the current storage configuration file is correctly configured, and comparing the space identifier in the current space identifier set with the historical space identifier; When there is a space identifier other than the historical space identifier in the current space identifier set, determining that there is a newly added storage space in the current node; When there is no space identifier other than the historical space identifier in the current space identifier set, it is determined that there is no newly added storage space in the current node.

11. The block storage method according to claim 10, characterized in that: After determining that the current node does not have any newly added storage space, the method further includes: When the current node has a current block data index, storing the block to be stored based on the current block data index; When the block data index does not exist in the current node, the block data index is constructed based on the metadata set, and the block to be stored is stored based on the block data index.

12. A block storage device, characterized in that: include: An acquisition unit, configured to acquire a currently stored configuration file and compare the currently stored configuration file with a corresponding historically stored configuration file; an updating unit, configured to update a metadata set based on a space identifier of the newly added storage space when the comparison result indicates that the current node has newly added storage space, wherein the metadata set indicates a file mapping relationship between the space identifier, the file identifier, and the block identifier information of the file; an identification unit, configured to identify a block mapping relationship in the updated metadata set to obtain a block data index, wherein the block mapping relationship includes a mapping relationship between the block identifier in the block identifier information and the file identifier and the space identifier respectively; a determination unit, configured to determine a target file and a target storage space corresponding to the target file based on the block data index and the current block identifier of the block to be stored when the block data of the block to be stored is obtained; A writing unit is used to write the block data into the target file in the target storage space.

13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the block storage method according to any one of claims 1 to 11.

14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps in the block storage method according to any one of claims 1 to 11 are implemented.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the block storage method according to any one of claims 1 to 11.

Citation Information

Cited By

  • Cache storage method and related equipment

    CN116185949A