Data storage method and device, equipment, medium and product
The CPU splits the stored data and stores the data in hard disk striping and non-volatile memory, solving the problem of wasted hard disk storage resources and achieving more efficient data storage and reading.
Patent Information
- Application Number
- CN202510344263.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-07-11
AI Technical Summary
The method of zeroing in the storage data in the prior art leads to wasting hard disk storage resources and failing to effectively utilize the storage capabilities of the hard disk.
The data to be stored is split by a central processor (CPU), and the first data to be stored and the second data to be stored are generated, the first data to be stored is stored in a strip, and the second data to be stored is stored in non-volatile memory to avoid zero-compensation operations.
It improves the storage resource utilization rate of hard disk, ensures that data is not lost in power-down scenarios, and improves data storage and reading efficiency.
Smart Images

Figure CN120295566A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic devices, and particularly to a data storage method, apparatus, device, medium and product. Background Art
[0002] The Redundant Arrays of Independent Disks (RAID) technology is a technology that combines multiple hard disks into a hard disk group with a huge capacity to achieve higher storage performance, data reliability and fault tolerance.
[0003] A stripe includes a storage block of each hard disk. In the related art, when storing data to be stored, the Central Processing Unit (CPU) can make the size of the data to be stored after supplementation an integer multiple of the first storable data size corresponding to the stripe by padding zeros to the data to be stored, so that the data to be stored can be stored in the stripe of the hard disk group.
[0004] However, the method of padding zeros to the data to be stored in the related art has the problem of wasting the storage resources of the hard disk. Summary of the Invention
[0005] Embodiments of this application provide a data storage method, apparatus, device, medium and product, which can improve the utilization rate of the storage resources of the hard disk.
[0006] In a first aspect, an embodiment of this application provides a data storage method, which is applied to a Central Processing Unit (CPU). The CPU is connected to a non-volatile memory and multiple hard disks; the hard disk includes multiple storage blocks, and a stripe includes a storage block of each hard disk; the method includes:
[0007] Obtain a storage request; the storage request includes the data to be stored;
[0008] Obtain the size of the data to be stored, the size of the already stored data, and the first storable data size corresponding to the stripe; wherein, the already stored data is stored in the non-volatile memory;
[0009] According to the size of the data to be stored, the size of the already stored data, and the first storable data size, perform splitting processing on the data to be stored to obtain a first data to be stored and a second data to be stored;
[0010] Store the first data to be stored and the already stored data into the stripe, and store the second data to be stored into the non-volatile memory.
[0011] In this solution, in this embodiment, the CPU can obtain a storage request; where the storage request includes data to be stored. The CPU can obtain the size of the data to be stored, the size of the data already stored, and the size of the first storable data corresponding to the stripe; where the data already stored is stored in non-volatile memory. The CPU can split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the size of the first storable data, to obtain a first data to be stored and a second data to be stored. The CPU can store the first data to be stored and the data already stored into the stripe, and store the second data to be stored into non-volatile memory. By the above method, without padding zeros to the data to be stored, the first data to be stored in the data to be stored can be stored into the stripe, improving the storage resource utilization rate of the hard disk. In addition, by storing the second data to be stored into non-volatile memory, on the one hand, it can ensure that the second data to be stored is not lost in the power-off scenario; on the other hand, it can improve the storage efficiency of the second data to be stored, and further improve the efficiency of the CPU to feedback the storage result.
[0012] In one implementation, the size of the data to be stored includes the size of at least one data block; splitting the data to be stored according to the size of the data to be stored, the size of the data already stored, and the size of the first storable data, to obtain a first data to be stored and a second data to be stored, includes:
[0013] Obtain the size of the second storable data corresponding to the storage block;
[0014] According to the size of at least one data block, the size of the data already stored, the size of the first storable data, and the size of the second storable data, split and classify at least one data block, to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored; where the ratio of the sum of the sizes of at least one first target data block and the size of the data already stored to the size of the first storable data is a positive integer.
[0015] In this solution, the CPU can obtain the size of the second storable data corresponding to the storage block. The CPU can split and classify at least one data block according to the size of at least one data block, the size of the data already stored, the size of the first storable data, and the size of the second storable data, to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored. By the above method, a reasonable division of the data to be stored is achieved, so that the CPU can store the first data to be stored in the data to be stored into the stripe without padding zeros to the data to be stored, improving the storage resource utilization rate of the hard disk.
[0016] In one implementation, storing the first data to be stored and the stored data in a stripe, and storing the second data to be stored in a non-volatile memory, includes:
[0017] For any data block, determine the storage location information of the data block;
[0018] When the data block includes a first target data block, determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block in the stripe according to the first storage location information corresponding to the first target data block;
[0019] When the data block includes a second target data block, determine the second storage location information corresponding to the second target data block in the storage location information, and store the second target data block in the non-volatile memory according to the second storage location information corresponding to the second target data block;
[0020] Obtain the storage location information of at least one stored second target data block in the stored data, and store the stored second target data block in the stripe according to the storage location information of the stored second target data block.
[0021] In this solution, when the data block includes a first target data block, the CPU can determine the first storage location information corresponding to the first target data block in the storage location information. When the data block includes a second target data block, the CPU can determine the second storage location information of the second target data block, so that when the CPU needs to perform a read process on the data block, it can directly read the second target data block from the non-volatile memory or read the first target data block from the stripe, improving the data read efficiency.
[0022] In one implementation, the method further includes:
[0023] Obtain a read request; the read request includes the target storage location information of the data block to be read;
[0024] Obtain the second storage location information of each second target data block in the non-volatile memory;
[0025] According to the target storage location information, determine whether there is a second target data block to be read in the non-volatile memory; wherein, there is an overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information;
[0026] When there is a second target data block to be read in the non-volatile memory, read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
[0027] In this solution, the CPU can obtain a read request; the read request includes the target storage location information of the data block to be read. The CPU can obtain the second storage location information of each second target data block in the non-volatile memory. The CPU can determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information; wherein, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information. The CPU can, when there is a second target data block to be read in the non-volatile memory, read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read. By the above method of directly reading the second target data block to be read from the non-volatile memory when it is found that there is a second target data block to be read in the non-volatile memory, the data read efficiency can be improved.
[0028] In one implementation, the method further includes:
[0029] Determine whether there is a first target data block to be read in the stripe according to the target storage location information and the storage location information of the second target data block to be read;
[0030] When there is a first target data block to be read in the stripe, obtain the first storage location information of the first target data block to be read;
[0031] Read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read.
[0032] In this solution, the CPU can also, when there is a first target data block to be read in the stripe, obtain the first storage location information of the first target data block to be read and read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read. By the above method, the comprehensiveness of data reading is ensured.
[0033] In one implementation, the method further includes:
[0034] When there is no second target data block to be read in the non-volatile memory, read the data block to be read in the stripe according to the target storage location information.
[0035] In this solution, the CPU can, when there is no second target data block to be read in at least one second target data block, read the data block to be read in the stripe according to the target storage location information. By the above method, the data block to be read can be accurately read.
[0036] In one implementation, obtaining the second storable data size corresponding to the storage block includes:
[0037] Calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the size of the first storable data;
[0038] Determine whether N is less than 1;
[0039] In the case where N is greater than 1, determine whether N is a positive integer;
[0040] In the case where N is not a positive integer, obtain the size of the second storable data.
[0041] In this solution, the CPU can calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the size of the first storable data. When N is greater than 1 and N is not a positive integer, that is, when the data to be stored and the data already stored in the non-volatile memory cannot fill a stripe, the CPU can split the data to be stored into the first data to be stored and the second data to be stored, store the first data to be stored and the already stored data into the stripe, and store the second data to be stored into the non-volatile memory, so as to realize the storage of the data to be stored, and improve the utilization rate of the storage resources of the hard disk.
[0042] In one implementation, the method further includes:
[0043] In the case where N is less than 1, store the data to be stored into the non-volatile memory.
[0044] In this solution, the CPU can store the data to be stored into the non-volatile memory in the case where N is less than 1. By the above method, padding zeros for the data to be stored can be avoided, thereby improving the utilization rate of the storage resources of the hard disk.
[0045] In one implementation,
[0046] In the case where N is a positive integer, store the data to be stored and the already stored data into the stripe.
[0047] In this solution, the CPU can store the data to be stored and the already stored data into the stripe in the case where N is a positive integer. By the above method, padding zeros for the data to be stored can be avoided, thereby improving the utilization rate of the storage resources of the hard disk.
[0048] In a second aspect, an embodiment of the present application provides a data storage device, which is applied to a central processing unit CPU. The CPU is connected to a non-volatile memory and a plurality of hard disks; each hard disk includes a plurality of storage blocks, and a stripe includes one storage block of each hard disk; the device includes:
[0049] An obtaining module, configured to obtain a storage request; the storage request includes data to be stored;
[0050] A processing module is configured to obtain the size of the data to be stored, the size of the data already stored, and the size of the first storable data corresponding to a stripe; wherein, the data already stored is stored in non-volatile memory.
[0051] The processing module is further configured to split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the size of the first storable data, to obtain a first data to be stored and a second data to be stored.
[0052] The processing module is further configured to store the first data to be stored and the data already stored into the stripe, and store the second data to be stored into non-volatile memory.
[0053] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principle and beneficial effects are similar, and will not be elaborated here.
[0054] In one implementation, the size of the data to be stored includes the size of at least one data block; specifically, the processing module is configured to:
[0055] Obtain the size of the second storable data corresponding to the storage block.
[0056] According to the size of at least one data block, the size of the data already stored, the size of the first storable data, and the size of the second storable data, split and classify at least one data block, to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored; wherein, the ratio of the sum of the sizes of at least one first target data block and the size of the data already stored to the size of the first storable data is a positive integer.
[0057] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principle and beneficial effects are similar, and will not be elaborated here.
[0058] In one implementation, the processing module is specifically configured to:
[0059] For any data block, determine the storage location information of the data block.
[0060] In the case that the data block includes a first target data block, determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block into the stripe according to the first storage location information corresponding to the first target data block.
[0061] When the data block includes a second target data block, determine the second storage location information corresponding to the second target data block in the storage location information, and store the second target data block in the non-volatile memory according to the second storage location information corresponding to the second target data block;
[0062] Obtain the storage location information of at least one stored second target data block in the stored data, and store the stored second target data block in the strip according to the storage location information of the stored second target data block.
[0063] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, which will not be elaborated here.
[0064] In one implementation
[0065] The obtaining module is further configured to obtain a read request; the read request includes the target storage location information of the data block to be read;
[0066] The processing module is further configured to obtain the second storage location information of each second target data block in the non-volatile memory;
[0067] The processing module is further configured to determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information; wherein, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information;
[0068] The processing module is further configured to, when there is a second target data block to be read in the non-volatile memory, read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
[0069] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, which will not be elaborated here.
[0070] In one implementation, the processing module is further configured to:
[0071] Determine whether there is a first target data block to be read in the strip according to the target storage location information and the storage location information of the second target data block to be read;
[0072] When there is a first target data block to be read in the strip, obtain the first storage location information of the first target data block to be read;
[0073] Read the first target data block to be read in the strip according to the first storage location information of the first target data block to be read.
[0074] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0075] In one implementation, the processing module is further configured to:
[0076] When the second target data block to be read does not exist in the non-volatile memory, read the data block to be read in the stripe according to the target storage location information.
[0077] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0078] In one implementation, the processing module is specifically configured to:
[0079] Calculate the ratio N of the sum of the size of the data to be stored and the size of the already stored data to the first storable data size;
[0080] Determine whether N is less than 1;
[0081] When N is greater than 1, determine whether N is a positive integer;
[0082] When N is not a positive integer, obtain the second storable data size.
[0083] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0084] In one implementation, the processing module is further configured to:
[0085] When N is less than 1, store the data to be stored in the non-volatile memory; or,
[0086] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0087] In one implementation, the processing module is further configured to:
[0088] When N is a positive integer, store the data to be stored and the already stored data in the stripe.
[0089] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0090] In a third aspect, the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0091] The memory stores computer-executable instructions;
[0092] The processor executes the computer-executable instructions stored in the memory to implement the method as in the first aspect.
[0093] The electronic device provided in the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, which will not be elaborated here.
[0094] In a fourth aspect, the embodiments of the present application provide a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method as in the first aspect.
[0095] When the computer-executable instructions in the computer-readable storage medium provided in the embodiments of the present application are executed by a processor, the technical solutions shown in the above method embodiments can be implemented, and the implementation principles and beneficial effects are similar, which will not be elaborated here.
[0096] In a fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method as in the first aspect.
[0097] When the computer program in the computer program product provided in the embodiments of the present application is executed by a processor, the technical solutions shown in the above method embodiments can be implemented, and the implementation principles and beneficial effects are similar, which will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0098] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0099] Figure 1 It is a schematic diagram of the architecture of an electronic device provided in the embodiments of the present application;
[0100] Figure 2a It is a schematic flow chart of a data storage method provided in the embodiments of the present application Figure 1 ;
[0101] Figure 2b It is a schematic diagram of a hard disk group provided in the embodiments of the present application;
[0102] Figure 3 It is a second schematic flow chart of a data storage method provided in the embodiments of the present application;
[0103] Figure 4aFlow schematic diagram of a data storage method provided by an embodiment of the present application Figure 3 ;
[0104] Figure 4b Scenario schematic diagram of a data storage provided by an embodiment of the present application Figure 1 ;
[0105] Figure 4c Scenario schematic diagram II of a data storage provided by an embodiment of the present application;
[0106] Figure 5 Flow schematic diagram IV of a data storage method provided by an embodiment of the present application;
[0107] Figure 6 Structure schematic diagram of a data storage device provided by an embodiment of the present application;
[0108] Figure 7 Structure diagram of an electronic device provided by the present application.
[0109] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be given later. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0110] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0111] It should be noted that the data storage methods, devices, equipment, media, and products of the embodiments of the present application can be used in the technical field of electronic devices, and can also be used in any field other than electronic devices. The application fields of the data storage methods, devices, equipment, media, and products of the embodiments of the present application are not limited.
[0112] Glossary:
[0113] Redundant Arrays of Independent Disks (RAID) technology: It is a technology that combines multiple hard disks into a hard disk group with a huge capacity to achieve higher storage performance, data reliability, and fault tolerance.
[0114] Strip: In a hard disk group, each hard disk includes multiple storage blocks, and a strip includes one storage block from each hard disk. A strip is the basic unit of address mapping in the hard disk group. A strip includes at least one parity storage block and at least one data storage block. It should be noted that the first storable data size corresponding to a strip refers to the size of at least one data storage block included in a strip.
[0115] Data striping: A data partitioning technique for RAID that divides a file (data to be stored) into multiple data blocks and stores them on different hard disks respectively, so as to improve input / output performance by utilizing access parallelism.
[0116] A strip includes one storage block from each hard disk. In the related art, when the Central Processing Unit (CPU for short) stores data to be stored, it can make the size of the supplemented data to be stored an integer multiple of the first storable data size corresponding to the strip by padding zeros to the data to be stored, so that the data to be stored can be stored in the strip of the hard disk group.
[0117] However, in the related art, the method of padding zeros to the data to be stored has the problem of wasting the storage resources of the hard disk.
[0118] Based on the above technical problems, the technical concept of the embodiments of the present application is as follows: The CPU obtains a storage request; the storage request includes the data to be stored. The CPU can obtain the size of the data to be stored, the size of the data already stored in the non-volatile memory, and the first storable data size corresponding to the strip. The CPU can split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the first storable data size to obtain the first data to be stored and the second data to be stored. The CPU can store the first data to be stored and the data already stored in the strip, and store the second data to be stored in the non-volatile memory.
[0119] By the above method, the utilization rate of the storage resources of the hard disk can be improved.
[0120] Next, a data storage method provided by the embodiments of the present application will be described in detail.
[0121] For ease of understanding, first, in combination with Figure 1 an architecture of the electronic device involved in the embodiments of the present application will be described.
[0122] Figure 1 is a schematic diagram of the architecture of an electronic device provided by the embodiments of the present application.
[0123] As Figure 1As shown, the electronic device 10 includes a CPU 101, a non-volatile memory 102, and multiple hard disks.
[0124] The CPU 101 can be respectively connected to the non-volatile memory 102 and the multiple hard disks. In one implementation, the electronic device 10 may further include a RAID card ( Figure 1 not shown), and the CPU 101 can be connected to the multiple hard disks through the RAID card.
[0125] Exemplarily, Figure 1 five hard disks are shown, namely hard disk 103, hard disk 104, hard disk 105, hard disk 106, and hard disk 107 respectively.
[0126] It should be noted that Figure 1 this is only a structural diagram of an electronic device provided by an embodiment of the present application. The embodiments of the present application do not limit Figure 1 the actual forms of various components included therein, nor do they limit Figure 1 the interaction manners between the components therein. In the application of the solution, it can be set according to actual requirements.
[0127] The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0128] Figure 2a is a flowchart of a data storage method provided by an embodiment of the present application Figure 1 , as Figure 2a shown, the method includes the following steps:
[0129] S201: Obtain a storage request.
[0130] In this embodiment, the CPU can obtain a storage request. Among them, the storage request includes data to be stored.
[0131] In one implementation, the data to be stored may include at least one data block (IO data block). For example, the data to be stored may include 4 data blocks.
[0132] S202: Obtain the size of the data to be stored, the size of the already stored data, and the size of the first storable data corresponding to the stripe.
[0133] In this embodiment, the CPU can obtain the size of the data to be stored. In one implementation, when the data to be stored includes at least one data block, the CPU can obtain the size of each data block. For example, the data to be stored includes 4 data blocks. The CPU can obtain that the size of data block 1 is 16KB, the size of data block 2 is 8KB, the size of data block 3 is 8KB, and the size of data block 4 is 8KB.
[0134] The CPU can obtain the size of the data already stored in the non-volatile memory.
[0135] The CPU can obtain the first storable data size corresponding to the stripe. It should be noted that Figure 2b is a schematic diagram of a hard disk group provided by an embodiment of the present application. As Figure 2b shown, a stripe includes multiple storage blocks, and the multiple storage blocks can include multiple data storage blocks and parity storage blocks. The first storable data size refers to the sum of the storable data sizes corresponding to the multiple data storage blocks included in a stripe. For example, a stripe includes 4 data storage blocks, and the storable data size corresponding to each data storage block is 8KB, then the first storable data size corresponding to the stripe can be 32KB.
[0136] S203: Split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the first storable data size, to obtain the first data to be stored and the second data to be stored.
[0137] In this embodiment, the CPU can split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the first storable data size, to obtain the first data to be stored and the second data to be stored.
[0138] In one implementation,
[0139] The data to be stored includes at least one data block, and the size of the data to be stored includes the sizes of at least one data block.
[0140] The CPU can obtain the second storable data size corresponding to the storage block. It can be understood that the second storable data size corresponding to the storage block is the same as the storable data size corresponding to the data storage block and the storable data size corresponding to the parity storage block.
[0141] The CPU can split and classify at least one data block according to the sizes of at least one data block, the size of the data already stored, the first storable data size, and the second storable data size, to obtain at least one first target data block and at least one second target data block.
[0142] It should be noted that the ratio of the sum of the sizes of at least one first target data block and the size of the stored data to the size of the first storable data is a positive integer.
[0143] It should also be noted that the first data to be stored includes at least one first target data block. The second data to be stored includes at least one second target data block.
[0144] Next, the process by which the CPU splits and classifies at least one data block based on the sizes of at least one data block, the size of the stored data, the size of the first storable data, and the size of the second storable data to obtain at least one first target data block and at least one second target data block will be described.
[0145] In one implementation
[0146] When the CPU determines that the size of each data block is an integer multiple of the size of the second storable data, it can calculate the remainder of the sum of the sizes of at least one data block and the size of the stored data divided by the size of the first storable data. For example, if the size of at least one data block is 40KB, the size of the stored data is 0KB, and the size of the first storable data is 32KB, the remainder is 8KB.
[0147] The CPU can sort at least one data block in descending order of the size of the data block to obtain the serial number of each data block. It should be noted that the larger the size of the data block, the smaller the serial number of the data block.
[0148] For the data block with the i-th serial number, the CPU can determine whether the size of the data block is less than the remainder. When the CPU determines that the size of the data block with the i-th serial number is less than the remainder, it can determine the data block with the i-th serial number as the second target data block and update the remainder according to the size of the data block with the i-th serial number. It can be understood that the updated remainder is the difference between the remainder before the update and the size of the data block with the i-th serial number.
[0149] It should be noted that i is 1, 2,..., until the size of the data block with the i-th serial number is greater than or equal to the remainder.
[0150] It should also be noted that when the CPU determines that the size of the data block with the i-th serial number is equal to the remainder, it can determine the data block with the i-th serial number as the second target data block. For the data blocks with serial numbers greater than the i-th serial number, the CPU can split each data block according to the size of the second storable data to obtain at least one first target data block.
[0151] It should also be noted that when the CPU determines that the size of the data block with the i-th serial number is greater than the remainder, it can split the data block with the i-th serial number according to the remainder to obtain at least one first target data block and at least one second target data block (the size of at least one second target data block is equal to the remainder). In addition, for data blocks with serial numbers greater than the i-th serial number, the CPU can split each data block according to the second storable data size to obtain at least one first target data block.
[0152] S204: Store the first data to be stored and the stored data into the stripe, and store the second data to be stored into the non-volatile memory.
[0153] In this embodiment, the CPU can store the first data to be stored and the stored data into the stripe. In addition, the CPU can also delete the stored data in the non-volatile memory.
[0154] In one implementation, the CPU sends the first data to be stored and the stored data to the RAID card so that the RAID card stores the first data to be stored and the stored data into the stripe.
[0155] In addition, the CPU can also store the second data to be stored into the non-volatile memory.
[0156] Advantageous effects of this embodiment: In this embodiment, the CPU can obtain a storage request; where the storage request includes data to be stored. The CPU can obtain the size of the data to be stored, the size of the stored data, and the first storable data size corresponding to the stripe; the stored data is stored in the non-volatile memory. The CPU can split the data to be stored according to the size of the data to be stored, the size of the stored data, and the first storable data size to obtain the first data to be stored and the second data to be stored. The CPU can store the first data to be stored and the stored data into the stripe, and store the second data to be stored into the non-volatile memory. By the above method, without padding zeros to the data to be stored, the first data to be stored in the data to be stored can be stored into the stripe, improving the storage resource utilization rate of the hard disk. In addition, by storing the second data to be stored into the non-volatile memory, on the one hand, it can ensure that the second data to be stored is not lost in the power-off scenario; on the other hand, it can improve the storage efficiency of the second data to be stored, and thus improve the efficiency of the CPU to feedback the storage result.
[0157] Figure 3 This is the second flowchart of a data storage method provided by an embodiment of the present application. As Figure 3 shown, the method includes the following steps:
[0158] S301: Obtain a storage request.
[0159] In this embodiment, the CPU can obtain a storage request. Among them, the storage request includes data to be stored. The data to be stored includes at least one data block.
[0160] S302: Obtain the sizes of at least one data block, the size of the stored data, and the size of the first storable data corresponding to the stripe.
[0161] In this embodiment, the CPU can obtain the sizes of at least one data block, the size of the stored data, and the size of the first storable data corresponding to the stripe.
[0162] Among them, the stored data is stored in non-volatile memory.
[0163] S303: Calculate the ratio N of the sum of the size of the data to be stored and the size of the stored data to the size of the first storable data.
[0164] In this embodiment, the CPU can calculate the ratio N of the sum of the size of the data to be stored and the size of the stored data to the size of the first storable data.
[0165] For example, if the size of the data to be stored is 40KB, the size of the stored data is 0, and the size of the first storable data is 32, then N is 1.25.
[0166] S304: Determine whether N is less than 1.
[0167] In this embodiment, the CPU can determine whether N is less than 1.
[0168] If so, execute S305;
[0169] If not, execute S306.
[0170] S305: Store the data to be stored in non-volatile memory.
[0171] In this embodiment, the CPU can store the data to be stored in non-volatile memory when N is less than 1.
[0172] S306: Determine whether N is a positive integer.
[0173] In this embodiment, the CPU can determine whether N is a positive integer when it is determined that N is greater than or equal to 1.
[0174] If so, execute S307;
[0175] If not, execute S308.
[0176] S307: Store the data to be stored and the stored data in the stripe.
[0177] In this embodiment, when N is a positive integer, the CPU may store the data to be stored and the stored data in the non-volatile memory into stripes (at least one stripe).
[0178] In addition, the CPU may also perform a deletion process on the stored data in the non-volatile memory.
[0179] S308: Obtain the size of the second storable data.
[0180] In this embodiment, when N is not a positive integer, the CPU may obtain the size of the second storable data corresponding to the storage block.
[0181] S309: According to the sizes of at least one data block, the size of the stored data, the size of the first storable data, and the size of the second storable data, perform splitting and classification processing on at least one data block to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored.
[0182] In this embodiment, the CPU may perform splitting and classification processing on at least one data block according to the sizes of at least one data block, the size of the stored data, the size of the first storable data, and the size of the second storable data to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored.
[0183] Wherein, the ratio of the sum of the sizes of at least one first target data block and the size of the stored data to the size of the first storable data is a positive integer.
[0184] S310: Store the first data to be stored and the stored data into stripes, and store the second data to be stored into the non-volatile memory.
[0185] In this embodiment, the CPU may store the data to be stored and the stored data in the non-volatile memory into stripes. In addition, the CPU may also perform a deletion process on the stored data in the non-volatile memory.
[0186] The CPU may also store the second data to be stored into the non-volatile memory.
[0187] Advantages of this embodiment: In this embodiment, the CPU can calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored (stored in the non-volatile memory) to the size of the first storable data. When it is determined that N is greater than 1 and N is not a positive integer, the CPU can obtain the size of the second storable data, and perform splitting and classification processing on at least one data block according to the size of at least one data block, the size of the data already stored, the size of the first storable data, and the size of the second storable data, to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored. Among them, the ratio of the sum of the size of at least one first target data block and the size of the data already stored to the size of the first storable data is a positive integer. The CPU can store the first data to be stored and the data already stored in the stripe, and store the second data to be stored in the non-volatile memory. When it is determined that N is less than 1, the CPU can directly store the data to be stored in the non-volatile memory. When it is determined that N is a positive integer, the CPU can store the data to be stored and the data already stored in the non-volatile memory in the stripe. In the above manner, on the one hand, the component for storing the data to be stored (non-volatile memory and / or multiple hard disks (including multiple stripes)) can be accurately determined; on the other hand, zero-padding of the data to be stored is not required, and the storage of the data to be stored can be achieved, improving the storage resource utilization rate of the hard disk.
[0188] Figure 4a Flow schematic of a data storage method provided by an embodiment of the present application Figure 3 , such as Figure 4a shown, the method includes the following steps:
[0189] S401: Obtain a storage request.
[0190] In this embodiment, the CPU can obtain a storage request. Among them, the storage request includes the data to be stored.
[0191] It should be noted that the data to be stored includes at least one data block.
[0192] S402: Obtain the size of at least one data block, the size of the data already stored, and the size of the first storable data corresponding to the stripe.
[0193] In this embodiment, the CPU can obtain the size of at least one data block, the size of the data already stored, and the size of the first storable data corresponding to the stripe.
[0194] Among them, the data already stored is stored in the non-volatile memory.
[0195] S403: Calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the size of the first storable data.
[0196] In this embodiment, the CPU can calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the size of the first storable data.
[0197] S404: Determine whether N is less than 1.
[0198] In this embodiment, the CPU can determine whether N is less than 1.
[0199] If so, execute 405;
[0200] If not, execute S406.
[0201] S405: Store the data to be stored in the non-volatile memory.
[0202] In this embodiment, the CPU can store the data to be stored in the non-volatile memory when determining that N is less than 1.
[0203] S406: Determine whether N is a positive integer.
[0204] In this embodiment, the CPU can determine whether N is a positive integer when determining that N is greater than or equal to 1.
[0205] If so, execute S407;
[0206] If not, execute S408.
[0207] S407: Store the data to be stored and the data already stored in the stripe.
[0208] In this embodiment, the CPU can store the data to be stored and the data already stored in the stripe when N is a positive integer.
[0209] Figure 4b A scenario schematic for data storage provided by an embodiment of the present application Figure 1 . As Figure 4b shown, the storage request includes the data to be stored, and the data to be stored includes three data blocks. Among them, the size of data block 5 can be 8KB, the size of data block 6 can be 8KB, and the size of data block 7 can be 8KB. The CPU can obtain that the size of the data already stored is 8KB, the size of the first storable data corresponding to the stripe is 32KB, and the size of the second storable data corresponding to the storage block is 8KB. The CPU can calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored (32KB) to the size of the first storable data (32KB). The CPU can determine that N (1) is a positive integer. The CPU can store the data to be stored and the data already stored in the stripe.
[0210] S408: Obtain the size of the second storable data.
[0211] In this embodiment, the CPU can obtain the second storable data size corresponding to the storage block when N is not a positive integer.
[0212] S409: According to the sizes of at least one data block, the first storable data size, and the second storable data size, perform splitting and classification processing on the at least one data block to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored.
[0213] In this embodiment, the CPU can perform splitting and classification processing on the at least one data block according to the sizes of at least one data block, the first storable data size, and the second storable data size to obtain at least one first target data block and at least one second target data block.
[0214] It should be noted that the first data to be stored includes at least one first target data block.
[0215] The second data to be stored includes at least one second target data block.
[0216] It should also be noted that the ratio of the sum of the sizes of at least one first target data block and the size of the stored data to the first storable data size is a positive integer.
[0217] S410: For any data block, determine the storage location information of the data block.
[0218] In this embodiment, for any data block, the CPU can determine the storage location information of the data block.
[0219] In one implementation, the storage location information may include a logical start address and a length. In one implementation, the storage location information may also include the identifier of the component.
[0220] S411: When the data block includes a first target data block, determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block into the stripe according to the first storage location information corresponding to the first target data block.
[0221] In this embodiment, the CPU can determine the storage location information of the first target data block in the storage location information when the data block includes a first target data block.
[0222] In one implementation, the storage location information may include a logical start address and a length. In one implementation, the storage location information may further include an identifier of a component. Among them, the identifier of the component corresponding to the second target data block may indicate that the component is a hard disk. Additionally, the identifier of the component may also indicate the identifier of the hard disk, such as Hard Disk 1.
[0223] The CPU may store the first target data block into a stripe according to the first storage location information corresponding to the first target data block.
[0224] S412: When the data block includes the second target data block, determine the second storage location information of the second target data block in the storage location information, and store the second target data block into the non-volatile memory according to the second storage location information corresponding to the second target data block.
[0225] In this embodiment, when the data block includes the second target data block, the CPU may determine the storage location information of the second target data block in the storage location information, and store the second target data block into the non-volatile memory according to the second storage location information corresponding to the second target data block.
[0226] In one implementation, the storage location information may include a logical start address and a length. In one implementation, the storage location information may further include an identifier of a component. Among them, the identifier of the component corresponding to the second target data block may indicate that the component is a non-volatile memory.
[0227] In addition, it should be noted that based on the data block including the second target data block, there is overlapping storage location information between the storage location information of the data block and the second storage location information of the second target data block. For example, the logical start address in the storage location information of the data block is 1 and the length is 6, and the logical start address in the second storage location information of the second target data block is 1 and the length is 3. There is overlapping storage location information between the storage location information of the data block and the second storage location information of the second target data block, and the logical start address in the overlapping storage location information is 1 and the length is 3.
[0228] Figure 4c This is a schematic diagram II of a data storage scenario provided for the embodiments of the present application. As Figure 4cAs shown in the figure, the storage request includes data to be stored, and the data to be stored includes four data blocks. Among them, the size of data block 1 can be 16KB, the size of data block 2 can be 8KB, the size of data block 3 can be 8KB, and the size of data block 4 can be 8KB. The CPU can obtain that the size of the stored data is 0KB, the size of the first storable data corresponding to the stripe is 32KB, and the size of the second storable data corresponding to the storage block is 8KB. The CPU can split and classify the four data blocks according to the sizes of the four data blocks, the size of the first storable data, and the size of the second storable data, to obtain four first target data blocks (first target data block 1, first target data block 2, first target data block 3, and first target data block 4) and a second target data block (second target data block 1). It should be noted that first target data block 1 and second target data block 1 are obtained by splitting data block 1; data block 2 is first target data block 2; data block 3 is first target data block 3, and data block 4 is first target data block 4. The CPU can store first target data block 1, first target data block 2, first target data block 3, and first target data block 4 into the stripe. The CPU can store second target data block 1 into the non-volatile memory.
[0229] S413: Obtain the storage location information of at least one stored second target data block in the stored data, and store the stored second target data block into the stripe according to the storage location information of the stored second target data block.
[0230] In this embodiment, the CPU obtains the storage location information of at least one stored second target data block in the stored data, and stores the stored second target data block into the stripe according to the storage location information of the stored second target data block.
[0231] Beneficial effects of this embodiment: In this embodiment, for any data block, the CPU can determine the storage location information of the data block. When the data block includes a first target data block, the CPU can determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block into the stripe according to the first storage location information corresponding to the first target data block. When the data block includes a second target data block, the CPU can determine the second storage location information corresponding to the second target data block in the storage location information, and store the second target data block into the non-volatile memory according to the second storage location information corresponding to the second target data block. The CPU can obtain the storage location information of at least one stored second target data block in the stored data, and store the stored second target data block into the stripe according to the storage location information of the stored second target data block. Through the above method, the orderly storage of data can be realized, and the storage efficiency is improved.
[0232] Figure 5 FIG. 4 is a schematic flowchart of a data storage method provided by an embodiment of the present application, as Figure 5 shown, the method includes the following steps:
[0233] S501: Obtain a read request.
[0234] In this embodiment, the CPU may obtain a read request.
[0235] Among them, the read request includes the target storage location information of the data block to be read.
[0236] S502: Obtain the second storage location information of each second target data block in the non-volatile memory.
[0237] In this embodiment, the CPU may obtain the second storage location information of each second target data block in the non-volatile memory.
[0238] S503: Determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information.
[0239] In this embodiment, the CPU may determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information.
[0240] Among them, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information.
[0241] If not, execute S504;
[0242] If so, execute S505.
[0243] S504: Read the data block to be read in the stripe according to the target storage location information.
[0244] In this embodiment, when there is no second target data block to be read in the non-volatile memory, the CPU may read the data block to be read in the stripe according to the target storage location information.
[0245] S505: Read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
[0246] In this embodiment, when there is a second target data block to be read in the non-volatile memory, the CPU may read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
[0247] In one implementation, the non-volatile memory can store the second target data block in the form of key-value. Wherein, the key is the logical start address and length, and the value is the data. The CPU can read the second target data block to be read in the non-volatile memory according to the logical start address and length in the storage location information of the second target data block.
[0248] S506: Determine whether there is a first target data block to be read in the stripe according to the target storage location information and the storage location information of the second target data block to be read.
[0249] In this embodiment, the CPU can determine whether there is a first target data block to be read in the stripe according to the target storage location information and the storage location information of the second target data block to be read.
[0250] If so, execute S507;
[0251] If not, end.
[0252] It should be noted that the CPU can first execute S505 and then execute S506 - S508; the CPU can also first execute S506 - S508 and then execute S505; the CPU can also execute S506 - S508 while executing S505. The embodiments of the present application do not limit this.
[0253] S507: Obtain the first storage location information of the first target data block to be read.
[0254] In this embodiment, the CPU can obtain the first storage location information of the first target data block to be read when there is a first target data block to be read in the stripe.
[0255] S508: Read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read.
[0256] In this embodiment, the CPU can read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read.
[0257] Advantages of this embodiment: In this embodiment, the CPU can obtain a read request; the read request includes the target storage location information of the data block to be read. The CPU can obtain the second storage location information of each second target data block in the non-volatile memory. The CPU can determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information; wherein, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information. When there is a second target data block to be read in the non-volatile memory, the CPU can read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read. By directly reading the second target data block to be read from the non-volatile memory when it is found that there is a second target data block to be read in the non-volatile memory as described above, the data reading efficiency can be improved.
[0258] Figure 6 FIG. is a schematic structural diagram of a data storage device provided by an embodiment of the present application. The data storage device is applied to a CPU, and the CPU is connected to a non-volatile memory and multiple hard disks; each hard disk includes multiple storage blocks, and one stripe includes one storage block of each hard disk. As Figure 6 shown, the data storage device 60 may include an acquisition module 61 and a processing module 62.
[0259] The acquisition module 61 is configured to obtain a storage request; the storage request includes data to be stored;
[0260] The processing module 62 is configured to obtain the size of the data to be stored, the size of the already stored data, and the first storable data size corresponding to the stripe; wherein, the already stored data is stored in the non-volatile memory;
[0261] The processing module 62 is further configured to perform splitting processing on the data to be stored according to the size of the data to be stored, the size of the already stored data, and the first storable data size, to obtain first data to be stored and second data to be stored;
[0262] The processing module 62 is further configured to store the first data to be stored and the already stored data into the stripe, and store the second data to be stored into the non-volatile memory.
[0263] The data storage device provided by the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0264] In one implementation, the size of the data to be stored includes the size of at least one data block; the processing module 62 is specifically configured to:
[0265] Obtain the second storable data size corresponding to the storage block;
[0266] Split and classify at least one data block according to the size of at least one data block, the size of the stored data, the size of the first storable data, and the size of the second storable data, to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored; wherein, the ratio of the sum of the sizes of at least one first target data block and the stored data to the size of the first storable data is a positive integer.
[0267] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0268] In one implementation, the processing module 62 is specifically configured to:
[0269] For any data block, determine the storage location information of the data block;
[0270] When the data block includes a first target data block, determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block into the stripe according to the first storage location information corresponding to the first target data block;
[0271] When the data block includes a second target data block, determine the second storage location information corresponding to the second target data block in the storage location information, and store the second target data block into the non-volatile memory according to the second storage location information corresponding to the second target data block;
[0272] Obtain the storage location information of at least one stored second target data block in the stored data, and store the stored second target data block into the stripe according to the storage location information of the stored second target data block.
[0273] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principle and beneficial effects are similar, which will not be elaborated here.
[0274] In one implementation,
[0275] The acquisition module 61 is further configured to acquire a read request; the read request includes the target storage location information of the data block to be read;
[0276] The processing module 62 is further configured to acquire the second storage location information of each second target data block in the non-volatile memory;
[0277] The processing module 62 is further configured to determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information; wherein, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information.
[0278] The processing module 62 is further configured to, when there is a second target data block to be read in the non-volatile memory, read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
[0279] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principles and beneficial effects are similar, which will not be elaborated here.
[0280] In one implementation, the processing module 62 is further configured to:
[0281] Determine whether there is a first target data block to be read in the stripe according to the target storage location information and the storage location information of the second target data block to be read;
[0282] When there is a first target data block to be read in the stripe, obtain the first storage location information of the first target data block to be read;
[0283] Read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read.
[0284] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principles and beneficial effects are similar, which will not be elaborated here.
[0285] In one implementation, the processing module 62 is further configured to:
[0286] When there is no second target data block to be read in the non-volatile memory, read the data block to be read in the stripe according to the target storage location information.
[0287] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principles and beneficial effects are similar, which will not be elaborated here.
[0288] In one implementation, the processing module 62 is specifically configured to:
[0289] Calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the first storable data size;
[0290] Determine whether N is less than 1;
[0291] When N is greater than 1, determine whether N is a positive integer;
[0292] When N is not a positive integer, obtain the second storable data size.
[0293] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, so details will not be described here.
[0294] In one implementation, the processing module 62 is further configured to:
[0295] When N is less than 1, store the data to be stored in the non-volatile memory.
[0296] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, so details will not be described here.
[0297] In one implementation, the processing module 62 is further configured to:
[0298] When N is a positive integer, store the data to be stored and the stored data to the strip.
[0299] The data storage device provided by the embodiments of the present application can execute the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects are similar, so details will not be described here.
[0300] Figure 7 It is a structural diagram of an electronic device provided by the present application. As Figure 7 shown, the electronic device 70 includes a processor 71 and a memory 72. Among them, the processor 71 is communicatively connected to the memory 72, and the memory 72 is used to store computer execution instructions; the processor 71 is configured to execute the technical solutions in any of the foregoing method embodiments by executing the computer execution instructions stored in the memory 72.
[0301] Optionally, the memory 72 can be either independent or integrated with the processor 71. Optionally, when the memory 72 is a device independent of the processor 71, the electronic device 70 can further include: a bus 73 for connecting the above devices.
[0302] This electronic device is used to execute the technical solutions in any of the foregoing method embodiments, and the implementation principles and technical effects are similar, so details will not be described here.
[0303] The embodiments of the present application further provide a computer-readable storage medium, in which computer execution instructions are stored, and when the computer execution instructions are executed by a processor, they are used to implement the technical solutions provided by any of the foregoing method embodiments.
[0304] An embodiment of this application also provides a computer program product, including a computer program which, when executed by a processor, is used to implement the technical solutions provided in the foregoing method embodiments.
[0305] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should understand that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0306] Furthermore, it should be noted that although the steps in the flowchart are shown in sequence according to the indication of the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily have to be executed at the same moment, but can be executed at different moments. The execution order of these sub-steps or stages does not necessarily have to be sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0307] It should be understood that the above device embodiments are illustrative only, and the devices of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0308] In addition, without special description, in each embodiment of this application, the functional units / modules can be integrated into one unit / module, or each unit / module can exist physically alone, or two or more units / modules can be integrated together. The above integrated unit / module can be implemented in the form of hardware or in the form of a software program module.
[0309] When the integrated unit / module is implemented in the form of hardware, the hardware can be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.
[0310] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned memory includes: USB flash drives, read-only memory (ROM), random access memory (RAM), mobile hard disks, magnetic disks, or optical discs, etc., all of which can store program codes.
[0311] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0312] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include the common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0313] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A data storage method, characterized in that, Applied to a central processing unit (CPU), the CPU is connected to a non-volatile memory and a plurality of hard disks; each hard disk includes a plurality of storage blocks, and a stripe includes one storage block of each hard disk; the method includes: Obtain a storage request; the storage request includes data to be stored; Obtain the size of the data to be stored, the size of the data already stored, and the first storable data size corresponding to the stripe; wherein, the data already stored is stored in the non-volatile memory; According to the size of the data to be stored, the size of the data already stored, and the first storable data size, perform a splitting process on the data to be stored to obtain first data to be stored and second data to be stored; Store the first data to be stored and the data already stored into the stripe, and store the second data to be stored into the non-volatile memory.
2. The method according to claim 1, wherein The size of the data to be stored includes the size of at least one data block; the performing a splitting process on the data to be stored according to the size of the data to be stored, the size of the data already stored, and the first storable data size to obtain first data to be stored and second data to be stored includes: Obtain the second storable data size corresponding to the storage block; According to the size of the at least one data block, the size of the data already stored, the first storable data size, and the second storable data size, perform a splitting and classification process on the at least one data block to obtain at least one first target data block included in the first data to be stored and at least one second target data block included in the second data to be stored; wherein, the ratio of the sum of the sizes of at least one of the first target data blocks and the size of the data already stored to the first storable data size is a positive integer.
3. The method according to claim 2, wherein The storing the first data to be stored and the data already stored into the stripe, and storing the second data to be stored into the non-volatile memory includes: For any data block, determine the storage location information of the data block; In the case where the data block includes a first target data block, determine the first storage location information corresponding to the first target data block in the storage location information, and store the first target data block into the stripe according to the first storage location information corresponding to the first target data block; In the case where the data block includes a second target data block, determine the second storage location information corresponding to the second target data block in the storage location information, and store the second target data block into the non-volatile memory according to the second storage location information corresponding to the second target data block; Obtain the storage location information of at least one stored second target data block in the data already stored, and store the stored second target data block into the stripe according to the storage location information of the stored second target data block.
4. The method according to claim 3, characterized in that The method further includes: Obtain a read request; the read request includes the target storage location information of the data block to be read; Obtain the second storage location information of each second target data block in the non-volatile memory; Determine whether there is a second target data block to be read in the non-volatile memory according to the target storage location information; wherein, there is overlapping storage location information between the storage location information of the second target data block to be read and the target storage location information. When there is the second target data block to be read in the non-volatile memory, read the second target data block to be read in the non-volatile memory according to the storage location information of the second target data block to be read.
5. The method according to claim 4, wherein The method further includes: Determine whether there is a first target data block to be read in the stripe according to the target storage location information and the storage location information of the second target data block to be read. When there is the first target data block to be read in the stripe, obtain the first storage location information of the first target data block to be read. Read the first target data block to be read in the stripe according to the first storage location information of the first target data block to be read.
6. The method according to claim 4, characterized in that, The method further includes: When there is no second target data block to be read in the non-volatile memory, read the data block to be read in the stripe according to the target storage location information.
7. The method according to any one of claims 2-6, characterized in that, The obtaining the second storable data size corresponding to the storage block includes: Calculate the ratio N of the sum of the size of the data to be stored and the size of the data already stored to the first storable data size of the stripe. Determine whether the N is less than 1. When the N is greater than 1, determine whether the N is a positive integer. When the N is not a positive integer, obtain the second storable data size.
8. The method according to claim 7, wherein The method further includes: When the N is less than 1, store the data to be stored in the non-volatile memory.
9. The method according to claim 7, characterized in that, The method further includes: When the N is a positive integer, store the data to be stored and the data already stored in the stripe.
10. A data storage device, characterized in that, Applied to a central processing unit (CPU), the CPU is connected to a non-volatile memory and a plurality of hard disks; each hard disk includes a plurality of storage blocks, and a stripe includes one storage block of each hard disk; the device includes: An obtaining module, configured to obtain a storage request; the storage request includes data to be stored. A processing module, configured to obtain the size of the data to be stored, the size of the data already stored, and the first storable data size corresponding to the stripe; wherein, the data already stored is stored in the non-volatile memory. The processing module is further configured to split the data to be stored according to the size of the data to be stored, the size of the data already stored, and the first storable data size, to obtain first data to be stored and second data to be stored. The processing module is further configured to store the first data to be stored and the data already stored in the stripe, and store the second data to be stored in the non-volatile memory.
11. An electronic device, characterized in that, Includes: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-9.
13. A computer program product, characterized in that, It includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-9.