Data storage method and device, equipment and medium

By recording and reusing the vacancies in the data storage blocks of the distributed storage cluster, the problems of high system garbage rate and short disk life are solved, and the effect of reducing garbage collection frequency and improving disk life is achieved.

CN119718162APending Publication Date: 2025-03-28BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311249723.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-26
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In distributed storage clusters, space occupation caused by the deletion of invalid objects leads to a high system garbage rate, and frequent garbage collection operations are required, which increases the disk's read and write load and reduces the disk's life.

Method used

Set a preset list record in the data storage block to multiplex the vacancies, and when executing data writing instructions, the physical location of the vacancies can be multiplexed in the recorded data storage block to reduce the proportion of garbage collection and reduce the frequency of read and write operations.

Benefits of technology

Without affecting the read and write performance of the front desk, the proportion of garbage collection is greatly reduced, the read and write operations during the garbage collection process is reduced, and the disk life is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718162A_ABST
    Figure CN119718162A_ABST
Patent Text Reader

Abstract

The invention relates to a data storage method and device, equipment and a medium. The data storage method comprises the steps that a data writing instruction sent by a user side is received, and the data length of first data corresponding to the data writing instruction is determined; determining a target position for storing the first data in the data storage block from a preset list based on the data length, wherein the preset list is a list for recording reusable vacancies in the data storage block; and executing the write-in operation corresponding to the data write-in instruction, and writing the first data into the target position, so that the preset list can be set in the data storage block to record the reusable vacancy, and when the data write-in instruction is executed, the physical position of the reusable vacancy in the recorded data storage block is reused, thereby greatly reducing the garbage collection proportion, and improving the garbage collection efficiency. The read-write operation in the garbage collection process is reduced, and meanwhile the service life of a disk is prolonged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a data storage method, apparatus, device, and medium. Background Art

[0002] A distributed storage cluster is usually composed of several servers, where each distributed storage data node in the distributed storage cluster corresponds to a server. Each data node, i.e., server, contains at least one disk. Each data set shard on each disk is called a data storage block, i.e., a block. Each data storage block can contain multiple objects, i.e., objects. For each object, when the object is deleted from the data storage block where it is located, the object is determined to be an invalid object. Although the invalid object has been deleted, the vacant space corresponding to the invalid object still occupies the physical space in the data storage block, which causes a high garbage rate in the system.

[0003] Therefore, in order to maintain a low garbage rate in the system, garbage collection operations need to be performed frequently to release the physical space occupied by the vacancies corresponding to invalid objects in the data storage block. However, when garbage collection operations are performed frequently, a large number of read and write operations need to be performed. The read and write amplification caused to the disk is uncontrollable, and the life of the disk is greatly reduced. Summary of the Invention

[0004] In order to solve the above technical problems, the present disclosure provides a data storage method, apparatus, device and medium.

[0005] A first aspect of an embodiment of the present disclosure provides a data storage method, which is applied to any data node in a distributed storage cluster, wherein the data node includes at least one data storage block, and the at least one data storage block has a slot multiplexing function, including:

[0006] receiving a data write instruction sent by a user terminal, and determining a data length of first data corresponding to the data write instruction;

[0007] Determining a target location for storing the first data in the data storage block from a preset list based on the data length, where the preset list is a list for recording reusable spaces in the data storage block;

[0008] A write operation corresponding to the data write instruction is executed to write the first data into the target location.

[0009] A second aspect of an embodiment of the present disclosure provides a data storage device, which is applied to any data node in a distributed storage cluster. The data node includes at least one data storage block, and the at least one data storage block has a slot multiplexing function, including:

[0010] A first determining module is configured to receive a data write instruction sent by a user terminal and determine a data length of first data corresponding to the data write instruction;

[0011] a second determining module, configured to determine a target location for storing the first data in the data storage block from a preset list based on the data length, the preset list being a list for recording reusable spaces in the data storage block;

[0012] The instruction execution module is used to execute a write operation corresponding to the data write instruction to write the first data into a target location.

[0013] A third aspect of the present disclosure provides an electronic device, including:

[0014] processor;

[0015] a memory for storing executable instructions;

[0016] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the data storage method provided in the first aspect above.

[0017] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the data storage method provided by the first aspect.

[0018] A fifth aspect of an embodiment of the present disclosure provides a vehicle, which includes the electronic device provided by the third aspect.

[0019] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:

[0020] The data storage method, apparatus, device and medium provided by the embodiments of the present disclosure can receive a data write instruction sent by a user end, determine the data length of the first data corresponding to the data write instruction, and determine the target position for storing the first data in the data storage block from a preset list based on the data length. The preset list is a list for recording reusable spaces in the data storage block, and a write operation corresponding to the data write instruction is executed to write the first data to the target position. Thus, a preset list can be set in the data storage block to record reusable spaces, and when executing the data write instruction, the physical position of the reusable spaces in the recorded data storage block can be reused. Without affecting the read and write performance of the read and write instructions sent by the foreground, i.e., the user end, the proportion of garbage collection is greatly reduced, the read and write operations during the garbage collection process are reduced, and the life of the disk is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0022] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0023] Figure 1 is a flow chart of a data storage method provided by an embodiment of the present disclosure;

[0024] Figure 2 is a flow chart of another data storage method provided by an embodiment of the present disclosure;

[0025] Figure 3 is a structural diagram of a data storage device provided by an embodiment of the present disclosure;

[0026] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0030] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0031] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0032] Figure 1 This is a flowchart of a data storage method provided by an embodiment of the present disclosure. The method can be executed by a data storage device, which can be implemented in software and / or hardware. The data storage device can be configured in an electronic device, such as a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer, etc.

[0033] like Figure 1 As shown, the data storage method provided in the embodiment of the present disclosure can be applied to any data node in a distributed storage cluster, and the data node includes at least one disk, wherein each disk includes at least one data storage block, and at least one data storage block has a space multiplexing function. For each data storage block in each data node, the data storage method in the embodiment of the present disclosure can be used to perform data storage processing, wherein the disk can be a solid state disk (SSD). Specifically, the data storage method provided in this embodiment includes the following steps.

[0034] S110: Receive a data write instruction sent by a user terminal, and determine the data length of first data corresponding to the data write instruction.

[0035] In an embodiment of the present disclosure, the electronic device receives a data write instruction sent by the user terminal in real time. After receiving the data write instruction, the electronic device parses the data write instruction, determines the first data to be written in the data write instruction, and determines the data length of the first data.

[0036] S120: Determine a target location for storing the first data in the data storage block from a preset list based on the data length, where the preset list is a list for recording reusable spaces in the data storage block.

[0037] In an embodiment of the present disclosure, after determining the data length of the first data, the electronic device determines the target location for storing the first data in the data storage block from a preset list based on the data length. The preset list is a list for recording reusable spaces in the data storage block.

[0038] The preset list is a list pre-set in the electronic device for recording reusable spaces in the data storage block.

[0039] Reusable slots can be understood as the spaces left by deleted objects in a data storage block. These spaces can be reused by new data to be written. These objects can be understood as a piece of data in a data storage block.

[0040] Specifically, after determining the data length of the first data, the electronic device determines a target position that can be used to store the first data from the reusable spaces recorded in a preset list based on the data length of the first data, wherein the target position that can be used to store the first data is the position corresponding to the reusable space whose space length is greater than or equal to the data length of the first data.

[0041] S130 , executing a write operation corresponding to the data write instruction, and writing the first data into the target location.

[0042] In the disclosed embodiment, after determining a target location for storing the first data, the electronic device executes a write operation corresponding to the data write instruction to write the first data to the target location. The specific implementation of the write operation is similar to the existing implementation of the data write operation and is not further described here.

[0043] In an embodiment of the present disclosure, it is possible to receive a data write instruction sent by a user terminal, determine the data length of the first data corresponding to the data write instruction, determine the target position for storing the first data in the data storage block from a preset list based on the data length, the preset list is a list for recording reusable spaces in the data storage block, execute a write operation corresponding to the data write instruction, and write the first data to the target position. Thus, a preset list can be set in the data storage block to record reusable spaces, and when executing the data write instruction, the physical position of the reusable spaces in the recorded data storage block can be reused, without affecting the read and write performance of the read and write instructions sent by the foreground, i.e., the user terminal, thereby greatly reducing the proportion of garbage collection, reducing the read and write operations during the garbage collection process, and at the same time improving the life of the disk.

[0044] Based on the above-mentioned embodiments of the present disclosure, S120 determines the target position for storing the first data in the data storage block from a preset list based on the data length, which may specifically include: comparing the data length with the length of at least one reusable space in the preset list; determining a target reusable space in at least one reusable space whose space length is greater than or equal to the data length; and determining the target position for storing the first data based on the position corresponding to the target reusable space.

[0045] Specifically, the electronic device compares the data length of the first data with the length of each reusable space in a preset list, filters out the target reusable space whose length is greater than or equal to the data length of the first data, and determines the target position for storing the first data based on the position corresponding to the target reusable space.

[0046] In some embodiments of the present disclosure, when there is only one target reusable space, determining the target position for storing the first data based on the position corresponding to the target reusable space includes: determining the position corresponding to the target reusable space as the target position for storing the first data.

[0047] In other embodiments of the present disclosure, when there are multiple target reusable spaces, the target position for storing the first data is determined based on the position corresponding to the target reusable space, including: for each target reusable space in the multiple target reusable spaces, calculating the difference between the space length and the data length of the target reusable space; screening out the reusable space with the smallest difference between the space length and the data length from the multiple target reusable spaces; and determining the position corresponding to the reusable space with the smallest difference as the target position.

[0048] Specifically, when there are multiple target reusable slots, the electronic device can find the most suitable reusable slot, that is, the reusable slot with the smallest difference, based on the difference between the slot length and the data length of each reusable slot, and determine the position corresponding to the reusable slot with the smallest difference as the target position.

[0049] In this way, the most suitable reusable space can be found from multiple target reusable spaces, which not only reuses the reusable space but also further avoids the unreasonable use of the space and improves the life of the disk corresponding to the data storage block.

[0050] Figure 2 is a flow chart of another data storage method provided by an embodiment of the present disclosure, such as Figure 2 As shown, the data storage method may specifically include:

[0051] S210: After receiving the data deletion instruction sent by the user terminal, execute the data deletion operation corresponding to the data deletion instruction to delete the second data corresponding to the data deletion instruction from the data storage block.

[0052] In the embodiment of the present disclosure, the specific implementation of the data deletion operation performed by the electronic device after receiving the data deletion instruction sent by the user terminal is similar to the implementation of the existing data deletion operation, and will not be repeated here.

[0053] After the second data corresponding to the data deletion instruction is deleted from the data storage block, the position corresponding to the second data in the data storage block is empty.

[0054] S220: Record the data deletion operation in the metadata file of the data storage block, and record the offset position corresponding to the second data and the data length of the second data in a preset list.

[0055] In the disclosed embodiments, metadata files (e.g., idx_ files) are used to describe the status of all objects in a data storage block, including whether an object has been deleted, and the offset and length of all objects in the data file. Data files are used to store written data, including deleted data. Recording data deletion operations in the metadata file allows the status of the objects corresponding to the data deletion operations to be determined based on the data deletion operations.

[0056] S230: Determine whether there are at least two consecutive reusable spaces in the preset list.

[0057] In an embodiment of the present disclosure, the electronic device may determine whether there are at least two consecutive reusable slots based on the offset position corresponding to each reusable slot in a preset list. When the at least two offset positions are adjacent, it is determined that there are at least two consecutive reusable slots; when there are no adjacent offset positions, it is determined that there are not at least two consecutive reusable slots.

[0058] S240: When it is determined that there are at least two consecutive reusable vacancies, merge the at least two consecutive reusable vacancies into one target vacancies.

[0059] In an embodiment of the present disclosure, after receiving a data deletion instruction, the data deletion operation corresponding to the data deletion instruction can be executed, and the metadata file and the preset list in the data storage block can be updated according to the data deletion operation. At the same time, according to the offset position of the reusable space in the updated preset list, at least two consecutive reusable spaces in the updated preset list can be merged to facilitate the subsequent reuse of the reusable spaces.

[0060] In the embodiment of the present disclosure, after writing the first data to the target location, the data storage method may further include: updating the metadata file and the preset list in the data storage block.

[0061] Specifically, after writing the first data to the target location, the electronic device updates the object (such as the first data) and the status of the object in the metadata file in the data storage block, and updates the reusable space in the preset list. In this way, the subsequent reuse of the reusable space can be ensured, avoiding the problem of reuse errors caused by untimely updates.

[0062] In an embodiment of the present disclosure, the data storage method may further include: real-time monitoring of the fragmentation rate in the data storage block, where the fragmentation rate is the ratio of the length of the reusable spaces recorded in a preset list of the data storage block to the total length of data that can be stored in the data file of the data storage block; when it is monitored that the fragmentation rate is higher than a preset threshold, performing a garbage collection operation to perform garbage collection on the data storage block.

[0063] Among them, the length of the reusable spaces recorded in the preset list can be understood as the sum of the space lengths of all reusable spaces in the preset list. For example, the number of reusable spaces recorded in the preset list is 3, and the length of each reusable space is 1len, 3len and 10len respectively. At this time, the length of the reusable spaces recorded in the preset list is 14len.

[0064] The preset threshold is a preset threshold used to determine whether to perform a garbage collection operation.

[0065] Executing the garbage collection operation may specifically include: scanning all objects in the index file of the data storage block, recording the valid object set in the data storage block; performing a data reading operation on the valid object set, and writing the valid object set into a new data file.

[0066] The valid object set is a set consisting of valid objects. A valid object refers to an object that has not been deleted in a data storage block. Correspondingly, an object that has been deleted is an invalid object.

[0067] In an embodiment of the present disclosure, when the electronic device determines that a garbage collection operation needs to be performed, it scans all objects in the index file of the data storage block, determines a valid object set in the data storage block based on the scan result, and records the valid object set. It then performs a data reading operation on the valid objects from the old data file where the valid object set is located, and writes the valid object set into the new data file, thereby realizing garbage collection of the data storage block.

[0068] In the embodiment of the present disclosure, when the fragmentation rate in the data storage block reaches a preset threshold, a garbage collection operation can be performed to ensure that the fragmentation rate of the data storage block remains within a certain range.

[0069] In the disclosed embodiment, the physical space corresponding to the reusable empty space can also be returned to the file system by using the file pre-allocation physical space (fallocate) method, thereby achieving the reuse of the physical space corresponding to the empty space.

[0070] Figure 3 It is a structural diagram of a data storage device provided by an embodiment of the present disclosure.

[0071] In the embodiments of the present disclosure, the data storage device can be provided in an electronic device and can be understood as a partial functional module in the electronic device. Specifically, the electronic device can be a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer, or a tablet computer, etc., without limitation herein. The data storage device is applied to any data node in a distributed storage cluster, wherein the data node includes at least one data storage block, and at least one data storage block has a slot multiplexing function.

[0072] like Figure 3 As shown, the data storage device 300 may include a first determination module 310 , a second determination module 320 and an instruction execution module 330 .

[0073] The first determining module 310 may be configured to receive a data writing instruction sent by a user terminal, and determine a data length of first data corresponding to the data writing instruction.

[0074] The second determining module 320 may be configured to determine a target location for storing the first data in the data storage block from a preset list based on the data length. The preset list is a list for recording reusable spaces in the data storage block.

[0075] The instruction execution module 330 may be configured to execute a write operation corresponding to the data write instruction, and write the first data into the target location.

[0076] In an embodiment of the present disclosure, it is possible to receive a data write instruction sent by a user terminal, determine the data length of the first data corresponding to the data write instruction, determine the target position for storing the first data in the data storage block from a preset list based on the data length, the preset list is a list for recording reusable spaces in the data storage block, execute a write operation corresponding to the data write instruction, and write the first data to the target position. Thus, a preset list can be set in the data storage block to record reusable spaces, and when executing the data write instruction, the physical position of the reusable spaces in the recorded data storage block can be reused, without affecting the read and write performance of the read and write instructions sent by the foreground, i.e., the user terminal, thereby greatly reducing the proportion of garbage collection, reducing the read and write operations during the garbage collection process, and at the same time improving the life of the disk.

[0077] In some embodiments of the present disclosure, the second determination module 320 can be specifically used to compare the data length with the length of at least one reusable space in a preset list; determine a target reusable space in which the length of the space is greater than or equal to the data length; and determine a target position for storing the first data based on the position corresponding to the target reusable space.

[0078] In some embodiments of the present disclosure, the second determination module 320 can also be specifically used to calculate the difference between the vacancy length and the data length of the target multiplexable vacancies for each target multiplexable vacancies in the multiple target multiplexable vacancies when there are multiple target multiplexable vacancies; filter out the multiplexable vacancies with the smallest difference between the vacancy length and the data length from the multiple target multiplexable vacancies; and determine the position corresponding to the multiplexable vacancies with the smallest difference as the target position.

[0079] In some embodiments of the present disclosure, the data storage device 300 may further include a data recording module.

[0080] The data recording module can be used to execute the data deletion operation corresponding to the data deletion instruction after receiving the data deletion instruction sent by the user end, and delete the second data corresponding to the data deletion instruction from the data storage block; record the data deletion operation in the metadata file of the data storage block, and record the offset position corresponding to the second data and the data length of the second data in a preset list.

[0081] In some embodiments of the present disclosure, the data storage device 300 may further include a slot merging module.

[0082] The vacancy merging module can be used to determine whether there are at least two consecutive reusable vacancies in the preset list after recording the offset position corresponding to the second data and the data length of the second data in the preset list; when it is determined that there are at least two consecutive reusable vacancies, the at least two consecutive reusable vacancies are merged into one target vacancies.

[0083] In some embodiments of the present disclosure, the data storage device 300 may further include a data update module.

[0084] The data updating module may be configured to update the metadata file and the preset list in the data storage block after writing the first data to the target location.

[0085] In some embodiments of the present disclosure, the data storage device 300 may further include a garbage collection module.

[0086] The garbage collection module can be used to monitor the fragmentation rate in the data storage block in real time. The fragmentation rate is the ratio of the length of the reusable space recorded in the preset list of the data storage block to the total length of the data that can be stored in the data file of the data storage block; when the fragmentation rate is detected to be higher than the preset threshold, the garbage collection operation is performed to perform garbage collection on the data storage block.

[0087] It should be noted that Figure 3 The data storage device 300 shown can execute the various steps in the above method embodiment and realize the various processes and effects in the above method embodiment, which will not be described in detail here.

[0088] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present disclosure.

[0089] In the embodiments of the present disclosure, Figure 4 The electronic device shown may be a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer, or a tablet computer, etc., which is not limited here.

[0090] like Figure 4 As shown, the electronic device may include a processor 410 and a memory 420 storing computer program instructions.

[0091] Specifically, the processor 410 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present disclosure.

[0092] Memory 420 may include a large-capacity memory for information or instructions. By way of example, and not limitation, memory 420 may include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disk, a magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 420 may include removable or non-removable (or fixed) media. Where appropriate, memory 420 may be internal or external to the integrated gateway device. In certain embodiments, memory 420 is non-volatile solid-state memory. In certain embodiments, memory 420 includes read-only memory (ROM). Where appropriate, the ROM may be mask-programmed ROM, programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable PROM (EEPROM), electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0093] The processor 410 reads and executes the computer program instructions stored in the memory 420 to perform the steps of the data storage method provided in the embodiment of the present disclosure.

[0094] In one example, the electronic device may further include a transceiver 430 and a bus 440. Figure 4 As shown, the processor 410 , the memory 420 and the transceiver 430 are connected via a bus 440 and communicate with each other.

[0095] The bus 440 includes hardware, software, or both. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, the bus 440 may include one or more buses.

[0096] The embodiments of the present disclosure further provide a computer-readable storage medium, which may store a computer program. When the computer program is executed by a processor, the processor implements the data storage method provided by the embodiments of the present disclosure.

[0097] The above-mentioned storage medium may, for example, include a memory 420 of computer program instructions, and the above-mentioned instructions may be executed by the processor 410 of the electronic device to complete the data storage method provided by the embodiment of the present disclosure. Alternatively, the storage medium may be a non-transitory computer-readable storage medium, for example, a non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0098] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A data storage method, characterized in that: Applied to any data node in a distributed storage cluster, the data node includes at least one data storage block, and the at least one data storage block has a slot multiplexing function, including: Receiving a data write instruction sent by a user terminal, and determining a data length of first data corresponding to the data write instruction; Determining a target location in the data storage block for storing the first data from a preset list based on the data length, wherein the preset list is a list for recording reusable spaces in the data storage block; A write operation corresponding to the data write instruction is executed to write the first data into the target location.

2. The method according to claim 1, characterized in that The determining, based on the data length, from a preset list, a target location for storing the first data in the data storage block comprises: Comparing the data length with the length of at least one reusable space in a preset list; Determine a target multiplexable space whose length in the at least one multiplexable space is greater than or equal to the data length; A target position for storing the first data is determined based on a position corresponding to the target reusable empty space.

3. The method according to claim 2, characterized in that When there are multiple target multiplexable spaces, determining a target position for storing the first data based on positions corresponding to the target multiplexable spaces includes: For each target multiplexable space in the plurality of target multiplexable spaces, calculating a difference between a space length of the target multiplexable space and the data length; Filter out the reusable space with the smallest difference between the space length and the data length from the plurality of target reusable spaces; The position corresponding to the reusable empty position with the smallest difference is determined as the target position.

4. The method according to claim 1, characterized in that: The method further comprises: After receiving the data deletion instruction sent by the user terminal, executing the data deletion operation corresponding to the data deletion instruction, deleting the second data corresponding to the data deletion instruction from the data storage block; The data deletion operation is recorded in the metadata file of the data storage block, and the offset position corresponding to the second data and the data length of the second data are recorded in the preset list.

5. The method according to claim 4, characterized in that After recording the offset position corresponding to the second data and the data length of the second data in the preset list, the method further includes: Determining whether there are at least two consecutive reusable spaces in the preset list; When it is determined that there are at least two consecutive reusable vacancies, the at least two consecutive reusable vacancies are merged into one target vacancies.

6. The method according to claim 1, characterized in that After writing the first data to the target location, the method further includes: The metadata file in the data storage block and the preset list are updated.

7. The method according to claim 1, characterized in that The method further comprises: Real-time monitoring of the fragmentation rate in the data storage block, wherein the fragmentation rate is a ratio of the length of the reusable spaces recorded in the preset list of the data storage block to the total length of the data that can be stored in the data file of the data storage block; When it is monitored that the fragmentation rate is higher than a preset threshold, a garbage collection operation is performed to perform garbage collection on the data storage block.

8. A data storage device, characterized in that: Applied to any data node in a distributed storage cluster, the data node includes at least one data storage block, and the at least one data storage block has a slot multiplexing function, including: A first determining module, configured to receive a data writing instruction sent by a user terminal, and determine a data length of first data corresponding to the data writing instruction; A second determining module, configured to determine a target location in the data storage block for storing the first data from a preset list based on the data length, wherein the preset list is a list for recording reusable spaces in the data storage block; The instruction execution module is used to execute a write operation corresponding to the data write instruction to write the first data into the target location.

9. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the data storage method described in any one of claims 1 to 7.

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