CN114518834A - Information storage method and device and electronic equipment - Google Patents

Information storage method and device and electronic equipment Download PDF

Info

Publication number
CN114518834A
CN114518834A CN202011293723.7A CN202011293723A CN114518834A CN 114518834 A CN114518834 A CN 114518834A CN 202011293723 A CN202011293723 A CN 202011293723A CN 114518834 A CN114518834 A CN 114518834A
Authority
CN
China
Prior art keywords
storage unit
information
storage
bitmap
memory
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.)
Granted
Application number
CN202011293723.7A
Other languages
Chinese (zh)
Other versions
CN114518834B (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.)
China Mobile Communications Group Co Ltd
China Mobile IoT Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile IoT 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 China Mobile Communications Group Co Ltd, China Mobile IoT Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202011293723.7A priority Critical patent/CN114518834B/en
Publication of CN114518834A publication Critical patent/CN114518834A/en
Application granted granted Critical
Publication of CN114518834B publication Critical patent/CN114518834B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • 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/0638Organizing or formatting or addressing of data
    • 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]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses an information storage method, an information storage device and electronic equipment, wherein the method comprises the following steps: receiving an update request for first data information stored in a first storage unit, wherein the first storage unit is a storage unit in the first memory; in response to the update request, storing second data information for updating the first data information in a second storage unit based on bitmap information, wherein the bitmap information is used for indicating the storage state of each storage unit in the first storage, and the second storage unit is a storage unit in the first storage, and the storage state of the second storage unit is characterized as an idle state; and updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state. The embodiment of the invention prolongs the service life of the memory.

Description

Information storage method and device and electronic equipment
Technical Field
The present invention relates to the field of storage technologies, and in particular, to an information storage method and apparatus, and an electronic device.
Background
A non-volatile memory (NVM), also called a non-volatile memory, refers to a memory in which information stored in the NVM can still exist for a long time after the power is turned off and is not easy to lose. The non-volatile memory plays an increasingly important role in a storage system gradually due to the advantages of high storage density, low power consumption, random read-write, byte addressing and the like, particularly the characteristic that original data can be reserved after power failure.
Flash memory is a non-volatile memory having the characteristics of a non-volatile memory. Due to the hardware characteristic of the flash memory, when data is updated again to a storage unit in which data has been written, all data in the storage unit needs to be read out first according to the minimum erasing and writing unit supported by the flash memory, and after the new data is combined, the storage unit is erased integrally, and then the new data is written in the storage unit. Since most program write operations exhibit significant locality and non-uniformity, in existing flash memories, the number of times each memory cell modifies data may be different, resulting in different erase times for each memory cell in the memory, and the memory cells in the write operation set may reach the lifetime limit earlier than other memory cells, thereby causing data errors. Therefore, the service life of the existing flash memory is short.
Disclosure of Invention
The embodiment of the invention aims to provide an information storage method, an information storage device and electronic equipment, which can solve the problem that the service life of the existing flash memory is short.
In a first aspect, an embodiment of the present invention provides an information storage method, including:
receiving an update request for first data information stored in a first storage unit, wherein the first storage unit is a storage unit in the first memory;
in response to the update request, storing second data information for updating the first data information in a second storage unit based on bitmap information, wherein the bitmap information is used for indicating the storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, and the storage state of the second storage unit is characterized as an idle state;
and updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
In a second aspect, an embodiment of the present invention provides an information storage apparatus, including:
a receiving module, configured to receive an update request for first data information stored in a first storage unit, where the first storage unit is a storage unit in the first memory;
a storage module, configured to store, in response to the update request, second data information for updating the first data information in a second storage unit based on bitmap information, where the bitmap information is used to indicate a storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, where a storage state of the storage unit is characterized as an idle state;
and the updating module is used for updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect.
In the embodiment of the invention, the second data information used for updating the first data information stored in the first storage unit is stored in the second storage unit in the idle state according to the bitmap information in the first storage, so that frequent erasing operation on the first storage unit is avoided when data of the same service is updated for multiple times, the probability of bad areas in the first storage is reduced, and the service life of the first storage is prolonged.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a flow chart of an information storage method provided by an embodiment of the invention;
FIG. 2 is a second flowchart of an information storage method according to an embodiment of the present invention;
FIG. 3 is a block diagram of an information storage device provided by an embodiment of the present invention;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
The terms first, second and the like in the description and in the claims of the present invention are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that embodiments of the invention may be practiced otherwise than as specifically illustrated and described herein. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The information storage method provided by the embodiment of the invention is described in detail by specific embodiments and application scenarios thereof with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a flowchart of an information storage method according to an embodiment of the present invention, and as shown in fig. 1, the method includes the following steps:
step 101, receiving an update request for first data information stored in a first storage unit, where the first storage unit is a storage unit in the first memory.
Step 102, in response to the update request, storing second data information for updating the first data information in a second storage unit based on bitmap information, where the bitmap information is used to indicate a storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, which is characterized by a storage state being an idle state.
And 103, updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
In the embodiment of the present invention, the above method may be applied to an electronic device having a memory, and the control unit of the electronic device controls writing or reading of data stored in the memory.
In step 101, the first memory may be a flash memory because the first memory can still exist for a long time after the power of the electronic device is turned off and is not easily lost in order to store the information. Generally, for a flash memory, its storage space may be composed of a certain number of blocks (blocks), and each Block may be divided into a plurality of pages (pages) of fixed size.
The first storage unit may be a block area or a page area in the first memory, and is configured to store the first data information.
The update request may be sent to the electronic device by the server, or may be actively triggered by a user of the electronic device, and when the update request is received, the electronic device may acquire the second data information for replacing, or partially replacing, the first data information.
In step 102, the bitmap information is used to indicate the storage status of each storage unit in the first memory, and the specific form may be a numeric character string, where the number on each bit indicates the current storage status of one storage unit, for example, "1" indicates a storage unit in an occupied status, and "0" indicates a storage unit in an idle status. Of course, in other alternative embodiments, the bitmap information may also be represented in other forms, and is not further limited herein.
In the embodiment of the present invention, the bitmap information may be stored in the random access memory, and since the stored data information may disappear after the random access memory is powered off, the bitmap information may be generated according to the current storage state of each storage unit of the first memory each time the random access memory is powered on.
It should be understood that in other alternative embodiments, the bitmap information may also be stored in a flash memory, such as the first memory, and updated after each data update operation.
The second data information in the embodiment of the present invention may be generated based on the first data information, and after the first data information is updated, the read or write operation performed on the first data information may be converted into the execution performed on the second data information.
The second storage unit may be a unit in an idle state, and the idle state may indicate a case where no data information is stored in the current storage unit, or the stored data information is useless data information, or the like. It is to be understood that, in the case where the second storage unit further stores data information, before the step of storing the second data information in the second storage unit, an operation of erasing the data stored in the second storage unit may be further included.
The second storage unit may be determined according to the bitmap information. In an optional embodiment, the second storage unit may be any storage unit in the first memory that is in an idle state; specifically, the second storage unit may be a storage unit in an idle state in the first memory, which is adjacent to the first storage unit in a preset order, and the second data information is stored in the first memory, so that frequent write operations on the first storage unit can be avoided in other idle storage units except the first storage unit.
It should be understood that the first data information may be data information of a specific service in the electronic device, and when the current electronic device receives an update request for updating the data information of the specific service, the method may be applied to store the updated second data information in the second storage unit; when the electronic device receives an update request for updating the data information of the specific service, the method can be applied to store the updated third data information in another storage unit except the second storage unit. In this way, the erasing operation is not repeatedly performed on the same storage unit every time the electronic device receives an update request for updating data information of the same service.
In step 103, after the updated second data information is stored in the second storage unit, the storage state of the first storage unit may be set to an idle state in the bit map information.
Further, the first data information stored in the first storage unit may be erased, so that subsequent new data may be written into the first storage unit. Of course, in other alternative embodiments, the operation of erasing data may also be performed when the first storage unit needs to be written with new data, which is not further limited herein.
In the embodiment of the invention, the second data information used for updating the first data information stored in the first storage unit is stored in the second storage unit in the idle state according to the bitmap information in the first storage, so that frequent erasing operation on the first storage unit is avoided when data of the same service is updated for multiple times, the probability of bad areas in the first storage is reduced, and the service life of the first storage is prolonged.
Optionally, the step 102 may specifically include:
determining a second storage unit with a first characterization storage state being an idle state after a storage unit pointed by a first bitmap index according to a preset sequence based on bitmap information stored in a second storage, wherein the first bitmap index is used for indicating a third storage unit which is used for storing address mapping information in the first storage;
storing second data information for updating the first data information in the second storage unit.
In order to realize the storage unit in the first storage, the erasing operation is circularly carried out under the condition of multiple data updates, and further the wear leveling of the storage unit in the first storage is realized. In the embodiment of the present invention, the second storage units may be determined in a preset order based on the first bitmap index.
Specifically, the bitmap index may point to a storage unit in the first memory, and may specifically exist in the form of a number of the storage unit, or a physical address. The electronic device may determine the storage location indicated by the electronic device based on the bitmap index.
The first bitmap index is used for indicating the third storage unit, and can be stored in association with the bitmap information so as to be conveniently acquired by the electronic equipment.
The third storage unit may store address mapping information. Generally, in order to ensure that the electronic device can correctly access the memory unit when executing instructions, a logical address in the user program needs to be converted into a physical address in the runtime memory, and this process is called address mapping. In an embodiment of the present invention, the address mapping information may include a mapping relationship between a physical address and a logical address of each storage unit in the first memory, and is used for finding, by the electronic device, the physical address of the storage unit in which the required data information is stored according to the logical address.
Further, the third storage unit may be a storage unit after the first storage unit in a preset order. As can be seen from the memory cell in which the first characterized memory state after the second memory cell is the third memory cell is an idle state, the third memory cell may be located between the first memory cell and the second memory cell. Meanwhile, in order to cyclically use the memory cells in the first memory in the preset order, there may be no cell in an idle state between the first memory cell and the third memory cell.
In this way, in the embodiment of the present invention, after the physical address of the third storage unit is determined by the first bitmap index, the second storage unit in an idle state after the third storage unit is in the preset sequence is determined according to the bitmap information, and the second data information is stored in the second storage unit, so that the storage units in the first memory can be erased and written according to the preset sequence when data is updated for multiple times, the loss of the storage units is balanced, and the service life of the flash memory is further prolonged.
Optionally, before the step 101, the method may further include:
in the case of reset initialization, creating the first bitmap index and the bitmap information in a second memory according to first mapping information stored in the third storage unit;
the first mapping information includes a first mapping relation table, where the first mapping relation table is used to indicate a mapping relation between a physical address and a logical address of each storage unit in the first memory.
As can be seen from the above, the bitmap information may be stored in a second memory, and the second memory may be a random access memory, and the data stored after the reset initialization disappears. In an embodiment of the present invention, the first bitmap index and the bitmap information may be created in the second memory when the electronic device is reset and initialized.
Specifically, the first bitmap index and the bitmap information may be determined according to the first mapping information stored in the third storage unit. The first mapping information may include a first mapping relationship table. The first mapping relation table is a mapping relation between a Physical address and a Logical address of each storage unit in the current first memory, and may exist in the form of a Logical Block Number-Physical Block Number (LBN-PBN) mapping table or a Logical Page Number-Physical Page Number (LPN-PPN) mapping table, and corresponding Logical addresses and Physical addresses may be obtained through the Logical Block numbers and the Physical Block numbers, which is not further limited herein.
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE FE
A2 E1 2C 3F 32 C0 B3 AD 00 3B 37
Watch 1
Referring to a first table, the first table is a possible presentation form of the LBN-PBN mapping table, where each block area represents a memory unit, an "FE" on the area is used to indicate that the memory unit is occupied, and the rest of characters are used to indicate a logic block number of a free memory unit, and the physical block number is a serial number arranged according to a preset sequence from left to right and from top to bottom, and a corresponding physical address and a corresponding logic address can be obtained by calculation according to the physical block number and the logic block number. Based on table one, a numeric string of bitmap information, such as "000.. 000111.. 111000", may be generated, where the number on each bit corresponds to the storage state of one storage unit in the table in order, where 0 indicates that the corresponding storage unit on the bit is in an idle state, and 1 indicates that the corresponding storage unit on the bit is in an occupied state. The bitmap index, that is, the physical block number of the memory cell that can be used to store the current address mapping information, can be presented in the form of a character string, for example, 0x80, and 0x80 indicates the memory cell corresponding to the 16 th block in the preset order in table one.
In the embodiment of the invention, the bitmap information can be created in advance through the first mapping information, and the storage state of the storage unit can be known by acquiring the number on each bit of the bitmap information, so that the storage unit in an idle state can be found more quickly during data updating, and the information storage efficiency is improved.
Further, the first mapping information may further include identification information, where the identification information is used to identify that the third storage unit stores address mapping information, and may specifically exist in the form of a flag bit, which is not limited herein.
In the embodiment of the present invention, the electronic device may determine a third storage unit storing the first mapping information by searching the identification information, then determine the first bitmap index according to the physical address of the third storage unit, determine the storage state of each storage unit in the first memory according to the first mapping relationship table, generate bitmap information, store the bitmap information and the first bitmap index in the second memory, and create the bitmap information and the bitmap index in the second memory in advance before receiving the update request, so that when receiving the update request, the electronic device may directly store the second data information in the second storage unit according to the pre-created bitmap information and the bitmap index, thereby improving the efficiency of information storage.
Further, the method may further include:
generating updated second mapping information based on the first bitmap index and the first mapping information;
according to the first bitmap index and the bitmap information, determining a second storage unit with a second characterization storage state being an idle state after the storage unit pointed by the first bitmap index according to the preset sequence;
storing the second mapping information in the fourth storage unit;
erasing the first mapping information stored in the third storage unit;
the second mapping information includes a second mapping relationship table, and a logical address mapped by the second storage unit in the second mapping relationship table is a logical address mapped by the first storage unit in the first mapping relationship table.
In the process of updating the first data information to the second data information, since data is migrated from the first storage unit to the second storage unit, in order to obtain the second data information of the second storage unit through a logical address in the electronic device, the first mapping information stored in the third storage unit needs to be updated, and the logical address mapped by the first storage unit in the first mapping relation table is modified to the logical address mapped by the second storage unit, that is, the logical block number on the area corresponding to the free storage unit shown in the first table is adjusted backwards according to a preset sequence, so that the area of the second storage unit is the logical block number of the original first storage unit.
The step of writing the second mapping information into the fourth storage unit may be performed simultaneously with the step of writing the second data information into the second storage unit, or may be performed in a time-sharing manner, which is not limited herein.
Similarly to the third storage unit, the second mapping information stored in the fourth storage unit may also include the identification information, which indicates that the fourth storage unit stores address mapping information.
It should be understood that, since the address mapping information stored in the third storage unit is erased, in this case, resetting is performed, bitmap information and a third bitmap index are created according to the second mapping information stored in the fourth storage unit, at this time, the third bitmap index also points to the fourth storage unit, and a storage unit in an idle state after the fourth storage unit can be searched according to the third bitmap index in a preset sequence when data is updated next time.
In an embodiment of the present invention, similarly to the storing of the second data information, the updated second mapping information may be stored in the fourth storage unit, and the fourth storage unit may be a second unit in an idle state after the third storage unit is in a preset order. Therefore, the embodiment of the invention stores the updated second data information in the first idle unit behind the third storage unit and stores the updated second mapping information in the second idle unit behind the third storage unit, so that repeated erasing of the same storage unit can be avoided when the address mapping information is updated for multiple times, and the service life of the first memory is further prolonged.
Optionally, before the step of creating the first bitmap index and the bitmap information in the second memory according to the first mapping information stored in the third storage unit, the method may further include:
searching a storage unit in which address mapping information is stored in the first memory;
comparing check values of address mapping information in a fifth storage unit and a third storage unit under the condition that the fifth storage unit and the third storage unit exist in the first memory at the same time; the fifth storage unit is a storage unit which is positioned in the first storage and is in front of the first storage unit in the preset sequence and stores third mapping information;
if the third mapping information is consistent with the check value of the first mapping information, erasing the third mapping information stored in the fifth storage unit;
and if the third mapping information is inconsistent with the check value of the first mapping information, erasing the first mapping information stored in the third storage unit.
In an embodiment of the present invention, the first bitmap index and the bitmap information may be generated based on the first mapping information. Specifically, the electronic device may determine the storage unit in which the address mapping information is stored by searching the identification information.
Since the erasing and data writing processes of the flash memory storage unit require a certain time to complete, if the process suddenly loses power, the problem of unsuccessful data writing occurs. Therefore, before creating the first bitmap index and the bitmap information according to the first mapping information, the electronic device needs to search the number of memory cells storing the address mapping information.
For example, if the first mapping information in the third storage unit is updated from the third mapping information in the fifth storage unit, the electronic device does not erase the third mapping information in the fifth storage unit when the power is turned off, and therefore the third storage unit and the fifth storage unit exist in the first memory at the same time. The electronic device may determine that power failure occurs during writing of the first mapping information into the third storage unit by simultaneously storing the third storage unit and the fifth storage unit in the first storage.
In this case, the electronic device may further compare the check values of the first mapping information and the third mapping information. If the check value of the first mapping information is consistent with the third mapping information, it indicates that the first mapping information is complete, and at this time, the third mapping information in the fifth storage unit may be erased. If the check value of the first mapping information is inconsistent with the third mapping information, it indicates that the first mapping information is incomplete, and the first mapping information in the third storage unit can be erased, thereby avoiding an error in operation of the first memory.
The embodiment of the invention determines whether power failure occurs in the updating process of the mapping information by searching whether two storage units for storing address mapping information exist in the first storage unit, and erases the mapping information before updating by comparing the check value of the mapping information under the condition that the check value of the updated mapping information is consistent with the mapping information before updating; under the condition that the check value of the updated mapping information is inconsistent with the mapping information before updating, erasing the updated mapping information; the situation that the first memory fails to operate due to incomplete updated address mapping information caused by power failure is avoided, and the power failure protection function of the first memory is realized.
Further, the step of creating the first bitmap index and the bitmap information in the second memory according to the first mapping information stored in the third storage unit may include:
under the condition of reset initialization, if the third storage unit exists in the first memory and the fifth storage unit does not exist, creating the first bitmap index and the bitmap information in the second memory according to first mapping information stored in the third storage unit;
the above method may further comprise:
in the case of reset initialization, if the fifth storage unit exists in the first memory and the third storage unit does not exist, a second bitmap index and the bitmap information are created in the second memory according to third mapping information stored in the fifth storage unit, where the second bitmap index is used to indicate the fifth storage unit.
As can be seen from the above, the electronic device may erase the mapping information before updating when the check value of the mapping information after updating is consistent with the mapping information before updating; and in the case that the check value of the mapping information after updating is inconsistent with the mapping information before updating, erasing the mapping information after updating.
In an embodiment of the present invention, if the third storage unit exists in the first memory and the fifth storage unit does not exist during reset initialization, indicating that the address mapping information is updated, a first bitmap index and bitmap information may be created according to the updated first mapping information in the third storage unit; if the fifth storage unit exists in the first memory and the third storage unit does not exist during reset initialization, the address mapping information is failed to be updated, at this time, a second bitmap index and bitmap information can be created according to the third mapping information before updating in the fifth storage unit, and the second bitmap index can point to the fifth storage unit, so that the situation that the first memory is in operation error due to mapping information error after power failure is avoided.
Referring to fig. 2 and fig. 2 are schematic diagrams of another possible flow of the information storage method, and a specific flow of the information storage method will be described in detail below by taking an embodiment in which the first memory is a flash memory and the second memory is a random access memory as an example:
step 201, during reset initialization, creating a bitmap information table of a physical unit according to address mapping information stored in a flash memory and storing the bitmap information table in a random access memory, wherein the bitmap information table records idle or occupied information of the physical unit of the flash memory and generates a bitmap index.
Step 202, the program fetches the first idle physical unit after bitmap indexing according to the bitmap information and the bitmap index according to the data updating request; and writing the updated data in the free physical unit.
Step 203, according to the bitmap information and the bitmap index, taking a second idle physical unit after the bitmap index, and pointing the bitmap index to the physical unit; and writing the updated address mapping information into the free physical unit.
Step 204, setting the bitmap of the physical unit where the old data is located and the bitmap of the physical unit where the old address mapping information is located to be idle.
Step 205, erasing the physical unit where the original mapping information is located.
Before step 201, the method may further include:
if only one physical unit of the address mapping information exists in the flash memory after the flash memory is powered on, judging that accidental power failure does not occur;
if the flash memory has two physical units of address mapping information after being electrified, the accidental power failure is judged.
If unexpected power failure occurs, calculating and comparing the check values of the address mapping information of the newer version, if the check values are consistent, recovering new data according to the address mapping information of the newer version, and erasing the physical unit where the address mapping information of the old version is located; if not, recovering the old data according to the address mapping information of the old version, and erasing the physical unit where the address mapping information of the new version is located.
The step 203 may specifically include:
writing a mapping table entry of a logic unit and a first idle physical unit corresponding to the updated data;
writing other mapping table entries of the original mapping information;
generating and writing version information of the updated mapping information;
writing the identification information of the mapping information;
and generating and writing the verification information of all the data.
In the embodiment of the invention, each memory cell can be erased and written evenly, so that the service life of the flash memory depends on the number of free physical cells.
Illustratively, in the extreme case, the flash memory stores data assuming that only one stored physical unit of data is updated during the life cycle of the flash memoryThe theoretical erasable life of the device is: t ismax*(M+1)/2。
In another limiting case, assuming that other existing physical units are modified once before any existing physical unit data is modified again, the theoretical erasable life of the flash memory is as follows: t ismax*(M+N)/2。TmaxThe erasable frequency of the minimum erasable unit of the flash memory; n is the number of physical units of stored data of the flash memory; m is the number of free physical units of the flash memory.
Therefore, the theoretical life of the flash memory which can be achieved by the embodiment of the invention is between Tmax(M +1)/2 and TmaxAnd the service life of the flash memory is prolonged between M + N)/2.
It should be noted that, in the information storage method provided in the embodiment of the present invention, the execution main body may be an information storage device, or a control module in the information storage device, configured to execute the loaded information storage method. In the embodiment of the present invention, an information storage device executes a method for loading and storing information, which is used as an example, to describe the information storage method provided in the embodiment of the present invention.
Referring to fig. 3, fig. 3 is a structural diagram of an information storage apparatus 300 according to an embodiment of the present invention, and as shown in fig. 3, the information storage apparatus 300 includes:
a receiving module 310, configured to receive an update request for first data information stored in a first storage unit, where the first storage unit is a storage unit in the first memory;
a first storage module 320, configured to, in response to the update request, store second data information for updating the first data information in a second storage unit based on bitmap information, where the bitmap information is used to indicate a storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, where a storage state of the storage unit is characterized as an idle state;
an updating module 330, configured to update a storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
The embodiment of the invention receives an update request aiming at first data information stored in a first storage unit through a receiving module, stores second data information used for updating the first data information in a second storage unit through a first storage module based on bitmap information, and updates the storage state of the first storage unit in the bitmap information from an occupied state to an idle state through an updating module, thereby avoiding frequent erasing and writing operations on the first storage unit when data of the same service is updated for multiple times, reducing the probability of bad areas in a flash memory and prolonging the service life of the memory.
Optionally, the first storage module 320 may specifically include:
the determining unit is used for determining a second storage unit with a first representation storage state being an idle state after a storage unit pointed by a first bitmap index according to a preset sequence based on bitmap information stored in a second storage, wherein the first bitmap index is used for indicating a third storage unit which is in the first storage and used for storing address mapping information;
and the storage unit is used for storing second data information used for updating the first data information in the second storage unit.
Optionally, the information storage apparatus 300 may further include:
a first creating module, configured to create the first bitmap index and the bitmap information in a second memory according to first mapping information stored in the third storage unit in case of reset initialization;
the first mapping information includes a first mapping relation table and identification information of the third storage unit, the identification information corresponds to the first bitmap index, and the first mapping relation table is used for indicating a mapping relation between a physical address and a logical address of each storage unit in the first memory.
Optionally, the information storage apparatus 300 may further include:
a generating module, configured to generate updated second mapping information based on the first bitmap index and the first mapping information;
the determining module is used for determining a second storage unit with a free representation storage state after the storage unit pointed by the first bitmap index according to the preset sequence according to the first bitmap index and the bitmap information;
a second storage module, configured to store the second mapping information in the fourth storage unit;
the first erasing module is used for erasing the first mapping information stored in the third storage unit;
the second mapping information includes a second mapping relationship table and identification information of the fourth storage unit, and a logical address mapped by the second storage unit in the second mapping relationship table is a logical address mapped by the first storage unit in the first mapping relationship table.
Optionally, the information storage apparatus 300 may further include:
the searching module is used for searching a storage unit which stores address mapping information in the first storage;
the comparison module is used for comparing the check values of the address mapping information in a fifth storage unit and a third storage unit under the condition that the fifth storage unit and the third storage unit exist in the first memory at the same time; the fifth storage unit is a storage unit which is positioned in the first storage and is in front of the first storage unit in the preset sequence and stores third mapping information;
the second erasing module is used for erasing the third mapping information stored in the fifth storage unit if the third mapping information is consistent with the check value of the first mapping information;
and the third erasing module is used for erasing the first mapping information stored in the third storage unit if the third mapping information is inconsistent with the check value of the first mapping information.
Optionally, the first creating module may specifically include:
a first creating unit, configured to, in a case of reset initialization, if the third storage unit exists in the first memory and the fifth storage unit does not exist, create the first bitmap index and the bitmap information in the second memory according to first mapping information stored in the third storage unit;
the information storage apparatus 300 may further include:
a second creating module, configured to, in a case of reset initialization, if the fifth storage unit exists in the first memory and the third storage unit does not exist, create a second bitmap index and the bitmap information in the second memory according to third mapping information stored in the fifth storage unit, where the second bitmap index is used to indicate the fifth storage unit.
The information storage device in the embodiment of the present invention may be a device, and may also be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiment of the present invention is not particularly limited.
The information storage device in the embodiment of the present invention may be a device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, and embodiments of the present invention are not limited in particular.
The information storage device provided in the embodiment of the present invention can implement each process implemented by the information storage method in the method embodiment of fig. 1, and is not described herein again to avoid repetition.
Optionally, an embodiment of the present invention further provides an electronic device, which includes a processor 402, a memory 401, and a program or an instruction stored in the memory 401 and executable on the processor 402, where the program or the instruction, when executed by the processor 402, implements each process of the above-mentioned information storage method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
It should be noted that the electronic device in the embodiment of the present invention includes the mobile electronic device and the non-mobile electronic device described above.
The embodiment of the present invention further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the above-mentioned information storage method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
The embodiment of the present invention further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to execute a program or an instruction to implement each process of the above information storage method embodiment, and can achieve the same technical effect, and in order to avoid repetition, the description is omitted here.
It should be understood that the chips mentioned in the embodiments of the present invention may also be referred to as a system-on-chip, or a system-on-chip.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of embodiments of the present invention is not limited to performing functions in the order illustrated or discussed, but may include performing functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the methods according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (10)

1. An information storage method, comprising:
receiving an update request for first data information stored in a first storage unit, wherein the first storage unit is a storage unit in the first memory;
in response to the update request, storing second data information for updating the first data information in a second storage unit based on bitmap information, wherein the bitmap information is used for indicating the storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, and the storage state of the second storage unit is characterized as an idle state;
and updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
2. The information storage method according to claim 1, wherein the step of storing second data information for updating the first data information in a second storage unit based on the bitmap information comprises:
determining a second storage unit with a first characterization storage state being an idle state after a storage unit pointed by a first bitmap index according to a preset sequence based on bitmap information stored in a second storage, wherein the first bitmap index is used for indicating a third storage unit which is used for storing address mapping information in the first storage;
storing second data information for updating the first data information in the second storage unit.
3. The information storage method according to claim 2, wherein, prior to the step of receiving an update request for the first data information stored in the first storage unit, the method further comprises:
in the case of reset initialization, creating the first bitmap index and the bitmap information in a second memory according to first mapping information stored in the third storage unit;
the first mapping information includes a first mapping relation table, where the first mapping relation table is used to indicate a mapping relation between a physical address and a logical address of each storage unit in the first memory.
4. The information storage method according to claim 3, wherein after the step of storing second data information for updating the first data information in a second storage unit based on bitmap information, the method further comprises:
generating updated second mapping information based on the first bitmap index and the first mapping information;
according to the first bitmap index and the bitmap information, determining a second storage unit with a second characterization storage state being an idle state after the storage unit pointed by the first bitmap index according to the preset sequence;
storing the second mapping information in the fourth storage unit;
erasing the first mapping information stored in the third storage unit;
the second mapping information includes a second mapping relationship table, and a logical address mapped by the second storage unit in the second mapping relationship table is a logical address mapped by the first storage unit in the first mapping relationship table.
5. The information storage method according to claim 3, wherein before the step of creating the first bitmap index and the bitmap information in the second memory based on the first mapping information stored in the third storage unit, the method further comprises:
searching a storage unit in which address mapping information is stored in the first memory;
comparing check values of address mapping information in a fifth storage unit and a third storage unit under the condition that the fifth storage unit and the third storage unit exist in the first memory at the same time; the fifth storage unit is a storage unit which is positioned in the first storage and is in front of the first storage unit in the preset sequence and stores third mapping information;
if the third mapping information is consistent with the check value of the first mapping information, erasing the third mapping information stored in the fifth storage unit;
and if the third mapping information is inconsistent with the check value of the first mapping information, erasing the first mapping information stored in the third storage unit.
6. The information storage method according to claim 5, wherein the step of creating the first bitmap index and the bitmap information in the second memory based on the first mapping information stored in the third storage unit comprises:
under the condition of reset initialization, if the third storage unit exists in the first memory and the fifth storage unit does not exist, creating the first bitmap index and the bitmap information in the second memory according to first mapping information stored in the third storage unit;
the method further comprises the following steps:
in the case of reset initialization, if the fifth storage unit exists in the first memory and the third storage unit does not exist, a second bitmap index and the bitmap information are created in the second memory according to third mapping information stored in the fifth storage unit, where the second bitmap index is used to indicate the fifth storage unit.
7. An information storage device, comprising:
a receiving module, configured to receive an update request for first data information stored in a first storage unit, where the first storage unit is a storage unit in the first memory;
a first storage module, configured to store, in response to the update request, second data information for updating the first data information in a second storage unit based on bitmap information, where the bitmap information is used to indicate a storage state of each storage unit in the first memory, and the second storage unit is a storage unit in the first memory, where a storage state of the storage unit is characterized as an idle state;
and the updating module is used for updating the storage state of the first storage unit in the bitmap information from an occupied state to an idle state.
8. The information storage device of claim 7, wherein the storage module comprises:
the determining unit is used for determining a second storage unit with a first representation storage state being an idle state after a storage unit pointed by a first bitmap index according to a preset sequence based on bitmap information stored in a second storage, wherein the first bitmap index is used for indicating a third storage unit which is in the first storage and used for storing address mapping information;
a storage unit configured to store second data information for updating the first data information in the second storage unit.
9. The information storage device of claim 8, further comprising:
a first creating module, configured to create the first bitmap index and the bitmap information in a second memory according to first mapping information stored in the third storage unit in case of reset initialization;
the first mapping information includes a first mapping relation table, where the first mapping relation table is used to indicate a mapping relation between a physical address and a logical address of each storage unit in the first memory.
10. An electronic device comprising a processor, a memory and a computer program or instructions stored on the memory and executable on the processor, which program or instructions, when executed by the processor, implement the steps of the information storage method according to any one of claims 1-5.
CN202011293723.7A 2020-11-18 2020-11-18 Information storage method and device and electronic equipment Active CN114518834B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011293723.7A CN114518834B (en) 2020-11-18 2020-11-18 Information storage method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011293723.7A CN114518834B (en) 2020-11-18 2020-11-18 Information storage method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN114518834A true CN114518834A (en) 2022-05-20
CN114518834B CN114518834B (en) 2023-10-27

Family

ID=81594584

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011293723.7A Active CN114518834B (en) 2020-11-18 2020-11-18 Information storage method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114518834B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101315628A (en) * 2007-06-01 2008-12-03 华为技术有限公司 Internal memory database system and method and device for implementing internal memory data base
CN101533670A (en) * 2009-04-23 2009-09-16 北京握奇数据系统有限公司 Method and memory device realizing loss balance of memory device
CN101840308A (en) * 2009-10-28 2010-09-22 创新科存储技术有限公司 Hierarchical memory system and logical volume management method thereof
CN101916290A (en) * 2010-08-18 2010-12-15 中兴通讯股份有限公司 Managing method of internal memory database and device
CN101980177A (en) * 2010-10-21 2011-02-23 北京握奇数据系统有限公司 Method and device for operating Flash
CN102622309A (en) * 2011-01-30 2012-08-01 成都市华为赛门铁克科技有限公司 Method and device for erasing data securely
CN104090730A (en) * 2014-07-08 2014-10-08 飞天诚信科技股份有限公司 Method and device for conducting data reading and writing on storage device
US20170185331A1 (en) * 2015-12-29 2017-06-29 EMC IP Holding Company LLC Method and apparatus for controlling access to a disk array
US20170337212A1 (en) * 2015-01-13 2017-11-23 Hitachi Data Systems Engineering UK Limited Computer program product, method, apparatus and data storage system for managing defragmentation in file systems
CN108255740A (en) * 2017-12-07 2018-07-06 深圳市中易通安全芯科技有限公司 A kind of FLASH equilibriums erasing-writing method and system
CN110175001A (en) * 2019-05-27 2019-08-27 牧星机器人(江苏)有限公司 A kind of NOR-FLASH date storage method, computer equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101315628A (en) * 2007-06-01 2008-12-03 华为技术有限公司 Internal memory database system and method and device for implementing internal memory data base
CN101533670A (en) * 2009-04-23 2009-09-16 北京握奇数据系统有限公司 Method and memory device realizing loss balance of memory device
CN101840308A (en) * 2009-10-28 2010-09-22 创新科存储技术有限公司 Hierarchical memory system and logical volume management method thereof
CN101916290A (en) * 2010-08-18 2010-12-15 中兴通讯股份有限公司 Managing method of internal memory database and device
CN101980177A (en) * 2010-10-21 2011-02-23 北京握奇数据系统有限公司 Method and device for operating Flash
CN102622309A (en) * 2011-01-30 2012-08-01 成都市华为赛门铁克科技有限公司 Method and device for erasing data securely
CN104090730A (en) * 2014-07-08 2014-10-08 飞天诚信科技股份有限公司 Method and device for conducting data reading and writing on storage device
US20170337212A1 (en) * 2015-01-13 2017-11-23 Hitachi Data Systems Engineering UK Limited Computer program product, method, apparatus and data storage system for managing defragmentation in file systems
US20170185331A1 (en) * 2015-12-29 2017-06-29 EMC IP Holding Company LLC Method and apparatus for controlling access to a disk array
CN108255740A (en) * 2017-12-07 2018-07-06 深圳市中易通安全芯科技有限公司 A kind of FLASH equilibriums erasing-writing method and system
CN110175001A (en) * 2019-05-27 2019-08-27 牧星机器人(江苏)有限公司 A kind of NOR-FLASH date storage method, computer equipment and storage medium

Also Published As

Publication number Publication date
CN114518834B (en) 2023-10-27

Similar Documents

Publication Publication Date Title
US10552311B2 (en) Recovery for non-volatile memory after power loss
US10606761B2 (en) Method for accessing flash memory module and associated flash memory controller and electronic device
US7363421B2 (en) Optimizing write/erase operations in memory devices
US20070016719A1 (en) Memory device including nonvolatile memory and memory controller
US20160170671A1 (en) Data storage device and data writing method thereof
US10475516B2 (en) Data storage device and data erasing method wherein after erasing process, predetermined value is written to indicate completion of said erasing method
US10216564B2 (en) High voltage failure recovery for emulated electrically erasable (EEE) memory system
US20080104361A1 (en) Storage Device, Memory Managing Apparatus, Memory Managing Method, and Program
US9710340B2 (en) Replacement of a corrupt driver variable record
CN108108261B (en) Data storage device and operation method thereof
US11354192B2 (en) Data storage devices and methods for firmware failure prevention
CN107391038B (en) Data writing method of data storage type flash memory, flash memory and storage medium
US20070136510A1 (en) Storage device, memory managing device, memory managing method, and program
JP2008033801A (en) Memory data management device
CN107045423B (en) Memory device and data access method thereof
CN112988611A (en) Data writing method of nonvolatile memory, terminal and readable storage medium
CN111124294B (en) Sector mapping information management method and device, storage medium and equipment
CN111694580B (en) Method and device for upgrading and initializing storage device and electronic device
CN114518834B (en) Information storage method and device and electronic equipment
US11295792B2 (en) Back-up and restoration of register data
JP3826115B2 (en) Storage device, memory management method, and program
CN114138176A (en) Nor Flash erasing and upgrading method and device, computer equipment and storage medium
CN111708487A (en) Data storage method and device and computer storage medium
US20090055574A1 (en) NAND Flash Memory Device And Related Method Thereof
CN110568997A (en) Data writing method, device and equipment based on Flash memory

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
GR01 Patent grant