Flash memory data management system and method, flash memory chip and storage device
Technical Field
The invention belongs to the technical field of storage, and particularly relates to a flash memory data management system and method, a flash memory chip and a storage device.
Background
In an existing Flash Translation Layer (FTL) algorithm, a Block (Block) with a large number of Invalid pages (Invalid pages) is generally selected for merging in a Garbagegistration (GC). This causes problems in that when the flash Memory Block (Block Memory) has too many Invalid pages (Invalid pages), it takes much time to integrate data, and some compatibility problems with the Host (Host) often arise.
Disclosure of Invention
The embodiment of the invention provides a flash memory data management system and method, a flash memory chip and a storage device, and aims to solve the existing problems.
In an embodiment of the present invention, there is provided a flash memory data management system, which includes a flash memory controller and a flash memory,
the flash memory controller is used for classifying external data when the external data are written, and distinguishing continuous data and random data;
the flash memory comprises a system area, a temporary storage area and a data area,
the system area includes a random block for storing the random data and a continuous block for storing the continuous data;
the temporary storage area is used for storing the effective pages in the random block when the random block is sorted by the flash memory controller, and when the effective page quantity of the temporary storage area meets the set condition, the effective pages are transferred to the data area.
In the embodiment of the invention, the flash controller distinguishes continuous data from random data according to the data length of the external data.
In an embodiment of the present invention, when the data in the continuous block is full, the flash memory controller moves the data in the continuous block to the data area and releases the continuous block.
In the embodiment of the present invention, when the data in the random block is full, the flash memory controller sorts the valid pages of the random block and stores the valid pages into the temporary storage area.
In an embodiment of the present invention, when the number of valid pages in the temporary storage area does not reach the set number, the flash memory controller releases the random block and moves the valid pages in the temporary storage area to the random block.
In an embodiment of the present invention, a flash memory data management method is further provided, where the flash memory includes a system area, a temporary storage area, and a data area, and the method includes:
a pretreatment step: when external data is written, classifying the external data to distinguish continuous data and random data;
a data storage step: storing the classified external data into the system area, wherein the system area comprises a random block and a continuous block, the random block stores the random data, and the continuous block stores the continuous data;
data arrangement: sorting the effective pages in the random block, and storing the effective pages into the temporary storage area;
a data unloading step: and judging whether the number of the effective pages in the temporary storage area meets a set condition, and when the number of the effective pages meets the set condition, transferring the effective pages to the data area.
In the preprocessing step, continuous data and random data are distinguished according to the data length of the external data.
In the data storage step, when the data in the continuous block is filled, the data in the continuous block is moved to the data area, and the continuous block is released.
In the data sorting step, after the valid pages in the temporary storage area are moved to the data area, the random blocks and the temporary storage area are released.
In the data transfer step, when the number of the effective pages in the temporary storage area does not reach the set number, the random block is released, and the effective pages in the temporary storage area are moved to the random block.
In an embodiment of the present invention, a flash memory chip is further provided, where the flash memory chip includes at least one processor, a memory, and an interface, and the at least one processor, the memory, and the interface are all connected through a bus;
the memory stores computer-executable instructions;
the at least one processor executes computer-executable instructions stored in the memory, so that the flash memory chip executes the flash memory data management method.
In an embodiment of the present invention, a storage device is further provided, where the storage device stores instructions, and the instructions, when executed by a processor, implement the steps of the above-mentioned flash data management method.
Compared with the prior art, in the technical scheme of the invention, the storage space of the flash memory is divided into a system area, a temporary storage area and a data area, when external data is written, the external data is classified to distinguish continuous data and random data, when the data is written, the data is firstly written into the system area, the temporary storage area is adopted to arrange effective pages of the random data in the temporary storage area, and finally the arranged data is stored into the data area, so that the data in the storage space is well ordered, more invalid pages can not exist, and the data arrangement speed and the system compatibility are improved.
Drawings
Fig. 1 is a schematic structural diagram of a flash memory data management system according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a state of a flash memory data management system for organizing random blocks in a system area according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a state of a flash memory data management system for organizing random blocks in a system area according to an embodiment of the present invention;
FIG. 4 is a flowchart of a flash memory data management method according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a flash memory chip according to a third embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The following detailed description of the implementation of the present invention is made with reference to specific embodiments:
example one
In this embodiment, a flash memory data management system and a method of managing a memory in the system are described.
Fig. 1 shows a schematic structural diagram of a flash data management system according to an embodiment of the present invention, where the flash data management system includes a flash controller 10 and a flash memory 20, and the flash memory 20 is divided into a system area 21, a temporary storage area 22, and a data area 23. The details will be described below.
The flash memory controller 10 is configured to classify external data when the external data is written, and distinguish continuous data from random data. When external data is written, the external data may be scattered data or may be continuous data of a whole block. When classifying the external data, the flash memory controller 10 distinguishes continuous data from random data according to the data length of the external data, where the external data is scattered data and classified as random data, and the external data is a whole block of data and classified as continuous data.
The system area 21 includes a random block 211 for storing the random data and a continuous block 212 for storing the continuous data, the random block 211 being used for storing the random data. After distinguishing the continuous data and the random data from the external data, the flash memory controller 10 writes the random data into the random block 211, and writes the continuous data into the continuous block 212. When one of the continuous blocks 212 in the system area 21 is full, the flash controller 10 moves the continuous data in the continuous block 212 to the data area 23 and releases the continuous block 212.
The temporary storage area 22 is used for the flash memory controller 10 to store the valid pages in the random block 211 when the random block 211 is sorted, and when the number of the valid pages in the temporary storage area 22 meets the set condition, the valid pages are transferred to the data area 23
The data area 23 is used for storing the valid pages sorted out from the random block 211 and the continuous data in the continuous block 212.
Fig. 2 and fig. 3 show a process of arranging the random block 221 in the system area 21 by the flash data management system according to an embodiment of the present invention. When the random block 211 in the system area 21 is full, the flash memory controller 10 sorts the full random block 211, puts the valid pages of the random block 211 into the temporary storage area 22, and counts the number of the valid pages, and when the number of the valid pages in the temporary storage area 22 does not reach the set number, the flash memory controller 10 releases the random block 211, and moves the valid pages in the temporary storage area 22 to the random block 211, and the random block 211 continues to receive receipts. When the number of valid pages in the temporary storage area 22 satisfies a set condition, the flash memory controller 10 transfers the valid pages to the data area 23 and releases the temporary storage area 22.
By adopting the flash memory data management system, the data in the memory space is well ordered, and more invalid pages can not exist, so that the data sorting speed and the system compatibility are improved.
Example two
Fig. 4 shows a flow of a flash memory data management method according to a second embodiment of the present invention, in this embodiment, a flash memory includes a system area, a temporary storage area, and a data area, and the method is implemented by using steps S1 to S4. The details will be described below.
Step S1, preprocessing step: when external data is written, the external data is classified to distinguish continuous data from random data.
It should be noted that, when external data is written, the external data may be scattered data or continuous data in whole block, and therefore, in the preprocessing step, the continuous data and the random data are distinguished according to the data length of the external data, and when the external data is scattered data, the external data is classified as random data, and when the external data is data in whole block, the external data is classified as continuous data.
Step S2, data storage step: and storing the classified external data into the system area. Wherein the system area includes a random block into which the random data is stored and a continuous block into which the continuous data is stored.
In the data storage step, when the data in the continuous block is full, the data in the continuous block is moved to the data area, and the continuous block is released; when the data in the random block is full, step S3 is started to sort the valid pages in the random block.
Step S3, data arrangement step: and arranging the effective pages in the random block, and storing the effective pages into the temporary storage area.
It should be noted that in the data sorting step, after the valid page in the temporary storage area is moved to the data area, the random block and the temporary storage area are released.
Step S4, data dump step: and judging whether the number of the effective pages in the temporary storage area meets a set condition, and when the number of the effective pages meets the set condition, transferring the effective pages to the data area.
It should be noted that, in the data transfer step, when the number of valid pages in the temporary storage area does not reach the set number, the random block is released, the valid pages in the temporary storage area are moved to the random block, and the random block continues to receive external random data.
After the processing of the steps, the data in the memory space are well ordered, and a plurality of invalid pages are avoided, so that the data sorting speed is increased, and the system compatibility is improved.
EXAMPLE III
As shown in fig. 5, a third embodiment of the present invention provides a flash memory chip in the third embodiment of the present invention, which includes at least one processor 310, a memory 320 and an interface 330, wherein the at least one processor 310, the memory 320 and the interface 330 are all connected by a bus;
the memory 320 stores computer-executable instructions;
the at least one processor 310 executes the computer executable instructions stored in the memory 320, so that the flash memory chip executes the flash memory data management method according to the second embodiment.
In an embodiment of the present invention, a storage device is further provided, where the storage device stores instructions, and the instructions, when executed by a processor, implement the steps of the flash memory data management method according to the second embodiment.
In summary, by using the flash memory data management system, method, flash memory chip and storage device of the present invention, the storage space of the flash memory is divided into the system area, the temporary storage area and the data area, when external data is written, the external data is classified to distinguish continuous data and random data, when data is written, the data is written into the system area first, and the temporary storage area is used to sort the valid pages of the random data in the temporary storage area, and finally the sorted data is stored into the data area, so that the data in the memory space is well ordered, and there are no more invalid pages, thereby improving the speed of sorting data and the compatibility of the system.
Notably, one of ordinary skill in the art will understand that: the steps or part of the steps for implementing the above method embodiments may be implemented by hardware related to program instructions, the program may be stored in a computer-readable storage medium, and when executed, the program performs the steps including the above method embodiments, and the storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.