Data storage method, device, medium and equipment
By dividing the data storage block into multiple sub-blocks and performing consistency verification, the problem of slow read and write speed and limited erase times of FLASH chips in automotive electronics products is solved, and the efficiency of data storage and the service life of the memory chip are improved.
Patent Information
- Application Number
- CN202210008659.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-06
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-01-06
AI Technical Summary
In automotive electronics, FLASH chips have slow read and write speeds and limited erasing times, resulting in high CPU usage and short service life of the memory chip during data storage. Especially when only part of most data changes, the entire storage unit Write operations are detrimental to efficiency.
Divide the data storage block into multiple storage sub-blocks, and when receiving a write request, obtain the local data to be written from the random access memory and verify the consistency with the historical data written in the previous round. If there are differences , then the data is written to the non-volatile memory, otherwise the write operation is ignored, reducing the number of write operations and the data length.
It improves the writing efficiency of data storage, reduces the CPU occupancy rate and the number of writes to non-volatile memory, and extends the service life of the memory chip.
Smart Images

Figure CN114518845B
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular to data storage methods, devices, media and equipment. Background Art
[0002] With the rapid development of automotive electronic technology, data for various purposes are stored in the memory of the automotive ECU (Electronic Control Unit). Most of the data will be lost when the ECU loses power. Some important data can still be saved in non-volatile memory (such as FLASH, EEPROM) after power failure, such as vehicle identification number, anti-theft key, vehicle offline configuration word, diagnostic fault code, etc. This data is called non-volatile data.
[0003] In order to reduce costs, automotive electronic products generally use FLASH chips as non-volatile memory, but FLASH has slow read and write speeds and a limited number of erase times. At the same time, in most cases in actual use, the latest data that needs to be stored may have only a small part of the data changed compared to the previous round of data, but the storage data of the entire storage unit needs to be written to the non-volatile memory. The amount of data written becomes larger and the writing time is longer, which is not conducive to reducing CPU occupancy and extending the service life of the storage chip. Summary of the invention
[0004] In order to improve the writing efficiency of data storage, the present application provides a data storage method, device, medium and equipment. The technical solution is as follows:
[0005] In a first aspect, the present application provides a data storage method, wherein a data storage block is divided into a plurality of storage sub-blocks, and the method comprises:
[0006] In response to a data write request, traverse the multiple storage sub-blocks and obtain the local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory;
[0007] Acquire local historical written data stored in the storage sub-block, where the local historical written data is local data written in a previous round;
[0008] Performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result;
[0009] When the verification result indicates that there is a difference between the local data to be written and the local historical written data, the local data to be written is written into a second storage space corresponding to the storage sub-block; the second storage space is located in a non-volatile memory.
[0010] Optionally, the method further includes:
[0011] When the verification result indicates that the local data to be written is consistent with the local historical written data, writing of the local data to be written is ignored.
[0012] Optionally, performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result includes:
[0013] The local data to be written and the local historical written data are compared bit by bit to obtain the verification result, and the verification result represents the consistency between the local data to be written and the local historical written data.
[0014] Optionally, the performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result further includes:
[0015] Calculating a corresponding first cyclic redundancy check value according to the local data to be written;
[0016] Determining a second cyclic redundancy check value of the local historical written data;
[0017] The first cyclic redundancy check value and the second cyclic redundancy check value are compared to obtain the verification result.
[0018] Optionally, when the verification result indicates that there is a difference between the local data to be written and the local historical written data, writing the local data to be written into a second storage space corresponding to the storage sub-block includes:
[0019] When the verification result indicates that there is a difference between the local data to be written and the local historical written data, in response to a write service request of the storage sub-block, the write service request includes a storage space identifier corresponding to the storage sub-block, determining the second storage space in the non-volatile memory corresponding to the storage space identifier.
[0020] A write operation is performed to store the local data to be written in the second storage space.
[0021] Optionally, the method further includes:
[0022] Each storage sub-block among the multiple storage sub-blocks includes a sub-block header area, a sub-block data area and / or a sub-block check area, wherein the sub-block header area stores the node identifier of the storage sub-block, and the sub-block check area stores the second cyclic redundancy check value of the local historical write data.
[0023] In a second aspect, the present application provides a data storage device, the device comprising:
[0024] A first acquisition module, configured to traverse the plurality of storage sub-blocks in response to a data write request, and acquire local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory;
[0025] A second acquisition module is used to acquire the local historical written data stored in the storage sub-block, where the local historical written data is the local data written in the previous round;
[0026] A comparison module, used for performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result;
[0027] A writing module is used to write the local data to be written into a second storage space corresponding to the storage sub-block when the verification result indicates that there is a difference between the local data to be written and the local historical written data; the second storage space is located in a non-volatile memory.
[0028] Optionally, the device further comprises:
[0029] The ignoring module is used to ignore the writing of the local data to be written when the verification result indicates that the local data to be written is consistent with the local historical written data.
[0030] In a third aspect, the present application provides a computer-readable storage medium, wherein at least one instruction or at least one program is stored in the computer-readable storage medium, and the at least one instruction or at least one program is loaded and executed by a processor to implement a data storage method as described in the first aspect.
[0031] In a fourth aspect, the present application provides a computer device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement a data storage method as described in the first aspect.
[0032] In a fifth aspect, the present application provides a computer program product, wherein the computer program product comprises computer instructions, and when the computer instructions are executed by a processor, a data storage method as described in the first aspect is implemented.
[0033] The data storage method, device, medium and equipment provided by this application have the following technical effects:
[0034] The solution provided by the present application divides the data storage block into multiple storage sub-blocks. When a data write request is received, the corresponding local data to be written is read from the first storage space corresponding to the storage sub-block, and the local data to be written and the local historical written data are verified for consistency. The local historical written data is the local data written in the previous round. If the verification result indicates that there is a difference between the two, the local data to be written is written into the second storage space and stored in the non-volatile memory. If the two are consistent, the write operation of the local data to be written is ignored, and each storage sub-block is traversed at the same time, and the above process is repeated. The technical solution provided by the present application can reduce the number or time of write operations, and can also reduce the length of data required to be written, thereby improving the write efficiency of data storage.
[0035] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0037] Figure 1 It is a flowchart of a data storage method provided by an embodiment of the present application;
[0038] Figure 2 is a schematic diagram of the structure of a storage sub-block provided in an embodiment of the present application;
[0039] Figure 3 It is a structural diagram of a non-volatile memory management module in the Autosar architecture provided by an embodiment of the present application;
[0040] Figure 4 It is a structural diagram of a RAM Block provided in an embodiment of the present application;
[0041] Figure 5 It is a structural diagram of a ROM Blcok provided in an embodiment of the present application;
[0042] Figure 6 This is a structural diagram of a Native management type provided in an embodiment of the present application;
[0043] Figure 7 This is a structural diagram of a Redundant management type provided in an embodiment of the present application;
[0044] Figure 8 It is a structural diagram of a Dataset management type provided in an embodiment of the present application;
[0045] Fig. 9 It is a schematic diagram of a data storage device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to improve the writing efficiency during data storage, the embodiments of the present application provide data storage methods, devices, media and equipment. The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of this application. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions.
[0047] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] In order to facilitate understanding of the technical solutions described in the embodiments of the present application and the technical effects produced therefrom, the embodiments of the present application explain the relevant professional terms involved:
[0049] Autosar: Automotive Open System Architecture, automotive open system architecture.
[0050] NVM: Non-Volatile RAM Manager, non-volatile memory management, provides asynchronous access management and maintenance services for stored data. It reads NVRAM at power-on, powers off, or periodically stores NVRAM to non-volatile storage media to ensure that NVRAM data is not lost when power is off.
[0051] NV Block: Non-volatile storage block, which is the basic storage object of NVM and is used to manage and store non-volatile data.
[0052] VIN: Vehicle Identification Number, vehicle identification number or frame number.
[0053] DTC: Diagnostic Trouble Code, diagnostic trouble code.
[0054] CRC: Cyclic Redundancy Check, cyclic redundancy check.
[0055] FEE: Flash EEPROM Emulation, Flash emulates EEPROM, abstracts from device-specific addressing schemes and segmentation, and provides virtual addressing schemes and segmentation to the upper layer, as well as implements EEPROM-like "random access".
[0056] The following introduces a data storage method provided by this application. Figure 1 It is a flowchart of a data storage method provided in an embodiment of the present application. The present application provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Please refer to Figure 1 A data storage method provided in an embodiment of the present application may include the following steps:
[0057] S100: In response to a data write request, traverse multiple storage sub-blocks and obtain local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory.
[0058] In the embodiment of the present application, the data to be written is non-volatile data, referred to as NV (Non-Volatile) data, which can still be stored in the non-volatile memory after the system is powered off, such as vehicle identification number (VIN), diagnostic trouble code (DTC), etc. In the application scenario based on the Autosar architecture, the application layer sends a data write request to the non-volatile memory management module (NVM), and the non-volatile memory management module responds to the request and determines whether to write the application layer data temporarily stored in the random access memory (RAM) to the non-volatile memory.
[0059] In one embodiment of the present application, based on the memory protocol stack structure provided by the Autosar architecture, the non-volatile memory block (NV Block), the basic storage object of the non-volatile memory management module in the memory protocol stack, is divided into multiple non-volatile storage sub-blocks (NV Sub-Blocks), which are hereinafter referred to as storage blocks and storage sub-blocks. The number of storage sub-blocks can be manually preset according to demand. Figure 2 A schematic diagram of the structure of a storage sub-block is shown, such as Figure 2 As shown, each storage sub-block in the above-mentioned multiple storage sub-blocks may include a sub-block header area (NV Sub-Block Header), a sub-block data area (NV Sub-Block Data) or a sub-block check area (NV Sub-Block CRC), wherein the sub-block header area may store the node identifier of the storage sub-block, the sub-block check area may store a cyclic redundancy check value (CRC) calculated based on local historical write data, and the sub-block data area may store the local write data of the previous round, that is, the local historical write data. It can be understood that the sub-block header area and the sub-block check area are optional.
[0060] In an embodiment of the present application, after the storage sub-blocks are divided, a corresponding first storage space is allocated to each storage sub-block, and the first storage space corresponds to an address interval in a random access memory. The first storage space temporarily stores local data of data to be written, and the local data temporarily stored in multiple first storage spaces constitute the completed data to be written. The local data to be written corresponding to the storage sub-block is obtained from the first storage space through the read and write services provided by the non-volatile memory management module.
[0061] S200: Acquire local historical write data stored in a storage sub-block, where the local historical write data is local data written in a previous round.
[0062] In one embodiment of the present application, according to Figure 2 The structure of the storage sub-block shown determines the local historical write data stored in the storage sub-block from the sub-block data area, and the local historical write data is the local data written by the storage sub-block to the non-volatile memory in the previous round of write service.
[0063] In another feasible implementation, local historical write data can also be obtained from a second storage space corresponding to the storage sub-block through a read service provided by a non-volatile memory management module, where the second storage space corresponds to a storage space of a non-volatile memory for storing non-volatile data.
[0064] S300: Perform consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result.
[0065] It should be noted that a storage block can store complete data to be written. When executing a write service, assuming that only one byte of data has changed compared to the historical written data of the previous round, it is still necessary to write all the data to be written in the entire storage block into the non-volatile memory. This approach increases the time consumption of a single write operation and increases the amount of data written, which is not conducive to reducing the CPU (Central Processing Unit) occupancy rate. At the same time, when the number of read and write times of the non-volatile memory is limited, it will also reduce the service life of the non-volatile memory. In an embodiment of the present application, the original basic storage object is segmented, and each storage sub-block after the segmentation only stores and manages local data in the data to be written. If the local data is consistent with the local historical written data, the write operation can be performed on the local data, which can reduce the time of the write operation and the amount of data written.
[0066] In a feasible implementation, the above consistency verification can be implemented to determine whether the local data to be written and the local historical written data are the same at the same code position. Specifically, the local data to be written and the local historical written data can be compared bit by bit to obtain a verification result, which can characterize the consistency between the local data to be written and the local historical written data.
[0067] In another feasible implementation manner, the above consistency verification may be implemented as determining whether the redundant check values of the local data to be written and the local historical written data are the same. Specifically, the following steps may be included:
[0068] S301: Calculate and obtain a corresponding first cyclic redundancy check value according to local data to be written.
[0069] It is understood that a cyclic redundancy check value (CRC) is a channel coding technology that generates a short fixed-bit check code based on data such as network data packets or computer files, and can be used to detect or check errors that may occur after data transmission or storage. Specifically, it uses the principle of division and remainder for error detection.
[0070] S303: Determine a second cyclic redundancy check value of the local historical written data.
[0071] In a possible implementation, according to Figure 2 The structure of the storage sub-block shown determines the second cyclic redundancy check value of the local historical written data from the sub-block check area.
[0072] S305: Compare the first cyclic redundancy check value and the second cyclic redundancy check value to obtain a verification result.
[0073] If the data values of the first cyclic redundancy check value and the second cyclic redundancy check value are the same, then the verification result can indicate that the local data to be written and the corresponding local historical written data are consistent.
[0074] If the data values of the first cyclic redundancy check value and the second cyclic redundancy check value are different, then the verification result can indicate that there is a difference between the local data to be written and the corresponding local historical written data.
[0075] S400: When the verification result indicates that there is a difference between the local data to be written and the local historical written data, the local data to be written is written into a second storage space corresponding to the storage sub-block; the second storage space is located in a non-volatile memory.
[0076] In the embodiment of the present application, each storage sub-block corresponds to the second storage space in the non-volatile memory, and the second storage space corresponds to the address interval where the storage block is located. Optionally, the non-volatile memory can also be based on the storage block as a storage unit.
[0077] In one embodiment of the present application, when the verification result indicates that there is a difference between the local data to be written and the local historical written data, the storage sub-block sends a write service request to the non-volatile memory management module, and the write service request includes a storage space identifier corresponding to the storage sub-block. The non-volatile memory management module responds to the write service request of the storage sub-block, determines a second storage space in the non-volatile memory corresponding to the storage space identifier, and performs a write operation to store the local data to be written in the second storage space.
[0078] S500: When the verification result indicates that the local data to be written is consistent with the local historical written data, the writing of the local data to be written is ignored.
[0079] In an embodiment of the present application, multiple storage sub-blocks are traversed, and the above process is implemented on each storage sub-block to complete the storage, update and management of non-volatile data, which can effectively reduce the write time and the amount of data written, improve the write efficiency of data storage, and indirectly extend the service life of the non-volatile memory.
[0080] Figure 3 FIG. 1 shows a schematic diagram of the related structure of a non-volatile memory management module in the Autosar architecture. Figure 3As shown in the figure, the non-volatile memory management module (NVM) is located in the basic software layer (BSW) in the Autosar architecture. It provides asynchronous access management and maintenance services for data, such as periodic storage of key data, reading of power-on data, storage of power-off data, etc. The upper layer of the non-volatile memory management module is RTE (Runtime Environment), and the lower layer is MEMIF (Memory Abstraction Interface), FEE (Flash EEPROM Emulation), EA (EEPROMAbstraction), FLS (Flash Driver), etc. Among them, MEMIF provides a unified memory initialization, read, write, and state management interface for the EA module and the FEE module. The FEE module simulates the Flash as the read and write mode of EEPROM to improve the erase and write life of FLASH. The EA module provides an interface independent of hardware to access EEPROM data. The FLS module mainly provides related operation services such as initialization, read, write, and erase of Flash.
[0081] Regarding the non-volatile memory management (NVM) module, the Autosar architecture specifies four types of non-volatile memory blocks, namely NV Block, RAM Block, ROM Blcok, and Administrative Blcok. Among them, NV Block and RAM Block are essential items, and NV Block is used to store non-volatile data, which can be modified during program execution. It consists of three parts: NV Blcok Header, NV Block Data, and NV Block CRC. NV Blcok Header is optional, which contains Block ID and can be verified after reading data; NV Block CRC is optional, mainly storing the CRC value of NVBlock Data after CRC calculation; NV Block Data is used to store data. In an embodiment of the present application, NVBlock is divided into multiple storage sub-blocks (Sub-Block), and the structure is as follows: Figure 2 As shown, no further details are given here. Each storage sub-block corresponds to a RAM Block, and each storage sub-block also corresponds to a storage block in a non-volatile memory (FEE or EA). Among them, the RAM Block is located in the RAM (Random Access Memory) and is used to store non-volatile data to be written or read. Its composition structure is consistent with that of the NV Block, which can be referred to Figure 4 As shown. Among them, ROM Blcok is located in PFlash (ProgramFlash, program flash memory), which is used to store default data so that it can be restored when the data in NV Block is damaged. Its structure can be referred to Figure 5 As shown, it includes a data area (ROM Block Data). Among them, Administrative Block exists in RAM and is mainly used to describe the properties, status and other information of NV Block.
[0082] The non-volatile memory management (NVM) module provides three types of management for each block, namely Native, Redundant, and Dataset. In the Native management type, it includes 1 NV Block, 1 RAM Block, 1 Administrative Block, and 1 ROM Block (optional). After the NVBlock is split, 1 NV Sub-Block corresponds to 1 Block of the FEE module, such as Figure 6 As shown in the figure, NV Block 0-0 to NV Block 0-n are the n+1 sub-blocks of NV Block 0. In the redundant management type, only the NV Block is divided, and the specific number of divisions can be defined by the user. The ROM Block and RAM Block are not divided, but correspond one-to-one with the Nv Sub-Block, as shown in Figure 7As shown in the figure, Redundant management has two Nv Blocks, and the two Nv Blocks have the same partitioning scheme. The Sub-Blocks of NV Block 0 are divided into NV Block 0-0 to NV Block 0-n, and the Sub-Blocks of NV Block 1 are NV Block 1-0 to NV Block 1-n respectively; Nv Block 0-0 and Nv Block1-0 are redundant with each other, and have the same memory length. When one of them fails, the other sub-block is used for data recovery, and the same applies to the remaining sub-blocks; all Nv Sub-Blocks correspond to the Blocks in the FEE module one by one. Redundant management type can realize redundant backup storage of data. In the Dataset management type, it contains N NV Blocks, 1 RAM Block, 1 Administrative Block, and M ROM Blocks. The NVBlocks and ROM Blocks are independent of each other. The total number of NV Blocks and ROM Blocks must be between 1-255. The nodes of NV Block are 0 to N-1, and the nodes of ROM Block are N to N+M-1. ROM Block and Nv Block share the same RAM Block. Figure 8 1 NV Block and 1 RAM Block are shown, but ROM Block is not shown. Figure 8 As shown, NVBlock is segmented, and the specific number of segmented blocks can be defined by the user, among which ROM Block and RAM Block are not segmented. After segmentation, all Nv Sub-Blocks correspond to the Blocks in the FEE module one by one. In each of the above Nv Sub-Blocks, the local data to be written is read from the corresponding RAM Block. If the local data to be written is different from the local historical written data, the local data to be written is written to the corresponding FEE Block. If they are consistent, the writing and storage of the local data to be written is ignored.
[0083] When writing to the FEE Block, each Block is identified by a unique Blocknumber. When a write request for a certain Nv Sub-Block is received, the Blocknumber corresponding to the Nv Sub-Block is sent to the FEE module, so that the FEE module matches the corresponding Block according to the Blocknumber and performs the corresponding write operation. Furthermore, the FEE module or the EA module provides a 32-bit byte for describing the addressing of the address space to determine the corresponding Block and storage space. As shown in Table 1, the first 16 bits are the BlockNumber, and the last 16 bits are the address offset. The 16-bit BlockNumber consists of the NvMBlockBaseNumber of 16-NvMDatasetSelectionbits and the DataIndex of NvMDatasetSelectionbits.
[0084] Table 1 Block address space description
[0085]
[0086] An embodiment of the present application also provides a data storage device 900, in which a data storage block is divided into multiple storage sub-blocks, each of the multiple storage sub-blocks includes a sub-block header area, a sub-block data area and / or a sub-block check area, wherein the sub-block header area stores a node identifier of the storage sub-block, and the sub-block check area stores a second cyclic redundancy check value of the local historical write data.
[0087] like Fig. 9 As shown, the device 900 may include:
[0088] A first acquisition module 910 is used to traverse the multiple storage sub-blocks in response to a data write request, and acquire the local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory;
[0089] A second acquisition module 920 is used to acquire local historical written data stored in the storage sub-block, where the local historical written data is local data written in a previous round;
[0090] A comparison module 930 is used to perform consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result;
[0091] The writing module 940 is used to write the local data to be written into a second storage space corresponding to the storage sub-block when the verification result indicates that there is a difference between the local data to be written and the local historical written data; the second storage space is located in a non-volatile memory.
[0092] In one embodiment of the present application, the device 900 may include:
[0093] The ignoring module 950 is configured to ignore writing of the local data to be written when the verification result indicates that the local data to be written is consistent with the local historical written data.
[0094] In one embodiment of the present application, the comparison module 930 may include:
[0095] The first comparison unit is used to compare the local data to be written and the local historical written data bit by bit to obtain the verification result, and the verification result represents the consistency between the local data to be written and the local historical written data.
[0096] In one embodiment of the present application, the comparison module 930 may further include:
[0097] A first redundancy check value determining unit, configured to calculate a corresponding first cyclic redundancy check value according to the local data to be written;
[0098] A second redundancy check value determining unit, used to determine a second cyclic redundancy check value of the local historical written data;
[0099] The second comparison unit is used to compare the first cyclic redundancy check value with the second cyclic redundancy check value to obtain the verification result.
[0100] In one embodiment of the present application, the writing module 940 may include:
[0101] a storage space determining unit, configured to, when the verification result indicates that there is a difference between the local data to be written and the local historical written data, respond to a write service request of the storage sub-block, the write service request including a storage space identifier corresponding to the storage sub-block, determine the second storage space in the non-volatile memory corresponding to the storage space identifier
[0102] The writing unit is used to perform a writing operation to store the local data to be written in the second storage space.
[0103] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0104] An embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement a data storage method provided in the above method embodiment.
[0105] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a server to store at least one instruction or at least one program related to a data storage method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement a data storage method provided by the above method embodiment.
[0106] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0107] The embodiment of the present invention further provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes a data storage method provided in the above various optional embodiments.
[0108] It can be seen from the embodiments of the data storage method, device, medium and equipment provided by the present application that
[0109] The solution provided by the present application divides the data storage block into multiple storage sub-blocks. When a data write request is received, the corresponding local data to be written is read from the first storage space corresponding to the storage sub-block, and the local data to be written and the local historical written data are verified for consistency. The local historical written data is the local data written in the previous round. If the verification result indicates that there is a difference between the two, the local data to be written is written into the second storage space and stored in the non-volatile memory. If the two are consistent, the write operation of the local data to be written is ignored, and each storage sub-block is traversed at the same time, and the above process is repeated. The technical solution provided by the present application can reduce the number or time of write operations, and can also reduce the length of data required to be written, thereby improving the write efficiency of data storage.
[0110] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0111] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0112] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0113] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A data storage method, characterized in that: The data storage block is divided into a plurality of storage sub-blocks, and the method comprises: In response to a data write request, traverse the multiple storage sub-blocks and obtain the local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory; Acquire local historical written data stored in the storage sub-block, where the local historical written data is local data written in a previous round; Performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result; When the verification result indicates that there is a difference between the local data to be written and the local historical written data, the local data to be written is written into a second storage space corresponding to the storage sub-block; the second storage space is located in a non-volatile memory; When the verification result indicates that the local data to be written is consistent with the local historical written data, writing of the local data to be written is ignored.
2. The data storage method according to claim 1, characterized in that: The performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result includes: The local data to be written and the local historical written data are compared bit by bit to obtain the verification result, and the verification result represents the consistency between the local data to be written and the local historical written data.
3. The data storage method according to claim 1, characterized in that: The performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result further includes: Calculating a corresponding first cyclic redundancy check value according to the local data to be written; Determining a second cyclic redundancy check value of the local historical written data; The first cyclic redundancy check value and the second cyclic redundancy check value are compared to obtain the verification result.
4. The data storage method according to claim 1, characterized in that: When the verification result indicates that there is a difference between the local data to be written and the local historical written data, writing the local data to be written into a second storage space corresponding to the storage sub-block includes: When the verification result indicates that there is a difference between the local data to be written and the local historical written data, in response to a write service request of the storage sub-block, the write service request includes a storage space identifier corresponding to the storage sub-block, determining the second storage space in the non-volatile memory corresponding to the storage space identifier. A write operation is performed to store the local data to be written in the second storage space.
5. The data storage method according to claim 1, characterized in that: The method further comprises: Each storage sub-block among the multiple storage sub-blocks includes a sub-block header area, a sub-block data area and / or a sub-block check area, wherein the sub-block header area stores the node identifier of the storage sub-block, and the sub-block check area stores the second cyclic redundancy check value of the local historical write data.
6. A data storage device, characterized in that: The data storage block is divided into a plurality of storage sub-blocks, and the device comprises: A first acquisition module, configured to traverse the plurality of storage sub-blocks in response to a data write request, and acquire local to-be-written data corresponding to the storage sub-block from a first storage space corresponding to the storage sub-block; the first storage space is located in a random access memory; A second acquisition module is used to acquire the local historical written data stored in the storage sub-block, where the local historical written data is the local data written in the previous round; A comparison module, used for performing consistency verification on the local data to be written and the local historical written data corresponding to the storage sub-block to obtain a verification result; A writing module, configured to write the local data to be written into a second storage space corresponding to the storage sub-block when the verification result indicates that there is a difference between the local data to be written and the local historical written data; the second storage space is located in a non-volatile memory; The ignoring module is used to ignore the writing of the local data to be written when the verification result indicates that the local data to be written is consistent with the local historical written data.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by a processor to implement a data storage method as described in any one of claims 1 to 5.
8. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement a data storage method as described in any one of claims 1 to 5.
