CN103268201A - Data storing method, storing device and reading method - Google Patents

Data storing method, storing device and reading method Download PDF

Info

Publication number
CN103268201A
CN103268201A CN2013101381913A CN201310138191A CN103268201A CN 103268201 A CN103268201 A CN 103268201A CN 2013101381913 A CN2013101381913 A CN 2013101381913A CN 201310138191 A CN201310138191 A CN 201310138191A CN 103268201 A CN103268201 A CN 103268201A
Authority
CN
China
Prior art keywords
data
written
writing
target
storage space
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
CN2013101381913A
Other languages
Chinese (zh)
Other versions
CN103268201B (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.)
Beijing Jingwei Hirain Tech Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech 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 Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN201310138191.3A priority Critical patent/CN103268201B/en
Publication of CN103268201A publication Critical patent/CN103268201A/en
Application granted granted Critical
Publication of CN103268201B publication Critical patent/CN103268201B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data storing method, a storing device and a reading method. The method comprises steps of firstly, receiving data to be written, then determining the type of the data to be written, and finally, sequentially wiring the data to be written into the storage space corresponding to the data type. In the data storing process of the method, the data to be written is sequentially written into the storage spaces, and an erasing operation is carried out for one time when the data to be written does not need to be written each time, so that the method solves the problem in the prior art that the service life of flash memory is shortened due to frequent erasing operations which are caused by the fact that data in the last effective SECTOR needs to be erased in each data storing process.

Description

Data storage method, storage device and reading method
Technical Field
The present application relates to the field of flash memory technologies, and in particular, to a data storage method, a storage device, and a reading method.
Background
Flash memory is usually erased 10 ten thousand times, while serial memory is usually erased 100 ten thousand times, so many electronic products use flash memory to store program codes and serial memory to store data which needs to be updated frequently. However, this storage method, on one hand, increases the hardware cost of the product because of using the serial memory, and on the other hand, only stores the program code in the flash memory because of the large storage space of the flash memory, which results in waste of the flash memory space.
In the prior art, a data storage method is provided, which simulates a function of a serial memory for storing data by using a flash memory, and mainly divides a storage space of the flash memory into n SECTORs (where a SECTOR is a minimum erase unit of the flash memory), and each SECTOR is provided with a SECTOR Status corresponding to the SECTOR Status (where the SECTOR Status includes information of state validity, data validity, type, length, and the like of the SECTOR).
Through the research on the prior art, the inventor finds that: although the existing data storage method can realize the function of storing data through the flash memory analog serial memory, in the process of writing data each time, the data in the last effective SECTOR needs to be erased, so that the erasing operation is frequent, and the service life of the flash memory is further reduced.
Disclosure of Invention
In view of this, embodiments of the present application provide a data storage method, a storage device, and a reading method, so as to solve the problem that in the prior art, in the process of performing data storage each time, data in the last valid SECTOR needs to be erased, so that the erase operation is frequent, and the lifetime of a flash memory is reduced.
In order to achieve the above purpose, the technical solutions provided in the embodiments of the present application are as follows:
a data storage method is applied to a flash memory, wherein the flash memory comprises at least one storage space, and the method comprises the following steps:
receiving data to be written;
determining the data type of the data to be written;
and sequentially writing the data to be written in the storage space corresponding to the data type.
Preferably, the determining the data type of the data to be written includes:
acquiring a type identifier carried by the data to be written;
and determining the data type of the data to be written according to the preset corresponding relation between the type identification and the data type.
Preferably, each storage space includes at least two writing areas, and each writing area is provided with a status identifier, the status identifier represents a valid status or an invalid status, and only one status identifier in the same storage space at the same time represents a valid status,
the sequentially writing the data to be written in the storage space corresponding to the data type comprises:
determining a storage space corresponding to the data type of the data to be written according to a preset corresponding relation between the data type and the storage space, and using the storage space as a target storage space;
searching a writing area with a state identifier representing an effective state in the target storage space, and taking the writing area as a target writing area;
judging whether the residual space of the target writing area meets the occupied space of the data to be written;
and when the data is satisfied, writing the data to be written in the blank area of the target writing area.
Preferably, each of the writing areas in each of the storage spaces is provided with a consecutive number, and a next writing area of the trailing writing area is a leading writing area,
when the remaining space of the target writing area does not satisfy the occupation space of the data to be written, the method further comprises:
obtaining valid data in the target writing area;
storing the valid data in a next write area of the target write area;
writing the data to be written after the valid data stored in the next writing area of the target writing area;
setting a state identifier of the target writing area to a state identifier representing an invalid state;
setting a state identifier in a next writing area of the target writing area to a state identifier representing a valid state;
erasing all data in the target write area.
Preferably, the method further comprises:
judging whether a fault occurs in the process of sequentially writing the data to be written in the storage space corresponding to the data type;
if so, acquiring a fault identifier;
determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type;
executing a preset fault processing mechanism corresponding to the fault type;
or,
judging whether a bit reversal fault exists or not;
if so, executing a preset bit reversal fault processing mechanism corresponding to the bit reversal fault.
A data storage device is applied to a flash memory, wherein the flash memory comprises at least one storage space, and the data storage device comprises: a data receiving unit, a data type determining unit and a storing unit, wherein,
the data receiving unit is used for receiving data to be written;
the data type determining unit is connected with the data receiving unit and used for determining the data type of the data to be written;
and the storage unit is connected with the data type determining unit and is used for sequentially writing the data to be written in the storage space corresponding to the data type.
Preferably, the data type determining unit includes: a type identification obtaining unit and a data type determining subunit, wherein,
the type identification obtaining unit is connected with the data receiving unit and is used for obtaining the type identification carried by the data to be written;
the data type determining subunit is connected to the type identifier obtaining unit and configured to determine the data type of the data to be written according to a preset correspondence between the type identifier and the data type.
Preferably, each of the storage spaces includes at least two writing areas, and each of the writing areas is provided with a status identifier, the status identifier represents a valid status or an invalid status, and only one status identifier in the same storage space at the same time represents a valid status; each writing area in each storage space is provided with a continuous number, and the next writing area of the tail writing area is a head writing area;
the memory cell includes: a target writing area search unit, a judgment unit, and a data writing unit, wherein,
the target storage space determining unit is connected with the data type determining subunit, and is used for determining a storage space corresponding to the data type of the data to be written according to a preset corresponding relationship between the data type and the storage space, and using the storage space as a target storage space; the target writing area searching unit is connected with the target storage space determining unit and used for searching a writing area with a state identifier representing an effective state and taking the writing area as a target writing area;
the judging unit is connected with the target writing area searching unit and used for judging whether the residual space of the target writing area meets the occupation space of the data to be written;
the data writing unit is connected with the judging unit and is used for writing the data to be written in the blank area of the target writing area when the data writing unit meets the requirement;
the data writing unit includes: the device comprises an effective data acquisition unit, a writing subunit and an erasing unit, wherein:
the valid data acquisition unit is connected with the judgment unit and used for acquiring valid data in the target writing area when the residual space of the target writing area does not meet the occupation space of the data to be written;
the writing subunit is connected to the valid data acquiring unit, and is configured to store the acquired valid data in a next writing area of the target writing area; writing the data to be written into the target writing area after the valid data stored in the next writing area of the target writing area;
the erasing unit is connected with the writing subunit and is used for erasing all data in the target writing area.
Preferably, the apparatus further comprises: a fault handling unit, wherein,
the fault processing unit is used for judging whether faults occur in the process of sequentially writing the data to be written in the storage space corresponding to the data type;
if so, acquiring a fault identifier;
determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type;
executing a preset fault processing mechanism corresponding to the fault type;
or,
the fault processing unit is used for judging whether bit reversal faults exist or not;
if so, executing a preset bit reversal fault processing mechanism corresponding to the bit reversal fault.
Corresponding to the data storage method and device provided above, the present application also provides a data reading method, which can read the stored data.
A data reading method is applied to a flash memory, the flash memory comprises at least one storage space, each storage space comprises at least two writing areas, each writing area is provided with a state identifier, the state identifiers represent valid states or invalid states, and only one state identifier in the same storage space at the same time represents a valid state, the method comprises the following steps:
receiving data reading request information;
acquiring the data type of the data to be read carried by the data reading request information;
determining a storage space corresponding to the data reading request information according to a preset corresponding relation between the data type and the storage space, and taking the storage space as a target reading storage space;
searching a writing area with a state identifier representing an effective state in the target reading storage space as a target reading writing area;
and reading valid data in the target read-write area.
Therefore, the data storage method and the storage device provided by the application can solve the problem that in the process of data storage in the prior art, the data in the last effective SECTOR needs to be erased, so that the erasing operation is frequent and the service life of a flash memory is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a data storage method according to an embodiment of the present application;
fig. 2 is a flowchart of a data storage method according to a second embodiment of the present application;
fig. 3 is a flowchart of a data storage method according to a third embodiment of the present application;
fig. 4 is a flowchart of a data reading method according to a fourth embodiment of the present application;
fig. 5 is a schematic structural diagram of a data storage device according to a fifth embodiment of the present application;
fig. 6 is a schematic structural diagram of another data storage device according to a fifth embodiment of the present application;
fig. 7 is a schematic detailed structure diagram of a data writing unit according to a fifth embodiment of the present application.
Detailed Description
In order to better understand the present solution for those skilled in the art. The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The first embodiment is as follows:
fig. 1 is a flowchart of a data storage method according to an embodiment of the present application.
As shown in fig. 1, the method includes:
step S101: data to be written is received.
In the embodiment of the application, the provided data storage method is applied to a flash memory, the flash memory comprises at least one storage space, and when a user needs to store data in the flash memory, namely when a data storage requirement exists, the method firstly receives data to be written, which is sent by the user.
Step S102: the data type of the data to be written is determined.
In the data storage method provided in the embodiment of the application, after receiving the data to be written, the method determines the data type of the data to be written, and determines the data type of the data to be written mainly by acquiring the type identifier carried by the data to be written, and then determines the data type of the data to be written according to the preset corresponding relationship between the type identifier and the data type.
Step S103: and sequentially writing the data to be written in the storage space corresponding to the data type.
In the embodiment of the application, each storage space in the flash memory corresponds to a unique data type, and after the data type of the data to be written is determined, the data to be written is sequentially written in the storage space corresponding to the data type of the data to be written in the flash memory. The writing of the data to be written in the storage space corresponding to the data type of the data to be written may be sequentially writing the data to be written when there is a blank area in the storage space each time.
In the embodiment of the present application, the data type of the data to be written may be a data type with low modification frequency and importance, a data type with high modification frequency, or a data type with low modification frequency, and the like, and each storage space correspondingly stores data of only one data type.
Therefore, the data storage method provided by the application comprises the steps of firstly receiving data to be written, then determining the type of the data to be written, and finally sequentially writing the data to be written in the storage space corresponding to the data type.
Example two:
fig. 2 is a flowchart of a data storage method according to a second embodiment of the present application.
As shown in fig. 2, the method includes
Step S201: data to be written is received.
In the embodiment of the application, the provided data storage method is applied to a flash memory, the flash memory comprises at least one storage space, and when a user needs to store data in the flash memory, namely when a data storage requirement exists, the method firstly receives data to be written, which is sent by the user.
Step S202: and acquiring the type identification carried by the data to be written.
In the embodiment of the application, the received data to be written sent by the user all carry the type identifier, and the type identifier of the data to be written is obtained.
Step S203: and determining the data type of the data to be written according to the preset corresponding relation between the type identification and the data type.
In the data storage method provided by the embodiment of the application, the corresponding relationship between the type identifier and the data type is preset, after the data to be written is received, the type identifier of the data to be written is obtained, and the data type of the data to be written is determined according to the corresponding relationship between the preset type identifier and the data type.
Step S204: and determining a storage space corresponding to the data type of the data to be written according to the preset corresponding relation between the data type and the storage space, and taking the storage space as a target storage space.
In the embodiment of the application, each storage space in the flash memory corresponds to a unique data type, after the data type of the data to be written is determined, the storage space corresponding to the data type to be written is determined according to the preset corresponding relation between the data type and the storage space, and the storage space is used as a target storage space.
Step S205: the search status identifier indicates a write area of a valid status and is a target write area.
In this embodiment of the present application, each of the storage spaces includes at least two writing areas, and each of the writing areas is provided with a state identifier, where the state identifier represents a valid state or an invalid state, and only one state identifier in the same storage space at the same time represents a valid state. And after determining the storage space corresponding to the data type of the data to be written, taking the storage space as a target storage space, searching a writing area with a state identifier representing an effective state in the target storage space, and taking the writing area as a target writing area.
Step S206: and judging whether the residual space of the target writing area meets the occupied space of the data to be written.
In the embodiment of the present application, other data may already be stored in the target writing area before the data to be written is written, and at this time, it is determined whether the remaining space of the target writing area satisfies the space occupied by the data to be written.
Step S207: and writing the data to be written in the blank area of the target writing area.
In the embodiment of the present application, when the remaining space of the target writing area satisfies the space occupied by the data to be written, the data to be written is written in the blank area of the target writing area.
Step S208: and acquiring valid data in the target writing area.
In the embodiment of the application, when the remaining space of the target writing area does not satisfy the space occupied by the data to be written, the valid data in the target writing area is acquired. The valid data refers to the currently latest stored data, such as: in the target writing area, the information of the same file is stored twice in total, and then the information of the file stored for the second time is valid data. However, the above is only a preferred implementation method provided by the embodiments of the present application, and specifically specifies which are valid data, and the inventors can arbitrarily set the data according to their own needs.
Step S209: valid data is stored in a next writing area of the target writing area.
In this embodiment, each of the writing areas in each of the storage spaces is provided with a consecutive number, and a next writing area of the trailing writing area is a leading writing area. And after the valid data in the target writing area is acquired, storing the valid data in a writing area corresponding to the next number of the target writing area, and writing the data to be written into the next writing area of the target writing area after the valid data stored in the next writing area.
Step S210: the data to be written is written after the valid data stored in the next writing area of the target writing area.
In the embodiment of the present application, after the valid data is stored in the writing area corresponding to the number next to the number of the target writing area, the data to be written is written.
Step S211: all data in the target write area is erased.
Therefore, the embodiment of the application provides a data storage method, and the specific process of data storage is introduced clearly and clearly through the detailed description of each process of the data storage method, so that specific operators of the method can understand the method better.
Example three:
fig. 3 is a flowchart of a data storage method according to a third embodiment of the present application.
As shown in fig. 3, the method includes:
step S301: data to be written is received.
Step S302: the data type of the data to be written is determined.
Step S303: and sequentially writing the data to be written in the storage space corresponding to the data type.
The execution process of steps S301 to S303 provided in the third embodiment of the present application is the same as the execution process of steps S101 to S103 provided in the first embodiment of the present application, and for detailed description of steps S301 to S303 provided in the third embodiment of the present application, reference is made to steps S101 to S103 in the first embodiment of the present application, which is not repeated herein.
In the implementation of the present application, a failure may occur in the process of writing the data to be written into the storage space corresponding to the data type of the data to be written, and therefore, the data storage method provided in the embodiment of the present application further includes:
step S304: and judging whether a fault occurs in the process of sequentially writing the data to be written in the storage space corresponding to the data type.
In the embodiment of the present application, whether a failure occurs in the process of sequentially writing the data to be written in the storage space corresponding to the data type is determined, which is only a preferred mode of the embodiment of the present application, and the inventor may set any time to determine whether a failure occurs according to the requirement of the inventor.
Step S305: a fault identifier is obtained.
Step S306: and determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type.
In the implementation of the application, the fault type corresponding to the fault identifier is preset, and after the fault identifier is obtained, the fault type of the fault is determined according to the preset corresponding relation between the fault identifier and the fault type.
Step S307: and executing a preset fault processing mechanism corresponding to the fault type.
In the embodiment of the application, a fault handling mechanism corresponding to a fault type is preset, after the fault type corresponding to the fault identifier is determined, the fault handling mechanism to be executed is determined according to the preset fault handling mechanism corresponding to the fault type, and the fault handling mechanism is executed.
In practical application, the following faults and corresponding fault handling mechanisms are set:
in the embodiment of the present application, when the following faults occur, for example:
when the address to be written is not empty, or the written data does not conform to the expected value, or the current write operation is not completed yet and a new request is made, or the next write area of the target write area is not empty, the adopted fault handling mechanism is to firstly execute the delete operation on the next write area of the target write area and then copy the valid data in the target write area to the next write area of the target write area.
When the state of one writing area is valid and the state of the other writing area is writing in all the writing areas in the same storage area, the adopted fault handling mechanism is to erase the writing area in the writing state.
When the head information of a write-in area in a storage area is incorrect, the adopted fault handling mechanism is to erase the data in all the storage areas in the storage area and then record according to the data in the RAM.
When the checksum of the data read from the write area does not match the checksum calculated when the data was written to the write area, the failure handling mechanism employed is to ignore the data read this time and record the event this time.
In the implementation of the present application, a bit inversion failure may occur in data stored in a write area in each storage space of a flash memory, and therefore, the data storage method provided in the embodiment of the present application further includes:
step S308: it is determined whether a bit reversal fault exists.
Step S309: and executing a preset bit inversion fault processing mechanism corresponding to the bit inversion fault.
In the embodiment of the present application, a mechanism for handling a corresponding bit inversion failure is provided, in which an error address is first obtained, all valid data before the error address is read, the valid data is written into a next write area of a storage area where the error address is located, and the write area where the error address is located is simultaneously erased.
Therefore, on the basis of the above embodiments, the embodiments of the present application provide a failure handling mechanism for failure during data storage and a bit reversal failure handling mechanism for bit reversal failure of data stored in a write area in each storage space of a flash memory, and the data storage method provided by the present application is more complete and clear by providing the failure handling mechanism on the basis of the data storage method.
Example four:
in view of the data storage methods provided in the foregoing embodiments, a corresponding data reading method is provided in the embodiments of the present application.
Fig. 4 is a flowchart of a data reading method according to a fourth embodiment of the present application.
As shown in fig. 4, the method includes:
step S401: data read request information is received.
In the embodiment of the application, the provided data reading method firstly receives data reading request information, and the data reading request information carries the data type of data to be read.
Step S402: and acquiring the data type of the data to be read carried by the data reading request information.
Step S403: and determining a storage space corresponding to the data reading request information according to a preset corresponding relation between the data type and the storage space, and taking the storage space as a target reading storage space.
In the embodiment of the application, in the data reading process, data request information is received first, the data type of data to be read carried in the data request information is acquired, then the storage space corresponding to the data reading request information is determined according to the preset corresponding relation between the data type and the storage space, and the storage space is used as a target reading storage space.
Step S404: and searching the writing area with the state identifier representing the valid state in the target reading storage space as the target reading writing area.
In the embodiment of the application, each storage space comprises at least two writing areas, each writing area is provided with a state identifier, the state identifiers represent valid states or invalid states, only one state identifier in the same storage space at the same time represents a valid state, and after a target reading storage space is inquired, the writing area with the state identifier representing the valid state is searched in the target reading storage space and is used as the target reading writing area.
Step S405: valid data is read in the target read-write area.
In the embodiment of the present application, the valid data in the target read storage space refers to the currently latest stored data, such as: in the target writing area, the information of the same file is stored twice in total, and then the information of the file stored for the second time is valid data. However, the above is only a preferred implementation method provided by the embodiments of the present application, and specifically specifies which are valid data, and the inventors can arbitrarily set the data according to their own needs.
Therefore, the embodiment of the present application provides a data reading method based on the data storage method provided by the above embodiment, and the method first receives data reading request information, then determines a storage space corresponding to the data reading request information, and uses the storage space as a target reading storage space, queries a writing area with an effective status identifier in the target reading storage space, and uses the writing area as a target reading writing area, and finally reads effective data in the target reading writing area. The embodiment of the application makes the scheme provided by the application more perfect by a data reading method aiming at a data storage method.
Example five:
fig. 5 is a schematic structural diagram of a data storage device according to a fifth embodiment of the present application.
As shown in fig. 5, the apparatus includes: a data receiving unit 1, a data type determining unit 2 and a storage unit 3.
Wherein, the data receiving unit 1, the data type determining unit 2 and the storage unit 3 are connected in sequence.
The data receiving unit 1 is used for receiving data to be written.
In the embodiment of the present application, the provided data storage device is applied to a flash memory, and the flash memory includes at least one storage space, and when a user needs to store data in the flash memory, that is, there is a data storage requirement, the data receiving unit 1 first receives data to be written sent by the user.
The data type determining unit 2 is connected to the data receiving unit 1, and the data type determining unit 2 determines the data type of the received data to be written.
In the embodiment of the application, in the data storage device, after receiving data to be written, the data type determining unit 2 in the device may determine the data type of the data to be written, and determine the data type of the data to be written mainly by obtaining a type identifier carried by the data to be written, and then determine the data type of the data to be written according to a preset correspondence between the type identifier and the data type.
The storage unit 3 is connected with the data type determining unit 2, and the data to be written are sequentially written into the storage space corresponding to the data type by the storage unit 3.
In the embodiment of the present application, each storage space in the flash memory corresponds to a unique data type, and after determining the data type of the data to be written, the storage unit 3 sequentially writes the data to be written in the storage space corresponding to the data type of the data to be written in the flash memory. The writing of the data to be written in the storage space corresponding to the data type of the data to be written may be sequentially writing the data to be written when there is a blank area in the storage space each time.
Fig. 6 is a schematic structural diagram of another data storage device according to a fifth embodiment of the present application.
As shown in fig. 6, the apparatus includes: the data receiving unit 1, the type identification obtaining unit 21, the data type determination subunit 22, the target storage space determining unit 31, the target writing area searching unit 32, the judging unit 33, and the data writing unit 34.
The data receiving unit 1, the type identifier obtaining unit 21, the data type determining subunit 22, the target storage space determining unit 31, the target writing area searching unit 32, the judging unit 33, and the data writing unit 34 are connected in sequence.
The data receiving unit 1 is used for receiving data to be written.
In the embodiment of the present application, the provided data storage device is applied to a flash memory, and the flash memory includes at least one storage space, and when a user needs to store data in the flash memory, that is, there is a data storage requirement, the data receiving unit 1 first receives data to be written sent by the user.
The type identifier obtaining unit 21 is connected to the data receiving unit 1, and the type identifier obtaining unit 21 obtains a type identifier carried by the received data to be written.
The data type determining subunit 22 is connected to the type identifier obtaining unit 21, and the data type determining subunit 22 determines the data type of the data to be written according to a preset correspondence between the type identifier and the data type.
The target storage space determining unit 31 is connected to the data type determining subunit 22, and the target storage space determining unit 31 determines, according to a preset correspondence between a data type and a storage space, a storage space corresponding to the data type of the data to be written, and uses the storage space as a target storage space.
In this embodiment of the present application, each storage space in the flash memory corresponds to a unique data type, and after determining the data type of the data to be written, the target storage space determining unit 31 determines, according to a preset correspondence between the data type and the storage space, a storage space corresponding to the data type to be written, that is, the storage space in which the data to be written is to be written, and uses the storage space as the target storage space.
The target writing area finding unit 32 is connected to the target storage space determining unit 31, and the target writing area finding unit 32 finds a writing area whose status identifier indicates a valid status, and takes it as a target writing area.
In this embodiment of the present application, each of the storage spaces includes at least two writing areas, and each of the writing areas is provided with a state identifier, where the state identifier represents a valid state or an invalid state, and only one state identifier in the same storage space at the same time represents a valid state. When the storage space corresponding to the data type of the data to be written is determined, the storage space is used as a target storage space, the target writing area searching unit 32 searches a writing area with a state identifier indicating an effective state in the target storage space, and uses the writing area as a target writing area.
The determining unit 33 is connected to the target writing area searching unit 32, and the determining unit 33 determines whether the remaining space of the target writing area satisfies the occupied space of the data to be written.
The data writing unit 34 is connected to the determining unit 33, and when the data writing unit 34 is satisfied, the data to be written is written in a blank area of the target writing area.
When the data is not satisfied, as shown in fig. 7, the specific structure of the data writing unit includes: a write subunit 341, a valid data acquisition unit 342, and an erase unit 343.
The writing subunit 341, the valid data acquiring unit 342, and the erasing unit 343 are connected in sequence.
The valid data obtaining unit 342 is connected to the determining unit 33, and when the remaining space of the target writing area does not satisfy the occupied space of the data to be written, the valid data obtaining unit 342 obtains valid data in the target writing area. In this embodiment of the application, when the remaining space of the target writing area does not satisfy the space occupied by the data to be written, the valid data obtaining unit 342 obtains valid data in the target writing area. The valid data refers to the currently latest stored data, such as: in the target writing area, the information of the same file is stored twice in total, and then the information of the file stored for the second time is valid data. However, the above is only a preferred implementation method provided by the embodiments of the present application, and specifically specifies which are valid data, and the inventors can arbitrarily set the data according to their own needs.
The writing subunit 342 is connected to the valid data acquiring unit 341, and the writing subunit 342 is configured to store the acquired valid data in a next writing area of the target writing area; and writing the data to be written to the target writing area after the valid data stored in the next writing area of the target writing area.
In this embodiment, each of the writing areas in each of the storage spaces is provided with a consecutive number, and a next writing area of the trailing writing area is a leading writing area. After obtaining the valid data in the target writing area, the writing subunit 342 writes the valid data in the writing area corresponding to the number next to the number of the target writing area, and writes the data to be written to the next writing area of the target writing area after the valid data stored in the next writing area.
The erasing unit 343 is connected to the writing subunit 342, and the erasing unit 343 erases all data in the target writing area.
In addition, as shown in fig. 6, the data storage device provided in the embodiment of the present application further includes a failure processing unit 4.
The failure processing unit 4 is connected to the data writing unit 34, and on one hand, the failure processing unit 4 may determine whether a failure occurs in the process of sequentially writing the data to be written in the storage space corresponding to the data type; if so, acquiring a fault identifier; determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type; finally, executing a preset fault processing mechanism corresponding to the fault type;
the failure processing unit 4 may be configured to determine whether a bit reversal failure exists in data in a write area in the flash memory; if so, executing a preset bit reversal fault processing mechanism corresponding to the bit reversal fault.
It can be seen that the embodiments of the present application provide a data storage device, which includes: the data writing device comprises a data receiving unit, a data type determining unit and a storage unit, wherein the data receiving unit is used for receiving data to be written; the data type determining unit is connected with the data receiving unit and determines the data type of the received data to be written; the storage unit is connected with the data type determining unit, and the storage unit sequentially writes the data to be written in the storage space corresponding to the data type. The device is in the data storage in-process, through writing in proper order in memory space and waiting to write in data, when need not write in waiting to write in data at every turn, all carry out once and erase the operation, can solve prior art and carry out data storage's in-process at every turn, all need erase the operation to the data in last effectual SECTOR for it is frequent to erase the operation, and then leads to the problem that the flash memory life-span reduces.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the embodiments or some parts of the embodiments of the present application.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The foregoing is directed to embodiments of the present application and it is noted that numerous modifications and adaptations may be made by those skilled in the art without departing from the principles of the present application and are intended to be within the scope of the present application.

Claims (10)

1. A data storage method is applied to a flash memory, wherein the flash memory comprises at least one storage space, and the method is characterized by comprising the following steps:
receiving data to be written;
determining the data type of the data to be written;
and sequentially writing the data to be written in the storage space corresponding to the data type.
2. The method of claim 1, wherein the determining the data type of the data to be written comprises:
acquiring a type identifier carried by the data to be written;
and determining the data type of the data to be written according to the preset corresponding relation between the type identification and the data type.
3. Method according to claim 2, characterized in that each of said storage spaces comprises at least two writing areas, and that each of said writing areas is provided with a status identifier, said status identifier representing a valid status or an invalid status, and that only one status identifier in the same storage space at a time represents a valid status,
the sequentially writing the data to be written in the storage space corresponding to the data type comprises:
determining a storage space corresponding to the data type of the data to be written according to a preset corresponding relation between the data type and the storage space, and using the storage space as a target storage space;
searching a writing area with a state identifier representing an effective state in the target storage space, and taking the writing area as a target writing area;
judging whether the residual space of the target writing area meets the occupied space of the data to be written;
and when the data is satisfied, writing the data to be written in the blank area of the target writing area.
4. The method according to claim 3, wherein each of the writing areas in each of the storage spaces is provided with consecutive numbers, and a next writing area of a trailing writing area is a leading writing area,
when the remaining space of the target writing area does not satisfy the occupation space of the data to be written, the method further comprises:
obtaining valid data in the target writing area;
storing the valid data in a next write area of the target write area;
writing the data to be written after the valid data stored in the next writing area of the target writing area;
setting a state identifier of the target writing area to a state identifier representing an invalid state;
setting a state identifier in a next writing area of the target writing area to a state identifier representing a valid state;
erasing all data in the target write area.
5. The method of claim 4, further comprising:
judging whether a fault occurs in the process of sequentially writing the data to be written in the storage space corresponding to the data type;
if so, acquiring a fault identifier;
determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type;
executing a preset fault processing mechanism corresponding to the fault type;
or,
judging whether a bit reversal fault exists or not;
if so, executing a preset bit reversal fault processing mechanism corresponding to the bit reversal fault.
6. A data storage device applied to a flash memory, the flash memory including at least one storage space therein, the data storage device comprising: a data receiving unit, a data type determining unit and a storing unit, wherein,
the data receiving unit is used for receiving data to be written;
the data type determining unit is connected with the data receiving unit and used for determining the data type of the data to be written;
and the storage unit is connected with the data type determining unit and is used for sequentially writing the data to be written in the storage space corresponding to the data type.
7. The apparatus of claim 6, wherein the data type determining unit comprises: a type identification obtaining unit and a data type determining subunit, wherein,
the type identification obtaining unit is connected with the data receiving unit and is used for obtaining the type identification carried by the data to be written;
the data type determining subunit is connected to the type identifier obtaining unit and configured to determine the data type of the data to be written according to a preset correspondence between the type identifier and the data type.
8. The apparatus according to claim 7, wherein each of the storage spaces comprises at least two writing areas, and each of the writing areas is provided with a status identifier, the status identifier represents a valid status or an invalid status, and only one status identifier in the same storage space at the same time represents a valid status; each writing area in each storage space is provided with a continuous number, and the next writing area of the tail writing area is a head writing area;
the memory cell includes: a target writing area search unit, a judgment unit, and a data writing unit, wherein,
the target storage space determining unit is connected with the data type determining subunit, and is used for determining a storage space corresponding to the data type of the data to be written according to a preset corresponding relationship between the data type and the storage space, and using the storage space as a target storage space; the target writing area searching unit is connected with the target storage space determining unit and used for searching a writing area with a state identifier representing an effective state and taking the writing area as a target writing area;
the judging unit is connected with the target writing area searching unit and used for judging whether the residual space of the target writing area meets the occupation space of the data to be written;
the data writing unit is connected with the judging unit and is used for writing the data to be written in the blank area of the target writing area when the data writing unit meets the requirement;
the data writing unit includes: the device comprises an effective data acquisition unit, a writing subunit and an erasing unit, wherein:
the valid data acquisition unit is connected with the judgment unit and used for acquiring valid data in the target writing area when the residual space of the target writing area does not meet the occupation space of the data to be written;
the writing subunit is connected to the valid data acquiring unit, and is configured to store the acquired valid data in a next writing area of the target writing area; writing the data to be written into the target writing area after the valid data stored in the next writing area of the target writing area;
the erasing unit is connected with the writing subunit and is used for erasing all data in the target writing area.
9. The apparatus of claim 8, further comprising: a fault handling unit, wherein,
the fault processing unit is used for judging whether faults occur in the process of sequentially writing the data to be written in the storage space corresponding to the data type;
if so, acquiring a fault identifier;
determining the fault type of the fault according to the preset corresponding relation between the fault identifier and the fault type;
executing a preset fault processing mechanism corresponding to the fault type;
or,
the fault processing unit is used for judging whether bit reversal faults exist or not;
if so, executing a preset bit reversal fault processing mechanism corresponding to the bit reversal fault.
10. A data reading method is applied to a flash memory, the flash memory comprises at least one storage space, each storage space comprises at least two writing areas, each writing area is provided with a state identifier, the state identifiers represent valid states or invalid states, and only one state identifier in the same storage space at the same time represents a valid state, the method is characterized by comprising the following steps:
receiving data reading request information;
acquiring the data type of the data to be read carried by the data reading request information;
determining a storage space corresponding to the data reading request information according to a preset corresponding relation between the data type and the storage space, and taking the storage space as a target reading storage space;
searching a writing area with a state identifier representing an effective state in the target reading storage space as a target reading writing area;
and reading valid data in the target read-write area.
CN201310138191.3A 2013-04-19 2013-04-19 A kind of date storage method, memory storage and read method Active CN103268201B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310138191.3A CN103268201B (en) 2013-04-19 2013-04-19 A kind of date storage method, memory storage and read method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310138191.3A CN103268201B (en) 2013-04-19 2013-04-19 A kind of date storage method, memory storage and read method

Publications (2)

Publication Number Publication Date
CN103268201A true CN103268201A (en) 2013-08-28
CN103268201B CN103268201B (en) 2016-02-17

Family

ID=49011836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310138191.3A Active CN103268201B (en) 2013-04-19 2013-04-19 A kind of date storage method, memory storage and read method

Country Status (1)

Country Link
CN (1) CN103268201B (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615546A (en) * 2015-02-13 2015-05-13 小米科技有限责任公司 File data management method and device
CN105760112A (en) * 2016-02-01 2016-07-13 惠州市蓝微新源技术有限公司 Data storage method, reading method and systems for prolonging service life of memory
CN106649138A (en) * 2015-10-13 2017-05-10 株式会社艾库塞尔 Information processing apparatus and method of processing information
CN106816175A (en) * 2015-12-01 2017-06-09 中芯国际集成电路制造(上海)有限公司 The control method and device of memory
CN107015985A (en) * 2016-01-27 2017-08-04 阿里巴巴集团控股有限公司 A kind of data storage and acquisition methods and device
CN107153510A (en) * 2016-03-03 2017-09-12 爱思开海力士有限公司 Memory Controller and the method for managing memory
CN107783732A (en) * 2017-10-30 2018-03-09 郑州云海信息技术有限公司 A kind of data read-write method, system, equipment and computer-readable storage medium
CN109446462A (en) * 2018-10-29 2019-03-08 东软集团股份有限公司 Data monitoring processing method, device, equipment and storage medium based on the page
CN109769005A (en) * 2017-11-09 2019-05-17 宁波方太厨具有限公司 A kind of data cache method and data buffering system of network request
CN109767003A (en) * 2019-01-31 2019-05-17 深兰科技(上海)有限公司 Storage controlling method, device, electronic equipment and the medium of neural network accelerator
CN110515944A (en) * 2019-08-16 2019-11-29 出门问问(苏州)信息科技有限公司 Date storage method, storage medium and electronic equipment based on distributed data base
CN111324554A (en) * 2020-02-18 2020-06-23 日立楼宇技术(广州)有限公司 Management method and device of flash memory data and elevator controller
CN111797089A (en) * 2019-04-09 2020-10-20 Oppo广东移动通信有限公司 Data writing method and device, storage medium and electronic equipment
CN111831590A (en) * 2020-06-05 2020-10-27 嘉兴行适安车联网信息科技有限公司 Algorithm for reliably protecting NVRAM data content from loss
CN112255997A (en) * 2020-10-23 2021-01-22 深圳市元征科技股份有限公司 Vehicle offline diagnosis method and device and computer storage medium
CN113504873A (en) * 2021-05-20 2021-10-15 新华三信息安全技术有限公司 Communication equipment and data storage method thereof
CN113660180A (en) * 2021-07-30 2021-11-16 鹏城实验室 Data storage method, device, terminal and storage medium
WO2023179243A1 (en) * 2022-03-21 2023-09-28 上海美仁半导体有限公司 Data reading/writing method and system, medium, and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1627272A (en) * 2003-12-10 2005-06-15 上海贝豪通讯电子有限公司 Method for managing files in flash memory of mobile terminal
CN101324862A (en) * 2008-05-05 2008-12-17 青岛海信电器股份有限公司 Flash memory storage management method
US20090125753A1 (en) * 2007-11-13 2009-05-14 Anton Joseph Kryka Handling of data storage within a flash media device
CN101446921A (en) * 2008-12-23 2009-06-03 青岛海信宽带多媒体技术股份有限公司 Dynamic storage method of Flash memory
CN101521734A (en) * 2009-03-31 2009-09-02 深圳创维-Rgb电子有限公司 Method, device and television for storing television data
CN101894077A (en) * 2010-06-24 2010-11-24 深圳市江波龙电子有限公司 Data storage method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1627272A (en) * 2003-12-10 2005-06-15 上海贝豪通讯电子有限公司 Method for managing files in flash memory of mobile terminal
US20090125753A1 (en) * 2007-11-13 2009-05-14 Anton Joseph Kryka Handling of data storage within a flash media device
CN101324862A (en) * 2008-05-05 2008-12-17 青岛海信电器股份有限公司 Flash memory storage management method
CN101446921A (en) * 2008-12-23 2009-06-03 青岛海信宽带多媒体技术股份有限公司 Dynamic storage method of Flash memory
CN101521734A (en) * 2009-03-31 2009-09-02 深圳创维-Rgb电子有限公司 Method, device and television for storing television data
CN101894077A (en) * 2010-06-24 2010-11-24 深圳市江波龙电子有限公司 Data storage method and system

Cited By (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615546B (en) * 2015-02-13 2018-04-27 小米科技有限责任公司 file data management method and device
CN104615546A (en) * 2015-02-13 2015-05-13 小米科技有限责任公司 File data management method and device
CN106649138A (en) * 2015-10-13 2017-05-10 株式会社艾库塞尔 Information processing apparatus and method of processing information
CN106816175A (en) * 2015-12-01 2017-06-09 中芯国际集成电路制造(上海)有限公司 The control method and device of memory
CN107015985A (en) * 2016-01-27 2017-08-04 阿里巴巴集团控股有限公司 A kind of data storage and acquisition methods and device
CN105760112A (en) * 2016-02-01 2016-07-13 惠州市蓝微新源技术有限公司 Data storage method, reading method and systems for prolonging service life of memory
KR20170103200A (en) * 2016-03-03 2017-09-13 에스케이하이닉스 주식회사 Method for managing memory
CN107153510A (en) * 2016-03-03 2017-09-12 爱思开海力士有限公司 Memory Controller and the method for managing memory
KR102652293B1 (en) * 2016-03-03 2024-03-29 에스케이하이닉스 주식회사 Method for managing memory
CN107153510B (en) * 2016-03-03 2020-09-08 爱思开海力士有限公司 Memory controller and method for managing memory
CN107783732A (en) * 2017-10-30 2018-03-09 郑州云海信息技术有限公司 A kind of data read-write method, system, equipment and computer-readable storage medium
CN109769005A (en) * 2017-11-09 2019-05-17 宁波方太厨具有限公司 A kind of data cache method and data buffering system of network request
CN109446462A (en) * 2018-10-29 2019-03-08 东软集团股份有限公司 Data monitoring processing method, device, equipment and storage medium based on the page
CN109767003A (en) * 2019-01-31 2019-05-17 深兰科技(上海)有限公司 Storage controlling method, device, electronic equipment and the medium of neural network accelerator
CN111797089A (en) * 2019-04-09 2020-10-20 Oppo广东移动通信有限公司 Data writing method and device, storage medium and electronic equipment
CN110515944A (en) * 2019-08-16 2019-11-29 出门问问(苏州)信息科技有限公司 Date storage method, storage medium and electronic equipment based on distributed data base
CN111324554B (en) * 2020-02-18 2022-03-18 日立楼宇技术(广州)有限公司 Management method and device of flash memory data and elevator controller
CN111324554A (en) * 2020-02-18 2020-06-23 日立楼宇技术(广州)有限公司 Management method and device of flash memory data and elevator controller
CN111831590A (en) * 2020-06-05 2020-10-27 嘉兴行适安车联网信息科技有限公司 Algorithm for reliably protecting NVRAM data content from loss
CN112255997A (en) * 2020-10-23 2021-01-22 深圳市元征科技股份有限公司 Vehicle offline diagnosis method and device and computer storage medium
CN113504873A (en) * 2021-05-20 2021-10-15 新华三信息安全技术有限公司 Communication equipment and data storage method thereof
CN113660180A (en) * 2021-07-30 2021-11-16 鹏城实验室 Data storage method, device, terminal and storage medium
CN113660180B (en) * 2021-07-30 2023-11-28 鹏城实验室 Data storage method, device, terminal and storage medium
WO2023179243A1 (en) * 2022-03-21 2023-09-28 上海美仁半导体有限公司 Data reading/writing method and system, medium, and device

Also Published As

Publication number Publication date
CN103268201B (en) 2016-02-17

Similar Documents

Publication Publication Date Title
CN103268201B (en) A kind of date storage method, memory storage and read method
US6711663B2 (en) Algorithm of flash memory capable of quickly building table and preventing improper operation and control system thereof
CN110018989B (en) Snapshot comparison method and device
CN110673789B (en) Metadata storage management method, device, equipment and storage medium of solid state disk
KR101933766B1 (en) Methods and systems for improving flash memory flushing
US11422726B1 (en) Efficient storage device data move operation based on priority of garbage collection command
CN108829342B (en) Log storage method, system and storage device
CN104461390A (en) Method and device for writing data into imbricate magnetic recording SMR hard disk
CN104808951A (en) Storage control method and device
CN112631516B (en) FLASH file management system with service life management function
CN104978148A (en) Data writing method and device and data reading method and device
CN112835528B (en) Dirty page refreshing method and device, electronic equipment and storage medium
CN110083379A (en) A kind of server component upgrade method and relevant apparatus
CN104036823A (en) Symmetrical Data Replication For Failure Management In Non-volatile Memory Systems
CN112965661A (en) Data storage method, device, equipment and storage medium
CN112527276B (en) Data updating method and device in visual programming tool and terminal equipment
CN108959517B (en) File management method and device and electronic equipment
CN110767258B (en) Data erasure command test method and related device
CN105573862B (en) Method and equipment for recovering file system
CN103389943A (en) Control device, storage device, and storage control method
CN114328280A (en) Log access method and device based on Flash, storage medium and terminal
CN112306379A (en) Data movement recovery method and device, electronic equipment and storage medium
CN113703671B (en) Data block erasing method and related device
CN111984460B (en) Metadata recovery method and device
CN109165172A (en) Caching data processing method and relevant device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 4 / F, building 1, No.14 Jiuxianqiao Road, Chaoyang District, Beijing 100020

Patentee after: Beijing Jingwei Hirain Technologies Co.,Inc.

Address before: 100101 Beijing city Chaoyang District Anxiang Beili 11 B block 8 layer

Patentee before: Beijing Jingwei HiRain Technologies Co.,Ltd.