CN112558868B - Method, device and equipment for storing configuration data - Google Patents

Method, device and equipment for storing configuration data Download PDF

Info

Publication number
CN112558868B
CN112558868B CN202011436860.1A CN202011436860A CN112558868B CN 112558868 B CN112558868 B CN 112558868B CN 202011436860 A CN202011436860 A CN 202011436860A CN 112558868 B CN112558868 B CN 112558868B
Authority
CN
China
Prior art keywords
subspace
configuration item
data
configuration
item data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011436860.1A
Other languages
Chinese (zh)
Other versions
CN112558868A (en
Inventor
刘炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Actions Technology Co Ltd
Original Assignee
Actions Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Actions Technology Co Ltd filed Critical Actions Technology Co Ltd
Priority to CN202011436860.1A priority Critical patent/CN112558868B/en
Publication of CN112558868A publication Critical patent/CN112558868A/en
Application granted granted Critical
Publication of CN112558868B publication Critical patent/CN112558868B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • G06F3/0607Improving or facilitating administration, e.g. storage management by facilitating the process of upgrading existing storage systems, e.g. for improving compatibility between host and storage device
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Abstract

The invention provides a method, a device and equipment for storing configuration data, wherein the method comprises the following steps: acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data; if the free space of the first subspace for storing the configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, determining the first subspace as a target subspace; otherwise, when the next subspace exists and is unoccupied, copying the effective data in the first subspace to the next subspace, and updating the next subspace into the target subspace; when determining that the next subspace does not exist or is occupied, erasing the subspace which stores the configuration item data first, copying the effective data in the first subspace to the erased subspace, and updating the subspace into a target subspace; the configuration item data is sequentially stored to the target subspace. By using the method of the invention, the erasing times of NOR Flash during data storage can be reduced, and the performance can be improved.

Description

Method, device and equipment for storing configuration data
Technical Field
The present invention relates to the field of data storage technologies, and in particular, to a method, an apparatus, and a device for storing configuration data.
Background
NOR and NAND are two major nonvolatile flash technologies on the market today. The NOR is characterized in that the application program can directly run in the NOR Flash chip, and the code does not need to be read into a system RAM (Random Access Memory ); and the transmission efficiency of the NOR FLASH is very high, and the NOR FLASH has very high cost efficiency when transmitting with small capacity of 1-4 MB. In addition, the NOR FLASH chip has the advantages of high reliability, small volume, high density, erasability, rewriteability and the like, so the NOR FLASH chip is widely applied to embedded systems.
The NOR Flash chip comprises a configuration storage space, and the operation of the embedded system on the configuration storage space mainly comprises reading configuration data, storing the configuration data, erasing the configuration data and the like. In the scheme of storing configuration data, NOR Flash is usually written in units of bytes, erased in units of blocks, and an erase operation must be performed before a write operation is performed. And when the NOR Flash is erased, the embedded system cannot read and execute the data on the NOR Flash, and the erasing time of the NOR Flash is generally tens of milliseconds, so that the performance of the embedded system, particularly the real-time performance of the embedded system, is seriously affected.
Disclosure of Invention
The invention provides a method, a device and equipment for storing configuration data, which solve the problem that when the NOR Flash stores the configuration data, the data is frequently erased, and the performance of an embedded system is affected.
In a first aspect, the present invention provides a method of configuring a data store, the method comprising:
acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data;
if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, determining the first subspace as a target subspace;
otherwise, when the next subspace exists and is unoccupied, copying the valid data in the first subspace to the next subspace, and updating the next subspace into a target subspace;
when determining that the next subspace does not exist or the next subspace is occupied, erasing the subspace which stores the configuration item data first, copying the effective data in the first subspace to the erased subspace, and updating the subspace to be the target subspace;
and storing the configuration item data to the target subspace sequentially.
Optionally, the configuration storage space is divided into two subspaces.
Optionally, any subspace of the plurality of subspaces comprises a plurality of space blocks with preset granularity.
Optionally, storing the configuration item data sequentially to the target subspace includes:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
Optionally, copying the valid data in the first subspace to the next subspace/erased subspace comprises:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
copying the valid data in the first subspace to the next subspace/erased subspace.
Optionally, storing the configuration item data sequentially to the target subspace includes:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
And updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
Optionally, the method further comprises:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
Optionally, for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by a first bit value, and other space blocks are identified by a second bit value.
Optionally, the configuration item data includes header data and configuration parameters, and the configuration parameters include configuration item identification and configuration data, and further includes:
receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
And determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
Optionally, after reading the configuration parameter, the method further includes:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
In a second aspect, the invention provides an apparatus for configuration data storage comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is used for reading the program in the memory and executing the following steps:
acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data;
if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, determining the first subspace as a target subspace;
otherwise, when the next subspace exists and is unoccupied, copying the valid data in the first subspace to the next subspace, and updating the next subspace into a target subspace;
When determining that the next subspace does not exist or the next subspace is occupied, erasing the subspace which stores the configuration item data first, copying the effective data in the first subspace to the erased subspace, and updating the subspace to be the target subspace;
and storing the configuration item data to the target subspace sequentially.
Optionally, the configuration storage space is divided into two subspaces.
Optionally, any subspace of the plurality of subspaces comprises a plurality of space blocks with preset granularity.
Optionally, the processor sequentially stores the configuration item data to the target subspace, including:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
Optionally, the processor copies the valid data in the first subspace to the next subspace/erased subspace, including:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
Copying the valid data in the first subspace to the next subspace/erased subspace.
Optionally, the processor sequentially stores the configuration item data to the target subspace, including:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
Optionally, the processor is further configured to:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
Optionally, for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by a first bit value, and other space blocks are identified by a second bit value.
Optionally, the configuration item data includes header data and configuration parameters, the configuration parameters including configuration item identification and configuration data, and the processor is further configured to:
receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
Optionally, after the processor reads the configuration parameters, the processor is further configured to:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
In a third aspect, the present invention provides an apparatus for configuration data storage, comprising:
The data acquisition unit is used for acquiring configuration item data to be stored and determining the expected occupied space of the configuration item data;
the first space determining unit is used for determining that the first subspace is a target subspace if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space;
a second space determining unit, configured to copy, when it is determined that a next subspace exists and is unoccupied, valid data in the first subspace to the next subspace, and update the next subspace as a target subspace;
a third space determining unit, configured to determine that when there is no next subspace or the next subspace is occupied, erase a subspace in which configuration item data is stored first, copy valid data in the first subspace to the erased subspace, and update the subspace to a target subspace;
and the storage unit is used for sequentially storing the configuration item data into the target subspace.
Optionally, the configuration storage space is divided into two subspaces.
Optionally, any subspace of the plurality of subspaces comprises a plurality of space blocks with preset granularity.
Optionally, the storing unit sequentially stores the configuration item data to the target subspace, including:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
Optionally, the second space determining unit copies the valid data in the first subspace to the next subspace, including:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
and copying the valid data in the first subspace to the next subspace.
Optionally, the third space determining unit copies the valid data in the first subspace to an erased subspace, including:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
and copying the valid data in the first subspace to the erased subspace.
Optionally, the storing unit sequentially stores the configuration item data to the target subspace, including:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
Optionally, the storage unit is further configured to:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
Optionally, for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by a first bit value, and other space blocks are identified by a second bit value.
Optionally, the configuration item data includes header data and configuration parameters, the configuration parameters include configuration item identification and configuration data, and the storage unit is further configured to:
Receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
Optionally, after the storage unit reads the configuration parameters, the storage unit is further configured to:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
In a fourth aspect, the present invention provides a computer program medium having a computer program stored thereon, which when executed by a processor performs the steps of a method of configuring data storage as provided in the first aspect above.
The method, the device and the equipment for storing the configuration data have the following beneficial effects:
the storage of the configuration item data on the Nor Flash is realized, the erasing operation during the writing of the configuration item data is reduced, the influence of the erasing operation on the system performance is reduced, and the performance of the embedded system is improved.
Drawings
FIG. 1 is a flow chart of a method for configuring data storage according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of configuration item data according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating a configuration space division according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a correspondence relationship between a search bitmap and a space block according to an embodiment of the present invention;
FIG. 5 is a flow chart of partitioning a configuration memory space into two subspaces for configuration data storage according to an embodiment of the present invention;
FIG. 6 is a flowchart of a method for reading configuration parameters according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of an apparatus for configuring data storage according to an embodiment of the present invention;
fig. 8 is a schematic diagram of an apparatus for storing configuration data according to an embodiment of the present invention.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It should be noted that the embodiments described in the following exemplary examples do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
In the following, some terms in the embodiments of the present disclosure are explained for easy understanding by those skilled in the art.
(1) The term "NOR Flash" in embodiments of the present disclosure is a non-volatile Flash technology that can be written and reprogrammed in blocks of memory cells that are symmetrical to a block.
(2) The term "random access memory" (Random Access Memory, RAM), also called main memory, in embodiments of the present disclosure is an internal memory that exchanges data directly with a central processor. Can be read and written at any time and is fast, usually as a temporary data storage medium for an operating system or other program in operation, and is used in computer and digital systems to temporarily store programs, data and intermediate results.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure based on the embodiments of the present invention.
NOR and NAND are two major nonvolatile flash technologies on the market today.
The NOR is characterized in that the application program can directly run in the NOR Flash chip, and the code does not need to be read into a system RAM (Random Access Memory ); and the transmission efficiency of the NOR FLASH is very high, and the NOR FLASH has very high cost efficiency when transmitting with small capacity of 1-4 MB. In addition, the NOR FLASH chip has the advantages of high reliability, small volume, high density, erasability, rewriteability and the like, so the NOR FLASH chip is widely applied to embedded systems.
The NOR Flash chip comprises a configuration storage space, and the operation of the embedded system on the configuration storage space mainly comprises reading configuration data, storing the configuration data, erasing the configuration data and the like.
The embedded system has the following requirements for storing configuration data:
(1) Reliability: the configuration data is not lost when the power is accidentally lost, and the error configuration data is not read;
(2) Performance: the read-write speed is as fast as possible;
(3) Resource overhead: the code is also as simple as possible using as little RAM as possible.
In the scheme of storing configuration data, NOR Flash is usually written in units of bytes, erased in units of blocks, and an erase operation must be performed before a write operation is performed.
The characteristic of NOR Flash causes that when the NOR Flash is erased, data on the NOR Flash cannot be read, and the erasing time of the NOR Flash generally takes tens of milliseconds, so that the performance of an embedded system is affected.
In addition, if power is accidentally lost after the NOR Flash performs an erase operation, the configuration item data may be lost.
In view of the above problems, embodiments of the present application provide a method, an apparatus, and a device for storing configuration data, which divide a configuration storage space into a plurality of subspaces, and optimize a configuration data storing process, so as to reduce an erasing operation and improve performance.
The following provides an implementation manner of a method, a device and equipment for storing configuration data.
Example 1
An embodiment of the present invention provides a flowchart of a method for configuring data storage, as shown in fig. 1, including:
step S101, acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data;
the configuration item data is obtained by packaging configuration data to be stored into a preset format, and header data for checking, auxiliary storage and other operations is added to the configuration data during packaging.
The configuration item data obtained after encapsulation comprises header data and configuration parameters, wherein the configuration parameters comprise configuration item identifiers and configuration data, and the configuration item identifiers are used for identifying names of the configuration data.
The header data includes, but is not limited to, a HASH value HASH and a cyclic redundancy check bit CRC.
As shown in fig. 2, an embodiment of the present invention provides a schematic diagram of configuration item data, where the configuration item data includes:
head check bit Magic: the size is 8 bits, and the initial check bit of the configuration item data is used for marking whether the configuration item data is complete;
status bit State: the size is 8 bits, which is used for marking whether the configuration item data is valid data, wherein the status bits comprise two values: the first state bit value and the second state bit value can be distinguished by using 0, 1 or 1, 0 or any different value.
The first state bit value is used for indicating that the configuration item data is valid data, the second state bit value is used for indicating that the configuration item data is non-valid data, and the valid data is the latest stored configuration item data in the configuration item data belonging to the same configuration item.
The first status bit is valued to the second status bit, indicating that the status of the configuration item data is changed from valid data to invalid data.
It should be noted that, the first state bit value may be changed to the second state bit value, but the second state bit value cannot be changed to the first state bit value, that is, the configuration item data set as invalid data is not reset as valid data.
As an alternative embodiment, the first state bit has a value of 1, and the second state bit has a value of 0.
Hash value Hash: the size of the configuration item identifier is reduced to 8 bits, and the configuration item identifier is used for preliminary comparison when the configuration item data is read.
Cyclic redundancy check bits (Cyclic Redundancy Check, CRC): the size is 8 bits, and is used for checking whether the configuration item data have errors in the storage process.
Configuration item identification Size Name Size: the size is 5 bits, and is used for representing the size of the configuration item identifier;
configuration Data Size: a size of 11 bits for characterizing the size of the configuration data;
the configuration item identifies Name: the size is 1 to 31 bytes, and the identification of the complete configuration item is used for distinguishing the configuration item data;
configuration Data n: the size is 0 to 2047 bytes, and specific data in the item data are configured;
alignment check bit Pad Data: the size is 0 to 31 bytes, and is used for aligning the configuration item data according to the principle that the length is aligned according to the fixed size.
It should be noted that, the specific form of the configuration item data and the content and the size of each configuration item given above are only given as examples of one configuration item data in the embodiment of the present invention, and the form of the configuration item data in the embodiment of the present invention is not limited in any way, and any format of the configuration item data capable of implementing the configuration data storage method in the embodiment of the present invention may be applied to the embodiment of the present invention, and those skilled in the art may perform other forms of configuration item data encapsulation.
The expected occupied space is a space occupied in the configuration storage space obtained by calculation according to the configuration item data, and the space can be realized by the existing calculation method and is not described herein.
Step S102, judging whether the free space of the first subspace for storing the configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, if so, executing step S103, otherwise, executing step S104;
it should be noted that, the first subspace and the first, second, what words are referred to in the embodiments of the present invention are merely conceptual distinction, and do not generate any limitation of advantages and disadvantages, and are not described in detail later.
As shown in fig. 3, an embodiment of the present invention provides a schematic diagram of configuration space division.
Fig. 3 specifically provides two schematic views of configuration space division, from left to right:
(1) A schematic diagram of the configuration storage space, namely an undivided original configuration storage space;
(2) Dividing the configuration storage space into a first subspace and a second subspace, wherein the total of the first subspace and the second subspace is divided into a dividing schematic diagram;
(3) Dividing the configuration storage space into a first subspace, a second subspace and a third subspace;
the above-mentioned three subspaces are divided into three.
The three subspaces are taken as specific examples of the plurality of subspaces, and other number of schemes are not described in detail, and when the method is implemented, the specific division number can be determined according to specific implementation conditions.
It should be noted that, the size of any subspace obtained by dividing the configuration memory space must be a multiple of the minimum erase unit of NOR Flash.
In addition, when the configuration storage space is divided, the subspace may be divided into a plurality of subspaces with equal sizes, or the subspace may be divided into a plurality of subspaces with different sizes according to specific implementation cases, which is not limited in the embodiment of the present invention.
Step S103, determining the first subspace as a target subspace, and executing step S107;
in performing configuration data storage, there are two cases:
firstly, storing configuration item data for the first time in all unoccupied idle subspaces;
for the first case, the first subspace of the last stored configuration item data is not searched, and the first free subspace is updated to be the target subspace.
Second, non-primary storage configuration item data;
and if so, determining that the first subspace is the target subspace, and if not, executing the following steps.
Step S104, determining that the next subspace exists and is unoccupied, if yes, executing step S105, otherwise, executing step S106;
when the free space of the first subspace for storing the configuration item data last time is not larger than the expected occupied space, namely, the free space in the first subspace is insufficient for storing the data to be stored, whether a next subspace exists or not needs to be judged, whether the next subspace is unoccupied or not is judged, and the data to be stored is stored in the unoccupied next subspace.
If there is no next subspace or the next subspace is occupied, an erase operation is performed in step S106.
Step S105, copying the valid data in the first subspace to the next subspace, updating the next subspace to a target subspace, and executing step S107;
as an optional implementation manner, before copying the valid data in the first subspace to the next subspace, determining the latest stored configuration item data as valid data in the configuration item data belonging to the same configuration item in the configuration item data stored in the first subspace.
It should be noted that, the configuration item data belonging to the same configuration item refer to configuration item data with the same configuration item identifier, and will not be described herein.
According to the embodiment of the invention, whether the configuration data is valid is identified through the value of the status bit in the configuration item data, wherein the valid data is the configuration item data with the value of the status bit being the value of the first status bit, for example, the value of the status bit is 1.
The judgment of the effective data can also be realized in other modes, for example, the storage sequence of the configuration item data in the same subspace is marked, when the effective data is determined, the configuration item data belonging to the same configuration item are screened, and the configuration item data with the last storage sequence is used as the effective data.
The valid data can distinguish new data from old data in the configuration item data of the same configuration item, and only the valid data, namely the latest stored configuration item data in the configuration item data of the same configuration item, is copied when the data is copied, so that the storage space can be saved;
the effective data in the configuration item data is copied, so that the latest data can be stored in the configuration storage space forever, and the data loss caused by unexpected power failure is avoided.
Step S106, erasing the subspace which stores the configuration item data firstly, copying the effective data in the first subspace to the erased subspace, updating the subspace to be a target subspace, and then executing step S107;
as an optional implementation manner, before copying the valid data in the first subspace to the erased subspace, determining that the latest stored configuration item data in the configuration item data belonging to the same configuration item is valid data in the configuration item data stored in the first subspace.
According to the embodiment of the invention, whether the configuration data is valid is identified through the value of the status bit in the configuration item data, wherein the valid data is the configuration item data with the value of the status bit being the value of the first status bit, for example, the value of the status bit is 1.
The judgment of the effective data can also be realized in other modes, for example, the storage sequence of the configuration item data in the same subspace is marked, when the effective data is determined, the configuration item data belonging to the same configuration item are screened, and the configuration item data with the last storage sequence is used as the effective data.
If the copying of the valid data in the first subspace to the next subspace in the step S105 or the copying of the valid data in the first subspace to the erased subspace in the step S106 is performed, the free subspace in any one of the copied valid data and the erased subspace is not larger than the expected occupied space, an error message is returned, and the configuration item data is not stored.
The scheme of the embodiment of the invention erases the subspace which stores the configuration item data firstly only when the free space of the first subspace which stores the configuration item data last time is not larger than the expected occupied space and the next subspace is occupied, and the invalid subspace is erased uniformly in advance when the system is started, so that the execution times of the erasing operation are greatly reduced when the configuration item data is stored.
Step S107, storing the configuration item data in the target subspace sequentially.
The above sequential storage means that after the configuration item data is stored in the target subspace, there is no free storage space between the two configuration item data.
The embodiment of the invention identifies whether the configuration item data is valid or not through the value of the status bit in the configuration item data, and as an optional implementation manner, the configuration item data is sequentially stored in the target subspace, and the status bit is further updated, which specifically comprises:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
It should be noted that, the function of the status bit is to indicate whether the configuration item data is valid data, where the value of the first status bit indicates that the configuration item data is valid data, and the value of the second status bit indicates that the configuration item data is non-valid data.
In the step S105 and the step S106, when valid data copying is performed, the value of the status bit is read, and if the status bit is the value of the first status bit, the configuration item data is valid data; if the second status bit is valued, the configuration item data is non-valid data, and the valid data and the non-valid data can be rapidly distinguished through the valued of the status bit.
In the step S107, after the configuration item data is sequentially stored in the target subspace, the value of the status bit of the configuration item data stored in the target subspace is updated.
For example, 10 pieces of configuration item data exist in the target subspace, from configuration item data 1 to configuration item data 10, at this time, after the configuration item data 11 are sequentially stored in the target subspace, the configuration item data 8 in the 10 pieces of configuration item data are the same configuration item as the configuration item data 11, and the value of the status bit of the configuration item data 8 is updated to the second status bit.
Thus, when the target subspace is filled and the copy operation is performed, the invalid data represented by the configuration item data 8 is not copied.
When the configuration item data is stored, the value of the status bit of the configuration item data is updated, so that the copying of the effective data is realized, and meanwhile, the error data is prevented from being read when the data is read.
By the description of the above embodiment, the configuration storage space is divided into a plurality of subspaces, new configuration data is sequentially written into the free space of the first subspace storing configuration item data, and no erasing operation is performed.
Only when one subspace is full, the valid data in the subspace is copied to the other free subspace, and the configuration item data is continuously stored in the free space of the other free subspace.
Only when the subspace storing the configuration item data last time is fully written and no free subspace exists, the subspace storing the configuration item data first is erased again, the effective data is copied to the subspace, and the configuration item data continues to be stored in the subspace.
Therefore, the Flash storage always has one part of effective configuration data, and the configuration data damage caused by unexpected power failure can be avoided.
In addition, the technical effect of reducing the erasing times can be achieved by the scheme, but in the embodiment, the configuration items are stored in disorder on the NOR Flash storage, so that traversing search is needed to be carried out on the whole configuration storage space for finding out the effective data, and the efficiency is low.
In order to accelerate the searching speed and avoid reading and comparing invalid storage contents, a bitmap is selected to record the storage position of the current valid configuration item.
First, the subspace is divided into spatial blocks:
as an alternative embodiment, any subspace of the plurality of subspaces comprises a plurality of space blocks with a preset granularity.
The preset granularity may be determined according to a specific implementation, for example, the granularity is set to 32 bytes.
The space blocks are obtained by dividing the subspaces, and the sizes of the space blocks are all the preset granularity.
For example, the first subspace is 4096 bytes, the second subspace is 8192 bytes, and the granularity is 1024 bytes, so that the first subspace is divided into 4 space blocks, and the second subspace is divided into 8 space blocks.
When dividing, all subspaces need to be divided, and the rest space which is less than the preset granularity cannot exist.
For example, the first subspace is 4096 bytes, the preset granularity is set to 3072 bytes, and the first subspace is divided into a 3072-byte space block and a 1024-byte space block, which are not allowed.
In an embodiment where each subspace is divided into space blocks of a preset granularity, storing the configuration item data sequentially to the target subspace includes:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
And taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
In the embodiment where each subspace is divided into space blocks with a preset granularity, the expected occupied space of the configuration item data is first determined: and determining the number of space blocks occupied by the configuration item data according to the size of the configuration item data.
For example, the size of the configuration item data is 48 bytes, and the size of the space block is 32 bytes, and the number of the space blocks occupied by the configuration item data is 2.
The above-mentioned sequential searching of the empty space blocks means that according to the sequence of the space blocks in the target subspace, it is determined whether the space blocks are unoccupied empty space blocks sequentially from front to back, if yes, the searching is stopped, otherwise, the backward searching is continued until the unoccupied empty space blocks are found.
The meaning of storing the configuration item data in sequence is that after one free space block is full, the configuration item data is stored in the next free block in sequence.
It should be noted that, when the configuration item data is stored, the initial position of the configuration item data is aligned according to a preset granularity, and the length of the configuration item data is aligned according to the preset granularity.
Specifically, the granularity is set to be 32 bytes, the length of the configuration item data is 48 bytes, and the configuration item data is larger than one space block but smaller than two space blocks, so that when the configuration item data is stored, the configuration item data is stored from the first free space block and occupies two space blocks.
The above embodiment illustrates the division of the subspace into space blocks, and in order to record the storage condition of configuration item data in the space blocks, the embodiment of the present invention adds a search bitmap in the RAM.
The search bitmap includes bits corresponding one-to-one to the spatial blocks in the target subspace, each bit being used to identify a data storage state of the corresponding spatial block, wherein the bits may be one or more bits.
Dividing each subspace into space blocks with preset granularity, identifying the data storage state of the corresponding space blocks by using bits corresponding to the space blocks in the target subspace one by one in a search bitmap, and determining the data storage state of the space blocks by searching the bits corresponding to the space blocks in the bitmap.
It should be noted that, the data storage state of the spatial block corresponding to the identifier may be:
(1) Marking whether the corresponding space block stores configuration item data or not;
(2) And marking whether the corresponding space block is a starting space block occupied by the latest configuration item data.
As described above, the data storage state includes not storing data, storing valid data, storing invalid data, wherein storing valid data further includes storing a start position of valid data and storing a non-start position of valid data. The data storage state of the spatial block corresponding to the identifier may be the following embodiment:
embodiment 1: setting the bit corresponding to the space block as two bits, and determining the three storage states through the value condition of the two bits;
for example, setting 00 corresponds to not storing data, 01 and 10 corresponds to storing invalid data, and 11 corresponds to storing valid data;
for another example, setting 00 corresponds to not storing data, 01 corresponds to storing invalid data, 10 corresponds to a non-start position storing valid data, and 11 corresponds to a start position storing valid data.
Embodiment 2: setting a bit corresponding to the space block, and mapping whether the space block stores data or not by two values of the bit.
When searching data, the space block with data can be directly positioned, and whether the data is valid or not can be judged from the state bit in the space block with data.
For example, set 0 to correspond to non-stored data, 1 to correspond to stored data;
further, whether the spatial block stores valid data may be mapped by setting the value of the bit.
For example, setting 0 corresponds to non-stored data and storing invalid data, and 1 corresponds to storing valid data;
further, whether the spatial block stores the start position of valid data may be mapped by setting the value of the bit.
For example, setting 0 corresponds to a non-start position where no data is stored, invalid data is stored, and valid data is stored, and 1 corresponds to a start position where valid data is stored;
as an optional implementation manner, the embodiment of the invention identifies the data storage state of the corresponding space blocks in the following manner, and for a plurality of space blocks in the target subspace, the initial space block occupied by the latest configuration item data of the same configuration item is identified by adopting a first bit value, and other space blocks are identified by adopting a second bit value.
As an alternative embodiment, the first bit value may be 1, and the second bit value may be 0.
As shown in fig. 4, an embodiment of the present invention provides a schematic diagram of a correspondence between a search bitmap and a space block.
Dividing the storage medium according to a certain granularity, such as the granularity of 32bytes, aligning the starting addresses of the writing of the configuration item data according to the granularity, recording the starting position of the effective configuration item by using a bitmap, wherein a corresponding bit of 1 in the bitmap represents that the granularity is an effective configuration item starting position, and a value of 0 represents that the granularity has no data or no configuration item starting position.
In the specific embodiment shown in fig. 4, each bit in the search bitmap corresponds to a space block with the granularity of 32B in the configuration storage space one by one, for example, when the storage medium is 8KB in size, only 32 bitmaps with the size of bytes are needed, so that a small amount of bitmap data is used, and the storage offset position is recorded, thereby avoiding the need to traverse the search of the whole configuration storage space.
When it is determined that there is a configuration item data change in the target subspace, the search bitmap of the random access memory RAM is updated.
In a specific implementation, the bitmap updating method at least includes any one of the following embodiments:
when the configuration item data are sequentially stored in the target subspace, updating the value of the bit corresponding to the initial space block occupied by the configuration item data into a first bit value;
updating the value of the bit corresponding to the occupied initial space block to a second bit value, wherein the configuration item data in the target subspace and the latest stored configuration item data belong to the same configuration item;
when the effective data in the first subspace is copied to any free subspace, updating the value of the bit corresponding to the initial space block occupied by the effective data into a first bit value;
When a subspace of configuration item data stored at first is erased, updating the value of a bit corresponding to a space block in the subspace to be a second bit value;
determining a space block where the starting position of the effective data is located, and updating bits corresponding to the space block in the search bitmap to a first bit value indicating the starting position;
and updating other bits in the search bitmap to a second bit value indicating a non-starting position.
In the following, taking configuration storage space divided into two subspaces, subspace 1 and subspace 2, the two subspaces are divided into a plurality of space blocks, configuration data storage is performed as an example, and the complete data storage step is explained.
As shown in fig. 5, an embodiment of the present invention provides a flowchart for partitioning a configuration storage space into two subspaces for configuration data storage, including:
step S501, acquiring configuration item data to be stored, and determining the number N of space blocks expected to be occupied by the configuration item data;
and determining the number of space blocks occupied by the configuration item data according to the size of the configuration item data. For example, the size of the configuration item data is 48 bytes, and the size of the space block is 32 bytes, and the number N of the space blocks occupied by the configuration item data is 2.
Step S502, judging whether the number M of the idle space blocks in the first subspace for storing the configuration item data is larger than the number N of the space blocks occupied by the configuration item data in the last time in a plurality of subspaces obtained by dividing the configuration storage space, if so, executing step S503, otherwise, executing step S504;
for example, the subspace 1, the subspace 2 and the subspace 3 obtained by dividing the configuration storage space are the subspace 2, and whether the number M of the free space blocks in the subspace 2 is larger than N is judged.
Step S503, determining the first subspace as a target subspace, and executing step S507;
assuming that m=3, M is greater than N, determining the subspace 2 as a target subspace;
step S504, determining that the next subspace exists and is unoccupied, if yes, executing step S505, otherwise, executing step S506;
assuming that m=1, M is smaller than N, and it is determined whether the above subspace 3 is an unoccupied free subspace.
Step S505, copying the valid data in the first subspace to the next subspace, updating the next subspace to a target subspace, and executing step S507;
the subspace 3 is an unoccupied free subspace, valid data in the subspace 2 is copied to the subspace 3, and the subspace 3 is updated to be a target subspace;
Step S506, erasing the subspace which stores the configuration item data firstly, copying the effective data in the first subspace to the erased subspace, updating the subspace to be a target subspace, and executing step S507;
the subspace 3 is occupied, the subspace 1 which stores configuration item data firstly is erased, valid data in the subspace 2 is copied to the erased subspace 1, and the subspace 1 is updated to be a target subspace;
step S507, storing the configuration item data to the target subspace sequentially.
According to the above space block division and setting of the search bitmap, a method for reading configuration parameters using the search bitmap is provided below, including:
receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
it should be noted that, when the configuration parameter is read, only the start space block identified by the first bit value in the search bitmap is read only in the target subspace according to the data of the search bitmap, and specifically, in the specific embodiment shown in fig. 4, only the storage space corresponding to the bit with the search bitmap of 1 is read.
Acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
it should be noted that, the Hash value Hash is compared first, and if the Hash matching is successful, the complete comparison of the configuration identifier is performed.
As an optional implementation manner, matching the Hash of the configuration item data in the space block with the standard Hash, and determining the configuration item data matched with the Hash;
comparing the identifier of the configuration item data matched with the Hash with the standard identifier to determine whether the configuration item data are identical, and if not, continuing to search the configuration item data matched with the Hash;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
It should be noted that after reading the configuration parameters, the method further includes:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
After the Hash and the configuration item data with the same identification are read, the CRC of the read configuration data is calculated, if the CRC is the same as the CRC in the header data, the configuration parameters are returned, and otherwise, error information is returned.
It should be noted that if the last configuration item has an error, such as a CRC error, which may be an unexpected power-off during writing, resulting in a write interrupt, then the valid configuration item on the last configuration item in the current subspace is used.
As shown in fig. 6, an embodiment of the present invention provides a flowchart for reading configuration parameters, including:
step S601, receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
step S602, determining a starting space block identified by a first bit value according to the search bitmap, and acquiring header data in configuration item data in the starting space block;
step S603, determining whether the second hash value in the header data matches the first hash value, if yes, executing step S604, otherwise executing step S603;
step S604, judging whether the second configuration item identifier in the header data is matched with the first configuration item identifier, if yes, executing step S605, otherwise executing step S603;
Step S605, determining a starting space block in which a configuration parameter to be read is located, and starting to read the configuration parameter from the starting space block;
step S606, calculating a second Cyclic Redundancy Check (CRC) bit of the read configuration parameter, and comparing the second Cyclic Redundancy Check (CRC) bit with the first Cyclic Redundancy Check (CRC) bit in the header data;
step S607, determining whether the second CRC is identical to the first CRC, if yes, executing step S608, otherwise executing step S609;
step S608, returning configuration parameters;
in step S609, an error message is returned.
Example 2
An embodiment of the present invention provides a schematic diagram of an apparatus 700 for configuration data storage, including a memory 701 and a processor 702, as shown in fig. 7, wherein:
the memory is used for storing a computer program;
the processor is used for reading the program in the memory and executing the following steps:
acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data;
if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, determining the first subspace as a target subspace;
Otherwise, when the next subspace exists and is unoccupied, copying the valid data in the first subspace to the next subspace, and updating the next subspace into a target subspace;
when determining that the next subspace does not exist or the next subspace is occupied, erasing the subspace which stores the configuration item data first, copying the effective data in the first subspace to the erased subspace, and updating the subspace to be the target subspace;
and storing the configuration item data to the target subspace sequentially.
Optionally, the configuration storage space is divided into two subspaces.
Optionally, any subspace of the plurality of subspaces comprises a plurality of space blocks with preset granularity.
Optionally, the processor sequentially stores the configuration item data to the target subspace, including:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
Optionally, the processor copies the valid data in the first subspace to the next subspace/erased subspace, including:
In the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
copying the valid data in the first subspace to the next subspace/erased subspace.
Optionally, the processor sequentially stores the configuration item data to the target subspace, including:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
Optionally, the processor is further configured to:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
Optionally, for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by a first bit value, and other space blocks are identified by a second bit value.
Optionally, the configuration item data includes header data and configuration parameters, the configuration parameters including configuration item identification and configuration data, and the processor is further configured to:
receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
Optionally, after the processor reads the configuration parameters, the processor is further configured to:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
An embodiment of the present invention provides a schematic diagram of an apparatus for configuring data storage, as shown in fig. 8, including:
A data acquisition unit 801, configured to acquire configuration item data to be stored, and determine an expected occupied space of the configuration item data;
a first space determining unit 802, configured to determine, from a plurality of subspaces obtained by dividing a configuration storage space, that a first subspace storing configuration item data is a target subspace if a free space of the first subspace storing configuration item data last time is greater than the expected occupied space;
a second space determining unit 803, configured to copy valid data in the first subspace to a next subspace when it is determined that the next subspace exists and is unoccupied, and update the next subspace as a target subspace;
a third space determining unit 804, configured to, when determining that there is no next subspace or the next subspace is occupied, erase a subspace in which configuration item data is stored first, copy valid data in the first subspace to the erased subspace, and update the subspace to a target subspace;
and a storage unit 805, configured to sequentially store the configuration item data into the target subspace.
Optionally, the configuration storage space is divided into two subspaces.
Optionally, any subspace of the plurality of subspaces comprises a plurality of space blocks with preset granularity.
Optionally, the storing unit sequentially stores the configuration item data to the target subspace, including:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
Optionally, the second space determining unit copies the valid data in the first subspace to the next subspace, including:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
and copying the valid data in the first subspace to the next subspace.
Optionally, the third space determining unit copies the valid data in the first subspace to an erased subspace, including:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
and copying the valid data in the first subspace to the erased subspace.
Optionally, the storing unit sequentially stores the configuration item data to the target subspace, including:
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
Optionally, the storage unit is further configured to:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
Optionally, for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by a first bit value, and other space blocks are identified by a second bit value.
Optionally, the configuration item data includes header data and configuration parameters, the configuration parameters include configuration item identification and configuration data, and the storage unit is further configured to:
Receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
Optionally, after the storage unit reads the configuration parameters, the storage unit is further configured to:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
The present invention also provides a computer program medium having stored thereon a computer program which, when executed by a processor, implements the steps of a method of configuration data storage provided in the above-described embodiment 1.
In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or modules, which may be in electrical, mechanical, or other forms.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
The foregoing has described in detail the technical solutions provided herein, and specific examples have been used to illustrate the principles and embodiments of the present application, where the above examples are only used to help understand the methods and core ideas of the present application; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (12)

1. A method of configuring a data store, comprising:
acquiring configuration item data to be stored, and determining the expected occupied space of the configuration item data;
if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space, determining the first subspace as a target subspace;
otherwise, when the next subspace exists and is unoccupied, copying the valid data in the first subspace to the next subspace, and updating the next subspace into a target subspace; the effective data are the latest stored configuration item data in the configuration item data belonging to the same configuration item;
when determining that the next subspace does not exist or the next subspace is occupied, erasing the subspace which stores the configuration item data first, copying the effective data in the first subspace to the erased subspace, and updating the subspace to be the target subspace;
sequentially storing the configuration item data into the target subspace, and setting the value of the status bit of the configuration item data as the value of the first status bit;
And updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
2. The method of claim 1, wherein the configuration storage space is divided into two subspaces.
3. The method of claim 1, wherein any of the plurality of subspaces comprises a plurality of spatial blocks of a predetermined granularity.
4. A method according to claim 3, wherein sequentially storing the configuration item data to the target subspace comprises:
sequentially searching idle space blocks in the target subspace according to the number of the space blocks occupied by the configuration item data;
and taking the searched idle space blocks as starting positions for storing the configuration item data, and sequentially storing the configuration item data.
5. The method of claim 1, wherein copying valid data in the first subspace to the next subspace/erased subspace comprises:
in the configuration item data stored in the first subspace, determining that the latest stored configuration item data is effective data in the configuration item data belonging to the same configuration item;
Copying the valid data in the first subspace to the next subspace/erased subspace.
6. A method according to claim 3, further comprising:
updating a search bitmap of the RAM when determining that the configuration item data of the target subspace changes;
the search bitmap includes bits in one-to-one correspondence with spatial blocks in the target subspace, each bit being used to identify a data storage state of a corresponding spatial block.
7. The method of claim 6, wherein the step of providing the first layer comprises,
and for a plurality of space blocks in the target subspace, the starting space block occupied by the latest configuration item data of the same configuration item is identified by adopting a first bit value, and other space blocks are identified by adopting a second bit value.
8. The method of claim 7, wherein the configuration item data comprises header data and configuration parameters, the configuration parameters comprising configuration item identification and configuration data, further comprising:
receiving a configuration parameter reading instruction, and determining a first hash value and a first configuration item identifier related to the configuration parameter;
determining a starting space block of a first bit value identifier according to the search bitmap;
Acquiring head data in configuration item data in the initial space block, and respectively matching the first hash value and the first configuration item identifier with a second hash value and a second configuration item identifier in the head data correspondingly;
and determining a starting space block in which the configuration parameters to be read are located according to the matching result, and starting to read the configuration parameters from the starting space block.
9. The method of claim 8, further comprising, after reading the configuration parameters:
calculating a second Cyclic Redundancy Check (CRC) of the read configuration parameters, and comparing the second CRC with the first CRC in the header data;
and if the second cyclic redundancy check bit CRC is inconsistent with the first cyclic redundancy check bit CRC, returning error information.
10. A device for configuring data storage, comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor being arranged to read the program in the memory and to perform the method of configuration data storage according to any one of claims 1 to 9.
11. An apparatus for configuring data storage, comprising:
The data acquisition unit is used for acquiring configuration item data to be stored and determining the expected occupied space of the configuration item data;
the first space determining unit is used for determining that the first subspace is a target subspace if the free space of the first subspace for storing configuration item data last time is larger than the expected occupied space in a plurality of subspaces obtained by dividing the configuration storage space;
a second space determining unit, configured to copy, when it is determined that a next subspace exists and is unoccupied, valid data in the first subspace to the next subspace, and update the next subspace as a target subspace; the effective data are the latest stored configuration item data in the configuration item data belonging to the same configuration item;
a third space determining unit, configured to determine that when there is no next subspace or the next subspace is occupied, erase a subspace in which configuration item data is stored first, copy valid data in the first subspace to the erased subspace, and update the subspace to a target subspace;
the storage unit is used for sequentially storing the configuration item data into the target subspace and setting the value of the state bit of the configuration item data as the value of the first state bit; and updating the value of the status bit of the configuration item data belonging to the same configuration item as the latest stored configuration item data into a second status bit value in the configuration item data stored in the target subspace.
12. A computer program medium, characterized in that a computer program is stored thereon, which program, when being executed by a processor, realizes the steps of the method of configuration data storage according to any of claims 1 to 9.
CN202011436860.1A 2020-12-07 2020-12-07 Method, device and equipment for storing configuration data Active CN112558868B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011436860.1A CN112558868B (en) 2020-12-07 2020-12-07 Method, device and equipment for storing configuration data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011436860.1A CN112558868B (en) 2020-12-07 2020-12-07 Method, device and equipment for storing configuration data

Publications (2)

Publication Number Publication Date
CN112558868A CN112558868A (en) 2021-03-26
CN112558868B true CN112558868B (en) 2024-04-09

Family

ID=75060317

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011436860.1A Active CN112558868B (en) 2020-12-07 2020-12-07 Method, device and equipment for storing configuration data

Country Status (1)

Country Link
CN (1) CN112558868B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239114A (en) * 2021-05-13 2021-08-10 中国邮政储蓄银行股份有限公司 Data storage method, data storage device, storage medium and electronic device
CN113282247A (en) * 2021-06-24 2021-08-20 京东科技控股股份有限公司 Data storage method, data reading method, data storage device, data reading device and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6687815B1 (en) * 2000-02-01 2004-02-03 Sun Microsystems, Inc. Method and apparatus for storing non-volatile configuration information
CN1913040A (en) * 2005-08-12 2007-02-14 中兴通讯股份有限公司 Method for configuring parameter in NOR FLASH
CN103442000A (en) * 2013-08-22 2013-12-11 北京星网锐捷网络技术有限公司 Method and device for replacing WEB caches and HTTP proxy server
CN105528301A (en) * 2015-12-07 2016-04-27 中国人民解放军信息工程大学 NAND Flash memory garbage collection method
CN106484331A (en) * 2015-09-29 2017-03-08 华为技术有限公司 A kind of data processing method, device and flash memory device
CN110968253A (en) * 2018-09-29 2020-04-07 阿里巴巴集团控股有限公司 Data storage method, device and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4414451B2 (en) * 2007-08-03 2010-02-10 富士通株式会社 Storage control program, storage control device, and storage control method
JP2015082166A (en) * 2013-10-22 2015-04-27 ルネサスエレクトロニクス株式会社 Method for managing data storage flash memory and program therefor
CN103902337A (en) * 2014-03-14 2014-07-02 北京金山网络科技有限公司 Data download method and device
JP6524039B2 (en) * 2016-09-23 2019-06-05 東芝メモリ株式会社 Memory system and control method
CN108496161A (en) * 2017-09-29 2018-09-04 深圳市大疆创新科技有限公司 Data buffer storage device and control method, data processing chip, data processing system
US10613787B2 (en) * 2018-01-31 2020-04-07 EMC IP Holding Company LLC Techniques for rebalancing storage between subspaces

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6687815B1 (en) * 2000-02-01 2004-02-03 Sun Microsystems, Inc. Method and apparatus for storing non-volatile configuration information
CN1913040A (en) * 2005-08-12 2007-02-14 中兴通讯股份有限公司 Method for configuring parameter in NOR FLASH
CN103442000A (en) * 2013-08-22 2013-12-11 北京星网锐捷网络技术有限公司 Method and device for replacing WEB caches and HTTP proxy server
CN106484331A (en) * 2015-09-29 2017-03-08 华为技术有限公司 A kind of data processing method, device and flash memory device
CN105528301A (en) * 2015-12-07 2016-04-27 中国人民解放军信息工程大学 NAND Flash memory garbage collection method
CN110968253A (en) * 2018-09-29 2020-04-07 阿里巴巴集团控股有限公司 Data storage method, device and system

Also Published As

Publication number Publication date
CN112558868A (en) 2021-03-26

Similar Documents

Publication Publication Date Title
US11474972B2 (en) Metadata query method and apparatus
US11704239B2 (en) Garbage collection method for storage medium, storage medium, and program product
CN112558868B (en) Method, device and equipment for storing configuration data
WO2014144449A1 (en) Apparatus and method for translation from multi-dimensional to linear address space in storage
CN110147203B (en) File management method and device, electronic equipment and storage medium
CN112631950B (en) L2P table saving method, system, device and medium
CN110399333B (en) Method, apparatus and computer program product for deleting snapshots
CN109885577B (en) Data processing method, device, terminal and storage medium
CN115292266A (en) High-reliability log storage method based on memory
CN109189759B (en) Data reading method, data query method, device and equipment in KV storage system
CN106095331B (en) Control method for internal resources of fixed large file
US10761932B2 (en) Data and metadata storage in storage devices
CN111435286B (en) Data storage method, device and system
CN108829342B (en) Log storage method, system and storage device
CN112463020A (en) Data access method, device and equipment based on Flash
CN115857811A (en) Data processing method and device, solid state disk and readable storage medium
CN111241090A (en) Method and device for managing data index in storage system
CN115328851A (en) Data protection method, device, equipment and medium
CN113467724A (en) CRC (Cyclic redundancy check) code storage method, device, equipment and medium
CN116917873A (en) Data access method, memory controller and memory device
CN112988037A (en) Static wear leveling method, terminal and computer-readable storage medium
CN107749307B (en) Rewriting method, device, equipment and storage medium for storage system in failure of writing disk
CN110795297B (en) Electronic equipment testing method and device
CN115993938B (en) Disk formatting method, apparatus, device and computer readable storage medium
WO2024032194A1 (en) Memory swapping processing method and apparatus, and storage medium and electronic apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant