Data storage method and device, electronic equipment, storage medium and program product

By inversely calculating the original stored data of the FLASH memory and calculating the data to be stored, we can determine whether an erase operation is needed, and solve the life problem caused by frequent erase writing, realize the effective storage of data and extend the device service life.

CN118915970AInactive Publication Date: 2024-11-08NINGBO FOTILE KITCHEN WARE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411003896.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-11-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Frequent erase write operations of FLASH memory will lead to life problems, and it is difficult for the prior art to effectively reduce the number of erase operations.

Method used

By inversely calculating the original stored data in non-volatile memory and calculating the data to be stored, it is determined whether an erase operation is required. If there is no need to erase, the original stored data will be rewrite to store the data to be stored, reducing erase Number of operations.

Benefits of technology

It effectively reduces the number of erasing operations of FLASH memory and extends its service life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118915970A_ABST
    Figure CN118915970A_ABST
Patent Text Reader

Abstract

The invention provides a data storage method and device, electronic equipment, a storage medium and a program product. The method comprises the following steps: in response to a data storage request, obtaining original storage data of a storage space in a nonvolatile memory; carrying out negation operation on the original storage data, and carrying out AND operation on a negation operation result and to-be-stored data; and in response to the result of the AND operation being zero, rewriting original storage data of the storage space according to the to-be-stored data so as to store the to-be-stored data in the storage space. According to the method, the number of times of erasing operation can be reduced, and the service life of the FLASH is prolonged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data storage, and in particular to a data storage method, device, electronic device, storage medium, and program product. Background Art

[0002] The characteristics of non-volatile memory FLASH determine that when writing data to FLASH, the data in one or more sectors (the smallest unit of erasure) must be erased first, and then the corresponding data can be written. FLASH erasure generally has a life limit, and too frequent erasing and writing will cause FLASH life problems. Summary of the invention

[0003] The technical problem to be solved by the present disclosure is to overcome the above-mentioned defects in the prior art and to provide a data storage method, device, electronic device, storage medium, and program product.

[0004] The present invention solves the above technical problems through the following technical solutions:

[0005] In a first aspect, a data storage method is provided, comprising:

[0006] In response to a data storage request, obtaining original stored data in a storage space in a non-volatile memory;

[0007] Performing a negation operation on the original stored data, and performing an AND operation on the result of the negation operation and the data to be stored;

[0008] In response to the result of the AND operation being zero, the original stored data in the storage space is rewritten according to the data to be stored, so as to store the data to be stored in the storage space.

[0009] Optionally, rewriting the storage space according to the data to be stored includes:

[0010] Determining bit by bit whether the data to be stored is the same as the original stored data;

[0011] The storage address in the storage space corresponding to the target bit with different value is rewritten.

[0012] Optionally, before the step of performing a negation operation on the original stored data, the step further includes:

[0013] In response to the storage space being non-empty and the original stored data being different from the data to be stored, a step of performing a negation operation on the original stored data is executed.

[0014] Optionally, the data to be stored includes a compression encoding result of log data and the log record format;

[0015] Before the step of performing an AND operation on the result of the negation operation and the data to be stored, the method includes:

[0016] Generate log record format;

[0017] The log record format is filled into the compression encoding result of the log data to obtain the data to be stored.

[0018] Optionally, the log record format includes a timestamp of the log data;

[0019] The timestamp is determined according to the deviation between the generation time of the log data and the standard time;

[0020] When the deviation is greater than the duration threshold, determining the deviation as the timestamp;

[0021] When the deviation is less than or equal to the duration threshold, the inverse code of the deviation is determined as the timestamp.

[0022] Optionally, the log record format includes a control header; the control header includes at least one of the following: log data length, a feature code, a CRC16 checksum, and a control header reservation; the feature code is used for upgrading and transforming the log format.

[0023] In a second aspect, a data storage device is provided, comprising:

[0024] An acquisition module, used for acquiring original storage data of the storage space in the non-volatile memory;

[0025] An operation module, used for performing a negation operation on the original stored data, and performing an AND operation on the result of the negation operation and the data to be stored;

[0026] The storage module is used for rewriting the storage space according to the data to be stored in response to the result of the AND operation being zero, so as to store the data to be stored in the storage space.

[0027] According to a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, wherein when the processor executes the computer program, the data storage method described in any one of the first aspects is implemented.

[0028] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the data storage method described in any one of the first aspects is implemented.

[0029] In a fifth aspect, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the data storage method described in any one of the first aspects is implemented.

[0030] On the basis of being in accordance with the common sense in the art, the above-mentioned preferred conditions can be arbitrarily combined to obtain the preferred embodiments of the present disclosure.

[0031] The positive and progressive effect of the present disclosure lies in that: before the present disclosure stores the data to be stored in the storage space with the original storage data, it is determined whether an erase operation needs to be performed by combining a negation operation with an AND operation. When it is determined that the data to be stored cannot be stored in the storage space by improving the original storage data, an erase operation needs to be performed to achieve effective storage of the data to be stored; when it is determined that there is no need to perform an erase operation on the storage space, the data to be stored is stored in the storage space by rewriting the original storage data of the storage space, thereby reducing the number of erase operations and increasing the service life of the FLASH. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flowchart of a data storage method provided by an exemplary embodiment of the present disclosure;

[0033] Figure 2a A schematic diagram of a FLASH scene application provided by an exemplary embodiment of the present disclosure;

[0034] Figure 2b A schematic diagram of another FLASH application scenario provided by an exemplary embodiment of the present disclosure;

[0035] Figure 3 A schematic diagram of a module of a data storage device provided by an exemplary embodiment of the present disclosure;

[0036] Figure 4 The present invention provides a schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0037] The present disclosure is further described below by way of examples, but the present disclosure is not limited to the scope of the examples.

[0038] Prefixes such as "first" and "second" are used in the embodiments of the present disclosure only to distinguish different description objects, and have no limiting effect on the position, order, priority, quantity or content of the described objects. The use of prefixes such as ordinal numbers to distinguish description objects in the embodiments of the present disclosure does not constitute a limitation on the described objects. For the statement of the described objects, please refer to the description in the context of the claims or embodiments, and no unnecessary limitation should be constituted due to the use of such prefixes. In addition, in the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.

[0039] In the embodiments of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of the stored data involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0040] Figure 1 A flowchart of a data storage method provided by an exemplary embodiment of the present disclosure, the method comprising the following steps:

[0041] Step 101: In response to a data storage request, obtain original storage data in a storage space in a non-volatile memory.

[0042] The embodiments of the present disclosure are applicable to various types of non-volatile memory FLASH, such as SPI Flash (a type of FLASH that uses a serial peripheral interface SPI for communication).

[0043] The size of the storage space in step 101 is determined according to the size of the data to be stored. Assuming that the storage space required to store the data to be stored is n, the original storage data of the storage space n is obtained.

[0044] Step 102: perform a negation operation on the original stored data, and perform an AND operation on the result of the negation operation and the data to be stored.

[0045] Step 103 : In response to the result of the AND operation being zero, rewrite the storage space according to the data to be stored, so as to store the data to be stored in the storage space.

[0046] According to the characteristics of FLASH writing, after performing an erase operation on FLASH, the erased area will be set to a preset state, usually all 1. The process of storing data in FLASH is also the process of rewriting the content in FLASH from 1 to 0. At the same time, it should be known that FLASH does not need to be erased before writing to FLASH. Step 102 and step 103 are to determine whether an erase operation is required before writing data; when the result of the AND operation is zero, it is determined that there is no need to perform an erase operation, and the data to be stored can be stored in the storage space by improving the original stored data; when the result of the AND operation is non-zero, it is determined that the data to be stored cannot be stored in the storage space by improving the original stored data, and an erase operation needs to be performed.

[0047] For example, the original storage data of the storage space in the non-volatile memory is 00000011 (3), and the data to be stored is 00000010 (2). The original storage data is negated, and the result of the negation operation is 11111100. 11111100 and the data to be stored 00000010 are ANDed, and the result of the AND operation is zero. This means that by rewriting the original storage data, the data to be stored can be written into the storage space with the original storage data, without performing an erase operation on the storage space, thereby reducing the number of erase operations and increasing the service life of the FLASH.

[0048] For another example, the original storage data in the storage space of the non-volatile memory is 00000101(5), and the data to be stored is 00000010(2). The original storage data is negated, and the result of the negation operation is 11111010. 11111010 and the data to be stored 00000010 are ANDed, and the result of the AND operation is zero, which is 0000010, not 0. This means that the data to be stored cannot be written into the storage space with the original storage data by overwriting the original storage data, and it is necessary to perform an erase operation on the storage space to achieve effective storage of the data to be stored.

[0049] In the present embodiment, before the data to be stored is stored in the storage space with the original storage data, a negation operation is combined with an AND operation to determine whether an erase operation needs to be performed. When it is determined that the data to be stored cannot be stored in the storage space by improving the original storage data, an erase operation needs to be performed to achieve effective storage of the data to be stored. When it is determined that there is no need to perform an erase operation on the storage space, the data to be stored is stored in the storage space by rewriting the original storage data of the storage space, thereby reducing the number of erase operations and increasing the service life of the FLASH.

[0050] In one embodiment, the step of rewriting the storage space according to the data to be stored includes: determining bit by bit whether the data to be stored is the same as the original stored data, and rewriting the storage address in the storage space corresponding to the target bit with different value.

[0051] For example, taking the original stored data as 00000011 and the data to be stored as 00000010 as an example, perform bit by bit judgment from left to right. If the values ​​of the last bits of the two are different, the "1" in the storage address corresponding to the last bit (target bit) of the original stored data is rewritten as "0".

[0052] In this embodiment, by determining whether the data to be stored is the same as the original stored data bit by bit, and then rewriting the storage space according to the determination result, the data to be stored is accurately stored in the storage space.

[0053] In one embodiment, before step 102, the method further includes: in response to the storage space being not empty and the original stored data being different from the data to be stored, executing a step of negating the original stored data.

[0054] In this embodiment, before executing the step of negating the original stored data, it is first determined whether the storage space is empty (or whether the storage space has just been erased) and whether the original stored data is different from the data to be stored. If the storage space is empty, the data to be stored is directly written into the storage space to achieve data storage; if the storage space is not empty, it is further determined whether the original stored data is the same as the data to be stored. When the storage space is not empty and the original stored data is the same as the data to be stored, no action is required; when the storage space is not empty and the original stored data is different from the data to be stored, step 102 is executed to determine whether it is necessary to perform an erase operation on the storage space before the data to be stored can be stored.

[0055] In this embodiment, before performing the negation operation on the original stored data, it is first determined whether the storage space is not empty and whether the original stored data is different from the data to be stored. When the above conditions are met, step 102 is executed, thereby determining the validity of the data operation and reducing the amount of calculation.

[0056] In one embodiment, the data to be stored includes the compression coding result of the log data and the log record format. Before the step of performing AND operation on the result of the inversion operation and the data to be stored, it includes: generating a log record format, filling the log record format with the compression coding result of the log data to obtain the data to be stored.

[0057] The log record format can be set according to the actual situation. The log record format can include but is not limited to at least one of the following: timestamp, formatting, log level, log type, control header, log length, etc. The timestamp, formatting, log level, log type, control header, etc. can be represented in a coded form.

[0058] Log data may include, but is not limited to: equipment / system power on / off records, equipment / system fault alarm records, equipment / system operation records, etc.

[0059] The log record format can be filled in the head, tail or middle of the compression encoding result, and the embodiment of the present disclosure does not specifically limit this.

[0060] It should be noted that the execution steps of generating the log record format can be performed synchronously with obtaining the original stored data and performing the inversion operation, and the execution steps of generating the log record format can also be performed synchronously or asynchronously with obtaining the original stored data and performing the inversion operation, and the embodiments of the present disclosure do not specifically limit this.

[0061] In this embodiment, the log data and the log record format are compressed and encoded, which can reduce the space occupied by the stored data.

[0062] In one embodiment, different compression algorithms are used for compression encoding for different log record formats, so as to effectively compress the stored data, reduce the space occupied by the stored data, and thus increase the life of the FLASH.

[0063] The data storage method of this embodiment is applicable to the circular log recording scenario. Circular log recording is to divide a fixed FLASH space to write log data one by one, and when the record is full, rewrite from the divided starting address to meet the circular requirement.

[0064] The following uses the circular logging scenario as an example to further illustrate the data storage process.

[0065] Design a FLASH space for N circular log records. The FLASH space includes M sectors. Assume that the storage space for recording a single log data is n, and the size of a sector is S, so the maximum number of records stored in a single sector is Sm = S / n. The FLASH space includes two storage conditions: full and not full. Before writing the data to be stored for the first time, the M sectors will be erased. See Figure 2a , when the FLASH space is not full, only a single piece of data to be stored needs to be written, for example Figure 2a In the above example, log 1 (log data) and log 2 (log data) are directly written to sector 2 without additional erase operations until M sectors are filled. Figure 2b , start writing from the first record of sector 1. Since sector 1 has been written at this time, it is necessary to determine whether an erase operation is required before writing the data to be stored.

[0066] It is understandable that a sector can store one log data or multiple log data. In the case where a sector can store multiple log data and the sector has been written, for example, sector 1 can store multiple log data and the sector has been written, if the storage of log data a does not require an erase operation, then a portion of sector 1 is directly rewritten to store the stored log data a in sector 1. However, log data b cannot be directly stored in sector 1 by rewriting, and an erase operation needs to be performed on sector 1. At this time, log data a in sector 1 can be extracted first and / or log data a can be backed up. After the erase operation is performed on sector 1, log data a and log data b can be written to sector 1.

[0067] It should be noted that the number of sectors can be set according to actual conditions. Of course, when there is room in the FLASH space, the larger the value of M, the better. The larger M is, the lower the utilization rate of each space is. In this way, the probability of erasure is lower and the life of the FLASH is longer. Of course, M must satisfy M>=(N / Sm+1) because when the record is full and overwrites the previous storage, we will erase the record of one sector, that is, erase Sm records at a time. If M does not meet this condition, the valid records may be less than N after the record is full, which is inconsistent with the actual situation.

[0068] Through the data storage method of this embodiment, effective circular storage of device logs can be achieved for later maintenance, searching, and restoring of the operating status of the device.

[0069] In one embodiment, the log record format includes a timestamp of the log data. The timestamp is determined based on the deviation of the log data generation time from the standard time. When the deviation is greater than a duration threshold, the deviation is determined as the timestamp; when the deviation is less than or equal to the duration threshold, the inverse of the deviation is determined as the timestamp.

[0070] Among them, the standard time can be set according to actual conditions.

[0071] In this embodiment, the log date is not represented by the conventional year, month, day, hour, minute, and second, but is stored as a deviation after a standard time. According to the life cycle of a general product, a 4-byte number can basically meet all scenarios, so the storage space of the date can be reduced to 4 bytes; at the same time, because the deviation characteristics are from small to large, if no special processing is performed, the effective number of digits at the beginning is 0, so when the time deviation value is less than or equal to 2 31 When the inverse code is taken, it is greater than 2 31 In this way, 1 bit of Flash is used as much as possible to represent valid data.

[0072] It should be noted that 2 31 This is just an example. The value can be set according to the actual situation. For example, half of the 32-bit data is taken. The principle is to encode with 1 as much as possible.

[0073] In one embodiment, the log record format includes a control header; the control header includes at least one of the following: log data length, a feature code, a CRC16 checksum, and a control header reservation; the feature code is used for upgrading and transforming the log format.

[0074] In order to be able to more accurately verify the log and identify the log, in the present embodiment, when designing the log space, not only the effective bytes of the log data are reserved, but also a control header is added on each log. The number of bytes of the control header can be set according to actual conditions. The number of bytes of the control header can be a fixed value, for example, the number of bytes of the control header is 20 bytes, including 4 bytes for characterizing the length of the log data, 4 bytes for characterizing the feature code, 2 bytes for characterizing the CRC16 checksum, and 10 bytes reserved for characterizing the control header. The number of bytes of the control header can be a dynamic value, so that the length of the stored data is variable, and the diversity of the data / log record format can be increased.

[0075] The feature code can be understood as a special number. Different special numbers can correspond to different log formats, so that subsequent programs only need to parse the log formats according to different special numbers. In this way, log formats of different formats at different times can be parsed, so that after the log format is upgraded, the content corresponding to the old format can also be parsed as usual.

[0076] In the present embodiment, the log format can be upgraded and transformed through the feature code, and the log data accuracy can be verified through the CRC16 check code. Due to the addition of the log control header, the log length is variable, and each log data does not require equal length, which greatly facilitates our use. When encountering logs that need to store different formats, there is no need to open up new storage space. At the same time, due to the addition of the feature code, the log content can have different parsing methods, so that after the log format is upgraded, the content corresponding to the old format can also be parsed as usual, which increases the compatibility of the device / system.

[0077] In one embodiment, the log record format also includes a log type. In this embodiment, when designing the log type, the encoding length is fixed, two bytes, and the probability of the log type appearing is counted by product type and arranged from high to low, and then encoded as follows:

[0078] Log Type Probability coding Log 1 100% 0b1111111111111111 Log 2 99% 0b1111111111111110 … … … Log N 1% 0b0000000000000000

[0079] In one embodiment, Huffman compression is used to compress and encode log data. The specific steps are as follows:

[0080] S1. Extract the characters required by the log data, and give N characters and corresponding weight values ​​according to the application scenario;

[0081] S2. Find the two smallest characters, with the smaller one on the right and the larger one on the left, to form a binary tree, and add the sum of the weights to the character queue;

[0082] S3. Recursively follow this process and find the smallest two characters, with the smaller one on the right and the larger one on the left, to form a binary tree.

[0083] S4. Mark each left branch as 1 and each right branch as 0;

[0084] S5. The path from the root node to the leaf node is the encoding of the corresponding characters in the log.

[0085] In this embodiment, through the above steps, frequently occurring codes can be represented by fewer bits, reducing the space occupied by the log and adapting to the characteristics of FLASH. The code with a large weight value is 1, and the code with a small weight value is 0, which reduces the change in the number of bits during erasure and increases the life of FLASH.

[0086] In one embodiment, a backup area is allocated for each piece of stored data, and the storage space of the backup area is consistent with the main area, which further ensures the security and accuracy of data storage.

[0087] The following takes a single log data as an example to explain the process of writing log data into the storage space: generate a log record format, fill the log record format into the compression code of the log data, obtain storage data, and write the storage data into the storage space of the primary area and the storage space of the backup area. Alternatively, generate a log record format, and write the log data and the log record format into the storage space of the primary area and the storage space of the backup area in sequence.

[0088] In the process of writing SPIFLASH log, the log record format must be written at the end, no matter the data in the main area or the backup area is written. Since the log data is read by reading the control header one by one to find the total number of logs in FLASH, if the log record format is written first, but the power is off abnormally at this time, the log content is not written successfully, and this record may be mistakenly regarded as a normal record. Conversely, write the log data first and then write the log record format. As long as the log record format is abnormal, the log data in FLASH can be handled abnormally, thereby ensuring the validity of the data stored in FLASH.

[0089] The following describes the process of reading log data:

[0090] Step 1: Read the log record format of the main area;

[0091] Step 2: Determine whether the feature code, log length, etc. contained in the log record format are normal. If abnormal, jump to step 5;

[0092] Step 3: If step 2 is normal, read the valid data (log data);

[0093] Step 4: Perform CRC16 check on valid data. If the check succeeds, the data is read successfully. If it fails, jump to step 5.

[0094] Step 5: Read the log record format of the backup area;

[0095] Step 6: Determine whether the feature code length, log length, etc. contained in the log record format are normal. If abnormal, the reading fails. If successful, jump to step 7;

[0096] Step 7: Read the backup valid data (log data);

[0097] Step 8: Perform valid data verification. If it fails, the data reading fails. If it succeeds, jump to step 9;

[0098] Step 9: Restore the main area data.

[0099] Restoring the primary area data in step 9 means synchronizing the backup data to the primary area.

[0100] Corresponding to the aforementioned data storage method embodiment, the present disclosure also provides an embodiment of a data storage device.

[0101] Figure 3 A schematic diagram of a data storage device provided by an exemplary embodiment of the present disclosure, the device comprising:

[0102] The acquisition module 21 is used to acquire the original storage data of the storage space in the non-volatile memory;

[0103] An operation module 22, used for performing a negation operation on the original stored data, and performing an AND operation on the result of the negation operation and the data to be stored;

[0104] The storage module 23 is used for rewriting the storage space according to the data to be stored in response to the result of the AND operation being zero, so as to store the data to be stored in the storage space.

[0105] Optionally, when rewriting the storage space according to the data to be stored, the storage module 23 is specifically configured to:

[0106] Determining bit by bit whether the data to be stored is the same as the original stored data;

[0107] The storage address in the storage space corresponding to the target bit with different value is rewritten.

[0108] Optionally, it also includes:

[0109] The logic operation module is used to call the operation module in response to the storage space being not empty and the original stored data being different from the data to be stored.

[0110] Optionally, the data to be stored includes a compression encoding result of log data and the log record format;

[0111] The device also includes:

[0112] Generate module, used to generate log record format;

[0113] A filling module is used to fill the log record format into the compression encoding result of the log data, obtain the data to be stored and call the operation module.

[0114] Optionally, the log record format includes a timestamp of the log data;

[0115] The timestamp is determined according to the deviation between the generation time of the log data and the standard time;

[0116] When the deviation is greater than the duration threshold, determining the deviation as the timestamp;

[0117] When the deviation is less than or equal to the duration threshold, the inverse code of the deviation is determined as the timestamp.

[0118] Optionally, the log record format includes a control header; the control header includes at least one of the following: log data length, a feature code, a CRC16 checksum, and a control header reservation; the feature code is used for upgrading and transforming the log format.

[0119] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only illustrative, wherein the units described as separate components may or may not be physically separated, and the components as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution.

[0120] Figure 4 This is a structural schematic diagram of an electronic device shown in an example embodiment of the present disclosure, the electronic device includes a memory, a processor, and a computer program stored in the memory and used to run on the processor, and when the processor executes the computer program, the data storage method described in any of the above embodiments is implemented. Figure 4 The electronic device 30 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0121] like Figure 4 As shown, the electronic device 30 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 30 may include, but are not limited to: at least one processor 31, at least one memory 32, and a bus 33 connecting different system components (including the memory 32 and the processor 31).

[0122] The bus 33 includes a data bus, an address bus, and a control bus.

[0123] The memory 32 may include a volatile memory, such as a random access memory (RAM) 321 and / or a cache memory 322 , and may further include a read-only memory (ROM) 323 .

[0124] The memory 32 may also include a program tool 325 (or utility) having a set (at least one) of program modules 324, such program modules 324 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.

[0125] The processor 31 executes various functional applications and data processing by running the computer programs stored in the memory 32, such as the data storage method provided in any of the above embodiments.

[0126] The electronic device 30 may also communicate with one or more external devices 34 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 35. Furthermore, the electronic device 30 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 36. As shown, the network adapter 36 communicates with other modules of the electronic device 30 via a bus 33. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.

[0127] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.

[0128] The embodiments of the present disclosure further provide a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the data storage method provided by any of the above embodiments is implemented.

[0129] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.

[0130] The embodiment of the present disclosure further provides a computer program product, including a computer program, which implements any of the above-mentioned data storage methods when executed by a processor.

[0131] Among them, the program code for executing the computer program product of the present disclosure can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.

[0132] Although the specific embodiments of the present disclosure are described above, those skilled in the art should understand that this is only an example, and the protection scope of the present disclosure is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present disclosure, but these changes and modifications all fall within the protection scope of the present disclosure.

Claims

1. A data storage method, It is characterized in that include: In response to a data storage request, obtaining original stored data in a storage space in a non-volatile memory; Performing a negation operation on the original stored data, and performing an AND operation on the result of the negation operation and the data to be stored; In response to the result of the AND operation being zero, the original stored data in the storage space is rewritten according to the data to be stored, so as to store the data to be stored in the storage space.

2. The data storage method according to claim 1, It is characterized in that Rewriting the storage space according to the data to be stored includes: Determining bit by bit whether the data to be stored is the same as the original stored data; The storage address in the storage space corresponding to the target bit with different value is rewritten.

3. The data storage method according to claim 1, It is characterized in that Before the step of performing a negation operation on the original stored data, the method further includes: In response to the storage space being non-empty and the original stored data being different from the data to be stored, a step of performing a negation operation on the original stored data is executed.

4. The data storage method according to any one of claims 1 to 3, It is characterized in that The data to be stored includes the compression encoding result of the log data and the log record format; Before the step of performing an AND operation on the result of the negation operation and the data to be stored, the method includes: Generate log record format; The log record format is filled into the compression encoding result of the log data to obtain the data to be stored.

5. The data storage method according to claim 4, It is characterized in that The log record format includes a timestamp of the log data; The timestamp is determined according to the deviation between the generation time of the log data and the standard time; When the deviation is greater than the duration threshold, determining the deviation as the timestamp; When the deviation is less than or equal to the duration threshold, the inverse code of the deviation is determined as the timestamp.

6. The data storage method according to claim 4, It is characterized in that The log record format includes a control header; the control header includes at least one of the following: log data length, a feature code, a CRC16 check code, and a control header reservation; the feature code is used for upgrading and transforming the log format.

7. A data storage device, It is characterized in that include: An acquisition module, used for acquiring original storage data of the storage space in the non-volatile memory; An operation module, used for performing a negation operation on the original stored data, and performing an AND operation on the result of the negation operation and the data to be stored; The storage module is used for rewriting the storage space according to the data to be stored in response to the result of the AND operation being zero, so as to store the data to be stored in the storage space.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and for running on the processor, It is characterized in that When the processor executes the computer program, the data storage method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the data storage method according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the data storage method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for solving problem of write failure of STT-RAM cache

    CN111580750A

  • User attribute data updating method and device, server and storage medium

    CN112035493A

  • Solid state disk name space creation method and device, equipment and readable storage medium

    CN113590032A

  • Apparatus and method for managing data of flash memory

    US20070061504A1