Methods, apparatus, storage media and electronic devices for writing data

By using data units smaller than a preset size and write status information, the problem of computational resource consumption during mapping relationship updates in distributed storage systems is solved, achieving efficient data writing and storage pool capacity management.

CN119292529BActive Publication Date: 2026-06-30JINAN INSPUR DATA TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2024-09-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing technologies involve a large number of data read and write operations when updating mapping relationships in distributed storage systems, resulting in excessive consumption of computing resources.

Method used

Using data units smaller than a preset size as processing units, the system determines whether a mapping relationship exists at the target location by reading the write status information in the data block, thereby performing the writing or updating of the mapping relationship and reducing unnecessary data read and write operations.

Benefits of technology

It improves data writing efficiency, saves computing resources, and enables precise management and updating of storage pool capacity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292529B_ABST
    Figure CN119292529B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, computer-readable storage medium, and electronic device for writing data, relating to the field of computers. The method includes: acquiring a data block to be written, wherein the data block includes at least one data unit, the size of which is smaller than a preset size, and the data unit is used to indicate a mapping relationship; reading write status information of the mapping relationship in the data block; wherein the write status information is used to indicate whether data containing a mapping relationship exists at the target location of the storage pool containing the data unit to be written; and, if it is determined from the write status information that data containing a mapping relationship exists at the target location, writing the data unit to the target location to update the mapping relationship. By using write status information, it is convenient and quick to identify whether data containing a mapping relationship exists at the target location of the storage pool, without needing to read the mapping relationship in the storage pool, thus saving computational resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more specifically, to a method, apparatus, computer-readable storage medium, and electronic device for writing data. Background Technology

[0002] With the rapid development of technology, the amount of data on the internet is growing exponentially, and this data is constantly being updated. To cope with scenarios involving massive amounts of data, distributed storage systems have gradually become widely used. Distributed storage systems typically use mapping relationships to map data objects to physical locations on storage media to achieve data storage. However, with the rapid updates of data and the presence of a large number of business objects in distributed storage systems, these mapping relationships also need to be updated frequently.

[0003] In related technologies, when it is necessary to update the mapping relationship, in order to ensure the correctness and consistency of the mapping relationship update, the mapping relationship update includes two processes: data reading and data updating. First, the existing mapping relationship needs to be read, then the existing mapping relationship is updated, and then it is rewritten into the storage system.

[0004] However, existing technologies involve a large number of data read and write operations during the process of updating the mapping relationship, which consumes too much computing resources. Summary of the Invention

[0005] This application provides a method, apparatus, computer-readable storage medium, and electronic device for writing data.

[0006] According to one embodiment of this application, a method for writing data is provided. The method includes: obtaining a data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate a mapping relationship; reading write status information of the mapping relationship in the data block; wherein the write status information is used to indicate whether there is data containing the mapping relationship at a target location in the storage pool where the data unit is to be written; and if it is determined from the write status information that there is data containing the mapping relationship at the target location, writing the data unit to the target location to update the mapping relationship.

[0007] In an exemplary embodiment, after reading the write status information of the mapping relationship in the data block, the data writing method further includes: if it is determined from the write status information that there is no data containing the mapping relationship at the target location, writing the data unit to the target location to add the mapping relationship at the target location.

[0008] In an exemplary embodiment, after writing the data unit to the target location when it is determined from the write status information that no data containing the mapping relationship exists at the target location, the data writing method further includes: updating the write status information of the target location, wherein the updated write status information of the target location is used to indicate that data containing the mapping relationship exists at the target location.

[0009] In an exemplary embodiment, the data writing method includes: determining that the capacity of the storage pool remains unchanged when the mapping relationship of the target location is updated; and updating the capacity of the storage pool according to the size of the added data unit when the mapping relationship is added at the target location.

[0010] In an exemplary embodiment, after reading the write status information of the mapping relationship in the data block, the data writing method further includes:

[0011] If it is determined that the write status information of the mapping relationship in the data block does not exist, initial extended data is added to the data block, wherein the extended data is used to record the write status information of the data block, and each bit in the initial extended data is in a first state;

[0012] The data block is divided into multiple data units;

[0013] The extended data is divided into multiple sub-extended data, wherein the number of the multiple sub-extended data is the same as the number of the multiple data units, and each sub-extended data includes at least one bit.

[0014] Write the first data unit from the plurality of data units into the storage pool, wherein the first data unit is any one of the plurality of data units;

[0015] After the first data unit is written into the storage pool, the first position of the first data unit in the storage pool is determined;

[0016] Based on the first position of the first data unit in the storage pool, a first sub-extended data corresponding to the first position is determined from the plurality of sub-extended data, wherein the first sub-extended data is used to indicate whether there is data containing the mapping relationship at the first position of the storage pool;

[0017] The state of the bits of the first sub-extended data is modified to a second state, wherein the second state is different from the first state;

[0018] Determine whether all of the data units have been written to the storage pool;

[0019] If it is determined that there is at least one second data unit among the plurality of data units that has not been written to the storage pool, one of the second data units is taken as a new first data unit and the step of writing the first data unit among the plurality of data units to the storage pool is returned until all the plurality of data units are written to the storage pool.

[0020] After all the data units are written to the storage pool, the write status information of the mapping relationship in the data block is obtained according to the sub-extended data corresponding to each of the data units.

[0021] In an exemplary embodiment, the mapping relationship is at least one of a forward relationship and a reverse relationship, wherein the forward relationship is the relationship between the business objects of the storage pool and the internal objects, and the reverse relationship is the relationship between the internal objects of the storage pool and the business objects.

[0022] In an exemplary embodiment, after writing the data unit to the target location to update the mapping relationship, the method further includes: recording the write status information of the target location; and calling the corresponding transmission interface to store the write status information of the target location in the storage pool.

[0023] According to another embodiment of the present application, a data writing apparatus is also provided, the apparatus comprising:

[0024] A data acquisition module is used to acquire a data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate a mapping relationship;

[0025] An information reading module is used to read the write status information of the mapping relationship in the data block; wherein, the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool to be written to the data unit;

[0026] The data writing module is used to write the data unit to the target location to update the mapping relationship when it is determined from the writing status information that data containing the mapping relationship exists at the target location.

[0027] According to yet another embodiment of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program is configured to perform the steps in any of the above method embodiments when it is run.

[0028] According to yet another embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0029] According to yet another embodiment of this application, a computer program product is also provided, which includes a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0030] The data writing method of this application first obtains a data block to be written. The data block includes at least one data unit, the size of which is smaller than a preset size. The data unit indicates a mapping relationship. Therefore, when a mapping relationship needs to be written or updated, it is written or updated in units of data units. Because the data units are small, only small amounts of data can be written, reducing unnecessary data reads and writes. Then, the write status information of the mapping relationship in the data block is read. This write status information indicates whether the target location of the data unit to be written in the storage pool contains data with a mapping relationship. By introducing write status information into the data block, the system can quickly identify whether the target location in the storage pool contains data with a mapping relationship, without needing to read existing mapping relationships in the storage pool. If the write status information determines that the target location contains data with a mapping relationship, the data unit is written to the target location to update the mapping relationship. In summary, the method of this application, by using data units smaller than a preset size as data processing units, allows for the processing of only a small portion of data at the required location during data writing, improving writing efficiency and saving computational resources. On the other hand, by writing status information, it is convenient and quick to identify whether there is data containing mapping relationships in the target location of the storage pool, without having to read the mapping relationships in the storage pool, thus saving the reading action and saving computing resources. Attached Figure Description

[0031] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0032] Figure 1 This is a hardware structure block diagram of a server device for a data writing method according to an embodiment of this application;

[0033] Figure 2 This is a flowchart of a data writing method according to an embodiment of this application;

[0034] Figure 3This is a second flowchart of a data writing method according to an embodiment of this application;

[0035] Figure 4 This is a third flowchart of a data writing method according to an embodiment of this application;

[0036] Figure 5 This is a flowchart of a method for updating the capacity of a storage pool according to an embodiment of this application;

[0037] Figure 6 This is a flowchart of a data writing method according to an embodiment of this application;

[0038] Figure 7 This is the fifth flowchart of a data writing method according to an embodiment of this application;

[0039] Figure 8 This is a schematic diagram illustrating the workflow of a data writing method according to an embodiment of this application;

[0040] Figure 9 This is a structural block diagram of a data writing device according to an embodiment of this application;

[0041] Figure 10 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0042] The embodiments of this application will be described in detail below with reference to the accompanying drawings and examples.

[0043] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0044] The data writing method embodiments provided in this application can be executed on a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a hardware structure block diagram of a server device for a data writing method according to an embodiment of this application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The server device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server equipment described above. For example, the server equipment may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0045] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the data writing method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to server devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0046] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the server device. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0047] In one embodiment, a method for writing data is provided, such as Figure 2 As shown, the method includes the following steps S200-220:

[0048] Step S200: Obtain the data block to be written.

[0049] The data block includes at least one data unit, the size of which is smaller than a preset size. The data unit is used to indicate the mapping relationship, that is, the data unit is the data used to record the mapping relationship.

[0050] For example, the preset size can be 8KB, 64KB, 512KB, etc., and can be selected according to the actual situation, with 8KB being the preferred size.

[0051] The mapping relationship is at least one of a forward relationship and a reverse relationship. A forward relationship is the relationship between business objects in the storage pool and internal objects, while a reverse relationship is the relationship between internal objects in the storage pool and business objects.

[0052] It should be noted that, taking a forward mapping relationship as an example, in a distributed storage system, due to the large number of business objects within the storage system, updates to forward relationships can be very frequent. In some related technologies, forward relationships are stored and managed in batches, such as sharded storage, where each shard can be on the order of MB. Therefore, when updating and writing forward relationships, operations are performed on a shard-by-shard basis, requiring read and write operations on the entire shard's forward relationships, resulting in excessive computational resource consumption. In this embodiment, however, a single data unit can be used as the unit for updating and writing forward relationships. Since a data unit is much smaller than a shard, the required computational resources are significantly reduced.

[0053] Step S210: Read the write status information of the mapping relationship in the data block.

[0054] The write status information is used to indicate whether there is data containing a mapping relationship at the target location of the storage pool of the data unit to be written.

[0055] Specifically, write status information indicating mapping relationships can be added to the attribute information (attrs) of data blocks. This write status information can be in the form of a bitmap, recording whether data containing the mapping relationship already exists at the target location in the storage pool where the data unit to be written is to be written. This allows for quick determination of whether data containing the mapping relationship exists at the target location in the storage pool for the data unit to be written, without needing to read the mapping relationship information from the storage pool. This facilitates rapid determination of whether the write operation is an append write or an overwrite write, which is crucial for accurately managing and updating the storage pool capacity. Only by knowing precisely which data blocks are newly written or modified can storage resources be correctly adjusted.

[0056] For example, taking an 8KB data unit as an example, the bitmap includes multiple bits, each bit representing whether a positive relationship already exists at the corresponding 8KB position of a data unit. In other words, the bitmap marks whether a positive relationship has been established for each 8KB data unit, allowing the system to quickly determine which data blocks contain valid data when processing read requests. Secondly, because the bitmap provides direct and immediate information, the system does not need to read the entire storage pool's metadata every time to determine the positive relationship, reducing computational resource consumption.

[0057] For example, taking a positive mapping relationship as an example, the data unit of the positive relationship is saved in the mapping type information of the business object in the form of key-value (kv). The data (value) of the data unit is 8KB, and the write status information is k. k can be a special character + an offset that is an integer multiple of 8KB. Each data unit is associated with a unique write status information.

[0058] Step S220: If it is determined from the write status information that there is data containing a mapping relationship at the target location, the data unit is written to the target location to update the mapping relationship.

[0059] Specifically, if it is determined that there is data containing a mapping relationship at the target location, then the write of this data unit is an overwrite write, which updates the mapping relationship data at the target location.

[0060] In this embodiment, a data block to be written is first obtained. The data block includes at least one data unit, the size of which is smaller than a preset size. The data unit is used to indicate a mapping relationship. Therefore, when a mapping relationship needs to be written or updated, it is written or updated in units of data units. Because the data units are small, only a small amount of data can be written, reducing unnecessary data reads and writes. Then, the write status information of the mapping relationship in the data block is read. This write status information indicates whether the target location of the data unit to be written in the storage pool contains data with a mapping relationship. By introducing write status information into the data block, the system can quickly identify whether the target location of the storage pool contains data with a mapping relationship, without needing to read existing mapping relationships in the storage pool. If the write status information determines that the target location contains data with a mapping relationship, the data unit is written to the target location to update the mapping relationship. In summary, the method of this application, on the one hand, uses data units smaller than a preset size as data processing units. When writing data, only a small portion of data can be processed for the required location, improving writing efficiency and saving computing resources. On the other hand, by writing status information, it is convenient and quick to identify whether there is data containing mapping relationships in the target location of the storage pool, without having to read the mapping relationships in the storage pool, thus saving the reading action and saving computing resources.

[0061] In one embodiment, such as Figure 3 As shown, in step S210, the write status information of the mapping relationship in the data block is read. Subsequently, the data writing method further includes: step S230, if it is determined from the write status information that no data containing the mapping relationship exists at the target location, the data unit is written to the target location to add the mapping relationship at the target location.

[0062] If the write status information determines that there is no data containing a mapping relationship at the target location, it means that the data unit being written is an append write, and therefore a mapping relationship is added at the target location.

[0063] In this embodiment, if it is determined that there is no data containing a mapping relationship at the target location, then an additional data unit is written at the target location to represent the mapping relationship, thereby realizing the appending of the mapping relationship.

[0064] In one embodiment, such as Figure 4 As shown, in step S230, if it is determined from the write status information that there is no data containing a mapping relationship at the target location, the data unit is written to the target location to add a mapping relationship at the target location. Afterwards, the data writing method further includes step S240, updating the write status information at the target location.

[0065] The updated write status information of the target location is used to indicate that there is data containing mapping relationships at the target location.

[0066] Specifically, before the data unit is written to the target location, the write status information indicates that no data containing the mapping relationship exists at the target location. However, after the data unit is written to the target location, data containing the mapping relationship exists at the target location. Therefore, the write status information needs to be updated to indicate that data containing the mapping relationship exists at the target location.

[0067] In this embodiment, after the data unit is written to the target location, since the target location has changed from having no data containing a mapping relationship to having data containing a mapping relationship, the writing status information corresponding to the target location also needs to be updated so that it can be quickly and accurately identified whether the target location has data containing a mapping relationship based on the writing status information.

[0068] In one embodiment, such as Figure 5 As shown, the data writing method further includes steps S500-S510, wherein,

[0069] In step S500, while updating the mapping relationship of the target location, it is determined that the capacity of the storage pool remains unchanged.

[0070] In the case of updating the mapping relationship of the target location, the data representing the mapping relationship of the target location is overwritten, but the total capacity of the storage pool does not change, so the capacity of the storage pool is determined to remain unchanged.

[0071] Step S510: When a mapping relationship is added at the target location, update the capacity of the storage pool according to the size of the added data unit.

[0072] In the case of adding a mapping relationship to the target location, the total capacity of the storage pool changes because the data representing the added mapping relationship to the target location has changed. Therefore, the capacity of the storage pool needs to be updated based on the increased amount of data.

[0073] In this embodiment, the changes in the storage pool capacity can be accurately identified based on whether to update the mapping relationship of the target location or to add a mapping relationship at the target location, so as to accurately manage and update the storage pool capacity and accurately adjust storage resources.

[0074] In one embodiment, such as Figure 6 As shown, in step S210, the write status information of the mapping relationship in the data block is read. Afterwards, the data writing method further includes steps S600-S690, wherein:

[0075] Step S600: If it is determined that the write status information of the mapping relationship in the data block does not exist, add initial extended data to the data block.

[0076] The extended data is used to record the write status information of the data block. Initially, each bit in the extended data is in the first state. The write status information can be in the form of a bitmap, including multiple bits. If the write status information corresponding to the mapping relationship in the data block does not exist, each bit can be initialized to the first state of 0, indicating that no write status information has been recorded for the write position corresponding to any data unit in the data block.

[0077] Step S610: Divide the data block into multiple data units.

[0078] In this way, the data block can be divided into multiple data units so that when the mapping relationship is updated and written, a data unit can be used as the unit for updating and writing. Only the data unit corresponding to the mapping relationship that needs to be updated needs to be written. Since the size of the data unit is very small (e.g., 8KB), the required computing resources are small.

[0079] Step S620: Divide the extended data into multiple sub-extended data.

[0080] The number of sub-extended data is the same as the number of data units, and each sub-extended data includes at least one bit.

[0081] Step S630: Write the first data unit among the multiple data units into the storage pool.

[0082] The first data unit is any one of the multiple data units.

[0083] Step S640: After the first data unit is written to the storage pool, determine the first position of the first data unit in the storage pool.

[0084] Step S650: Based on the first position of the first data unit in the storage pool, determine the first sub-extended data corresponding to the first position among multiple sub-extended data.

[0085] The first sub-extended data is used to indicate whether there is data containing mapping relationships in the first location of the storage pool.

[0086] Specifically, in the bitmap of the write status information, each bit corresponds to a position in the storage pool. Therefore, after determining the first position of the first data unit in the storage pool, the corresponding bit is selected in the bitmap of the write status information, which means determining the first sub-extended data corresponding to the first position among multiple sub-extended data.

[0087] Step S660: Modify the state of the bits of the first sub-extended data to the second state.

[0088] The second state differs from the first state. The first state can be 0, and the second state can be 1. The state of the bits of the first sub-extended data is the second state, indicating that the location of the storage pool corresponding to the first sub-extended data has been written into the data unit.

[0089] Step S670: Determine whether all data units have been written to the storage pool.

[0090] In step S680, if it is determined that there is at least one second data unit that has not been written to the storage pool among the multiple data units, one second data unit is taken as the new first data unit, and the process returns to step S630.

[0091] Step S690: If it is determined that multiple data units are written to the storage pool, then the write status information of the mapping relationship in the data block is obtained according to the sub-extended data corresponding to the multiple data units respectively.

[0092] After multiple data units are written to the storage pool, the state of the sub-extended data corresponding to each data unit is adjusted from the first state to the second state. Therefore, the extended data of the data block at this time has recorded the write state information of all data units of the data block.

[0093] In this embodiment, when new data is written to the storage pool, the state of the corresponding bit in the write status information (bitmap) is modified simultaneously with the writing, based on the location of the data being written. This records the location of the written data unit. Thus, the write status information is recorded during the first write of a data block, facilitating rapid location and identification during subsequent writes, improving data writing efficiency and saving computational resources.

[0094] In one embodiment, such as Figure 7 As shown, in step S220, if it is determined from the write status information that data containing a mapping relationship exists at the target location, the data unit is written to the target location to update the mapping relationship. The data writing method then further includes steps S700-S710.

[0095] Step S700: Record the write status information of the target location.

[0096] Step S710: Call the corresponding transmission interface to store the write status information of the target location into the storage pool.

[0097] For example, such as Figure 8 As shown, the storage system includes a Cache Placement Group (CachePG), which refers to a portion of the data in the storage system. This data is placed in a cache layer close to computing resources for faster data access and processing. The storage backend (Bluestore) can access data blocks and store them in the storage system (RockSDB). If the write status information for the mapping relationship in the data block does not exist, data is written and write status information is generated. That is, the data block is written, and the corresponding write status information is generated. Then, the data unit and write status information are stored on disk. If the write status information for the mapping relationship in the data block exists, it is determined whether data exists at the target write location. If no data exists, data is written and the write status information is updated. Then, the data unit and write status information are stored on disk. The specific data writing process has been described in detail in the above embodiments and will not be repeated here.

[0098] In this embodiment, after recording the write status information of the target location, the write status information of the target location can be stored on disk in the storage pool so that it can be quickly located and identified when writing again in the future, thereby improving the efficiency of data writing and saving computing resources.

[0099] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.

[0100] This embodiment also provides a data writing device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.

[0101] Figure 9 This is a structural block diagram of a data writing apparatus according to an embodiment of this application, the apparatus comprising:

[0102] The data acquisition module 901 is used to acquire a data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate a mapping relationship.

[0103] The information reading module 902 is used to read the write status information of the mapping relationship in the data block; wherein, the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool of the data unit to be written;

[0104] The data writing module 903 is used to write data units to the target location to update the mapping relationship when it is determined from the writing status information that data containing the mapping relationship exists at the target location.

[0105] The aforementioned apparatus first acquires a data block to be written. The data block includes at least one data unit, the size of which is smaller than a preset size. The data unit indicates a mapping relationship, allowing the mapping relationship to be written or updated in units of data units when needed. Because the data units are small, only small amounts of data can be written, reducing unnecessary data reads and writes. Then, the write status information of the mapping relationship in the data block is read. This write status information indicates whether the target location of the data unit to be written in the storage pool contains data with a mapping relationship. By introducing write status information into the data block, the system can quickly identify whether the target location in the storage pool contains data with a mapping relationship, without needing to read existing mapping relationships in the storage pool. If the write status information determines that the target location contains data with a mapping relationship, the data unit is written to the target location to update the mapping relationship. In summary, the method of this application, by using data units smaller than a preset size as data processing units, allows for the processing of only a small portion of data at the required location during data writing, improving writing efficiency and saving computational resources. On the other hand, by writing status information, it is convenient and quick to identify whether there is data containing mapping relationships in the target location of the storage pool, without having to read the mapping relationships in the storage pool, thus saving the reading action and saving computing resources.

[0106] In an exemplary embodiment, the above-described apparatus is further configured to write data units to the target location when it is determined from the write status information that no data containing a mapping relationship exists at the target location, so as to add a mapping relationship at the target location.

[0107] In an exemplary embodiment, the above-described apparatus is further configured to update the write status information of the target location, wherein the updated write status information of the target location is used to indicate that there is data containing a mapping relationship at the target location.

[0108] In an exemplary embodiment, the above-described apparatus is further configured to determine that the capacity of the storage pool remains unchanged when the mapping relationship of the target location is updated; and to update the capacity of the storage pool according to the size of the added data unit when the mapping relationship of the target location is increased.

[0109] In an exemplary embodiment, the above-described apparatus is further configured to, when determining that the write status information of the mapping relationship in the data block does not exist, add initial extended data to the data block, wherein the extended data is used to record the write status information of the data block, and each bit in the initial extended data is a first state; divide the data block into multiple data units; divide the extended data into multiple sub-extended data, wherein the number of multiple sub-extended data is the same as the number of multiple data units, and each sub-extended data includes at least one bit; write a first data unit among the multiple data units into a storage pool, wherein the first data unit is any one of the multiple data units; after the first data unit is written into the storage pool, determine the first position of the first data unit in the storage pool; based on the position of the first data unit in the storage pool... First position: Determine the first sub-extended data corresponding to the first position among multiple sub-extended data, wherein the first sub-extended data is used to indicate whether there is data containing the mapping relationship at the first position of the storage pool; Modify the state of the bits of the first sub-extended data to a second state, wherein the second state is different from the first state; Determine whether multiple data units have all been written to the storage pool; If it is determined that there is at least one second data unit among the multiple data units that has not been written to the storage pool, take one second data unit as a new first data unit and return to execute the step of writing the first data unit among the multiple data units to the storage pool, until all multiple data units are written to the storage pool; After all multiple data units are written to the storage pool, obtain the write status information of the mapping relationship in the data block according to the sub-extended data corresponding to the multiple data units respectively.

[0110] In an exemplary embodiment, the above-described apparatus is further configured to record the write status information of the target location; and call the corresponding transmission interface to store the write status information of the target location in the storage pool.

[0111] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0112] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.

[0113] Optionally, in this embodiment, the computer program described above can be configured to perform the following steps:

[0114] S1, Obtain the data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate the mapping relationship.

[0115] S2, read the write status information of the mapping relationship in the data block; wherein, the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool of the data unit to be written.

[0116] S3, if it is determined from the write status information that there is data containing the mapping relationship at the target location, write the data unit to the target location to update the mapping relationship.

[0117] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0118] Embodiments of this application also provide an electronic device, such as... Figure 10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps of any of the above method embodiments via the computer program.

[0119] Optionally, in this embodiment, the processor 1004 may be configured to perform the following steps via a computer program:

[0120] S1, Obtain the data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate the mapping relationship.

[0121] S2, read the write status information of the mapping relationship in the data block; wherein, the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool of the data unit to be written.

[0122] S3, if it is determined from the write status information that there is data containing the mapping relationship at the target location, write the data unit to the target location to update the mapping relationship.

[0123] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0124] Alternatively, as those skilled in the art will understand, Figure 10 The structure shown is for illustrative purposes only. Figure 10This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 10 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 10 The different configurations shown.

[0125] The memory 1002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the data writing method and data writing device in this embodiment. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, thereby implementing the aforementioned data writing method. The memory 1002 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include memory remotely located relative to the processor 1004, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1002 may be used, but is not limited to, to store information such as system configuration files. As an example, such as... Figure 10 As shown, the memory 1002 may include, but is not limited to, the data acquisition module 901, information reading module 902, and data writing module 903 in the data writing device described above. Furthermore, it may include, but is not limited to, other module units in the data writing device described above, which will not be elaborated upon in this example.

[0126] Optionally, the transmission device 1006 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1006 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one example, the transmission device 1006 is a radio frequency (RF) device.

[0127] The Frequency (RF) module is used to communicate with the Internet wirelessly.

[0128] In addition, the above-mentioned electronic device also includes: a display 1008; and a connection bus 1010 for connecting the various module components in the above-mentioned electronic device.

[0129] In other embodiments, the aforementioned electronic device can be a node in a distributed system, which can be a blockchain system. This blockchain system is formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any type of computing device, such as a server or terminal, can become a node in the blockchain system by joining this peer-to-peer network.

[0130] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0131] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0132] The embodiments described herein also provide a computer program that includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps in any of the above method embodiments.

[0133] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0134] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A method for writing data, characterized in that, The method includes: Obtain a data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate a mapping relationship; Read the write status information of the mapping relationship in the data block; wherein, the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool to be written to the data unit; If it is determined that the write status information of the mapping relationship in the data block does not exist, initial extended data is added to the data block, wherein the extended data is used to record the write status information of the data block, and each bit in the initial extended data is in a first state; The data block is divided into multiple data units; The extended data is divided into multiple sub-extended data, wherein the number of the multiple sub-extended data is the same as the number of the multiple data units, and each sub-extended data includes at least one bit. Write the first data unit among the plurality of data units into the storage pool, wherein the first data unit is any one of the plurality of data units; After the first data unit is written into the storage pool, the first position of the first data unit in the storage pool is determined; Based on the first position of the first data unit in the storage pool, a first sub-extended data corresponding to the first position is determined from the plurality of sub-extended data, wherein the first sub-extended data is used to indicate whether there is data containing the mapping relationship at the first position of the storage pool; The state of the bits of the first sub-extended data is modified to a second state, wherein the second state is different from the first state; Determine whether all of the data units have been written to the storage pool; If it is determined that there is at least one second data unit among the plurality of data units that has not been written to the storage pool, one of the second data units is taken as a new first data unit and the step of writing the first data unit among the plurality of data units to the storage pool is returned until all the plurality of data units are written to the storage pool. After all the data units are written to the storage pool, the write status information of the mapping relationship in the data block is obtained according to the sub-extended data corresponding to each of the data units. If, based on the write status information, it is determined that the target location contains data with the mapping relationship, the data unit is written to the target location to update the mapping relationship. Specifically, if it is determined that the target location contains data with the mapping relationship, this write of the data unit is an overwrite write, and the mapping relationship of the target location is updated. If it is determined that the target location does not contain data with the mapping relationship, this write of the data unit is an append write, and the mapping relationship of the target location is added.

2. The data writing method according to claim 1, characterized in that, After reading the write status information of the mapping relationship in the data block, the method further includes: If, based on the write status information, it is determined that no data containing the mapping relationship exists at the target location, the data unit is written to the target location to add the mapping relationship at the target location.

3. The data writing method according to claim 2, characterized in that, After writing the data unit to the target location when it is determined from the write status information that no data containing the mapping relationship exists at the target location, the method further includes: Update the write status information of the target location, wherein the updated write status information of the target location is used to indicate that the target location contains data containing the mapping relationship.

4. The data writing method according to claim 2, characterized in that, The method further includes: When updating the mapping relationship of the target location, the capacity of the storage pool is determined to remain unchanged; When the mapping relationship is added at the target location, the capacity of the storage pool is updated according to the size of the added data unit.

5. The data writing method according to any one of claims 1-4, characterized in that, The mapping relationship is at least one of a forward relationship and a reverse relationship, wherein the forward relationship is the relationship between the business objects of the storage pool and the internal objects, and the reverse relationship is the relationship between the internal objects of the storage pool and the business objects.

6. The data writing method according to any one of claims 1-4, characterized in that, After writing the data unit to the target location to update the mapping relationship, the method further includes: Record the write status information of the target location; The corresponding transmission interface is invoked to store the write status information of the target location into the storage pool.

7. A data writing device, characterized in that, The device includes: A data acquisition module is used to acquire a data block to be written, wherein the data block includes at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used to indicate a mapping relationship; An information reading module is used to read the write status information of the mapping relationship in the data block; wherein the write status information is used to indicate whether there is data containing the mapping relationship at the target location of the storage pool to be written to the data unit; if it is determined that the write status information of the mapping relationship in the data block does not exist, initial extended data is added to the data block, wherein the extended data is used to record the write status information of the data block, and each bit in the initial extended data is a first state; the data block is divided into multiple data units; the extended data is divided into multiple sub-extended data, wherein the number of the multiple sub-extended data is the same as the number of multiple data units, and each sub-extended data includes at least one bit; a first data unit among the multiple data units is written to the storage pool, wherein the first data unit is any one of the multiple data units; after the first data unit is written to the storage pool, it is determined that the first data unit is in the storage pool. A first location in the storage pool; based on the first location of the first data unit in the storage pool, determining a first sub-extended data corresponding to the first location among the plurality of sub-extended data, wherein the first sub-extended data is used to indicate whether there is data containing the mapping relationship at the first location of the storage pool; modifying the state of the bits of the first sub-extended data to a second state, wherein the second state is different from the first state; determining whether all of the plurality of data units have been written to the storage pool; if it is determined that there is at least one second data unit among the plurality of data units that has not been written to the storage pool, taking one of the second data units as a new first data unit and returning to execute the step of writing the first data unit among the plurality of data units to the storage pool, until all of the plurality of data units have been written to the storage pool; after all of the plurality of data units have been written to the storage pool, obtaining the write status information of the mapping relationship in the data block according to the sub-extended data corresponding to the plurality of data units respectively; The data writing module is used to write the data unit to the target location to update the mapping relationship when it is determined from the writing status information that data containing the mapping relationship exists at the target location. Specifically, if it is determined that data containing the mapping relationship exists at the target location, this data unit write is an overwrite write, and the mapping relationship at the target location is updated. If it is determined that data containing the mapping relationship does not exist at the target location, this data unit write is an append write, and the mapping relationship at the target location is added.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 6.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 6.