Data writing method and device, storage medium and electronic equipment

By using data units smaller than the preset size and write status information in a distributed storage system, the update process of mapping relationships is optimized, the problem of excessive consumption of computing resources is solved, the writing efficiency is improved, and the computing resources are saved.

CN119292529AActive Publication Date: 2025-01-10JINAN INSPUR DATA TECH CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411388124.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-01-10
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

When the prior art updates the mapping relationship in a distributed storage system, there are a large number of data reading and writing operations, resulting in excessive consumption of computing resources.

Method used

By obtaining data units smaller than the preset size, reading the write status information in the data block, determining whether there is a mapping relationship in the target position, and writing data only when necessary, reducing unnecessary data reading and writing.

Benefits of technology

Improve data writing efficiency, save computing resources, avoid the need to read mapping relationships in the storage pool, and reduce computing resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292529A_ABST
    Figure CN119292529A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data writing method and device, a computer readable storage medium and electronic equipment, and relates to the field of computers.The method comprises the steps that a to-be-written data block is obtained, the data block comprises at least one data unit, the size of the data unit is smaller than a preset size, and the data unit is used for indicating a mapping relation; reading write-in state information of the mapping relation in the data block; wherein the write-in state information is used for indicating whether data containing a mapping relation exists at a target position of a storage pool of the data unit to be written in; and writing the data unit into the target position to update the mapping relation under the condition of determining that the data containing the mapping relation exists in the target position according to the writing state information. Whether the data containing the mapping relation exists in the target position of the storage pool or not can be conveniently and rapidly recognized through the write-in state information, the mapping relation in the storage pool does not need to be read, the reading action is omitted, and computing resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and more specifically, to a method and device for writing data, a computer-readable storage medium, and an electronic device. Background Art

[0002] With the rapid development of science and technology, the amount of data on the Internet is becoming larger and larger, and at the same time, the data is constantly updated. In order to cope with the scenario of massive data, distributed storage systems are gradually being widely used. Distributed storage systems usually use mapping relationships to map data objects to physical locations on storage media to achieve data storage. However, with the rapid update of data and the existence of a large number of business objects in distributed storage systems, mapping relationships also need to be frequently updated.

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

[0004] However, in the prior art, a large number of data reading and writing operations are involved in the process of updating the mapping relationship, which consumes too much computing resources. Summary of the invention

[0005] The embodiments of the present application provide a method, device, computer-readable storage medium and electronic device for writing data, which can:

[0006] According to one embodiment of the present application, a method for writing data is provided, the method comprising: obtaining a data block to be written, wherein the data block comprises 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 data containing the mapping relationship exists at a target location of a storage pool to which the data unit is to be written; and when it is determined according to the write status information that data containing the mapping relationship exists 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: when it is determined according to the write status information that no data containing the mapping relationship exists 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, when it is determined according to the write status information that the target location does not contain data containing the mapping relationship, after writing the data unit to 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 the target location contains data containing the mapping relationship.

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

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

[0011] When 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 the first state;

[0012] Dividing the data block into a plurality of the data units;

[0013] Dividing the extended data into a plurality of sub-extended data, wherein the number of the plurality of sub-extended data is the same as the number of the plurality of data units, and each of the sub-extended data includes at least one bit;

[0014] Writing a first data unit among the multiple data units into the storage pool, wherein the first data unit is any one of the multiple data units;

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

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

[0017] modifying a state of a bit of the first sub-extension data to a second state, wherein the second state is different from the first state;

[0018] Determining whether the plurality of data units have all been written into the storage pool;

[0019] In the case of determining that there is at least one second data unit that has not been written into the storage pool among the plurality of data units, taking one of the second data units as a new first data unit and returning to the step of writing the first data unit among the plurality of data units into the storage pool until all the plurality of data units are written into the storage pool;

[0020] After the plurality of data units are written into the storage pool, the write status information of the mapping relationship in the data block is obtained according to the sub-extended data respectively corresponding to the plurality of 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 object of the storage pool and the internal object, and the reverse relationship is the relationship between the internal object of the storage pool and the business object.

[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; 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 device for writing data is further provided, the device comprising:

[0024] A data acquisition module, used for acquiring 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 for indicating a mapping relationship;

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

[0026] A data writing module is used to write the data unit into the target location to update the mapping relationship when it is determined according to the writing status information that the data containing the mapping relationship exists in the target location.

[0027] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0028] According to another embodiment of the present application, an electronic device is 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 execute the steps in any one of the above method embodiments.

[0029] According to another embodiment of the present application, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0030] According to the data writing method of the present application, firstly, a data block to be written is obtained, the data block includes at least one data unit, the size of the data unit is smaller than the preset size, and the data unit is used to indicate the mapping relationship, so that when the mapping relationship needs to be written or updated, the mapping relationship is written or updated in units of data units. Since the data unit is small, only a small amount of data can be written, reducing unnecessary data reading and writing. Then, the writing status information of the mapping relationship in the data block is read, and the writing status information is used to indicate whether the target position of the storage pool of the data unit to be written contains data of the mapping relationship, so that by introducing the writing status information in the data block, the system can quickly identify whether the target position of the storage pool contains data of the mapping relationship, without reading the existing mapping relationship in the storage pool. In the case of determining that the target position contains data of the mapping relationship according to the writing status information, the data unit is written to the target position to update the mapping relationship. In summary, the method of the present application adopts a data unit smaller than the preset size as a unit for data processing, and when writing data, only a small part of the data can be processed for the required position, thereby improving the writing efficiency and saving computing resources. On the other hand, by writing the status information, it is convenient and quick to identify whether there is data containing a mapping relationship at the target location of the storage pool, without having to read the mapping relationship in the storage pool, thus eliminating the need for reading and saving computing resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

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

[0033] Figure 2 is a flow chart of a method for writing data according to an embodiment of the present application;

[0034] Figure 3This is a second flow chart of a method for writing data according to an embodiment of the present application;

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

[0036] Figure 5 is a flow chart of a method for updating the capacity of a storage pool according to an embodiment of the present application;

[0037] Figure 6 This is a fourth flowchart of a method for writing data according to an embodiment of the present application;

[0038] Figure 7 is a fifth flow chart of a method for writing data according to an embodiment of the present application;

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

[0040] Fig. 9 is a structural block diagram of a data writing device according to an embodiment of the present application;

[0041] Fig.10 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

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

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

[0044] The data writing method embodiment provided in the embodiment of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a method for writing data in an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0045] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method of data writing in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0046] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

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

[0048] Step S200, obtaining a data block to be written.

[0049] 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, that is, the data unit is data used to record the mapping relationship.

[0050] Exemplarily, the preset size may be 8KB, 64KB, 512KB, etc., and may be selected according to actual conditions, and is preferably 8KB.

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

[0052] It should be noted that, taking the mapping relationship as a forward relationship as an example, in a distributed storage system, due to the presence of a large number of business objects in the storage system, the update of the forward relationship may be very frequent. In some related technologies, the forward relationship is stored and managed in a batch manner, such as shard storage, and the size of each shard may be at the MB level. Therefore, when the forward relationship is updated and written, it is performed in units of one shard, and the operation data of the forward relationship of the entire shard needs to be read and written, which consumes too much computing resources. In this embodiment, a data unit can be used as a unit to update and write the forward relationship. The data unit is much smaller than the shard, so the required computing resources are smaller.

[0053] Step S210, reading 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 where the data unit is to be written.

[0055] Among them, the writing status information of the mapping relationship can be added to the attribute information (attrs) of the data block. The writing status information can be in the form of a bitmap (bitmap). The writing status information records whether the target location in the storage pool where the data unit in the data block is to be written already has data containing the mapping relationship. Therefore, it is not necessary to read the mapping relationship information in the storage pool, and it is possible to quickly determine whether the target location of the storage pool where the data unit to be written has data containing the mapping relationship, so as to quickly determine whether the current writing of the data unit is an append write or an overwrite write. This is crucial for accurately managing and updating the capacity of the storage pool, because only by knowing exactly which data blocks are newly written or modified can the storage resources be correctly adjusted.

[0056] For example, taking a data unit of 8KB in size as an example, the bitmap includes multiple bits, each bit representing whether a positive relationship already exists in the corresponding 8kB position of a data unit. In other words, the bitmap is used to mark whether a positive relationship has been established for each 8KB data unit, so that the system can quickly determine which data blocks contain valid data when processing a read request. Secondly, because the bitmap provides direct and immediate information, the system does not need to read the metadata of the entire storage pool every time to determine the positive relationship, reducing the consumption of computing resources.

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

[0058] Step S220 , when it is determined according to the write status information that data containing a mapping relationship exists at the target location, the data unit is written into the target location to update the mapping relationship.

[0059] Specifically, when it is determined that data containing a mapping relationship exists at the target location, it means that the writing of the data unit this time is an overwrite write, and the mapping relationship data at the target location is updated.

[0060] In this embodiment, firstly, a data block to be written is obtained, the data block includes at least one data unit, the size of the data unit is smaller than the preset size, and the data unit is used to indicate the mapping relationship, so that when the mapping relationship needs to be written or updated, the mapping relationship is written or updated in units of data units. Since the data unit is small, only a small amount of data can be written, reducing unnecessary data reading and writing. Then, the write status information of the mapping relationship in the data block is read, and the write status information is used to indicate whether the target position of the storage pool of the data unit to be written contains data of the mapping relationship, so that by introducing the write status information in the data block, the system can quickly identify whether the target position of the storage pool contains data of the mapping relationship, without reading the existing mapping relationship in the storage pool. In the case of determining that the target position contains data of the mapping relationship according to the write status information, the data unit is written to the target position to update the mapping relationship. In summary, the method of the present application adopts a data unit smaller than the preset size as a unit for data processing, and when writing data, only a small amount of data can be processed for the required position, thereby improving the writing efficiency and saving computing resources. On the other hand, by writing the status information, it is convenient and quick to identify whether there is data containing a mapping relationship at the target location of the storage pool, without having to read the mapping relationship in the storage pool, thus eliminating the need for reading and saving computing resources.

[0061] In one embodiment, Figure 3 As shown, in step S210, the writing status information of the mapping relationship in the data block is read. Afterwards, the data writing method further includes: step S230, when it is determined according to the writing status information that the target position does not contain data containing the mapping relationship, writing the data unit to the target position to add the mapping relationship to the target position.

[0062] If it is determined according to the write status information that the target position does not contain data containing a mapping relationship, it means that the data unit written this time is an additional write, so a mapping relationship is added to the target position.

[0063] In this embodiment, if it is determined that the target position does not contain data containing a mapping relationship, an additional data unit is written at the target position to indicate the mapping relationship, thereby implementing additional writing of the mapping relationship.

[0064] In one embodiment, Figure 4 As shown, in step S230, when it is determined according to the write status information that the target location does not contain data containing a mapping relationship, the data unit is written to the target location to add a mapping relationship to the target location. Afterwards, the data writing method further includes: step S240, updating the write status information of the target location.

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

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

[0067] In this embodiment, after the data unit is written to the target location, since the target location has never had data containing a mapping relationship but now has data containing a mapping relationship, the write status information corresponding to the target location also needs to be updated so that it can subsequently be quickly and accurately identified whether the target location has data containing a mapping relationship based on the write status information.

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

[0069] Step S500: When the mapping relationship of the target location is updated, 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 is not changed, so the capacity of the storage pool is determined to be unchanged.

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

[0072] In the case where a mapping relationship is added to the target location, it means that data of the mapping relationship is newly added to the target location, and the total capacity of the storage pool is changed, so the capacity of the storage pool needs to be updated based on the increased data volume.

[0073] In this embodiment, the change in the capacity of the storage pool can be accurately identified based on whether the mapping relationship of the target location is updated or a mapping relationship is added to the target location, so that the capacity of the storage pool can be accurately managed and updated, and storage resources can be accurately adjusted.

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

[0075] Step S600: when 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.

[0076] 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 the first state. The write status information can be in the form of a bitmap, including multiple bits. When it is determined that the write status information of the mapping relationship in the data block does not exist, each bit can be initialized to be in the first state of 0, indicating that the write positions corresponding to all data units in the data block have not been recorded with the write status information.

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

[0078] Among them, the data block can be divided into multiple data units, so that when the mapping relationship is updated and written, one data unit can be used as a 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 (for example, 8KB), the required computing resources are relatively small.

[0079] Step S620: Divide the extended data into a plurality of sub-extended data.

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

[0081] Step S630: write a first data unit among the multiple data units into a 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 into the storage pool, determine a 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-extension data corresponding to the first position from the plurality of sub-extension data.

[0085] The first sub-extension data is used to indicate whether there is data containing a mapping relationship at the first position of the storage pool.

[0086] Specifically, in the bitmap of the write status information, the bit of each position corresponds to a position in the storage pool, so 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, that is, the first sub-extension data corresponding to the first position is determined among the multiple sub-extension data.

[0087] Step S660: modify the state of the bits of the first sub-extension data to a second state.

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

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

[0090] Step S680: If it is determined that there is at least one second data unit that has not been written into the storage pool among the multiple data units, use the second data unit as a new first data unit, and return to step S630.

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

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

[0093] In this embodiment, when new data is written into the storage pool, the state of the corresponding bit in the write status information (bitmap) is modified according to the position of the written data while writing, so the position of the written data unit is recorded. Therefore, when the data block is written for the first time, the write status information is recorded, which is convenient for rapid positioning and identification when writing again later, improving the efficiency of data writing and saving computing resources.

[0094] In one embodiment, Figure 7 As shown, in step S220, when it is determined according to the write status information that the target location has data containing a mapping relationship, the data unit is written into the target location to update the mapping relationship. Afterwards, the data writing method further includes: steps S700-S710.

[0095] Step S700, recording the write status information of the target location.

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

[0097] For example, Figure 8 As shown, the storage system includes a cache placement group (Cache Placement Group, CachePG), which refers to a part of the data in the storage system, which is placed in a cache layer close to the computing resources for faster data access and processing. The storage backend (Bluestore) can call data blocks and store data blocks in the storage system (RockSDB). If the write status information of the mapping relationship in the data block does not exist, the data is written and the write status information is recorded and generated, that is, the data block is written, and the corresponding write status information is generated, and then the data unit and the write status information are stored on the disk. If the write status information of the mapping relationship in the data block exists, it is determined whether there is data in the target write position. If there is no data, the data is written and the write status information is updated, and then the data unit and the write status information are stored on the disk. The content of the specific data writing has been described in detail in the above embodiment and will not be repeated.

[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 and in a storage pool so that it can be quickly located and identified when it is written again later, thereby improving the efficiency of data writing and saving computing resources.

[0099] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0100] In the present embodiment, a device for data writing is also provided to implement the above-mentioned embodiments and preferred implementation modes, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the modules described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.

[0101] Fig. 9 : is a structural block diagram of a data writing device according to an embodiment of the present application, the device 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 the data unit to the target location to update the mapping relationship when it is determined according to the writing status information that there is data containing the mapping relationship at the target location.

[0105] The above device first obtains a data block to be written, the data block includes at least one data unit, the size of the data unit is smaller than the preset size, and the data unit is used to indicate the mapping relationship, so that when the mapping relationship needs to be written or updated, the mapping relationship is written or updated in units of data units. Since the data unit is small, only a small amount of data can be written, reducing unnecessary data reading and writing. Then read the write status information of the mapping relationship in the data block, the write status information is used to indicate whether the target position of the storage pool of the data unit to be written contains data containing the mapping relationship, so that by introducing the write status information in the data block, the system can quickly identify whether the target position of the storage pool contains data containing the mapping relationship, without reading the existing mapping relationship in the storage pool. In the case of determining that the target position contains data containing the mapping relationship according to the write status information, the data unit is written to the target position to update the mapping relationship. In summary, the method of the present application, on the one hand, uses a data unit smaller than the preset size as a unit for data processing, and when writing data, only a small amount of data can be processed for the required position, thereby improving writing efficiency and saving computing resources. On the other hand, by writing the status information, it is convenient and quick to identify whether there is data containing a mapping relationship at the target location of the storage pool, without having to read the mapping relationship in the storage pool, thus eliminating the need for reading and saving computing resources.

[0106] In an exemplary embodiment, the apparatus is further configured to write the data unit to the target location, so as to add the mapping relationship to the target location, when it is determined according to the write status information that the target location does not contain data containing the mapping relationship.

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

[0108] In an exemplary embodiment, the above-mentioned device is also used to determine that the capacity of the storage pool remains unchanged when the mapping relationship of the target location is updated; when the mapping relationship of the target location is increased, the capacity of the storage pool is updated according to the size of the increased data unit.

[0109] In an exemplary embodiment, the above-mentioned device is also used to add initial extended data to the data block when it is determined that the write status information of the mapping relationship in the data block does not exist, 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 the first state; divide the data block into multiple data units; divide the extended data 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 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 first data unit in the storage pool a first position, determining first sub-extension data corresponding to the first position from among the plurality of sub-extension data, wherein the first sub-extension data is used to indicate whether data containing a mapping relationship exists at the first position of the storage pool; modifying a bit state of the first sub-extension data to a second state, wherein the second state is different from the first state; determining whether the plurality of data units have all been written into the storage pool; in the case of determining that there is at least one second data unit that has not been written into the storage pool among the plurality of data units, taking the second data unit as a new first data unit and returning to execute the step of writing the first data unit among the plurality of data units into the storage pool until the plurality of data units are all written into the storage pool; after the plurality of data units are all written into the storage pool, obtaining write state information of the mapping relationship in the data block according to the sub-extension data respectively corresponding to the plurality of data units.

[0110] In an exemplary embodiment, the above-mentioned device is also used to record the write status information of the target location; 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, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0112] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0113] Optionally, in this embodiment, the computer program may be configured to perform the following steps by means of the computer program:

[0114] S1, 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.

[0115] S2, reading 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, when it is determined according to the write status information that data containing a mapping relationship exists at the target location, write the data unit to the target location to update the mapping relationship.

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

[0118] The embodiment of the present application also provides an electronic device, such as Fig.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 in any of the above method embodiments through the computer program.

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

[0120] S1, 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.

[0121] S2, reading 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, when it is determined according to the write status information that data containing a mapping relationship exists at the target location, write the data unit to the target location to update the mapping relationship.

[0123] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0124] Alternatively, a person skilled in the art may understand that: Fig.10 The structure shown is for illustration only. Fig.10The structure of the electronic device is not limited. For example, the electronic device may also include Fig.10 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.10 Different configurations are shown.

[0125] Among them, the memory 1002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method for writing data and the device for writing data in the embodiments of the present application. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, that is, realizing the above-mentioned method for writing data. The memory 1002 may include a high-speed random access memory, and may also include a 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 a memory remotely arranged relative to the processor 1004, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1002 may be specifically, but not limited to, used to store information such as system configuration files. As an example, such as Fig.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. In addition, other module units in the data writing device may also be included but are not limited to the other modules in the data writing device, which will not be described in detail in this example.

[0126] Optionally, the transmission device 1006 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers 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)

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

[0128] In addition, the electronic device further includes: a display 1008; and a connection bus 1010, which is used to connect various module components in the electronic device.

[0129] In other embodiments, the electronic device may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes in the form of network communication. Among them, the nodes may form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.

[0130] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0131] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0132] The embodiments of the present application also provide a computer program, which includes computer instructions, which are 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 performs the steps of any one of the above method embodiments.

[0133] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0134] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for writing data, characterized in that: The method comprises: 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; 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 of the storage pool to be written into the data unit; When it is determined according to the write status information that data including the mapping relationship exists at the target location, the data unit is written into the target location to update the mapping relationship.

2. The method for writing data 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: When it is determined according to the write status information that the target location does not have data including the mapping relationship, the data unit is written into the target location to add the mapping relationship into the target location.

3. The method for writing data according to claim 2, characterized in that: In the case where it is determined according to the write status information that the target location does not contain data containing the mapping relationship, after writing the data unit to the target location, the method further includes: The write status information of the target location is updated, 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.

4. The method for writing data according to claim 2, characterized in that: The method further comprises: In case of updating the mapping relationship of the target location, determining that the capacity of the storage pool remains unchanged; In the case where the mapping relationship is added to the target location, the capacity of the storage pool is updated according to the size of the added data unit.

5. The method for writing data 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: When 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 the first state; Dividing the data block into a plurality of the data units; Dividing the extended data into a plurality of sub-extended data, wherein the number of the plurality of sub-extended data is the same as the number of the plurality of data units, and each of the sub-extended data includes at least one bit; Writing a first data unit among the multiple data units into the 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, determining a first position of the first data unit in the storage pool; determining, based on a first position of the first data unit in the storage pool, first sub-extension data corresponding to the first position from among the plurality of sub-extension data, wherein the first sub-extension data is used to indicate whether data containing the mapping relationship exists at the first position of the storage pool; modifying a state of a bit of the first sub-extension data to a second state, wherein the second state is different from the first state; Determining whether the plurality of data units have all been written into the storage pool; In the case of determining that there is at least one second data unit that has not been written into the storage pool among the plurality of data units, taking one of the second data units as a new first data unit and returning to the step of writing the first data unit among the plurality of data units into the storage pool until all the plurality of data units are written into the storage pool; After the plurality of data units are written into the storage pool, the write status information of the mapping relationship in the data block is obtained according to the sub-extended data respectively corresponding to the plurality of data units.

6. The method for writing data according to any one of claims 1 to 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 object of the storage pool and the internal object, and the reverse relationship is the relationship between the internal object of the storage pool and the business object.

7. The method for writing data according to any one of claims 1 to 4, characterized in that: 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; The corresponding transmission interface is called to store the write status information of the target location in the storage pool.

8. A data writing device, characterized in that: The device comprises: A data acquisition module, used for acquiring 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 for indicating 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 into the data unit; and a data writing module is used to write the data unit to the target location to update the mapping relationship when it is determined according to the write status information that there is data containing the mapping relationship at the target location.

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

10. 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, the steps of the method described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Dynamic strip system design method based on RAID5 solid-state disk array

    CN108958656A

  • Data processing method, device, equipment and storage medium

    CN111381779A

  • Storage space management method and device, equipment, medium and program product

    CN113254365A

  • Double-storage-pool data writing processing method and device, equipment and medium

    CN114442956A

  • Redirection-on-write snapshot implementation method and device, equipment and storage medium

    CN115033174A